All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cezary Rojewski <cezary.rojewski@intel.com>
To: alsa-devel@alsa-project.org
Cc: Kevin Tian <kevin.tian@intel.com>,
	Cezary Rojewski <cezary.rojewski@intel.com>,
	broonie@kernel.org, Dave Jiang <dave.jiang@intel.com>,
	tiwai@suse.com
Subject: [PATCH 1/5] ASoC: Intel: catpt: Test dmaengine_submit() result before moving on
Date: Thu, 16 Dec 2021 12:57:39 +0100	[thread overview]
Message-ID: <20211216115743.2130622-2-cezary.rojewski@intel.com> (raw)
In-Reply-To: <20211216115743.2130622-1-cezary.rojewski@intel.com>

After calling dmaengine_submit(), the submitted transfer descriptor
belongs to the DMA engine. Pointer to that descriptor may no longer be
valid after the call and should be tested before awaiting transfer
completion.

Reported-by: Kevin Tian <kevin.tian@intel.com>
Suggested-by: Dave Jiang <dave.jiang@intel.com>
Fixes: 4fac9b31d0b9 ("ASoC: Intel: Add catpt base members")
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
 sound/soc/intel/catpt/dsp.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/sound/soc/intel/catpt/dsp.c b/sound/soc/intel/catpt/dsp.c
index 9c5fd18f2600..346bec000306 100644
--- a/sound/soc/intel/catpt/dsp.c
+++ b/sound/soc/intel/catpt/dsp.c
@@ -65,6 +65,7 @@ static int catpt_dma_memcpy(struct catpt_dev *cdev, struct dma_chan *chan,
 {
 	struct dma_async_tx_descriptor *desc;
 	enum dma_status status;
+	int ret;
 
 	desc = dmaengine_prep_dma_memcpy(chan, dst_addr, src_addr, size,
 					 DMA_CTRL_ACK);
@@ -77,13 +78,22 @@ static int catpt_dma_memcpy(struct catpt_dev *cdev, struct dma_chan *chan,
 	catpt_updatel_shim(cdev, HMDC,
 			   CATPT_HMDC_HDDA(CATPT_DMA_DEVID, chan->chan_id),
 			   CATPT_HMDC_HDDA(CATPT_DMA_DEVID, chan->chan_id));
-	dmaengine_submit(desc);
+
+	ret = dma_submit_error(dmaengine_submit(desc));
+	if (ret) {
+		dev_err(cdev->dev, "submit tx failed: %d\n", ret);
+		goto clear_hdda;
+	}
+
 	status = dma_wait_for_async_tx(desc);
+	ret = (status == DMA_COMPLETE) ? 0 : -EPROTO;
+
+clear_hdda:
 	/* regardless of status, disable access to HOST memory in demand mode */
 	catpt_updatel_shim(cdev, HMDC,
 			   CATPT_HMDC_HDDA(CATPT_DMA_DEVID, chan->chan_id), 0);
 
-	return (status == DMA_COMPLETE) ? 0 : -EPROTO;
+	return ret;
 }
 
 int catpt_dma_memcpy_todsp(struct catpt_dev *cdev, struct dma_chan *chan,
-- 
2.25.1


  reply	other threads:[~2021-12-16 11:57 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-16 11:57 [PATCH 0/5] ASoC: Intel: catpt: Dma-transfer fix and couple Cezary Rojewski
2021-12-16 11:57 ` Cezary Rojewski [this message]
2021-12-16 11:57 ` [PATCH 2/5] ASoC: Intel: catpt: Reduce size of catpt_component_open() Cezary Rojewski
2021-12-16 11:57 ` [PATCH 3/5] ASoC: Intel: catpt: Streamline locals declaration for PCM-functions Cezary Rojewski
2021-12-16 11:57 ` [PATCH 4/5] ASoC: Intel: catpt: Drop SND_SOC_ACPI_INTEL_MATCH dependency Cezary Rojewski
2021-12-16 14:11   ` Pierre-Louis Bossart
2021-12-16 14:37     ` Cezary Rojewski
2021-12-16 15:13       ` Pierre-Louis Bossart
2021-12-16 15:59         ` Cezary Rojewski
2021-12-16 16:29           ` Pierre-Louis Bossart
2021-12-16 16:50             ` Cezary Rojewski
2021-12-16 18:04               ` Pierre-Louis Bossart
2021-12-17  9:06                 ` Cezary Rojewski
2021-12-17  2:42   ` kernel test robot
2021-12-16 11:57 ` [PATCH 5/5] ASoC: Intel: Drop legacy HSW/BDW board-match information Cezary Rojewski
2021-12-21  2:50 ` (subset) [PATCH 0/5] ASoC: Intel: catpt: Dma-transfer fix and couple Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211216115743.2130622-2-cezary.rojewski@intel.com \
    --to=cezary.rojewski@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=dave.jiang@intel.com \
    --cc=kevin.tian@intel.com \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.