I2C: designware: fix IO timeout issue for AMD controller
Subsystems (3)
PATCH v2 1/1 I2C: designware: fix IO timeout issue for AMD controller
Because of some hardware limitation, AMD I2C controller can't trigger pending interrupt if interrupt status has been changed after clearing interrupt status bits. Then, I2C will lost interrupt and IO timeout.
According to hardware design, this patch implements a workaround to disable i2c controller interrupt and re-enable i2c interrupt before exiting ISR.
To reduce the performance impacts on other vendors, use unlikely function to check flag in ISR.
---
Changes in v2:
- pass flags with ->driver_data
- unmask interrupt right after masking
--- drivers/i2c/busses/i2c-designware-core.c | 6 ++++++ drivers/i2c/busses/i2c-designware-core.h | 1 + drivers/i2c/busses/i2c-designware-platdrv.c | 7 ++++++- 3 files changed, 13 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-designware-core.c +6 -0
@@ -813,6 +813,12 @@ static irqreturn_t i2c_dw_isr(int this_irq, void *dev_id) tx_aborted:if ((stat & (DW_IC_INTR_TX_ABRT |DW_IC_INTR_STOP_DET )) || dev->msg_err)complete (&dev->cmd_complete); +else if (unlikely (dev->accessor_flags &ACCESS_INTR_MASK )) { +/* workaround to trigger pending interrupt */ + stat =dw_readl (dev,DW_IC_INTR_MASK ); +i2c_dw_disable_int (dev); +dw_writel (dev, stat,DW_IC_INTR_MASK ); + }return IRQ_HANDLED ; }
drivers/i2c/busses/i2c-designware-core.h +1 -0
@@ -111,6 +111,7 @@ struct dw_i2c_dev {#define ACCESS_SWAP 0x00000001#define ACCESS_16BIT 0x00000002 +#define ACCESS_INTR_MASK 0x00000004extern int i2c_dw_init (struct dw_i2c_dev *dev);extern void i2c_dw_disable (struct dw_i2c_dev *dev);
drivers/i2c/busses/i2c-designware-platdrv.c +6 -1
@@ -93,6 +93,7 @@ static void dw_i2c_acpi_params(struct platform_device *pdev, char method[],static int dw_i2c_acpi_configure (struct platform_device *pdev) {struct dw_i2c_dev *dev =platform_get_drvdata (pdev); +const struct acpi_device_id *id; dev->adapter.nr =-1 ; dev->tx_fifo_depth =32 ;
@@ -106,6 +107,10 @@ static int dw_i2c_acpi_configure(struct platform_device *pdev)dw_i2c_acpi_params (pdev,"FMCN" , &dev->fs_hcnt, &dev->fs_lcnt, &dev->sda_hold_time); + id =acpi_match_device (pdev->dev.driver->acpi_match_table, &pdev->dev); +if (id && id->driver_data) + dev->accessor_flags |= (u32 )id->driver_data; +return 0 ; }
@@ -116,7 +121,7 @@ static const struct acpi_device_id dw_i2c_acpi_match[] = { { "INT3433", 0 }, { "80860F41", 0 }, { "808622C1", 0 }, - { "AMD0010", 0 }, + { "AMD0010", ACCESS_INTR_MASK }, { } };MODULE_DEVICE_TABLE (acpi, dw_i2c_acpi_match);
Signature · 1 line
1.9.1
Quoted 28 lines · Xiangliang Yu
Because of some hardware limitation, AMD I2C controller can't trigger pending interrupt if interrupt status has been changed after clearing interrupt status bits. Then, I2C will lost interrupt and IO timeout.
According to hardware design, this patch implements a workaround to disable i2c controller interrupt and re-enable i2c interrupt before exiting ISR.
To reduce the performance impacts on other vendors, use unlikely function to check flag in ISR.
---
Changes in v2:
- pass flags with ->driver_data
- unmask interrupt right after maskingSigned-off-by Xiangliang Yu <[email protected]>--- drivers/i2c/busses/i2c-designware-core.c | 6 ++++++ drivers/i2c/busses/i2c-designware-core.h | 1 + drivers/i2c/busses/i2c-designware-platdrv.c | 7 ++++++- 3 files changed, 13 insertions(+), 1 deletion(-)drivers/i2c/busses/i2c-designware-core.c +0
-0
drivers/i2c/busses/i2c-designware-core.c static irqreturn_t i2c_dw_isr(int this_irq, void *dev_id) · line 822
Quoted 10 lines
drivers/i2c/busses/i2c-designware-core.c +6
-0@@ -813,6 +813,12 @@ static irqreturn_t i2c_dw_isr(int this_irq, void *dev_id) tx_aborted:if ((stat & (DW_IC_INTR_TX_ABRT |DW_IC_INTR_STOP_DET )) || dev->msg_err)complete (&dev->cmd_complete); +else if (unlikely (dev->accessor_flags &ACCESS_INTR_MASK )) { +/* workaround to trigger pending interrupt */ + stat =dw_readl (dev,DW_IC_INTR_MASK ); +i2c_dw_disable_int (dev); +dw_writel (dev, stat,DW_IC_INTR_MASK ); + }
Looks ok to me.
Quoted 5 lines · Xiangliang Yu
Because of some hardware limitation, AMD I2C controller can't trigger pending interrupt if interrupt status has been changed after clearing interrupt status bits. Then, I2C will lost interrupt and IO timeout.
Quoted 7 lines
According to hardware design, this patch implements a workaround to disable i2c controller interrupt and re-enable i2c interrupt before exiting ISR.
To reduce the performance impacts on other vendors, use unlikely function to check flag in ISR.
---
Don't manually add "---". This breaks a lot of workflow scripts. "Patchwork" missed your Signed-off, for example!
Quoted 3 lines
Changes in v2:
- pass flags with ->driver_data
- unmask interrupt right after masking
This paragraph...
Quoted 3 lines
Signed-off-by Xiangliang Yu <[email protected]>---
... needs to go here.
However, I fixed it this time and applied to for-current, thanks!
Quoted 19 lines
-----Original Message-----
From: Wolfram Sang [mailto:[email protected]]
Sent: Sunday, December 13, 2015 1:03 AM
To: Yu, Xiangliang
Cc: [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected];SPG_Linux_Kernel
Subject: Re: [PATCH v2] I2C: designware: fix IO timeout issue for AMD controllerQuoted 8 lines · Xiangliang Yu
Because of some hardware limitation, AMD I2C controller can't trigger pending interrupt if interrupt status has been changed after clearing interrupt status bits. Then, I2C will lost interrupt and IO timeout.
According to hardware design, this patch implements a workaround to disable i2c controller interrupt and re-enable i2c interrupt before exiting ISR.
Quoted 6 lines
Quoted 3 lines
To reduce the performance impacts on other vendors, use unlikely function to check flag in ISR.
---Don't manually add "---". This breaks a lot of workflow scripts. "Patchwork" missed your Signed-off, for example!
Sorry for my mistake.
Quoted 7 lines
Quoted 3 lines
Changes in v2:
- pass flags with ->driver_data
- unmask interrupt right after maskingThis paragraph...
Quoted 1 line
Quoted 6 lines
Quoted 2 lines
Signed-off-by Xiangliang Yu <[email protected]>---
... needs to go here.
However, I fixed it this time and applied to for-current, thanks!
Thank you very much!