Skip to contentSkip to conversation

i2c: ocores: Add missing wake_up() call upon state change to STATE_DONE

PATCH In review Stefan Roese 3 participants 7 messages Jun 16, 2017 – Jun 26, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: ocores: Add missing wake_up() call upon state change to STATE_DONE

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.

---
 drivers/i2c/busses/i2c-ocores.c | 1 +
 1 file changed, 1 insertion(+)
drivers/i2c/busses/i2c-ocores.c +1 -0
index 34f1889a4073..5f8395ea0106 100644
@@ -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;
 		}
 	}
Signature · 1 line
2.13.1
maintainer
#1 lore raw
Quoted 22 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Stefan" == Stefan Roese <[email protected]> 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.

---
 drivers/i2c/busses/i2c-ocores.c | 1 +
 1 file changed, 1 insertion(+)
drivers/i2c/busses/i2c-ocores.c +0 -0
index 34f1889a4073..5f8395ea0106 100644

drivers/i2c/busses/i2c-ocores.c static void ocores_process(struct ocores_i2c *i2c) · line 195

Quoted 5 lines
drivers/i2c/busses/i2c-ocores.c +1 -0
@@ -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?

Signature · 1 line
Bye, Peter Korsgaard
#2 lore raw

Hi Peter,

Quoted 33 lines · Peter Korsgaard
Quoted 22 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Stefan" == Stefan Roese <[email protected]> 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.

---
 drivers/i2c/busses/i2c-ocores.c | 1 +
 1 file changed, 1 insertion(+)
drivers/i2c/busses/i2c-ocores.c +0 -0
index 34f1889a4073..5f8395ea0106 100644

drivers/i2c/busses/i2c-ocores.c static void ocores_process(struct ocores_i2c *i2c) · line 195

Quoted 5 lines
drivers/i2c/busses/i2c-ocores.c +1 -0
@@ -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:

Quoted 8 lines
	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

maintainer
#3 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Stefan" == Stefan Roese <[email protected]> writes:

Hi,

Quoted 12 lines
Quoted 12 lines

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;
}

Quoted 5 lines
Quoted 1 line

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.

Signature · 1 line
Bye, Peter Korsgaard
#4 lore raw

Hi Peter,

first sorry for the delay.

Quoted 16 lines · Peter Korsgaard
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Stefan" == Stefan Roese <[email protected]> writes:

Hi,

Quoted 12 lines
Quoted 12 lines

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;
}

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

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)

Quoted 4 lines

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

#5 lore raw
Quoted 4 lines

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!

maintainer
#6 lore raw
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Wolfram" == Wolfram Sang <[email protected]> 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!

Signature · 1 line
Bye, Peter Korsgaard