linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dmaengine: pl330: fix irq race with terminate_all
@ 2018-07-17 10:48 John Keeping
  2018-07-25 12:30 ` Vinod
  0 siblings, 1 reply; 2+ messages in thread
From: John Keeping @ 2018-07-17 10:48 UTC (permalink / raw)
  To: dmaengine; +Cc: Vinod Koul, Dan Williams, linux-kernel, John Keeping

In pl330_update() when checking if a channel has been aborted, the
channel's lock is not taken, only the overall pl330_dmac lock.  But in
pl330_terminate_all() the aborted flag (req_running==-1) is set under
the channel lock and not the pl330_dmac lock.

With threaded interrupts, this leads to a potential race:

    pl330_terminate_all	        pl330_update
    -------------------         ------------
    lock channel
                                entry
    lock pl330
    _stop channel
    unlock pl330
                                lock pl330
                                check req_running != -1
    req_running = -1
                                _start channel

Signed-off-by: John Keeping <john@metanate.com>
---
 drivers/dma/pl330.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index 370df2e74ddd..88750a34e859 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -2256,13 +2256,14 @@ static int pl330_terminate_all(struct dma_chan *chan)
 
 	pm_runtime_get_sync(pl330->ddma.dev);
 	spin_lock_irqsave(&pch->lock, flags);
+
 	spin_lock(&pl330->lock);
 	_stop(pch->thread);
-	spin_unlock(&pl330->lock);
-
 	pch->thread->req[0].desc = NULL;
 	pch->thread->req[1].desc = NULL;
 	pch->thread->req_running = -1;
+	spin_unlock(&pl330->lock);
+
 	power_down = pch->active;
 	pch->active = false;
 
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] dmaengine: pl330: fix irq race with terminate_all
  2018-07-17 10:48 [PATCH] dmaengine: pl330: fix irq race with terminate_all John Keeping
@ 2018-07-25 12:30 ` Vinod
  0 siblings, 0 replies; 2+ messages in thread
From: Vinod @ 2018-07-25 12:30 UTC (permalink / raw)
  To: John Keeping; +Cc: dmaengine, Dan Williams, linux-kernel

On 17-07-18, 11:48, John Keeping wrote:
> In pl330_update() when checking if a channel has been aborted, the
> channel's lock is not taken, only the overall pl330_dmac lock.  But in
> pl330_terminate_all() the aborted flag (req_running==-1) is set under
> the channel lock and not the pl330_dmac lock.
> 
> With threaded interrupts, this leads to a potential race:
> 
>     pl330_terminate_all	        pl330_update
>     -------------------         ------------
>     lock channel
>                                 entry
>     lock pl330
>     _stop channel
>     unlock pl330
>                                 lock pl330
>                                 check req_running != -1
>     req_running = -1
>                                 _start channel
> 

Applied, thanks

-- 
~Vinod

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-07-25 12:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-17 10:48 [PATCH] dmaengine: pl330: fix irq race with terminate_all John Keeping
2018-07-25 12:30 ` Vinod

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).