On Thu, Dec 02, 2010 at 10:37:54AM -0500, Alan Stern wrote: > On Wed, 1 Dec 2010, Sarah Sharp wrote: > > > Hi Alan, > > > > Matthew Garret points out that the current xHCI code doesn't work so > > well when the host is suspended and then the card is removed. The > > xhci_suspend() method frees the MSI-X interrupts because the USB core > > calls synchronize_irq() with the legacy interrupt in suspend_common() in > > hcd-pci.c. The hotplug layer will attempt to deallocate the interrupts > > the card had before suspend, which results in a double free. > > > > Is there a reason the USB PCI code calls synchronize_irq()? > > See commit 8de98402652c01839ae321be (USB: Fix USB suspend/resume > crasher (#2)) by Ben Herrenschmidt -- 5 years ago! He's the best > person to ask. My best guess is that this was done to avoid a race in > which an IRQ is received before the suspend starts but is not delivered > until after the controller is put into D3, at which point the ISR would > get a bus exception when trying to read the controller's status > register. > > Let me turn your question around: Is there a reason xhci_suspend() > frees the MSI-X interrupts instead of just synchronizing them? I don't know, that was Andiry's code. I think he was just trying to work around the USB core synchronizing the legacy PCI IRQ. Perhaps the xHCI driver could synchronize the MSI-X interrupts and the USB core could skip the legacy PCI IRQ synchronization if hcd->irq == -1? Andiry, was there a reason you were freeing the MSI-X vectors? Is there some bug you were working around? 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