i2c: aspeed: Consider i2c reset for muti-master case
Subsystems (4)
PATCH 1/1 i2c: aspeed: Consider i2c reset for muti-master case
In the original code, the device reset would not be triggered when the driver is set to multi-master and bus is free. It needs to be considered with multi-master condition.
--- drivers/i2c/busses/i2c-aspeed.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/i2c/busses/i2c-aspeed.c +8 -7
@@ -716,14 +716,15 @@ static int aspeed_i2c_master_xfer(struct i2c_adapter *adap,if (time_left ==0 ) {/* * In a multi-master setup, if a timeout occurs, attempt -* recovery. But if the bus is idle, we still need to reset the -* i2c controller to clear the remaining interrupts. +* recovery device. But if the bus is idle, +* we still need to reset the i2c controller to clear +* the remaining interrupts or reset device abnormal condition. */ -if (bus->multi_master && - (readl (bus->base +ASPEED_I2C_CMD_REG ) & -ASPEED_I2CD_BUS_BUSY_STS )) -aspeed_i2c_recover_bus (bus); -else +if ((readl (bus->base +ASPEED_I2C_CMD_REG ) & +ASPEED_I2CD_BUS_BUSY_STS )){ +if (bus->multi_master) +aspeed_i2c_recover_bus (bus); + }else aspeed_i2c_reset (bus);/*
Signature · 1 line
2.25.1
kernel test robot
build botFYI: kernel test robot notices the stable kernel rule is not satisfied.
Hi,
Thanks for your patch.
FYI: kernel test robot notices the stable kernel rule is not satisfied.
The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1
Rule: add the tag "Cc: [email protected]" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH] i2c: aspeed: Consider i2c reset for muti-master case
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Andrew Jeffery
maintainerHi Tommy,
Quoted 2 lines · Tommy Huang
In the original code, the device reset would not be triggered when the driver is set to multi-master and bus is free.
That's not how I read the existing code. As it stands, if it's multi- master and busy we do the recovery, however, if it's multi-master and free, or busy but not multi-master, or free and not multi-master, then we do the reset.
Quoted 1 line
It needs to be considered with multi-master condition.
Is there a specific circumstance you've found that's problematic? Can you provide some more details about that scenario?
Quoted 21 lines
Fixes <f327c686d3ba> ("i2c: aspeed: Reset the i2c controller when timeout occurs")Signed-off-by Tommy Huang <[email protected]>--- drivers/i2c/busses/i2c-aspeed.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)drivers/i2c/busses/i2c-aspeed.c +3
-2@@ -716,14 +716,15 @@ static int aspeed_i2c_master_xfer(struct i2c_adapter *adap,if (time_left ==0 ) {/* * In a multi-master setup, if a timeout occurs, attempt -* recovery. But if the bus is idle, we still need to reset the -* i2c controller to clear the remaining interrupts. +* recovery device. But if the bus is idle, +* we still need to reset the i2c controller to clear +* the remaining interrupts or reset device abnormal condition.
drivers/i2c/busses/i2c-aspeed.c static int aspeed_i2c_master_xfer(struct i2c_adapter *adap, · line 726
Quoted 10 lines
drivers/i2c/busses/i2c-aspeed.c +4
-5*/ -if (bus->multi_master && - (readl (bus->base +ASPEED_I2C_CMD_REG ) & -ASPEED_I2CD_BUS_BUSY_STS )) -aspeed_i2c_recover_bus (bus); -else +if ((readl (bus->base +ASPEED_I2C_CMD_REG ) & +ASPEED_I2CD_BUS_BUSY_STS )){ +if (bus->multi_master) +aspeed_i2c_recover_bus (bus);
The change doesn't seem match the commit message. In this case you've punched a hole - if the bus is busy but _not_ multi-master, we neither do the reset _nor_ the recovery.
Which is what you intended? The implementation? Or the prose description?
Now, back to the implementation, punching this hole seems reasonable on the surface, but I guess we need to keep in mind that time_left has also expired...
drivers/i2c/busses/i2c-aspeed.c static int aspeed_i2c_master_xfer(struct i2c_adapter *adap, · line 730
Quoted 4 lines
drivers/i2c/busses/i2c-aspeed.c +1
-0+ }else aspeed_i2c_reset (bus);/*
Andrew
Hi Andrew,
Thanks for your comments.
I want to fix the situation when our controller is set as target mode and reading / writing by other i2c host. However, this host is stopped by any other reason (DC on/off..etc).
It will cause the controller is stuck in this situation.
But I find it might not have clear hints to identify this situation is normal or abnormal. So, this patch should not be applied into mainstream.
BR,
By Tommy
Quoted 78 lines
-----Original Message-----
From: Andrew Jeffery <[email protected]>
Sent: Monday, October 21, 2024 7:49 PM
To: Tommy Huang <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Cc: BMC-SW <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] i2c: aspeed: Consider i2c reset for muti-master caseHi Tommy,
Quoted 2 lines · Tommy Huang
In the original code, the device reset would not be triggered when the driver is set to multi-master and bus is free.
That's not how I read the existing code. As it stands, if it's multi- master and busy we do the recovery, however, if it's multi-master and free, or busy but not multi-master, or free and not multi-master, then we do the reset.
Quoted 1 line
It needs to be considered with multi-master condition.
Is there a specific circumstance you've found that's problematic? Can you provide some more details about that scenario?
drivers/i2c/busses/i2c-aspeed.c static int aspeed_i2c_master_xfer(struct
Quoted 15 lines
Fixes: <
f327c686d3ba> ("i2c: aspeed: Reset the i2c controller when timeout occurs")Signed-off-by Tommy Huang <[email protected]>--- drivers/i2c/busses/i2c-aspeed.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)(quoted diff) +0
-0
b/drivers/i2c/busses/i2c-aspeed.cindexcc5a26637fd5..7639ae3ace67100644drivers/i2c/busses/i2c-aspeed.c +0
-0@@ -716,14 +716,15 @@ static int aspeed_i2c_master_xfer(struct
i2c_adapter*adap,Quoted 8 lines
drivers/i2c/busses/i2c-aspeed.c +3
-2if (time_left ==0 ) {/* * In a multi-master setup, if a timeout occurs, attempt -* recovery. But if the bus is idle, we still need to reset the -* i2c controller to clear the remaining interrupts. +* recovery device. But if the bus is idle, +* we still need to reset the i2c controller to clear +* the remaining interrupts or reset device abnormal condition. drivers/i2c/busses/i2c-aspeed.c static int aspeed_i2c_master_xfer(struct i2c_adapter *adap, · line 726
Quoted 10 lines
drivers/i2c/busses/i2c-aspeed.c +4
-5*/ -if (bus->multi_master && - (readl (bus->base +ASPEED_I2C_CMD_REG ) & -ASPEED_I2CD_BUS_BUSY_STS )) -aspeed_i2c_recover_bus (bus); -else +if ((readl (bus->base +ASPEED_I2C_CMD_REG ) & +ASPEED_I2CD_BUS_BUSY_STS )){ +if (bus->multi_master) +aspeed_i2c_recover_bus (bus);The change doesn't seem match the commit message. In this case you've punched a hole - if the bus is busy but _not_ multi-master, we neither do the reset _nor_ the recovery.
Which is what you intended? The implementation? Or the prose description?
Now, back to the implementation, punching this hole seems reasonable on the surface, but I guess we need to keep in mind that
time_lefthas also expired...drivers/i2c/busses/i2c-aspeed.c static int aspeed_i2c_master_xfer(struct i2c_adapter *adap, · line 730
Quoted 4 lines
drivers/i2c/busses/i2c-aspeed.c +1
-0+ }else aspeed_i2c_reset (bus);/* Andrew
Andi Shyti
maintainerHi Tommy,
Quoted 8 lines · Tommy Huang
Hi Andrew,
Thanks for your comments.
I want to fix the situation when our controller is set as target mode and reading / writing by other i2c host. However, this host is stopped by any other reason (DC on/off..etc).
It will cause the controller is stuck in this situation.
But I find it might not have clear hints to identify this situation is normal or abnormal. So, this patch should not be applied into mainstream.
Please, avoid top posting, I don't understand which part of the original message you are trying to comment on.
Second thing, please, before sending a patch, always always always make sure that checkpatch.pl reports '0' errors and '0' warnings, except for few sporadic cases.
Andi
Quoted 20 lines
-----Original Message-----
From: Andi Shyti <[email protected]>
Sent: Thursday, October 24, 2024 9:23 PM
To: Tommy Huang <[email protected]>
Cc: Andrew Jeffery <[email protected]>; [email protected]; [email protected]; [email protected]; BMC-SW <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] i2c: aspeed: Consider i2c reset for muti-master caseHi Tommy,
Quoted 4 lines · Tommy Huang
Hi Andrew,
Thanks for your comments.
I want to fix the situation when our controller is set as target mode andreading / writing by other i2c host.
Quoted 8 lines
Quoted 3 lines
However, this host is stopped by any other reason (DC on/off..etc). It will cause the controller is stuck in this situation.
But I find it might not have clear hints to identify this situation is normalor abnormal.
Quoted 1 line
So, this patch should not be applied into mainstream.
Please, avoid top posting, I don't understand which part of the original message you are trying to comment on.
Got it.
Quoted 3 lines
Second thing, please, before sending a patch, always always always make sure that checkpatch.pl reports '0' errors and '0'
warnings, except for few sporadic cases.
Sure. Thanks for your suggestion.
Quoted 2 lines
Andi