Skip to content

Commit

Permalink
ARM: 7136/1: pl330: Fix a race condition
Browse files Browse the repository at this point in the history
If two requests have been submitted and one of them is running, if you
call pl330_chan_ctrl(ch_id, PL330_OP_START), there's a window of time
between the spin_lock_irqsave() and the _state() check in which the
running transaction may finish.  In that case, we don't receive the
interrupt (because they are disabled), but _start() sees that the DMA
is stopped, so it starts it.  The problem is that it sends the
transaction that has just finished again, because pl330_update()
hasn't mark it as done yet.

This patch fixes this race condition by not calling _start() if the
DMA is already executing transactions.  When interrupts are reenabled,
pl330_update() will call _start().

Reference: <1317892206-3600-1-git-send-email-javi.merino@arm.com>

Signed-off-by: Javi Merino <javi.merino@arm.com>
Acked-by: Jassi Brar <jassi.brar@samsung.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
Javi Merino authored and Russell King committed Oct 22, 2011
1 parent b55fa18 commit ee3f615
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion arch/arm/common/pl330.c
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,7 @@ int pl330_chan_ctrl(void *ch_id, enum pl330_chan_op op)

/* Start the next */
case PL330_OP_START:
if (!_start(thrd))
if (!_thrd_active(thrd) && !_start(thrd))
ret = -EIO;
break;

Expand Down

0 comments on commit ee3f615

Please sign in to comment.