lkml.org 
[lkml]   [2022]   [Jan]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.15 424/846] ASoC: Intel: catpt: Test dmaengine_submit() result before moving on
    Date
    From: Cezary Rojewski <cezary.rojewski@intel.com>

    [ Upstream commit 2a9a72e290d4a4741e673f86b9fba9bfb319786d ]

    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>
    Link: https://lore.kernel.org/r/20211216115743.2130622-2-cezary.rojewski@intel.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    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 9c5fd18f2600f..346bec0003066 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.34.1


    \
     
     \ /
      Last update: 2022-01-25 00:11    [W:5.971 / U:0.012 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site