[PATCH] i2c: uniphier-f: correct error recovery

The uniphier i2c block can recognize some handshake errors. But driver handles all error detections as no error if no timeout. So this makes unrecoverable state.
This replaces the return values with the right ones to tell the i2c framework the errors: - EDEADLK for arbitration lost error - ENODATA for no answer error
Signed-off-by: Dai Okamura okamura.dai@socionext.com --- drivers/i2c/i2c-uniphier-f.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/i2c-uniphier-f.c b/drivers/i2c/i2c-uniphier-f.c index 9d6f1688cb..3dcd382469 100644 --- a/drivers/i2c/i2c-uniphier-f.c +++ b/drivers/i2c/i2c-uniphier-f.c @@ -130,12 +130,12 @@ static int wait_for_irq(struct uniphier_fi2c_priv *priv, u32 flags, if (irq & I2C_INT_AL) { dev_dbg(priv->dev, "error: arbitration lost\n"); *stop = false; - return ret; + return -EDEADLK; }
if (irq & I2C_INT_NA) { dev_dbg(priv->dev, "error: no answer\n"); - return ret; + return -ENODATA; }
return 0;

On 2022/12/09 20:38, Dai Okamura wrote:
The uniphier i2c block can recognize some handshake errors. But driver handles all error detections as no error if no timeout. So this makes unrecoverable state.
This replaces the return values with the right ones to tell the i2c framework the errors:
- EDEADLK for arbitration lost error
- ENODATA for no answer error
Signed-off-by: Dai Okamura okamura.dai@socionext.com
drivers/i2c/i2c-uniphier-f.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/i2c-uniphier-f.c b/drivers/i2c/i2c-uniphier-f.c index 9d6f1688cb..3dcd382469 100644 --- a/drivers/i2c/i2c-uniphier-f.c +++ b/drivers/i2c/i2c-uniphier-f.c @@ -130,12 +130,12 @@ static int wait_for_irq(struct uniphier_fi2c_priv *priv, u32 flags, if (irq & I2C_INT_AL) { dev_dbg(priv->dev, "error: arbitration lost\n"); *stop = false;
return ret;
return -EDEADLK;
}
if (irq & I2C_INT_NA) { dev_dbg(priv->dev, "error: no answer\n");
return ret;
return -ENODATA;
}
return 0;
I understand this "ret" comes from readl_poll_timeout() and is zero, so the error can't be detected. It should be fixed.
Fixes: 238bd0b8ce52 ("i2c: UniPhier: add driver for UniPhier FIFO-builtin i2c controller")
and,
Acked-by: Kunihiko Hayashi hayashi.kunihiko@socionext.com
Thank you,
--- Best Regards Kunihiko Hayashi

Hello Dai Okamura,
On 09.12.22 12:38, Dai Okamura wrote:
The uniphier i2c block can recognize some handshake errors. But driver handles all error detections as no error if no timeout. So this makes unrecoverable state.
This replaces the return values with the right ones to tell the i2c framework the errors:
- EDEADLK for arbitration lost error
- ENODATA for no answer error
Signed-off-by: Dai Okamura okamura.dai@socionext.com
drivers/i2c/i2c-uniphier-f.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Heiko Schocher hs@denx.de
@Tom: Is it okay for you, to add this patch to 2023.01 release? If yes, do you want to pick it up, or should I send a pull request?
Thanks!
bye, Heiko

On Sun, Jan 01, 2023 at 08:45:44AM +0100, Heiko Schocher wrote:
Hello Dai Okamura,
On 09.12.22 12:38, Dai Okamura wrote:
The uniphier i2c block can recognize some handshake errors. But driver handles all error detections as no error if no timeout. So this makes unrecoverable state.
This replaces the return values with the right ones to tell the i2c framework the errors:
- EDEADLK for arbitration lost error
- ENODATA for no answer error
Signed-off-by: Dai Okamura okamura.dai@socionext.com
drivers/i2c/i2c-uniphier-f.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Heiko Schocher hs@denx.de
@Tom: Is it okay for you, to add this patch to 2023.01 release? If yes, do you want to pick it up, or should I send a pull request?
I'll pick it up, thanks!

On Fri, Dec 09, 2022 at 08:38:27PM +0900, Dai Okamura wrote:
The uniphier i2c block can recognize some handshake errors. But driver handles all error detections as no error if no timeout. So this makes unrecoverable state.
This replaces the return values with the right ones to tell the i2c framework the errors:
- EDEADLK for arbitration lost error
- ENODATA for no answer error
Signed-off-by: Dai Okamura okamura.dai@socionext.com Acked-by: Kunihiko Hayashi hayashi.kunihiko@socionext.com Reviewed-by: Heiko Schocher hs@denx.de
Applied to u-boot/master, thanks!
participants (4)
-
Dai Okamura
-
Heiko Schocher
-
Kunihiko Hayashi
-
Tom Rini