[PATCH] BusLogic: Prevent write reordering when writing outgoing mailboxes

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

 



From: Alexander Eichner <Alexander.Eichner@xxxxxxxxxx>

Make sure the compiler doesn't reorder the writes to the outgoing
mailbox because the correct order does matter. Otherwise the
controller might see a stale CCB handle under rare circumstances
if the action code is written first and the controller happens to
read the mailbox between the action code and CCB handle write.
This causes trouble later on as the completion handler will get
confused because the request was not active.

This is very difficult to trigger but happened in some virtualized
environments with a high I/O load.

Signed-off-by: Alexander Eichner <Alexander.Eichner@xxxxxxxxxx>
---
 drivers/scsi/BusLogic.c | 1 +
 drivers/scsi/BusLogic.h | 6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
index c7be7bb37209..20cc34fa5754 100644
--- a/drivers/scsi/BusLogic.c
+++ b/drivers/scsi/BusLogic.c
@@ -2981,6 +2981,7 @@ static bool blogic_write_outbox(struct blogic_adapter *adapter,
 		   by the Host Adapter.
 		 */
 		next_outbox->ccb = ccb->dma_handle;
+		wmb();
 		next_outbox->action = action;
 		blogic_execmbox(adapter);
 		if (++next_outbox > adapter->last_outbox)
diff --git a/drivers/scsi/BusLogic.h b/drivers/scsi/BusLogic.h
index b53ec2f1e8cd..16f372f3e9c2 100644
--- a/drivers/scsi/BusLogic.h
+++ b/drivers/scsi/BusLogic.h
@@ -869,9 +869,9 @@ struct blogic_ccb {
 */
 
 struct blogic_outbox {
-	u32 ccb;			/* Bytes 0-3 */
-	u32:24;				/* Bytes 4-6 */
-	enum blogic_action action;	/* Byte 7 */
+	volatile u32 ccb;					/* Bytes 0-3 */
+	u32:24;								/* Bytes 4-6 */
+	volatile enum blogic_action action;	/* Byte 7 */
 };
 
 /*
-- 
2.12.0




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux