Skip to contentSkip to conversation

i2c: mediatek: Disable i2c start_en and clear intr_stat brfore reset

PATCH In review [email protected] 2 participants 4 messages May 27, 2021 – May 28, 2021

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 i2c: mediatek: Disable i2c start_en and clear intr_stat brfore reset

From: Qii Wang <[email protected]>

The i2c controller driver do dma reset after transfer timeout, but sometimes dma reset will trigger an unexpected DMA_ERR irq. It will cause the i2c controller to continuously send interrupts to the system and cause soft lock-up. So we need to disable i2c start_en and clear intr_stat to stop i2c controller before dma reset when transfer timeout.

---
 drivers/i2c/busses/i2c-mt65xx.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/i2c/busses/i2c-mt65xx.c +5 -0
index ea337ba..bfd80b2 100644
@@ -479,6 +479,11 @@ static void mtk_i2c_clock_disable(struct mtk_i2c *i2c)
 static void mtk_i2c_init_hw(struct mtk_i2c *i2c)
 {
 	u16 control_reg;
+	u16 intr_stat_reg;
+
+	mtk_i2c_writew(i2c, I2C_CHN_CLR_FLAG, OFFSET_START);
+	intr_stat_reg = mtk_i2c_readw(i2c, OFFSET_INTR_STAT);
+	mtk_i2c_writew(i2c, intr_stat_reg, OFFSET_INTR_STAT);
 
 	if (i2c->dev_comp->apdma_sync) {
 		writel(I2C_DMA_WARM_RST, i2c->pdmabase + OFFSET_RST);
Signature · 1 line
1.9.1
#1 lore raw
Quoted 10 lines · On Thu, May 27, 2021 at 08:04:04PM +0800, [email protected] wrote:

From: Qii Wang <[email protected]>

The i2c controller driver do dma reset after transfer timeout, but sometimes dma reset will trigger an unexpected DMA_ERR irq. It will cause the i2c controller to continuously send interrupts to the system and cause soft lock-up. So we need to disable i2c start_en and clear intr_stat to stop i2c controller before dma reset when transfer timeout.

Is there a suitable Fixes tag for this?

author maintainer
#2 lore raw
Quoted 10 lines · Wolfram Sang
Quoted 9 lines · On Thu, May 27, 2021 at 08:04:04PM +0800, [email protected] wrote:

From: Qii Wang <[email protected]>

The i2c controller driver do dma reset after transfer timeout, but sometimes dma reset will trigger an unexpected DMA_ERR irq. It will cause the i2c controller to continuously send interrupts to the system and cause soft lock-up. So we need to disable i2c start_en and clear intr_stat to stop i2c controller before dma reset when transfer timeout.

Quoted 4 lines
Quoted 1 line

Is there a suitable Fixes tag for this?

Can you help to add the following tag, thanks

Fixes aafced673c06("i2c: mediatek: move dma reset before i2c reset")
#3 lore raw
Quoted 11 lines · Qii Wang
Quoted 10 lines · Wolfram Sang
Quoted 9 lines · On Thu, May 27, 2021 at 08:04:04PM +0800, [email protected] wrote:

From: Qii Wang <[email protected]>

The i2c controller driver do dma reset after transfer timeout, but sometimes dma reset will trigger an unexpected DMA_ERR irq. It will cause the i2c controller to continuously send interrupts to the system and cause soft lock-up. So we need to disable i2c start_en and clear intr_stat to stop i2c controller before dma reset when transfer timeout.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Is there a suitable Fixes tag for this?

Can you help to add the following tag, thanks

Fixes aafced673c06("i2c: mediatek: move dma reset before i2c reset")

Added this tag and applied to for-current, thanks!