hw/i2c/aspeed: Fix wrong I2CC_DMA_LEN when I2CM_DMA_TX/RX_ADDR set first
PATCH 1/1 hw/i2c/aspeed: Fix wrong I2CC_DMA_LEN when I2CM_DMA_TX/RX_ADDR set first
In the previous design, the I2C model would update I2CC_DMA_LEN (0x54) based on the value of I2CM_DMA_LEN (0x1C) when the firmware set either I2CM_DMA_TX_ADDR (0x30) or I2CM_DMA_RX_ADDR (0x34). However, this only worked correctly if the firmware set I2CM_DMA_LEN before setting I2CM_DMA_TX_ADDR or I2CM_DMA_RX_ADDR.
If the firmware instead set I2CM_DMA_TX_ADDR or I2CM_DMA_RX_ADDR before setting I2CM_DMA_LEN, the value written to I2CC_DMA_LEN would be incorrect.
To fix this issue, the model should be updated to set I2CC_DMA_LEN when the firmware writes to the I2CM_DMA_LEN register, rather than when it writes to the I2CM_DMA_RX_ADDR and I2CM_DMA_TX_ADDR registers.
--- hw/i2c/aspeed_i2c.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
hw/i2c/aspeed_i2c.c +6 -4
@@ -656,8 +656,6 @@ static void aspeed_i2c_bus_new_write(AspeedI2CBus *bus, hwaddr offset, bus->dma_dram_offset =deposit64 (bus->dma_dram_offset,0 ,32 ,FIELD_EX32 (value,I2CM_DMA_TX_ADDR ,ADDR )); - bus->regs[R_I2CC_DMA_LEN ] =ARRAY_FIELD_EX32 (bus->regs,I2CM_DMA_LEN , -TX_BUF_LEN ) +1 ;break ;case A_I2CM_DMA_RX_ADDR : bus->regs[R_I2CM_DMA_RX_ADDR] = FIELD_EX32(value, I2CM_DMA_RX_ADDR,
@@ -665,8 +663,6 @@ static void aspeed_i2c_bus_new_write(AspeedI2CBus *bus, hwaddr offset, bus->dma_dram_offset =deposit64 (bus->dma_dram_offset,0 ,32 ,FIELD_EX32 (value,I2CM_DMA_RX_ADDR ,ADDR )); - bus->regs[R_I2CC_DMA_LEN ] =ARRAY_FIELD_EX32 (bus->regs,I2CM_DMA_LEN , -RX_BUF_LEN ) +1 ;break ;case A_I2CM_DMA_LEN : w1t = FIELD_EX32(value, I2CM_DMA_LEN, RX_BUF_LEN_W1T) ||
@@ -679,10 +675,16 @@ static void aspeed_i2c_bus_new_write(AspeedI2CBus *bus, hwaddr offset,if (FIELD_EX32 (value,I2CM_DMA_LEN ,RX_BUF_LEN_W1T )) {ARRAY_FIELD_DP32 (bus->regs,I2CM_DMA_LEN ,RX_BUF_LEN ,FIELD_EX32 (value,I2CM_DMA_LEN ,RX_BUF_LEN )); + bus->regs[R_I2CC_DMA_LEN ] =ARRAY_FIELD_EX32 (bus->regs, +I2CM_DMA_LEN , +RX_BUF_LEN ) +1 ; }if (FIELD_EX32 (value,I2CM_DMA_LEN ,TX_BUF_LEN_W1T )) {ARRAY_FIELD_DP32 (bus->regs,I2CM_DMA_LEN ,TX_BUF_LEN ,FIELD_EX32 (value,I2CM_DMA_LEN ,TX_BUF_LEN )); + bus->regs[R_I2CC_DMA_LEN ] =ARRAY_FIELD_EX32 (bus->regs, +I2CM_DMA_LEN , +TX_BUF_LEN ) +1 ; }break ;case A_I2CM_DMA_LEN_STS :
Signature · 1 line
2.43.0
Hello Jamin
Quoted 8 lines · Jamin Lin
In the previous design, the I2C model would update
I2CC_DMA_LEN(0x54) based on the value ofI2CM_DMA_LEN(0x1C) when the firmware set eitherI2CM_DMA_TX_ADDR(0x30) orI2CM_DMA_RX_ADDR(0x34). However, this only worked correctly if the firmware setI2CM_DMA_LENbefore settingI2CM_DMA_TX_ADDRorI2CM_DMA_RX_ADDR.If the firmware instead set
I2CM_DMA_TX_ADDRorI2CM_DMA_RX_ADDRbefore settingI2CM_DMA_LEN, the value written toI2CC_DMA_LENwould be incorrect.
Quoted 7 lines
To fix this issue, the model should be updated to set
I2CC_DMA_LENwhen the firmware writes to theI2CM_DMA_LENregister, rather than when it writes to theI2CM_DMA_RX_ADDRandI2CM_DMA_TX_ADDRregisters.Signed-off-by Jamin Lin <[email protected]>Fixes ba2cccd (aspeed: i2c: Add new mode support)Change-Id Ibb4039773a88ba4f2ebda7f1ab5b5f9e99d22456
It looks like this is breaking the functional test. Could you check please ?
Thanks,
C.
Quoted 43 lines
--- hw/i2c/aspeed_i2c.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)hw/i2c/aspeed_i2c.c +6
-4@@ -656,8 +656,6 @@ static void aspeed_i2c_bus_new_write(AspeedI2CBus *bus, hwaddr offset, bus->dma_dram_offset =deposit64 (bus->dma_dram_offset,0 ,32 ,FIELD_EX32 (value,I2CM_DMA_TX_ADDR ,ADDR )); - bus->regs[R_I2CC_DMA_LEN ] =ARRAY_FIELD_EX32 (bus->regs,I2CM_DMA_LEN , -TX_BUF_LEN ) +1 ;break ;case A_I2CM_DMA_RX_ADDR : bus->regs[R_I2CM_DMA_RX_ADDR] = FIELD_EX32(value, I2CM_DMA_RX_ADDR,@@ -665,8 +663,6 @@ static void aspeed_i2c_bus_new_write(AspeedI2CBus *bus, hwaddr offset, bus->dma_dram_offset =deposit64 (bus->dma_dram_offset,0 ,32 ,FIELD_EX32 (value,I2CM_DMA_RX_ADDR ,ADDR )); - bus->regs[R_I2CC_DMA_LEN ] =ARRAY_FIELD_EX32 (bus->regs,I2CM_DMA_LEN , -RX_BUF_LEN ) +1 ;break ;case A_I2CM_DMA_LEN : w1t = FIELD_EX32(value, I2CM_DMA_LEN, RX_BUF_LEN_W1T) ||@@ -679,10 +675,16 @@ static void aspeed_i2c_bus_new_write(AspeedI2CBus *bus, hwaddr offset,if (FIELD_EX32 (value,I2CM_DMA_LEN ,RX_BUF_LEN_W1T )) {ARRAY_FIELD_DP32 (bus->regs,I2CM_DMA_LEN ,RX_BUF_LEN ,FIELD_EX32 (value,I2CM_DMA_LEN ,RX_BUF_LEN )); + bus->regs[R_I2CC_DMA_LEN ] =ARRAY_FIELD_EX32 (bus->regs, +I2CM_DMA_LEN , +RX_BUF_LEN ) +1 ; }if (FIELD_EX32 (value,I2CM_DMA_LEN ,TX_BUF_LEN_W1T )) {ARRAY_FIELD_DP32 (bus->regs,I2CM_DMA_LEN ,TX_BUF_LEN ,FIELD_EX32 (value,I2CM_DMA_LEN ,TX_BUF_LEN )); + bus->regs[R_I2CC_DMA_LEN ] =ARRAY_FIELD_EX32 (bus->regs, +I2CM_DMA_LEN , +TX_BUF_LEN ) +1 ; }break ;case A_I2CM_DMA_LEN_STS :
Hi Cedric,
Quoted 21 lines
Cc: Troy Lee <[email protected]>; [email protected]
Subject: Re: [PATCH v1 1/1] hw/i2c/aspeed: Fix wrongI2CC_DMA_LENwhen I2CM_DMA_TX/RX_ADDR set firstHello Jamin
Quoted 5 lines · Jamin Lin
In the previous design, the I2C model would update
I2CC_DMA_LEN(0x54) based on the value ofI2CM_DMA_LEN(0x1C) when the firmware set eitherI2CM_DMA_TX_ADDR
(0x30) orI2CM_DMA_RX_ADDR(0x34). However, this only worked correctly if the firmware setI2CM_DMA_LENbefore settingI2CM_DMA_TX_ADDRor
I2CM_DMA_RX_ADDR.Quoted 3 lines
If the firmware instead set
I2CM_DMA_TX_ADDRorI2CM_DMA_RX_ADDRbefore settingI2CM_DMA_LEN, the value written toI2CC_DMA_LENwouldbe incorrect.
Quoted 4 lines
To fix this issue, the model should be updated to set
I2CC_DMA_LENwhen the firmware writes to theI2CM_DMA_LENregister, rather than when it writes to theI2CM_DMA_RX_ADDRandI2CM_DMA_TX_ADDR
Quoted 8 lines
registers.
Quoted 4 lines
Signed-off-by Jamin Lin <[email protected]>Fixes ba2cccd (aspeed: i2c: Add new mode support)Change-Id Ibb4039773a88ba4f2ebda7f1ab5b5f9e99d22456It looks like this is breaking the functional test. Could you check please ?
Thanks for review.
Will check functional test issue
Jamin
Quoted 72 lines
Thanks,
C.
hw/i2c/aspeed_i2c.c static void
Quoted 9 lines
--- hw/i2c/aspeed_i2c.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)hw/i2c/aspeed_i2c.c index renamed from hw/i2c/aspeed_i2c.c +0
-0
a8fbb9f44a..c68b8a5ec0100644hw/i2c/aspeed_i2c.c +0
-0@@ -656,8 +656,6 @@ static voidaspeed_i2c_bus_new_write(AspeedI2CBus *bus, hwaddr offset,
hw/i2c/aspeed_i2c.c static void aspeed_i2c_bus_new_write(AspeedI2CBus *bus, hwaddr offset,
Quoted 3 lines
hw/i2c/aspeed_i2c.c +0
-0bus->dma_dram_offset = deposit64(bus->dma_dram_offset, 0, 32, FIELD_EX32(value, I2CM_DMA_TX_ADDR,ADDR));
hw/i2c/aspeed_i2c.c static void · line 659
Quoted 1 line
hw/i2c/aspeed_i2c.c +0
-1- bus->regs[R_I2CC_DMA_LEN] = ARRAY_FIELD_EX32(bus->regs,
I2CM_DMA_LEN,hw/i2c/aspeed_i2c.c static void · line 660
Quoted 1 line
hw/i2c/aspeed_i2c.c +0
-1-
TX_BUF_LEN) + 1;Quoted 4 lines
hw/i2c/aspeed_i2c.c +0
-0break ;case A_I2CM_DMA_RX_ADDR : bus->regs[R_I2CM_DMA_RX_ADDR] = FIELD_EX32(value,
I2CM_DMA_RX_ADDR, @@ -665,8 +663,6 @@ static voidaspeed_i2c_bus_new_write(AspeedI2CBus *bus, hwaddr offset,
Quoted 3 lines
bus->dma_dram_offset = deposit64(bus->dma_dram_offset, 0, 32, FIELD_EX32(value, I2CM_DMA_RX_ADDR,ADDR));
Quoted 1 line
- bus->regs[R_I2CC_DMA_LEN] = ARRAY_FIELD_EX32(bus->regs,
I2CM_DMA_LEN,Quoted 1 line
-
RX_BUF_LEN) + 1;Quoted 3 lines
break; case A_I2CM_DMA_LEN: w1t = FIELD_EX32(value, I2CM_DMA_LEN, RX_BUF_LEN_W1T)|| @@
Quoted 1 line
-679,10 +675,16 @@ static void aspeed_i2c_bus_new_write(AspeedI2CBus
*bus, hwaddr offset,
Quoted 2 lines
if (FIELD_EX32(value, I2CM_DMA_LEN, RX_BUF_LEN_W1T)) { ARRAY_FIELD_DP32(bus->regs, I2CM_DMA_LEN,
RX_BUF_LEN,Quoted 3 lines
FIELD_EX32(value, I2CM_DMA_LEN,
RX_BUF_LEN));
+ bus->regs[R_I2CC_DMA_LEN] =ARRAY_FIELD_EX32(bus->regs,
Quoted 1 line
+
I2CM_DMA_LEN,Quoted 1 line
+
RX_BUF_LEN)Quoted 4 lines
+ + 1; } if (FIELD_EX32(value, I2CM_DMA_LEN, TX_BUF_LEN_W1T)) { ARRAY_FIELD_DP32(bus->regs, I2CM_DMA_LEN,
TX_BUF_LEN,Quoted 3 lines
FIELD_EX32(value, I2CM_DMA_LEN,
TX_BUF_LEN));
+ bus->regs[R_I2CC_DMA_LEN] =ARRAY_FIELD_EX32(bus->regs,
Quoted 1 line
+
I2CM_DMA_LEN,Quoted 1 line
+
TX_BUF_LEN)Quoted 4 lines
+ + 1; } break; case A_I2CM_DMA_LEN_STS: