All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: ocores: Add missing wake_up() call upon state change to STATE_DONE
@ 2017-06-16  9:23 Stefan Roese
  2017-06-16 12:52 ` Peter Korsgaard
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Roese @ 2017-06-16  9:23 UTC (permalink / raw)
  To: linux-i2c; +Cc: Wolfram Sang

I've noticed that this driver adds a timeout pause of 1 second after
each xfer. This is due to the wait_event_timeout() call in ocores_xfer()
using a "HZ" timeout value and a missing call to wake_up() in
ocores_process() called by the interrupt handler when the state changes
to STATE_DONE at the end of the frame.

This patch adds the missing call resulting in the removal of this 1
second timeout delay after each xfer.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Wolfram Sang <wsa@the-dreams.de>
---
 drivers/i2c/busses/i2c-ocores.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
index 34f1889a4073..5f8395ea0106 100644
--- a/drivers/i2c/busses/i2c-ocores.c
+++ b/drivers/i2c/busses/i2c-ocores.c
@@ -191,6 +191,7 @@ static void ocores_process(struct ocores_i2c *i2c)
 		} else {
 			i2c->state = STATE_DONE;
 			oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_STOP);
+			wake_up(&i2c->wait);
 			return;
 		}
 	}
-- 
2.13.1

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

* Re: [PATCH] i2c: ocores: Add missing wake_up() call upon state change to STATE_DONE
  2017-06-16  9:23 [PATCH] i2c: ocores: Add missing wake_up() call upon state change to STATE_DONE Stefan Roese
@ 2017-06-16 12:52 ` Peter Korsgaard
  2017-06-16 13:04   ` Stefan Roese
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Korsgaard @ 2017-06-16 12:52 UTC (permalink / raw)
  To: Stefan Roese; +Cc: linux-i2c, Wolfram Sang

>>>>> "Stefan" == Stefan Roese <sr@denx.de> writes:

 > I've noticed that this driver adds a timeout pause of 1 second after
 > each xfer. This is due to the wait_event_timeout() call in ocores_xfer()
 > using a "HZ" timeout value and a missing call to wake_up() in
 > ocores_process() called by the interrupt handler when the state changes
 > to STATE_DONE at the end of the frame.

 > This patch adds the missing call resulting in the removal of this 1
 > second timeout delay after each xfer.

 > Signed-off-by: Stefan Roese <sr@denx.de>
 > Cc: Wolfram Sang <wsa@the-dreams.de>
 > ---
 >  drivers/i2c/busses/i2c-ocores.c | 1 +
 >  1 file changed, 1 insertion(+)

 > diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
 > index 34f1889a4073..5f8395ea0106 100644
 > --- a/drivers/i2c/busses/i2c-ocores.c
 > +++ b/drivers/i2c/busses/i2c-ocores.c
 > @@ -191,6 +191,7 @@ static void ocores_process(struct ocores_i2c *i2c)
 >  		} else {
>                       i2c-> state = STATE_DONE;
 >  			oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_STOP);
 > +			wake_up(&i2c->wait);
 >  			return;

It is close to 10 years ago since I last had access to any boards with
the ocores controller, but the logic in ocores_process() indicates that
the controller would generate another interrupt once the stop condition
has been sent:

	if ((i2c->state == STATE_DONE) || (i2c->state == STATE_ERROR)) {
		/* stop has been sent */
		oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_IACK);
		wake_up(&i2c->wait);
		return;
	}

Do you not see this interrupt?

-- 
Bye, Peter Korsgaard

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

* Re: [PATCH] i2c: ocores: Add missing wake_up() call upon state change to STATE_DONE
  2017-06-16 12:52 ` Peter Korsgaard
@ 2017-06-16 13:04   ` Stefan Roese
  2017-06-16 13:26     ` Peter Korsgaard
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Roese @ 2017-06-16 13:04 UTC (permalink / raw)
  To: Peter Korsgaard; +Cc: linux-i2c, Wolfram Sang

Hi Peter,

On 16.06.2017 14:52, Peter Korsgaard wrote:
>>>>>> "Stefan" == Stefan Roese <sr@denx.de> writes:
> 
>   > I've noticed that this driver adds a timeout pause of 1 second after
>   > each xfer. This is due to the wait_event_timeout() call in ocores_xfer()
>   > using a "HZ" timeout value and a missing call to wake_up() in
>   > ocores_process() called by the interrupt handler when the state changes
>   > to STATE_DONE at the end of the frame.
> 
>   > This patch adds the missing call resulting in the removal of this 1
>   > second timeout delay after each xfer.
> 
>   > Signed-off-by: Stefan Roese <sr@denx.de>
>   > Cc: Wolfram Sang <wsa@the-dreams.de>
>   > ---
>   >  drivers/i2c/busses/i2c-ocores.c | 1 +
>   >  1 file changed, 1 insertion(+)
> 
>   > diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
>   > index 34f1889a4073..5f8395ea0106 100644
>   > --- a/drivers/i2c/busses/i2c-ocores.c
>   > +++ b/drivers/i2c/busses/i2c-ocores.c
>   > @@ -191,6 +191,7 @@ static void ocores_process(struct ocores_i2c *i2c)
>   >  		} else {
>>                        i2c-> state = STATE_DONE;
>   >  			oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_STOP);
>   > +			wake_up(&i2c->wait);
>   >  			return;
> 
> It is close to 10 years ago since I last had access to any boards with
> the ocores controller, but the logic in ocores_process() indicates that
> the controller would generate another interrupt once the stop condition
> has been sent:
> 
> 	if ((i2c->state == STATE_DONE) || (i2c->state == STATE_ERROR)) {
> 		/* stop has been sent */
> 		oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_IACK);
> 		wake_up(&i2c->wait);
> 		return;
> 	}
> 
> Do you not see this interrupt?

No. It took me quite some time last week, to notice this misbehavior
in this I2C driver. As the client (Goodix I2C touchscreen) always
returned only after more than 1 second from reading one I2C frame.

Thanks,
Stefan

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

* Re: [PATCH] i2c: ocores: Add missing wake_up() call upon state change to STATE_DONE
  2017-06-16 13:04   ` Stefan Roese
@ 2017-06-16 13:26     ` Peter Korsgaard
  2017-06-22 10:53       ` Stefan Roese
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Korsgaard @ 2017-06-16 13:26 UTC (permalink / raw)
  To: Stefan Roese; +Cc: linux-i2c, Wolfram Sang

>>>>> "Stefan" == Stefan Roese <sr@denx.de> writes:

Hi,

 >> It is close to 10 years ago since I last had access to any boards with
 >> the ocores controller, but the logic in ocores_process() indicates that
 >> the controller would generate another interrupt once the stop condition
 >> has been sent:
 >> 
 >> if ((i2c->state == STATE_DONE) || (i2c->state == STATE_ERROR)) {
 >> /* stop has been sent */
 >> oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_IACK);
 >> wake_up(&i2c->wait);
 >> return;
 >> }
 >> 
 >> Do you not see this interrupt?

 > No. It took me quite some time last week, to notice this misbehavior
 > in this I2C driver. As the client (Goodix I2C touchscreen) always
 > returned only after more than 1 second from reading one I2C frame.

Funky. On what kind of platform / what VHDL source version is this? The
driver has now existed for more than 10 years and has had contributions
from a number of people, but this is the first time I hear about this
missing interrupt.

-- 
Bye, Peter Korsgaard

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

* Re: [PATCH] i2c: ocores: Add missing wake_up() call upon state change to STATE_DONE
  2017-06-16 13:26     ` Peter Korsgaard
@ 2017-06-22 10:53       ` Stefan Roese
  2017-06-23 18:29         ` Wolfram Sang
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Roese @ 2017-06-22 10:53 UTC (permalink / raw)
  To: Peter Korsgaard; +Cc: linux-i2c, Wolfram Sang

Hi Peter,

first sorry for the delay.

On 16.06.2017 15:26, Peter Korsgaard wrote:
>>>>>> "Stefan" == Stefan Roese <sr@denx.de> writes:
> 
> Hi,
> 
>   >> It is close to 10 years ago since I last had access to any boards with
>   >> the ocores controller, but the logic in ocores_process() indicates that
>   >> the controller would generate another interrupt once the stop condition
>   >> has been sent:
>   >>
>   >> if ((i2c->state == STATE_DONE) || (i2c->state == STATE_ERROR)) {
>   >> /* stop has been sent */
>   >> oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_IACK);
>   >> wake_up(&i2c->wait);
>   >> return;
>   >> }
>   >>
>   >> Do you not see this interrupt?
> 
>   > No. It took me quite some time last week, to notice this misbehavior
>   > in this I2C driver. As the client (Goodix I2C touchscreen) always
>   > returned only after more than 1 second from reading one I2C frame.
> 
> Funky. On what kind of platform / what VHDL source version is this?

Thanks for looking into this. It seems that we had a quite old
version of the OpenCores I2C core implemented on our Altera /
Intel Arria V board:

Rev 1.2 (2001/11/10)

> The
> driver has now existed for more than 10 years and has had contributions
> from a number of people, but this is the first time I hear about this
> missing interrupt.

After updating to the latest version from OpenCores, the issue
with the missing interrupt seems to be resolved. So this patch
can be dropped.

Thanks,
Stefan

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

* Re: [PATCH] i2c: ocores: Add missing wake_up() call upon state change to STATE_DONE
  2017-06-22 10:53       ` Stefan Roese
@ 2017-06-23 18:29         ` Wolfram Sang
  2017-06-26 21:30           ` Peter Korsgaard
  0 siblings, 1 reply; 7+ messages in thread
From: Wolfram Sang @ 2017-06-23 18:29 UTC (permalink / raw)
  To: Stefan Roese; +Cc: Peter Korsgaard, linux-i2c

[-- Attachment #1: Type: text/plain, Size: 224 bytes --]


> After updating to the latest version from OpenCores, the issue
> with the missing interrupt seems to be resolved. So this patch
> can be dropped.

Thanks for the heads up and thanks to Peter for looking into this issue!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] i2c: ocores: Add missing wake_up() call upon state change to STATE_DONE
  2017-06-23 18:29         ` Wolfram Sang
@ 2017-06-26 21:30           ` Peter Korsgaard
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Korsgaard @ 2017-06-26 21:30 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: Stefan Roese, linux-i2c

>>>>> "Wolfram" == Wolfram Sang <wsa@the-dreams.de> writes:

 >> After updating to the latest version from OpenCores, the issue
 >> with the missing interrupt seems to be resolved. So this patch
 >> can be dropped.

 > Thanks for the heads up and thanks to Peter for looking into this issue!

Great, thanks both!

-- 
Bye, Peter Korsgaard

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

end of thread, other threads:[~2017-06-26 21:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-16  9:23 [PATCH] i2c: ocores: Add missing wake_up() call upon state change to STATE_DONE Stefan Roese
2017-06-16 12:52 ` Peter Korsgaard
2017-06-16 13:04   ` Stefan Roese
2017-06-16 13:26     ` Peter Korsgaard
2017-06-22 10:53       ` Stefan Roese
2017-06-23 18:29         ` Wolfram Sang
2017-06-26 21:30           ` Peter Korsgaard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.