On Mon, Oct 21, 2013 at 10:24:47AM -0400, Alan Stern wrote: > On Sun, 20 Oct 2013, Sarah Sharp wrote: > > > > > So it means xHCI driver should clear wakeup flags for suspended ports > > > > in this case, just like ehci driver does. Correct? > > > > > > Yes, I agree. > > > > > > Sarah, is this worth reporting to the Intel chipset engineers as a bug? > > > > I'm not sure. I'll have to take a closer look at it after I get back > > from LinuxCon/Kernel Summit and vacation (which won't be until after Nov > > 6th, FYI). > > > > I do agree that it should be fixed. I've stared at that code a couple > > times and tired to figure out why it unconditionally sets the wake on > > flags. I suppose it might even explain some of the spurious wakeups > > we've seen on xHCI host controllers, although those systems seem to > > reboot on shutdown even if there's no port changes. > > I suspect it looks the way it does because it was copied more or less > directly from ehci-hub.c. > > Probably the current code is wrong. The wakeup bits don't need to be > set during port suspend or root-hub suspend, but only during controller > suspend -- they get used only when the controller is not in D0. I > guess we should change both drivers. Ok, let me see if I understand this issue correctly. The wakeup file in /sys/bus/pci/devices/../power/wakeup for the xHCI PCI host controller is supposed to control whether PMEs are enabled when the device is placed into D3. The value in that file will correspond to the do_wakeup variable passed to xhci_pci_suspend. Each of the two xHCI roothubs have separate files in /sys/bus/usb/devices../usbN/power/wakeup. That controls whether the roothub is allowed to set the "wake on" flags for the roothub ports. Those file values are reflected in hcd->self.root_hub->do_remote_wakeup, which xhci_bus_suspend checks before enabling the wake on flags for each roothub port. It will set those flags when the bus is suspended, even if PMEs are disabled for the xHCI PCI device. The problem is that buggy Intel EHCI and xHCI silicon will assert the PME status in S3 if the remote wake up flags are set, even if PME enable is not set. Therefore, we need to fix this by not setting the remote wakeup flags for the ports unless the PCI device has PMEs enabled. In order to fix the xHCI driver, we would remove setting the wake on bits from xhci_bus_suspend. Then, in xhci_pci_suspend, if do_wakeup was set, we would check hcd->self.root_hub->do_remote_wakeup for each of the roothubs, and enable the wake on flags if that was set. Correct? One more question: what happens if the PCI wakeup file is set to disabled while the host is in D3? Will the PCI device be resumed and then suspended with do_wakeup set to false? Sarah Sharp -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html