From 5e49f172d86142f55ec670830d04b1dab73b4c10 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Tue, 16 Jul 2024 10:21:06 -0400 Subject: [PATCH] Fixes for 4.19 Signed-off-by: Sasha Levin --- ...hardware-to-known-state-when-probing.patch | 71 +++++++++++++++++++ queue-4.19/series | 1 + 2 files changed, 72 insertions(+) create mode 100644 queue-4.19/i2c-rcar-bring-hardware-to-known-state-when-probing.patch diff --git a/queue-4.19/i2c-rcar-bring-hardware-to-known-state-when-probing.patch b/queue-4.19/i2c-rcar-bring-hardware-to-known-state-when-probing.patch new file mode 100644 index 00000000000..5bbc8754f59 --- /dev/null +++ b/queue-4.19/i2c-rcar-bring-hardware-to-known-state-when-probing.patch @@ -0,0 +1,71 @@ +From d64339de699ee3111bc4dec7b409e97cf3df5644 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 7 Jul 2024 10:28:46 +0200 +Subject: i2c: rcar: bring hardware to known state when probing + +From: Wolfram Sang + +[ 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 +Reported-by: Geert Uytterhoeven +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 +Signed-off-by: Andi Shyti +Signed-off-by: Sasha Levin +--- + 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 3ea2ceec676c1..1f89ee4f05783 100644 +--- a/drivers/i2c/busses/i2c-rcar.c ++++ b/drivers/i2c/busses/i2c-rcar.c +@@ -215,6 +215,14 @@ static void rcar_i2c_init(struct rcar_i2c_priv *priv) + rcar_i2c_write(priv, ICCCR, priv->icccr); + } + ++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; +@@ -864,11 +872,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; + +@@ -971,7 +976,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 + diff --git a/queue-4.19/series b/queue-4.19/series index fc32ea60a74..bc82cfab674 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -63,3 +63,4 @@ tcp-use-signed-arithmetic-in-tcp_rtx_probe0_timed_out.patch tcp-avoid-too-many-retransmit-packets.patch sunrpc-fix-rpc-client-cleaned-up-the-freed-pipefs-dentries.patch nilfs2-fix-kernel-bug-on-rename-operation-of-broken-directory.patch +i2c-rcar-bring-hardware-to-known-state-when-probing.patch -- 2.47.3