From 3bf525d6b77727937112a35767ad4621b7a74282 Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Fri, 26 Jan 2024 19:03:35 +0200 Subject: [PATCH] chain_dma: workaround for failed DMA stop on pause/stop Starting with Zephyr commit e021ccfc745221c6 ("drivers: dma: intel-adsp-hda: add delay to stop host dma"), the pause-resume sof-test cases started failing on Intel cAVS2.5 platforms. Add a delay loop around DMA stop code in chain DMA to workaround the issue while a proper fix is under investigation. This allows to resume integration of newer Zephyr versions to SOF and ensure we detect any new regressions in time. Link: https://github.com/thesofproject/sof/issues/8792 Signed-off-by: Kai Vehmanen --- src/audio/chain_dma.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/audio/chain_dma.c b/src/audio/chain_dma.c index 696973146404..99e8502f8bd5 100644 --- a/src/audio/chain_dma.c +++ b/src/audio/chain_dma.c @@ -121,9 +121,28 @@ static int chain_host_stop(struct comp_dev *dev) int err; err = dma_stop(cd->chan_host->dma->z_dev, cd->chan_host->index); - if (err < 0) + if (err < 0) { + if (err == -EBUSY) { + int retries = 100; + + comp_warn(dev, "dma_stop() fail chan_index = %u, retrying...", + cd->chan_link->index); + + /* + * FIXME: ugly workaround for + * https://github.com/thesofproject/sof/issues/8686 + */ + while (err == -EBUSY && --retries) { + k_busy_wait(10); + err = dma_stop(cd->chan_link->dma->z_dev, cd->chan_link->index); + if (!err) + goto out; + } + } return err; +} +out: comp_info(dev, "chain_host_stop(): dma_stop() host chan_index = %u", cd->chan_host->index);