From 2cd6bf6748f28008a1650dca57a8f14b27283803 Mon Sep 17 00:00:00 2001
From: Jassi Brar <jaswinder.singh@linaro.org>
Date: Tue, 31 Mar 2015 10:21:14 +0530
Subject: [PATCH 2/2] dma: pl330: fix race between trigger and completion
We need to hold the lock on channel in ISR to prevent it
racing against the trigger call on the channel.
Reported-by: Scott Branden <sbranden@broadcom.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
---
drivers/dma/pl330.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
@@ -1573,6 +1573,7 @@ static int pl330_update(struct pl330_dmac *pl330)
if (val & (1 << ev)) { /* Event occurred */
struct pl330_thread *thrd;
u32 inten = readl(regs + INTEN);
+ unsigned long flag;
int active;
/* Clear the event */
@@ -1584,10 +1585,13 @@ static int pl330_update(struct pl330_dmac *pl330)
id = pl330->events[ev];
thrd = &pl330->channels[id];
+ spin_lock_irqsave(&thrd->pch->lock, flag);
active = thrd->req_running;
- if (active == -1) /* Aborted */
+ if (active == -1) { /* Aborted */
+ spin_unlock_irqrestore(&thrd->pch->lock, flag);
continue;
+ }
/* Detach the req */
descdone = thrd->req[active].desc;
@@ -1600,6 +1604,7 @@ static int pl330_update(struct pl330_dmac *pl330)
/* For now, just make a list of callbacks to be done */
list_add_tail(&descdone->rqd, &pl330->req_done);
+ spin_unlock_irqrestore(&thrd->pch->lock, flag);
}
}
--
1.9.1