aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 15:19:23 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 15:19:23 -0400
commitec25e246b94a3233ab064994ef05a170bdba0e7c (patch)
tree49b7d7e4c46e13bb465c7b832961596e41e8526a /drivers/usb/core
parent507ffe4f3840ac24890a8123c702cf1b7fe4d33c (diff)
parent4626b8daf9bb00ce6b4d533c1a155211ad880f32 (diff)
Merge tag 'usb-3.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB patches from Greg Kroah-Hartman: "Here's the big USB pull request for 3.10-rc1. Lots of USB patches here, the majority being USB gadget changes and USB-serial driver cleanups, the rest being ARM build fixes / cleanups, and individual driver updates. We also finally got some chipidea fixes, which have been delayed for a number of kernel releases, as the maintainer has now reappeared. All of these have been in linux-next for a while" * tag 'usb-3.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (568 commits) USB: ehci-msm: USB_MSM_OTG needs USB_PHY USB: OHCI: avoid conflicting platform drivers USB: OMAP: ISP1301 needs USB_PHY USB: lpc32xx: ISP1301 needs USB_PHY USB: ftdi_sio: enable two UART ports on ST Microconnect Lite usb: phy: tegra: don't call into tegra-ehci directly usb: phy: phy core cannot yet be a module USB: Fix initconst in ehci driver usb-storage: CY7C68300A chips do not support Cypress ATACB USB: serial: option: Added support Olivetti Olicard 145 USB: ftdi_sio: correct ST Micro Connect Lite PIDs ARM: mxs_defconfig: add CONFIG_USB_PHY ARM: imx_v6_v7_defconfig: add CONFIG_USB_PHY usb: phy: remove exported function from __init section usb: gadget: zero: put function instances on unbind usb: gadget: f_sourcesink.c: correct a copy-paste misnomer usb: gadget: cdc2: fix error return code in cdc_do_config() usb: gadget: multi: fix error return code in rndis_do_config() usb: gadget: f_obex: fix error return code in obex_bind() USB: storage: convert to use module_usb_driver() ...
Diffstat (limited to 'drivers/usb/core')
-rw-r--r--drivers/usb/core/Kconfig36
-rw-r--r--drivers/usb/core/devio.c2
-rw-r--r--drivers/usb/core/driver.c25
-rw-r--r--drivers/usb/core/generic.c2
-rw-r--r--drivers/usb/core/hcd-pci.c214
-rw-r--r--drivers/usb/core/hcd.c10
-rw-r--r--drivers/usb/core/hub.c136
-rw-r--r--drivers/usb/core/port.c4
-rw-r--r--drivers/usb/core/quirks.c16
-rw-r--r--drivers/usb/core/sysfs.c4
-rw-r--r--drivers/usb/core/urb.c5
-rw-r--r--drivers/usb/core/usb.c4
-rw-r--r--drivers/usb/core/usb.h2
13 files changed, 251 insertions, 209 deletions
diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
index f70c1a1694ad..8772b3659296 100644
--- a/drivers/usb/core/Kconfig
+++ b/drivers/usb/core/Kconfig
@@ -3,7 +3,6 @@
3# 3#
4config USB_DEBUG 4config USB_DEBUG
5 bool "USB verbose debug messages" 5 bool "USB verbose debug messages"
6 depends on USB
7 help 6 help
8 Say Y here if you want the USB core & hub drivers to produce a bunch 7 Say Y here if you want the USB core & hub drivers to produce a bunch
9 of debug messages to the system log. Select this if you are having a 8 of debug messages to the system log. Select this if you are having a
@@ -11,7 +10,6 @@ config USB_DEBUG
11 10
12config USB_ANNOUNCE_NEW_DEVICES 11config USB_ANNOUNCE_NEW_DEVICES
13 bool "USB announce new devices" 12 bool "USB announce new devices"
14 depends on USB
15 default N 13 default N
16 help 14 help
17 Say Y here if you want the USB core to always announce the 15 Say Y here if you want the USB core to always announce the
@@ -25,11 +23,24 @@ config USB_ANNOUNCE_NEW_DEVICES
25 log, or have any doubts about this, say N here. 23 log, or have any doubts about this, say N here.
26 24
27comment "Miscellaneous USB options" 25comment "Miscellaneous USB options"
28 depends on USB 26
27config USB_DEFAULT_PERSIST
28 bool "Enable USB persist by default"
29 default y
30 help
31 Say N here if you don't want USB power session persistance
32 enabled by default. If you say N it will make suspended USB
33 devices that lose power get reenumerated as if they had been
34 unplugged, causing any mounted filesystems to be lost. The
35 persist feature can still be enabled for individual devices
36 through the power/persist sysfs node. See
37 Documentation/usb/persist.txt for more info.
38
39 If you have any questions about this, say Y here, only say N
40 if you know exactly what you are doing.
29 41
30config USB_DYNAMIC_MINORS 42config USB_DYNAMIC_MINORS
31 bool "Dynamic USB minor allocation" 43 bool "Dynamic USB minor allocation"
32 depends on USB
33 help 44 help
34 If you say Y here, the USB subsystem will use dynamic minor 45 If you say Y here, the USB subsystem will use dynamic minor
35 allocation for any device that uses the USB major number. 46 allocation for any device that uses the USB major number.
@@ -38,25 +49,8 @@ config USB_DYNAMIC_MINORS
38 49
39 If you are unsure about this, say N here. 50 If you are unsure about this, say N here.
40 51
41config USB_SUSPEND
42 bool "USB runtime power management (autosuspend) and wakeup"
43 depends on USB && PM_RUNTIME
44 help
45 If you say Y here, you can use driver calls or the sysfs
46 "power/control" file to enable or disable autosuspend for
47 individual USB peripherals (see
48 Documentation/usb/power-management.txt for more details).
49
50 Also, USB "remote wakeup" signaling is supported, whereby some
51 USB devices (like keyboards and network adapters) can wake up
52 their parent hub. That wakeup cascades up the USB tree, and
53 could wake the system from states like suspend-to-RAM.
54
55 If you are unsure about this, say N here.
56
57config USB_OTG 52config USB_OTG
58 bool "OTG support" 53 bool "OTG support"
59 depends on USB
60 depends on USB_SUSPEND 54 depends on USB_SUSPEND
61 default n 55 default n
62 help 56 help
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 8823e98989fe..caefc800f298 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -739,6 +739,8 @@ static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype,
739 index &= 0xff; 739 index &= 0xff;
740 switch (requesttype & USB_RECIP_MASK) { 740 switch (requesttype & USB_RECIP_MASK) {
741 case USB_RECIP_ENDPOINT: 741 case USB_RECIP_ENDPOINT:
742 if ((index & ~USB_DIR_IN) == 0)
743 return 0;
742 ret = findintfep(ps->dev, index); 744 ret = findintfep(ps->dev, index);
743 if (ret >= 0) 745 if (ret >= 0)
744 ret = checkintf(ps, ret); 746 ret = checkintf(ps, ret);
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index d938b2b99e31..6eab440e1542 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -1196,9 +1196,14 @@ done:
1196 * 1196 *
1197 * This is the central routine for suspending USB devices. It calls the 1197 * This is the central routine for suspending USB devices. It calls the
1198 * suspend methods for all the interface drivers in @udev and then calls 1198 * suspend methods for all the interface drivers in @udev and then calls
1199 * the suspend method for @udev itself. If an error occurs at any stage, 1199 * the suspend method for @udev itself. When the routine is called in
1200 * all the interfaces which were suspended are resumed so that they remain 1200 * autosuspend, if an error occurs at any stage, all the interfaces
1201 * in the same state as the device. 1201 * which were suspended are resumed so that they remain in the same
1202 * state as the device, but when called from system sleep, all error
1203 * from suspend methods of interfaces and the non-root-hub device itself
1204 * are simply ignored, so all suspended interfaces are only resumed
1205 * to the device's state when @udev is root-hub and its suspend method
1206 * returns failure.
1202 * 1207 *
1203 * Autosuspend requests originating from a child device or an interface 1208 * Autosuspend requests originating from a child device or an interface
1204 * driver may be made without the protection of @udev's device lock, but 1209 * driver may be made without the protection of @udev's device lock, but
@@ -1248,10 +1253,12 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
1248 1253
1249 /* If the suspend failed, resume interfaces that did get suspended */ 1254 /* If the suspend failed, resume interfaces that did get suspended */
1250 if (status != 0) { 1255 if (status != 0) {
1251 msg.event ^= (PM_EVENT_SUSPEND | PM_EVENT_RESUME); 1256 if (udev->actconfig) {
1252 while (++i < n) { 1257 msg.event ^= (PM_EVENT_SUSPEND | PM_EVENT_RESUME);
1253 intf = udev->actconfig->interface[i]; 1258 while (++i < n) {
1254 usb_resume_interface(udev, intf, msg, 0); 1259 intf = udev->actconfig->interface[i];
1260 usb_resume_interface(udev, intf, msg, 0);
1261 }
1255 } 1262 }
1256 1263
1257 /* If the suspend succeeded then prevent any more URB submissions 1264 /* If the suspend succeeded then prevent any more URB submissions
@@ -1407,7 +1414,7 @@ int usb_resume(struct device *dev, pm_message_t msg)
1407 1414
1408#endif /* CONFIG_PM */ 1415#endif /* CONFIG_PM */
1409 1416
1410#ifdef CONFIG_USB_SUSPEND 1417#ifdef CONFIG_PM_RUNTIME
1411 1418
1412/** 1419/**
1413 * usb_enable_autosuspend - allow a USB device to be autosuspended 1420 * usb_enable_autosuspend - allow a USB device to be autosuspended
@@ -1775,7 +1782,7 @@ int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable)
1775 return ret; 1782 return ret;
1776} 1783}
1777 1784
1778#endif /* CONFIG_USB_SUSPEND */ 1785#endif /* CONFIG_PM_RUNTIME */
1779 1786
1780struct bus_type usb_bus_type = { 1787struct bus_type usb_bus_type = {
1781 .name = "usb", 1788 .name = "usb",
diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c
index 271e761f563e..acbfeb0a0119 100644
--- a/drivers/usb/core/generic.c
+++ b/drivers/usb/core/generic.c
@@ -169,7 +169,7 @@ static int generic_probe(struct usb_device *udev)
169 c = usb_choose_configuration(udev); 169 c = usb_choose_configuration(udev);
170 if (c >= 0) { 170 if (c >= 0) {
171 err = usb_set_configuration(udev, c); 171 err = usb_set_configuration(udev, c);
172 if (err) { 172 if (err && err != -ENODEV) {
173 dev_err(&udev->dev, "can't set config #%d, error %d\n", 173 dev_err(&udev->dev, "can't set config #%d, error %d\n",
174 c, err); 174 c, err);
175 /* This need not be fatal. The user can try to 175 /* This need not be fatal. The user can try to
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index 2b487d4797bd..caeb8d6d39fb 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -37,119 +37,123 @@
37 37
38/* PCI-based HCs are common, but plenty of non-PCI HCs are used too */ 38/* PCI-based HCs are common, but plenty of non-PCI HCs are used too */
39 39
40#ifdef CONFIG_PM_SLEEP 40/*
41 41 * Coordinate handoffs between EHCI and companion controllers
42/* Coordinate handoffs between EHCI and companion controllers 42 * during EHCI probing and system resume.
43 * during system resume
44 */ 43 */
45 44
46static DEFINE_MUTEX(companions_mutex); 45static DECLARE_RWSEM(companions_rwsem);
47 46
48#define CL_UHCI PCI_CLASS_SERIAL_USB_UHCI 47#define CL_UHCI PCI_CLASS_SERIAL_USB_UHCI
49#define CL_OHCI PCI_CLASS_SERIAL_USB_OHCI 48#define CL_OHCI PCI_CLASS_SERIAL_USB_OHCI
50#define CL_EHCI PCI_CLASS_SERIAL_USB_EHCI 49#define CL_EHCI PCI_CLASS_SERIAL_USB_EHCI
51 50
52enum companion_action { 51static inline int is_ohci_or_uhci(struct pci_dev *pdev)
53 SET_HS_COMPANION, CLEAR_HS_COMPANION, WAIT_FOR_COMPANIONS 52{
54}; 53 return pdev->class == CL_OHCI || pdev->class == CL_UHCI;
54}
55
56typedef void (*companion_fn)(struct pci_dev *pdev, struct usb_hcd *hcd,
57 struct pci_dev *companion, struct usb_hcd *companion_hcd);
55 58
56static void companion_common(struct pci_dev *pdev, struct usb_hcd *hcd, 59/* Iterate over PCI devices in the same slot as pdev and call fn for each */
57 enum companion_action action) 60static void for_each_companion(struct pci_dev *pdev, struct usb_hcd *hcd,
61 companion_fn fn)
58{ 62{
59 struct pci_dev *companion; 63 struct pci_dev *companion;
60 struct usb_hcd *companion_hcd; 64 struct usb_hcd *companion_hcd;
61 unsigned int slot = PCI_SLOT(pdev->devfn); 65 unsigned int slot = PCI_SLOT(pdev->devfn);
62 66
63 /* Iterate through other PCI functions in the same slot. 67 /*
64 * If pdev is OHCI or UHCI then we are looking for EHCI, and 68 * Iterate through other PCI functions in the same slot.
65 * vice versa. 69 * If the function's drvdata isn't set then it isn't bound to
70 * a USB host controller driver, so skip it.
66 */ 71 */
67 companion = NULL; 72 companion = NULL;
68 for_each_pci_dev(companion) { 73 for_each_pci_dev(companion) {
69 if (companion->bus != pdev->bus || 74 if (companion->bus != pdev->bus ||
70 PCI_SLOT(companion->devfn) != slot) 75 PCI_SLOT(companion->devfn) != slot)
71 continue; 76 continue;
72
73 companion_hcd = pci_get_drvdata(companion); 77 companion_hcd = pci_get_drvdata(companion);
74 if (!companion_hcd) 78 if (!companion_hcd)
75 continue; 79 continue;
76 80 fn(pdev, hcd, companion, companion_hcd);
77 /* For SET_HS_COMPANION, store a pointer to the EHCI bus in
78 * the OHCI/UHCI companion bus structure.
79 * For CLEAR_HS_COMPANION, clear the pointer to the EHCI bus
80 * in the OHCI/UHCI companion bus structure.
81 * For WAIT_FOR_COMPANIONS, wait until the OHCI/UHCI
82 * companion controllers have fully resumed.
83 */
84
85 if ((pdev->class == CL_OHCI || pdev->class == CL_UHCI) &&
86 companion->class == CL_EHCI) {
87 /* action must be SET_HS_COMPANION */
88 dev_dbg(&companion->dev, "HS companion for %s\n",
89 dev_name(&pdev->dev));
90 hcd->self.hs_companion = &companion_hcd->self;
91
92 } else if (pdev->class == CL_EHCI &&
93 (companion->class == CL_OHCI ||
94 companion->class == CL_UHCI)) {
95 switch (action) {
96 case SET_HS_COMPANION:
97 dev_dbg(&pdev->dev, "HS companion for %s\n",
98 dev_name(&companion->dev));
99 companion_hcd->self.hs_companion = &hcd->self;
100 break;
101 case CLEAR_HS_COMPANION:
102 companion_hcd->self.hs_companion = NULL;
103 break;
104 case WAIT_FOR_COMPANIONS:
105 device_pm_wait_for_dev(&pdev->dev,
106 &companion->dev);
107 break;
108 }
109 }
110 } 81 }
111} 82}
112 83
113static void set_hs_companion(struct pci_dev *pdev, struct usb_hcd *hcd) 84/*
85 * We're about to add an EHCI controller, which will unceremoniously grab
86 * all the port connections away from its companions. To prevent annoying
87 * error messages, lock the companion's root hub and gracefully unconfigure
88 * it beforehand. Leave it locked until the EHCI controller is all set.
89 */
90static void ehci_pre_add(struct pci_dev *pdev, struct usb_hcd *hcd,
91 struct pci_dev *companion, struct usb_hcd *companion_hcd)
114{ 92{
115 mutex_lock(&companions_mutex); 93 struct usb_device *udev;
116 dev_set_drvdata(&pdev->dev, hcd); 94
117 companion_common(pdev, hcd, SET_HS_COMPANION); 95 if (is_ohci_or_uhci(companion)) {
118 mutex_unlock(&companions_mutex); 96 udev = companion_hcd->self.root_hub;
97 usb_lock_device(udev);
98 usb_set_configuration(udev, 0);
99 }
119} 100}
120 101
121static void clear_hs_companion(struct pci_dev *pdev, struct usb_hcd *hcd) 102/*
103 * Adding the EHCI controller has either succeeded or failed. Set the
104 * companion pointer accordingly, and in either case, reconfigure and
105 * unlock the root hub.
106 */
107static void ehci_post_add(struct pci_dev *pdev, struct usb_hcd *hcd,
108 struct pci_dev *companion, struct usb_hcd *companion_hcd)
122{ 109{
123 mutex_lock(&companions_mutex); 110 struct usb_device *udev;
124 dev_set_drvdata(&pdev->dev, NULL);
125 111
126 /* If pdev is OHCI or UHCI, just clear its hs_companion pointer */ 112 if (is_ohci_or_uhci(companion)) {
127 if (pdev->class == CL_OHCI || pdev->class == CL_UHCI) 113 if (dev_get_drvdata(&pdev->dev)) { /* Succeeded */
128 hcd->self.hs_companion = NULL; 114 dev_dbg(&pdev->dev, "HS companion for %s\n",
115 dev_name(&companion->dev));
116 companion_hcd->self.hs_companion = &hcd->self;
117 }
118 udev = companion_hcd->self.root_hub;
119 usb_set_configuration(udev, 1);
120 usb_unlock_device(udev);
121 }
122}
129 123
130 /* Otherwise search for companion buses and clear their pointers */ 124/*
131 else 125 * We just added a non-EHCI controller. Find the EHCI controller to
132 companion_common(pdev, hcd, CLEAR_HS_COMPANION); 126 * which it is a companion, and store a pointer to the bus structure.
133 mutex_unlock(&companions_mutex); 127 */
128static void non_ehci_add(struct pci_dev *pdev, struct usb_hcd *hcd,
129 struct pci_dev *companion, struct usb_hcd *companion_hcd)
130{
131 if (is_ohci_or_uhci(pdev) && companion->class == CL_EHCI) {
132 dev_dbg(&pdev->dev, "FS/LS companion for %s\n",
133 dev_name(&companion->dev));
134 hcd->self.hs_companion = &companion_hcd->self;
135 }
134} 136}
135 137
136static void wait_for_companions(struct pci_dev *pdev, struct usb_hcd *hcd) 138/* We are removing an EHCI controller. Clear the companions' pointers. */
139static void ehci_remove(struct pci_dev *pdev, struct usb_hcd *hcd,
140 struct pci_dev *companion, struct usb_hcd *companion_hcd)
137{ 141{
138 /* Only EHCI controllers need to wait. 142 if (is_ohci_or_uhci(companion))
139 * No locking is needed because a controller cannot be resumed 143 companion_hcd->self.hs_companion = NULL;
140 * while one of its companions is getting unbound.
141 */
142 if (pdev->class == CL_EHCI)
143 companion_common(pdev, hcd, WAIT_FOR_COMPANIONS);
144} 144}
145 145
146#else /* !CONFIG_PM_SLEEP */ 146#ifdef CONFIG_PM
147 147
148static inline void set_hs_companion(struct pci_dev *d, struct usb_hcd *h) {} 148/* An EHCI controller must wait for its companions before resuming. */
149static inline void clear_hs_companion(struct pci_dev *d, struct usb_hcd *h) {} 149static void ehci_wait_for_companions(struct pci_dev *pdev, struct usb_hcd *hcd,
150static inline void wait_for_companions(struct pci_dev *d, struct usb_hcd *h) {} 150 struct pci_dev *companion, struct usb_hcd *companion_hcd)
151{
152 if (is_ohci_or_uhci(companion))
153 device_pm_wait_for_dev(&pdev->dev, &companion->dev);
154}
151 155
152#endif /* !CONFIG_PM_SLEEP */ 156#endif /* CONFIG_PM */
153 157
154/*-------------------------------------------------------------------------*/ 158/*-------------------------------------------------------------------------*/
155 159
@@ -217,7 +221,7 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
217 driver->description)) { 221 driver->description)) {
218 dev_dbg(&dev->dev, "controller already in use\n"); 222 dev_dbg(&dev->dev, "controller already in use\n");
219 retval = -EBUSY; 223 retval = -EBUSY;
220 goto clear_companion; 224 goto put_hcd;
221 } 225 }
222 hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); 226 hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
223 if (hcd->regs == NULL) { 227 if (hcd->regs == NULL) {
@@ -244,16 +248,35 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
244 if (region == PCI_ROM_RESOURCE) { 248 if (region == PCI_ROM_RESOURCE) {
245 dev_dbg(&dev->dev, "no i/o regions available\n"); 249 dev_dbg(&dev->dev, "no i/o regions available\n");
246 retval = -EBUSY; 250 retval = -EBUSY;
247 goto clear_companion; 251 goto put_hcd;
248 } 252 }
249 } 253 }
250 254
251 pci_set_master(dev); 255 pci_set_master(dev);
252 256
253 retval = usb_add_hcd(hcd, hcd_irq, IRQF_SHARED); 257 /* Note: dev_set_drvdata must be called while holding the rwsem */
258 if (dev->class == CL_EHCI) {
259 down_write(&companions_rwsem);
260 dev_set_drvdata(&dev->dev, hcd);
261 for_each_companion(dev, hcd, ehci_pre_add);
262 retval = usb_add_hcd(hcd, hcd_irq, IRQF_SHARED);
263 if (retval != 0)
264 dev_set_drvdata(&dev->dev, NULL);
265 for_each_companion(dev, hcd, ehci_post_add);
266 up_write(&companions_rwsem);
267 } else {
268 down_read(&companions_rwsem);
269 dev_set_drvdata(&dev->dev, hcd);
270 retval = usb_add_hcd(hcd, hcd_irq, IRQF_SHARED);
271 if (retval != 0)
272 dev_set_drvdata(&dev->dev, NULL);
273 else
274 for_each_companion(dev, hcd, non_ehci_add);
275 up_read(&companions_rwsem);
276 }
277
254 if (retval != 0) 278 if (retval != 0)
255 goto unmap_registers; 279 goto unmap_registers;
256 set_hs_companion(dev, hcd);
257 280
258 if (pci_dev_run_wake(dev)) 281 if (pci_dev_run_wake(dev))
259 pm_runtime_put_noidle(&dev->dev); 282 pm_runtime_put_noidle(&dev->dev);
@@ -266,8 +289,7 @@ release_mem_region:
266 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 289 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
267 } else 290 } else
268 release_region(hcd->rsrc_start, hcd->rsrc_len); 291 release_region(hcd->rsrc_start, hcd->rsrc_len);
269clear_companion: 292put_hcd:
270 clear_hs_companion(dev, hcd);
271 usb_put_hcd(hcd); 293 usb_put_hcd(hcd);
272disable_pci: 294disable_pci:
273 pci_disable_device(dev); 295 pci_disable_device(dev);
@@ -310,14 +332,29 @@ void usb_hcd_pci_remove(struct pci_dev *dev)
310 usb_hcd_irq(0, hcd); 332 usb_hcd_irq(0, hcd);
311 local_irq_enable(); 333 local_irq_enable();
312 334
313 usb_remove_hcd(hcd); 335 /* Note: dev_set_drvdata must be called while holding the rwsem */
336 if (dev->class == CL_EHCI) {
337 down_write(&companions_rwsem);
338 for_each_companion(dev, hcd, ehci_remove);
339 usb_remove_hcd(hcd);
340 dev_set_drvdata(&dev->dev, NULL);
341 up_write(&companions_rwsem);
342 } else {
343 /* Not EHCI; just clear the companion pointer */
344 down_read(&companions_rwsem);
345 hcd->self.hs_companion = NULL;
346 usb_remove_hcd(hcd);
347 dev_set_drvdata(&dev->dev, NULL);
348 up_read(&companions_rwsem);
349 }
350
314 if (hcd->driver->flags & HCD_MEMORY) { 351 if (hcd->driver->flags & HCD_MEMORY) {
315 iounmap(hcd->regs); 352 iounmap(hcd->regs);
316 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 353 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
317 } else { 354 } else {
318 release_region(hcd->rsrc_start, hcd->rsrc_len); 355 release_region(hcd->rsrc_start, hcd->rsrc_len);
319 } 356 }
320 clear_hs_companion(dev, hcd); 357
321 usb_put_hcd(hcd); 358 usb_put_hcd(hcd);
322 pci_disable_device(dev); 359 pci_disable_device(dev);
323} 360}
@@ -463,8 +500,15 @@ static int resume_common(struct device *dev, int event)
463 pci_set_master(pci_dev); 500 pci_set_master(pci_dev);
464 501
465 if (hcd->driver->pci_resume && !HCD_DEAD(hcd)) { 502 if (hcd->driver->pci_resume && !HCD_DEAD(hcd)) {
466 if (event != PM_EVENT_AUTO_RESUME) 503
467 wait_for_companions(pci_dev, hcd); 504 /*
505 * Only EHCI controllers have to wait for their companions.
506 * No locking is needed because PCI controller drivers do not
507 * get unbound during system resume.
508 */
509 if (pci_dev->class == CL_EHCI && event != PM_EVENT_AUTO_RESUME)
510 for_each_companion(pci_dev, hcd,
511 ehci_wait_for_companions);
468 512
469 retval = hcd->driver->pci_resume(hcd, 513 retval = hcd->driver->pci_resume(hcd,
470 event == PM_EVENT_RESTORE); 514 event == PM_EVENT_RESTORE);
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index f9ec44cbb82f..d53547d2e4c7 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2125,7 +2125,7 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg)
2125 2125
2126#endif /* CONFIG_PM */ 2126#endif /* CONFIG_PM */
2127 2127
2128#ifdef CONFIG_USB_SUSPEND 2128#ifdef CONFIG_PM_RUNTIME
2129 2129
2130/* Workqueue routine for root-hub remote wakeup */ 2130/* Workqueue routine for root-hub remote wakeup */
2131static void hcd_resume_work(struct work_struct *work) 2131static void hcd_resume_work(struct work_struct *work)
@@ -2160,7 +2160,7 @@ void usb_hcd_resume_root_hub (struct usb_hcd *hcd)
2160} 2160}
2161EXPORT_SYMBOL_GPL(usb_hcd_resume_root_hub); 2161EXPORT_SYMBOL_GPL(usb_hcd_resume_root_hub);
2162 2162
2163#endif /* CONFIG_USB_SUSPEND */ 2163#endif /* CONFIG_PM_RUNTIME */
2164 2164
2165/*-------------------------------------------------------------------------*/ 2165/*-------------------------------------------------------------------------*/
2166 2166
@@ -2336,7 +2336,7 @@ struct usb_hcd *usb_create_shared_hcd(const struct hc_driver *driver,
2336 init_timer(&hcd->rh_timer); 2336 init_timer(&hcd->rh_timer);
2337 hcd->rh_timer.function = rh_timer_func; 2337 hcd->rh_timer.function = rh_timer_func;
2338 hcd->rh_timer.data = (unsigned long) hcd; 2338 hcd->rh_timer.data = (unsigned long) hcd;
2339#ifdef CONFIG_USB_SUSPEND 2339#ifdef CONFIG_PM_RUNTIME
2340 INIT_WORK(&hcd->wakeup_work, hcd_resume_work); 2340 INIT_WORK(&hcd->wakeup_work, hcd_resume_work);
2341#endif 2341#endif
2342 2342
@@ -2590,7 +2590,7 @@ error_create_attr_group:
2590 hcd->rh_registered = 0; 2590 hcd->rh_registered = 0;
2591 spin_unlock_irq(&hcd_root_hub_lock); 2591 spin_unlock_irq(&hcd_root_hub_lock);
2592 2592
2593#ifdef CONFIG_USB_SUSPEND 2593#ifdef CONFIG_PM_RUNTIME
2594 cancel_work_sync(&hcd->wakeup_work); 2594 cancel_work_sync(&hcd->wakeup_work);
2595#endif 2595#endif
2596 mutex_lock(&usb_bus_list_lock); 2596 mutex_lock(&usb_bus_list_lock);
@@ -2645,7 +2645,7 @@ void usb_remove_hcd(struct usb_hcd *hcd)
2645 hcd->rh_registered = 0; 2645 hcd->rh_registered = 0;
2646 spin_unlock_irq (&hcd_root_hub_lock); 2646 spin_unlock_irq (&hcd_root_hub_lock);
2647 2647
2648#ifdef CONFIG_USB_SUSPEND 2648#ifdef CONFIG_PM_RUNTIME
2649 cancel_work_sync(&hcd->wakeup_work); 2649 cancel_work_sync(&hcd->wakeup_work);
2650#endif 2650#endif
2651 2651
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 5480352f984d..feef9351463d 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -555,8 +555,9 @@ static int hub_port_status(struct usb_hub *hub, int port1,
555 mutex_lock(&hub->status_mutex); 555 mutex_lock(&hub->status_mutex);
556 ret = get_port_status(hub->hdev, port1, &hub->status->port); 556 ret = get_port_status(hub->hdev, port1, &hub->status->port);
557 if (ret < 4) { 557 if (ret < 4) {
558 dev_err(hub->intfdev, 558 if (ret != -ENODEV)
559 "%s failed (err = %d)\n", __func__, ret); 559 dev_err(hub->intfdev,
560 "%s failed (err = %d)\n", __func__, ret);
560 if (ret >= 0) 561 if (ret >= 0)
561 ret = -EIO; 562 ret = -EIO;
562 } else { 563 } else {
@@ -699,7 +700,7 @@ static void hub_tt_work(struct work_struct *work)
699 /* drop lock so HCD can concurrently report other TT errors */ 700 /* drop lock so HCD can concurrently report other TT errors */
700 spin_unlock_irqrestore (&hub->tt.lock, flags); 701 spin_unlock_irqrestore (&hub->tt.lock, flags);
701 status = hub_clear_tt_buffer (hdev, clear->devinfo, clear->tt); 702 status = hub_clear_tt_buffer (hdev, clear->devinfo, clear->tt);
702 if (status) 703 if (status && status != -ENODEV)
703 dev_err (&hdev->dev, 704 dev_err (&hdev->dev,
704 "clear tt %d (%04x) error %d\n", 705 "clear tt %d (%04x) error %d\n",
705 clear->tt, clear->devinfo, status); 706 clear->tt, clear->devinfo, status);
@@ -837,10 +838,11 @@ static int hub_hub_status(struct usb_hub *hub,
837 838
838 mutex_lock(&hub->status_mutex); 839 mutex_lock(&hub->status_mutex);
839 ret = get_hub_status(hub->hdev, &hub->status->hub); 840 ret = get_hub_status(hub->hdev, &hub->status->hub);
840 if (ret < 0) 841 if (ret < 0) {
841 dev_err (hub->intfdev, 842 if (ret != -ENODEV)
842 "%s failed (err = %d)\n", __func__, ret); 843 dev_err(hub->intfdev,
843 else { 844 "%s failed (err = %d)\n", __func__, ret);
845 } else {
844 *status = le16_to_cpu(hub->status->hub.wHubStatus); 846 *status = le16_to_cpu(hub->status->hub.wHubStatus);
845 *change = le16_to_cpu(hub->status->hub.wHubChange); 847 *change = le16_to_cpu(hub->status->hub.wHubChange);
846 ret = 0; 848 ret = 0;
@@ -877,11 +879,8 @@ static int hub_usb3_port_disable(struct usb_hub *hub, int port1)
877 return -EINVAL; 879 return -EINVAL;
878 880
879 ret = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_SS_DISABLED); 881 ret = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_SS_DISABLED);
880 if (ret) { 882 if (ret)
881 dev_err(hub->intfdev, "cannot disable port %d (err = %d)\n",
882 port1, ret);
883 return ret; 883 return ret;
884 }
885 884
886 /* Wait for the link to enter the disabled state. */ 885 /* Wait for the link to enter the disabled state. */
887 for (total_time = 0; ; total_time += HUB_DEBOUNCE_STEP) { 886 for (total_time = 0; ; total_time += HUB_DEBOUNCE_STEP) {
@@ -918,7 +917,7 @@ static int hub_port_disable(struct usb_hub *hub, int port1, int set_state)
918 ret = usb_clear_port_feature(hdev, port1, 917 ret = usb_clear_port_feature(hdev, port1,
919 USB_PORT_FEAT_ENABLE); 918 USB_PORT_FEAT_ENABLE);
920 } 919 }
921 if (ret) 920 if (ret && ret != -ENODEV)
922 dev_err(hub->intfdev, "cannot disable port %d (err = %d)\n", 921 dev_err(hub->intfdev, "cannot disable port %d (err = %d)\n",
923 port1, ret); 922 port1, ret);
924 return ret; 923 return ret;
@@ -1317,6 +1316,10 @@ static int hub_configure(struct usb_hub *hub,
1317 message = "hub has too many ports!"; 1316 message = "hub has too many ports!";
1318 ret = -ENODEV; 1317 ret = -ENODEV;
1319 goto fail; 1318 goto fail;
1319 } else if (hub->descriptor->bNbrPorts == 0) {
1320 message = "hub doesn't have any ports!";
1321 ret = -ENODEV;
1322 goto fail;
1320 } 1323 }
1321 1324
1322 hdev->maxchild = hub->descriptor->bNbrPorts; 1325 hdev->maxchild = hub->descriptor->bNbrPorts;
@@ -2192,8 +2195,9 @@ static int usb_enumerate_device(struct usb_device *udev)
2192 if (udev->config == NULL) { 2195 if (udev->config == NULL) {
2193 err = usb_get_configuration(udev); 2196 err = usb_get_configuration(udev);
2194 if (err < 0) { 2197 if (err < 0) {
2195 dev_err(&udev->dev, "can't read configurations, error %d\n", 2198 if (err != -ENODEV)
2196 err); 2199 dev_err(&udev->dev, "can't read configurations, error %d\n",
2200 err);
2197 return err; 2201 return err;
2198 } 2202 }
2199 } 2203 }
@@ -2640,14 +2644,16 @@ static int hub_port_reset(struct usb_hub *hub, int port1,
2640 status = set_port_feature(hub->hdev, port1, (warm ? 2644 status = set_port_feature(hub->hdev, port1, (warm ?
2641 USB_PORT_FEAT_BH_PORT_RESET : 2645 USB_PORT_FEAT_BH_PORT_RESET :
2642 USB_PORT_FEAT_RESET)); 2646 USB_PORT_FEAT_RESET));
2643 if (status) { 2647 if (status == -ENODEV) {
2648 ; /* The hub is gone */
2649 } else if (status) {
2644 dev_err(hub->intfdev, 2650 dev_err(hub->intfdev,
2645 "cannot %sreset port %d (err = %d)\n", 2651 "cannot %sreset port %d (err = %d)\n",
2646 warm ? "warm " : "", port1, status); 2652 warm ? "warm " : "", port1, status);
2647 } else { 2653 } else {
2648 status = hub_port_wait_reset(hub, port1, udev, delay, 2654 status = hub_port_wait_reset(hub, port1, udev, delay,
2649 warm); 2655 warm);
2650 if (status && status != -ENOTCONN) 2656 if (status && status != -ENOTCONN && status != -ENODEV)
2651 dev_dbg(hub->intfdev, 2657 dev_dbg(hub->intfdev,
2652 "port_wait_reset: err = %d\n", 2658 "port_wait_reset: err = %d\n",
2653 status); 2659 status);
@@ -2821,7 +2827,7 @@ void usb_enable_ltm(struct usb_device *udev)
2821} 2827}
2822EXPORT_SYMBOL_GPL(usb_enable_ltm); 2828EXPORT_SYMBOL_GPL(usb_enable_ltm);
2823 2829
2824#ifdef CONFIG_USB_SUSPEND 2830#ifdef CONFIG_PM
2825/* 2831/*
2826 * usb_disable_function_remotewakeup - disable usb3.0 2832 * usb_disable_function_remotewakeup - disable usb3.0
2827 * device's function remote wakeup 2833 * device's function remote wakeup
@@ -2880,9 +2886,11 @@ static int usb_disable_function_remotewakeup(struct usb_device *udev)
2880 * Linux (2.6) currently has NO mechanisms to initiate that: no khubd 2886 * Linux (2.6) currently has NO mechanisms to initiate that: no khubd
2881 * timer, no SRP, no requests through sysfs. 2887 * timer, no SRP, no requests through sysfs.
2882 * 2888 *
2883 * If CONFIG_USB_SUSPEND isn't enabled, devices only really suspend when 2889 * If Runtime PM isn't enabled or used, non-SuperSpeed devices really get
2884 * the root hub for their bus goes into global suspend ... so we don't 2890 * suspended only when their bus goes into global suspend (i.e., the root
2885 * (falsely) update the device power state to say it suspended. 2891 * hub is suspended). Nevertheless, we change @udev->state to
2892 * USB_STATE_SUSPENDED as this is the device's "logical" state. The actual
2893 * upstream port setting is stored in @udev->port_is_suspended.
2886 * 2894 *
2887 * Returns 0 on success, else negative errno. 2895 * Returns 0 on success, else negative errno.
2888 */ 2896 */
@@ -2893,6 +2901,7 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
2893 enum pm_qos_flags_status pm_qos_stat; 2901 enum pm_qos_flags_status pm_qos_stat;
2894 int port1 = udev->portnum; 2902 int port1 = udev->portnum;
2895 int status; 2903 int status;
2904 bool really_suspend = true;
2896 2905
2897 /* enable remote wakeup when appropriate; this lets the device 2906 /* enable remote wakeup when appropriate; this lets the device
2898 * wake up the upstream hub (including maybe the root hub). 2907 * wake up the upstream hub (including maybe the root hub).
@@ -2949,9 +2958,19 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
2949 /* see 7.1.7.6 */ 2958 /* see 7.1.7.6 */
2950 if (hub_is_superspeed(hub->hdev)) 2959 if (hub_is_superspeed(hub->hdev))
2951 status = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_U3); 2960 status = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_U3);
2952 else 2961 else if (PMSG_IS_AUTO(msg))
2953 status = set_port_feature(hub->hdev, port1, 2962 status = set_port_feature(hub->hdev, port1,
2954 USB_PORT_FEAT_SUSPEND); 2963 USB_PORT_FEAT_SUSPEND);
2964 /*
2965 * For system suspend, we do not need to enable the suspend feature
2966 * on individual USB-2 ports. The devices will automatically go
2967 * into suspend a few ms after the root hub stops sending packets.
2968 * The USB 2.0 spec calls this "global suspend".
2969 */
2970 else {
2971 really_suspend = false;
2972 status = 0;
2973 }
2955 if (status) { 2974 if (status) {
2956 dev_dbg(hub->intfdev, "can't suspend port %d, status %d\n", 2975 dev_dbg(hub->intfdev, "can't suspend port %d, status %d\n",
2957 port1, status); 2976 port1, status);
@@ -2987,8 +3006,10 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
2987 (PMSG_IS_AUTO(msg) ? "auto-" : ""), 3006 (PMSG_IS_AUTO(msg) ? "auto-" : ""),
2988 udev->do_remote_wakeup); 3007 udev->do_remote_wakeup);
2989 usb_set_device_state(udev, USB_STATE_SUSPENDED); 3008 usb_set_device_state(udev, USB_STATE_SUSPENDED);
2990 udev->port_is_suspended = 1; 3009 if (really_suspend) {
2991 msleep(10); 3010 udev->port_is_suspended = 1;
3011 msleep(10);
3012 }
2992 } 3013 }
2993 3014
2994 /* 3015 /*
@@ -3226,6 +3247,10 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg)
3226 return status; 3247 return status;
3227} 3248}
3228 3249
3250#endif /* CONFIG_PM */
3251
3252#ifdef CONFIG_PM_RUNTIME
3253
3229/* caller has locked udev */ 3254/* caller has locked udev */
3230int usb_remote_wakeup(struct usb_device *udev) 3255int usb_remote_wakeup(struct usb_device *udev)
3231{ 3256{
@@ -3242,38 +3267,6 @@ int usb_remote_wakeup(struct usb_device *udev)
3242 return status; 3267 return status;
3243} 3268}
3244 3269
3245#else /* CONFIG_USB_SUSPEND */
3246
3247/* When CONFIG_USB_SUSPEND isn't set, we never suspend or resume any ports. */
3248
3249int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
3250{
3251 return 0;
3252}
3253
3254/* However we may need to do a reset-resume */
3255
3256int usb_port_resume(struct usb_device *udev, pm_message_t msg)
3257{
3258 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent);
3259 int port1 = udev->portnum;
3260 int status;
3261 u16 portchange, portstatus;
3262
3263 status = hub_port_status(hub, port1, &portstatus, &portchange);
3264 status = check_port_resume_type(udev,
3265 hub, port1, status, portchange, portstatus);
3266
3267 if (status) {
3268 dev_dbg(&udev->dev, "can't resume, status %d\n", status);
3269 hub_port_logical_disconnect(hub, port1);
3270 } else if (udev->reset_resume) {
3271 dev_dbg(&udev->dev, "reset-resume\n");
3272 status = usb_reset_and_verify_device(udev);
3273 }
3274 return status;
3275}
3276
3277#endif 3270#endif
3278 3271
3279static int check_ports_changed(struct usb_hub *hub) 3272static int check_ports_changed(struct usb_hub *hub)
@@ -4090,9 +4083,9 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
4090 goto fail; 4083 goto fail;
4091 } 4084 }
4092 if (r) { 4085 if (r) {
4093 dev_err(&udev->dev, 4086 if (r != -ENODEV)
4094 "device descriptor read/64, error %d\n", 4087 dev_err(&udev->dev, "device descriptor read/64, error %d\n",
4095 r); 4088 r);
4096 retval = -EMSGSIZE; 4089 retval = -EMSGSIZE;
4097 continue; 4090 continue;
4098 } 4091 }
@@ -4112,9 +4105,9 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
4112 msleep(200); 4105 msleep(200);
4113 } 4106 }
4114 if (retval < 0) { 4107 if (retval < 0) {
4115 dev_err(&udev->dev, 4108 if (retval != -ENODEV)
4116 "device not accepting address %d, error %d\n", 4109 dev_err(&udev->dev, "device not accepting address %d, error %d\n",
4117 devnum, retval); 4110 devnum, retval);
4118 goto fail; 4111 goto fail;
4119 } 4112 }
4120 if (udev->speed == USB_SPEED_SUPER) { 4113 if (udev->speed == USB_SPEED_SUPER) {
@@ -4136,7 +4129,8 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
4136 4129
4137 retval = usb_get_device_descriptor(udev, 8); 4130 retval = usb_get_device_descriptor(udev, 8);
4138 if (retval < 8) { 4131 if (retval < 8) {
4139 dev_err(&udev->dev, 4132 if (retval != -ENODEV)
4133 dev_err(&udev->dev,
4140 "device descriptor read/8, error %d\n", 4134 "device descriptor read/8, error %d\n",
4141 retval); 4135 retval);
4142 if (retval >= 0) 4136 if (retval >= 0)
@@ -4190,8 +4184,9 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
4190 4184
4191 retval = usb_get_device_descriptor(udev, USB_DT_DEVICE_SIZE); 4185 retval = usb_get_device_descriptor(udev, USB_DT_DEVICE_SIZE);
4192 if (retval < (signed)sizeof(udev->descriptor)) { 4186 if (retval < (signed)sizeof(udev->descriptor)) {
4193 dev_err(&udev->dev, "device descriptor read/all, error %d\n", 4187 if (retval != -ENODEV)
4194 retval); 4188 dev_err(&udev->dev, "device descriptor read/all, error %d\n",
4189 retval);
4195 if (retval >= 0) 4190 if (retval >= 0)
4196 retval = -ENOMSG; 4191 retval = -ENOMSG;
4197 goto fail; 4192 goto fail;
@@ -4333,7 +4328,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
4333 if (portstatus & USB_PORT_STAT_ENABLE) { 4328 if (portstatus & USB_PORT_STAT_ENABLE) {
4334 status = 0; /* Nothing to do */ 4329 status = 0; /* Nothing to do */
4335 4330
4336#ifdef CONFIG_USB_SUSPEND 4331#ifdef CONFIG_PM_RUNTIME
4337 } else if (udev->state == USB_STATE_SUSPENDED && 4332 } else if (udev->state == USB_STATE_SUSPENDED &&
4338 udev->persist_enabled) { 4333 udev->persist_enabled) {
4339 /* For a suspended device, treat this as a 4334 /* For a suspended device, treat this as a
@@ -4373,7 +4368,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
4373 USB_PORT_STAT_C_ENABLE)) { 4368 USB_PORT_STAT_C_ENABLE)) {
4374 status = hub_port_debounce_be_stable(hub, port1); 4369 status = hub_port_debounce_be_stable(hub, port1);
4375 if (status < 0) { 4370 if (status < 0) {
4376 if (printk_ratelimit()) 4371 if (status != -ENODEV && printk_ratelimit())
4377 dev_err(hub_dev, "connect-debounce failed, " 4372 dev_err(hub_dev, "connect-debounce failed, "
4378 "port %d disabled\n", port1); 4373 "port %d disabled\n", port1);
4379 portstatus &= ~USB_PORT_STAT_CONNECTION; 4374 portstatus &= ~USB_PORT_STAT_CONNECTION;
@@ -4402,6 +4397,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
4402 else 4397 else
4403 unit_load = 100; 4398 unit_load = 100;
4404 4399
4400 status = 0;
4405 for (i = 0; i < SET_CONFIG_TRIES; i++) { 4401 for (i = 0; i < SET_CONFIG_TRIES; i++) {
4406 4402
4407 /* reallocate for each attempt, since references 4403 /* reallocate for each attempt, since references
@@ -4526,9 +4522,11 @@ loop:
4526 } 4522 }
4527 if (hub->hdev->parent || 4523 if (hub->hdev->parent ||
4528 !hcd->driver->port_handed_over || 4524 !hcd->driver->port_handed_over ||
4529 !(hcd->driver->port_handed_over)(hcd, port1)) 4525 !(hcd->driver->port_handed_over)(hcd, port1)) {
4530 dev_err(hub_dev, "unable to enumerate USB device on port %d\n", 4526 if (status != -ENOTCONN && status != -ENODEV)
4531 port1); 4527 dev_err(hub_dev, "unable to enumerate USB device on port %d\n",
4528 port1);
4529 }
4532 4530
4533done: 4531done:
4534 hub_port_disable(hub, port1, 1); 4532 hub_port_disable(hub, port1, 1);
diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index 65d4e55552c6..b8bad294eeb8 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -70,7 +70,7 @@ static void usb_port_device_release(struct device *dev)
70 kfree(port_dev); 70 kfree(port_dev);
71} 71}
72 72
73#ifdef CONFIG_USB_SUSPEND 73#ifdef CONFIG_PM_RUNTIME
74static int usb_port_runtime_resume(struct device *dev) 74static int usb_port_runtime_resume(struct device *dev)
75{ 75{
76 struct usb_port *port_dev = to_usb_port(dev); 76 struct usb_port *port_dev = to_usb_port(dev);
@@ -138,7 +138,7 @@ static int usb_port_runtime_suspend(struct device *dev)
138#endif 138#endif
139 139
140static const struct dev_pm_ops usb_port_pm_ops = { 140static const struct dev_pm_ops usb_port_pm_ops = {
141#ifdef CONFIG_USB_SUSPEND 141#ifdef CONFIG_PM_RUNTIME
142 .runtime_suspend = usb_port_runtime_suspend, 142 .runtime_suspend = usb_port_runtime_suspend,
143 .runtime_resume = usb_port_runtime_resume, 143 .runtime_resume = usb_port_runtime_resume,
144 .runtime_idle = pm_generic_runtime_idle, 144 .runtime_idle = pm_generic_runtime_idle,
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index 3113c1d71442..ab5638d9c707 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -201,20 +201,14 @@ void usb_detect_quirks(struct usb_device *udev)
201 dev_dbg(&udev->dev, "USB quirks for this device: %x\n", 201 dev_dbg(&udev->dev, "USB quirks for this device: %x\n",
202 udev->quirks); 202 udev->quirks);
203 203
204 /* For the present, all devices default to USB-PERSIST enabled */ 204#ifdef CONFIG_USB_DEFAULT_PERSIST
205#if 0 /* was: #ifdef CONFIG_PM */ 205 if (!(udev->quirks & USB_QUIRK_RESET))
206 /* Hubs are automatically enabled for USB-PERSIST */
207 if (udev->descriptor.bDeviceClass == USB_CLASS_HUB)
208 udev->persist_enabled = 1; 206 udev->persist_enabled = 1;
209
210#else 207#else
211 /* In the absence of PM, we can safely enable USB-PERSIST 208 /* Hubs are automatically enabled for USB-PERSIST */
212 * for all devices. It will affect things like hub resets 209 if (udev->descriptor.bDeviceClass == USB_CLASS_HUB)
213 * and EMF-related port disables.
214 */
215 if (!(udev->quirks & USB_QUIRK_RESET))
216 udev->persist_enabled = 1; 210 udev->persist_enabled = 1;
217#endif /* CONFIG_PM */ 211#endif /* CONFIG_USB_DEFAULT_PERSIST */
218} 212}
219 213
220void usb_detect_interface_quirks(struct usb_device *udev) 214void usb_detect_interface_quirks(struct usb_device *udev)
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index 3f81a3dc6867..aa38db44818a 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -338,7 +338,7 @@ static void remove_persist_attributes(struct device *dev)
338 338
339#endif /* CONFIG_PM */ 339#endif /* CONFIG_PM */
340 340
341#ifdef CONFIG_USB_SUSPEND 341#ifdef CONFIG_PM_RUNTIME
342 342
343static ssize_t 343static ssize_t
344show_connected_duration(struct device *dev, struct device_attribute *attr, 344show_connected_duration(struct device *dev, struct device_attribute *attr,
@@ -544,7 +544,7 @@ static void remove_power_attributes(struct device *dev)
544#define add_power_attributes(dev) 0 544#define add_power_attributes(dev) 0
545#define remove_power_attributes(dev) do {} while (0) 545#define remove_power_attributes(dev) do {} while (0)
546 546
547#endif /* CONFIG_USB_SUSPEND */ 547#endif /* CONFIG_PM_RUNTIME */
548 548
549 549
550/* Descriptor fields */ 550/* Descriptor fields */
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index e0d9d948218c..16927fa88fbd 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -683,10 +683,13 @@ EXPORT_SYMBOL_GPL(usb_kill_urb);
683void usb_poison_urb(struct urb *urb) 683void usb_poison_urb(struct urb *urb)
684{ 684{
685 might_sleep(); 685 might_sleep();
686 if (!(urb && urb->dev && urb->ep)) 686 if (!urb)
687 return; 687 return;
688 atomic_inc(&urb->reject); 688 atomic_inc(&urb->reject);
689 689
690 if (!urb->dev || !urb->ep)
691 return;
692
690 usb_hcd_unlink_urb(urb, -ENOENT); 693 usb_hcd_unlink_urb(urb, -ENOENT);
691 wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0); 694 wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0);
692} 695}
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index e092b414dc50..b10da720f2b4 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -49,7 +49,7 @@ const char *usbcore_name = "usbcore";
49 49
50static bool nousb; /* Disable USB when built into kernel image */ 50static bool nousb; /* Disable USB when built into kernel image */
51 51
52#ifdef CONFIG_USB_SUSPEND 52#ifdef CONFIG_PM_RUNTIME
53static int usb_autosuspend_delay = 2; /* Default delay value, 53static int usb_autosuspend_delay = 2; /* Default delay value,
54 * in seconds */ 54 * in seconds */
55module_param_named(autosuspend, usb_autosuspend_delay, int, 0644); 55module_param_named(autosuspend, usb_autosuspend_delay, int, 0644);
@@ -307,7 +307,7 @@ static const struct dev_pm_ops usb_device_pm_ops = {
307 .thaw = usb_dev_thaw, 307 .thaw = usb_dev_thaw,
308 .poweroff = usb_dev_poweroff, 308 .poweroff = usb_dev_poweroff,
309 .restore = usb_dev_restore, 309 .restore = usb_dev_restore,
310#ifdef CONFIG_USB_SUSPEND 310#ifdef CONFIG_PM_RUNTIME
311 .runtime_suspend = usb_runtime_suspend, 311 .runtime_suspend = usb_runtime_suspend,
312 .runtime_resume = usb_runtime_resume, 312 .runtime_resume = usb_runtime_resume,
313 .runtime_idle = usb_runtime_idle, 313 .runtime_idle = usb_runtime_idle,
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index a7f20bde0e5e..823857767a16 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -93,7 +93,7 @@ static inline int usb_port_resume(struct usb_device *udev, pm_message_t msg)
93 93
94#endif 94#endif
95 95
96#ifdef CONFIG_USB_SUSPEND 96#ifdef CONFIG_PM_RUNTIME
97 97
98extern void usb_autosuspend_device(struct usb_device *udev); 98extern void usb_autosuspend_device(struct usb_device *udev);
99extern int usb_autoresume_device(struct usb_device *udev); 99extern int usb_autoresume_device(struct usb_device *udev);