All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: designware: prevent signals from aborting I2C transfers
@ 2013-05-22 10:03 ` Mika Westerberg
  0 siblings, 0 replies; 5+ messages in thread
From: Mika Westerberg @ 2013-05-22 10:03 UTC (permalink / raw)
  To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
  Cc: Wolfram Sang, Jean Delvare, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	Mika Westerberg

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 <mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 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

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

* [PATCH] i2c: designware: prevent signals from aborting I2C transfers
@ 2013-05-22 10:03 ` Mika Westerberg
  0 siblings, 0 replies; 5+ messages in thread
From: Mika Westerberg @ 2013-05-22 10:03 UTC (permalink / raw)
  To: linux-kernel; +Cc: Wolfram Sang, Jean Delvare, linux-i2c, Mika Westerberg

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 <mika.westerberg@linux.intel.com>
---
 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


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

* Re: i2c: designware: prevent signals from aborting I2C transfers
  2013-05-22 10:03 ` Mika Westerberg
@ 2013-06-07  8:53     ` Christian Ruppert
  -1 siblings, 0 replies; 5+ messages in thread
From: Christian Ruppert @ 2013-06-07  8:53 UTC (permalink / raw)
  To: Mika Westerberg
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, Wolfram Sang, Jean Delvare,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA

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 <mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Reviewed-by: Christian Ruppert <christian.ruppert-ux6zf3SgZrrQT0dZR+AlfA@public.gmane.org>
> 
> ---
> 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              ,          <christian.ruppert@abilis.com>
                                /|
  Tel: +41/(0)22 816 19-42     //|                 3, Chemin du Pré-Fleuri
                             _// | bilis Systems   CH-1228 Plan-les-Ouates

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

* Re: i2c: designware: prevent signals from aborting I2C transfers
@ 2013-06-07  8:53     ` Christian Ruppert
  0 siblings, 0 replies; 5+ messages in thread
From: Christian Ruppert @ 2013-06-07  8:53 UTC (permalink / raw)
  To: Mika Westerberg; +Cc: linux-kernel, Wolfram Sang, Jean Delvare, linux-i2c

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 <mika.westerberg@linux.intel.com>
Reviewed-by: Christian Ruppert <christian.ruppert@abilis.com>
> 
> ---
> 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              ,          <christian.ruppert@abilis.com>
                                /|
  Tel: +41/(0)22 816 19-42     //|                 3, Chemin du Pré-Fleuri
                             _// | bilis Systems   CH-1228 Plan-les-Ouates

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

* Re: [PATCH] i2c: designware: prevent signals from aborting I2C transfers
  2013-05-22 10:03 ` Mika Westerberg
  (?)
  (?)
@ 2013-06-11 18:35 ` Wolfram Sang
  -1 siblings, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2013-06-11 18:35 UTC (permalink / raw)
  To: Mika Westerberg; +Cc: linux-kernel, Jean Delvare, linux-i2c

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

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 <mika.westerberg@linux.intel.com>

Applied to for-next, thanks!


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2013-06-11 18:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-22 10:03 [PATCH] i2c: designware: prevent signals from aborting I2C transfers Mika Westerberg
2013-05-22 10:03 ` Mika Westerberg
     [not found] ` <1369216991-13334-1-git-send-email-mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2013-06-07  8:53   ` Christian Ruppert
2013-06-07  8:53     ` Christian Ruppert
2013-06-11 18:35 ` [PATCH] " Wolfram Sang

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.