Skip to content

Commit 9aee1ee

Browse files
committed
dw-dma: change to use runtime_shared heap for lli buffer
The lli structs are used by both DSP and DMAC, allocate them from the runtime_shared heap to avoid being corrupted by cache writing back. This helps to fix a lot of DMA xrun issue according to the validation. Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
1 parent 475a48b commit 9aee1ee

2 files changed

Lines changed: 5 additions & 23 deletions

File tree

  • src

src/drivers/dw/dma.c

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,6 @@ static int dw_dma_stop(struct dma_chan_data *channel)
437437
lli->ctrl_hi &= ~DW_CTLH_DONE(1);
438438
lli++;
439439
}
440-
441-
dcache_writeback_region(dw_chan->lli,
442-
sizeof(struct dw_lli) * channel->desc_count);
443440
#endif
444441

445442
/* disable linear link position */
@@ -557,9 +554,9 @@ static int dw_dma_set_config(struct dma_chan_data *channel,
557554
if (dw_chan->lli)
558555
rfree(dw_chan->lli);
559556

560-
dw_chan->lli = rballoc_align(0, SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_DMA,
561-
sizeof(struct dw_lli) * channel->desc_count,
562-
PLATFORM_DCACHE_ALIGN);
557+
dw_chan->lli = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0,
558+
SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_DMA,
559+
sizeof(struct dw_lli) * channel->desc_count);
563560
if (!dw_chan->lli) {
564561
tr_err(&dwdma_tr, "dw_dma_set_config(): dma %d channel %d lli alloc failed",
565562
channel->dma->plat_data.id,
@@ -767,10 +764,6 @@ static int dw_dma_set_config(struct dma_chan_data *channel,
767764
#endif
768765
}
769766

770-
/* write back descriptors so DMA engine can read them directly */
771-
dcache_writeback_region(dw_chan->lli,
772-
sizeof(struct dw_lli) * channel->desc_count);
773-
774767
channel->status = COMP_STATE_PREPARE;
775768
dw_chan->lli_current = dw_chan->lli;
776769

@@ -810,7 +803,7 @@ static void dw_dma_verify_transfer(struct dma_chan_data *channel,
810803
#if defined __ZEPHYR__
811804
int i;
812805
#else
813-
struct dw_lli *lli = platform_dw_dma_lli_get(dw_chan->lli_current);
806+
struct dw_lli *lli = dw_chan->lli_current;
814807
#endif
815808
switch (next->status) {
816809
case DMA_CB_STATUS_END:
@@ -823,20 +816,14 @@ static void dw_dma_verify_transfer(struct dma_chan_data *channel,
823816
* sure the cache is coherent between DSP and DMAC.
824817
*/
825818
#if defined __ZEPHYR__
826-
dcache_invalidate_region(dw_chan->lli,
827-
sizeof(struct dw_lli) * channel->desc_count);
828-
829819
for (i = 0; i < channel->desc_count; i++)
830820
dw_chan->lli[i].ctrl_hi &= ~DW_CTLH_DONE(1);
831-
832-
dcache_writeback_region(dw_chan->lli,
833-
sizeof(struct dw_lli) * channel->desc_count);
834821
#else
835822
while (lli->ctrl_hi & DW_CTLH_DONE(1)) {
836823
lli->ctrl_hi &= ~DW_CTLH_DONE(1);
837824
dw_chan->lli_current =
838825
(struct dw_lli *)dw_chan->lli_current->llp;
839-
lli = platform_dw_dma_lli_get(dw_chan->lli_current);
826+
lli = dw_chan->lli_current;
840827
}
841828
#endif
842829
break;

src/platform/intel/cavs/include/cavs/drivers/dw-dma.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,6 @@ static inline void platform_dw_dma_llp_disable(struct dma *dma,
8585
shim_read(DW_CHLLPC(dma, chan)) & ~SHIM_GPDMA_CHLLPC_EN);
8686
}
8787

88-
static inline struct dw_lli *platform_dw_dma_lli_get(struct dw_lli *lli)
89-
{
90-
return cache_to_uncache(lli);
91-
}
92-
9388
#endif /* __CAVS_LIB_DW_DMA_H__ */
9489

9590
#else

0 commit comments

Comments
 (0)