Skip to contentSkip to conversation

usb: musb: da8xx: Add DMA support

PATCH Superseded Alexandre Bailon 3 participants 11 messages Jan 9, 2017 – Jan 10, 2017 7 messages not in the archive

Subsystems (3)

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

cover usb: musb: da8xx: Add DMA support

This series update musb driver to add DMA support to da8xx. To work correctly, the follwings patches are required:
"dmaengine: cppi41: Add dma support to da8xx", "ARM: davinci: da850: Share the usb20 clock", "ARM: dts: da850: Enable cppi41 dma",
"dmaengine: cppi41: PM runtime fixes"

I haven't changed yet the davinci_all_defconfig to enable the DMA mode by default. I'm planning to do it once all the warnings happening during the teardwon will be fixed.

The series has been tested on beaglebone black and omapl138-lcdk in both host mode (pendrive, headset, wifi, webcam) and device mode (MSC, CDC).
Expect few warnings on omapl138-lcdk, I haven't noticed any issues.

Alexandre Bailon (4):
usb: musb: da8xx: Use the right dma controller
usb: musb: Add support of cppi41 dma controller for da8xx to Kconfig
usb: musb: Use shared irq
usb: musb: musb_cppi41: Workaround dma stall issue during teardown

 drivers/dma/Kconfig            | 2 +-
 drivers/usb/musb/Kconfig       | 4 ++--
 drivers/usb/musb/da8xx.c       | 8 ++++----
 drivers/usb/musb/musb_core.c   | 2 +-
 drivers/usb/musb/musb_core.h   | 1 +
 drivers/usb/musb/musb_cppi41.c | 4 ++++
 6 files changed, 13 insertions(+), 8 deletions(-)
Signature · 6 lines
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

PATCH 1/4 usb: musb: da8xx: Use the right dma controller

In reply to a message not in the archive

da8xx driver is registering and using the cppi dma controller but actually, the da8xx has a cppi41 dma controller.
Update the driver to register and use the cppi41 dma controller.

---
 drivers/usb/musb/da8xx.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/musb/da8xx.c +4 -4
index e89708d..74dcc07 100644
@@ -458,14 +458,14 @@ static inline u8 get_vbus_power(struct device *dev)
 }
 
 static const struct musb_platform_ops da8xx_ops = {
-	.quirks		= MUSB_DMA_CPPI | MUSB_INDEXED_EP,
+	.quirks		= MUSB_DMA_CPPI41 | MUSB_INDEXED_EP,
 	.init		= da8xx_musb_init,
 	.exit		= da8xx_musb_exit,
 
 	.fifo_mode	= 2,
-#ifdef CONFIG_USB_TI_CPPI_DMA
-	.dma_init	= cppi_dma_controller_create,
-	.dma_exit	= cppi_dma_controller_destroy,
+#ifdef CONFIG_USB_TI_CPPI41_DMA
+	.dma_init	= cppi41_dma_controller_create,
+	.dma_exit	= cppi41_dma_controller_destroy,
 #endif
 	.enable		= da8xx_musb_enable,
 	.disable	= da8xx_musb_disable,
Signature · 6 lines
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#11 lore raw

PATCH 2/4 usb: musb: Add support of cppi41 dma controller for da8xx to Kconfig

In reply to a message not in the archive

Currently, cppi41 driver can only be built for omap platform. As da8xx platform has a cppi41 dma controller, update the Kconfig to also support the da8xx.

---
 drivers/dma/Kconfig      | 2 +-
 drivers/usb/musb/Kconfig | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/dma/Kconfig +1 -1
index 0d6a96e..8fe9de7 100644
@@ -515,7 +515,7 @@ config TIMB_DMA
 
 config TI_CPPI41
 	tristate "AM33xx CPPI41 DMA support"
-	depends on ARCH_OMAP
+	depends on (ARCH_OMAP || ARCH_DAVINCI_DA8XX)
 	select DMA_ENGINE
 	help
 	  The Communications Port Programming Interface (CPPI) 4.1 DMA engine
drivers/usb/musb/Kconfig +2 -2
index 72a2a50..3018518 100644
@@ -160,8 +160,8 @@ config USB_TI_CPPI_DMA
 	  Enable DMA transfers when TI CPPI DMA is available.
 
 config USB_TI_CPPI41_DMA
-	bool 'TI CPPI 4.1 (AM335x)'
-	depends on ARCH_OMAP && DMADEVICES
+	bool 'TI CPPI 4.1 (AM335x or DA8xx)'
+	depends on (ARCH_OMAP || ARCH_DAVINCI_DA8XX) && DMADEVICES
 	select TI_CPPI41
 
 config USB_TUSB_OMAP_DMA
Signature · 6 lines
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#12 lore raw

PATCH 3/4 usb: musb: Use shared irq

In reply to a message not in the archive

In the da8xx, usb core and cppi41 are sharing the same interrupt line. Update the driver to request a shared irq.

---
 drivers/usb/musb/musb_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/musb/musb_core.c +1 -1
index fca288bb..cf40adf 100644
@@ -2329,7 +2329,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
 	setup_timer(&musb->otg_timer, musb_otg_timer_func, (unsigned long) musb);
 
 	/* attach to the IRQ */
-	if (request_irq(nIrq, musb->isr, 0, dev_name(dev), musb)) {
+	if (request_irq(nIrq, musb->isr, IRQF_SHARED, dev_name(dev), musb)) {
 		dev_err(dev, "request_irq %d failed!\n", nIrq);
 		status = -ENODEV;
 		goto fail3;
Signature · 6 lines
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#13 lore raw

PATCH 4/4 usb: musb: musb_cppi41: Workaround dma stall issue during teardown

In reply to a message not in the archive

The dma may hung up if a teardown is initiated while an endpoint is still active (Advisory 2.3.27 of da8xx errata).
To workaround this issue, add a delay before to initiate the teardown.

---
 drivers/usb/musb/da8xx.c       | 2 +-
 drivers/usb/musb/musb_core.h   | 1 +
 drivers/usb/musb/musb_cppi41.c | 4 ++++
 3 files changed, 6 insertions(+), 1 deletion(-)
drivers/usb/musb/da8xx.c +1 -1
index 74dcc07..3513284 100644
@@ -458,7 +458,7 @@ static inline u8 get_vbus_power(struct device *dev)
 }
 
 static const struct musb_platform_ops da8xx_ops = {
-	.quirks		= MUSB_DMA_CPPI41 | MUSB_INDEXED_EP,
+	.quirks		= MUSB_DMA_CPPI41 | MUSB_INDEXED_EP | MUSB_DA8XX,
 	.init		= da8xx_musb_init,
 	.exit		= da8xx_musb_exit,
 
drivers/usb/musb/musb_core.h +1 -0
index ade902e..d129278 100644
@@ -172,6 +172,7 @@ struct musb_io;
  */
 struct musb_platform_ops {
 
+#define MUSB_DA8XX		BIT(7)
 #define MUSB_DMA_UX500		BIT(6)
 #define MUSB_DMA_CPPI41		BIT(5)
 #define MUSB_DMA_CPPI		BIT(4)
drivers/usb/musb/musb_cppi41.c +4 -0
index 1636385..8fdbc17 100644
@@ -547,6 +547,10 @@ static int cppi41_dma_channel_abort(struct dma_channel *channel)
 		}
 	}
 
+	/* DA8xx Advisory 2.3.27: wait 250 ms before to start the teardown */
+	if (musb->io.quirks & MUSB_DA8XX)
+		mdelay(250);
+
 	tdbit = 1 << cppi41_channel->port_num;
 	if (is_tx)
 		tdbit <<= 16;
Signature · 6 lines
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw

Re: [PATCH 1/4] usb: musb: da8xx: Use the right dma controller

In reply to a message not in the archive

Hello!

Quoted 14 lines · Alexandre Bailon

da8xx driver is registering and using the cppi dma controller but actually, the da8xx has a cppi41 dma controller.
Update the driver to register and use the cppi41 dma controller.

---
 drivers/usb/musb/da8xx.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/musb/da8xx.c +0 -0
index e89708d..74dcc07 100644

drivers/usb/musb/da8xx.c static inline u8 get_vbus_power(struct device *dev) · line 461

Quoted 4 lines
drivers/usb/musb/da8xx.c +0 -1
@@ -458,14 +458,14 @@ static inline u8 get_vbus_power(struct device *dev)
 }
 
 static const struct musb_platform_ops da8xx_ops = {
-	.quirks		= MUSB_DMA_CPPI | MUSB_INDEXED_EP,

Grr, MUSB_DMA_CPPI is certainly wrong! There's no CPPI 3.0 support for
DA8xx. Where have this come from?

drivers/usb/musb/da8xx.c static inline u8 get_vbus_power(struct device *dev) · line 468

Quoted 8 lines
drivers/usb/musb/da8xx.c +1 -3
+	.quirks		= MUSB_DMA_CPPI41 | MUSB_INDEXED_EP,
 	.init		= da8xx_musb_init,
 	.exit		= da8xx_musb_exit,
 
 	.fifo_mode	= 2,
-#ifdef CONFIG_USB_TI_CPPI_DMA
-	.dma_init	= cppi_dma_controller_create,
-	.dma_exit	= cppi_dma_controller_destroy,

Likewise, WTF?
I suggest that you fix this crap in a separate commit, to be backported to
-stable if needed.

[...]

MBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#15 lore raw

Re: [PATCH 4/4] usb: musb: musb_cppi41: Workaround dma stall issue during teardown

In reply to a message not in the archive

Hello!

Quoted 1 line · Alexandre Bailon

The dma may hung up if a teardown is initiated while an endpoint is still

The DMA may hang up...

Quoted 4 lines

active (Advisory 2.3.27 of da8xx errata).
To workaround this issue, add a delay before to initiate the teardown.

[...]

drivers/usb/musb/musb_cppi41.c static int cppi41_dma_channel_abort(struct dma_channel *channel) · line 552

Quoted 11 lines
drivers/usb/musb/musb_cppi41.c +3 -0
index 1636385..8fdbc17 100644
@@ -547,6 +547,10 @@ static int cppi41_dma_channel_abort(struct dma_channel *channel)
 		}
 	}
 
+	/* DA8xx Advisory 2.3.27: wait 250 ms before to start the teardown */
+	if (musb->io.quirks & MUSB_DA8XX)
+		mdelay(250);

This is a horrible workaround, not even msleep()...

[...]

MBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw

Re: [PATCH 1/4] usb: musb: da8xx: Use the right dma controller

In reply to a message not in the archive
Quoted 30 lines · Sergei Shtylyov

Hello!

Quoted 14 lines · Alexandre Bailon

da8xx driver is registering and using the cppi dma controller but actually, the da8xx has a cppi41 dma controller.
Update the driver to register and use the cppi41 dma controller.

---
 drivers/usb/musb/da8xx.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/musb/da8xx.c +0 -0
index e89708d..74dcc07 100644

drivers/usb/musb/da8xx.c static inline u8 get_vbus_power(struct device *dev) · line 461

Quoted 4 lines
drivers/usb/musb/da8xx.c +0 -1
@@ -458,14 +458,14 @@ static inline u8 get_vbus_power(struct device *dev)
 }
 
 static const struct musb_platform_ops da8xx_ops = {
-	.quirks		= MUSB_DMA_CPPI | MUSB_INDEXED_EP,

Grr, MUSB_DMA_CPPI is certainly wrong! There's no CPPI 3.0 support for
DA8xx. Where have this come from?

Quoted 4 lines
drivers/usb/musb/da8xx.c +1 -0
+	.quirks		= MUSB_DMA_CPPI41 | MUSB_INDEXED_EP,
 	.init		= da8xx_musb_init,
 	.exit		= da8xx_musb_exit,
 
Quoted 8 lines

drivers/usb/musb/da8xx.c static inline u8 get_vbus_power(struct device *dev) · line 468

Quoted 4 lines
drivers/usb/musb/da8xx.c +0 -3
 	.fifo_mode	= 2,
-#ifdef CONFIG_USB_TI_CPPI_DMA
-	.dma_init	= cppi_dma_controller_create,
-	.dma_exit	= cppi_dma_controller_destroy,

Likewise, WTF?
I suggest that you fix this crap in a separate commit, to be backported
to -stable if needed.

Probably came from my DMA patch 7f6283ed6fe8 ("usb: musb: Set up function pointers for DMA"). At that point I thought da8xxx.c and davinci.c are just separate attempts of the same driver.. Sorry the number of musb glue layers is just too confusing.

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#8 lore raw

Re: [PATCH 1/4] usb: musb: da8xx: Use the right dma controller

In reply to a message not in the archive
Quoted 35 lines · Tony Lindgren
Quoted 26 lines
Quoted 14 lines

da8xx driver is registering and using the cppi dma controller but actually, the da8xx has a cppi41 dma controller.
Update the driver to register and use the cppi41 dma controller.

---
 drivers/usb/musb/da8xx.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/musb/da8xx.c +0 -0
index e89708d..74dcc07 100644

drivers/usb/musb/da8xx.c static inline u8 get_vbus_power(struct device *dev) · line 461

Quoted 4 lines
drivers/usb/musb/da8xx.c +0 -1
@@ -458,14 +458,14 @@ static inline u8 get_vbus_power(struct device *dev)
 }
 
 static const struct musb_platform_ops da8xx_ops = {
-	.quirks		= MUSB_DMA_CPPI | MUSB_INDEXED_EP,

Grr, MUSB_DMA_CPPI is certainly wrong! There's no CPPI 3.0 support for
DA8xx. Where have this come from?

Quoted 4 lines
drivers/usb/musb/da8xx.c +1 -0
+	.quirks		= MUSB_DMA_CPPI41 | MUSB_INDEXED_EP,
 	.init		= da8xx_musb_init,
 	.exit		= da8xx_musb_exit,
 
Quoted 8 lines

drivers/usb/musb/da8xx.c static inline u8 get_vbus_power(struct device *dev) · line 468

Quoted 4 lines
drivers/usb/musb/da8xx.c +0 -3
 	.fifo_mode	= 2,
-#ifdef CONFIG_USB_TI_CPPI_DMA
-	.dma_init	= cppi_dma_controller_create,
-	.dma_exit	= cppi_dma_controller_destroy,

Likewise, WTF?
I suggest that you fix this crap in a separate commit, to be backported
to -stable if needed.

Quoted 1 line

Probably came from my DMA patch 7f6283ed6fe8 ("usb: musb: Set up function

Too bad I missed it back then. Then certainly this should be fixed in a
separate patch. The first hunk was not a part of that commit, tho...

Quoted 3 lines

pointers for DMA"). At that point I thought da8xxx.c and davinci.c are just separate attempts of the same driver.. Sorry the number of musb glue layers is just too confusing.

:-)

Quoted 1 line

Tony

MBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#10 lore raw

Re: [PATCH 1/4] usb: musb: da8xx: Use the right dma controller

In reply to a message not in the archive
Quoted 37 lines · Sergei Shtylyov
Quoted 35 lines · Tony Lindgren
Quoted 34 lines
Quoted 14 lines

da8xx driver is registering and using the cppi dma controller but actually, the da8xx has a cppi41 dma controller.
Update the driver to register and use the cppi41 dma controller.

---
 drivers/usb/musb/da8xx.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/musb/da8xx.c +0 -0
index e89708d..74dcc07 100644

drivers/usb/musb/da8xx.c static inline u8 get_vbus_power(struct device *dev) · line 461

Quoted 4 lines
drivers/usb/musb/da8xx.c +0 -1
@@ -458,14 +458,14 @@ static inline u8 get_vbus_power(struct device *dev)
 }
 
 static const struct musb_platform_ops da8xx_ops = {
-	.quirks		= MUSB_DMA_CPPI | MUSB_INDEXED_EP,

Grr, MUSB_DMA_CPPI is certainly wrong! There's no CPPI 3.0 support for
DA8xx. Where have this come from?

drivers/usb/musb/da8xx.c static inline u8 get_vbus_power(struct device *dev) · line 468

Quoted 8 lines
drivers/usb/musb/da8xx.c +1 -3
+	.quirks		= MUSB_DMA_CPPI41 | MUSB_INDEXED_EP,
 	.init		= da8xx_musb_init,
 	.exit		= da8xx_musb_exit,
 
 	.fifo_mode	= 2,
-#ifdef CONFIG_USB_TI_CPPI_DMA
-	.dma_init	= cppi_dma_controller_create,
-	.dma_exit	= cppi_dma_controller_destroy,

Likewise, WTF?
I suggest that you fix this crap in a separate commit, to be backported
to -stable if needed.

Quoted 8 lines
Quoted 1 line

Probably came from my DMA patch 7f6283ed6fe8 ("usb: musb: Set up function

Too bad I missed it back then. Then certainly this should be fixed in a
separate patch. The first hunk was not a part of that commit, tho...

Quoted 3 lines

pointers for DMA"). At that point I thought da8xxx.c and davinci.c are just separate attempts of the same driver.. Sorry the number of musb glue layers is just too confusing.

Maybe from f8e9f34f80a2 ("usb: musb: Fix up DMA related macros")?

Sorry obviously I have no idea how the da8xx.c should be configured for DMA.

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#17 lore raw

Re: [PATCH 4/4] usb: musb: musb_cppi41: Workaround dma stall issue during teardown

In reply to a message not in the archive
Quoted 23 lines · Sergei Shtylyov

Hello!

Quoted 1 line · Alexandre Bailon

The dma may hung up if a teardown is initiated while an endpoint is still

The DMA may hang up...

Quoted 4 lines

active (Advisory 2.3.27 of da8xx errata).
To workaround this issue, add a delay before to initiate the teardown.

[...]

Quoted 10 lines
drivers/usb/musb/musb_cppi41.c +0 -0
index 1636385..8fdbc17 100644
@@ -547,6 +547,10 @@ static int cppi41_dma_channel_abort(struct
 dma_channel *channel)
         }
     }
 
Quoted 6 lines

drivers/usb/musb/musb_cppi41.c static int cppi41_dma_channel_abort(struct dma_channel *channel) · line 552

Quoted 4 lines
drivers/usb/musb/musb_cppi41.c +1 -0
+    /* DA8xx Advisory 2.3.27: wait 250 ms before to start the

teardown */

drivers/usb/musb/musb_cppi41.c +2 -0
+    if (musb->io.quirks & MUSB_DA8XX)
+        mdelay(250);

This is a horrible workaround, not even msleep()...

Indeed, that's a bad workaround but have not found a better one. cppi41_dma_channel_abort() is called from atomic context, so we can't use msleep().
And update the musb driver to call cppi41_dma_channel_abort() from process context would require too many changes.

Best Regards,
Alexandre

Quoted 5 lines

[...]

MBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html