From: Christian Gmeiner <christian.gmeiner@gmail.com>
To: linux-spi@vger.kernel.org
Cc: broonie@kernel.org, linux-kernel@vger.kernel.org,
Christian Gmeiner <christian.gmeiner@gmail.com>
Subject: [PATCH] spi: imx: wait_for_completion_timeout(..) for PIO transfers
Date: Fri, 1 Jul 2016 14:32:58 +0200 [thread overview]
Message-ID: <1467376378-21535-1-git-send-email-christian.gmeiner@gmail.com> (raw)
In-Reply-To: <20160621185100.GD28202@sirena.org.uk>
In some rare cases I see the following 'task blocked' information. It
looks like the PIO transfer has some problems and never succeeds. Make
use of wait_for_completion_timeout(..) to detect this case and
return -ETIMEDOUT.
v2: remove backtrace from commit message
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
---
drivers/spi/spi-imx.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index 50769078..d2b96b1 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -1050,6 +1050,8 @@ static int spi_imx_pio_transfer(struct spi_device *spi,
struct spi_transfer *transfer)
{
struct spi_imx_data *spi_imx = spi_master_get_devdata(spi->master);
+ unsigned long transfer_timeout;
+ unsigned long timeout;
spi_imx->tx_buf = transfer->tx_buf;
spi_imx->rx_buf = transfer->rx_buf;
@@ -1062,7 +1064,15 @@ static int spi_imx_pio_transfer(struct spi_device *spi,
spi_imx->devtype_data->intctrl(spi_imx, MXC_INT_TE);
- wait_for_completion(&spi_imx->xfer_done);
+ transfer_timeout = spi_imx_calculate_timeout(spi_imx, transfer->len);
+
+ timeout = wait_for_completion_timeout(&spi_imx->xfer_done,
+ transfer_timeout);
+ if (!timeout) {
+ dev_err(&spi->dev, "I/O Error in PIO\n");
+ spi_imx->devtype_data->reset(spi_imx);
+ return -ETIMEDOUT;
+ }
return transfer->len;
}
--
2.7.4
next prev parent reply other threads:[~2016-07-01 12:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-21 12:12 [PATCH] spi: imx: wait_for_completion_timeout(..) for PIO transfers Christian Gmeiner
2016-06-21 18:51 ` Mark Brown
2016-07-01 12:32 ` Christian Gmeiner [this message]
2016-07-01 15:01 ` Mark Brown
2016-07-02 13:26 ` Christian Gmeiner
2016-06-21 18:53 ` Applied "spi: imx: wait_for_completion_timeout(..) for PIO transfers" to the spi tree Mark Brown
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=1467376378-21535-1-git-send-email-christian.gmeiner@gmail.com \
--to=christian.gmeiner@gmail.com \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.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).