All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] usb: Allow compilation on platforms where NO_DMA=y
@ 2016-02-15 11:21 Geert Uytterhoeven
  2016-02-15 11:21 ` [PATCH 1/3] usb: core: " Geert Uytterhoeven
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Geert Uytterhoeven @ 2016-02-15 11:21 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

This patch series allows to compile USB on platforms where NO_DMA=y.
I've been using it for quite a while to make allmodconfig/allyesconfig
build for m68k/sun3.

Thanks for your comments!

Geert Uytterhoeven (3):
  usb: core: Allow compilation on platforms where NO_DMA=y
  usb: host: Some host drivers should depend on HAS_DMA
  usb: dwc2: USB_DWC2 should depend on HAS_DMA

 drivers/usb/core/buffer.c | 18 ++++++++++++------
 drivers/usb/core/hcd.c    | 14 ++++++++++----
 drivers/usb/dwc2/Kconfig  |  1 +
 drivers/usb/host/Kconfig  |  5 ++++-
 4 files changed, 27 insertions(+), 11 deletions(-)

-- 
1.9.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds


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

* [PATCH 1/3] usb: core: Allow compilation on platforms where NO_DMA=y
  2016-02-15 11:21 [PATCH 0/3] usb: Allow compilation on platforms where NO_DMA=y Geert Uytterhoeven
@ 2016-02-15 11:21 ` Geert Uytterhoeven
  2016-02-15 11:49   ` Vegard Nossum
  2016-02-15 11:21 ` [PATCH 2/3] usb: host: Some host drivers should depend on HAS_DMA Geert Uytterhoeven
  2016-02-15 11:21 ` [PATCH 3/3] usb: dwc2: USB_DWC2 " Geert Uytterhoeven
  2 siblings, 1 reply; 9+ messages in thread
From: Geert Uytterhoeven @ 2016-02-15 11:21 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: "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>
---
 drivers/usb/core/buffer.c | 18 ++++++++++++------
 drivers/usb/core/hcd.c    | 14 ++++++++++----
 2 files changed, 22 insertions(+), 10 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..f6caa7ba6f05655b 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1408,12 +1408,15 @@ 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)
 {
+#ifdef CONFIG_HAS_DMA
 	if (urb->transfer_flags & URB_SETUP_MAP_SINGLE)
 		dma_unmap_single(hcd->self.controller,
 				urb->setup_dma,
 				sizeof(struct usb_ctrlrequest),
 				DMA_TO_DEVICE);
-	else if (urb->transfer_flags & URB_SETUP_MAP_LOCAL)
+	else
+#endif /* CONFIG_HAS_DMA */
+	if (urb->transfer_flags & URB_SETUP_MAP_LOCAL)
 		hcd_free_coherent(urb->dev->bus,
 				&urb->setup_dma,
 				(void **) &urb->setup_packet,
@@ -1440,6 +1443,7 @@ 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;
+#ifdef CONFIG_HAS_DMA
 	if (urb->transfer_flags & URB_DMA_MAP_SG)
 		dma_unmap_sg(hcd->self.controller,
 				urb->sg,
@@ -1455,7 +1459,9 @@ void usb_hcd_unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
 				urb->transfer_dma,
 				urb->transfer_buffer_length,
 				dir);
-	else if (urb->transfer_flags & URB_MAP_LOCAL)
+	else
+#endif /* CONFIG_HAS_DMA */
+	if (urb->transfer_flags & URB_MAP_LOCAL)
 		hcd_free_coherent(urb->dev->bus,
 				&urb->transfer_dma,
 				&urb->transfer_buffer,
@@ -1492,7 +1498,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 +1524,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] 9+ messages in thread

* [PATCH 2/3] usb: host: Some host drivers should depend on HAS_DMA
  2016-02-15 11:21 [PATCH 0/3] usb: Allow compilation on platforms where NO_DMA=y Geert Uytterhoeven
  2016-02-15 11:21 ` [PATCH 1/3] usb: core: " Geert Uytterhoeven
@ 2016-02-15 11:21 ` Geert Uytterhoeven
  2016-02-15 11:21 ` [PATCH 3/3] usb: dwc2: USB_DWC2 " Geert Uytterhoeven
  2 siblings, 0 replies; 9+ messages in thread
From: Geert Uytterhoeven @ 2016-02-15 11:21 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>
---
 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] 9+ messages in thread

* [PATCH 3/3] usb: dwc2: USB_DWC2 should depend on HAS_DMA
  2016-02-15 11:21 [PATCH 0/3] usb: Allow compilation on platforms where NO_DMA=y Geert Uytterhoeven
  2016-02-15 11:21 ` [PATCH 1/3] usb: core: " Geert Uytterhoeven
  2016-02-15 11:21 ` [PATCH 2/3] usb: host: Some host drivers should depend on HAS_DMA Geert Uytterhoeven
@ 2016-02-15 11:21 ` Geert Uytterhoeven
  2016-02-15 23:21   ` John Youn
  2 siblings, 1 reply; 9+ messages in thread
From: Geert Uytterhoeven @ 2016-02-15 11:21 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>
---
 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] 9+ messages in thread

* Re: [PATCH 1/3] usb: core: Allow compilation on platforms where NO_DMA=y
  2016-02-15 11:21 ` [PATCH 1/3] usb: core: " Geert Uytterhoeven
@ 2016-02-15 11:49   ` Vegard Nossum
  2016-02-15 12:28     ` Geert Uytterhoeven
  0 siblings, 1 reply; 9+ messages in thread
From: Vegard Nossum @ 2016-02-15 11:49 UTC (permalink / raw)
  To: Geert Uytterhoeven, Greg Kroah-Hartman
  Cc: John Youn, Richard Weinberger, James McMechan, Alan Stern,
	Martin Schwidefsky, linux-usb, uml-devel

On 02/15/2016 12:21 PM, Geert Uytterhoeven wrote:
> 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>
> ---
>   drivers/usb/core/buffer.c | 18 ++++++++++++------
>   drivers/usb/core/hcd.c    | 14 ++++++++++----
>   2 files changed, 22 insertions(+), 10 deletions(-)
>

This does look nicer than my patch.

> 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..f6caa7ba6f05655b 100644
> --- a/drivers/usb/core/hcd.c
> +++ b/drivers/usb/core/hcd.c
> @@ -1408,12 +1408,15 @@ 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)
>   {
> +#ifdef CONFIG_HAS_DMA
>   	if (urb->transfer_flags & URB_SETUP_MAP_SINGLE)
>   		dma_unmap_single(hcd->self.controller,
>   				urb->setup_dma,
>   				sizeof(struct usb_ctrlrequest),
>   				DMA_TO_DEVICE);
> -	else if (urb->transfer_flags & URB_SETUP_MAP_LOCAL)
> +	else
> +#endif /* CONFIG_HAS_DMA */
> +	if (urb->transfer_flags & URB_SETUP_MAP_LOCAL)

Why not use IS_ENABLED() here as well instead of the ifdef?

>   		hcd_free_coherent(urb->dev->bus,
>   				&urb->setup_dma,
>   				(void **) &urb->setup_packet,
> @@ -1440,6 +1443,7 @@ 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;
> +#ifdef CONFIG_HAS_DMA
>   	if (urb->transfer_flags & URB_DMA_MAP_SG)
>   		dma_unmap_sg(hcd->self.controller,
>   				urb->sg,
> @@ -1455,7 +1459,9 @@ void usb_hcd_unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
>   				urb->transfer_dma,
>   				urb->transfer_buffer_length,
>   				dir);
> -	else if (urb->transfer_flags & URB_MAP_LOCAL)
> +	else
> +#endif /* CONFIG_HAS_DMA */
> +	if (urb->transfer_flags & URB_MAP_LOCAL)

and here.

>   		hcd_free_coherent(urb->dev->bus,
>   				&urb->transfer_dma,
>   				&urb->transfer_buffer,
> @@ -1492,7 +1498,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 +1524,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;
>
>

Assuming this still lets the platform actually run USB drivers (which it
looks like it does -- I still have to test it), then I'm all for it. You
may want to steal parts of the commit description for my last patch to
include that this actually allows using USB on UML and the references to
the discussion.

Thanks!


Vegard


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

* Re: [PATCH 1/3] usb: core: Allow compilation on platforms where NO_DMA=y
  2016-02-15 11:49   ` Vegard Nossum
@ 2016-02-15 12:28     ` Geert Uytterhoeven
  2016-02-15 20:38       ` Vegard Nossum
  0 siblings, 1 reply; 9+ messages in thread
From: Geert Uytterhoeven @ 2016-02-15 12:28 UTC (permalink / raw)
  To: Vegard Nossum
  Cc: Greg Kroah-Hartman, John Youn, Richard Weinberger,
	James McMechan, Alan Stern, Martin Schwidefsky, USB list,
	uml-devel

Hi Vegard,

On Mon, Feb 15, 2016 at 12:49 PM, Vegard Nossum
<vegard.nossum@oracle.com> wrote:
> On 02/15/2016 12:21 PM, Geert Uytterhoeven wrote:
>> 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>
>> ---
>>   drivers/usb/core/buffer.c | 18 ++++++++++++------
>>   drivers/usb/core/hcd.c    | 14 ++++++++++----
>>   2 files changed, 22 insertions(+), 10 deletions(-)
>>
>
> This does look nicer than my patch.

I'm happy you like it ;-)

>> --- a/drivers/usb/core/hcd.c
>> +++ b/drivers/usb/core/hcd.c
>> @@ -1408,12 +1408,15 @@ 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)
>>   {
>> +#ifdef CONFIG_HAS_DMA
>>         if (urb->transfer_flags & URB_SETUP_MAP_SINGLE)
>>                 dma_unmap_single(hcd->self.controller,
>>                                 urb->setup_dma,
>>                                 sizeof(struct usb_ctrlrequest),
>>                                 DMA_TO_DEVICE);
>> -       else if (urb->transfer_flags & URB_SETUP_MAP_LOCAL)
>> +       else
>> +#endif /* CONFIG_HAS_DMA */
>> +       if (urb->transfer_flags & URB_SETUP_MAP_LOCAL)
>
>
> Why not use IS_ENABLED() here as well instead of the ifdef?

This used to be needed, else the calls to e.g. dma_unmap_single() would
still cause link errors.

This no longer seems to be the case (I told you this was a patch set I started
a while ago ;-), probably due to the recent dma_map_ops conversion.
Will update.

> Assuming this still lets the platform actually run USB drivers (which it
> looks like it does -- I still have to test it), then I'm all for it. You

Please give it a try and let me know, as I'm not in a position to test-run
this on Sun-3.

> may want to steal parts of the commit description for my last patch to
> include that this actually allows using USB on UML and the references to
> the discussion.

Thanks, will do!

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds


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

* Re: [PATCH 1/3] usb: core: Allow compilation on platforms where NO_DMA=y
  2016-02-15 12:28     ` Geert Uytterhoeven
@ 2016-02-15 20:38       ` Vegard Nossum
  2016-02-16 12:35         ` Vegard Nossum
  0 siblings, 1 reply; 9+ messages in thread
From: Vegard Nossum @ 2016-02-15 20:38 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Greg Kroah-Hartman, John Youn, Richard Weinberger,
	James McMechan, Alan Stern, Martin Schwidefsky, USB list,
	uml-devel

On 02/15/2016 01:28 PM, Geert Uytterhoeven wrote:
> On Mon, Feb 15, 2016 at 12:49 PM, Vegard Nossum
> <vegard.nossum@oracle.com> wrote:
>> On 02/15/2016 12:21 PM, Geert Uytterhoeven wrote:
>>> 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>
>>> ---
>>>    drivers/usb/core/buffer.c | 18 ++++++++++++------
>>>    drivers/usb/core/hcd.c    | 14 ++++++++++----
>>>    2 files changed, 22 insertions(+), 10 deletions(-)
>>>
[...]

>> Assuming this still lets the platform actually run USB drivers (which it
>> looks like it does -- I still have to test it), then I'm all for it. You
>
> Please give it a try and let me know, as I'm not in a position to test-run
> this on Sun-3.

Hrm, I can't quite get usb-over-ip working, I get this in the UML guest
when trying to attach the host device:

# usbip -d attach -r 192.168.0.20 -b 2-1
usbip: debug: usbip.c:141:[run_command] running command: `attach'
libusbip: debug: vhci_driver.c:242:[usbip_vhci_driver_open] available 
ports: 7
libusbip: debug: vhci_driver.c:71:[parse_status] port 0 status 4 speed 0 
devid 0
libusbip: debug: vhci_driver.c:72:[parse_status] socket 0 lbusid 
0000000000000000
libusbip: debug: vhci_driver.c:71:[parse_status] port 1 status 4 speed 0 
devid 0
libusbip: debug: vhci_driver.c:72:[parse_status] socket 0 lbusid 
0000000000000000
libusbip: debug: vhci_driver.c:71:[parse_status] port 2 status 4 speed 0 
devid 0
libusbip: debug: vhci_driver.c:72:[parse_status] socket 0 lbusid 
0000000000000000
libusbip: debug: vhci_driver.c:71:[parse_status] port 3 status 4 speed 0 
devid 0
libusbip: debug: vhci_driver.c:72:[parse_status] socket 0 lbusid 
0000000000000000
libusbip: debug: vhci_driver.c:71:[parse_status] port 4 status 4 speed 0 
devid 0
libusbip: debug: vhci_driver.c:72:[parse_status] socket 0 lbusid 
0000000000000000
libusbip: debug: vhci_driver.c:71:[parse_status] port 5 status 4 speed 0 
devid 0
libusbip: debug: vhci_driver.c:72:[parse_status] socket 0 lbusid 
0000000000000000
libusbip: debug: vhci_driver.c:71:[parse_status] port 6 status 4 speed 0 
devid 0
libusbip: debug: vhci_driver.c:72:[parse_status] socket 0 lbusid 
0000000000000000
libusbip: debug: vhci_driver.c:71:[parse_status] port 7 status 4 speed 0 
devid 0
libusbip: debug: vhci_driver.c:72:[parse_status] socket 0 lbusid 
0000000000000000
libusbip: debug: vhci_driver.c:105:[parse_status] exit
libusbip: debug: vhci_driver.c:311:[usbip_vhci_attach_device2] writing: 
0 3 131074 5
libusbip: debug: vhci_driver.c:316:[usbip_vhci_attach_device2] attach 
attribute path: /sys/devices/platform/vhci_hcd/attach
vhci_hcd: Failed attach request for unsupported USB speed: super-speed
usbip: debug: sysfs_utils.c:23:[write_sysfs_attribute] error writing to 
attribute /sys/devices/platform/vhci_hcd/attach
libusbip: debug: vhci_driver.c:320:[usbip_vhci_attach_device2] 
write_sysfs_attribute failed
usbip: error: import device
usbip: error: query

That said, I haven't tried if it works with my patches either, so it
might be something else.

I'll dive into it tomorrow.


Vegard


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

* Re: [PATCH 3/3] usb: dwc2: USB_DWC2 should depend on HAS_DMA
  2016-02-15 11:21 ` [PATCH 3/3] usb: dwc2: USB_DWC2 " Geert Uytterhoeven
@ 2016-02-15 23:21   ` John Youn
  0 siblings, 0 replies; 9+ messages in thread
From: John Youn @ 2016-02-15 23:21 UTC (permalink / raw)
  To: Geert Uytterhoeven, Greg Kroah-Hartman, Vegard Nossum
  Cc: John Youn, Richard Weinberger, James McMechan, Alan Stern,
	Martin Schwidefsky, linux-usb, uml-devel

On 2/15/2016 3:21 AM, Geert Uytterhoeven wrote:
> 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>
> ---
>  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
> 


Acked-by: John Youn <johnyoun@synopsys.com>





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

* Re: [PATCH 1/3] usb: core: Allow compilation on platforms where NO_DMA=y
  2016-02-15 20:38       ` Vegard Nossum
@ 2016-02-16 12:35         ` Vegard Nossum
  0 siblings, 0 replies; 9+ messages in thread
From: Vegard Nossum @ 2016-02-16 12:35 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Greg Kroah-Hartman, John Youn, Richard Weinberger,
	James McMechan, Alan Stern, Martin Schwidefsky, USB list,
	uml-devel

On 02/15/2016 09:38 PM, Vegard Nossum wrote:
> On 02/15/2016 01:28 PM, Geert Uytterhoeven wrote:
>> On Mon, Feb 15, 2016 at 12:49 PM, Vegard Nossum
>> <vegard.nossum@oracle.com> wrote:
>>> On 02/15/2016 12:21 PM, Geert Uytterhoeven wrote:

[...]

>>> Assuming this still lets the platform actually run USB drivers (which it
>>> looks like it does -- I still have to test it), then I'm all for it. You
>>
>> Please give it a try and let me know, as I'm not in a position to
>> test-run
>> this on Sun-3.
>
> Hrm, I can't quite get usb-over-ip working, I get this in the UML guest
> when trying to attach the host device:

[...]

> That said, I haven't tried if it works with my patches either, so it
> might be something else.

Ok, so I managed to get UML to read a USB flash drive plugged into the 
host machine using USB-over-IP:

mconsole (version 2) initialized on /home/vegard/.uml/eaqEV4/mconsole
Checking host MADV_REMOVE support...OK
UML Audio Relay (host dsp = /dev/sound/dsp, host mixer = /dev/sound/mixer)
[...]
vhci_hcd vhci_hcd: rhport(0) sockfd(3) devid(65538) speed(3) 
speed_str(high-speed)
usb 2-1: new high-speed USB device number 2 using vhci_hcd
usb 2-1: new high-speed USB device number 3 using vhci_hcd
usb 2-1: new high-speed USB device number 4 using vhci_hcd
usb 2-1: SetAddress Request (4) to port 0
usb 2-1: New USB device found, idVendor=0000, idProduct=0000
usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-1: Product: USB
usb 2-1: Manufacturer: SMI Corporation
usb 2-1: SerialNumber: AA627084901000000298
usb-storage 2-1:1.0: USB Mass Storage device detected
scsi host0: usb-storage 2-1:1.0
scsi 0:0:0:0: Direct-Access     ST       2GB              0000 PQ: 0 
ANSI: 0 CCS
sd 0:0:0:0: Attached scsi generic sg0 type 0
sd 0:0:0:0: [sda] 3915776 512-byte logical blocks: (2.00 GB/1.87 GiB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Mode Sense: 43 00 00 00
sd 0:0:0:0: [sda] No Caching mode page found
sd 0:0:0:0: [sda] Assuming drive cache: write through
  sda: sda1
sd 0:0:0:0: [sda] Attached SCSI removable disk

This is using your patches (on top of the ones Greg already took), so
feel free to add

     Acked-by: Vegard Nossum <vegard.nossum@oracle.com>

If you post the new version of your patch I can test that too :-)

Thanks,


Vegard


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

end of thread, other threads:[~2016-02-16 12:35 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-15 11:21 [PATCH 0/3] usb: Allow compilation on platforms where NO_DMA=y Geert Uytterhoeven
2016-02-15 11:21 ` [PATCH 1/3] usb: core: " Geert Uytterhoeven
2016-02-15 11:49   ` Vegard Nossum
2016-02-15 12:28     ` Geert Uytterhoeven
2016-02-15 20:38       ` Vegard Nossum
2016-02-16 12:35         ` Vegard Nossum
2016-02-15 11:21 ` [PATCH 2/3] usb: host: Some host drivers should depend on HAS_DMA Geert Uytterhoeven
2016-02-15 11:21 ` [PATCH 3/3] usb: dwc2: USB_DWC2 " Geert Uytterhoeven
2016-02-15 23:21   ` John Youn

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.