* [PATCH v2 1/3] usb: core: Allow compilation on platforms where NO_DMA=y
2016-02-16 15:10 [PATCH v2 0/3] usb: Allow compilation on platforms where NO_DMA=y Geert Uytterhoeven
@ 2016-02-16 15:10 ` Geert Uytterhoeven
2016-02-21 4:23 ` Greg Kroah-Hartman
2016-02-16 15:10 ` [PATCH v2 2/3] usb: host: Host drivers relying on DMA should depend on HAS_DMA Geert Uytterhoeven
2016-02-16 15:10 ` [PATCH v2 3/3] usb: dwc2: USB_DWC2 " Geert Uytterhoeven
2 siblings, 1 reply; 7+ messages in thread
From: Geert Uytterhoeven @ 2016-02-16 15:10 UTC (permalink / raw)
To: Greg Kroah-Hartman, Vegard Nossum
Cc: John Youn, Richard Weinberger, James McMechan, Alan Stern,
Martin Schwidefsky, linux-usb, uml-devel, Geert Uytterhoeven
Some platforms don't have DMA, but we should still be able to build USB
drivers for these platforms. They could still be used through vhci_hcd,
usbip_host, or maybe something like USB passthrough in UML from a
capable host.
If NO_DMA=y:
ERROR: "dma_pool_destroy" [drivers/usb/core/usbcore.ko] undefined!
ERROR: "bad_dma_ops" [drivers/usb/core/usbcore.ko] undefined!
ERROR: "dma_pool_free" [drivers/usb/core/usbcore.ko] undefined!
ERROR: "dma_pool_alloc" [drivers/usb/core/usbcore.ko] undefined!
ERROR: "dma_pool_create" [drivers/usb/core/usbcore.ko] undefined!
Add a few checks for CONFIG_HAS_DMA to fix this.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Vegard Nossum <vegard.nossum@oracle.com>
---
v2:
- Replace remaining #ifdefs by IS_ENABLED() checks,
- Add to patch description that this actually allows using USB on UML,
- Add Acked-by.
---
drivers/usb/core/buffer.c | 18 ++++++++++++------
drivers/usb/core/hcd.c | 16 ++++++++++------
2 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c
index 89f2e7765093955b..2741566ee4f25849 100644
--- a/drivers/usb/core/buffer.c
+++ b/drivers/usb/core/buffer.c
@@ -62,8 +62,9 @@ int hcd_buffer_create(struct usb_hcd *hcd)
char name[16];
int i, size;
- if (!hcd->self.controller->dma_mask &&
- !(hcd->driver->flags & HCD_LOCAL_MEM))
+ if (!IS_ENABLED(CONFIG_HAS_DMA) ||
+ (!hcd->self.controller->dma_mask &&
+ !(hcd->driver->flags & HCD_LOCAL_MEM)))
return 0;
for (i = 0; i < HCD_BUFFER_POOLS; i++) {
@@ -93,6 +94,9 @@ void hcd_buffer_destroy(struct usb_hcd *hcd)
{
int i;
+ if (!IS_ENABLED(CONFIG_HAS_DMA))
+ return;
+
for (i = 0; i < HCD_BUFFER_POOLS; i++) {
struct dma_pool *pool = hcd->pool[i];
@@ -119,8 +123,9 @@ void *hcd_buffer_alloc(
int i;
/* some USB hosts just use PIO */
- if (!bus->controller->dma_mask &&
- !(hcd->driver->flags & HCD_LOCAL_MEM)) {
+ if (!IS_ENABLED(CONFIG_HAS_DMA) ||
+ (!bus->controller->dma_mask &&
+ !(hcd->driver->flags & HCD_LOCAL_MEM))) {
*dma = ~(dma_addr_t) 0;
return kmalloc(size, mem_flags);
}
@@ -145,8 +150,9 @@ void hcd_buffer_free(
if (!addr)
return;
- if (!bus->controller->dma_mask &&
- !(hcd->driver->flags & HCD_LOCAL_MEM)) {
+ if (!IS_ENABLED(CONFIG_HAS_DMA) ||
+ (!bus->controller->dma_mask &&
+ !(hcd->driver->flags & HCD_LOCAL_MEM))) {
kfree(addr);
return;
}
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index df0e3b92533a745f..b277977cada2b382 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1408,7 +1408,8 @@ static void hcd_free_coherent(struct usb_bus *bus, dma_addr_t *dma_handle,
void usb_hcd_unmap_urb_setup_for_dma(struct usb_hcd *hcd, struct urb *urb)
{
- if (urb->transfer_flags & URB_SETUP_MAP_SINGLE)
+ if (IS_ENABLED(CONFIG_HAS_DMA) &&
+ (urb->transfer_flags & URB_SETUP_MAP_SINGLE))
dma_unmap_single(hcd->self.controller,
urb->setup_dma,
sizeof(struct usb_ctrlrequest),
@@ -1440,17 +1441,20 @@ void usb_hcd_unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
usb_hcd_unmap_urb_setup_for_dma(hcd, urb);
dir = usb_urb_dir_in(urb) ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
- if (urb->transfer_flags & URB_DMA_MAP_SG)
+ if (IS_ENABLED(CONFIG_HAS_DMA) &&
+ (urb->transfer_flags & URB_DMA_MAP_SG))
dma_unmap_sg(hcd->self.controller,
urb->sg,
urb->num_sgs,
dir);
- else if (urb->transfer_flags & URB_DMA_MAP_PAGE)
+ else if (IS_ENABLED(CONFIG_HAS_DMA) &&
+ (urb->transfer_flags & URB_DMA_MAP_PAGE))
dma_unmap_page(hcd->self.controller,
urb->transfer_dma,
urb->transfer_buffer_length,
dir);
- else if (urb->transfer_flags & URB_DMA_MAP_SINGLE)
+ else if (IS_ENABLED(CONFIG_HAS_DMA) &&
+ (urb->transfer_flags & URB_DMA_MAP_SINGLE))
dma_unmap_single(hcd->self.controller,
urb->transfer_dma,
urb->transfer_buffer_length,
@@ -1492,7 +1496,7 @@ int usb_hcd_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb,
if (usb_endpoint_xfer_control(&urb->ep->desc)) {
if (hcd->self.uses_pio_for_control)
return ret;
- if (hcd->self.uses_dma) {
+ if (IS_ENABLED(CONFIG_HAS_DMA) && hcd->self.uses_dma) {
urb->setup_dma = dma_map_single(
hcd->self.controller,
urb->setup_packet,
@@ -1518,7 +1522,7 @@ int usb_hcd_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb,
dir = usb_urb_dir_in(urb) ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
if (urb->transfer_buffer_length != 0
&& !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)) {
- if (hcd->self.uses_dma) {
+ if (IS_ENABLED(CONFIG_HAS_DMA) && hcd->self.uses_dma) {
if (urb->num_sgs) {
int n;
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v2 2/3] usb: host: Host drivers relying on DMA should depend on HAS_DMA
2016-02-16 15:10 [PATCH v2 0/3] usb: Allow compilation on platforms where NO_DMA=y Geert Uytterhoeven
2016-02-16 15:10 ` [PATCH v2 1/3] usb: core: " Geert Uytterhoeven
@ 2016-02-16 15:10 ` Geert Uytterhoeven
2016-02-16 15:10 ` [PATCH v2 3/3] usb: dwc2: USB_DWC2 " Geert Uytterhoeven
2 siblings, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2016-02-16 15:10 UTC (permalink / raw)
To: Greg Kroah-Hartman, Vegard Nossum
Cc: John Youn, Richard Weinberger, James McMechan, Alan Stern,
Martin Schwidefsky, linux-usb, uml-devel, Geert Uytterhoeven
If NO_DMA=y:
ERROR: "bad_dma_ops" [drivers/usb/host/xhci-plat-hcd.ko] undefined!
ERROR: "bad_dma_ops" [drivers/usb/host/xhci-mtk.ko] undefined!
ERROR: "dma_pool_destroy" [drivers/usb/host/xhci-hcd.ko] undefined!
ERROR: "bad_dma_ops" [drivers/usb/host/xhci-hcd.ko] undefined!
ERROR: "dma_pool_free" [drivers/usb/host/xhci-hcd.ko] undefined!
ERROR: "dma_pool_alloc" [drivers/usb/host/xhci-hcd.ko] undefined!
ERROR: "dma_pool_create" [drivers/usb/host/xhci-hcd.ko] undefined!
ERROR: "bad_dma_ops" [drivers/usb/host/ohci-platform.ko] undefined!
ERROR: "dma_pool_destroy" [drivers/usb/host/ohci-hcd.ko] undefined!
ERROR: "bad_dma_ops" [drivers/usb/host/ohci-hcd.ko] undefined!
ERROR: "dma_pool_free" [drivers/usb/host/ohci-hcd.ko] undefined!
ERROR: "dma_pool_alloc" [drivers/usb/host/ohci-hcd.ko] undefined!
ERROR: "dma_pool_create" [drivers/usb/host/ohci-hcd.ko] undefined!
ERROR: "dma_pool_create" [drivers/usb/host/fotg210-hcd.ko] undefined!
ERROR: "bad_dma_ops" [drivers/usb/host/fotg210-hcd.ko] undefined!
ERROR: "dma_pool_destroy" [drivers/usb/host/fotg210-hcd.ko] undefined!
ERROR: "dma_pool_alloc" [drivers/usb/host/fotg210-hcd.ko] undefined!
ERROR: "dma_pool_free" [drivers/usb/host/fotg210-hcd.ko] undefined!
ERROR: "bad_dma_ops" [drivers/usb/host/ehci-platform.ko] undefined!
ERROR: "dma_pool_destroy" [drivers/usb/host/ehci-hcd.ko] undefined!
ERROR: "bad_dma_ops" [drivers/usb/host/ehci-hcd.ko] undefined!
ERROR: "dma_pool_free" [drivers/usb/host/ehci-hcd.ko] undefined!
ERROR: "dma_pool_alloc" [drivers/usb/host/ehci-hcd.ko] undefined!
ERROR: "dma_pool_create" [drivers/usb/host/ehci-hcd.ko] undefined!
Add dependencies on HAS_DMA to fix this.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
v2:
- Reword one-line summary.
---
drivers/usb/host/Kconfig | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 1f117c360ebbba33..573789698474ad8d 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -17,6 +17,7 @@ config USB_C67X00_HCD
config USB_XHCI_HCD
tristate "xHCI HCD (USB 3.0) support"
+ depends on HAS_DMA
---help---
The eXtensible Host Controller Interface (xHCI) is standard for USB 3.0
"SuperSpeed" host controller hardware.
@@ -70,6 +71,7 @@ endif # USB_XHCI_HCD
config USB_EHCI_HCD
tristate "EHCI HCD (USB 2.0) support"
+ depends on HAS_DMA
---help---
The Enhanced Host Controller Interface (EHCI) is standard for USB 2.0
"high speed" (480 Mbit/sec, 60 Mbyte/sec) host controller hardware.
@@ -361,7 +363,7 @@ config USB_ISP1362_HCD
config USB_FOTG210_HCD
tristate "FOTG210 HCD support"
- depends on USB
+ depends on USB && HAS_DMA
---help---
Faraday FOTG210 is an OTG controller which can be configured as
an USB2.0 host. It is designed to meet USB2.0 EHCI specification
@@ -383,6 +385,7 @@ config USB_MAX3421_HCD
config USB_OHCI_HCD
tristate "OHCI HCD (USB 1.1) support"
+ depends on HAS_DMA
---help---
The Open Host Controller Interface (OHCI) is a standard for accessing
USB 1.1 host controller hardware. It does more in hardware than Intel's
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v2 3/3] usb: dwc2: USB_DWC2 should depend on HAS_DMA
2016-02-16 15:10 [PATCH v2 0/3] usb: Allow compilation on platforms where NO_DMA=y Geert Uytterhoeven
2016-02-16 15:10 ` [PATCH v2 1/3] usb: core: " Geert Uytterhoeven
2016-02-16 15:10 ` [PATCH v2 2/3] usb: host: Host drivers relying on DMA should depend on HAS_DMA Geert Uytterhoeven
@ 2016-02-16 15:10 ` Geert Uytterhoeven
2 siblings, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2016-02-16 15:10 UTC (permalink / raw)
To: Greg Kroah-Hartman, Vegard Nossum
Cc: John Youn, Richard Weinberger, James McMechan, Alan Stern,
Martin Schwidefsky, linux-usb, uml-devel, Geert Uytterhoeven
If NO_DMA=y:
ERROR: "usb_gadget_map_request" [drivers/usb/dwc2/dwc2.ko] undefined!
ERROR: "usb_gadget_unmap_request" [drivers/usb/dwc2/dwc2.ko] undefined!
ERROR: "bad_dma_ops" [drivers/usb/dwc2/dwc2.ko] undefined!
Add a dependency on HAS_DMA to fix this.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: John Youn <johnyoun@synopsys.com>
---
v2:
- Add Acked-by.
---
drivers/usb/dwc2/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/usb/dwc2/Kconfig b/drivers/usb/dwc2/Kconfig
index fd95ba6ec317fdac..f0decc0d69b5197d 100644
--- a/drivers/usb/dwc2/Kconfig
+++ b/drivers/usb/dwc2/Kconfig
@@ -1,5 +1,6 @@
config USB_DWC2
tristate "DesignWare USB2 DRD Core Support"
+ depends on HAS_DMA
depends on USB || USB_GADGET
help
Say Y here if your system has a Dual Role Hi-Speed USB
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread