LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-usb@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	Alan Stern <stern@rowland.harvard.edu>,
	Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 1/6] USB: EHCI: carry out port handover during each root-hub resume
Date: Mon, 10 Mar 2008 17:59:07 -0700	[thread overview]
Message-ID: <1205197152-18146-1-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <20080311004239.GD17890@suse.de>

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

This patch (as1044) causes EHCI port handover for non-high-speed
devices to occur during every root-hub resume, not just in cases where
the controller lost power or was reset.  This is necessary because:

	When some machines go into suspend, they remove power from
	on-board USB devices while retaining suspend current for USB
	controllers.

	The user might well unplug a USB device while the system is
	suspended and then plug it back in before resuming.

A corresponding change is made to the core resume routine; now
high-speed root hubs will always be resumed when the system wakes up,
even if they were suspended before the system went to sleep.  If this
weren't done then EHCI port handover wouldn't work, since it is called
when the EHCI root hub is resumed.

Finally, a comment is added to the hub driver explaining the khubd has
to be freezable; if it weren't frozen then it could interfere with
port handover.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/usb/core/driver.c   |    9 +++++++--
 drivers/usb/core/hub.c      |    6 ++++++
 drivers/usb/host/ehci-hub.c |    4 +---
 drivers/usb/host/ehci-pci.c |    1 -
 4 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 801b6f1..ebccdef 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -1523,9 +1523,14 @@ static int usb_suspend(struct device *dev, pm_message_t message)
 	udev = to_usb_device(dev);
 
 	/* If udev is already suspended, we can skip this suspend and
-	 * we should also skip the upcoming system resume. */
+	 * we should also skip the upcoming system resume.  High-speed
+	 * root hubs are an exception; they need to resume whenever the
+	 * system wakes up in order for USB-PERSIST port handover to work
+	 * properly.
+	 */
 	if (udev->state == USB_STATE_SUSPENDED) {
-		udev->skip_sys_resume = 1;
+		if (udev->parent || udev->speed != USB_SPEED_HIGH)
+			udev->skip_sys_resume = 1;
 		return 0;
 	}
 
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 68fc521..acd4658 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2891,7 +2891,13 @@ loop:
 
 static int hub_thread(void *__unused)
 {
+	/* khubd needs to be freezable to avoid intefering with USB-PERSIST
+	 * port handover.  Otherwise it might see that a full-speed device
+	 * was gone before the EHCI controller had handed its port over to
+	 * the companion full-speed controller.
+	 */
 	set_freezable();
+
 	do {
 		hub_events();
 		wait_event_freezable(khubd_wait,
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 40e8240..3a2eb01 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -280,9 +280,7 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
 	ehci_writel(ehci, INTR_MASK, &ehci->regs->intr_enable);
 
 	spin_unlock_irq (&ehci->lock);
-
-	if (!power_okay)
-		ehci_handover_companion_ports(ehci);
+	ehci_handover_companion_ports(ehci);
 	return 0;
 }
 
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 3ba0166..c12ada6 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -315,7 +315,6 @@ static int ehci_pci_resume(struct usb_hcd *hcd)
 
 	/* here we "know" root ports should always stay powered */
 	ehci_port_power(ehci, 1);
-	ehci_handover_companion_ports(ehci);
 
 	hcd->state = HC_STATE_SUSPENDED;
 	return 0;
-- 
1.5.4.3


  reply	other threads:[~2008-03-11  0:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-11  0:42 [GIT PATCH] USB suspend persistance for 2.6.25-rc5 git Greg KH
2008-03-11  0:59 ` Greg Kroah-Hartman [this message]
2008-03-11  0:59 ` [PATCH 2/6] USB: reorganize code in hub.c Greg Kroah-Hartman
2008-03-11  0:59 ` [PATCH 3/6] USB: make USB-PERSIST work after every system sleep Greg Kroah-Hartman
2008-03-11  0:59 ` [PATCH 4/6] USB: remove CONFIG_USB_PERSIST setting Greg Kroah-Hartman
2008-03-11  0:59 ` [PATCH 5/6] USB: check serial-number string after device reset Greg Kroah-Hartman
2008-03-11  0:59 ` [PATCH 6/6] USB: enable USB-PERSIST by default Greg Kroah-Hartman
2008-03-19 17:05   ` Mark Lord
2008-03-19 21:35     ` Alan Stern
2008-03-20 14:17       ` Mark Lord
2008-03-11 10:27 ` [GIT PATCH] USB suspend persistance for 2.6.25-rc5 git Pavel Machek
2008-03-11 15:28   ` Greg KH
2008-03-11 16:18   ` Linus Torvalds

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=1205197152-18146-1-git-send-email-gregkh@suse.de \
    --to=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    --subject='Re: [PATCH 1/6] USB: EHCI: carry out port handover during each root-hub resume' \
    /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

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).