* [RFC PATCH] i2c: rcar: bring hardware to known state when probing
@ 2024-07-03 7:12 Wolfram Sang
2024-07-03 20:27 ` Andi Shyti
0 siblings, 1 reply; 3+ messages in thread
From: Wolfram Sang @ 2024-07-03 7:12 UTC (permalink / raw)
To: linux-renesas-soc
Cc: Wolfram Sang, Dirk Behme, Geert Uytterhoeven, Andi Shyti,
linux-i2c, linux-kernel
Probably due to a lot of refactorization, the hardware was not brought
into a known state in probe. This may be a problem when a hypervisor
restarts Linux without resetting the hardware, leaving an old state
running. Make sure the hardware gets initialized, especially interrupts
should be cleared and disabled.
Reported-by: Dirk Behme <dirk.behme@de.bosch.com>
Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
Closes: https://lore.kernel.org/r/20240702045535.2000393-1-dirk.behme@de.bosch.com
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
Here is my proposal to fix the issue reported by Dirk. Build tested.
I can do proper testing on HW only tomorrow. But so you know already...
It is strange to add another "_slave" function to the driver while I
work on removing such language from I2C somewhere else. "Consistency" is
the answer here. The driver will be converted as well. But then as a
whole.
drivers/i2c/busses/i2c-rcar.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index 828aa2ea0fe4..00a885205075 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -257,6 +257,14 @@ static void rcar_i2c_init(struct rcar_i2c_priv *priv)
}
}
+static void rcar_i2c_init_slave(struct rcar_i2c_priv *priv)
+{
+ rcar_i2c_write(priv, ICSIER, 0);
+ rcar_i2c_write(priv, ICSSR, 0);
+ rcar_i2c_write(priv, ICSCR, SDBS);
+ rcar_i2c_write(priv, ICSAR, 0); /* Gen2: must be 0 if not using slave */
+}
+
static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv)
{
int ret;
@@ -1033,11 +1041,8 @@ static int rcar_unreg_slave(struct i2c_client *slave)
/* ensure no irq is running before clearing ptr */
disable_irq(priv->irq);
- rcar_i2c_write(priv, ICSIER, 0);
- rcar_i2c_write(priv, ICSSR, 0);
+ rcar_i2c_init_slave(priv);
enable_irq(priv->irq);
- rcar_i2c_write(priv, ICSCR, SDBS);
- rcar_i2c_write(priv, ICSAR, 0); /* Gen2: must be 0 if not using slave */
priv->slave = NULL;
@@ -1152,7 +1157,9 @@ static int rcar_i2c_probe(struct platform_device *pdev)
goto out_pm_disable;
}
- rcar_i2c_write(priv, ICSAR, 0); /* Gen2: must be 0 if not using slave */
+ /* Bring hardware to known state */
+ rcar_i2c_init(priv);
+ rcar_i2c_init_slave(priv);
if (priv->devtype < I2C_RCAR_GEN3) {
irqflags |= IRQF_NO_THREAD;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [RFC PATCH] i2c: rcar: bring hardware to known state when probing
2024-07-03 7:12 [RFC PATCH] i2c: rcar: bring hardware to known state when probing Wolfram Sang
@ 2024-07-03 20:27 ` Andi Shyti
2024-07-04 9:57 ` Wolfram Sang
0 siblings, 1 reply; 3+ messages in thread
From: Andi Shyti @ 2024-07-03 20:27 UTC (permalink / raw)
To: Wolfram Sang
Cc: linux-renesas-soc, Dirk Behme, Geert Uytterhoeven, linux-i2c,
linux-kernel
Hi Wolfram,
On Wed, Jul 03, 2024 at 09:12:03AM GMT, Wolfram Sang wrote:
> Probably due to a lot of refactorization, the hardware was not brought
> into a known state in probe. This may be a problem when a hypervisor
> restarts Linux without resetting the hardware, leaving an old state
> running. Make sure the hardware gets initialized, especially interrupts
> should be cleared and disabled.
>
> Reported-by: Dirk Behme <dirk.behme@de.bosch.com>
> Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Closes: https://lore.kernel.org/r/20240702045535.2000393-1-dirk.behme@de.bosch.com
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Do we need the Fixes tag here?
> ---
>
> Here is my proposal to fix the issue reported by Dirk. Build tested.
> I can do proper testing on HW only tomorrow. But so you know already...
Looks reasonable. If testing is fine I can queue this up for this
week's pull request.
> It is strange to add another "_slave" function to the driver while I
> work on removing such language from I2C somewhere else. "Consistency" is
> the answer here. The driver will be converted as well. But then as a
> whole.
Ack!
Thanks,
Andi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-07-04 9:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-03 7:12 [RFC PATCH] i2c: rcar: bring hardware to known state when probing Wolfram Sang
2024-07-03 20:27 ` Andi Shyti
2024-07-04 9:57 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox