diff options
author | Michael Brown | 2015-05-06 17:38:28 +0200 |
---|---|---|
committer | Michael Brown | 2015-05-08 15:57:14 +0200 |
commit | f6604627ff71d42bb63a3d81c2986a9d296d55cb (patch) | |
tree | 8eb038959b4e3429c4c15e9a1a7a5bd73e68c2b2 /src/drivers/usb/ehci.c | |
parent | [pci] Provide PCI_CLASS() to calculate a scalar PCI class value (diff) | |
download | ipxe-f6604627ff71d42bb63a3d81c2986a9d296d55cb.tar.gz ipxe-f6604627ff71d42bb63a3d81c2986a9d296d55cb.tar.xz ipxe-f6604627ff71d42bb63a3d81c2986a9d296d55cb.zip |
[usb] Detect missed disconnections
The USB core will currently fail to detect disconnections if a new
device has attached by the time the port is examined in
usb_hotplug().
Fix by recording the fact that a disconnection has taken place
whenever the "connection status changed" (CSC) bit is observed to be
set. (Whether the change represents a disconnection or a
reconnection, it indicates that the port has experienced some time of
being disconnected.)
Note that the time at which a disconnection can be detected varies by
hub type. In particular: root hubs can observe the CSC bit when
polling, and so will record the disconnection before calling
usb_port_changed(), but USB hubs read the port status (and hence the
CSC bit) only during the call to hub_speed(), long after the call to
usb_port_changed().
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/drivers/usb/ehci.c')
-rw-r--r-- | src/drivers/usb/ehci.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/drivers/usb/ehci.c b/src/drivers/usb/ehci.c index 653e72c1..d64024da 100644 --- a/src/drivers/usb/ehci.c +++ b/src/drivers/usb/ehci.c @@ -1498,6 +1498,7 @@ static int ehci_root_speed ( struct usb_hub *hub, struct usb_port *port ) { unsigned int speed; unsigned int line; int ccs; + int csc; int ped; /* Read port status */ @@ -1505,9 +1506,14 @@ static int ehci_root_speed ( struct usb_hub *hub, struct usb_port *port ) { DBGC2 ( ehci, "EHCI %p port %d status is %08x\n", ehci, port->address, portsc ); ccs = ( portsc & EHCI_PORTSC_CCS ); + csc = ( portsc & EHCI_PORTSC_CSC ); ped = ( portsc & EHCI_PORTSC_PED ); line = EHCI_PORTSC_LINE_STATUS ( portsc ); + /* Record disconnections and clear changes */ + port->disconnected |= csc; + writel ( portsc, ehci->op + EHCI_OP_PORTSC ( port->address ) ); + /* Determine port speed */ if ( ! ccs ) { /* Port not connected */ @@ -1564,7 +1570,8 @@ static void ehci_root_poll ( struct usb_hub *hub, struct usb_port *port ) { if ( ! change ) return; - /* Acknowledge changes */ + /* Record disconnections and clear changes */ + port->disconnected |= ( portsc & EHCI_PORTSC_CSC ); writel ( portsc, ehci->op + EHCI_OP_PORTSC ( port->address ) ); /* Report port status change */ |