linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Slaby <jslaby@suse.cz>
To: stable@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	Alan Stern <stern@rowland.harvard.edu>,
	Jiri Slaby <jslaby@suse.cz>
Subject: [PATCH 3.12 054/111] USB: Avoid runtime suspend loops for HCDs that can't handle suspend/resume
Date: Mon, 23 Jun 2014 10:31:29 +0200	[thread overview]
Message-ID: <7db4c4d2e0e04ea112a1900aea2fa3a746ebe633.1403512281.git.jslaby@suse.cz> (raw)
In-Reply-To: <55d5f044a1fc96a74e4470e318c0a24f27a9ab7e.1403512280.git.jslaby@suse.cz>
In-Reply-To: <cover.1403512280.git.jslaby@suse.cz>

From: Alan Stern <stern@rowland.harvard.edu>

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

===============

commit 8ef42ddd9a53b73e6fc3934278710c27f80f324f upstream.

Not all host controller drivers have bus-suspend and bus-resume
methods.  When one doesn't, it will cause problems if runtime PM is
enabled in the kernel.  The PM core will attempt to suspend the
controller's root hub, the suspend will fail because there is no
bus-suspend routine, and a -EBUSY error code will be returned to the
PM core.  This will cause the suspend attempt to be repeated shortly
thereafter, in a never-ending loop.

Part of the problem is that the original error code -ENOENT gets
changed to -EBUSY in usb_runtime_suspend(), on the grounds that the PM
core will interpret -ENOENT as meaning that the root hub has gotten
into a runtime-PM error state.  While this change is appropriate for
real USB devices, it's not such a good idea for a root hub.  In fact,
considering the root hub to be in a runtime-PM error state would not
be far from the truth.  Therefore this patch updates
usb_runtime_suspend() so that it adjusts error codes only for
non-root-hub devices.

Furthermore, the patch attempts to prevent the problem from occurring
in the first place by not enabling runtime PM by default for root hubs
whose host controller driver doesn't have bus_suspend and bus_resume
methods.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: Will Deacon <will.deacon@arm.com>
Tested-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/usb/core/driver.c |  9 ++++++---
 drivers/usb/core/hub.c    | 15 +++++++++++++--
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 2ddc586457c8..bfddeb3bc97e 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -1770,10 +1770,13 @@ int usb_runtime_suspend(struct device *dev)
 	if (status == -EAGAIN || status == -EBUSY)
 		usb_mark_last_busy(udev);
 
-	/* The PM core reacts badly unless the return code is 0,
-	 * -EAGAIN, or -EBUSY, so always return -EBUSY on an error.
+	/*
+	 * The PM core reacts badly unless the return code is 0,
+	 * -EAGAIN, or -EBUSY, so always return -EBUSY on an error
+	 * (except for root hubs, because they don't suspend through
+	 * an upstream port like other USB devices).
 	 */
-	if (status != 0)
+	if (status != 0 && udev->parent)
 		return -EBUSY;
 	return status;
 }
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 5064fc8ba14f..60a1f13db296 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1688,8 +1688,19 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
 	 */
 	pm_runtime_set_autosuspend_delay(&hdev->dev, 0);
 
-	/* Hubs have proper suspend/resume support. */
-	usb_enable_autosuspend(hdev);
+	/*
+	 * Hubs have proper suspend/resume support, except for root hubs
+	 * where the controller driver doesn't have bus_suspend and
+	 * bus_resume methods.
+	 */
+	if (hdev->parent) {		/* normal device */
+		usb_enable_autosuspend(hdev);
+	} else {			/* root hub */
+		const struct hc_driver *drv = bus_to_hcd(hdev->bus)->driver;
+
+		if (drv->bus_suspend && drv->bus_resume)
+			usb_enable_autosuspend(hdev);
+	}
 
 	if (hdev->level == MAX_TOPO_LEVEL) {
 		dev_err(&intf->dev,
-- 
2.0.0


  parent reply	other threads:[~2014-06-23  8:52 UTC|newest]

Thread overview: 116+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-23  8:32 [PATCH 3.12 000/111] 3.12.23-stable review Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 001/111] ath9k: Fix sequence number assignment for non-data frames Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 002/111] rtlwifi: rtl8192se: Fix regression due to commit 1bf4bbb Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 003/111] xhci: extend quirk for Renesas cards Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 004/111] drm/i915: restrict vt-d stolen memory workaround to pre-gen8 Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 005/111] floppy: do not corrupt bio.bi_flags when reading block 0 Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 006/111] xhci: Switch only Intel Lynx Point-LP ports to EHCI on shutdown Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 007/111] MIPS: asm: thread_info: Add _TIF_SECCOMP flag Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 008/111] btrfs: fix defrag 32-bit integer overflow Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 009/111] target: Fix NULL pointer dereference for XCOPY in target_put_sess_cmd Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 010/111] mm: compaction: reset cached scanner pfn's before reading them Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 011/111] mm: compaction: detect when scanners meet in isolate_freepages Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 012/111] mm/compaction: make isolate_freepages start at pageblock boundary Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 013/111] ARM: perf: hook up perf_sample_event_took around pmu irq handling Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 014/111] iommu/vt-d: Fix missing IOTLB flush in intel_iommu_unmap() Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 015/111] sched: Use CPUPRI_NR_PRIORITIES instead of MAX_RT_PRIO in cpupri check Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 016/111] sched: Sanitize irq accounting madness Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 017/111] perf: Prevent false warning in perf_swevent_add Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 018/111] perf: Limit perf_event_attr::sample_period to 63 bits Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 019/111] perf: Fix race in removing an event Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 020/111] mm/memory-failure.c: fix memory leak by race between poison and unpoison Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 021/111] Documentation: fix DOCBOOKS=... building Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 022/111] hwmon: (ntc_thermistor) Fix dependencies Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 023/111] hwmon: (ntc_thermistor) Fix OF device ID mapping Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 024/111] drm/gf119-/disp: fix nasty bug which can clobber SOR0's clock setup Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 025/111] drm/radeon: also try GART for CPU accessed buffers Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 026/111] drm/radeon: handle non-VGA class pci devices with ATRM Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 027/111] SCSI: scsi_transport_sas: move bsg destructor into sas_rphy_remove Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 028/111] ARM: imx: fix error handling in ipu device registration Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 029/111] ARM: omap5: hwmod_data: Correct IDLEMODE for McPDM Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 030/111] ARM: OMAP3: clock: Back-propagate rate change from cam_mclk to dpll4_m5 on all OMAP3 platforms Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 031/111] ARM: 8051/1: put_user: fix possible data corruption in put_user Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 032/111] ARM: 8064/1: fix v7-M signal return Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 033/111] cpufreq: remove race while accessing cur_policy Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 034/111] dm cache: always split discards on cache block boundaries Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 035/111] sched: Fix hotplug vs. set_cpus_allowed_ptr() Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 036/111] drm/radeon: avoid crash if VM command submission isn't available Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 037/111] drm/i915: Only copy back the modified fields to userspace from execbuffer Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 038/111] libata: Blacklist queued trim for Crucial M500 Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 039/111] md: always set MD_RECOVERY_INTR when aborting a reshape or other "resync" Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 040/111] md: always set MD_RECOVERY_INTR when interrupting a reshape thread Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 041/111] xhci: delete endpoints from bandwidth list before freeing whole device Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 042/111] Staging: speakup: Move pasting into a work item Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 043/111] staging: comedi: ni_daq_700: add mux settling delay Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 044/111] Staging: speakup: Update __speakup_paste_selection() tty (ab)usage to match vt Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 045/111] ALSA: hda/analog - Fix silent output on ASUS A8JN Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 046/111] ALSA: hda/realtek - Correction of fixup codes for PB V7900 laptop Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 047/111] ALSA: hda/realtek - Fix COEF widget NID for ALC260 replacer fixup Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 048/111] USB: ftdi_sio: add NovaTech OrionLXm product ID Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 049/111] usb: cdc-wdm: export cdc-wdm uapi header Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 050/111] USB: cdc-wdm: properly include types.h Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 051/111] USB: serial: option: add support for Novatel E371 PCIe card Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 052/111] USB: io_ti: fix firmware download on big-endian machines (part 2) Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 053/111] usb: pci-quirks: Prevent Sony VAIO t-series from switching usb ports Jiri Slaby
2014-06-23  8:31 ` Jiri Slaby [this message]
2014-06-23  8:31 ` [PATCH 3.12 055/111] percpu-refcount: fix usage of this_cpu_ops Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 056/111] mm: rmap: fix use-after-free in __put_anon_vma Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 057/111] iser-target: Add missing target_put_sess_cmd for ImmedateData failure Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 058/111] target: Fix alua_access_state attribute OOPs for un-configured devices Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 059/111] gpio: mcp23s08: Bug fix of SPI device tree registration Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 060/111] [media] rtl28xxu: add 15f4:0131 Astrometa DVB-T2 Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 061/111] [media] Add USB IDs for Winfast DTV Dongle Mini-D Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 062/111] fs,userns: Change inode_capable to capable_wrt_inode_uidgid Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 063/111] Target/iscsi,iser: Avoid accepting transport connections during stop stage Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 064/111] iser-target: Fix multi network portal shutdown regression Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 065/111] target: Allow READ_CAPACITY opcode in ALUA Standby access state Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 066/111] auditsc: audit_krule mask accesses need bounds checking Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 067/111] mei: me: drop harmful wait optimization Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 068/111] rtl28xxu: add ID [0ccd:00b4] TerraTec NOXON DAB Stick (rev 3) Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 069/111] rtl28xxu: add USB ID for Genius TVGo DVB-T03 Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 070/111] rtl28xxu: add chipset version comments into device list Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 071/111] rtl28xxu: add 1b80:d395 Peak DVB-T USB Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 072/111] rtl28xxu: add [1b80:d39d] Sveon STV20 Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 073/111] rtl28xxu: add [1b80:d3af] Sveon STV27 Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 074/111] ahci: Add Device ID for HighPoint RocketRaid 642L Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 075/111] ahci: add PCI ID for Marvell 88SE91A0 SATA Controller Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 076/111] drm/i915: Allow user modes to exceed DVI 165MHz limit Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 077/111] ima: audit log files opened with O_DIRECT flag Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 078/111] skbuff: skb_segment: s/frag/nskb_frag/ Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 079/111] skbuff: skb_segment: s/skb_frag/frag/ Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 080/111] skbuff: skb_segment: s/skb/head_skb/ Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 081/111] skbuff: skb_segment: s/fskb/list_skb/ Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 082/111] skbuff: skb_segment: orphan frags before copying Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 083/111] rtc: rtc-at91rm9200: fix infinite wait for ACKUPD irq Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 084/111] iscsi-target: Reject mutual authentication with reflected CHAP_C Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 085/111] ima: introduce ima_kernel_read() Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 086/111] evm: prohibit userspace writing 'security.evm' HMAC value Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 087/111] netlink: Rename netlink_capable netlink_allowed Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 088/111] net: Move the permission check in sock_diag_put_filterinfo to packet_diag_dump Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 089/111] net: Add variants of capable for use on on sockets Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 090/111] net: Add variants of capable for use on netlink messages Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 091/111] net: Use netlink_ns_capable to verify the permisions of " Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 092/111] netlink: Only check file credentials for implicit destinations Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 093/111] qlcnic: info leak in qlcnic_dcb_peer_app_info() Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 094/111] netlink: rate-limit leftover bytes warning and print process name Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 095/111] bridge: Prevent insertion of FDB entry with disallowed vlan Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 096/111] net: tunnels - enable module autoloading Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 097/111] net: fix inet_getid() and ipv6_select_ident() bugs Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 098/111] team: fix mtu setting Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 099/111] tcp: fix cwnd undo on DSACK in F-RTO Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 100/111] sh_eth: use RNC mode for packet reception Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 101/111] sh_eth: fix SH7619/771x support Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 102/111] net: filter: fix typo in sparc BPF JIT Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 103/111] net: filter: fix sparc32 typo Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 104/111] net: qmi_wwan: add Olivetti Olicard modems Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 105/111] net: force a list_del() in unregister_netdevice_many() Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 106/111] ipip, sit: fix ipv4_{update_pmtu,redirect} calls Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 107/111] ipv4: fix a race in ip4_datagram_release_cb() Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 108/111] sctp: Fix sk_ack_backlog wrap-around problem Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 109/111] rtnetlink: fix userspace API breakage for iproute2 < v3.9.0 Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 110/111] vxlan: use dev->needed_headroom instead of dev->hard_header_len Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 111/111] ARM: at91: fix at91_sysirq_mask_rtc for sam9x5 SoCs Jiri Slaby
2014-06-23 14:55 ` [PATCH 3.12 000/111] 3.12.23-stable review Guenter Roeck
2014-06-25 13:29   ` Jiri Slaby
2014-06-23 16:45 ` Shuah Khan
2014-06-23 22:13 ` Satoru Takeuchi

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=7db4c4d2e0e04ea112a1900aea2fa3a746ebe633.1403512281.git.jslaby@suse.cz \
    --to=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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;
as well as URLs for NNTP newsgroup(s).