Changeset fb154e13 in mainline for uspace/drv/bus/usb/xhci/hc.c


Ignore:
Timestamp:
2018-01-12T22:48:57Z (6 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0e7380f
Parents:
7242ba21
Message:

xhci: revised roothub event handling

According to the xHCI specification, Port Status Change Event is
generated per port. Also, the PCD bit can be safely ignored. Added
mutual exclusion to roothub event handling to avoid duplicate device
adding.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/xhci/hc.c

    r7242ba21 rfb154e13  
    476476         * not cause an interrupt.
    477477         */
    478         xhci_rh_handle_port_change(&hc->rh);
     478        for (uint8_t port = 1; port <= hc->rh.max_ports; ++port)
     479                xhci_rh_handle_port_change(&hc->rh, port);
    479480
    480481        return EOK;
     
    508509}
    509510
     511static int handle_port_status_change_event(xhci_hc_t *hc, xhci_trb_t *trb)
     512{
     513        uint8_t port_id = XHCI_QWORD_EXTRACT(trb->parameter, 31, 24);
     514        usb_log_debug("Port status change event detected for port %u.", port_id);
     515        xhci_rh_handle_port_change(&hc->rh, port_id);
     516        return EOK;
     517}
     518
    510519typedef int (*event_handler) (xhci_hc_t *, xhci_trb_t *trb);
    511520
    512521static event_handler event_handlers [] = {
    513522        [XHCI_TRB_TYPE_COMMAND_COMPLETION_EVENT] = &xhci_handle_command_completion,
    514         [XHCI_TRB_TYPE_PORT_STATUS_CHANGE_EVENT] = &xhci_rh_handle_port_status_change_event,
     523        [XHCI_TRB_TYPE_PORT_STATUS_CHANGE_EVENT] = &handle_port_status_change_event,
    515524        [XHCI_TRB_TYPE_TRANSFER_EVENT] = &xhci_handle_transfer_event,
    516525        [XHCI_TRB_TYPE_MFINDEX_WRAP_EVENT] = &xhci_handle_mfindex_wrap_event,
     
    578587        status = xhci2host(32, status);
    579588
    580         if (status & XHCI_REG_MASK(XHCI_OP_PCD)) {
    581                 usb_log_debug2("Root hub interrupt.");
    582                 xhci_rh_handle_port_change(&hc->rh);
    583                 status &= ~XHCI_REG_MASK(XHCI_OP_PCD);
    584         }
    585 
    586589        if (status & XHCI_REG_MASK(XHCI_OP_HSE)) {
    587590                usb_log_error("Host controller error occured. Bad things gonna happen...");
     
    599602                status &= ~XHCI_REG_MASK(XHCI_OP_SRE);
    600603        }
     604
     605        /* According to Note on p. 302, we may safely ignore the PCD bit. */
     606        status &= ~XHCI_REG_MASK(XHCI_OP_PCD);
    601607
    602608        if (status) {
Note: See TracChangeset for help on using the changeset viewer.