Skip to contentSkip to conversation

I2C: designware: fix IO timeout issue for AMD controller

PATCH Superseded Xiangliang Yu 4 participants 8 messages Nov 5, 2015 – Dec 1, 2015

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 I2C: designware: fix IO timeout issue for AMD controller

Because of some hardware limitation, AMD I2C controller can't trigger next 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 after clearing interrupt bits when entering ISR and to enable i2c interrupt before exiting ISR.

To reduce the performance impacts on other vendors, use unlikely function to check flag in ISR.

---
 drivers/i2c/busses/i2c-designware-core.c    | 6 ++++++
 drivers/i2c/busses/i2c-designware-core.h    | 1 +
 drivers/i2c/busses/i2c-designware-platdrv.c | 4 ++++
 3 files changed, 11 insertions(+)
drivers/i2c/busses/i2c-designware-core.c +6 -0
index 7441cdc..04e7b65 100644
@@ -783,6 +783,9 @@ irqreturn_t i2c_dw_isr(int this_irq, void *dev_id)
 
 	stat = i2c_dw_read_clear_intrbits(dev);
 
+	if (unlikely(dev->accessor_flags & ACCESS_INTR_MASK))
+		i2c_dw_disable_int(dev);
+
 	if (stat & DW_IC_INTR_TX_ABRT) {
 		dev->cmd_err |= DW_IC_ERR_TX_ABRT;
 		dev->status = STATUS_IDLE;
@@ -811,6 +814,9 @@ tx_aborted:
 	if ((stat & (DW_IC_INTR_TX_ABRT | DW_IC_INTR_STOP_DET)) || dev->msg_err)
 		complete(&dev->cmd_complete);
 
+	if (unlikely(dev->accessor_flags & ACCESS_INTR_MASK))
+		dw_writel(dev, DW_IC_INTR_DEFAULT_MASK, DW_IC_INTR_MASK);
+
 	return IRQ_HANDLED;
 }
 EXPORT_SYMBOL_GPL(i2c_dw_isr);
drivers/i2c/busses/i2c-designware-core.h +1 -0
index 9630222..808ef6a 100644
@@ -111,6 +111,7 @@ struct dw_i2c_dev {
 
 #define ACCESS_SWAP		0x00000001
 #define ACCESS_16BIT		0x00000002
+#define ACCESS_INTR_MASK	0x00000004
 
 extern u32 dw_readl(struct dw_i2c_dev *dev, int offset);
 extern void dw_writel(struct dw_i2c_dev *dev, u32 b, int offset);
drivers/i2c/busses/i2c-designware-platdrv.c +4 -0
index 472b882..0c59357 100644
@@ -251,6 +251,10 @@ static int dw_i2c_probe(struct platform_device *pdev)
 		dev->rx_fifo_depth = ((param1 >> 8)  & 0xff) + 1;
 		dev->adapter.nr = pdev->id;
 	}
+
+	if (!strncmp(pdev->name, "AMD0010", 7))
+		dev->accessor_flags |= ACCESS_INTR_MASK;
+
 	r = i2c_dw_init(dev);
 	if (r)
 		return r;
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 24 lines · Xiangliang Yu

Because of some hardware limitation, AMD I2C controller can't trigger next 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 after clearing interrupt bits when entering ISR and to enable i2c interrupt before exiting ISR.

To reduce the performance impacts on other vendors, use unlikely function to check flag in ISR.

---
 drivers/i2c/busses/i2c-designware-core.c    | 6 ++++++
 drivers/i2c/busses/i2c-designware-core.h    | 1 +
 drivers/i2c/busses/i2c-designware-platdrv.c | 4 ++++
 3 files changed, 11 insertions(+)
drivers/i2c/busses/i2c-designware-core.c +0 -0
index 7441cdc..04e7b65 100644

drivers/i2c/busses/i2c-designware-core.c irqreturn_t i2c_dw_isr(int this_irq, void *dev_id) · line 784

Quoted 2 lines
drivers/i2c/busses/i2c-designware-core.c +0 -0
@@ -783,6 +783,9 @@ irqreturn_t i2c_dw_isr(int this_irq, void *dev_id)
 
 	stat = i2c_dw_read_clear_intrbits(dev);

What if the status changes right here, before you go and mask the interrupt?

drivers/i2c/busses/i2c-designware-core.c tx_aborted: · line 818

Quoted 13 lines
drivers/i2c/busses/i2c-designware-core.c +5 -0
+	if (unlikely(dev->accessor_flags & ACCESS_INTR_MASK))
+		i2c_dw_disable_int(dev);
+
 	if (stat & DW_IC_INTR_TX_ABRT) {
 		dev->cmd_err |= DW_IC_ERR_TX_ABRT;
 		dev->status = STATUS_IDLE;
@@ -811,6 +814,9 @@ tx_aborted:
 	if ((stat & (DW_IC_INTR_TX_ABRT | DW_IC_INTR_STOP_DET)) || dev->msg_err)
 		complete(&dev->cmd_complete);
 
+	if (unlikely(dev->accessor_flags & ACCESS_INTR_MASK))
+		dw_writel(dev, DW_IC_INTR_DEFAULT_MASK, DW_IC_INTR_MASK);

The driver disables TX interrupt when it is not needed anymore or when TX gets aborted but the above will re-enable all interrupts regardless. Is that the intention?

Quoted 21 lines
drivers/i2c/busses/i2c-designware-core.c +1 -0
+
 	return IRQ_HANDLED;
 }
 EXPORT_SYMBOL_GPL(i2c_dw_isr);
drivers/i2c/busses/i2c-designware-core.h +1 -0
index 9630222..808ef6a 100644
@@ -111,6 +111,7 @@ struct dw_i2c_dev {
 
 #define ACCESS_SWAP		0x00000001
 #define ACCESS_16BIT		0x00000002
+#define ACCESS_INTR_MASK	0x00000004
 
 extern u32 dw_readl(struct dw_i2c_dev *dev, int offset);
 extern void dw_writel(struct dw_i2c_dev *dev, u32 b, int offset);
drivers/i2c/busses/i2c-designware-platdrv.c +0 -0
index 472b882..0c59357 100644

drivers/i2c/busses/i2c-designware-platdrv.c static int dw_i2c_probe(struct platform_device *pdev) · line 257

Quoted 7 lines
drivers/i2c/busses/i2c-designware-platdrv.c +4 -0
@@ -251,6 +251,10 @@ static int dw_i2c_probe(struct platform_device *pdev)
 		dev->rx_fifo_depth = ((param1 >> 8)  & 0xff) + 1;
 		dev->adapter.nr = pdev->id;
 	}
+
+	if (!strncmp(pdev->name, "AMD0010", 7))
+		dev->accessor_flags |= ACCESS_INTR_MASK;
+

Can't you put this to ->driver_data? For example it could refer to a configuration structure that then contains quirk flags.

Quoted 5 lines
drivers/i2c/busses/i2c-designware-platdrv.c +0 -0
 	r = i2c_dw_init(dev);
 	if (r)
 		return r;
Signature · 1 line
1.9.1
#2 lore raw
Quoted 37 lines

-----Original Message-----
From: Mika Westerberg [mailto:[email protected]]
Sent: Thursday, November 05, 2015 9:52 PM
To: Yu, Xiangliang
Cc: [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; Xue, Ken; Wan, Vincent; Huang, Ray; Wang, Annie; Li, Tony
Subject: Re: [PATCH 1/1] I2C: designware: fix IO timeout issue for AMD controller

Quoted 25 lines · Xiangliang Yu

Because of some hardware limitation, AMD I2C controller can't trigger next 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 after clearing interrupt bits when entering ISR and to enable i2c interrupt before exiting ISR.

To reduce the performance impacts on other vendors, use unlikely function to check flag in ISR.

---
 drivers/i2c/busses/i2c-designware-core.c    | 6 ++++++
 drivers/i2c/busses/i2c-designware-core.h    | 1 +
 drivers/i2c/busses/i2c-designware-platdrv.c | 4 ++++
 3 files changed, 11 insertions(+)
drivers/i2c/busses/i2c-designware-core.c +0 -0
index 7441cdc..04e7b65 100644
@@ -783,6 +783,9 @@ irqreturn_t i2c_dw_isr(int this_irq, void *dev_id)
 
Quoted 3 lines

drivers/i2c/busses/i2c-designware-core.c irqreturn_t i2c_dw_isr(int this_irq, void *dev_id) · line 784

Quoted 1 line
drivers/i2c/busses/i2c-designware-core.c +0 -0
 	stat = i2c_dw_read_clear_intrbits(dev);

What if the status changes right here, before you go and mask the interrupt?

Have no effect, because i2c controller can't trigger next interrupt.

Quoted 13 lines

drivers/i2c/busses/i2c-designware-core.c tx_aborted: · line 814

Quoted 10 lines
drivers/i2c/busses/i2c-designware-core.c +3 -0
+	if (unlikely(dev->accessor_flags & ACCESS_INTR_MASK))
+		i2c_dw_disable_int(dev);
+
 	if (stat & DW_IC_INTR_TX_ABRT) {
 		dev->cmd_err |= DW_IC_ERR_TX_ABRT;
 		dev->status = STATUS_IDLE;
@@ -811,6 +814,9 @@ tx_aborted:
 	if ((stat & (DW_IC_INTR_TX_ABRT | DW_IC_INTR_STOP_DET)) ||

dev->msg_err)

Quoted 2 lines
drivers/i2c/busses/i2c-designware-core.c +0 -0
 		complete(&dev->cmd_complete);
 
Quoted 7 lines

drivers/i2c/busses/i2c-designware-core.c tx_aborted: · line 818

Quoted 2 lines
drivers/i2c/busses/i2c-designware-core.c +2 -0
+	if (unlikely(dev->accessor_flags & ACCESS_INTR_MASK))
+		dw_writel(dev, DW_IC_INTR_DEFAULT_MASK,

DW_IC_INTR_MASK);

The driver disables TX interrupt when it is not needed anymore or when TX gets aborted but the above will re-enable all interrupts regardless. Is that the intention?

No, i2c controller can trigger next interrupt only after re-enable all interrupt.

Quoted 25 lines

drivers/i2c/busses/i2c-designware-platdrv.c static int dw_i2c_probe(struct platform_device

Quoted 24 lines
drivers/i2c/busses/i2c-designware-core.c +1 -0
+
 	return IRQ_HANDLED;
 }
 EXPORT_SYMBOL_GPL(i2c_dw_isr);
drivers/i2c/busses/i2c-designware-core.h +1 -0
index 9630222..808ef6a 100644
@@ -111,6 +111,7 @@ struct dw_i2c_dev {
 
 #define ACCESS_SWAP		0x00000001
 #define ACCESS_16BIT		0x00000002
+#define ACCESS_INTR_MASK	0x00000004
 
 extern u32 dw_readl(struct dw_i2c_dev *dev, int offset);  extern void

dw_writel(struct dw_i2c_dev *dev, u32 b, int offset); diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 472b882..0c59357 100644

drivers/i2c/busses/i2c-designware-platdrv.c +0 -0
@@ -251,6 +251,10 @@ static int dw_i2c_probe(struct platform_device

*pdev)

Quoted 10 lines

drivers/i2c/busses/i2c-designware-platdrv.c static int dw_i2c_probe(struct platform_device *pdev) · line 257

Quoted 7 lines
drivers/i2c/busses/i2c-designware-platdrv.c +4 -0
 		dev->rx_fifo_depth = ((param1 >> 8)  & 0xff) + 1;
 		dev->adapter.nr = pdev->id;
 	}
+
+	if (!strncmp(pdev->name, "AMD0010", 7))
+		dev->accessor_flags |= ACCESS_INTR_MASK;
+

Can't you put this to ->driver_data? For example it could refer to a configuration structure that then contains quirk flags.

I think it will need to add a function to support it, but the function Is rarely used. It will easy to add if i2c driver has quirk mechanisms. Added code is very simple and have no influence on others.

Quoted 6 lines
Quoted 6 lines
drivers/i2c/busses/i2c-designware-platdrv.c +0 -1
 	r = i2c_dw_init(dev);
 	if (r)
 		return r;
--

1.9.1

maintainer
#3 lore raw
Quoted 55 lines · Xiangliang
Quoted 37 lines

-----Original Message-----
From: Mika Westerberg [mailto:[email protected]]
Sent: Thursday, November 05, 2015 9:52 PM
To: Yu, Xiangliang
Cc: [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; Xue, Ken; Wan, Vincent; Huang, Ray; Wang, Annie; Li, Tony
Subject: Re: [PATCH 1/1] I2C: designware: fix IO timeout issue for AMD controller

Quoted 25 lines · Xiangliang Yu

Because of some hardware limitation, AMD I2C controller can't trigger next 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 after clearing interrupt bits when entering ISR and to enable i2c interrupt before exiting ISR.

To reduce the performance impacts on other vendors, use unlikely function to check flag in ISR.

---
 drivers/i2c/busses/i2c-designware-core.c    | 6 ++++++
 drivers/i2c/busses/i2c-designware-core.h    | 1 +
 drivers/i2c/busses/i2c-designware-platdrv.c | 4 ++++
 3 files changed, 11 insertions(+)
drivers/i2c/busses/i2c-designware-core.c +0 -0
index 7441cdc..04e7b65 100644
@@ -783,6 +783,9 @@ irqreturn_t i2c_dw_isr(int this_irq, void *dev_id)
 
Quoted 3 lines

drivers/i2c/busses/i2c-designware-core.c irqreturn_t i2c_dw_isr(int this_irq, void *dev_id) · line 784

Quoted 1 line
drivers/i2c/busses/i2c-designware-core.c +0 -0
 	stat = i2c_dw_read_clear_intrbits(dev);

What if the status changes right here, before you go and mask the interrupt?

Have no effect, because i2c controller can't trigger next interrupt.

Quoted 13 lines

drivers/i2c/busses/i2c-designware-core.c tx_aborted: · line 814

Quoted 10 lines
drivers/i2c/busses/i2c-designware-core.c +3 -0
+	if (unlikely(dev->accessor_flags & ACCESS_INTR_MASK))
+		i2c_dw_disable_int(dev);
+
 	if (stat & DW_IC_INTR_TX_ABRT) {
 		dev->cmd_err |= DW_IC_ERR_TX_ABRT;
 		dev->status = STATUS_IDLE;
@@ -811,6 +814,9 @@ tx_aborted:
 	if ((stat & (DW_IC_INTR_TX_ABRT | DW_IC_INTR_STOP_DET)) ||

dev->msg_err)

Quoted 2 lines
drivers/i2c/busses/i2c-designware-core.c +0 -0
 		complete(&dev->cmd_complete);
 
Quoted 8 lines
Quoted 7 lines

drivers/i2c/busses/i2c-designware-core.c tx_aborted: · line 818

Quoted 2 lines
drivers/i2c/busses/i2c-designware-core.c +2 -0
+	if (unlikely(dev->accessor_flags & ACCESS_INTR_MASK))
+		dw_writel(dev, DW_IC_INTR_DEFAULT_MASK,

DW_IC_INTR_MASK);

The driver disables TX interrupt when it is not needed anymore or when TX gets aborted but the above will re-enable all interrupts regardless. Is that the intention?

No, i2c controller can trigger next interrupt only after re-enable all interrupt.

If you get an error the function masks all interrupts and jumps to tx_aborted label. With this patch you unmask all interrupts again before exiting the function.

Quoted 35 lines
Quoted 25 lines

drivers/i2c/busses/i2c-designware-platdrv.c static int dw_i2c_probe(struct platform_device

Quoted 24 lines
drivers/i2c/busses/i2c-designware-core.c +1 -0
+
 	return IRQ_HANDLED;
 }
 EXPORT_SYMBOL_GPL(i2c_dw_isr);
drivers/i2c/busses/i2c-designware-core.h +1 -0
index 9630222..808ef6a 100644
@@ -111,6 +111,7 @@ struct dw_i2c_dev {
 
 #define ACCESS_SWAP		0x00000001
 #define ACCESS_16BIT		0x00000002
+#define ACCESS_INTR_MASK	0x00000004
 
 extern u32 dw_readl(struct dw_i2c_dev *dev, int offset);  extern void

dw_writel(struct dw_i2c_dev *dev, u32 b, int offset); diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 472b882..0c59357 100644

drivers/i2c/busses/i2c-designware-platdrv.c +0 -0
@@ -251,6 +251,10 @@ static int dw_i2c_probe(struct platform_device

*pdev)

Quoted 10 lines

drivers/i2c/busses/i2c-designware-platdrv.c static int dw_i2c_probe(struct platform_device *pdev) · line 257

Quoted 7 lines
drivers/i2c/busses/i2c-designware-platdrv.c +4 -0
 		dev->rx_fifo_depth = ((param1 >> 8)  & 0xff) + 1;
 		dev->adapter.nr = pdev->id;
 	}
+
+	if (!strncmp(pdev->name, "AMD0010", 7))
+		dev->accessor_flags |= ACCESS_INTR_MASK;
+

Can't you put this to ->driver_data? For example it could refer to a configuration structure that then contains quirk flags.

Quoted 3 lines

I think it will need to add a function to support it, but the function Is rarely used. It will easy to add if i2c driver has quirk mechanisms. Added code is very simple and have no influence on others.

What if the next AMD I2C controller needs another quirk, and then another?

I would rather pass flags or similar (reference to config structure including flags) with ->driver_data.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/i2c/busses/i2c-designware-platdrv.c +0 -1
 	r = i2c_dw_init(dev);
 	if (r)
 		return r;
--

1.9.1

#4 lore raw
Quoted 75 lines

-----Original Message-----
From: Mika Westerberg [mailto:[email protected]]
Sent: Friday, November 06, 2015 3:46 PM
To: Yu, Xiangliang
Cc: [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; Xue, Ken; Wan, Vincent; Huang, Ray; Wang, Annie; Li, Tony
Subject: Re: [PATCH 1/1] I2C: designware: fix IO timeout issue for AMD controller

Quoted 38 lines · Xiangliang
Quoted 38 lines

-----Original Message-----
From: Mika Westerberg [mailto:[email protected]]
Sent: Thursday, November 05, 2015 9:52 PM
To: Yu, Xiangliang
Cc: [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; Xue, Ken; Wan, Vincent; Huang, Ray; Wang, Annie; Li, Tony
Subject: Re: [PATCH 1/1] I2C: designware: fix IO timeout issue for AMD controller

Quoted 26 lines · Xiangliang Yu

Because of some hardware limitation, AMD I2C controller can't trigger next 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 after clearing interrupt bits when entering ISR and to enable i2c interrupt before exiting ISR.

To reduce the performance impacts on other vendors, use unlikely function to check flag in ISR.

---
 drivers/i2c/busses/i2c-designware-core.c    | 6 ++++++
 drivers/i2c/busses/i2c-designware-core.h    | 1 +
 drivers/i2c/busses/i2c-designware-platdrv.c | 4 ++++
 3 files changed, 11 insertions(+)
drivers/i2c/busses/i2c-designware-core.c +0 -0
index 7441cdc..04e7b65 100644
@@ -783,6 +783,9 @@ irqreturn_t i2c_dw_isr(int this_irq, void
 *dev_id)
 
Quoted 3 lines
Quoted 3 lines

drivers/i2c/busses/i2c-designware-core.c irqreturn_t i2c_dw_isr(int this_irq, void *dev_id) · line 784

Quoted 1 line
drivers/i2c/busses/i2c-designware-core.c +0 -0
 	stat = i2c_dw_read_clear_intrbits(dev);

What if the status changes right here, before you go and mask the

interrupt?

Quoted 21 lines

Have no effect, because i2c controller can't trigger next interrupt.

Quoted 19 lines

drivers/i2c/busses/i2c-designware-core.c tx_aborted: · line 814

Quoted 10 lines
drivers/i2c/busses/i2c-designware-core.c +3 -0
+	if (unlikely(dev->accessor_flags & ACCESS_INTR_MASK))
+		i2c_dw_disable_int(dev);
+
 	if (stat & DW_IC_INTR_TX_ABRT) {
 		dev->cmd_err |= DW_IC_ERR_TX_ABRT;
 		dev->status = STATUS_IDLE;
@@ -811,6 +814,9 @@ tx_aborted:
 	if ((stat & (DW_IC_INTR_TX_ABRT | DW_IC_INTR_STOP_DET)) ||

dev->msg_err)

drivers/i2c/busses/i2c-designware-core.c tx_aborted:

Quoted 4 lines
drivers/i2c/busses/i2c-designware-core.c +2 -0
 		complete(&dev->cmd_complete);
 
+	if (unlikely(dev->accessor_flags & ACCESS_INTR_MASK))
+		dw_writel(dev, DW_IC_INTR_DEFAULT_MASK,

DW_IC_INTR_MASK);

The driver disables TX interrupt when it is not needed anymore or when TX gets aborted but the above will re-enable all interrupts

Quoted 8 lines

regardless.

Quoted 2 lines
Quoted 1 line

Is that the intention?

No, i2c controller can trigger next interrupt only after re-enable all interrupt.

If you get an error the function masks all interrupts and jumps to tx_aborted label. With this patch you unmask all interrupts again before exiting the function.

I see, how about change if statement to else if?

Quoted 36 lines
Quoted 36 lines
Quoted 36 lines
Quoted 24 lines
drivers/i2c/busses/i2c-designware-core.c +1 -0
+
 	return IRQ_HANDLED;
 }
 EXPORT_SYMBOL_GPL(i2c_dw_isr);
drivers/i2c/busses/i2c-designware-core.h +1 -0
index 9630222..808ef6a 100644
@@ -111,6 +111,7 @@ struct dw_i2c_dev {
 
 #define ACCESS_SWAP		0x00000001
 #define ACCESS_16BIT		0x00000002
+#define ACCESS_INTR_MASK	0x00000004
 
 extern u32 dw_readl(struct dw_i2c_dev *dev, int offset);  extern

void dw_writel(struct dw_i2c_dev *dev, u32 b, int offset); diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 472b882..0c59357 100644

drivers/i2c/busses/i2c-designware-platdrv.c +0 -0
@@ -251,6 +251,10 @@ static int dw_i2c_probe(struct
Quoted 1 line

platform_device

*pdev)

drivers/i2c/busses/i2c-designware-platdrv.c static int dw_i2c_probe(struct platform_device *pdev) · line 257

Quoted 7 lines
drivers/i2c/busses/i2c-designware-platdrv.c +4 -0
 		dev->rx_fifo_depth = ((param1 >> 8)  & 0xff) + 1;
 		dev->adapter.nr = pdev->id;
 	}
+
+	if (!strncmp(pdev->name, "AMD0010", 7))
+		dev->accessor_flags |= ACCESS_INTR_MASK;
+

Can't you put this to ->driver_data? For example it could refer to a configuration structure that then contains quirk flags.

Quoted 9 lines
Quoted 3 lines

I think it will need to add a function to support it, but the function Is rarely used. It will easy to add if i2c driver has quirk mechanisms. Added code is very simple and have no influence on others.

What if the next AMD I2C controller needs another quirk, and then another?

I would rather pass flags or similar (reference to config structure including flags) with ->driver_data.

I don't think there is another quirk.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/i2c/busses/i2c-designware-platdrv.c +0 -1
 	r = i2c_dw_init(dev);
 	if (r)
 		return r;
--

1.9.1

#6 lore raw
In reply to Yu, Xiangliang
Quoted 11 lines · Xiangliang
Quoted 9 lines

-----Original Message-----
From: Mika Westerberg [mailto:[email protected]]

drivers/i2c/busses/i2c-designware-core.c irqreturn_t i2c_dw_isr(int this_irq, void *dev_id) · line 784

Quoted 5 lines
drivers/i2c/busses/i2c-designware-core.c +0 -0
@@ -783,6 +783,9 @@ irqreturn_t i2c_dw_isr(int this_irq, void *dev_id)
 
  	stat = i2c_dw_read_clear_intrbits(dev);

What if the status changes right here, before you go and mask the interrupt?

Have no effect, because i2c controller can't trigger next interrupt.

Does it mean possible lost interrupt too? I guess it can be debugged by placing a few ms long mdelay() between clearing and masking.

How frequent is this timeout? I guess lost interrupt is somehow nearly related to clearing, masking and unmasking if that cycle helps. One thing that comes to my mind is masking needed and could plain unmasking be also a working workaround?

Have you tried to print DW_IC_INTR_STAT, DW_IC_INTR_MASK and DW_IC_RAW_INTR_STAT when timeout occurs? E.g. just after printing the timeout out error in i2c_dw_xfer(). Probably good in i2c_dw_isr() too if if doesn't produce too much data and make debugging impossible.

Signature · 1 line
Jarkko
#7 lore raw
Quoted 18 lines

-----Original Message-----
From: Jarkko Nikula [mailto:[email protected]]
Sent: Friday, November 06, 2015 5:00 PM
To: Yu, Xiangliang; Mika Westerberg
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; Xue, Ken; Wan, Vincent; Huang, Ray; Wang, Annie; Li, Tony
Subject: Re: [PATCH 1/1] I2C: designware: fix IO timeout issue for AMD controller

Quoted 7 lines · Xiangliang
Quoted 7 lines

-----Original Message-----
From: Mika Westerberg [mailto:[email protected]]

Quoted 5 lines
drivers/i2c/busses/i2c-designware-core.c +0 -0
@@ -783,6 +783,9 @@ irqreturn_t i2c_dw_isr(int this_irq, void
 *dev_id)
 
Quoted 9 lines
Quoted 3 lines
Quoted 3 lines

drivers/i2c/busses/i2c-designware-core.c irqreturn_t i2c_dw_isr(int this_irq, void *dev_id) · line 784

Quoted 1 line
drivers/i2c/busses/i2c-designware-core.c +0 -0
  	stat = i2c_dw_read_clear_intrbits(dev);

What if the status changes right here, before you go and mask the

interrupt?

Quoted 2 lines

Have no effect, because i2c controller can't trigger next interrupt.

Does it mean possible lost interrupt too? I guess it can be debugged by placing a few ms long mdelay() between clearing and masking.

The interrupt will not be lost if status bits change before masking interrupt.

Quoted 4 lines

How frequent is this timeout? I guess lost interrupt is somehow nearly related to clearing, masking and unmasking if that cycle helps. One thing that comes to my mind is masking needed and could plain unmasking be also a working workaround?

Quite frequently.

Quoted 6 lines

Have you tried to print DW_IC_INTR_STAT, DW_IC_INTR_MASK and DW_IC_RAW_INTR_STAT when timeout occurs? E.g. just after printing the timeout out error in i2c_dw_xfer(). Probably good in i2c_dw_isr() too if if doesn't produce too much data and make debugging impossible.

Yes, I have tried to print these status. I have confirmed the issue with hardware engineer.

#5 lore raw
In reply to Yu, Xiangliang
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

The driver disables TX interrupt when it is not needed anymore or when TX gets aborted but the above will re-enable all interrupts

regardless.

Quoted 1 line
Quoted 1 line

Is that the intention?

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

No, i2c controller can trigger next interrupt only after re-enable all interrupt.

If you get an error the function masks all interrupts and jumps to tx_aborted label. With this patch you unmask all interrupts again before exiting the function.

I see, how about change if statement to else if?

That sounds to me that a V2 is needed, or? Marking as "Changes requested"...