From: Sascha Hauer <s.hauer@pengutronix.de>
To: dmaengine@vger.kernel.org
Cc: Vinod Koul <vkoul@kernel.org>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
NXP Linux Team <linux-imx@nxp.com>,
Peter Ujfalusi <peter.ujfalusi@ti.com>,
Robert Jarzmik <robert.jarzmik@free.fr>,
Sascha Hauer <s.hauer@pengutronix.de>
Subject: [PATCH 4/5] dmaengine: imx-sdma: find desc first in sdma_tx_status
Date: Fri, 6 Dec 2019 14:53:43 +0100 [thread overview]
Message-ID: <20191206135344.29330-5-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20191206135344.29330-1-s.hauer@pengutronix.de>
In sdma_tx_status() we must first find the current sdma_desc. In cyclic
mode we assume that this can always be found with vchan_find_desc().
This is true because do not remove the current descriptor from the
desc_issued list:
/*
* Do not delete the node in desc_issued list in cyclic mode, otherwise
* the desc allocated will never be freed in vchan_dma_desc_free_list
*/
if (!(sdmac->flags & IMX_DMA_SG_LOOP))
list_del(&vd->node);
We will change this in the next step, so check if the current descriptor is
the desired one also for the cyclic case.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/dma/imx-sdma.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index 527f8a81f50b..99dbfd9039cf 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -1648,7 +1648,7 @@ static enum dma_status sdma_tx_status(struct dma_chan *chan,
struct dma_tx_state *txstate)
{
struct sdma_channel *sdmac = to_sdma_chan(chan);
- struct sdma_desc *desc;
+ struct sdma_desc *desc = NULL;
u32 residue;
struct virt_dma_desc *vd;
enum dma_status ret;
@@ -1659,19 +1659,23 @@ static enum dma_status sdma_tx_status(struct dma_chan *chan,
return ret;
spin_lock_irqsave(&sdmac->vc.lock, flags);
+
vd = vchan_find_desc(&sdmac->vc, cookie);
- if (vd) {
+ if (vd)
desc = to_sdma_desc(&vd->tx);
+ else if (sdmac->desc && sdmac->desc->vd.tx.cookie == cookie)
+ desc = sdmac->desc;
+
+ if (desc) {
if (sdmac->flags & IMX_DMA_SG_LOOP)
residue = (desc->num_bd - desc->buf_ptail) *
desc->period_len - desc->chn_real_count;
else
residue = desc->chn_count - desc->chn_real_count;
- } else if (sdmac->desc && sdmac->desc->vd.tx.cookie == cookie) {
- residue = sdmac->desc->chn_count - sdmac->desc->chn_real_count;
} else {
residue = 0;
}
+
spin_unlock_irqrestore(&sdmac->vc.lock, flags);
dma_set_tx_state(txstate, chan->completed_cookie, chan->cookie,
--
2.24.0
next prev parent reply other threads:[~2019-12-06 13:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-06 13:53 [PATCH 0/5] virt-dma and i.MX SDMA fixes Sascha Hauer
2019-12-06 13:53 ` [PATCH 1/5] dmaengine: virt-dma: Add missing locking around list operations Sascha Hauer
2019-12-09 7:38 ` Peter Ujfalusi
2019-12-10 11:56 ` Sascha Hauer
2019-12-06 13:53 ` [PATCH 2/5] dmaengine: virt-dma: Do not call desc_free() under a spin_lock Sascha Hauer
2019-12-09 7:48 ` Peter Ujfalusi
2019-12-09 8:33 ` Peter Ujfalusi
2019-12-10 11:58 ` Sascha Hauer
2019-12-06 13:53 ` [PATCH 3/5] dmaengine: imx-sdma: rename function Sascha Hauer
2019-12-06 13:53 ` Sascha Hauer [this message]
2019-12-06 13:53 ` [PATCH 5/5] dmaengine: imx-sdma: Fix memory leak Sascha Hauer
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=20191206135344.29330-5-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=dmaengine@vger.kernel.org \
--cc=kernel@pengutronix.de \
--cc=linux-imx@nxp.com \
--cc=peter.ujfalusi@ti.com \
--cc=robert.jarzmik@free.fr \
--cc=vkoul@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).