Skip to contentSkip to conversation

Use master-abort for slave probes

PATCH New Russell King - ARM Linux admin 3 participants 5 messages May 6, 2020 – May 12, 2020 I2C subsystem host drivers

lore
Share & tools
lore
#0 lore raw

cover Use master-abort for slave probes

Hi,

This series allows us to use the "master abort" feature when probing slaves rather than resetting the controller, which allows more graceful recovery to bus free state after sending the address byte.

The i2c-pxa controller expects to send data after the address byte rather than a stop. Rather than resetting the bus (and thus forcing a bus-free state by releasing the SCL line) which may leave the bus in an indeterminant state, use the master-abort command instead.

This patch series applies on top of the previous posted cleanup patches, although it may also apply to -rc.

 drivers/i2c/busses/i2c-pxa.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 10.2Mbps down 587kbps up
#1 lore raw

PATCH 1/2 i2c: pxa: clear all master action bits in i2c_pxa_stop_message()

If we timeout during a message transfer, the control register may contain bits that cause an action to be set. Read-modify-writing the register leaving these bits set may trigger the hardware to attempt one of these actions unintentionally.

Always clear these bits when cleaning up after a message or after a timeout.

---
 drivers/i2c/busses/i2c-pxa.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-pxa.c +2 -4
index db739cce93ac..a72d07bdb793 100644
@@ -795,11 +795,9 @@ static inline void i2c_pxa_stop_message(struct pxa_i2c *i2c)
 {
 	u32 icr;
 
-	/*
-	 * Clear the STOP and ACK flags
-	 */
+	/* Clear the START, STOP, ACK, TB and MA flags */
 	icr = readl(_ICR(i2c));
-	icr &= ~(ICR_STOP | ICR_ACKNAK);
+	icr &= ~(ICR_START | ICR_STOP | ICR_ACKNAK | ICR_TB | ICR_MA);
 	writel(icr, _ICR(i2c));
 }
 
Signature · 1 line
2.20.1
#3 lore raw

PATCH 2/2 i2c: pxa: use master-abort for device probes

In reply to Russell King - ARM Linux admin

Use master-abort to send the stop condition after an address cycle rather than resetting the controller.

---
 drivers/i2c/busses/i2c-pxa.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/i2c/busses/i2c-pxa.c +2 -8
index a72d07bdb793..0e194d6cd1b5 100644
@@ -940,14 +940,8 @@ static void i2c_pxa_irq_txempty(struct pxa_i2c *i2c, u32 isr)
 		icr &= ~ICR_ALDIE;
 		icr |= ICR_START | ICR_TB;
 	} else {
-		if (i2c->msg->len == 0) {
-			/*
-			 * Device probes have a message length of zero
-			 * and need the bus to be reset before it can
-			 * be used again.
-			 */
-			i2c_pxa_reset(i2c);
-		}
+		if (i2c->msg->len == 0)
+			icr |= ICR_MA;
 		i2c_pxa_master_complete(i2c, 0);
 	}
 
Signature · 1 line
2.20.1
Applied
#2 lore raw

Re: [PATCH 1/2] i2c: pxa: clear all master action bits in i2c_pxa_stop_message()

In reply to Russell King
Quoted 9 lines · Russell King

If we timeout during a message transfer, the control register may contain bits that cause an action to be set. Read-modify-writing the register leaving these bits set may trigger the hardware to attempt one of these actions unintentionally.

Always clear these bits when cleaning up after a message or after a timeout.

Applied to for-next, thanks! I was considering for-current, though, but there have been no real bug reports, so for-next it is.