* [PATCH v1 0/1] i2c: npcm: Add clock toggle in case of stuck bus during init
@ 2025-03-24 20:32 mohammed.0.elbadry
2025-03-24 20:32 ` [PATCH v1 1/1] i2c: npcm: Add clock toggle in case of stuck bus during init in npcm_i2c_init_module mohammed.0.elbadry
0 siblings, 1 reply; 16+ messages in thread
From: mohammed.0.elbadry @ 2025-03-24 20:32 UTC (permalink / raw)
Cc: Tali Perry, Mohammed Elbadry, Avi Fishman, Tomer Maimon,
Patrick Venture, Nancy Yuen, Benjamin Fair, Andi Shyti, openbmc,
linux-i2c, linux-kernel
From: Tali Perry <tali.perry1@gmail.com>
Hi,
During init of the bus, the module checks that the bus is idle.
If one of the lines are stuck try to toggle them first.
Fixes: 76487532f797 (i2c: npcm: Add slave enable/disable function)
Signed-off-by: Tali Perry <tali.perry1@gmail.com>
Signed-off-by: Mohammed Elbadry <mohammed.0.elbadry@gmail.com>
---
Tali Perry (1):
i2c: npcm: Add clock toggle in case of stuck bus during init in
npcm_i2c_init_module
drivers/i2c/busses/i2c-npcm7xx.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 16+ messages in thread* [PATCH v1 1/1] i2c: npcm: Add clock toggle in case of stuck bus during init in npcm_i2c_init_module 2025-03-24 20:32 [PATCH v1 0/1] i2c: npcm: Add clock toggle in case of stuck bus during init mohammed.0.elbadry @ 2025-03-24 20:32 ` mohammed.0.elbadry 2025-03-24 20:58 ` [PATCH v2 0/1] i2c: npcm: Add clock toggle recovery mohammed.0.elbadry 0 siblings, 1 reply; 16+ messages in thread From: mohammed.0.elbadry @ 2025-03-24 20:32 UTC (permalink / raw) Cc: Tali Perry, Mohammed Elbadry, Avi Fishman, Tomer Maimon, Patrick Venture, Nancy Yuen, Benjamin Fair, Andi Shyti, openbmc, linux-i2c, linux-kernel From: Tali Perry <tali.perry1@gmail.com> Signed-off-by: Tali Perry <tali.perry1@gmail.com> Signed-off-by: Mohammed Elbadry <mohammed.0.elbadry@gmail.com> --- drivers/i2c/busses/i2c-npcm7xx.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c index 3ad6124be80f..78c85015d955 100644 --- a/drivers/i2c/busses/i2c-npcm7xx.c +++ b/drivers/i2c/busses/i2c-npcm7xx.c @@ -2043,10 +2043,14 @@ static int npcm_i2c_init_module(struct npcm_i2c *bus, enum i2c_mode mode, /* Check HW is OK: SDA and SCL should be high at this point. */ if ((npcm_i2c_get_SDA(&bus->adap) == 0) || (npcm_i2c_get_SCL(&bus->adap) == 0)) { - dev_err(bus->dev, "I2C%d init fail: lines are low\n", bus->num); - dev_err(bus->dev, "SDA=%d SCL=%d\n", npcm_i2c_get_SDA(&bus->adap), - npcm_i2c_get_SCL(&bus->adap)); - return -ENXIO; + dev_warn(bus->dev, " I2C%d SDA=%d SCL=%d, attempt recover\n", bus->num, + npcm_i2c_get_SDA(&bus->adap), npcm_i2c_get_SCL(&bus->adap)); + if (npcm_i2c_recovery_tgclk(&bus->adap)) { + dev_err(bus->dev, "I2C%d init fail: lines are low\n", bus->num); + dev_err(bus->dev, "SDA=%d SCL=%d\n", npcm_i2c_get_SDA(&bus->adap), + npcm_i2c_get_SCL(&bus->adap)); + return -ENXIO; + } } npcm_i2c_int_enable(bus, true); -- 2.34.1 **Reported-by: Mohammed Elbadry <mohammed.0.elbadry@gmail.com>** **Tested-by: Mohammed Elbadry <mohammed.0.elbadry@gmail.com>** ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 0/1] i2c: npcm: Add clock toggle recovery 2025-03-24 20:32 ` [PATCH v1 1/1] i2c: npcm: Add clock toggle in case of stuck bus during init in npcm_i2c_init_module mohammed.0.elbadry @ 2025-03-24 20:58 ` mohammed.0.elbadry 2025-03-24 20:58 ` [PATCH v2 1/1] " mohammed.0.elbadry 2025-03-26 4:45 ` [PATCH v2 0/1] " Mukesh Kumar Savaliya 0 siblings, 2 replies; 16+ messages in thread From: mohammed.0.elbadry @ 2025-03-24 20:58 UTC (permalink / raw) Cc: Tali Perry, Mohammed Elbadry, Avi Fishman, Tomer Maimon, Patrick Venture, Nancy Yuen, Benjamin Fair, Andi Shyti, openbmc, linux-i2c, linux-kernel From: Tali Perry <tali.perry1@gmail.com> Hi, During init of the bus, the module checks that the bus is idle. If one of the lines are stuck try to toggle them first. Fixes: 76487532f797 (i2c: npcm: Add slave enable/disable function) Signed-off-by: Tali Perry <tali.perry1@gmail.com> Signed-off-by: Mohammed Elbadry <mohammed.0.elbadry@gmail.com> --- Tali Perry (1): i2c: npcm: Add clock toggle recovery drivers/i2c/busses/i2c-npcm7xx.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) -- 2.34.1 ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 1/1] i2c: npcm: Add clock toggle recovery 2025-03-24 20:58 ` [PATCH v2 0/1] i2c: npcm: Add clock toggle recovery mohammed.0.elbadry @ 2025-03-24 20:58 ` mohammed.0.elbadry 2025-03-26 4:43 ` Mukesh Kumar Savaliya 2025-03-27 19:38 ` [PATCH v3] " mohammed.0.elbadry 2025-03-26 4:45 ` [PATCH v2 0/1] " Mukesh Kumar Savaliya 1 sibling, 2 replies; 16+ messages in thread From: mohammed.0.elbadry @ 2025-03-24 20:58 UTC (permalink / raw) Cc: Tali Perry, Mohammed Elbadry, Avi Fishman, Tomer Maimon, Patrick Venture, Nancy Yuen, Benjamin Fair, Andi Shyti, openbmc, linux-i2c, linux-kernel From: Tali Perry <tali.perry1@gmail.com> During init of the bus, the module checks that the bus is idle. If one of the lines are stuck try to recover them first before failing. Sometimes SDA and SCL are low if improper reset occurs (e.g., reboot). Signed-off-by: Tali Perry <tali.perry1@gmail.com> Signed-off-by: Mohammed Elbadry <mohammed.0.elbadry@gmail.com> --- drivers/i2c/busses/i2c-npcm7xx.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c index 3ad6124be80f..78c85015d955 100644 --- a/drivers/i2c/busses/i2c-npcm7xx.c +++ b/drivers/i2c/busses/i2c-npcm7xx.c @@ -2043,10 +2043,14 @@ static int npcm_i2c_init_module(struct npcm_i2c *bus, enum i2c_mode mode, /* Check HW is OK: SDA and SCL should be high at this point. */ if ((npcm_i2c_get_SDA(&bus->adap) == 0) || (npcm_i2c_get_SCL(&bus->adap) == 0)) { - dev_err(bus->dev, "I2C%d init fail: lines are low\n", bus->num); - dev_err(bus->dev, "SDA=%d SCL=%d\n", npcm_i2c_get_SDA(&bus->adap), - npcm_i2c_get_SCL(&bus->adap)); - return -ENXIO; + dev_warn(bus->dev, " I2C%d SDA=%d SCL=%d, attempt recover\n", bus->num, + npcm_i2c_get_SDA(&bus->adap), npcm_i2c_get_SCL(&bus->adap)); + if (npcm_i2c_recovery_tgclk(&bus->adap)) { + dev_err(bus->dev, "I2C%d init fail: lines are low\n", bus->num); + dev_err(bus->dev, "SDA=%d SCL=%d\n", npcm_i2c_get_SDA(&bus->adap), + npcm_i2c_get_SCL(&bus->adap)); + return -ENXIO; + } } npcm_i2c_int_enable(bus, true); -- 2.34.1 **Reported-by: Mohammed Elbadry <mohammed.0.elbadry@gmail.com>** **Tested-by: Mohammed Elbadry <mohammed.0.elbadry@gmail.com>** ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v2 1/1] i2c: npcm: Add clock toggle recovery 2025-03-24 20:58 ` [PATCH v2 1/1] " mohammed.0.elbadry @ 2025-03-26 4:43 ` Mukesh Kumar Savaliya 2025-03-27 19:38 ` [PATCH v3] " mohammed.0.elbadry 1 sibling, 0 replies; 16+ messages in thread From: Mukesh Kumar Savaliya @ 2025-03-26 4:43 UTC (permalink / raw) To: mohammed.0.elbadry Cc: Tali Perry, Avi Fishman, Tomer Maimon, Patrick Venture, Nancy Yuen, Benjamin Fair, Andi Shyti, openbmc, linux-i2c, linux-kernel On 3/25/2025 2:28 AM, mohammed.0.elbadry@gmail.com wrote: > From: Tali Perry <tali.perry1@gmail.com> > > During init of the bus, the module checks that the bus is idle. > If one of the lines are stuck try to recover them first before failing. > Sometimes SDA and SCL are low if improper reset occurs (e.g., reboot). > > Signed-off-by: Tali Perry <tali.perry1@gmail.com> > Signed-off-by: Mohammed Elbadry <mohammed.0.elbadry@gmail.com> > --- > drivers/i2c/busses/i2c-npcm7xx.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c > index 3ad6124be80f..78c85015d955 100644 > --- a/drivers/i2c/busses/i2c-npcm7xx.c > +++ b/drivers/i2c/busses/i2c-npcm7xx.c > @@ -2043,10 +2043,14 @@ static int npcm_i2c_init_module(struct npcm_i2c *bus, enum i2c_mode mode, > > /* Check HW is OK: SDA and SCL should be high at this point. */ > if ((npcm_i2c_get_SDA(&bus->adap) == 0) || (npcm_i2c_get_SCL(&bus->adap) == 0)) { > - dev_err(bus->dev, "I2C%d init fail: lines are low\n", bus->num); > - dev_err(bus->dev, "SDA=%d SCL=%d\n", npcm_i2c_get_SDA(&bus->adap), > - npcm_i2c_get_SCL(&bus->adap)); > - return -ENXIO; > + dev_warn(bus->dev, " I2C%d SDA=%d SCL=%d, attempt recover\n", bus->num, > + npcm_i2c_get_SDA(&bus->adap), npcm_i2c_get_SCL(&bus->adap)); > + if (npcm_i2c_recovery_tgclk(&bus->adap)) { > + dev_err(bus->dev, "I2C%d init fail: lines are low\n", bus->num); > + dev_err(bus->dev, "SDA=%d SCL=%d\n", npcm_i2c_get_SDA(&bus->adap), > + npcm_i2c_get_SCL(&bus->adap)); Should combine logging into one line. First line you say they are low, second line you are printing the actual status, may be conflicting ? > + return -ENXIO; > + } > } > > npcm_i2c_int_enable(bus, true); ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v3] i2c: npcm: Add clock toggle recovery 2025-03-24 20:58 ` [PATCH v2 1/1] " mohammed.0.elbadry 2025-03-26 4:43 ` Mukesh Kumar Savaliya @ 2025-03-27 19:38 ` mohammed.0.elbadry 2025-03-28 11:19 ` Mukesh Kumar Savaliya 2025-03-28 19:32 ` [PATCH v4] " mohammed.0.elbadry 1 sibling, 2 replies; 16+ messages in thread From: mohammed.0.elbadry @ 2025-03-27 19:38 UTC (permalink / raw) To: avifishman70, linux-i2c, linux-kernel, andi.shyti, venture Cc: Tali Perry, Mohammed Elbadry From: Tali Perry <tali.perry1@gmail.com> During init of the bus, the module checks that the bus is idle. If one of the lines are stuck try to recover them first before failing. Sometimes SDA and SCL are low if improper reset occurs (e.g., reboot). Signed-off-by: Tali Perry <tali.perry1@gmail.com> Signed-off-by: Mohammed Elbadry <mohammed.0.elbadry@gmail.com> --- drivers/i2c/busses/i2c-npcm7xx.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c index 2fe68615942e..f05cae20cb27 100644 --- a/drivers/i2c/busses/i2c-npcm7xx.c +++ b/drivers/i2c/busses/i2c-npcm7xx.c @@ -1967,10 +1967,14 @@ static int npcm_i2c_init_module(struct npcm_i2c *bus, enum i2c_mode mode, /* Check HW is OK: SDA and SCL should be high at this point. */ if ((npcm_i2c_get_SDA(&bus->adap) == 0) || (npcm_i2c_get_SCL(&bus->adap) == 0)) { - dev_err(bus->dev, "I2C%d init fail: lines are low\n", bus->num); - dev_err(bus->dev, "SDA=%d SCL=%d\n", npcm_i2c_get_SDA(&bus->adap), - npcm_i2c_get_SCL(&bus->adap)); - return -ENXIO; + dev_warn(bus->dev, " I2C%d SDA=%d SCL=%d, attempt recover\n", bus->num, + npcm_i2c_get_SDA(&bus->adap), npcm_i2c_get_SCL(&bus->adap)); + if (npcm_i2c_recovery_tgclk(&bus->adap)) { + dev_err(bus->dev, "I2C%d init fail: lines are low, SDA=%d SCL=%d\n", + bus->num, npcm_i2c_get_SDA(&bus->adap), + npcm_i2c_get_SCL(&bus->adap)); + return -ENXIO; + } } npcm_i2c_int_enable(bus, true); -- 2.49.0.472.ge94155a9ec-goog ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v3] i2c: npcm: Add clock toggle recovery 2025-03-27 19:38 ` [PATCH v3] " mohammed.0.elbadry @ 2025-03-28 11:19 ` Mukesh Kumar Savaliya 2025-03-28 19:32 ` [PATCH v4] " mohammed.0.elbadry 1 sibling, 0 replies; 16+ messages in thread From: Mukesh Kumar Savaliya @ 2025-03-28 11:19 UTC (permalink / raw) To: mohammed.0.elbadry, avifishman70, linux-i2c, linux-kernel, andi.shyti, venture Cc: Tali Perry On 3/28/2025 1:08 AM, mohammed.0.elbadry@gmail.com wrote: > From: Tali Perry <tali.perry1@gmail.com> > > During init of the bus, the module checks that the bus is idle. > If one of the lines are stuck try to recover them first before failing. > Sometimes SDA and SCL are low if improper reset occurs (e.g., reboot). > > Signed-off-by: Tali Perry <tali.perry1@gmail.com> > Signed-off-by: Mohammed Elbadry <mohammed.0.elbadry@gmail.com> > --- > drivers/i2c/busses/i2c-npcm7xx.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c > index 2fe68615942e..f05cae20cb27 100644 > --- a/drivers/i2c/busses/i2c-npcm7xx.c > +++ b/drivers/i2c/busses/i2c-npcm7xx.c > @@ -1967,10 +1967,14 @@ static int npcm_i2c_init_module(struct npcm_i2c *bus, enum i2c_mode mode, > > /* Check HW is OK: SDA and SCL should be high at this point. */ > if ((npcm_i2c_get_SDA(&bus->adap) == 0) || (npcm_i2c_get_SCL(&bus->adap) == 0)) { > - dev_err(bus->dev, "I2C%d init fail: lines are low\n", bus->num); > - dev_err(bus->dev, "SDA=%d SCL=%d\n", npcm_i2c_get_SDA(&bus->adap), > - npcm_i2c_get_SCL(&bus->adap)); > - return -ENXIO; > + dev_warn(bus->dev, " I2C%d SDA=%d SCL=%d, attempt recover\n", bus->num, > + npcm_i2c_get_SDA(&bus->adap), npcm_i2c_get_SCL(&bus->adap)); > + if (npcm_i2c_recovery_tgclk(&bus->adap)) { You are here post trying recovery. In the log below you may want to add, "Post recovery" ? instead of "init fail" ? Just a suggestion. > + dev_err(bus->dev, "I2C%d init fail: lines are low, SDA=%d SCL=%d\n", > + bus->num, npcm_i2c_get_SDA(&bus->adap), Thanks for making previous change. Now "lines are low" not relevant as you just need to print status 1 or 0. > + npcm_i2c_get_SCL(&bus->adap)); > + return -ENXIO; > + } > } > > npcm_i2c_int_enable(bus, true); ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v4] i2c: npcm: Add clock toggle recovery 2025-03-27 19:38 ` [PATCH v3] " mohammed.0.elbadry 2025-03-28 11:19 ` Mukesh Kumar Savaliya @ 2025-03-28 19:32 ` mohammed.0.elbadry 2025-03-29 9:15 ` Mukesh Kumar Savaliya ` (3 more replies) 1 sibling, 4 replies; 16+ messages in thread From: mohammed.0.elbadry @ 2025-03-28 19:32 UTC (permalink / raw) Cc: Tali Perry, Mohammed Elbadry, Avi Fishman, Tomer Maimon, Patrick Venture, Nancy Yuen, Benjamin Fair, Andi Shyti, openbmc, linux-i2c, linux-kernel From: Tali Perry <tali.perry1@gmail.com> During init of the bus, the module checks that the bus is idle. If one of the lines are stuck try to recover them first before failing. Sometimes SDA and SCL are low if improper reset occurs (e.g., reboot). Signed-off-by: Tali Perry <tali.perry1@gmail.com> Signed-off-by: Mohammed Elbadry <mohammed.0.elbadry@gmail.com> --- drivers/i2c/busses/i2c-npcm7xx.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c index 2fe68615942e..caf9aa1e6319 100644 --- a/drivers/i2c/busses/i2c-npcm7xx.c +++ b/drivers/i2c/busses/i2c-npcm7xx.c @@ -1967,10 +1967,14 @@ static int npcm_i2c_init_module(struct npcm_i2c *bus, enum i2c_mode mode, /* Check HW is OK: SDA and SCL should be high at this point. */ if ((npcm_i2c_get_SDA(&bus->adap) == 0) || (npcm_i2c_get_SCL(&bus->adap) == 0)) { - dev_err(bus->dev, "I2C%d init fail: lines are low\n", bus->num); - dev_err(bus->dev, "SDA=%d SCL=%d\n", npcm_i2c_get_SDA(&bus->adap), - npcm_i2c_get_SCL(&bus->adap)); - return -ENXIO; + dev_warn(bus->dev, " I2C%d SDA=%d SCL=%d, attempting to recover\n", bus->num, + npcm_i2c_get_SDA(&bus->adap), npcm_i2c_get_SCL(&bus->adap)); + if (npcm_i2c_recovery_tgclk(&bus->adap)) { + dev_err(bus->dev, "I2C%d init fail: SDA=%d SCL=%d\n", + bus->num, npcm_i2c_get_SDA(&bus->adap), + npcm_i2c_get_SCL(&bus->adap)); + return -ENXIO; + } } npcm_i2c_int_enable(bus, true); -- 2.49.0.472.ge94155a9ec-goog ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v4] i2c: npcm: Add clock toggle recovery 2025-03-28 19:32 ` [PATCH v4] " mohammed.0.elbadry @ 2025-03-29 9:15 ` Mukesh Kumar Savaliya 2025-04-13 23:06 ` Andi Shyti ` (2 subsequent siblings) 3 siblings, 0 replies; 16+ messages in thread From: Mukesh Kumar Savaliya @ 2025-03-29 9:15 UTC (permalink / raw) To: mohammed.0.elbadry Cc: Tali Perry, Avi Fishman, Tomer Maimon, Patrick Venture, Nancy Yuen, Benjamin Fair, Andi Shyti, openbmc, linux-i2c, linux-kernel Looks good to me. On 3/29/2025 1:02 AM, mohammed.0.elbadry@gmail.com wrote: > From: Tali Perry <tali.perry1@gmail.com> > > During init of the bus, the module checks that the bus is idle. > If one of the lines are stuck try to recover them first before failing. > Sometimes SDA and SCL are low if improper reset occurs (e.g., reboot). > > Signed-off-by: Tali Perry <tali.perry1@gmail.com> > Signed-off-by: Mohammed Elbadry <mohammed.0.elbadry@gmail.com> Reviewed-by: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com> > --- > drivers/i2c/busses/i2c-npcm7xx.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c > index 2fe68615942e..caf9aa1e6319 100644 > --- a/drivers/i2c/busses/i2c-npcm7xx.c > +++ b/drivers/i2c/busses/i2c-npcm7xx.c > @@ -1967,10 +1967,14 @@ static int npcm_i2c_init_module(struct npcm_i2c *bus, enum i2c_mode mode, > > /* Check HW is OK: SDA and SCL should be high at this point. */ > if ((npcm_i2c_get_SDA(&bus->adap) == 0) || (npcm_i2c_get_SCL(&bus->adap) == 0)) { > - dev_err(bus->dev, "I2C%d init fail: lines are low\n", bus->num); > - dev_err(bus->dev, "SDA=%d SCL=%d\n", npcm_i2c_get_SDA(&bus->adap), > - npcm_i2c_get_SCL(&bus->adap)); > - return -ENXIO; > + dev_warn(bus->dev, " I2C%d SDA=%d SCL=%d, attempting to recover\n", bus->num, > + npcm_i2c_get_SDA(&bus->adap), npcm_i2c_get_SCL(&bus->adap)); > + if (npcm_i2c_recovery_tgclk(&bus->adap)) { > + dev_err(bus->dev, "I2C%d init fail: SDA=%d SCL=%d\n", > + bus->num, npcm_i2c_get_SDA(&bus->adap), > + npcm_i2c_get_SCL(&bus->adap)); > + return -ENXIO; > + } > } > > npcm_i2c_int_enable(bus, true); ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v4] i2c: npcm: Add clock toggle recovery 2025-03-28 19:32 ` [PATCH v4] " mohammed.0.elbadry 2025-03-29 9:15 ` Mukesh Kumar Savaliya @ 2025-04-13 23:06 ` Andi Shyti 2025-04-14 0:07 ` Mohammed Elbadry 2025-05-27 2:22 ` [PATCH v5] " Mohammed Elbadry 2025-05-27 3:05 ` Mohammed Elbadry 3 siblings, 1 reply; 16+ messages in thread From: Andi Shyti @ 2025-04-13 23:06 UTC (permalink / raw) To: mohammed.0.elbadry Cc: Tali Perry, Avi Fishman, Tomer Maimon, Patrick Venture, Nancy Yuen, Benjamin Fair, openbmc, linux-i2c, linux-kernel Hi Mohammed, On Fri, Mar 28, 2025 at 07:32:50PM +0000, mohammed.0.elbadry@gmail.com wrote: > From: Tali Perry <tali.perry1@gmail.com> > > During init of the bus, the module checks that the bus is idle. > If one of the lines are stuck try to recover them first before failing. > Sometimes SDA and SCL are low if improper reset occurs (e.g., reboot). > > Signed-off-by: Tali Perry <tali.perry1@gmail.com> > Signed-off-by: Mohammed Elbadry <mohammed.0.elbadry@gmail.com> > --- we are missing the changelog here. You are at v4 and I need to see the changes between the versions. For now it's OK, please, next time don't forget to add the changelog. One more thing, no need to send patches as --in-reply-to your previous patch. > drivers/i2c/busses/i2c-npcm7xx.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c > index 2fe68615942e..caf9aa1e6319 100644 > --- a/drivers/i2c/busses/i2c-npcm7xx.c > +++ b/drivers/i2c/busses/i2c-npcm7xx.c > @@ -1967,10 +1967,14 @@ static int npcm_i2c_init_module(struct npcm_i2c *bus, enum i2c_mode mode, > > /* Check HW is OK: SDA and SCL should be high at this point. */ > if ((npcm_i2c_get_SDA(&bus->adap) == 0) || (npcm_i2c_get_SCL(&bus->adap) == 0)) { > - dev_err(bus->dev, "I2C%d init fail: lines are low\n", bus->num); > - dev_err(bus->dev, "SDA=%d SCL=%d\n", npcm_i2c_get_SDA(&bus->adap), > - npcm_i2c_get_SCL(&bus->adap)); > - return -ENXIO; > + dev_warn(bus->dev, " I2C%d SDA=%d SCL=%d, attempting to recover\n", bus->num, the space at the beginning of the line should be removed. I will take care of it if you won't be asked to send a new version. > + npcm_i2c_get_SDA(&bus->adap), npcm_i2c_get_SCL(&bus->adap)); > + if (npcm_i2c_recovery_tgclk(&bus->adap)) { > + dev_err(bus->dev, "I2C%d init fail: SDA=%d SCL=%d\n", > + bus->num, npcm_i2c_get_SDA(&bus->adap), > + npcm_i2c_get_SCL(&bus->adap)); > + return -ENXIO; why don't we return the error coming from npcm_i2c_recovery_tgclk() instead of forcing it to ENXIO? Thanks, Andi > + } > } > > npcm_i2c_int_enable(bus, true); > -- > 2.49.0.472.ge94155a9ec-goog > ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v4] i2c: npcm: Add clock toggle recovery 2025-04-13 23:06 ` Andi Shyti @ 2025-04-14 0:07 ` Mohammed Elbadry 2025-04-17 16:11 ` Andi Shyti 0 siblings, 1 reply; 16+ messages in thread From: Mohammed Elbadry @ 2025-04-14 0:07 UTC (permalink / raw) To: Andi Shyti Cc: Tali Perry, Avi Fishman, Tomer Maimon, Patrick Venture, Nancy Yuen, Benjamin Fair, openbmc, linux-i2c, linux-kernel Hi Andi, On Sun, Apr 13, 2025 at 4:06 PM Andi Shyti <andi.shyti@kernel.org> wrote: > > Hi Mohammed, > > On Fri, Mar 28, 2025 at 07:32:50PM +0000, mohammed.0.elbadry@gmail.com wrote: > > From: Tali Perry <tali.perry1@gmail.com> > > > > During init of the bus, the module checks that the bus is idle. > > If one of the lines are stuck try to recover them first before failing. > > Sometimes SDA and SCL are low if improper reset occurs (e.g., reboot). > > > > Signed-off-by: Tali Perry <tali.perry1@gmail.com> > > Signed-off-by: Mohammed Elbadry <mohammed.0.elbadry@gmail.com> > > --- > > we are missing the changelog here. You are at v4 and I need to > see the changes between the versions. For now it's OK, please, > next time don't forget to add the changelog. I understand, I will do that, thank you. > > One more thing, no need to send patches as --in-reply-to your > previous patch. > > > drivers/i2c/busses/i2c-npcm7xx.c | 12 ++++++++---- > > 1 file changed, 8 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c > > index 2fe68615942e..caf9aa1e6319 100644 > > --- a/drivers/i2c/busses/i2c-npcm7xx.c > > +++ b/drivers/i2c/busses/i2c-npcm7xx.c > > @@ -1967,10 +1967,14 @@ static int npcm_i2c_init_module(struct npcm_i2c *bus, enum i2c_mode mode, > > > > /* Check HW is OK: SDA and SCL should be high at this point. */ > > if ((npcm_i2c_get_SDA(&bus->adap) == 0) || (npcm_i2c_get_SCL(&bus->adap) == 0)) { > > - dev_err(bus->dev, "I2C%d init fail: lines are low\n", bus->num); > > - dev_err(bus->dev, "SDA=%d SCL=%d\n", npcm_i2c_get_SDA(&bus->adap), > > - npcm_i2c_get_SCL(&bus->adap)); > > - return -ENXIO; > > + dev_warn(bus->dev, " I2C%d SDA=%d SCL=%d, attempting to recover\n", bus->num, > > the space at the beginning of the line should be removed. I will > take care of it if you won't be asked to send a new version. > Got it, thank you. > > + npcm_i2c_get_SDA(&bus->adap), npcm_i2c_get_SCL(&bus->adap)); > > + if (npcm_i2c_recovery_tgclk(&bus->adap)) { > > + dev_err(bus->dev, "I2C%d init fail: SDA=%d SCL=%d\n", > > + bus->num, npcm_i2c_get_SDA(&bus->adap), > > + npcm_i2c_get_SCL(&bus->adap)); > > + return -ENXIO; > > why don't we return the error coming from > npcm_i2c_recovery_tgclk() instead of forcing it to ENXIO? The error that comes from the current driver is only -ENOTRECOVERABLE. I do not see why we cannot return that error instead. I understand the difference between both states; however, from the driver's perspective, on initialization, ENXIO and ENOTRECOVERABLE behavior is identical in that state. ENXIO was what the driver returned by default without trying to recover. Do you recommend changing it? Let me know. I am happy to send the v5 patch with the change and address the above comments, too. Thank you, Mo > > Thanks, > Andi > > > + } > > } > > > > npcm_i2c_int_enable(bus, true); > > -- > > 2.49.0.472.ge94155a9ec-goog > > ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v4] i2c: npcm: Add clock toggle recovery 2025-04-14 0:07 ` Mohammed Elbadry @ 2025-04-17 16:11 ` Andi Shyti 0 siblings, 0 replies; 16+ messages in thread From: Andi Shyti @ 2025-04-17 16:11 UTC (permalink / raw) To: Mohammed Elbadry Cc: Tali Perry, Avi Fishman, Tomer Maimon, Patrick Venture, Nancy Yuen, Benjamin Fair, openbmc, linux-i2c, linux-kernel Hi Mohammed, ... > > > + npcm_i2c_get_SDA(&bus->adap), npcm_i2c_get_SCL(&bus->adap)); > > > + if (npcm_i2c_recovery_tgclk(&bus->adap)) { > > > + dev_err(bus->dev, "I2C%d init fail: SDA=%d SCL=%d\n", > > > + bus->num, npcm_i2c_get_SDA(&bus->adap), > > > + npcm_i2c_get_SCL(&bus->adap)); > > > + return -ENXIO; > > > > why don't we return the error coming from > > npcm_i2c_recovery_tgclk() instead of forcing it to ENXIO? > > The error that comes from the current driver is only -ENOTRECOVERABLE. > I do not see why we cannot return that error instead. I understand the > difference between both states; however, from the driver's > perspective, on initialization, ENXIO and ENOTRECOVERABLE behavior is > identical in that state. I think it makes more sense to return the error we receive from npcm_i2c_recovery_tgclk(). Then we can discuss whether that error is correct or not, but that's a different topic. > ENXIO was what the driver returned by default without trying to > recover. Do you recommend changing it? Let me know. I am happy to send > the v5 patch with the change and address the above comments, too. Yes, please do. Andi ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v5] i2c: npcm: Add clock toggle recovery 2025-03-28 19:32 ` [PATCH v4] " mohammed.0.elbadry 2025-03-29 9:15 ` Mukesh Kumar Savaliya 2025-04-13 23:06 ` Andi Shyti @ 2025-05-27 2:22 ` Mohammed Elbadry 2025-05-27 3:05 ` Mohammed Elbadry 3 siblings, 0 replies; 16+ messages in thread From: Mohammed Elbadry @ 2025-05-27 2:22 UTC (permalink / raw) Cc: avifishman70, tmaimon77, tali.perry1, venture, yuenn, benjaminfair, andi.shyti, openbmc, linux-i2c, linux-kernel, Mukesh Kumar Savaliya From: Tali Perry <tali.perry1@gmail.com> During init of the bus, the module checks that the bus is idle. If one of the lines are stuck try to recover them first before failing. Sometimes SDA and SCL are low if improper reset occurs (e.g., reboot). Signed-off-by: Tali Perry <tali.perry1@gmail.com> Signed-off-by: Mohammed Elbadry <mohammed.0.elbadry@gmail.com> Reviewed-by: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com> --- drivers/i2c/busses/i2c-npcm7xx.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c index de713b5747fe..0757a23dc1cd 100644 --- a/drivers/i2c/busses/i2c-npcm7xx.c +++ b/drivers/i2c/busses/i2c-npcm7xx.c @@ -2178,10 +2178,15 @@ static int npcm_i2c_init_module(struct npcm_i2c *bus, enum i2c_mode mode, /* Check HW is OK: SDA and SCL should be high at this point. */ if ((npcm_i2c_get_SDA(&bus->adap) == 0) || (npcm_i2c_get_SCL(&bus->adap) == 0)) { - dev_err(bus->dev, "I2C%d init fail: lines are low\n", bus->num); - dev_err(bus->dev, "SDA=%d SCL=%d\n", npcm_i2c_get_SDA(&bus->adap), - npcm_i2c_get_SCL(&bus->adap)); - return -ENXIO; + dev_warn(bus->dev, " I2C%d SDA=%d SCL=%d, attempting to recover\n", bus->num, + npcm_i2c_get_SDA(&bus->adap), npcm_i2c_get_SCL(&bus->adap)); + ret = npcm_i2c_recovery_tgclk(&bus->adap); + if (ret) { + dev_err(bus->dev, "I2C%d init fail: SDA=%d SCL=%d\n", + bus->num, npcm_i2c_get_SDA(&bus->adap), + npcm_i2c_get_SCL(&bus->adap)); + return ret; + } } npcm_i2c_int_enable(bus, true); -- 2.39.5 (Apple Git-154) ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v5] i2c: npcm: Add clock toggle recovery 2025-03-28 19:32 ` [PATCH v4] " mohammed.0.elbadry ` (2 preceding siblings ...) 2025-05-27 2:22 ` [PATCH v5] " Mohammed Elbadry @ 2025-05-27 3:05 ` Mohammed Elbadry 3 siblings, 0 replies; 16+ messages in thread From: Mohammed Elbadry @ 2025-05-27 3:05 UTC (permalink / raw) To: andi.shyti Cc: avifishman70, tmaimon77, tali.perry1, venture, yuenn, benjaminfair, openbmc, linux-i2c, linux-kernel, Mukesh Kumar Savaliya From: Tali Perry <tali.perry1@gmail.com> During init of the bus, the module checks that the bus is idle. If one of the lines are stuck try to recover them first before failing. Sometimes SDA and SCL are low if improper reset occurs (e.g., reboot). Signed-off-by: Tali Perry <tali.perry1@gmail.com> Signed-off-by: Mohammed Elbadry <mohammed.0.elbadry@gmail.com> Reviewed-by: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com> --- drivers/i2c/busses/i2c-npcm7xx.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c index de713b5747fe..4738fc450a6b 100644 --- a/drivers/i2c/busses/i2c-npcm7xx.c +++ b/drivers/i2c/busses/i2c-npcm7xx.c @@ -2178,10 +2178,15 @@ static int npcm_i2c_init_module(struct npcm_i2c *bus, enum i2c_mode mode, /* Check HW is OK: SDA and SCL should be high at this point. */ if ((npcm_i2c_get_SDA(&bus->adap) == 0) || (npcm_i2c_get_SCL(&bus->adap) == 0)) { - dev_err(bus->dev, "I2C%d init fail: lines are low\n", bus->num); - dev_err(bus->dev, "SDA=%d SCL=%d\n", npcm_i2c_get_SDA(&bus->adap), - npcm_i2c_get_SCL(&bus->adap)); - return -ENXIO; + dev_warn(bus->dev, " I2C%d SDA=%d SCL=%d, attempting to recover\n", bus->num, + npcm_i2c_get_SDA(&bus->adap), npcm_i2c_get_SCL(&bus->adap)); + ret = npcm_i2c_recovery_tgclk(&bus->adap); + if (ret) { + dev_err(bus->dev, "I2C%d init fail: SDA=%d SCL=%d\n", + bus->num, npcm_i2c_get_SDA(&bus->adap), + npcm_i2c_get_SCL(&bus->adap)); + return ret; + } } npcm_i2c_int_enable(bus, true); -- 2.39.5 (Apple Git-154) ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v2 0/1] i2c: npcm: Add clock toggle recovery 2025-03-24 20:58 ` [PATCH v2 0/1] i2c: npcm: Add clock toggle recovery mohammed.0.elbadry 2025-03-24 20:58 ` [PATCH v2 1/1] " mohammed.0.elbadry @ 2025-03-26 4:45 ` Mukesh Kumar Savaliya 1 sibling, 0 replies; 16+ messages in thread From: Mukesh Kumar Savaliya @ 2025-03-26 4:45 UTC (permalink / raw) To: mohammed.0.elbadry Cc: Tali Perry, Avi Fishman, Tomer Maimon, Patrick Venture, Nancy Yuen, Benjamin Fair, Andi Shyti, openbmc, linux-i2c, linux-kernel On 3/25/2025 2:28 AM, mohammed.0.elbadry@gmail.com wrote: > From: Tali Perry <tali.perry1@gmail.com> > > Hi, > > During init of the bus, the module checks that the bus is idle. > If one of the lines are stuck try to toggle them first. > As such there is one file change and single patch. You may go ahead without cover-letter. Just my thought. > Fixes: 76487532f797 (i2c: npcm: Add slave enable/disable function) > Signed-off-by: Tali Perry <tali.perry1@gmail.com> > Signed-off-by: Mohammed Elbadry <mohammed.0.elbadry@gmail.com> > --- > > Tali Perry (1): > i2c: npcm: Add clock toggle recovery > > drivers/i2c/busses/i2c-npcm7xx.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v1 0/1] i2c: npcm: Add clock toggle in case of stuck bus during init
@ 2025-03-24 20:30 mohammed.0.elbadry
2025-03-24 20:30 ` [PATCH v1 1/1] i2c: npcm: Add clock toggle in case of stuck bus during init in npcm_i2c_init_module mohammed.0.elbadry
0 siblings, 1 reply; 16+ messages in thread
From: mohammed.0.elbadry @ 2025-03-24 20:30 UTC (permalink / raw)
Cc: Tali Perry, Mohammed Elbadry, Avi Fishman, Tomer Maimon,
Patrick Venture, Nancy Yuen, Benjamin Fair, Andi Shyti, openbmc,
linux-i2c, linux-kernel
From: Tali Perry <tali.perry1@gmail.com>
Hi,
During init of the bus, the module checks that the bus is idle.
If one of the lines are stuck try to toggle them first.
Fixes: 76487532f797 (i2c: npcm: Add slave enable/disable function)
Signed-off-by: Tali Perry <tali.perry1@gmail.com>
Signed-off-by: Mohammed Elbadry <mohammed.0.elbadry@google.com>
---
Tali Perry (1):
i2c: npcm: Add clock toggle in case of stuck bus during init in
npcm_i2c_init_module
drivers/i2c/busses/i2c-npcm7xx.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 16+ messages in thread* [PATCH v1 1/1] i2c: npcm: Add clock toggle in case of stuck bus during init in npcm_i2c_init_module 2025-03-24 20:30 [PATCH v1 0/1] i2c: npcm: Add clock toggle in case of stuck bus during init mohammed.0.elbadry @ 2025-03-24 20:30 ` mohammed.0.elbadry 0 siblings, 0 replies; 16+ messages in thread From: mohammed.0.elbadry @ 2025-03-24 20:30 UTC (permalink / raw) Cc: Tali Perry, Mohammed Elbadry, Avi Fishman, Tomer Maimon, Patrick Venture, Nancy Yuen, Benjamin Fair, Andi Shyti, openbmc, linux-i2c, linux-kernel From: Tali Perry <tali.perry1@gmail.com> Signed-off-by: Tali Perry <tali.perry1@gmail.com> Signed-off-by: Mohammed Elbadry <mohammed.0.elbadry@google.com> --- drivers/i2c/busses/i2c-npcm7xx.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c index 3ad6124be80f..78c85015d955 100644 --- a/drivers/i2c/busses/i2c-npcm7xx.c +++ b/drivers/i2c/busses/i2c-npcm7xx.c @@ -2043,10 +2043,14 @@ static int npcm_i2c_init_module(struct npcm_i2c *bus, enum i2c_mode mode, /* Check HW is OK: SDA and SCL should be high at this point. */ if ((npcm_i2c_get_SDA(&bus->adap) == 0) || (npcm_i2c_get_SCL(&bus->adap) == 0)) { - dev_err(bus->dev, "I2C%d init fail: lines are low\n", bus->num); - dev_err(bus->dev, "SDA=%d SCL=%d\n", npcm_i2c_get_SDA(&bus->adap), - npcm_i2c_get_SCL(&bus->adap)); - return -ENXIO; + dev_warn(bus->dev, " I2C%d SDA=%d SCL=%d, attempt recover\n", bus->num, + npcm_i2c_get_SDA(&bus->adap), npcm_i2c_get_SCL(&bus->adap)); + if (npcm_i2c_recovery_tgclk(&bus->adap)) { + dev_err(bus->dev, "I2C%d init fail: lines are low\n", bus->num); + dev_err(bus->dev, "SDA=%d SCL=%d\n", npcm_i2c_get_SDA(&bus->adap), + npcm_i2c_get_SCL(&bus->adap)); + return -ENXIO; + } } npcm_i2c_int_enable(bus, true); -- 2.34.1 **Reported-by: Mohammed Elbadry <mohammed.0.elbadry@google.com>** **Tested-by: Mohammed Elbadry <mohammed.0.elbadry@google.com>** ^ permalink raw reply related [flat|nested] 16+ messages in thread
end of thread, other threads:[~2025-05-27 3:05 UTC | newest] Thread overview: 16+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-03-24 20:32 [PATCH v1 0/1] i2c: npcm: Add clock toggle in case of stuck bus during init mohammed.0.elbadry 2025-03-24 20:32 ` [PATCH v1 1/1] i2c: npcm: Add clock toggle in case of stuck bus during init in npcm_i2c_init_module mohammed.0.elbadry 2025-03-24 20:58 ` [PATCH v2 0/1] i2c: npcm: Add clock toggle recovery mohammed.0.elbadry 2025-03-24 20:58 ` [PATCH v2 1/1] " mohammed.0.elbadry 2025-03-26 4:43 ` Mukesh Kumar Savaliya 2025-03-27 19:38 ` [PATCH v3] " mohammed.0.elbadry 2025-03-28 11:19 ` Mukesh Kumar Savaliya 2025-03-28 19:32 ` [PATCH v4] " mohammed.0.elbadry 2025-03-29 9:15 ` Mukesh Kumar Savaliya 2025-04-13 23:06 ` Andi Shyti 2025-04-14 0:07 ` Mohammed Elbadry 2025-04-17 16:11 ` Andi Shyti 2025-05-27 2:22 ` [PATCH v5] " Mohammed Elbadry 2025-05-27 3:05 ` Mohammed Elbadry 2025-03-26 4:45 ` [PATCH v2 0/1] " Mukesh Kumar Savaliya -- strict thread matches above, loose matches on Subject: below -- 2025-03-24 20:30 [PATCH v1 0/1] i2c: npcm: Add clock toggle in case of stuck bus during init mohammed.0.elbadry 2025-03-24 20:30 ` [PATCH v1 1/1] i2c: npcm: Add clock toggle in case of stuck bus during init in npcm_i2c_init_module mohammed.0.elbadry
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox