LKML Archive on
help / color / mirror / Atom feed
* [PATCH] usb: dwc2: avoid leaking DMA channels on disconnection
@ 2015-03-14  0:01 Vincent Palatin
  0 siblings, 0 replies; only message in thread
From: Vincent Palatin @ 2015-03-14  0:01 UTC (permalink / raw)
  To: linux-usb, LKML
  Cc: Doug Anderson, Julius Werner, Yunzhi Li, Greg Kroah-Hartman,
	John Youn, Vincent Palatin

When the HCD is disconnected, the DMA transfers still in-flight were cleaned-up
but the count of available DMA channels (e.g. available_host_channels) was not
The pool of DMA channels can be depleted when doing unclean
disconnection of USB peripherals, and reaches the point where no
transfer was possible until the next reboot/reload of the driver.

Tested by putting a programmable USB mux on the port and randomly
plugging/unpluging a USB HUB with USB mass-storage key, USB-audio and
USB-ethernet dongle connected to its downstream ports, and also doing the
disconnection early while the devices are still enumerating to get more URBs
After the patch, the devices are still enumerating after thousands of cycles,
while the port was totally dead before.

Signed-off-by: Vincent Palatin <>
 drivers/usb/dwc2/hcd.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index c78c874..559b55e 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -257,6 +257,14 @@ static void dwc2_hcd_cleanup_channels(struct dwc2_hsotg *hsotg)
 		channel->qh = NULL;
+	/* All channels have been freed, mark them available */
+	if (hsotg->core_params->uframe_sched > 0) {
+		hsotg->available_host_channels =
+			hsotg->core_params->host_channels;
+	} else {
+		hsotg->non_periodic_channels = 0;
+		hsotg->periodic_channels = 0;
+	}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-03-16  9:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-14  0:01 [PATCH] usb: dwc2: avoid leaking DMA channels on disconnection Vincent Palatin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).