diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2005-11-14 11:45:38 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-01-04 13:48:31 -0800 |
commit | 1c50c317e2e7f15427149cbc216a63366468710e (patch) | |
tree | d48dc0b03090e89c644f73f9997b4f70b6ec9b41 /drivers | |
parent | 8364d6b0be2dbbf162c6aea79615b5025a0d67c2 (diff) | |
download | blackbird-op-linux-1c50c317e2e7f15427149cbc216a63366468710e.tar.gz blackbird-op-linux-1c50c317e2e7f15427149cbc216a63366468710e.zip |
[PATCH] USB: central handling for host controllers that were reset during suspend/resume
This patch (as515b) adds a routine to usbcore to simplify handling of
host controllers that lost power or were reset during suspend/resume.
The new core routine marks all the child devices of the root hub as
NOTATTACHED and tells khubd to disconnect the device structures as soon
as possible.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/core/hcd.h | 1 | ||||
-rw-r--r-- | drivers/usb/core/hub.c | 33 | ||||
-rw-r--r-- | drivers/usb/host/ehci-pci.c | 9 | ||||
-rw-r--r-- | drivers/usb/host/ohci-hcd.c | 7 | ||||
-rw-r--r-- | drivers/usb/host/sl811-hcd.c | 1 | ||||
-rw-r--r-- | drivers/usb/host/uhci-hcd.c | 6 |
6 files changed, 42 insertions, 15 deletions
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h index c8a1b350e2cf..591b5aad1a18 100644 --- a/drivers/usb/core/hcd.h +++ b/drivers/usb/core/hcd.h @@ -380,6 +380,7 @@ extern int usb_find_interface_driver (struct usb_device *dev, #ifdef CONFIG_PM extern void usb_hcd_suspend_root_hub (struct usb_hcd *hcd); extern void usb_hcd_resume_root_hub (struct usb_hcd *hcd); +extern void usb_root_hub_lost_power (struct usb_device *rhdev); extern int hcd_bus_suspend (struct usb_bus *bus); extern int hcd_bus_resume (struct usb_bus *bus); #else diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index f78bd124d290..5faf7edd73cb 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -1039,6 +1039,39 @@ void usb_set_device_state(struct usb_device *udev, EXPORT_SYMBOL(usb_set_device_state); +#ifdef CONFIG_PM + +/** + * usb_root_hub_lost_power - called by HCD if the root hub lost Vbus power + * @rhdev: struct usb_device for the root hub + * + * The USB host controller driver calls this function when its root hub + * is resumed and Vbus power has been interrupted or the controller + * has been reset. The routine marks all the children of the root hub + * as NOTATTACHED and marks logical connect-change events on their ports. + */ +void usb_root_hub_lost_power(struct usb_device *rhdev) +{ + struct usb_hub *hub; + int port1; + unsigned long flags; + + dev_warn(&rhdev->dev, "root hub lost power or was reset\n"); + spin_lock_irqsave(&device_state_lock, flags); + hub = hdev_to_hub(rhdev); + for (port1 = 1; port1 <= rhdev->maxchild; ++port1) { + if (rhdev->children[port1 - 1]) { + recursively_mark_NOTATTACHED( + rhdev->children[port1 - 1]); + set_bit(port1, hub->change_bits); + } + } + spin_unlock_irqrestore(&device_state_lock, flags); +} +EXPORT_SYMBOL_GPL(usb_root_hub_lost_power); + +#endif + static void choose_address(struct usb_device *udev) { int devnum; diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index ac088bc72f1c..08ca0f849dab 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c @@ -278,7 +278,6 @@ static int ehci_pci_resume(struct usb_hcd *hcd) { struct ehci_hcd *ehci = hcd_to_ehci(hcd); unsigned port; - struct usb_device *root = hcd->self.root_hub; struct pci_dev *pdev = to_pci_dev(hcd->self.controller); int retval = -EINVAL; @@ -312,13 +311,7 @@ static int ehci_pci_resume(struct usb_hcd *hcd) restart: ehci_dbg(ehci, "lost power, restarting\n"); - for (port = HCS_N_PORTS(ehci->hcs_params); port > 0; ) { - port--; - if (!root->children [port]) - continue; - usb_set_device_state(root->children[port], - USB_STATE_NOTATTACHED); - } + usb_root_hub_lost_power(hcd->self.root_hub); /* Else reset, to cope with power loss or flush-to-storage * style "resume" having let BIOS kick in during reboot. diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index e3af3ac4416a..a4b12404ae08 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -795,7 +795,6 @@ static int ohci_restart (struct ohci_hcd *ohci) int temp; int i; struct urb_priv *priv; - struct usb_device *root = ohci_to_hcd(ohci)->self.root_hub; /* mark any devices gone, so they do nothing till khubd disconnects. * recycle any "live" eds/tds (and urbs) right away. @@ -804,11 +803,7 @@ static int ohci_restart (struct ohci_hcd *ohci) */ spin_lock_irq(&ohci->lock); disable (ohci); - for (i = 0; i < root->maxchild; i++) { - if (root->children [i]) - usb_set_device_state (root->children[i], - USB_STATE_NOTATTACHED); - } + usb_root_hub_lost_power(ohci_to_hcd(ohci)->self.root_hub); if (!list_empty (&ohci->pending)) ohci_dbg(ohci, "abort schedule...\n"); list_for_each_entry (priv, &ohci->pending, pending) { diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index 3a9cd4607962..517360b77d8e 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c @@ -1803,6 +1803,7 @@ sl811h_resume(struct platform_device *dev) || !device_can_wakeup(&hcd->self.root_hub->dev)) { sl811->port1 = 0; port_power(sl811, 1); + usb_root_hub_lost_power(hcd->self.root_hub); return 0; } diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index 1c0394cb3c89..071fab6b6475 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c @@ -748,8 +748,12 @@ static int uhci_resume(struct usb_hcd *hcd) check_and_reset_hc(uhci); configure_hc(uhci); - if (uhci->rh_state == UHCI_RH_RESET) + if (uhci->rh_state == UHCI_RH_RESET) { + + /* The controller had to be reset */ + usb_root_hub_lost_power(hcd->self.root_hub); suspend_rh(uhci, UHCI_RH_SUSPENDED); + } spin_unlock_irq(&uhci->lock); |