mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: stable-review@kernel.org, torvalds@linux-foundation.org,
	akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk,
	Sarah Sharp <sarah.a.sharp@linux.intel.com>
Subject: [03/26] xhci: Dont submit commands or URBs to halted hosts.
Date: Mon, 15 Aug 2011 19:42:46 -0700	[thread overview]
Message-ID: <20110816024452.646040388@pistachio.kroah.org> (raw)
In-Reply-To: <20110816024553.GA5631@kroah.com>

3.0-stable review patch.  If anyone has any objections, please let us know.

------------------

From: Sarah Sharp <sarah.a.sharp@linux.intel.com>

commit 7bd89b4017f46a9b92853940fd9771319acb578a upstream.

Commit fccf4e86200b8f5edd9a65da26f150e32ba79808
"USB: Free bandwidth when usb_disable_device is called" caused a bit of an
issue when the xHCI host controller driver is unloaded.  It changed the
USB core to remove all endpoints when a USB device is disabled.  When the
driver is unloaded, it will remove the SuperSpeed split root hub, which
will disable all devices under that roothub and then halt the host
controller.  When the second High Speed split roothub is removed, the USB
core will attempt to disable the endpoints, which will submit a Configure
Endpoint command to a halted host controller.

The command will eventually time out, but it makes the xHCI driver unload
take *minutes* if there are a couple of USB 1.1/2.0 devices attached.  We
must halt the host controller when the SuperSpeed roothub is removed,
because we can't allow any interrupts from things like port status
changes.

Make several different functions not submit commands or URBs to the host
controller when the host is halted, by adding a check in
xhci_check_args().  xhci_check_args() is used by these functions:

xhci.c-int xhci_urb_enqueue()
xhci.c-int xhci_drop_endpoint()
xhci.c-int xhci_add_endpoint()
xhci.c-int xhci_check_bandwidth()
xhci.c-void xhci_reset_bandwidth()
xhci.c-static int xhci_check_streams_endpoint()
xhci.c-int xhci_discover_or_reset_device()

It's also used by xhci_free_dev().  However, we have to take special
care in that case, because we want the device memory to be freed if the
host controller is halted.

This patch should be backported to the 2.6.39 and 3.0 kernel.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 drivers/usb/host/xhci.c |   19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -345,7 +345,8 @@ static void xhci_event_ring_work(unsigne
 	spin_lock_irqsave(&xhci->lock, flags);
 	temp = xhci_readl(xhci, &xhci->op_regs->status);
 	xhci_dbg(xhci, "op reg status = 0x%x\n", temp);
-	if (temp == 0xffffffff || (xhci->xhc_state & XHCI_STATE_DYING)) {
+	if (temp == 0xffffffff || (xhci->xhc_state & XHCI_STATE_DYING) ||
+			(xhci->xhc_state & XHCI_STATE_HALTED)) {
 		xhci_dbg(xhci, "HW died, polling stopped.\n");
 		spin_unlock_irqrestore(&xhci->lock, flags);
 		return;
@@ -939,8 +940,11 @@ static int xhci_check_args(struct usb_hc
 		return 0;
 	}
 
+	xhci = hcd_to_xhci(hcd);
+	if (xhci->xhc_state & XHCI_STATE_HALTED)
+		return -ENODEV;
+
 	if (check_virt_dev) {
-		xhci = hcd_to_xhci(hcd);
 		if (!udev->slot_id || !xhci->devs
 			|| !xhci->devs[udev->slot_id]) {
 			printk(KERN_DEBUG "xHCI %s called with unaddressed "
@@ -1242,7 +1246,8 @@ int xhci_urb_dequeue(struct usb_hcd *hcd
 		xhci_urb_free_priv(xhci, urb_priv);
 		return ret;
 	}
-	if (xhci->xhc_state & XHCI_STATE_DYING) {
+	if ((xhci->xhc_state & XHCI_STATE_DYING) ||
+			(xhci->xhc_state & XHCI_STATE_HALTED)) {
 		xhci_dbg(xhci, "Ep 0x%x: URB %p to be canceled on "
 				"non-responsive xHCI host.\n",
 				urb->ep->desc.bEndpointAddress, urb);
@@ -2667,7 +2672,10 @@ void xhci_free_dev(struct usb_hcd *hcd,
 	int i, ret;
 
 	ret = xhci_check_args(hcd, udev, NULL, 0, true, __func__);
-	if (ret <= 0)
+	/* If the host is halted due to driver unload, we still need to free the
+	 * device.
+	 */
+	if (ret <= 0 && ret != -ENODEV)
 		return;
 
 	virt_dev = xhci->devs[udev->slot_id];
@@ -2681,7 +2689,8 @@ void xhci_free_dev(struct usb_hcd *hcd,
 	spin_lock_irqsave(&xhci->lock, flags);
 	/* Don't disable the slot if the host controller is dead. */
 	state = xhci_readl(xhci, &xhci->op_regs->status);
-	if (state == 0xffffffff || (xhci->xhc_state & XHCI_STATE_DYING)) {
+	if (state == 0xffffffff || (xhci->xhc_state & XHCI_STATE_DYING) ||
+			(xhci->xhc_state & XHCI_STATE_HALTED)) {
 		xhci_free_virt_device(xhci, udev->slot_id);
 		spin_unlock_irqrestore(&xhci->lock, flags);
 		return;



  parent reply	other threads:[~2011-08-16  2:52 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-16  2:45 [00/26] 3.0.3-stable review Greg KH
2011-08-16  2:42 ` [01/26] staging: rtl8192u: declare MODULE_FIRMWARE Greg KH
2011-08-16  2:42 ` [02/26] USB: xhci: fix OS want to own HC Greg KH
2011-08-16  2:42 ` Greg KH [this message]
2011-08-16  2:42 ` [04/26] usb/config: use proper endian access for wMaxPacketSize Greg KH
2011-08-16  2:42 ` [05/26] usb: musb: fix oops on musb_gadget_pullup Greg KH
2011-08-16  2:42 ` [06/26] USB: assign instead of equal in usbtmc.c Greg KH
2011-08-16  2:42 ` [07/26] USB: ftdi_sio: fix minor typo in get_ftdi_divisor Greg KH
2011-08-16  2:42 ` [08/26] USB: usb-storage: unusual_devs entry for ARM V2M Greg KH
2011-08-16  2:42 ` [09/26] USB: Serial: Added device ID for Qualcomm Modem in Greg KH
2011-08-16  2:42 ` [10/26] USB: option driver: add PID for Vodafone-Huawei K3770 Greg KH
2011-08-16  2:42 ` [11/26] USB: option driver: add PID for Vodafone-Huawei K3771 Greg KH
2011-08-16  2:42 ` [12/26] USB: option driver: add PID for Vodafone-Huawei K4510 Greg KH
2011-08-16  2:42 ` [13/26] USB: option driver: add PID for Vodafone-Huawei K4511 Greg KH
2011-08-16  2:42 ` [14/26] atm: br2864: sent packets truncated in VC routed mode Greg KH
2011-08-16  2:42 ` [15/26] hwmon: (ibmaem) add missing kfree Greg KH
2011-08-16  2:42 ` [16/26] ALSA: snd-usb-caiaq: Correct offset fields of outbound iso_frame_desc Greg KH
2011-08-16  2:43 ` [17/26] ASoC: Fix binding of WM8750 on Jive Greg KH
2011-08-16  2:43 ` [18/26] ASoC: Tegra: tegra_pcm_deallocate_dma_buffer: Dont OOPS Greg KH
2011-08-16  2:43 ` [19/26] ASoC: Tegra: wm8903 machine driver: Allow re-insertion of Greg KH
2011-08-16  2:43 ` [20/26] ath5k: fix error handling in ath5k_beacon_send Greg KH
2011-08-16  2:43 ` [21/26] mm: fix wrong vmap address calculations with odd NR_CPUS values Greg KH
2011-08-16  2:43 ` [22/26] lguest: allow booting guest with CONFIG_RELOCATABLE=y Greg KH
2011-08-16  2:43 ` [23/26] drm/radeon/kms: dont enable connectors that are off in the Greg KH
2011-08-16  2:43 ` [24/26] drm/radeon/kms: fix regression is handling >2 heads on Greg KH
2011-08-16  2:43 ` [25/26] drm/radeon/kms: dont try to be smart in the hpd handler Greg KH
2011-08-16  2:43 ` [26/26] perf tools: do not look at ./config for configuration Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110816024452.646040388@pistachio.kroah.org \
    --to=gregkh@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sarah.a.sharp@linux.intel.com \
    --cc=stable-review@kernel.org \
    --cc=stable@kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®