From: Sekhar Nori <nsekhar-l0cyMroinI0@public.gmane.org>
To: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Linux ARM Mailing List
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
<linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Grygorii Strashko
<grygorii.strashko-l0cyMroinI0@public.gmane.org>
Subject: Re: [PATCH] spi: davinci: fix spurious i/o error
Date: Tue, 24 Nov 2015 17:57:26 +0530 [thread overview]
Message-ID: <565457AE.3050309@ti.com> (raw)
In-Reply-To: <108883742c4b44d338ea0816abeeb2901a2afcd5.1448361028.git.nsekhar-l0cyMroinI0@public.gmane.org>
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-l0cyMroinI0@public.gmane.org>
> ---
> 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-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2015-11-24 12:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-24 10:34 [PATCH] spi: davinci: fix spurious i/o error Sekhar Nori
[not found] ` <108883742c4b44d338ea0816abeeb2901a2afcd5.1448361028.git.nsekhar-l0cyMroinI0@public.gmane.org>
2015-11-24 12:27 ` Sekhar Nori [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=565457AE.3050309@ti.com \
--to=nsekhar-l0cymroini0@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=grygorii.strashko-l0cyMroinI0@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).