Skip to contentSkip to conversation

i2c: designware: Fix corrupted memory seen in the ISR

PATCH Superseded Jan Bottorff 1 participant 2 messages Sep 13, 2023

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 i2c: designware: Fix corrupted memory seen in the ISR

Errors were happening in the ISR that looked like corrupted memory. This was because memory writes from the core enabling interrupts were not yet visible to the core running the ISR. The kernel log would get the message "i2c_designware APMC0D0F:00:
controller timed out" during in-band IPMI SSIF stress tests.

Add a write barrier before enabling interrupts to assure data written by the current core is visible to all cores before the interrupt fires.

The ARM Barrier Litmus Tests and Cookbook has an example under Sending Interrupts and Barriers that matches the usage in this driver. That document says a DSB barrier is required.

---
 drivers/i2c/busses/i2c-designware-master.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/i2c/busses/i2c-designware-master.c +8 -0
index ca1035e010c7..1694ac6bb592 100644
@@ -248,6 +248,14 @@ static void i2c_dw_xfer_init(struct dw_i2c_dev *dev)
 	/* Dummy read to avoid the register getting stuck on Bay Trail */
 	regmap_read(dev->map, DW_IC_ENABLE_STATUS, &dummy);
 
+	/*
+	 * To guarantee data written by the current core is visible to
+	 * all cores, a write barrier is required. This needs to be
+	 * before an interrupt causes execution on another core.
+	 * For ARM processors, this needs to be a DSB barrier.
+	 */
+	wmb();
+
 	/* Clear and enable interrupts */
 	regmap_read(dev->map, DW_IC_CLR_INTR, &dummy);
 	regmap_write(dev->map, DW_IC_INTR_MASK, DW_IC_INTR_MASTER_MASK);
Signature · 1 line
2.41.0
#1 lore raw

Hi,

Sorry, I slightly fumbled the updated message. It should have been v2 not 2/2 and included the review/tested info. I'll send a corrected one.

My Apologies
Jan