linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* spi-rspi I/O errors
@ 2014-01-07 20:27 Geert Uytterhoeven
  2014-01-08  0:27 ` Laurent Pinchart
       [not found] ` <alpine.DEB.2.02.1401072116370.27579-97SZ98TBZzA1xEWliksxXw@public.gmane.org>
  0 siblings, 2 replies; 12+ messages in thread
From: Geert Uytterhoeven @ 2014-01-07 20:27 UTC (permalink / raw)
  To: linux-spi-u79uwXL29TY76Z2rM5mHXA, linux-sh-u79uwXL29TY76Z2rM5mHXA

I was regularly getting I/O errors when using the Renesas RSPI/QSPI
driver on r8a7791:

    m25p80 spi0.0: error -110 reading SR

Until I applied the following patch, which re-reads RSPI_SPSR on a time-out,
and continues if the condition has become true:

diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index 4b31d89e8568..e63e30c500da 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -442,8 +442,13 @@ static int rspi_wait_for_interrupt(struct rspi_data *rspi, u8 wait_mask,
 	rspi->spsr = rspi_read8(rspi, RSPI_SPSR);
 	rspi_enable_irq(rspi, enable_bit);
 	ret = wait_event_timeout(rspi->wait, rspi->spsr & wait_mask, HZ);
-	if (ret == 0 && !(rspi->spsr & wait_mask))
-		return -ETIMEDOUT;
+	if (ret == 0 && !(rspi->spsr & wait_mask)) {
+		u8 spsr = rspi_read8(rspi, RSPI_SPSR);
+		printk("*** rspi->spsr = 0x%02x, real spsr = 0x%02x, wait_mask = 0x%02x ***\n",
+		       rspi->spsr, spsr, wait_mask);
+		if (!(spsr & wait_mask))
+			return -ETIMEDOUT;
+	}
 
 	return 0;
 }

Now it prints from time to time:

    *** rspi->spsr = 0x20, real spsr = 0xa0, wait_mask = 0x80 ***

which shows that rspi->spsr (as set from the interrupt handler) didn't
have bit 7 set, while RSPI_SPSR does have bit 7 set.

So this looks like a race condition in the interrupt handling.

I didn't notice any data corruption after the patch.

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds
--
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

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

end of thread, other threads:[~2014-01-13 10:19 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-07 20:27 spi-rspi I/O errors Geert Uytterhoeven
2014-01-08  0:27 ` Laurent Pinchart
2014-01-08  8:28   ` Geert Uytterhoeven
     [not found]     ` <CAMuHMdWDwF+KcNPrKgjvH6w7Uxn-iON+nQz_+Z_RTU_yV7SVog-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-01-08  8:41       ` Laurent Pinchart
2014-01-08 13:13         ` Geert Uytterhoeven
     [not found]           ` <CAMuHMdVzFeymxW2CZUyKgZ-fxsektE1EpLQksfSzoekj2ex53Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-01-09  3:26             ` Magnus Damm
     [not found]               ` <CANqRtoRj_CybzDY3h1Caz=G=R7R-GVBxJ86xr5isWnWn1mDb2A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-01-09  9:48                 ` Geert Uytterhoeven
2014-01-09 18:13           ` Laurent Pinchart
2014-01-09 18:14             ` Laurent Pinchart
2014-01-10  9:20               ` Geert Uytterhoeven
     [not found]                 ` <CAMuHMdX+4Z5nzj1t-v3kG4__yjYohOic1b0dUA9ZwHJrt2MRgw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-01-13 10:19                   ` Geert Uytterhoeven
     [not found] ` <alpine.DEB.2.02.1401072116370.27579-97SZ98TBZzA1xEWliksxXw@public.gmane.org>
2014-01-08  0:28   ` Simon Horman

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).