Skip to contentSkip to conversation

i2c-mpc: do not allow interruptions when waiting for I2C to complete

PATCH Applied Timur Tabi 5 participants 11 messages Feb 6, 2009 – Feb 19, 2009 6 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Timur Tabi

author
#0 lore raw

PATCH 1/1 i2c-mpc: do not allow interruptions when waiting for I2C to complete

The i2c_wait() function is using wait_event_interruptible_timeout() to wait for the I2C controller to signal that it has completed an I2C bus operation. If the process that causes the I2C operation terminated abruptly, the wait will be interrupted, returning an error. It is better to let the I2C operation finished before the process exits.

It is safe to use wait_event_timeout() instead, because the timeout will allow the process to exit if the I2C bus hangs. It's also better to allow the I2C operation to finish, because unacknowledged I2C operations can cause the I2C bus to hang.

---

A similar change should probably be done to i2c-cpm.c, and maybe all other I2C drivers. Not many use wait_event_interruptible_timeout().

 drivers/i2c/busses/i2c-mpc.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
drivers/i2c/busses/i2c-mpc.c +3 -6
index a9a45fc..c0ace48 100644
@@ -70,7 +70,7 @@ static irqreturn_t mpc_i2c_isr(int irq, void *dev_id)
 		/* Read again to allow register to stabilise */
 		i2c->interrupt = readb(i2c->base + MPC_I2C_SR);
 		writeb(0, i2c->base + MPC_I2C_SR);
-		wake_up_interruptible(&i2c->queue);
+		wake_up(&i2c->queue);
 	}
 	return IRQ_HANDLED;
 }
@@ -115,13 +115,10 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
 		writeb(0, i2c->base + MPC_I2C_SR);
 	} else {
 		/* Interrupt mode */
-		result = wait_event_interruptible_timeout(i2c->queue,
+		result = wait_event_timeout(i2c->queue,
 			(i2c->interrupt & CSR_MIF), timeout * HZ);
 
-		if (unlikely(result < 0)) {
-			pr_debug("I2C: wait interrupted\n");
-			writeccr(i2c, 0);
-		} else if (unlikely(!(i2c->interrupt & CSR_MIF))) {
+		if (unlikely(!(i2c->interrupt & CSR_MIF))) {
 			pr_debug("I2C: wait timeout\n");
 			writeccr(i2c, 0);
 			result = -ETIMEDOUT;
Signature · 1 line
1.5.5

A message that is not in the archive (sent off-list or not yet received): 1233928837-3401-1-git-send-email-timur-KZfg59tc24xl57MIdRCFDg@public.gmane.org

author
#2 lore raw
Quoted 6 lines · Timur Tabi

The i2c_wait() function is using wait_event_interruptible_timeout() to wait for the I2C controller to signal that it has completed an I2C bus operation. If the process that causes the I2C operation terminated abruptly, the wait will be interrupted, returning an error. It is better to let the I2C operation finished before the process exits.

Quoted 6 lines

It is safe to use wait_event_timeout() instead, because the timeout will allow the process to exit if the I2C bus hangs. It's also better to allow the I2C operation to finish, because unacknowledged I2C operations can cause the I2C bus to hang.

Jean,

Could you pick up this patch for 2.6.30?

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale

A message that is not in the archive (sent off-list or not yet received): ed82fe3e0902100659p2eec9de6j61f9ffb504d60a89-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#4 lore raw
Quoted 12 lines · Timur Tabi
Quoted 11 lines · Timur Tabi

The i2c_wait() function is using wait_event_interruptible_timeout() to wait for the I2C controller to signal that it has completed an I2C bus operation. If the process that causes the I2C operation terminated abruptly, the wait will be interrupted, returning an error. It is better to let the I2C operation finished before the process exits.

It is safe to use wait_event_timeout() instead, because the timeout will allow the process to exit if the I2C bus hangs. It's also better to allow the I2C operation to finish, because unacknowledged I2C operations can cause the I2C bus to hang.

Quoted 5 lines
Quoted 1 line

Jean,

Could you pick up this patch for 2.6.30?

No, that's something for either Ben Dooks (Cc'd) or the powerpc tree.

Signature · 1 line
Jean Delvare

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#6 lore raw
Quoted 1 line · Jean Delvare

No, that's something for either Ben Dooks (Cc'd) or the powerpc tree.

This patch has nothing to do with ARM, so Kumar will pick it up, if you ACK it.

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw
Quoted 6 lines · Timur Tabi
Quoted 1 line · Jean Delvare

No, that's something for either Ben Dooks (Cc'd) or the powerpc tree.

This patch has nothing to do with ARM, so Kumar will pick it up, if you ACK it.

Why are you mentioning ARM?

Quoted 1 line

From MAINTAINERS:

I2C SUBSYSTEM

P:      Jean Delvare (PC drivers, core)
M:      [email protected]
P:      Ben Dooks (embedded platforms)
M:      [email protected]

To the best of my knowledge i2c-mpc falls into the "embedded platforms" category and is thus under Ben's responsibility.

Thanks,

Signature · 1 line
Jean Delvare

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#10 lore raw
Quoted 2 lines · Jean Delvare

To the best of my knowledge i2c-mpc falls into the "embedded platforms" category and is thus under Ben's responsibility.

I don't see his Signed-off-by on any patch to i2c-mpc.c for the past three years (at least). I do see yours, however. You have directly applied similar patches in the recent past, so of course I will assume that you would apply this one.

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale

A message that is not in the archive (sent off-list or not yet received): [email protected]

#12 lore raw
Quoted 2 lines

I don't see his Signed-off-by on any patch to i2c-mpc.c for the past three years (at least). I do see yours, however. You have directly

Ben is the I2C-"embedded"-maintainer. This job was created less than a year ago, this is why you don't see sob from him regarding this driver.

Regards,

Wolfram

Signature · 2 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#13 lore raw
In reply to a message not in the archive
Quoted 9 lines · Timur Tabi
Quoted 2 lines · Jean Delvare

To the best of my knowledge i2c-mpc falls into the "embedded platforms" category and is thus under Ben's responsibility.

I don't see his Signed-off-by on any patch to i2c-mpc.c for the past three years (at least). I do see yours, however. You have directly applied similar patches in the recent past, so of course I will assume that you would apply this one.

My appointment as an embedded maintainer is relatively recent.

I do try and review patches, and sometimes these patches get sent to another maintainer.

Signature · 3 lines
Ben ([email protected], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
Acked-by
#14 lore raw
In reply to a message not in the archive
Quoted 6 lines · Timur Tabi

The i2c_wait() function is using wait_event_interruptible_timeout() to wait for the I2C controller to signal that it has completed an I2C bus operation. If the process that causes the I2C operation terminated abruptly, the wait will be interrupted, returning an error. It is better to let the I2C operation finished before the process exits.

Quoted 6 lines

It is safe to use wait_event_timeout() instead, because the timeout will allow the process to exit if the I2C bus hangs. It's also better to allow the I2C operation to finish, because unacknowledged I2C operations can cause the I2C bus to hang.

Signature · 2 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Acked-by
#15 lore raw
In reply to a message not in the archive
Quoted 6 lines · Timur Tabi

The i2c_wait() function is using wait_event_interruptible_timeout() to wait for the I2C controller to signal that it has completed an I2C bus operation. If the process that causes the I2C operation terminated abruptly, the wait will be interrupted, returning an error. It is better to let the I2C operation finished before the process exits.

Quoted 6 lines

It is safe to use wait_event_timeout() instead, because the timeout will allow the process to exit if the I2C bus hangs. It's also better to allow the I2C operation to finish, because unacknowledged I2C operations can cause the I2C bus to hang.

Quoted 44 lines

---

A similar change should probably be done to i2c-cpm.c, and maybe all other I2C drivers. Not many use wait_event_interruptible_timeout().

 drivers/i2c/busses/i2c-mpc.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
drivers/i2c/busses/i2c-mpc.c +3 -6
index a9a45fc..c0ace48 100644
@@ -70,7 +70,7 @@ static irqreturn_t mpc_i2c_isr(int irq, void *dev_id)
 		/* Read again to allow register to stabilise */
 		i2c->interrupt = readb(i2c->base + MPC_I2C_SR);
 		writeb(0, i2c->base + MPC_I2C_SR);
-		wake_up_interruptible(&i2c->queue);
+		wake_up(&i2c->queue);
 	}
 	return IRQ_HANDLED;
 }
@@ -115,13 +115,10 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
 		writeb(0, i2c->base + MPC_I2C_SR);
 	} else {
 		/* Interrupt mode */
-		result = wait_event_interruptible_timeout(i2c->queue,
+		result = wait_event_timeout(i2c->queue,
 			(i2c->interrupt & CSR_MIF), timeout * HZ);
 
-		if (unlikely(result < 0)) {
-			pr_debug("I2C: wait interrupted\n");
-			writeccr(i2c, 0);
-		} else if (unlikely(!(i2c->interrupt & CSR_MIF))) {
+		if (unlikely(!(i2c->interrupt & CSR_MIF))) {
 			pr_debug("I2C: wait timeout\n");
 			writeccr(i2c, 0);
 			result = -ETIMEDOUT;
Signature · 6 lines
1.5.5

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Signature · 3 lines
Ben ([email protected], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
Applied
#16 lore raw
In reply to a message not in the archive
Quoted 11 lines · Timur Tabi

The i2c_wait() function is using wait_event_interruptible_timeout() to wait for the I2C controller to signal that it has completed an I2C bus operation. If the process that causes the I2C operation terminated abruptly, the wait will be interrupted, returning an error. It is better to let the I2C operation finished before the process exits.

It is safe to use wait_event_timeout() instead, because the timeout will allow the process to exit if the I2C bus hangs. It's also better to allow the I2C operation to finish, because unacknowledged I2C operations can cause the I2C bus to hang.

Quoted 8 lines

---

A similar change should probably be done to i2c-cpm.c, and maybe all other I2C drivers. Not many use wait_event_interruptible_timeout().

drivers/i2c/busses/i2c-mpc.c | 9 +++------

1 files changed, 3 insertions(+), 6 deletions(-)

applied to next

- k