Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1276292 > unrolled thread

[PATCH] spi: davinci: fix spurious i/o error

Started bySekhar Nori <nsekhar@ti.com>
First post2015-11-24 11:40 +0100
Last post2015-11-24 13:30 +0100
Articles 2 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH] spi: davinci: fix spurious i/o error Sekhar Nori <nsekhar@ti.com> - 2015-11-24 11:40 +0100
    Re: [PATCH] spi: davinci: fix spurious i/o error Sekhar Nori <nsekhar@ti.com> - 2015-11-24 13:30 +0100

#1276292 — [PATCH] spi: davinci: fix spurious i/o error

FromSekhar Nori <nsekhar@ti.com>
Date2015-11-24 11:40 +0100
Subject[PATCH] spi: davinci: fix spurious i/o error
Message-ID<qyjaW-6V9-5@gated-at.bofh.it>
davinci_spi_bufs() uses wait_for_completion_interruptible()
without bothering to handle -ERESTARTSYS. Due to this,
sometime, it returns prematurely when a signal is received.
Since the return value is never checked, userspace eventually
receives a spurious -EIO.

To fix this, use un-interruptible wait_for_completion_timeout().

Signed-off-by: Sekhar Nori <nsekhar@ti.com>
---
 drivers/spi/spi-davinci.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c
index 7d3af3eacf57..38026aa1afd7 100644
--- a/drivers/spi/spi-davinci.c
+++ b/drivers/spi/spi-davinci.c
@@ -703,7 +703,10 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
 
 	/* Wait for the transfer to complete */
 	if (spicfg->io_type != SPI_IO_TYPE_POLL) {
-		wait_for_completion_interruptible(&(dspi->done));
+		if (wait_for_completion_timeout(&dspi->done, HZ) == 0) {
+			dev_err(&spi->dev, "spi transfer timeout\n");
+			return -ETIMEDOUT;
+		}
 	} else {
 		while (dspi->rcount > 0 || dspi->wcount > 0) {
 			errors = davinci_spi_process_events(dspi);
-- 
2.4.4.408.g16da57c

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1276383

FromSekhar Nori <nsekhar@ti.com>
Date2015-11-24 13:30 +0100
Message-ID<qykTn-82V-13@gated-at.bofh.it>
In reply to#1276292
On Tuesday 24 November 2015 04:04 PM, Sekhar Nori wrote:
> davinci_spi_bufs() uses wait_for_completion_interruptible()
> without bothering to handle -ERESTARTSYS. Due to this,
> sometime, it returns prematurely when a signal is received.
> Since the return value is never checked, userspace eventually
> receives a spurious -EIO.
> 
> To fix this, use un-interruptible wait_for_completion_timeout().
> 
> Signed-off-by: Sekhar Nori <nsekhar@ti.com>
> ---
>  drivers/spi/spi-davinci.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c
> index 7d3af3eacf57..38026aa1afd7 100644
> --- a/drivers/spi/spi-davinci.c
> +++ b/drivers/spi/spi-davinci.c
> @@ -703,7 +703,10 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
>  
>  	/* Wait for the transfer to complete */
>  	if (spicfg->io_type != SPI_IO_TYPE_POLL) {
> -		wait_for_completion_interruptible(&(dspi->done));
> +		if (wait_for_completion_timeout(&dspi->done, HZ) == 0) {
> +			dev_err(&spi->dev, "spi transfer timeout\n");
> +			return -ETIMEDOUT;

Grygorii pointed out offline that this does not recover correctly in DMA
case. I will fix and send a v2.

Thanks,
Sekhar
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web