]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 5.4
authorSasha Levin <sashal@kernel.org>
Tue, 16 Jul 2024 14:21:05 +0000 (10:21 -0400)
committerSasha Levin <sashal@kernel.org>
Tue, 16 Jul 2024 14:21:05 +0000 (10:21 -0400)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-5.4/i2c-rcar-bring-hardware-to-known-state-when-probing.patch [new file with mode: 0644]
queue-5.4/series

diff --git a/queue-5.4/i2c-rcar-bring-hardware-to-known-state-when-probing.patch b/queue-5.4/i2c-rcar-bring-hardware-to-known-state-when-probing.patch
new file mode 100644 (file)
index 0000000..4706200
--- /dev/null
@@ -0,0 +1,71 @@
+From 526a6a9f21cc63b9e6c71fdbf8e3e78a4cbdd87f Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sun, 7 Jul 2024 10:28:46 +0200
+Subject: i2c: rcar: bring hardware to known state when probing
+
+From: Wolfram Sang <wsa+renesas@sang-engineering.com>
+
+[ Upstream commit 4e36c0f20cb1c74c7bd7ea31ba432c1c4a989031 ]
+
+When probing, the hardware is not brought into a known state. 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
+Fixes: 6ccbe607132b ("i2c: add Renesas R-Car I2C driver")
+Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
+Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ 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 d0c4b3019e41e..1327f29f1e93b 100644
+--- a/drivers/i2c/busses/i2c-rcar.c
++++ b/drivers/i2c/busses/i2c-rcar.c
+@@ -218,6 +218,14 @@ static void rcar_i2c_init(struct rcar_i2c_priv *priv)
+ }
++static void rcar_i2c_reset_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 i;
+@@ -863,11 +871,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_reset_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;
+@@ -973,7 +978,9 @@ static int rcar_i2c_probe(struct platform_device *pdev)
+       if (ret < 0)
+               goto out_pm_put;
+-      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_reset_slave(priv);
+       if (priv->devtype == I2C_RCAR_GEN3) {
+               priv->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
+-- 
+2.43.0
+
index 29b5289a992aa5a31ef73aed137957728ac8c7d6..0b63c5321b906cbc1a36c5d82db71bb30f7ff7bb 100644 (file)
@@ -76,3 +76,4 @@ tcp-use-signed-arithmetic-in-tcp_rtx_probe0_timed_out.patch
 tcp-avoid-too-many-retransmit-packets.patch
 nilfs2-fix-kernel-bug-on-rename-operation-of-broken-directory.patch
 ext4-avoid-ptr-null-pointer-dereference.patch
+i2c-rcar-bring-hardware-to-known-state-when-probing.patch