[PATCH] dmaengine: fix potential race condition in fsl raid

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Xuelin Shi <xuelin.shi@xxxxxxxxxxxxx>

checking available slots in HW should be under the lock.

Signed-off-by: Xuelin Shi <b29237@xxxxxxxxxxxxx>
---
 drivers/dma/fsl_raid.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/fsl_raid.c b/drivers/dma/fsl_raid.c
index 935d05a..fccad86 100644
--- a/drivers/dma/fsl_raid.c
+++ b/drivers/dma/fsl_raid.c
@@ -112,11 +112,11 @@ static void re_jr_issue_pending(struct dma_chan *chan)
 
 	jr = container_of(chan, struct re_jr, chan);
 
+	spin_lock_irqsave(&jr->desc_lock, flags);
 	avail = RE_JR_INB_SLOT_AVAIL(in_be32(&jr->jrregs->inbring_slot_avail));
 	if (!avail)
-		return;
+		goto out;
 
-	spin_lock_irqsave(&jr->desc_lock, flags);
 	list_for_each_entry_safe(desc, _desc, &jr->submit_q, node) {
 		if (!avail)
 			break;
@@ -132,6 +132,7 @@ static void re_jr_issue_pending(struct dma_chan *chan)
 		out_be32(&jr->jrregs->inbring_add_job, RE_JR_INB_JOB_ADD(1));
 		avail--;
 	}
+out:
 	spin_unlock_irqrestore(&jr->desc_lock, flags);
 }
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux PCI]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux