From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Tony Camuso <tcamuso@redhat.com>,
Don Zickus <dzickus@redhat.com>,
Sarah Sharp <sarah.a.sharp@linux.intel.com>
Subject: [ 02/32] xhci - correct comp_mode_recovery_timer on return from hibernate
Date: Tue, 11 Jun 2013 13:03:01 -0700 [thread overview]
Message-ID: <20130611200126.471760872@linuxfoundation.org> (raw)
In-Reply-To: <20130611200126.214442788@linuxfoundation.org>
3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Camuso <tcamuso@redhat.com>
commit 77df9e0b799b03e1d5d9c68062709af5f637e834 upstream.
Commit 71c731a2 (usb: host: xhci: Fix Compliance Mode on SN65LVPE502CP
Hardware) was a workaround for systems using the SN65LVPE502CP,
controller, but it introduced a bug in resume from hibernate.
The fix created a timer, comp_mode_recovery_timer, which is deleted from
a timer list when xhci_suspend() is called. However, the hibernate image,
including the timer list containing the comp_mode_recovery_timer, had
already been saved before the timer was deleted.
Upon resume from hibernate, the list containing the comp_mode_recovery_timer
is restored from the image saved to disk, and xhci_resume(), assuming that
the timer had been deleted by xhci_suspend(), makes a call to
compliance_mode_recoery_timer_init(), which creates a new instance of the
comp_mode_recovery_timer and attempts to place it into the same list in which
it is already active, thus corrupting the list during the list_add() call.
At this point, a call trace is emitted indicating the list corruption.
Soon afterward, the system locks up, the watchdog times out, and the
ensuing NMI crashes the system.
The problem did not occur when resuming from suspend. In suspend, the
image in RAM remains exactly as it was when xhci_suspend() deleted the
comp_mode_recovery_timer, so there is no problem when xhci_resume()
creates a new instance of this timer and places it in the still empty
list.
This patch avoids the problem by deleting the timer in xhci_resume()
when resuming from hibernate. Now xhci_resume() can safely make the
call to create a new instance of this timer, whether returning from
suspend or hibernate.
Thanks to Alan Stern for his help with understanding the problem.
[Sarah reworked this patch to cover the case where the xHCI restore
register operation fails, and (temp & STS_SRE) is true (and we re-init
the host, including re-init for the compliance mode), but hibernate is
false. The original patch would have caused list corruption in this
case.]
This patch should be backported to kernels as old as 3.2, that
contain the commit 71c731a296f1b08a3724bd1b514b64f1bda87a23 "usb: host:
xhci: Fix Compliance Mode on SN65LVPE502CP Hardware"
Signed-off-by: Tony Camuso <tcamuso@redhat.com>
Tested-by: Tony Camuso <tcamuso@redhat.com>
Acked-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/usb/host/xhci.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -947,6 +947,7 @@ int xhci_resume(struct xhci_hcd *xhci, b
struct usb_hcd *hcd = xhci_to_hcd(xhci);
struct usb_hcd *secondary_hcd;
int retval = 0;
+ bool comp_timer_running = false;
/* Wait a bit if either of the roothubs need to settle from the
* transition into bus suspend.
@@ -984,6 +985,13 @@ int xhci_resume(struct xhci_hcd *xhci, b
/* If restore operation fails, re-initialize the HC during resume */
if ((temp & STS_SRE) || hibernated) {
+
+ if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) &&
+ !(xhci_all_ports_seen_u0(xhci))) {
+ del_timer_sync(&xhci->comp_mode_recovery_timer);
+ xhci_dbg(xhci, "Compliance Mode Recovery Timer deleted!\n");
+ }
+
/* Let the USB core know _both_ roothubs lost power. */
usb_root_hub_lost_power(xhci->main_hcd->self.root_hub);
usb_root_hub_lost_power(xhci->shared_hcd->self.root_hub);
@@ -1026,6 +1034,8 @@ int xhci_resume(struct xhci_hcd *xhci, b
retval = xhci_init(hcd->primary_hcd);
if (retval)
return retval;
+ comp_timer_running = true;
+
xhci_dbg(xhci, "Start the primary HCD\n");
retval = xhci_run(hcd->primary_hcd);
if (!retval) {
@@ -1067,7 +1077,7 @@ int xhci_resume(struct xhci_hcd *xhci, b
* to suffer the Compliance Mode issue again. It doesn't matter if
* ports have entered previously to U0 before system's suspension.
*/
- if (xhci->quirks & XHCI_COMP_MODE_QUIRK)
+ if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) && !comp_timer_running)
compliance_mode_recovery_timer_init(xhci);
/* Re-enable port polling. */
next prev parent reply other threads:[~2013-06-11 20:03 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-11 20:02 [ 00/32] 3.4.49-stable review Greg Kroah-Hartman
2013-06-11 20:03 ` [ 01/32] USB: option: blacklist network interface on Huawei E1820 Greg Kroah-Hartman
2013-06-11 20:03 ` Greg Kroah-Hartman [this message]
2013-06-11 20:03 ` [ 03/32] xhci-mem: init list heads at the beginning of init Greg Kroah-Hartman
2013-06-11 20:03 ` [ 04/32] xhci: fix list access before init Greg Kroah-Hartman
2013-06-11 20:03 ` [ 05/32] ALSA: usb-audio: fix Roland/Cakewalk UM-3G support Greg Kroah-Hartman
2013-06-11 20:03 ` [ 06/32] ALSA: usb-audio - Apply Logitech QuickCam Pro 9000 quirk only to audio iface Greg Kroah-Hartman
2013-06-11 20:03 ` [ 07/32] ALSA: usb-audio - Fix invalid volume resolution on Logitech HD webcam c270 Greg Kroah-Hartman
2013-06-11 20:03 ` [ 08/32] USB: iuu_phoenix: fix bulk-message timeout Greg Kroah-Hartman
2013-06-11 20:03 ` [ 09/32] USB: keyspan: fix bogus array index Greg Kroah-Hartman
2013-06-11 20:03 ` [ 10/32] USB: ark3116: fix control-message timeout Greg Kroah-Hartman
2013-06-11 20:03 ` [ 11/32] USB: visor: fix initialisation of Treo/Kyocera devices Greg Kroah-Hartman
2013-06-11 20:03 ` [ 12/32] USB: Serial: cypress_M8: Enable FRWD Dongle hidcom device Greg Kroah-Hartman
2013-06-11 20:03 ` [ 13/32] USB: whiteheat: fix broken port configuration Greg Kroah-Hartman
2013-06-11 20:03 ` [ 14/32] USB: serial: fix Treo/Kyocera interrrupt-in urb context Greg Kroah-Hartman
2013-06-11 20:03 ` [ 15/32] USB: revert periodic scheduling bugfix Greg Kroah-Hartman
2013-06-11 20:03 ` [ 16/32] USB: mos7720: fix DMA to stack Greg Kroah-Hartman
2013-06-11 20:03 ` [ 17/32] USB: mos7720: fix message timeouts Greg Kroah-Hartman
2013-06-11 20:03 ` [ 18/32] USB: mos7720: fix hardware flow control Greg Kroah-Hartman
2013-06-11 20:03 ` [ 19/32] ACPI / video: ignore BIOS initial backlight value for HP m4 Greg Kroah-Hartman
2013-06-11 20:03 ` [ 20/32] ACPI / video: ignore BIOS initial backlight value for HP Pavilion g6 Greg Kroah-Hartman
2013-06-11 20:03 ` [ 21/32] powerpc/eeh: Dont check RTAS token to get PE addr Greg Kroah-Hartman
2013-06-11 20:03 ` [ 22/32] radeon: Fix system hang issue when using KMS with older cards Greg Kroah-Hartman
2013-06-11 20:03 ` [ 23/32] drm/radeon: dont allow audio on DCE6 Greg Kroah-Hartman
2013-06-11 20:03 ` [ 24/32] hwmon: (adm1021) Strengthen chip detection for ADM1021, LM84 and MAX1617 Greg Kroah-Hartman
2013-06-11 20:03 ` [ 25/32] drm: fix a use-after-free when GPU acceleration disabled Greg Kroah-Hartman
2013-06-11 20:03 ` [ 26/32] drm/i915/sdvo: Use &intel_sdvo->ddc instead of intel_sdvo->i2c for DDC Greg Kroah-Hartman
2013-06-11 20:03 ` [ 27/32] drm/i915: no lvds quirk for hp t5740 Greg Kroah-Hartman
2013-06-11 20:03 ` [ 28/32] xen-pciback: rate limit error messages from xen_pcibk_enable_msi{,x}() Greg Kroah-Hartman
2013-06-11 20:03 ` [ 29/32] USB: ftdi_sio: Quiet sparse noise about using plain integer was NULL pointer Greg Kroah-Hartman
2013-06-11 20:03 ` [ 30/32] drm/gma500: Increase max resolution for mode setting Greg Kroah-Hartman
2013-06-11 20:03 ` [ 31/32] tracing: Fix possible NULL pointer dereferences Greg Kroah-Hartman
2013-06-11 20:03 ` [ 32/32] ftrace: Move ftrace_filter_lseek out of CONFIG_DYNAMIC_FTRACE section Greg Kroah-Hartman
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=20130611200126.471760872@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=dzickus@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sarah.a.sharp@linux.intel.com \
--cc=stable@vger.kernel.org \
--cc=tcamuso@redhat.com \
/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