Skip to contentSkip to conversation

spi: omap2: disable DMA requests before complete()

PATCH Applied Felipe Balbi 2 participants 6 messages Dec 12, 2012 – Dec 16, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 spi: omap2: disable DMA requests before complete()

No actual errors have been found for completing before disabling DMA request lines, but it just looks more semantically correct that on our DMA callback we quiesce the whole thing before stating transfer is finished.

---
 drivers/spi/spi-omap2-mcspi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/spi/spi-omap2-mcspi.c +4 -4
index b610f52..68446db 100644
@@ -298,10 +298,10 @@ static void omap2_mcspi_rx_callback(void *data)
 	struct omap2_mcspi *mcspi = spi_master_get_devdata(spi->master);
 	struct omap2_mcspi_dma *mcspi_dma = &mcspi->dma_channels[spi->chip_select];
 
-	complete(&mcspi_dma->dma_rx_completion);
-
 	/* We must disable the DMA RX request */
 	omap2_mcspi_set_dma_req(spi, 1, 0);
+
+	complete(&mcspi_dma->dma_rx_completion);
 }
 
 static void omap2_mcspi_tx_callback(void *data)
@@ -310,10 +310,10 @@ static void omap2_mcspi_tx_callback(void *data)
 	struct omap2_mcspi *mcspi = spi_master_get_devdata(spi->master);
 	struct omap2_mcspi_dma *mcspi_dma = &mcspi->dma_channels[spi->chip_select];
 
-	complete(&mcspi_dma->dma_tx_completion);
-
 	/* We must disable the DMA TX request */
 	omap2_mcspi_set_dma_req(spi, 0, 0);
+
+	complete(&mcspi_dma->dma_tx_completion);
 }
 
 static void omap2_mcspi_tx_dma(struct spi_device *spi,
Signature · 1 line
1.8.1.rc1.5.g7e0651a
#1 lore raw

PATCH 2/2 spi: devicetree: add support for loopback mode

there are a few spi master drivers which make
use of that flag but there is no way to pass it
through devicetree.

This patch just creates a way to pass SPI_LOOP
via devicetree.

---
 Documentation/devicetree/bindings/spi/spi-bus.txt | 2 ++
 drivers/spi/spi.c                                 | 2 ++
 2 files changed, 4 insertions(+)
Documentation/devicetree/bindings/spi/spi-bus.txt +2 -0
index 296015e..1949586 100644
@@ -55,6 +55,8 @@ contain the following properties.
     		chip select active high
 - spi-3wire       - (optional) Empty property indicating device requires
     		    3-wire mode.
+- spi-loopback    - (optional) Empty property indicating device requires
+    		    loopback mode.
 
 If a gpio chipselect is used for the SPI slave the gpio number will be passed
 via the cs_gpio
drivers/spi/spi.c +2 -0
index 3f1b9ee..6bcdc03 100644
@@ -868,6 +868,8 @@ static void of_register_spi_devices(struct spi_master *master)
 			spi->mode |= SPI_CS_HIGH;
 		if (of_find_property(nc, "spi-3wire", NULL))
 			spi->mode |= SPI_3WIRE;
+		if (of_find_property(nc, "spi-loopback", NULL))
+			spi->mode |= SPI_LOOP;
 
 		/* Device speed */
 		prop = of_get_property(nc, "spi-max-frequency", &len);
Signature · 9 lines
1.8.1.rc1.5.g7e0651a


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
#2 lore raw

Re: [PATCH 2/2] spi: devicetree: add support for loopback mode

Quoted 6 lines · Felipe Balbi

there are a few spi master drivers which make
use of that flag but there is no way to pass it
through devicetree.

This patch just creates a way to pass SPI_LOOP
via devicetree.

I don't understand how this would be useful since loopback mode is really just a test feature. Is there any reason to do loopback for something other than test?

I think it would be better to add a sysfs or debugfs property to manipulate the SPI_LOOP flag from userspace. What do you think?

g.

Quoted 36 lines
---
 Documentation/devicetree/bindings/spi/spi-bus.txt | 2 ++
 drivers/spi/spi.c                                 | 2 ++
 2 files changed, 4 insertions(+)
Documentation/devicetree/bindings/spi/spi-bus.txt +2 -0
index 296015e..1949586 100644
@@ -55,6 +55,8 @@ contain the following properties.
     		chip select active high
 - spi-3wire       - (optional) Empty property indicating device requires
     		    3-wire mode.
+- spi-loopback    - (optional) Empty property indicating device requires
+    		    loopback mode.
 
 If a gpio chipselect is used for the SPI slave the gpio number will be passed
 via the cs_gpio
drivers/spi/spi.c +2 -0
index 3f1b9ee..6bcdc03 100644
@@ -868,6 +868,8 @@ static void of_register_spi_devices(struct spi_master *master)
 			spi->mode |= SPI_CS_HIGH;
 		if (of_find_property(nc, "spi-3wire", NULL))
 			spi->mode |= SPI_3WIRE;
+		if (of_find_property(nc, "spi-loopback", NULL))
+			spi->mode |= SPI_LOOP;
 
 		/* Device speed */
 		prop = of_get_property(nc, "spi-max-frequency", &len);
Signature · 1 line
1.8.1.rc1.5.g7e0651a
Signature · 2 lines
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.
#3 lore raw

Re: [PATCH 2/2] spi: devicetree: add support for loopback mode

Quoted 8 lines · Grant Likely
Quoted 6 lines · Felipe Balbi

there are a few spi master drivers which make
use of that flag but there is no way to pass it
through devicetree.

This patch just creates a way to pass SPI_LOOP
via devicetree.

Quoted 6 lines

I don't understand how this would be useful since loopback mode is really just a test feature. Is there any reason to do loopback for something other than test?

I think it would be better to add a sysfs or debugfs property to manipulate the SPI_LOOP flag from userspace. What do you think?

might be nicer in the long run, indeed. Want me to look into it, or do you wanna do it yourself ?

Signature · 1 line
balbi

_______________________________________________
devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss

#4 lore raw

Re: [PATCH 2/2] spi: devicetree: add support for loopback mode

Quoted 13 lines · Felipe Balbi
Quoted 12 lines · Grant Likely
Quoted 6 lines · Felipe Balbi

there are a few spi master drivers which make
use of that flag but there is no way to pass it
through devicetree.

This patch just creates a way to pass SPI_LOOP
via devicetree.

I don't understand how this would be useful since loopback mode is really just a test feature. Is there any reason to do loopback for something other than test?

Quoted 5 lines
Quoted 2 lines

I think it would be better to add a sysfs or debugfs property to manipulate the SPI_LOOP flag from userspace. What do you think?

might be nicer in the long run, indeed. Want me to look into it, or do you wanna do it yourself ?

Yes, please look into it. After all, you're the one who needs the feature/ :-)

g.

Applied
#5 lore raw
In reply to Felipe Balbi
Quoted 7 lines · Felipe Balbi

No actual errors have been found for completing before disabling DMA request lines, but it just looks more semantically correct that on our DMA callback we quiesce the whole thing before stating transfer is finished.

Applied, thanks.

g.

Quoted 37 lines
---
 drivers/spi/spi-omap2-mcspi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/spi/spi-omap2-mcspi.c +4 -4
index b610f52..68446db 100644
@@ -298,10 +298,10 @@ static void omap2_mcspi_rx_callback(void *data)
 	struct omap2_mcspi *mcspi = spi_master_get_devdata(spi->master);
 	struct omap2_mcspi_dma *mcspi_dma = &mcspi->dma_channels[spi->chip_select];
 
-	complete(&mcspi_dma->dma_rx_completion);
-
 	/* We must disable the DMA RX request */
 	omap2_mcspi_set_dma_req(spi, 1, 0);
+
+	complete(&mcspi_dma->dma_rx_completion);
 }
 
 static void omap2_mcspi_tx_callback(void *data)
@@ -310,10 +310,10 @@ static void omap2_mcspi_tx_callback(void *data)
 	struct omap2_mcspi *mcspi = spi_master_get_devdata(spi->master);
 	struct omap2_mcspi_dma *mcspi_dma = &mcspi->dma_channels[spi->chip_select];
 
-	complete(&mcspi_dma->dma_tx_completion);
-
 	/* We must disable the DMA TX request */
 	omap2_mcspi_set_dma_req(spi, 0, 0);
+
+	complete(&mcspi_dma->dma_tx_completion);
 }
 
 static void omap2_mcspi_tx_dma(struct spi_device *spi,
Signature · 1 line
1.8.1.rc1.5.g7e0651a
Signature · 2 lines
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.