All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dma-mapping: skip USB devices when configuring DMA during probe
@ 2017-08-03 10:05 Johan Hovold
  2017-08-03 11:50 ` Robin Murphy
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Johan Hovold @ 2017-08-03 10:05 UTC (permalink / raw)
  To: Christoph Hellwig, Marek Szyprowski, Greg Kroah-Hartman
  Cc: Andreas Färber, linux-usb, linux-kernel, linux-rpi-kernel,
	Johan Hovold, stable, Robin Murphy, Sricharan R, Stefan Wahren

USB devices use the DMA mask and offset of the controller, which have
already been setup when a device is probed. Note that modifying the mask
of a USB device would change the mask for the controller (and all
devices on the bus) as the mask is literally shared.

Since commit 2bf698671205 ("USB: of: fix root-hub device-tree node
handling"), of_dma_configure() would be called also for root hubs, which
use the device node of the controller. A separate bug that makes
of_dma_configure() generate a 30-bit DMA mask from the RPI3's
"dma-ranges" would thus set a broken mask also for the controller. This
in turn leads to USB devices failing to enumerate when control transfers
fail:

	dwc2 3f980000.usb: Cannot do DMA to address 0x000000003a166a00

Fix this, and similar future problems, by simply skipping USB devices
when dma_configure() is called during probe.

Fixes: 09515ef5ddad ("of/acpi: Configure dma operations at probe time for platform/amba/pci bus devices")
Cc: stable <stable@vger.kernel.org>	# 4.12
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Sricharan R <sricharan@codeaurora.org>
Cc: Stefan Wahren <stefan.wahren@i2se.com>
Reported-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/base/dma-mapping.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
index b555ff9dd8fc..c6cde7e79599 100644
--- a/drivers/base/dma-mapping.c
+++ b/drivers/base/dma-mapping.c
@@ -13,6 +13,7 @@
 #include <linux/gfp.h>
 #include <linux/of_device.h>
 #include <linux/slab.h>
+#include <linux/usb.h>
 #include <linux/vmalloc.h>
 
 /*
@@ -345,6 +346,10 @@ int dma_configure(struct device *dev)
 	enum dev_dma_attr attr;
 	int ret = 0;
 
+	/* USB devices share the controller's mask. */
+	if (dev->bus == &usb_bus_type)
+		return 0;
+
 	if (dev_is_pci(dev)) {
 		bridge = pci_get_host_bridge_device(to_pci_dev(dev));
 		dma_dev = bridge;
@@ -369,6 +374,9 @@ int dma_configure(struct device *dev)
 
 void dma_deconfigure(struct device *dev)
 {
+	if (dev->bus == &usb_bus_type)
+		return;
+
 	of_dma_deconfigure(dev);
 	acpi_dma_deconfigure(dev);
 }
-- 
2.13.3

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

end of thread, other threads:[~2017-08-04  7:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-03 10:05 [PATCH] dma-mapping: skip USB devices when configuring DMA during probe Johan Hovold
2017-08-03 11:50 ` Robin Murphy
2017-08-03 12:37   ` Johan Hovold
2017-08-03 19:40 ` kbuild test robot
2017-08-04  7:43   ` Johan Hovold
2017-08-03 19:41 ` kbuild test robot

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.