Skip to content

Commit 2dbedef

Browse files
committed
treewide: zephyr: add sof_ prefix to dma_get/put()
Add "sof_" namespace to dma_get()/put() calls in and modify all uses of the interface for builds with native Zephyr drivers. Keep the old name for XTOS builds. This reduces the amount of code that needs to be touched, and in XTOS code, there is no confusion with the namespaces as all dma_foo() calls are to SOF DMA layer. Link: #9561 Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent b6a48af commit 2dbedef

File tree

9 files changed

+34
-23
lines changed

9 files changed

+34
-23
lines changed

src/audio/chain_dma.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,9 @@ static void chain_release(struct comp_dev *dev)
392392
struct chain_dma_data *cd = comp_get_drvdata(dev);
393393

394394
dma_release_channel(cd->chan_host->dma->z_dev, cd->chan_host->index);
395-
dma_put(cd->dma_host);
395+
sof_dma_put(cd->dma_host);
396396
dma_release_channel(cd->chan_link->dma->z_dev, cd->chan_link->index);
397-
dma_put(cd->dma_link);
397+
sof_dma_put(cd->dma_link);
398398

399399
if (cd->dma_buffer) {
400400
buffer_free(cd->dma_buffer);
@@ -538,7 +538,7 @@ static int chain_task_init(struct comp_dev *dev, uint8_t host_dma_id, uint8_t li
538538
dir = (cd->stream_direction == SOF_IPC_STREAM_PLAYBACK) ?
539539
SOF_DMA_DIR_HMEM_TO_LMEM : SOF_DMA_DIR_LMEM_TO_HMEM;
540540

541-
cd->dma_host = dma_get(dir, 0, SOF_DMA_DEV_HOST, SOF_DMA_ACCESS_SHARED);
541+
cd->dma_host = sof_dma_get(dir, 0, SOF_DMA_DEV_HOST, SOF_DMA_ACCESS_SHARED);
542542
if (!cd->dma_host) {
543543
comp_err(dev, "chain_task_init(): dma_get() returned NULL");
544544
return -EINVAL;
@@ -547,9 +547,9 @@ static int chain_task_init(struct comp_dev *dev, uint8_t host_dma_id, uint8_t li
547547
dir = (cd->stream_direction == SOF_IPC_STREAM_PLAYBACK) ?
548548
SOF_DMA_DIR_MEM_TO_DEV : SOF_DMA_DIR_DEV_TO_MEM;
549549

550-
cd->dma_link = dma_get(dir, SOF_DMA_CAP_HDA, SOF_DMA_DEV_HDA, SOF_DMA_ACCESS_SHARED);
550+
cd->dma_link = sof_dma_get(dir, SOF_DMA_CAP_HDA, SOF_DMA_DEV_HDA, SOF_DMA_ACCESS_SHARED);
551551
if (!cd->dma_link) {
552-
dma_put(cd->dma_host);
552+
sof_dma_put(cd->dma_host);
553553
comp_err(dev, "chain_task_init(): dma_get() returned NULL");
554554
return -EINVAL;
555555
}
@@ -610,8 +610,8 @@ static int chain_task_init(struct comp_dev *dev, uint8_t host_dma_id, uint8_t li
610610

611611
return 0;
612612
error:
613-
dma_put(cd->dma_host);
614-
dma_put(cd->dma_link);
613+
sof_dma_put(cd->dma_host);
614+
sof_dma_put(cd->dma_link);
615615
return ret;
616616
}
617617

src/audio/dai-zephyr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ int dai_common_new(struct dai_data *dd, struct comp_dev *dev,
479479
dir = dai_cfg->direction == SOF_IPC_STREAM_PLAYBACK ?
480480
SOF_DMA_DIR_MEM_TO_DEV : SOF_DMA_DIR_DEV_TO_MEM;
481481

482-
dd->dma = dma_get(dir, dd->dai->dma_caps, dd->dai->dma_dev, SOF_DMA_ACCESS_SHARED);
482+
dd->dma = sof_dma_get(dir, dd->dai->dma_caps, dd->dai->dma_dev, SOF_DMA_ACCESS_SHARED);
483483
if (!dd->dma) {
484484
dai_put(dd->dai);
485485
comp_err(dev, "dma_get() failed to get shared access to DMA.");
@@ -591,7 +591,7 @@ void dai_common_free(struct dai_data *dd)
591591
dd->chan->dev_data = NULL;
592592
}
593593

594-
dma_put(dd->dma);
594+
sof_dma_put(dd->dma);
595595

596596
dai_release_llp_slot(dd);
597597

src/audio/host-zephyr.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ int host_common_new(struct host_data *hd, struct comp_dev *dev,
614614
dir = hd->ipc_host.direction == SOF_IPC_STREAM_PLAYBACK ?
615615
SOF_DMA_DIR_HMEM_TO_LMEM : SOF_DMA_DIR_LMEM_TO_HMEM;
616616

617-
hd->dma = dma_get(dir, 0, SOF_DMA_DEV_HOST, SOF_DMA_ACCESS_SHARED);
617+
hd->dma = sof_dma_get(dir, 0, SOF_DMA_DEV_HOST, SOF_DMA_ACCESS_SHARED);
618618
if (!hd->dma) {
619619
comp_err(dev, "dma_get() returned NULL");
620620
return -ENODEV;
@@ -630,7 +630,7 @@ int host_common_new(struct host_data *hd, struct comp_dev *dev,
630630
hd->msg = ipc_msg_init(hd->posn.rhdr.hdr.cmd, sizeof(hd->posn));
631631
if (!hd->msg) {
632632
comp_err(dev, "ipc_msg_init failed");
633-
dma_put(hd->dma);
633+
sof_dma_put(hd->dma);
634634
return -ENOMEM;
635635
}
636636
hd->chan = NULL;
@@ -678,7 +678,7 @@ static struct comp_dev *host_new(const struct comp_driver *drv,
678678

679679
void host_common_free(struct host_data *hd)
680680
{
681-
dma_put(hd->dma);
681+
sof_dma_put(hd->dma);
682682

683683
ipc_msg_free(hd->msg);
684684
dma_sg_free(&hd->config.elem_array);

src/drivers/imx/ipc.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,13 @@ int platform_ipc_init(struct ipc *ipc)
207207
PLATFORM_PAGE_TABLE_SIZE);
208208
if (iipc->dh_buffer.page_table)
209209
bzero(iipc->dh_buffer.page_table, PLATFORM_PAGE_TABLE_SIZE);
210+
#if CONFIG_ZEPHYR_NATIVE_DRIVERS
211+
iipc->dh_buffer.dmac = sof_dma_get(SOF_DMA_DIR_HMEM_TO_LMEM, 0, SOF_DMA_DEV_HOST,
212+
SOF_DMA_ACCESS_SHARED);
213+
#else
210214
iipc->dh_buffer.dmac = dma_get(SOF_DMA_DIR_HMEM_TO_LMEM, 0, SOF_DMA_DEV_HOST,
211215
SOF_DMA_ACCESS_SHARED);
216+
#endif
212217
if (!iipc->dh_buffer.dmac) {
213218
tr_err(&ipc_tr, "Unable to find DMA for host page table");
214219
sof_panic(SOF_IPC_PANIC_IPC);

src/lib/dma.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ DECLARE_TR_CTX(dma_tr, SOF_UUID(dma_uuid), LOG_LEVEL_INFO);
3030
#if CONFIG_ZEPHYR_NATIVE_DRIVERS
3131
static int dma_init(struct dma *dma);
3232

33-
struct dma *dma_get(uint32_t dir, uint32_t cap, uint32_t dev, uint32_t flags)
33+
struct dma *sof_dma_get(uint32_t dir, uint32_t cap, uint32_t dev, uint32_t flags)
3434
{
3535
const struct dma_info *info = dma_info_get();
3636
int users, ret = 0;
@@ -123,7 +123,7 @@ struct dma *dma_get(uint32_t dir, uint32_t cap, uint32_t dev, uint32_t flags)
123123
return !ret ? dmin : NULL;
124124
}
125125

126-
void dma_put(struct dma *dma)
126+
void sof_dma_put(struct dma *dma)
127127
{
128128
k_spinlock_key_t key;
129129

@@ -162,6 +162,8 @@ static int dma_init(struct dma *dma)
162162

163163
return 0;
164164
}
165+
EXPORT_SYMBOL(sof_dma_get);
166+
EXPORT_SYMBOL(sof_dma_put);
165167
#else
166168
struct dma *dma_get(uint32_t dir, uint32_t cap, uint32_t dev, uint32_t flags)
167169
{
@@ -278,9 +280,9 @@ void dma_put(struct dma *dma)
278280
dma, dma->sref);
279281
k_spin_unlock(&dma->lock, key);
280282
}
281-
#endif
282283
EXPORT_SYMBOL(dma_get);
283284
EXPORT_SYMBOL(dma_put);
285+
#endif
284286

285287
int dma_sg_alloc(struct dma_sg_elem_array *elem_array,
286288
enum mem_zone zone,

src/library_manager/lib_manager.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,8 @@ static int lib_manager_dma_init(struct lib_manager_dma_ext *dma_ext, uint32_t dm
746746
/* Initialize dma_ext with zeros */
747747
memset(dma_ext, 0, sizeof(struct lib_manager_dma_ext));
748748
/* request DMA in the dir HMEM->LMEM */
749-
dma_ext->dma = dma_get(SOF_DMA_DIR_HMEM_TO_LMEM, 0, SOF_DMA_DEV_HOST,
750-
SOF_DMA_ACCESS_EXCLUSIVE);
749+
dma_ext->dma = sof_dma_get(SOF_DMA_DIR_HMEM_TO_LMEM, 0, SOF_DMA_DEV_HOST,
750+
SOF_DMA_ACCESS_EXCLUSIVE);
751751
if (!dma_ext->dma) {
752752
tr_err(&lib_manager_tr,
753753
"lib_manager_dma_init(): dma_ext->dma = NULL");
@@ -774,7 +774,7 @@ static int lib_manager_dma_deinit(struct lib_manager_dma_ext *dma_ext, uint32_t
774774
if (dma_ext->dma->z_dev)
775775
dma_release_channel(dma_ext->dma->z_dev, dma_id);
776776

777-
dma_put(dma_ext->dma);
777+
sof_dma_put(dma_ext->dma);
778778
}
779779
return 0;
780780
}

src/probe/probe.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ static int probe_dma_init(struct probe_dma_ext *dma, uint32_t direction)
198198
channel = ((union ipc4_connector_node_id)dma->stream_tag).f.v_index;
199199

200200
/* request DMA in the dir LMEM->HMEM with shared access */
201-
dma->dc.dmac = dma_get(direction, 0, SOF_DMA_DEV_HOST,
202-
SOF_DMA_ACCESS_SHARED);
201+
dma->dc.dmac = sof_dma_get(direction, 0, SOF_DMA_DEV_HOST,
202+
SOF_DMA_ACCESS_SHARED);
203203
if (!dma->dc.dmac) {
204204
tr_err(&pr_tr, "probe_dma_init(): dma->dc.dmac = NULL");
205205
return -ENODEV;
@@ -267,10 +267,11 @@ static int probe_dma_deinit(struct probe_dma_ext *dma)
267267
}
268268
#if CONFIG_ZEPHYR_NATIVE_DRIVERS
269269
dma_release_channel(dma->dc.dmac->z_dev, dma->dc.chan->index);
270+
sof_dma_put(dma->dc.dmac);
270271
#else
271272
dma_channel_put_legacy(dma->dc.chan);
272-
#endif
273273
dma_put(dma->dc.dmac);
274+
#endif
274275

275276
rfree((void *)dma->dmapb.addr);
276277
dma->dmapb.addr = 0;

zephyr/include/sof/lib/dma-legacy.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
#define DMA_CHAN_INVALID SOF_DMA_CHAN_INVALID
2828
#define DMA_CORE_INVALID SOF_DMA_CORE_INVALID
2929

30+
struct dma *dma_get(uint32_t dir, uint32_t caps, uint32_t dev, uint32_t flags);
31+
void dma_put(struct dma *dma);
32+
3033
enum dma_cb_status {
3134
DMA_CB_STATUS_RELOAD = 0,
3235
DMA_CB_STATUS_END,

zephyr/include/sof/lib/dma.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,14 +253,14 @@ int dmac_init(struct sof *sof);
253253
* For exclusive access, ret DMAC with no channels draining.
254254
* For shared access, ret DMAC with the least number of channels draining.
255255
*/
256-
struct dma *dma_get(uint32_t dir, uint32_t caps, uint32_t dev, uint32_t flags);
256+
struct dma *sof_dma_get(uint32_t dir, uint32_t caps, uint32_t dev, uint32_t flags);
257257

258258
/**
259259
* \brief API to release a platform DMAC.
260260
*
261261
* @param[in] dma DMAC to relese.
262262
*/
263-
void dma_put(struct dma *dma);
263+
void sof_dma_put(struct dma *dma);
264264

265265
#ifndef CONFIG_ZEPHYR_NATIVE_DRIVERS
266266
#include "dma-legacy.h"

0 commit comments

Comments
 (0)