2020-10-30 12:00:28

by Qii Wang (王琪)

[permalink] [raw]
Subject: [PATCH] i2c: mediatek: move dma reset before i2c reset

From: Qii Wang <[email protected]>

The i2c driver default do dma reset after i2c reset, but sometimes
i2c reset will trigger dma tx2rx, then apdma write data to dram
which has been i2c_put_dma_safe_msg_buf(kfree). Move dma reset
before i2c reset in mtk_i2c_init_hw to fix it.

Signed-off-by: Qii Wang <[email protected]>
---
drivers/i2c/busses/i2c-mt65xx.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
index 0cbdfbe..33de99b 100644
--- a/drivers/i2c/busses/i2c-mt65xx.c
+++ b/drivers/i2c/busses/i2c-mt65xx.c
@@ -475,6 +475,10 @@ static void mtk_i2c_init_hw(struct mtk_i2c *i2c)
{
u16 control_reg;

+ writel(I2C_DMA_HARD_RST, i2c->pdmabase + OFFSET_RST);
+ udelay(50);
+ writel(I2C_DMA_CLR_FLAG, i2c->pdmabase + OFFSET_RST);
+
mtk_i2c_writew(i2c, I2C_SOFT_RST, OFFSET_SOFTRESET);

/* Set ioconfig */
@@ -529,10 +533,6 @@ static void mtk_i2c_init_hw(struct mtk_i2c *i2c)

mtk_i2c_writew(i2c, control_reg, OFFSET_CONTROL);
mtk_i2c_writew(i2c, I2C_DELAY_LEN, OFFSET_DELAY_LEN);
-
- writel(I2C_DMA_HARD_RST, i2c->pdmabase + OFFSET_RST);
- udelay(50);
- writel(I2C_DMA_CLR_FLAG, i2c->pdmabase + OFFSET_RST);
}

static const struct i2c_spec_values *mtk_i2c_get_spec(unsigned int speed)
--
1.9.1


2020-11-03 21:19:11

by Wolfram Sang

[permalink] [raw]
Subject: Re: [PATCH] i2c: mediatek: move dma reset before i2c reset

On Fri, Oct 30, 2020 at 07:58:01PM +0800, [email protected] wrote:
> From: Qii Wang <[email protected]>
>
> The i2c driver default do dma reset after i2c reset, but sometimes
> i2c reset will trigger dma tx2rx, then apdma write data to dram
> which has been i2c_put_dma_safe_msg_buf(kfree). Move dma reset
> before i2c reset in mtk_i2c_init_hw to fix it.
>
> Signed-off-by: Qii Wang <[email protected]>

Applied to for-current, thanks!


Attachments:
(No filename) (463.00 B)
signature.asc (849.00 B)
Download all attachments