Changeset 0f79283b in mainline


Ignore:
Timestamp:
2018-01-18T12:39:27Z (6 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2bff2cc2
Parents:
babcc423
Message:

usb: remove speed storing (and fix that misuse in xhci rh)

Location:
uspace
Files:
5 edited

Legend:

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

    rbabcc423 r0f79283b  
    134134        port_log(debug, port, "Port reset, enumerating device.");
    135135
    136         if ((err = usbhc_device_enumerate(exch, port->port_number, port->base.speed))) {
     136        if ((err = usbhc_device_enumerate(exch, port->port_number, port->speed))) {
    137137                port_log(error, port, "Failed to enumerate device: %s", str_error(err));
    138138                /* Disable the port */
     
    200200        const bool enabled = !!(status & USB_HUB_PORT_STATUS_ENABLED);
    201201
    202         if (enabled)
    203                 usb_port_enabled(&port->base, usb_port_speed(status));
    204         else
     202        if (enabled) {
     203                // The connecting fibril do not touch speed until the port is enabled,
     204                // so we do not have to lock
     205                port->speed = usb_port_speed(status);
     206                usb_port_enabled(&port->base);
     207        } else
    205208                usb_port_disabled(&port->base, &remove_device);
    206209}
  • uspace/drv/bus/usb/usbhub/port.h

    rbabcc423 r0f79283b  
    5252        /** Port number as reported in descriptors. */
    5353        unsigned int port_number;
     54        /** Speed at the time of enabling the port */
     55        usb_speed_t speed;
    5456} usb_hub_port_t;
    5557
  • uspace/drv/bus/usb/xhci/rh.c

    rbabcc423 r0f79283b  
    136136        }
    137137
    138         device_t *dev = hcd_ddf_fun_create(&port->rh->hc->base, port->base.speed);
     138        /*
     139         * We cannot know in advance, whether the speed in the status register
     140         * is valid - it depends on the protocol. So we read it later, but then
     141         * we have to check if the port is still enabled.
     142         */
     143        uint32_t status = XHCI_REG_RD_FIELD(&port->regs->portsc, 32);
     144
     145        bool enabled = !!(status & XHCI_REG_MASK(XHCI_PORT_PED));
     146        if (!enabled)
     147                return ENOENT;
     148
     149        unsigned psiv = (status & XHCI_REG_MASK(XHCI_PORT_PS)) >> XHCI_REG_SHIFT(XHCI_PORT_PS);
     150        const usb_speed_t speed = port->rh->hc->speeds[psiv].usb_speed;
     151
     152        device_t *dev = hcd_ddf_fun_create(&port->rh->hc->base, speed);
    139153        if (!dev) {
    140154                usb_log_error("Failed to create USB device function.");
     
    223237
    224238                        if (enabled) {
    225                                 unsigned psiv = (status & XHCI_REG_MASK(XHCI_PORT_PS)) >> XHCI_REG_SHIFT(XHCI_PORT_PS);
    226                                 const usb_speed_t speed = rh->hc->speeds[psiv].usb_speed;
    227                                 usb_port_enabled(&port->base, speed);
     239                                usb_port_enabled(&port->base);
    228240                        } else {
    229241                                usb_port_disabled(&port->base, &rh_remove_device);
  • uspace/lib/usb/include/usb/port.h

    rbabcc423 r0f79283b  
    4141 *
    4242 * This subsystem abstracts the rather complicated state machine, and offers
    43  * a simple call interface to announce events, and a callback structure for
    44  * implementations to supply the hardware-dependent part.
     43 * a simple interface to announce events and leave the fibril management on the
     44 * library.
    4545 */
    4646
     
    6565        /** Current state of the port */
    6666        usb_port_state_t state;
    67         /** A speed of the device connected (if any). Valid unless state == PORT_DISABLED. */
    68         usb_speed_t speed;
    6967        /** CV signalled on fibril exit. */
    7068        fibril_condvar_t finished_cv;
     
    8785void usb_port_init(usb_port_t *);
    8886int usb_port_connected(usb_port_t *, usb_port_enumerate_t);
    89 void usb_port_enabled(usb_port_t *, usb_speed_t);
     87void usb_port_enabled(usb_port_t *);
    9088void usb_port_disabled(usb_port_t *, usb_port_remove_t);
    9189void usb_port_fini(usb_port_t *);
  • uspace/lib/usb/src/port.c

    rbabcc423 r0f79283b  
    4141 *
    4242 * This subsystem abstracts the rather complicated state machine, and offers
    43  * a simple call interface to announce events, and a callback structure for
    44  * implementations to supply the hardware-dependent part.
     43 * a simple interface to announce events and leave the fibril management on the
     44 * library.
    4545 */
    4646
     
    127127}
    128128
    129 void usb_port_enabled(usb_port_t *port, usb_speed_t speed)
    130 {
    131         assert(port);
    132 
    133         fibril_mutex_lock(&port->guard);
    134         port->speed = speed;
     129void usb_port_enabled(usb_port_t *port)
     130{
     131        assert(port);
     132
     133        fibril_mutex_lock(&port->guard);
    135134        fibril_condvar_broadcast(&port->enabled_cv);
    136135        fibril_mutex_unlock(&port->guard);
Note: See TracChangeset for help on using the changeset viewer.