Changeset 7d1dd2b in mainline


Ignore:
Timestamp:
2018-01-16T13:36:30Z (6 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
47e9494
Parents:
c952abc4
git-author:
Ondřej Hlavatý <aearsis@…> (2018-01-16 13:36:28)
git-committer:
Ondřej Hlavatý <aearsis@…> (2018-01-16 13:36:30)
Message:

usbhub: port simply cannot inform HC when finalizing

There are three options regarding port finalization with device
connected and enabled:

1) Wait until HC disposes the device. Sorry, no, IPC deadlock, because

if the device is a hub, it will need to use the same connection that
is finalizing the port.

2) Create a fibril to announce this to HC. Yeah, no more deadlock, but

race condition. Host controller will want to clean up after the hub,
and will remove devices connected to it as soon as the unbinding
finishes.

3) If he is doing so… lets leave it up to him? That makes HC spit

a warning, but it's the only correct option then.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbhub/port.c

    rc952abc4 r7d1dd2b  
    153153{
    154154        assert(port);
     155
    155156        fibril_mutex_lock(&port->guard);
    156         port_make_disabled(port);
     157        switch (port->state) {
     158        case PORT_ENABLED:
     159                /*
     160                 * We shall inform the HC that the device is gone.
     161                 * However, we can't wait for it, because if the device is hub,
     162                 * it would have to use the same IPC handling fibril as we do.
     163                 * But we cannot even defer it to another fibril, because then
     164                 * the HC would assume our driver didn't cleanup properly, and
     165                 * will remove those devices by himself.
     166                 *
     167                 * So the solutions seems to behave like a bad driver and leave
     168                 * the work for HC.
     169                 */
     170                port_change_state(port, PORT_DISABLED);
     171                break;
     172
     173        case PORT_CONNECTED:
     174        case PORT_IN_RESET:
     175                port_change_state(port, PORT_ERROR);
     176                /* fallthrough */
     177        case PORT_ERROR:
     178                port_wait_state(port, PORT_DISABLED);
     179                /* fallthrough */
     180        case PORT_DISABLED:
     181                break;
     182        }
    157183        port_log(debug, port, "Finalized.");
    158184        fibril_mutex_unlock(&port->guard);
Note: See TracChangeset for help on using the changeset viewer.