public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: ocores: set IACK bit after core is enabled
@ 2024-05-17 19:10 Grygorii Tertychnyi
  2024-05-18 18:46 ` Peter Korsgaard
  2024-05-19  5:25 ` Markus Elfring
  0 siblings, 2 replies; 6+ messages in thread
From: Grygorii Tertychnyi @ 2024-05-17 19:10 UTC (permalink / raw)
  To: Peter Korsgaard, Andrew Lunn, Thomas Gleixner, linux-i2c,
	linux-kernel
  Cc: grembeter, bsp-development.geo, Grygorii Tertychnyi

Setting IACK bit when core is disabled does not clear the "Interrupt Flag"
bit in the status register, and the interrupt remains pending.

Sometimes it causes failure for the very first message transfer, that is
usually a device probe.

Hence, set IACK bit after core is enabled to clear pending interrupt.

Signed-off-by: Grygorii Tertychnyi <grygorii.tertychnyi@leica-geosystems.com>
---
 drivers/i2c/busses/i2c-ocores.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
index a0af027db04c..a52f8fd4e2fe 100644
--- a/drivers/i2c/busses/i2c-ocores.c
+++ b/drivers/i2c/busses/i2c-ocores.c
@@ -439,8 +439,8 @@ static int ocores_init(struct device *dev, struct ocores_i2c *i2c)
 	oc_setreg(i2c, OCI2C_PREHIGH, prescale >> 8);

 	/* Init the device */
-	oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_IACK);
 	oc_setreg(i2c, OCI2C_CONTROL, ctrl | OCI2C_CTRL_EN);
+	oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_IACK);

 	return 0;
 }
--
2.43.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: ocores: set IACK bit after core is enabled
  2024-05-17 19:10 [PATCH] i2c: ocores: set IACK bit after core is enabled Grygorii Tertychnyi
@ 2024-05-18 18:46 ` Peter Korsgaard
  2024-05-19  5:25 ` Markus Elfring
  1 sibling, 0 replies; 6+ messages in thread
From: Peter Korsgaard @ 2024-05-18 18:46 UTC (permalink / raw)
  To: Grygorii Tertychnyi
  Cc: Andrew Lunn, Thomas Gleixner, linux-i2c, linux-kernel,
	bsp-development.geo, Grygorii Tertychnyi

>>>>> "Grygorii" == Grygorii Tertychnyi <grembeter@gmail.com> writes:

 > Setting IACK bit when core is disabled does not clear the "Interrupt Flag"
 > bit in the status register, and the interrupt remains pending.

 > Sometimes it causes failure for the very first message transfer, that is
 > usually a device probe.

 > Hence, set IACK bit after core is enabled to clear pending interrupt.

 > Signed-off-by: Grygorii Tertychnyi <grygorii.tertychnyi@leica-geosystems.com>

I no longer have access to a device with i2c-ocores, but it sounds
sensible so:

Acked-by: Peter Korsgaard <peter@korsgaard.com>


> ---
 >  drivers/i2c/busses/i2c-ocores.c | 2 +-
 >  1 file changed, 1 insertion(+), 1 deletion(-)

 > diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
 > index a0af027db04c..a52f8fd4e2fe 100644
 > --- a/drivers/i2c/busses/i2c-ocores.c
 > +++ b/drivers/i2c/busses/i2c-ocores.c
 > @@ -439,8 +439,8 @@ static int ocores_init(struct device *dev, struct ocores_i2c *i2c)
 >  	oc_setreg(i2c, OCI2C_PREHIGH, prescale >> 8);

 >  	/* Init the device */
 > -	oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_IACK);
 >  	oc_setreg(i2c, OCI2C_CONTROL, ctrl | OCI2C_CTRL_EN);
 > +	oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_IACK);

 >  	return 0;
 >  }
 > --
 > 2.43.0

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: ocores: set IACK bit after core is enabled
  2024-05-17 19:10 [PATCH] i2c: ocores: set IACK bit after core is enabled Grygorii Tertychnyi
  2024-05-18 18:46 ` Peter Korsgaard
@ 2024-05-19  5:25 ` Markus Elfring
  2024-05-20 13:30   ` grygorii tertychnyi
  1 sibling, 1 reply; 6+ messages in thread
From: Markus Elfring @ 2024-05-19  5:25 UTC (permalink / raw)
  To: Grygorii Tertychnyi, bsp-development.geo, linux-i2c,
	kernel-janitors, Andrew Lunn, Peter Korsgaard, Thomas Gleixner
  Cc: LKML, Grygorii Tertychnyi

…
> Sometimes it causes failure for the very first message transfer, …

Does such an information indicate the need for the tag “Fixes”?

Regards,
Markus

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: ocores: set IACK bit after core is enabled
  2024-05-19  5:25 ` Markus Elfring
@ 2024-05-20 13:30   ` grygorii tertychnyi
  2024-05-20 13:41     ` Andrew Lunn
  0 siblings, 1 reply; 6+ messages in thread
From: grygorii tertychnyi @ 2024-05-20 13:30 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Grygorii Tertychnyi, bsp-development.geo, linux-i2c,
	kernel-janitors, Andrew Lunn, Peter Korsgaard, Thomas Gleixner,
	LKML

On Sun, May 19, 2024 at 7:25 AM Markus Elfring <Markus.Elfring@web.de> wrote:
>
> …
> > Sometimes it causes failure for the very first message transfer, …
>
> Does such an information indicate the need for the tag “Fixes”?

I'm not sure: the original initialization order was introduced by the
very first commit
18f98b1e3147 ("[PATCH] i2c: New bus driver for the OpenCores I2C controller").

Regards,
Grygorii

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: ocores: set IACK bit after core is enabled
  2024-05-20 13:30   ` grygorii tertychnyi
@ 2024-05-20 13:41     ` Andrew Lunn
  2024-05-20 15:01       ` grygorii tertychnyi
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Lunn @ 2024-05-20 13:41 UTC (permalink / raw)
  To: grygorii tertychnyi
  Cc: Markus Elfring, Grygorii Tertychnyi, bsp-development.geo,
	linux-i2c, kernel-janitors, Peter Korsgaard, Thomas Gleixner,
	LKML

On Mon, May 20, 2024 at 03:30:43PM +0200, grygorii tertychnyi wrote:
> On Sun, May 19, 2024 at 7:25 AM Markus Elfring <Markus.Elfring@web.de> wrote:
> >
> > …
> > > Sometimes it causes failure for the very first message transfer, …
> >
> > Does such an information indicate the need for the tag “Fixes”?
> 
> I'm not sure: the original initialization order was introduced by the
> very first commit
> 18f98b1e3147 ("[PATCH] i2c: New bus driver for the OpenCores I2C controller").

https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html

  It fixes a problem like an oops, a hang, data corruption, a real
  security issue, a hardware quirk, a build error (but not for things
  marked CONFIG_BROKEN), or some “oh, that’s not good” issue.

Your description of the very first message transfer failing sounds
like a data corruption? Using the commit which adds the driver is also
fine, some bugs have been there all the time.

Remember to add a

Cc: stable@vger.kernel.org

    Andrew

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: ocores: set IACK bit after core is enabled
  2024-05-20 13:41     ` Andrew Lunn
@ 2024-05-20 15:01       ` grygorii tertychnyi
  0 siblings, 0 replies; 6+ messages in thread
From: grygorii tertychnyi @ 2024-05-20 15:01 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Markus Elfring, Grygorii Tertychnyi, bsp-development.geo,
	linux-i2c, kernel-janitors, Peter Korsgaard, Thomas Gleixner,
	LKML

On Mon, May 20, 2024 at 3:41 PM Andrew Lunn <andrew@lunn.ch> wrote:
>
> On Mon, May 20, 2024 at 03:30:43PM +0200, grygorii tertychnyi wrote:
> > On Sun, May 19, 2024 at 7:25 AM Markus Elfring <Markus.Elfring@web.de> wrote:
> > >
> > > …
> > > > Sometimes it causes failure for the very first message transfer, …
> > >
> > > Does such an information indicate the need for the tag “Fixes”?
> >
> > I'm not sure: the original initialization order was introduced by the
> > very first commit
> > 18f98b1e3147 ("[PATCH] i2c: New bus driver for the OpenCores I2C controller").
>
> https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
>
>   It fixes a problem like an oops, a hang, data corruption, a real
>   security issue, a hardware quirk, a build error (but not for things
>   marked CONFIG_BROKEN), or some “oh, that’s not good” issue.
>
> Your description of the very first message transfer failing sounds
> like a data corruption? Using the commit which adds the driver is also
> fine, some bugs have been there all the time.

Thanks! Yes, it is a data corruption.

> Remember to add a
>
> Cc: stable@vger.kernel.org

I will send v2.

Regards,
Grygorii

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-05-20 15:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-17 19:10 [PATCH] i2c: ocores: set IACK bit after core is enabled Grygorii Tertychnyi
2024-05-18 18:46 ` Peter Korsgaard
2024-05-19  5:25 ` Markus Elfring
2024-05-20 13:30   ` grygorii tertychnyi
2024-05-20 13:41     ` Andrew Lunn
2024-05-20 15:01       ` grygorii tertychnyi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox