Re: [RFC v3 12/23] USB: Set usb_hcd->state and flags for shared roothubs.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 7 Mar 2011, Sarah Sharp wrote:

> The hcd->flags are in a sorry state.  Some of them are clearly specific to
> the particular roothub (HCD_POLL_RH, HCD_POLL_PENDING, and
> HCD_WAKEUP_PENDING), but some flags are related to PCI device state
> (HCD_HW_ACCESSIBLE and HCD_SAW_IRQ).  This is an issue when one PCI device
> can have two roothubs that share the same IRQ line and hardware.

Okay, this patch is going to need a major overhaul in light of the 
changes to hcd->state.

One simplification can be made easily enough.  We should guarantee that 
usb_hc_died() always affects both hcds when called for a shared hcd.

> Make sure to set HCD_FLAG_SAW_IRQ for both roothubs when an interrupt is
> serviced, or an URB is unlinked without an interrupt.  (We can't tell if
> the host actually serviced an interrupt for a particular bus, but we can
> tell it serviced some interrupt.)

The SAW_IRQ stuff can all be removed later.

> HCD_HW_ACCESSIBLE is set once by usb_add_hcd(), which is set for both
> roothubs as they are added, so it doesn't need to be modified.
> HCD_POLL_RH and HCD_POLL_PENDING are only checked by the USB core, and
> they are never set by the xHCI driver, since the roothub never needs to be
> polled.
> 
> The usb_hcd's state field is a similar mess.  Sometimes the state applies
> to the underlying hardware: HC_STATE_HALT, HC_STATE_RUNNING, and
> HC_STATE_QUIESCING.  But sometimes the state refers to the roothub state:
> HC_STATE_RESUMING and HC_STATE_SUSPENDED.
> 
> This poses an issue with the xHCI split roothub, where two buses are
> registered for one PCI device.  Each bus in the xHCI split roothub can be
> suspended separately, but both buses must be suspended before the PCI
> device can be suspended.  Therefore, make sure that the USB core checks
> hcd->state equals HC_STATE_SUSPENDED for both roothubs before suspending
> the PCI host.
> 
> Make sure to kill off the shared roothub when the PCI resume fails.
> 
> The xHCI driver will need to ensure that HC_STATE_HALT, HC_STATE_RUNNING,
> and HC_STATE_QUIESCING will be set for both the roothubs.

Fortunately this is no longer necessary, unless xhci-hcd uses 
hcd->state internally.

> I'm not quite sure if the code in hcd_pci_suspend_noirq() is correct,
> please check.  If one roothub is halted, then both roothubs should be
> halted (since they share the same hardware).  But I suppose there could be
> a race condition where one usb_hcd->state is set to HC_STATE_HALT, but the
> other isn't yet?

No, there's no race condition because by the time 
hcd_pci_suspend_noirq() is called, everything is quiescent.

Alan Stern

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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux