2013-05-22 10:00:50

by Mika Westerberg

[permalink] [raw]
Subject: [PATCH] i2c: designware: prevent signals from aborting I2C transfers

If a process receives signal while it is waiting for I2C transfer to
complete, an error is returned to the caller and the transfer is aborted.
This can cause the driver to fail subsequent transfers. Also according to
commit d295a86eab2 (i2c: mv64xxx: work around signals causing I2C
transactions to be aborted) I2C drivers aren't supposed to abort
transactions on signals.

To prevent this switch to use wait_for_completion_timeout() instead of
wait_for_completion_interruptible_timeout() in the designware I2C driver.

Signed-off-by: Mika Westerberg <[email protected]>
---
drivers/i2c/busses/i2c-designware-core.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c
index c41ca63..db20a28 100644
--- a/drivers/i2c/busses/i2c-designware-core.c
+++ b/drivers/i2c/busses/i2c-designware-core.c
@@ -580,14 +580,13 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
i2c_dw_xfer_init(dev);

/* wait for tx to complete */
- ret = wait_for_completion_interruptible_timeout(&dev->cmd_complete, HZ);
+ ret = wait_for_completion_timeout(&dev->cmd_complete, HZ);
if (ret == 0) {
dev_err(dev->dev, "controller timed out\n");
i2c_dw_init(dev);
ret = -ETIMEDOUT;
goto done;
- } else if (ret < 0)
- goto done;
+ }

if (dev->msg_err) {
ret = dev->msg_err;
--
1.7.10.4


2013-06-07 08:54:31

by Christian Ruppert

[permalink] [raw]
Subject: Re: i2c: designware: prevent signals from aborting I2C transfers

On Wed, May 22, 2013 at 10:03:11AM -0000, Mika Westerberg wrote:
> If a process receives signal while it is waiting for I2C transfer to
> complete, an error is returned to the caller and the transfer is aborted.
> This can cause the driver to fail subsequent transfers. Also according to
> commit d295a86eab2 (i2c: mv64xxx: work around signals causing I2C
> transactions to be aborted) I2C drivers aren't supposed to abort
> transactions on signals.
>
> To prevent this switch to use wait_for_completion_timeout() instead of
> wait_for_completion_interruptible_timeout() in the designware I2C driver.
>
> Signed-off-by: Mika Westerberg <[email protected]>
Reviewed-by: Christian Ruppert <[email protected]>
>
> ---
> drivers/i2c/busses/i2c-designware-core.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c
> index c41ca63..db20a28 100644
> --- a/drivers/i2c/busses/i2c-designware-core.c
> +++ b/drivers/i2c/busses/i2c-designware-core.c
> @@ -580,14 +580,13 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
> i2c_dw_xfer_init(dev);
>
> /* wait for tx to complete */
> - ret = wait_for_completion_interruptible_timeout(&dev->cmd_complete, HZ);
> + ret = wait_for_completion_timeout(&dev->cmd_complete, HZ);
> if (ret == 0) {
> dev_err(dev->dev, "controller timed out\n");
> i2c_dw_init(dev);
> ret = -ETIMEDOUT;
> goto done;
> - } else if (ret < 0)
> - goto done;
> + }
>
> if (dev->msg_err) {
> ret = dev->msg_err;

--
Christian Ruppert , <[email protected]>
/|
Tel: +41/(0)22 816 19-42 //| 3, Chemin du Pr?-Fleuri
_// | bilis Systems CH-1228 Plan-les-Ouates

2013-06-11 18:33:10

by Wolfram Sang

[permalink] [raw]
Subject: Re: [PATCH] i2c: designware: prevent signals from aborting I2C transfers

On Wed, May 22, 2013 at 01:03:11PM +0300, Mika Westerberg wrote:
> If a process receives signal while it is waiting for I2C transfer to
> complete, an error is returned to the caller and the transfer is aborted.
> This can cause the driver to fail subsequent transfers. Also according to
> commit d295a86eab2 (i2c: mv64xxx: work around signals causing I2C
> transactions to be aborted) I2C drivers aren't supposed to abort
> transactions on signals.
>
> To prevent this switch to use wait_for_completion_timeout() instead of
> wait_for_completion_interruptible_timeout() in the designware I2C driver.
>
> Signed-off-by: Mika Westerberg <[email protected]>

Applied to for-next, thanks!


Attachments:
(No filename) (703.00 B)
signature.asc (836.00 B)
Digital signature
Download all attachments