All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: torvalds@linux-foundation.org, akpm@linux-foundation.org,
	alan@lxorguk.ukuu.org.uk, Andiry Xu <andiry.xu@amd.com>,
	Sarah Sharp <sarah.a.sharp@linux.intel.com>,
	Alan Stern <stern@rowland.harvard.edu>
Subject: [ 57/91] xHCI: keep track of ports being resumed and indicate in hub_status_data
Date: Sun, 27 May 2012 09:26:03 +0900	[thread overview]
Message-ID: <20120527002519.381690179@linuxfoundation.org> (raw)
In-Reply-To: <20120527010903.GA18244@kroah.com>

3.4-stable review patch.  If anyone has any objections, please let me know.

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

From: Andiry Xu <andiry.xu@amd.com>

commit f370b9968a220a3d79d870dd7dee674cc0ff3d10 upstream.

This commit adds a bit-array to xhci bus_state for keeping track of
which ports are undergoing a resume transition. If any of the bits
are set when xhci_hub_status_data() is called, the routine will return
a non-zero value even if no ports have any status changes pending.
This will allow usbcore to handle races between root-hub suspend and
port wakeup.

This patch should be backported to kernels as old as 3.4, that contain
the commit 879d38e6bc36d73b0ac40ec9b0d839fda9fa8b1a "USB: fix race
between root-hub suspend and remote wakeup".

Signed-off-by: Andiry Xu <andiry.xu@amd.com>
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/host/xhci-hub.c  |   22 ++++++++++++----------
 drivers/usb/host/xhci-ring.c |    1 +
 drivers/usb/host/xhci.c      |   12 ++++++++++--
 drivers/usb/host/xhci.h      |    2 ++
 4 files changed, 25 insertions(+), 12 deletions(-)

--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -558,6 +558,7 @@ int xhci_hub_control(struct usb_hcd *hcd
 				xhci_dbg(xhci, "Resume USB2 port %d\n",
 					wIndex + 1);
 				bus_state->resume_done[wIndex] = 0;
+				clear_bit(wIndex, &bus_state->resuming_ports);
 				xhci_set_link_state(xhci, port_array, wIndex,
 							XDEV_U0);
 				xhci_dbg(xhci, "set port %d resume\n",
@@ -845,7 +846,12 @@ int xhci_hub_status_data(struct usb_hcd
 	/* Initial status is no changes */
 	retval = (max_ports + 8) / 8;
 	memset(buf, 0, retval);
-	status = 0;
+
+	/*
+	 * Inform the usbcore about resume-in-progress by returning
+	 * a non-zero value even if there are no status changes.
+	 */
+	status = bus_state->resuming_ports;
 
 	mask = PORT_CSC | PORT_PEC | PORT_OCC | PORT_PLC | PORT_WRC;
 
@@ -885,15 +891,11 @@ int xhci_bus_suspend(struct usb_hcd *hcd
 	spin_lock_irqsave(&xhci->lock, flags);
 
 	if (hcd->self.root_hub->do_remote_wakeup) {
-		port_index = max_ports;
-		while (port_index--) {
-			if (bus_state->resume_done[port_index] != 0) {
-				spin_unlock_irqrestore(&xhci->lock, flags);
-				xhci_dbg(xhci, "suspend failed because "
-						"port %d is resuming\n",
-						port_index + 1);
-				return -EBUSY;
-			}
+		if (bus_state->resuming_ports) {
+			spin_unlock_irqrestore(&xhci->lock, flags);
+			xhci_dbg(xhci, "suspend failed because "
+						"a port is resuming\n");
+			return -EBUSY;
 		}
 	}
 
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1377,6 +1377,7 @@ static void handle_port_status(struct xh
 			xhci_dbg(xhci, "resume HS port %d\n", port_id);
 			bus_state->resume_done[faked_port_index] = jiffies +
 				msecs_to_jiffies(20);
+			set_bit(faked_port_index, &bus_state->resuming_ports);
 			mod_timer(&hcd->rh_timer,
 				  bus_state->resume_done[faked_port_index]);
 			/* Do the rest in GetPortStatus */
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -152,7 +152,7 @@ int xhci_reset(struct xhci_hcd *xhci)
 {
 	u32 command;
 	u32 state;
-	int ret;
+	int ret, i;
 
 	state = xhci_readl(xhci, &xhci->op_regs->status);
 	if ((state & STS_HALT) == 0) {
@@ -175,7 +175,15 @@ int xhci_reset(struct xhci_hcd *xhci)
 	 * xHCI cannot write to any doorbells or operational registers other
 	 * than status until the "Controller Not Ready" flag is cleared.
 	 */
-	return handshake(xhci, &xhci->op_regs->status, STS_CNR, 0, 250 * 1000);
+	ret = handshake(xhci, &xhci->op_regs->status, STS_CNR, 0, 250 * 1000);
+
+	for (i = 0; i < 2; ++i) {
+		xhci->bus_state[i].port_c_suspend = 0;
+		xhci->bus_state[i].suspended_ports = 0;
+		xhci->bus_state[i].resuming_ports = 0;
+	}
+
+	return ret;
 }
 
 #ifdef CONFIG_PCI
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1362,6 +1362,8 @@ struct xhci_bus_state {
 	u32			suspended_ports;
 	u32			port_remote_wakeup;
 	unsigned long		resume_done[USB_MAXCHILDREN];
+	/* which ports have started to resume */
+	unsigned long		resuming_ports;
 };
 
 static inline unsigned int hcd_index(struct usb_hcd *hcd)



  parent reply	other threads:[~2012-05-27  1:18 UTC|newest]

Thread overview: 116+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-27  1:09 [ 00/91] 3.4.1-stable review Greg KH
2012-05-27  0:25 ` [ 01/91] isdn/gigaset: ratelimit CAPI message dumps Greg KH
2012-05-27  0:25 ` [ 02/91] isdn/gigaset: fix CAPI disconnect B3 handling Greg KH
2012-05-27  0:25 ` [ 03/91] isdn/gigaset: improve error handling querying firmware version Greg KH
2012-05-27  0:25 ` [ 04/91] vfs: make AIO use the proper rw_verify_area() area helpers Greg KH
2012-05-27  0:25 ` [ 05/91] iwlwifi: use 6000G2B for 6030 device series Greg KH
2012-05-27 13:34   ` Ben Hutchings
2012-06-01  7:03     ` Greg KH
2012-05-27  0:25 ` [ 06/91] iwlwifi: use correct released ucode version Greg KH
2012-05-27  0:25 ` [ 07/91] net/wireless: ipw2200: Fix WARN_ON occurring in wiphy_register called by ipw_pci_probe Greg KH
2012-05-27 19:24   ` Herton Ronaldo Krzesinski
2012-05-27 19:50     ` Ben Hutchings
2012-05-27  0:25 ` [ 08/91] cfg80211: warn if db.txt is empty with CONFIG_CFG80211_INTERNAL_REGDB Greg KH
2012-05-27  0:25 ` [ 09/91] regulator: core: Release regulator-regulator supplies on error Greg KH
2012-05-27  0:25 ` [ 10/91] Fix blocking allocations called very early during bootup Greg KH
2012-05-27  0:25 ` [ 11/91] s390/pfault: fix task state race Greg KH
2012-05-27  0:25 ` [ 12/91] SCSI: mpt2sas: Fix for panic happening because of improper memory allocation Greg KH
2012-05-27  0:25 ` [ 13/91] isci: fix oem parameter validation on single controller skus Greg KH
2012-05-27  0:25 ` [ 14/91] RDMA/cxgb4: Always wake up waiters in c4iw_peer_abort_intr() Greg KH
2012-05-27  0:25 ` [ 15/91] RDMA/cxgb4: Use dst parameter in import_ep() Greg KH
2012-05-27  0:25 ` [ 16/91] RDMA/cxgb4: Drop peer_abort when no endpoint found Greg KH
2012-05-27  0:25 ` [ 17/91] powerpc: Fix broken cpu_idle_wait() implementation Greg KH
2012-05-27  0:25 ` [ 18/91] KEYS: Use the compat keyctl() syscall wrapper on Sparc64 for Sparc32 compat Greg KH
2012-05-27  0:25 ` [ 19/91] SELinux: if sel_make_bools errors dont leave inconsistent state Greg KH
2012-05-27  0:25 ` [ 20/91] fbdev: sh_mobile_lcdc: Dont confuse line size with pitch Greg KH
2012-05-27  0:25 ` [ 21/91] IB/core: Fix mismatch between locked and pinned pages Greg KH
2012-05-27  0:25 ` [ 22/91] drivers/staging/comedi/comedi_fops.c: add missing vfree Greg KH
2012-05-27  0:25 ` [ 23/91] perf/x86: Update event scheduling constraints for AMD family 15h models Greg KH
2012-05-27  0:25 ` [ 24/91] HID: wiimote: Fix IR data parser Greg KH
2012-05-27  0:25 ` [ 25/91] usbhid: prevent deadlock during timeout Greg KH
2012-05-27  0:25 ` [ 26/91] HID: logitech: read all 32 bits of report type bitfield Greg KH
2012-05-27  0:25 ` [ 27/91] um: Fix __swp_type() Greg KH
2012-05-27  0:25 ` [ 28/91] um: Implement a custom pte_same() function Greg KH
2012-05-27  0:25 ` [ 29/91] persistent_ram: Fix buffer size clamping during writes Greg KH
2012-05-27  0:25 ` [ 30/91] docs: update HOWTO for 2.6.x -> 3.x versioning Greg KH
2012-05-27  0:25 ` [ 31/91] USB: cdc-wdm: sanitize error returns Greg KH
2012-05-27  0:25 ` [ 32/91] USB: cdc-wdm: fix memory leak Greg KH
2012-05-27  0:25 ` [ 33/91] USB: cdc-wdm: poll must return POLLHUP if device is gone Greg KH
2012-05-27  0:25 ` [ 34/91] USB: cdc-wdm: cannot use dev_printk when " Greg KH
2012-05-27  0:25 ` [ 35/91] USB: cdc-wdm: remove from device list on disconnect Greg KH
2012-05-27  0:25 ` [ 36/91] workqueue: skip nr_running sanity check in worker_enter_idle() if trustee is active Greg KH
2012-05-27  0:25 ` [ 37/91] mm: mempolicy: Let vma_merge and vma_split handle vma->vm_policy linkages Greg KH
2012-05-27  0:25 ` [ 38/91] md: using GFP_NOIO to allocate bio for flush request Greg KH
2012-05-27  0:25 ` [ 39/91] Add missing call to uart_update_timeout() Greg KH
2012-05-27  0:25 ` [ 40/91] 8250.c: less than 2400 baud fix Greg KH
2012-05-27  0:25 ` [ 41/91] 8250_pci: fix pch uart matching Greg KH
2012-05-27  0:25 ` [ 42/91] tty: Allow uart_register/unregister/register Greg KH
2012-05-27  0:25 ` [ 43/91] USB: ftdi-sio: add support for Physik Instrumente E-861 Greg KH
2012-05-27  0:25 ` [ 44/91] usb-serial: ftdi_sio: fix oops during autosuspend Greg KH
2012-05-27  0:25 ` [ 45/91] usb-storage: unusual_devs entry for Yarvik PMP400 MP4 player Greg KH
2012-05-27  0:25 ` [ 46/91] USB: ffs-test: fix length argument of out function call Greg KH
2012-05-27  0:25 ` [ 47/91] usb: usbtest: two super speed fixes for usbtest Greg KH
2012-05-27  0:25 ` [ 48/91] USB: ehci-platform: remove update_device Greg KH
2012-05-27  0:25 ` [ 49/91] USB: EHCI: OMAP: Finish ehci omap phy reset cycle before adding hcd Greg KH
2012-05-27  0:25 ` [ 50/91] USB: gpio_vbus: provide an appropriate debounce interval Greg KH
2012-05-27  0:25 ` [ 51/91] USB: ohci-at91: add a reset function to fix race condition Greg KH
2012-05-27  0:25 ` [ 52/91] USB: Remove races in devio.c Greg KH
2012-05-27  0:25 ` [ 53/91] USB: serial: ti_usb_3410_5052: Add support for the FRI2 serial console Greg KH
2012-05-27  0:26 ` [ 54/91] usb: gadget: fsl_udc_core: dTDs next dtd pointer need to be updated once written Greg KH
2012-05-27  0:26 ` [ 55/91] usb: add USB_QUIRK_RESET_RESUME for M-Audio 88es Greg KH
2012-05-27  0:26 ` [ 56/91] xhci: Add Lynx Point to list of Intel switchable hosts Greg KH
2012-05-27  0:26 ` Greg KH [this message]
2012-05-27  0:26 ` [ 58/91] xhci: Avoid dead ports when CONFIG_USB_XHCI_HCD=n Greg KH
2012-05-27  0:26 ` [ 59/91] usb-xhci: Handle COMP_TX_ERR for isoc tds Greg KH
2012-05-27  0:26 ` [ 60/91] xhci: Reset reserved command ring TRBs on cleanup Greg KH
2012-05-27  0:26 ` [ 61/91] xhci: Add new short TX quirk for Fresco Logic host Greg KH
2012-05-27  0:26 ` [ 62/91] USB: fix resource leak in xhci power loss path Greg KH
2012-05-27  0:26 ` [ 63/91] usbcore: enable USB2 LPM if port suspend fails Greg KH
2012-05-27  0:26 ` [ 64/91] gma500: Fix Poulsbo suspend/resume crash on devices with SDVO ports Greg KH
2012-05-27  0:26 ` [ 65/91] b43legacy: Fix error due to MMIO access with SSB unpowered Greg KH
2012-05-27  0:26 ` [ 66/91] drm/i915: Avoid a double-read of PCH_IIR during interrupt handling Greg KH
2012-05-27  0:26 ` [ 67/91] drm/i915: [GEN7] Use HW scheduler for fixed function shaders Greg KH
2012-05-27  0:26 ` [ 68/91] drm/i915: dont clobber the pipe param in sanitize_modesetting Greg KH
2012-05-27  0:26 ` [ 69/91] gpio: mpc8xxx: Prevent NULL pointer deref in demux handler Greg KH
2012-05-27  0:26 ` [ 70/91] spi/spi-fsl-spi: reference correct pdata in fsl_spi_cs_control Greg KH
2012-05-27  0:26 ` [ 71/91] hvc_xen: NULL dereference on allocation failure Greg KH
2012-05-27  0:26 ` [ 72/91] xen: do not map the same GSI twice in PVHVM guests Greg KH
2012-05-27  0:26 ` [ 73/91] nouveau: nouveau_set_bo_placement takes TTM flags Greg KH
2012-05-27  0:26 ` [ 74/91] [media] smsusb: add autodetection support for USB ID 2040:c0a0 Greg KH
2012-05-27  0:26 ` [ 75/91] media: uvcvideo: Fix ENUMINPUT handling Greg KH
2012-05-27  0:26 ` [ 76/91] x86, relocs: Build clean fix Greg KH
2012-05-27  0:26 ` [ 77/91] x86-32, relocs: Whitelist more symbols for ld bug workaround Greg KH
2012-05-27  0:26 ` [ 78/91] x86, relocs: Add jiffies and jiffies_64 to the relative whitelist Greg KH
2012-05-27  0:26 ` [ 79/91] x86/mce: Fix check for processor context when machine check was taken Greg KH
2012-05-27  0:26 ` [ 80/91] mmc: sdio: avoid spurious calls to interrupt handlers Greg KH
2012-05-27  0:26 ` [ 81/91] mmc: cd-gpio: protect against NULL context in mmc_cd_gpio_free() Greg KH
2012-05-27  0:26 ` [ 82/91] mmc: omap_hsmmc: pass IRQF_ONESHOT to request_threaded_irq Greg KH
2012-05-27  0:26 ` [ 83/91] tile: fix bug where fls(0) was not returning 0 Greg KH
2012-05-27  0:26 ` [ 84/91] intel-iommu: Add device info into list before doing context mapping Greg KH
2012-05-27  0:26 ` [ 85/91] iommu: Fix off by one in dmar_get_fault_reason() Greg KH
2012-05-27  0:26 ` [ 86/91] ARM: 7365/1: drop unused parameter from flush_cache_user_range Greg KH
2012-05-27  0:26 ` [ 87/91] ARM: 7409/1: Do not call flush_cache_user_range with mmap_sem held Greg KH
2012-05-27  0:26 ` [ 88/91] ARM: dt: tegra cardhu: fix typo in SDHCI node name Greg KH
2012-05-27  0:26 ` [ 89/91] MCE: Fix vm86 handling for 32bit mce handler Greg KH
2012-05-27  0:26 ` [ 90/91] i2c: davinci: Free requested IRQ in remove Greg KH
2012-05-27  0:26 ` [ 91/91] i2c: tegra: notify transfer-complete after clearing status Greg KH
2012-05-27 17:02 ` [ 00/91] 3.4.1-stable review Willy Tarreau
2012-05-27 20:00   ` Greg KH
2012-05-28 14:18 ` [ 00/91] 3.4.1-stable review Fw: [PATCH 1/2] libata: add a host flag to ignore detected ATA devices FW: use hv_storvsc instead of ata_piix to handle the IDE disks devices ( but not for the CD-ROM) Victor Miasnikov
2012-05-28 20:35   ` Greg KH
2012-05-28 20:40     ` Jonathan Nieder
2012-05-29  6:34     ` Linux on Hyper-V 1) cd006086fa5d ata_piix: defer disks to the Hyper-V drivers by default 2) db63a4c8115a libata: add a host flag to ignore detected ATA device " Victor Miasnikov
2012-06-01  9:20       ` Greg KH
2012-06-01 16:17         ` Linux on Hyper-V 1) cd006086fa5d ata_piix: defer disks to the Hyper-V drivers by default 2) db63a4c8115a libata: add a host flag to ignore detected ATA device FW: use hv_storvsc instead of ata_piix to handle the IDE disks devices ( but not for the CD-R Victor Miasnikov
2012-06-01 16:26           ` Greg KH
2012-06-01 19:23             ` Linux on Hyper-V 1) cd006086fa5d ata_piix: defer disks to the Hyper-V drivers by default 2) db63a4c8115a libata: add a host flag to ignore detected ATA device FW: use hv_storvsc instead of ata_piix to handle the IDE disks devices ( but not for the KY Srinivasan
2012-06-02  1:22               ` Greg KH
2012-06-04 12:33                 ` Victor Miasnikov
2012-06-04 13:56                   ` KY Srinivasan
2012-06-04 14:15                     ` Victor Miasnikov
2012-06-04 14:19                       ` KY Srinivasan
2012-06-04 15:57                         ` Victor Miasnikov
2012-06-05  4:59                   ` [PATCH 2/2] ata_piix: defer disks to the Hyper-V drivers by default Jonathan Nieder
2012-06-05  6:50                     ` ToDo: backport to v3.4 , v3.3 , v3.2 patches 1b) db63a4c8115a libata 1) cd006086fa5d ata_piix: defer disks to the Hyper-V drivers by default Fw: use hv_storvsc instead of ata_piix for IDE disks ( but not for the CD-ROM) Victor Miasnikov
2012-05-29  9:38 ` [ 00/91] 3.4.1-stable review Greg KH
2012-05-29 16:57 ` 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=20120527002519.381690179@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=andiry.xu@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sarah.a.sharp@linux.intel.com \
    --cc=stable@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    --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 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.