From: Brad Kim <brad.kim@sifive.com>
To: green.wan@sifive.com, vkoul@kernel.org
Cc: dmaengine@vger.kernel.org, Brad Kim <brad.kim@semifive.com>
Subject: [PATCH] dmaengine: sf-pdma: Fix an error that calls callback twice
Date: Thu, 27 Aug 2020 22:33:09 +0900 [thread overview]
Message-ID: <20200827133309.17362-1-brad.kim@semifive.com> (raw)
Because a callback is called twice when DMA transfer complete
the second callback may be possible to access a freed memory
if the first callback routines perform the dma_release_channel function.
So this patch serialized the callback functions
Signed-off-by: Brad Kim <brad.kim@semifive.com>
---
drivers/dma/sf-pdma/sf-pdma.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/dma/sf-pdma/sf-pdma.c b/drivers/dma/sf-pdma/sf-pdma.c
index 6e530dca6d9e..754994087e5f 100644
--- a/drivers/dma/sf-pdma/sf-pdma.c
+++ b/drivers/dma/sf-pdma/sf-pdma.c
@@ -295,7 +295,10 @@ static void sf_pdma_donebh_tasklet(unsigned long arg)
}
spin_unlock_irqrestore(&chan->lock, flags);
- dmaengine_desc_get_callback_invoke(desc->async_tx, NULL);
+ spin_lock_irqsave(&chan->vchan.lock, flags);
+ list_del(&chan->desc->vdesc.node);
+ vchan_cookie_complete(&chan->desc->vdesc);
+ spin_unlock_irqrestore(&chan->vchan.lock, flags);
}
static void sf_pdma_errbh_tasklet(unsigned long arg)
@@ -332,8 +335,7 @@ static irqreturn_t sf_pdma_done_isr(int irq, void *dev_id)
residue = readq(regs->residue);
if (!residue) {
- list_del(&chan->desc->vdesc.node);
- vchan_cookie_complete(&chan->desc->vdesc);
+ tasklet_hi_schedule(&chan->done_tasklet);
} else {
/* submit next trascatioin if possible */
struct sf_pdma_desc *desc = chan->desc;
@@ -347,8 +349,6 @@ static irqreturn_t sf_pdma_done_isr(int irq, void *dev_id)
spin_unlock_irqrestore(&chan->vchan.lock, flags);
- tasklet_hi_schedule(&chan->done_tasklet);
-
return IRQ_HANDLED;
}
--
2.17.1
next reply other threads:[~2020-08-27 13:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-27 13:33 Brad Kim [this message]
[not found] ` <CAJivOr4iT-GZ_CcAHRPp9rjZbOaBXcX6j4KGQH=XuGoArZSnsg@mail.gmail.com>
2020-09-01 3:04 ` [PATCH] dmaengine: sf-pdma: Fix an error that calls callback twice Green Wan
2020-09-03 6:22 ` Vinod Koul
-- strict thread matches above, loose matches on Subject: below --
2020-09-03 11:17 Brad Kim
2020-09-11 12:10 ` Vinod Koul
2020-08-27 13:27 Brad Kim
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=20200827133309.17362-1-brad.kim@semifive.com \
--to=brad.kim@sifive.com \
--cc=brad.kim@semifive.com \
--cc=dmaengine@vger.kernel.org \
--cc=green.wan@sifive.com \
--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