All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] spi: xilinx: Detect stall with Unknown commands
@ 2017-11-21  9:09 Ricardo Ribalda Delgado
       [not found] ` <20171121090904.6901-1-ricardo.ribalda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Ricardo Ribalda Delgado @ 2017-11-21  9:09 UTC (permalink / raw)
  To: linux-spi-u79uwXL29TY76Z2rM5mHXA
  Cc: Ricardo Ribalda Delgado, Mark Brown, Lars-Peter Clausen

When the core is configured in C_SPI_MODE > 0, it integrates a
lookup table that automatically configures the core in dual or quad mode
based on the command (first byte on the tx fifo).

Unfortunately, that list mode_?_memoy_*.mif does not contain all the
supported commands by the flash.

Since 4.14 spi-nor automatically tries to probe the flash using SFDP
(command 0x5a), and that command is not part of the list_mode table.

Whit the right combination of C_SPI_MODE and C_SPI_MEMORY this leads
into a stall that can only be recovered with a soft rest.

This patch detects this kind of stall and returns -EIO to the caller on
those commands. spi-nor can handle this error properly:

m25p80 spi0.0: Detected stall. Check C_SPI_MODE and C_SPI_MEMORY. 0x21 0x2404
m25p80 spi0.0: SPI transfer failed: -5
spi_master spi0: failed to transfer one message from queue
m25p80 spi0.0: s25sl064p (8192 Kbytes)

Cc: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/spi/spi-xilinx.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c
index bc7100b93dfc..e0b9fe1d0e37 100644
--- a/drivers/spi/spi-xilinx.c
+++ b/drivers/spi/spi-xilinx.c
@@ -271,6 +271,7 @@ static int xilinx_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t)
 	while (remaining_words) {
 		int n_words, tx_words, rx_words;
 		u32 sr;
+		int stalled;
 
 		n_words = min(remaining_words, xspi->buffer_size);
 
@@ -299,7 +300,17 @@ static int xilinx_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t)
 
 		/* Read out all the data from the Rx FIFO */
 		rx_words = n_words;
+		stalled = 10;
 		while (rx_words) {
+			if (rx_words == n_words && !(stalled--) &&
+			    !(sr & XSPI_SR_TX_EMPTY_MASK) &&
+			    (sr & XSPI_SR_RX_EMPTY_MASK)) {
+				dev_err(&spi->dev,
+					"Detected stall. Check C_SPI_MODE and C_SPI_MEMORY\n");
+				xspi_init_hw(xspi);
+				return -EIO;
+			}
+
 			if ((sr & XSPI_SR_TX_EMPTY_MASK) && (rx_words > 1)) {
 				xilinx_spi_rx(xspi);
 				rx_words--;
-- 
2.15.0

--
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] 10+ messages in thread

* [PATCH 2/3] spi: xilinx: Add support for xlnx,axi-quad-spi-1.00.a
       [not found] ` <20171121090904.6901-1-ricardo.ribalda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2017-11-21  9:09   ` Ricardo Ribalda Delgado
       [not found]     ` <20171121090904.6901-2-ricardo.ribalda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2017-11-21  9:09   ` [PATCH 3/3] MAINTAINERS: Add Ricardo Ribalda for spi-xilinx Ricardo Ribalda Delgado
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Ricardo Ribalda Delgado @ 2017-11-21  9:09 UTC (permalink / raw)
  To: linux-spi-u79uwXL29TY76Z2rM5mHXA
  Cc: Ricardo Ribalda Delgado, Mark Brown, Rob Herring,
	devicetree-u79uwXL29TY76Z2rM5mHXA

The driver has been successfully tested with Xilinx's core
axi-quad-spi-1.0.0a. Documented on DS843:

https://www.xilinx.com/support/documentation/ip_documentation/axi_quad_spi/v1_00_a/ds843_axi_quad_spi.pdf

Cc: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 Documentation/devicetree/bindings/spi/spi-xilinx.txt | 2 +-
 drivers/spi/spi-xilinx.c                             | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/spi/spi-xilinx.txt b/Documentation/devicetree/bindings/spi/spi-xilinx.txt
index c7b7856bd528..7bf61efc66c8 100644
--- a/Documentation/devicetree/bindings/spi/spi-xilinx.txt
+++ b/Documentation/devicetree/bindings/spi/spi-xilinx.txt
@@ -2,7 +2,7 @@ Xilinx SPI controller Device Tree Bindings
 -------------------------------------------------
 
 Required properties:
-- compatible		: Should be "xlnx,xps-spi-2.00.a" or "xlnx,xps-spi-2.00.b"
+- compatible		: Should be "xlnx,xps-spi-2.00.a", "xlnx,xps-spi-2.00.b" or "xlnx,axi-quad-spi-1.00.a"
 - reg			: Physical base address and size of SPI registers map.
 - interrupts		: Property with a value describing the interrupt
 			  number.
diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c
index e0b9fe1d0e37..63fedc49ae9c 100644
--- a/drivers/spi/spi-xilinx.c
+++ b/drivers/spi/spi-xilinx.c
@@ -381,6 +381,7 @@ static int xilinx_spi_find_buffer_size(struct xilinx_spi *xspi)
 }
 
 static const struct of_device_id xilinx_spi_of_match[] = {
+	{ .compatible = "xlnx,axi-quad-spi-1.00.a", },
 	{ .compatible = "xlnx,xps-spi-2.00.a", },
 	{ .compatible = "xlnx,xps-spi-2.00.b", },
 	{}
-- 
2.15.0

--
To unsubscribe from this list: send the line "unsubscribe devicetree" 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] 10+ messages in thread

* [PATCH 3/3] MAINTAINERS: Add Ricardo Ribalda for spi-xilinx
       [not found] ` <20171121090904.6901-1-ricardo.ribalda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2017-11-21  9:09   ` [PATCH 2/3] spi: xilinx: Add support for xlnx,axi-quad-spi-1.00.a Ricardo Ribalda Delgado
@ 2017-11-21  9:09   ` Ricardo Ribalda Delgado
  2017-11-22 11:12   ` [PATCH 1/3] spi: xilinx: Detect stall with Unknown commands Mark Brown
  2017-11-24 13:04   ` Applied "spi: xilinx: Detect stall with Unknown commands" to the spi tree Mark Brown
  3 siblings, 0 replies; 10+ messages in thread
From: Ricardo Ribalda Delgado @ 2017-11-21  9:09 UTC (permalink / raw)
  To: linux-spi-u79uwXL29TY76Z2rM5mHXA; +Cc: Ricardo Ribalda Delgado

Since almost half of the driver comes from changes from me, I have
access to the hardware and we are using it in a current product I
volunteer for maintaining this driver.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 CREDITS                  | 1 +
 MAINTAINERS              | 6 ++++++
 drivers/spi/spi-xilinx.c | 1 +
 3 files changed, 8 insertions(+)

diff --git a/CREDITS b/CREDITS
index a3ec0c744172..b3bca8d36d2a 100644
--- a/CREDITS
+++ b/CREDITS
@@ -3071,6 +3071,7 @@ D: Several AX.25 hacks
 N: Ricardo Ribalda Delgado
 E: ricardo.ribalda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
 W: http://ribalda.com
+D: Xilinx QUAD SPI driver
 D: PLX USB338x driver
 D: PCA9634 driver
 D: Option GTM671WFS
diff --git a/MAINTAINERS b/MAINTAINERS
index 2811a211632c..992f24e4e05a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -14786,6 +14786,12 @@ M:	John Linn <John.Linn-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>
 S:	Maintained
 F:	drivers/net/ethernet/xilinx/xilinx_axienet*
 
+XILINX SPI DRIVER
+M:	Ricardo Ribalda <ricardo.ribalda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
+L:	linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
+S:	Supported
+F:	drivers/spi/spi-xilinx.c
+
 XILINX UARTLITE SERIAL DRIVER
 M:	Peter Korsgaard <jacmet-OfajU3CKLf1/SzgSGea1oA@public.gmane.org>
 L:	linux-serial-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c
index 63fedc49ae9c..b401c4e1c93a 100644
--- a/drivers/spi/spi-xilinx.c
+++ b/drivers/spi/spi-xilinx.c
@@ -4,6 +4,7 @@
  * Author: MontaVista Software, Inc.
  *	source-Igf4POYTYCDQT0dZR+AlfA@public.gmane.org
  *
+ * Copyright (C) 2015-2017 Ricardo Ribalda, Qtechnology A/S
  * Copyright (c) 2010 Secret Lab Technologies, Ltd.
  * Copyright (c) 2009 Intel Corporation
  * 2002-2007 (c) MontaVista Software, Inc.
-- 
2.15.0

--
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] 10+ messages in thread

* Re: [PATCH 2/3] spi: xilinx: Add support for xlnx,axi-quad-spi-1.00.a
       [not found]     ` <20171121090904.6901-2-ricardo.ribalda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2017-11-21 18:38       ` Rob Herring
  2017-11-27 18:54         ` Mark Brown
  1 sibling, 0 replies; 10+ messages in thread
From: Rob Herring @ 2017-11-21 18:38 UTC (permalink / raw)
  To: Ricardo Ribalda Delgado
  Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA, Mark Brown,
	devicetree-u79uwXL29TY76Z2rM5mHXA

On Tue, Nov 21, 2017 at 10:09:03AM +0100, Ricardo Ribalda Delgado wrote:
> The driver has been successfully tested with Xilinx's core
> axi-quad-spi-1.0.0a. Documented on DS843:
> 
> https://www.xilinx.com/support/documentation/ip_documentation/axi_quad_spi/v1_00_a/ds843_axi_quad_spi.pdf
> 
> Cc: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> Cc: Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  Documentation/devicetree/bindings/spi/spi-xilinx.txt | 2 +-
>  drivers/spi/spi-xilinx.c                             | 1 +
>  2 files changed, 2 insertions(+), 1 deletion(-)

Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

--
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	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] spi: xilinx: Detect stall with Unknown commands
       [not found] ` <20171121090904.6901-1-ricardo.ribalda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2017-11-21  9:09   ` [PATCH 2/3] spi: xilinx: Add support for xlnx,axi-quad-spi-1.00.a Ricardo Ribalda Delgado
  2017-11-21  9:09   ` [PATCH 3/3] MAINTAINERS: Add Ricardo Ribalda for spi-xilinx Ricardo Ribalda Delgado
@ 2017-11-22 11:12   ` Mark Brown
       [not found]     ` <20171122111215.2isnpg3nfry3g3ll-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
  2017-11-24 13:04   ` Applied "spi: xilinx: Detect stall with Unknown commands" to the spi tree Mark Brown
  3 siblings, 1 reply; 10+ messages in thread
From: Mark Brown @ 2017-11-22 11:12 UTC (permalink / raw)
  To: Ricardo Ribalda Delgado
  Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA, Lars-Peter Clausen

[-- Attachment #1: Type: text/plain, Size: 498 bytes --]

On Tue, Nov 21, 2017 at 10:09:02AM +0100, Ricardo Ribalda Delgado wrote:

> +		stalled = 10;
>  		while (rx_words) {
> +			if (rx_words == n_words && !(stalled--) &&
> +			    !(sr & XSPI_SR_TX_EMPTY_MASK) &&
> +			    (sr & XSPI_SR_RX_EMPTY_MASK)) {

10 seems like a small number for what is essentially just a busy spin -
are we sure that we won't reasonably hit a case where the CPU is
sufficiently fast and the bus sufficiently slow we falsely detect a
stall?  Where did this number come from?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 1/3] spi: xilinx: Detect stall with Unknown commands
       [not found]     ` <20171122111215.2isnpg3nfry3g3ll-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
@ 2017-11-22 19:25       ` Ricardo Ribalda Delgado
       [not found]         ` <CAPybu_2MBMFOy+RDSSai1pGf_+A4AD6=gbyWbZSLEPQetjfBxA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Ricardo Ribalda Delgado @ 2017-11-22 19:25 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi, Lars-Peter Clausen

Hi Mark


On Wed, Nov 22, 2017 at 12:12 PM, Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote:
> On Tue, Nov 21, 2017 at 10:09:02AM +0100, Ricardo Ribalda Delgado wrote:
>
>> +             stalled = 10;
>>               while (rx_words) {
>> +                     if (rx_words == n_words && !(stalled--) &&
>> +                         !(sr & XSPI_SR_TX_EMPTY_MASK) &&
>> +                         (sr & XSPI_SR_RX_EMPTY_MASK)) {
>
> 10 seems like a small number for what is essentially just a busy spin -
> are we sure that we won't reasonably hit a case where the CPU is
> sufficiently fast and the bus sufficiently slow we falsely detect a
> stall?  Where did this number come from?

This code is executed after all the data has been pushed to the out
fifo. Since we are not inhibitng tx, the moment the empty mask is
evaluated,  at least one byte should be out.

After 1 day of use I have been able to locate one event when stalled
was two. So 10 is very conservative number.

In other words: 10 is one order of magnitude bigger than the worst
measured case.

Thanks for your review :)


-- 
Ricardo Ribalda
--
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	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] spi: xilinx: Detect stall with Unknown commands
       [not found]         ` <CAPybu_2MBMFOy+RDSSai1pGf_+A4AD6=gbyWbZSLEPQetjfBxA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2017-11-22 19:27           ` Ricardo Ribalda Delgado
  0 siblings, 0 replies; 10+ messages in thread
From: Ricardo Ribalda Delgado @ 2017-11-22 19:27 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi, Lars-Peter Clausen

Hi again

On Wed, Nov 22, 2017 at 8:25 PM, Ricardo Ribalda Delgado
<ricardo.ribalda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Hi Mark
>
>
> On Wed, Nov 22, 2017 at 12:12 PM, Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote:
>> On Tue, Nov 21, 2017 at 10:09:02AM +0100, Ricardo Ribalda Delgado wrote:
>>
>>> +             stalled = 10;
>>>               while (rx_words) {
>>> +                     if (rx_words == n_words && !(stalled--) &&
>>> +                         !(sr & XSPI_SR_TX_EMPTY_MASK) &&
>>> +                         (sr & XSPI_SR_RX_EMPTY_MASK)) {
>>
>> 10 seems like a small number for what is essentially just a busy spin -
>> are we sure that we won't reasonably hit a case where the CPU is
>> sufficiently fast and the bus sufficiently slow we falsely detect a
>> stall?  Where did this number come from?
>
> This code is executed after all the data has been pushed to the out
> fifo. Since we are not inhibitng tx, the moment the empty mask is
> evaluated,  at least one byte should be out.
>
> After 1 day of use I have been able to locate one event when stalled
> was two. So 10 is very conservative number.
>
> In other words: 10 is one order of magnitude bigger than the worst
> measured case.


If it makes you more comfortable I could add something like

if (n_tries < 8)
   msleep(10);

Regards!

>
> Thanks for your review :)
>
>
> --
> Ricardo Ribalda



-- 
Ricardo Ribalda
--
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	[flat|nested] 10+ messages in thread

* Applied "spi: xilinx: Detect stall with Unknown commands" to the spi tree
       [not found] ` <20171121090904.6901-1-ricardo.ribalda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (2 preceding siblings ...)
  2017-11-22 11:12   ` [PATCH 1/3] spi: xilinx: Detect stall with Unknown commands Mark Brown
@ 2017-11-24 13:04   ` Mark Brown
  3 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2017-11-24 13:04 UTC (permalink / raw)
  To: Ricardo Ribalda
  Cc: Mark Brown, Lars-Peter Clausen, Ricardo Ribalda Delgado,
	Mark Brown, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	Ricardo Ribalda Delgado, Mark Brown, Lars-Peter Clausen,
	linux-spi-u79uwXL29TY76Z2rM5mHXA

The patch

   spi: xilinx: Detect stall with Unknown commands

has been applied to the spi tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From fe56ebb8b93de2593f9e200d4ea3b2714287490b Mon Sep 17 00:00:00 2001
From: Ricardo Ribalda <ricardo.ribalda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date: Tue, 21 Nov 2017 10:09:02 +0100
Subject: [PATCH] spi: xilinx: Detect stall with Unknown commands

When the core is configured in C_SPI_MODE > 0, it integrates a
lookup table that automatically configures the core in dual or quad mode
based on the command (first byte on the tx fifo).

Unfortunately, that list mode_?_memoy_*.mif does not contain all the
supported commands by the flash.

Since 4.14 spi-nor automatically tries to probe the flash using SFDP
(command 0x5a), and that command is not part of the list_mode table.

Whit the right combination of C_SPI_MODE and C_SPI_MEMORY this leads
into a stall that can only be recovered with a soft rest.

This patch detects this kind of stall and returns -EIO to the caller on
those commands. spi-nor can handle this error properly:

m25p80 spi0.0: Detected stall. Check C_SPI_MODE and C_SPI_MEMORY. 0x21 0x2404
m25p80 spi0.0: SPI transfer failed: -5
spi_master spi0: failed to transfer one message from queue
m25p80 spi0.0: s25sl064p (8192 Kbytes)

Cc: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Signed-off-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
---
 drivers/spi/spi-xilinx.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c
index bc7100b93dfc..e0b9fe1d0e37 100644
--- a/drivers/spi/spi-xilinx.c
+++ b/drivers/spi/spi-xilinx.c
@@ -271,6 +271,7 @@ static int xilinx_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t)
 	while (remaining_words) {
 		int n_words, tx_words, rx_words;
 		u32 sr;
+		int stalled;
 
 		n_words = min(remaining_words, xspi->buffer_size);
 
@@ -299,7 +300,17 @@ static int xilinx_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t)
 
 		/* Read out all the data from the Rx FIFO */
 		rx_words = n_words;
+		stalled = 10;
 		while (rx_words) {
+			if (rx_words == n_words && !(stalled--) &&
+			    !(sr & XSPI_SR_TX_EMPTY_MASK) &&
+			    (sr & XSPI_SR_RX_EMPTY_MASK)) {
+				dev_err(&spi->dev,
+					"Detected stall. Check C_SPI_MODE and C_SPI_MEMORY\n");
+				xspi_init_hw(xspi);
+				return -EIO;
+			}
+
 			if ((sr & XSPI_SR_TX_EMPTY_MASK) && (rx_words > 1)) {
 				xilinx_spi_rx(xspi);
 				rx_words--;
-- 
2.14.1

--
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] 10+ messages in thread

* Applied "spi: xilinx: Add support for xlnx,axi-quad-spi-1.00.a" to the spi tree
       [not found]     ` <20171121090904.6901-2-ricardo.ribalda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2017-11-27 18:54         ` Mark Brown
  2017-11-27 18:54         ` Mark Brown
  1 sibling, 0 replies; 10+ messages in thread
From: Mark Brown @ 2017-11-27 18:54 UTC (permalink / raw)
  Cc: Mark Brown, Rob Herring, devicetree-u79uwXL29TY76Z2rM5mHXA,
	Ricardo Ribalda Delgado, Rob Herring

The patch

   spi: xilinx: Add support for xlnx,axi-quad-spi-1.00.a

has been applied to the spi tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From a094c2fa093cf7fd0fe23d15cc2abca4083c6a45 Mon Sep 17 00:00:00 2001
From: Ricardo Ribalda <ricardo.ribalda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date: Tue, 21 Nov 2017 10:09:03 +0100
Subject: [PATCH] spi: xilinx: Add support for xlnx,axi-quad-spi-1.00.a

The driver has been successfully tested with Xilinx's core
axi-quad-spi-1.0.0a. Documented on DS843:

https://www.xilinx.com/support/documentation/ip_documentation/axi_quad_spi/v1_00_a/ds843_axi_quad_spi.pdf

Cc: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Signed-off-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
---
 Documentation/devicetree/bindings/spi/spi-xilinx.txt | 2 +-
 drivers/spi/spi-xilinx.c                             | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/spi/spi-xilinx.txt b/Documentation/devicetree/bindings/spi/spi-xilinx.txt
index c7b7856bd528..7bf61efc66c8 100644
--- a/Documentation/devicetree/bindings/spi/spi-xilinx.txt
+++ b/Documentation/devicetree/bindings/spi/spi-xilinx.txt
@@ -2,7 +2,7 @@ Xilinx SPI controller Device Tree Bindings
 -------------------------------------------------
 
 Required properties:
-- compatible		: Should be "xlnx,xps-spi-2.00.a" or "xlnx,xps-spi-2.00.b"
+- compatible		: Should be "xlnx,xps-spi-2.00.a", "xlnx,xps-spi-2.00.b" or "xlnx,axi-quad-spi-1.00.a"
 - reg			: Physical base address and size of SPI registers map.
 - interrupts		: Property with a value describing the interrupt
 			  number.
diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c
index e0b9fe1d0e37..63fedc49ae9c 100644
--- a/drivers/spi/spi-xilinx.c
+++ b/drivers/spi/spi-xilinx.c
@@ -381,6 +381,7 @@ static int xilinx_spi_find_buffer_size(struct xilinx_spi *xspi)
 }
 
 static const struct of_device_id xilinx_spi_of_match[] = {
+	{ .compatible = "xlnx,axi-quad-spi-1.00.a", },
 	{ .compatible = "xlnx,xps-spi-2.00.a", },
 	{ .compatible = "xlnx,xps-spi-2.00.b", },
 	{}
-- 
2.15.0

--
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] 10+ messages in thread

* Applied "spi: xilinx: Add support for xlnx,axi-quad-spi-1.00.a" to the spi tree
@ 2017-11-27 18:54         ` Mark Brown
  0 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2017-11-27 18:54 UTC (permalink / raw)
  To: Ricardo Ribalda
  Cc: Mark Brown, Rob Herring, devicetree-u79uwXL29TY76Z2rM5mHXA,
	Ricardo Ribalda Delgado, Rob Herring, Mark Brown,
	linux-spi-u79uwXL29TY76Z2rM5mHXA, Ricardo Ribalda Delgado,
	Mark Brown, Rob Herring, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-spi-u79uwXL29TY76Z2rM5mHXA

The patch

   spi: xilinx: Add support for xlnx,axi-quad-spi-1.00.a

has been applied to the spi tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From a094c2fa093cf7fd0fe23d15cc2abca4083c6a45 Mon Sep 17 00:00:00 2001
From: Ricardo Ribalda <ricardo.ribalda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date: Tue, 21 Nov 2017 10:09:03 +0100
Subject: [PATCH] spi: xilinx: Add support for xlnx,axi-quad-spi-1.00.a

The driver has been successfully tested with Xilinx's core
axi-quad-spi-1.0.0a. Documented on DS843:

https://www.xilinx.com/support/documentation/ip_documentation/axi_quad_spi/v1_00_a/ds843_axi_quad_spi.pdf

Cc: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Signed-off-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
---
 Documentation/devicetree/bindings/spi/spi-xilinx.txt | 2 +-
 drivers/spi/spi-xilinx.c                             | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/spi/spi-xilinx.txt b/Documentation/devicetree/bindings/spi/spi-xilinx.txt
index c7b7856bd528..7bf61efc66c8 100644
--- a/Documentation/devicetree/bindings/spi/spi-xilinx.txt
+++ b/Documentation/devicetree/bindings/spi/spi-xilinx.txt
@@ -2,7 +2,7 @@ Xilinx SPI controller Device Tree Bindings
 -------------------------------------------------
 
 Required properties:
-- compatible		: Should be "xlnx,xps-spi-2.00.a" or "xlnx,xps-spi-2.00.b"
+- compatible		: Should be "xlnx,xps-spi-2.00.a", "xlnx,xps-spi-2.00.b" or "xlnx,axi-quad-spi-1.00.a"
 - reg			: Physical base address and size of SPI registers map.
 - interrupts		: Property with a value describing the interrupt
 			  number.
diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c
index e0b9fe1d0e37..63fedc49ae9c 100644
--- a/drivers/spi/spi-xilinx.c
+++ b/drivers/spi/spi-xilinx.c
@@ -381,6 +381,7 @@ static int xilinx_spi_find_buffer_size(struct xilinx_spi *xspi)
 }
 
 static const struct of_device_id xilinx_spi_of_match[] = {
+	{ .compatible = "xlnx,axi-quad-spi-1.00.a", },
 	{ .compatible = "xlnx,xps-spi-2.00.a", },
 	{ .compatible = "xlnx,xps-spi-2.00.b", },
 	{}
-- 
2.15.0

--
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] 10+ messages in thread

end of thread, other threads:[~2017-11-27 18:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-21  9:09 [PATCH 1/3] spi: xilinx: Detect stall with Unknown commands Ricardo Ribalda Delgado
     [not found] ` <20171121090904.6901-1-ricardo.ribalda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-11-21  9:09   ` [PATCH 2/3] spi: xilinx: Add support for xlnx,axi-quad-spi-1.00.a Ricardo Ribalda Delgado
     [not found]     ` <20171121090904.6901-2-ricardo.ribalda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-11-21 18:38       ` Rob Herring
2017-11-27 18:54       ` Applied "spi: xilinx: Add support for xlnx,axi-quad-spi-1.00.a" to the spi tree Mark Brown
2017-11-27 18:54         ` Mark Brown
2017-11-21  9:09   ` [PATCH 3/3] MAINTAINERS: Add Ricardo Ribalda for spi-xilinx Ricardo Ribalda Delgado
2017-11-22 11:12   ` [PATCH 1/3] spi: xilinx: Detect stall with Unknown commands Mark Brown
     [not found]     ` <20171122111215.2isnpg3nfry3g3ll-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2017-11-22 19:25       ` Ricardo Ribalda Delgado
     [not found]         ` <CAPybu_2MBMFOy+RDSSai1pGf_+A4AD6=gbyWbZSLEPQetjfBxA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-22 19:27           ` Ricardo Ribalda Delgado
2017-11-24 13:04   ` Applied "spi: xilinx: Detect stall with Unknown commands" to the spi tree Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.