Skip to contentSkip to conversation

i2c: designware: must wait for enable

PATCH Applied Ben Gardner 4 participants 4 messages Feb 14, 2018 – Feb 21, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: designware: must wait for enable

One I2C bus on my Atom E3845 board has been broken since 4.9. It has two devices, both declared by ACPI and with built-in drivers.

There are two back-to-back transactions originating from the kernel, one targeting each device. The first transaction works, the second one locks up the I2C controller. The controller never recovers.

These kernel logs show up whenever an I2C transaction is attempted after this failure.
i2c-designware-pci 0000:00:18.3: timeout in disabling adapter i2c-designware-pci 0000:00:18.3: timeout waiting for bus ready

Waiting for the I2C controller status to indicate that it is enabled before programming it fixes the issue.

I have tested this patch on 4.14 and 4.15.

Fixes commit 2702ea7dbec5 ("i2c: designware: wait for disable/enable only if necessary")
Cc linux-stable <[email protected]> #4.13+
Cc José Roberto de Souza <[email protected]>
---
 drivers/i2c/busses/i2c-designware-master.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-designware-master.c +1 -1
index ae69188..55926ef 100644
@@ -209,7 +209,7 @@ static void i2c_dw_xfer_init(struct dw_i2c_dev *dev)
 	i2c_dw_disable_int(dev);
 
 	/* Enable the adapter */
-	__i2c_dw_enable(dev, true);
+	__i2c_dw_enable_and_wait(dev, true);
 
 	/* Clear and enable interrupts */
 	dw_readl(dev, DW_IC_CLR_INTR);
Signature · 1 line
2.7.4
Acked-by on v1 1/1
#1 lore raw
Quoted 30 lines · Ben Gardner

One I2C bus on my Atom E3845 board has been broken since 4.9. It has two devices, both declared by ACPI and with built-in drivers.

There are two back-to-back transactions originating from the kernel, one targeting each device. The first transaction works, the second one locks up the I2C controller. The controller never recovers.

These kernel logs show up whenever an I2C transaction is attempted after this failure.
i2c-designware-pci 0000:00:18.3: timeout in disabling adapter i2c-designware-pci 0000:00:18.3: timeout waiting for bus ready

Waiting for the I2C controller status to indicate that it is enabled before programming it fixes the issue.

I have tested this patch on 4.14 and 4.15.

Fixes commit 2702ea7dbec5 ("i2c: designware: wait for disable/enable only if necessary")
Cc linux-stable <[email protected]> #4.13+
Cc José Roberto de Souza <[email protected]>
---
  drivers/i2c/busses/i2c-designware-master.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-designware-master.c +0 -0
index ae69188..55926ef 100644

drivers/i2c/busses/i2c-designware-master.c static void i2c_dw_xfer_init(struct dw_i2c_dev *dev) · line 213

Quoted 6 lines
drivers/i2c/busses/i2c-designware-master.c +1 -1
@@ -209,7 +209,7 @@ static void i2c_dw_xfer_init(struct dw_i2c_dev *dev)
  	i2c_dw_disable_int(dev);
 
  	/* Enable the adapter */
-	__i2c_dw_enable(dev, true);
+	__i2c_dw_enable_and_wait(dev, true);
 

I believe this conversion was missing from commit 2702ea7dbec5 and regression is better to fix this way than reverting. We'll provide similar fix for for v4.9..v4.12. Code have had changes and renaming.

Reviewed-by on v1 1/1
#2 lore raw
In reply to Ben Gardner

LGTM

Quoted 18 lines · Ben Gardner

One I2C bus on my Atom E3845 board has been broken since 4.9. It has two devices, both declared by ACPI and with built-in drivers.

There are two back-to-back transactions originating from the kernel, one
targeting each device. The first transaction works, the second one locks
up the I2C controller. The controller never recovers.

These kernel logs show up whenever an I2C transaction is attempted after
this failure.
i2c-designware-pci 0000:00:18.3: timeout in disabling adapter i2c-designware-pci 0000:00:18.3: timeout waiting for bus ready

Waiting for the I2C controller status to indicate that it is enabled before programming it fixes the issue.

Quoted 6 lines

I have tested this patch on 4.14 and 4.15.

Fixes commit 2702ea7dbec5 ("i2c: designware: wait for disable/enable

only if necessary")
Cc: linux-stable <[email protected]> #4.13+
Cc: José Roberto de Souza <[email protected]>

Quoted 20 lines
---
 drivers/i2c/busses/i2c-designware-master.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-designware-master.c +1 -1
index ae69188..55926ef 100644
@@ -209,7 +209,7 @@ static void i2c_dw_xfer_init(struct dw_i2c_dev
 *dev)
 	i2c_dw_disable_int(dev);
 
 	/* Enable the adapter */
-	__i2c_dw_enable(dev, true);
+	__i2c_dw_enable_and_wait(dev, true);
 
 	/* Clear and enable interrupts */

dw_readl(dev, DW_IC_CLR_INTR);

Applied
#3 lore raw
In reply to Ben Gardner
Quoted 15 lines · Ben Gardner

One I2C bus on my Atom E3845 board has been broken since 4.9. It has two devices, both declared by ACPI and with built-in drivers.

There are two back-to-back transactions originating from the kernel, one targeting each device. The first transaction works, the second one locks up the I2C controller. The controller never recovers.

These kernel logs show up whenever an I2C transaction is attempted after this failure.
i2c-designware-pci 0000:00:18.3: timeout in disabling adapter i2c-designware-pci 0000:00:18.3: timeout waiting for bus ready

Waiting for the I2C controller status to indicate that it is enabled before programming it fixes the issue.

Quoted 6 lines

I have tested this patch on 4.14 and 4.15.

Fixes commit 2702ea7dbec5 ("i2c: designware: wait for disable/enable only if necessary")
Cc linux-stable <[email protected]> #4.13+
Cc José Roberto de Souza <[email protected]>

Applied to for-current, thanks!