BusLogic: Prevent write reordering when writing outgoing mailboxes
Subsystems (2)
PATCH 1/1 BusLogic: Prevent write reordering when writing outgoing mailboxes
From: Alexander Eichner <[email protected]>
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 <[email protected]>
--- drivers/scsi/BusLogic.c | 1 + drivers/scsi/BusLogic.h | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/scsi/BusLogic.c +1 -0
@@ -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)
drivers/scsi/BusLogic.h +3 -3
@@ -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 */ };/*
Signature · 1 line
2.12.0