Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3635469pxb; Mon, 24 Jan 2022 14:04:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJwjayZ0TtafAvqGNNhW/H/ddEE716WOqIOHa2T4b2QgQ5lwGo8mk6PZcFZ8nmAeaMwNZV5p X-Received: by 2002:a17:90a:9504:: with SMTP id t4mr367643pjo.164.1643061861605; Mon, 24 Jan 2022 14:04:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643061861; cv=none; d=google.com; s=arc-20160816; b=S7lBrw1WyhwzfKeBdj1PLAlOwmo/rQYccKOwnsRgQ6yDSV0qGBZRZ8b7RnN2WwF/ue jZB/IXezpOP5sL9bc2U1AWtHlEFK/ap9Srp/3qU9bBDQqiDE/q2TkdakwSisflCswisJ R9lu9Z1EUr25x/BfOgHFDrdPxBqqQ1fxq3kBvrrGT4dTOrDyESxkTaozc7YXXB+P72a1 EQu8rBfpF0YtZQd8kqpQl/EUlTQH/aI7MSLunewx7Mfs/6XnoZfR54ZspjzYqVVAXqsR kTxAlnv776RGy3C9++ba4bm1q8DkaPuPRIUpSF/yyfi61u9eHxtzRK0eiUFpOXkzjSbC CtwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9W3puFXDUOIdCJrUQKU3JmVnIJ9fH+TI907vbHJ9Jfk=; b=DYJOQ6BTnx9LCvh6yb7QMl3lP8ijZmQLKYkTnxRL8S8AWiutgb/x+xkjE20TASlmM0 2qajYskkAfeuCXYqmvIeLXpiKS6YDSS2yatmb/ByjOLF3hBVT/ae7zD4RdrWgV2+r6qC oPIDFqbDnI9So5MZ6zBLeN/t2FDNq8SJoeJ7vobxKS42FGQ2QmxsG+lLZ3+iAvBf0NAJ iJrhQMJcqQYluEImBUNL1OhtGRv7ebf1BfkUhpZdGPt2rY6PSo5y6NKppXq2rdDLfKPP Y4j7tA5TOnsdnxSBwRoUhn3Ozzcp6HA6LQpCJr+yCso3s9mWDqi3vTDRaAt1Ac06vvz8 p+IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pXZBeCHk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 2si13351084pli.34.2022.01.24.14.04.08; Mon, 24 Jan 2022 14:04:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pXZBeCHk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1575516AbiAXVvx (ORCPT + 99 others); Mon, 24 Jan 2022 16:51:53 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:41534 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1446544AbiAXVSF (ORCPT ); Mon, 24 Jan 2022 16:18:05 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BC0CF614B4; Mon, 24 Jan 2022 21:18:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E1B6C340E4; Mon, 24 Jan 2022 21:18:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643059082; bh=e9ukgO2HtZrPpeNCuBBCRIWPjwNXuYeZrknKf0Rh6RA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pXZBeCHkod3GfaAEq4GG6GFmyc6SOJqpn6Ea9YDNRk0gsFie572KV3BR8SgVDP4Wl ZkmAmpbLlKIHhS0S2/SDmFO7x8+HrYcmeANtWWRZpp71tzX2KdpCwFEgcYiPUo9H3O JE1ppDz4ePMCeLXM3Wbj161miUxjzzrfafNH956M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kevin Tian , Dave Jiang , Cezary Rojewski , Mark Brown , Sasha Levin Subject: [PATCH 5.16 0498/1039] ASoC: Intel: catpt: Test dmaengine_submit() result before moving on Date: Mon, 24 Jan 2022 19:38:07 +0100 Message-Id: <20220124184141.990765690@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Cezary Rojewski [ 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 Suggested-by: Dave Jiang Fixes: 4fac9b31d0b9 ("ASoC: Intel: Add catpt base members") Signed-off-by: Cezary Rojewski Link: https://lore.kernel.org/r/20211216115743.2130622-2-cezary.rojewski@intel.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- 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