From: Javi Merino Date: Tue, 18 Oct 2011 10:50:07 +0000 (+0100) Subject: ARM: 7136/1: pl330: Fix a race condition X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ee3f615819404a9438b2dd01b7a39f276d2737f2;p=GitHub%2FLineageOS%2Fandroid_kernel_samsung_universal7580.git ARM: 7136/1: pl330: Fix a race condition 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 Acked-by: Jassi Brar Signed-off-by: Russell King --- diff --git a/arch/arm/common/pl330.c b/arch/arm/common/pl330.c index 97912fa4878..7129cfbdacd 100644 --- a/arch/arm/common/pl330.c +++ b/arch/arm/common/pl330.c @@ -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;