Re: [PATCH 1/2] spi/spi_s3c64xx: Fix timeout handling in wait_for_xfer()
From: Jassi Brar
Date: Tue Sep 07 2010 - 21:12:29 EST
On Wed, Sep 8, 2010 at 12:37 AM, Mark Brown
<broonie@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> In wait_for_xfer() for PIO transfer we are using val as both a
> counter variable to track the number of spins we've waited for
> completion and the value we read from the controller, causing
> us to fail to ever actually notice the timeout. Fix this by using
> a separate value to hold the register readback.
>
> Also warn when we hit the timeout.
>
> Signed-off-by: Mark Brown <broonie@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
> ---
> Âdrivers/spi/spi_s3c64xx.c | Â 11 +++++++----
> Â1 files changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/spi/spi_s3c64xx.c b/drivers/spi/spi_s3c64xx.c
> index 6e48ea9..03b28e4 100644
> --- a/drivers/spi/spi_s3c64xx.c
> +++ b/drivers/spi/spi_s3c64xx.c
> @@ -321,7 +321,7 @@ static int wait_for_xfer(struct s3c64xx_spi_driver_data *sdd,
> Â{
> Â Â Â Âstruct s3c64xx_spi_info *sci = sdd->cntrlr_info;
> Â Â Â Âvoid __iomem *regs = sdd->regs;
> - Â Â Â unsigned long val;
> + Â Â Â unsigned long val, reg;
> Â Â Â Âint ms;
>
> Â Â Â Â/* millisecs to xfer 'len' bytes @ 'cur_speed' */
> @@ -333,13 +333,16 @@ static int wait_for_xfer(struct s3c64xx_spi_driver_data *sdd,
> Â Â Â Â Â Â Â Âval = wait_for_completion_timeout(&sdd->xfer_completion, val);
> Â Â Â Â} else {
> Â Â Â Â Â Â Â Âval = msecs_to_loops(ms);
> +
> Â Â Â Â Â Â Â Âdo {
> - Â Â Â Â Â Â Â Â Â Â Â val = readl(regs + S3C64XX_SPI_STATUS);
> - Â Â Â Â Â Â Â } while (RX_FIFO_LVL(val, sci) < xfer->len && --val);
> + Â Â Â Â Â Â Â Â Â Â Â reg = readl(regs + S3C64XX_SPI_STATUS);
> + Â Â Â Â Â Â Â } while (RX_FIFO_LVL(reg, sci) < xfer->len && --val);
> Â Â Â Â}
>
> - Â Â Â if (!val)
> + Â Â Â if (!val) {
> + Â Â Â Â Â Â Â dev_warn(&sdd->pdev->dev, "Transfer timeout\n");
> Â Â Â Â Â Â Â Âreturn -EIO;
> + Â Â Â }
I have already submitted a patch a few days ago
https://patchwork.kernel.org/patch/151941/
(It's strange that Grant's id isn't there in the CC list, despite my writing it)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/