[PATCH v2] usb: musb: do not use dma for control transfers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The Inventra DMA engine used with the MUSB controller in many
SoCs cannot use DMA for control transfers on EP0, but can use
DMA for all other transfers.

The USB core maps urbs for DMA if hcd->self.uses_dma is true.
(hcd->self.uses_dma is true for MUSB as well).

Split the uses_dma flag into two - one that says if the
controller needs to use PIO for control transfers, and
another which says if the controller uses DMA (for all
other transfers).

Also, populate this flag for all MUSB by default.

(Tested on OMAP3 and OMAP4 boards, with EHCI and MUSB HCDs
simultaneously in use).

Signed-off-by: Anand Gadiyar <gadiyar@xxxxxx>
Cc: Oliver Neukum <oliver@xxxxxxxxxx>
Cc: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>
Cc: Praveena NADAHALLY <praveen.nadahally@xxxxxxxxxxxxxx>
Cc: Felipe Balbi <felipe.balbi@xxxxxxxxx>
Cc: Ajay Kumar Gupta <ajay.gupta@xxxxxx>
---
v2:
- Updated patch addressing Alan's comments
- Remove RFC tag
- Cc Felipe and Ajay for the MUSB parts

- I've populated the uses_pio_for_control flag for all
MUSB HCDs. Even though some DMA engines used with MUSB may
be able to carry out control transfers using DMA, there may
not be much to be gained. If someone disagrees, I'll respin
the patch to populate this flag for the Inventra engine alone.

 drivers/usb/core/hcd.c         |    4 +++-
 drivers/usb/musb/musb_core.c   |    3 +++
 drivers/usb/musb/musb_gadget.c |    4 ++++
 include/linux/usb.h            |    4 ++++
 4 files changed, 14 insertions(+), 1 deletion(-)

Index: kernel-omap4-base/drivers/usb/core/hcd.c
===================================================================
--- kernel-omap4-base.orig/drivers/usb/core/hcd.c	2010-08-04 14:57:04.129928076 +0530
+++ kernel-omap4-base/drivers/usb/core/hcd.c	2010-08-04 15:02:18.577938877 +0530
@@ -1321,7 +1321,9 @@
 	 */
 
 	if (usb_endpoint_xfer_control(&urb->ep->desc)) {
-		if (hcd->self.uses_dma) {
+		if (hcd->self.uses_pio_for_control) {
+			urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
+		} else if (hcd->self.uses_dma) {
 			urb->setup_dma = dma_map_single(
 					hcd->self.controller,
 					urb->setup_packet,
Index: kernel-omap4-base/include/linux/usb.h
===================================================================
--- kernel-omap4-base.orig/include/linux/usb.h	2010-08-04 14:57:04.109948812 +0530
+++ kernel-omap4-base/include/linux/usb.h	2010-08-04 14:58:20.817938610 +0530
@@ -311,6 +311,10 @@
 	int busnum;			/* Bus number (in order of reg) */
 	const char *bus_name;		/* stable id (PCI slot_name etc) */
 	u8 uses_dma;			/* Does the host controller use DMA? */
+	u8 uses_pio_for_control;	/*
+					 * Does the host controller use PIO
+					 * for control transfers?
+					 */
 	u8 otg_port;			/* 0, or number of OTG/HNP port */
 	unsigned is_b_host:1;		/* true during some HNP roleswitches */
 	unsigned b_hnp_enable:1;	/* OTG: did A-Host enable HNP? */
Index: kernel-omap4-base/drivers/usb/musb/musb_core.c
===================================================================
--- kernel-omap4-base.orig/drivers/usb/musb/musb_core.c	2010-08-04 14:57:04.121928264 +0530
+++ kernel-omap4-base/drivers/usb/musb/musb_core.c	2010-08-04 14:57:26.642178087 +0530
@@ -2107,12 +2107,15 @@
 	 * Otherwise, wait till the gadget driver hooks up.
 	 */
 	if (!is_otg_enabled(musb) && is_host_enabled(musb)) {
+		struct usb_hcd	*hcd = musb_to_hcd(musb);
+
 		MUSB_HST_MODE(musb);
 		musb->xceiv->default_a = 1;
 		musb->xceiv->state = OTG_STATE_A_IDLE;
 
 		status = usb_add_hcd(musb_to_hcd(musb), -1, 0);
 
+		hcd->self.uses_pio_for_control = 1;
 		DBG(1, "%s mode, status %d, devctl %02x %c\n",
 			"HOST", status,
 			musb_readb(musb->mregs, MUSB_DEVCTL),
Index: kernel-omap4-base/drivers/usb/musb/musb_gadget.c
===================================================================
--- kernel-omap4-base.orig/drivers/usb/musb/musb_gadget.c	2010-08-04 14:57:04.113928462 +0530
+++ kernel-omap4-base/drivers/usb/musb/musb_gadget.c	2010-08-04 14:57:26.642178087 +0530
@@ -1763,6 +1763,8 @@
 		spin_unlock_irqrestore(&musb->lock, flags);
 
 		if (is_otg_enabled(musb)) {
+			struct usb_hcd	*hcd = musb_to_hcd(musb);
+
 			DBG(3, "OTG startup...\n");
 
 			/* REVISIT:  funcall to other code, which also
@@ -1832,6 +1834,8 @@
 				musb->gadget_driver = NULL;
 				musb->g.dev.driver = NULL;
 				spin_unlock_irqrestore(&musb->lock, flags);
+			} else {
+				hcd->self.uses_pio_for_control = 1;
 			}
 		}
 	}
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux