Changeset 609f3f73 in mainline


Ignore:
Timestamp:
2018-01-20T00:17:33Z (6 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ba654f2
Parents:
b5c92d7
Message:

xhci: reset endpoint on ClearFeature(ENDPOINT_HALT) request

File:
1 edited

Legend:

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

    rb5c92d7 r609f3f73  
    395395        }
    396396
    397        
    398         if (xhci_endpoint_get_state(ep) == EP_STATE_HALTED) {
    399                 usb_log_debug("Endpoint halted, resetting endpoint.");
    400                 const int err = xhci_endpoint_clear_halt(ep, batch->target.stream);
    401                 if (err)
    402                         usb_log_error("Failed to clear halted condition on "
    403                             "endpoint " XHCI_EP_FMT ". Unexpected results "
    404                             "coming.", XHCI_EP_ARGS(*ep));
    405         }
    406 
    407397        if (batch->dir == USB_DIRECTION_IN) {
    408398                assert(batch->buffer);
     
    460450        }
    461451
     452        /*
     453         * If this is a ClearFeature(ENDPOINT_HALT) request, we have to issue
     454         * the Reset Endpoint command.
     455         */
     456        if (batch->ep->transfer_type == USB_TRANSFER_CONTROL && batch->dir == USB_DIRECTION_OUT) {
     457                const usb_device_request_setup_packet_t *request = &batch->setup.packet;
     458                if (request->request == USB_DEVREQ_CLEAR_FEATURE
     459                    && request->request_type == USB_REQUEST_RECIPIENT_ENDPOINT
     460                    && request->value == USB_FEATURE_ENDPOINT_HALT) {
     461                        const uint16_t index = uint16_usb2host(request->index);
     462                        const usb_endpoint_t ep_num = index & 0xf;
     463                        const usb_direction_t dir = (index >> 7) ? USB_DIRECTION_IN : USB_DIRECTION_OUT;
     464                        endpoint_t *halted_ep = bus_find_endpoint(&xhci_dev->base, ep_num, dir);
     465                        if (halted_ep) {
     466                                /*
     467                                 * TODO: Find out how to come up with stream_id. It
     468                                 * might be possible that we have to clear all of them.
     469                                 */
     470                                xhci_endpoint_clear_halt(xhci_endpoint_get(halted_ep), 0);
     471                                endpoint_del_ref(halted_ep);
     472                        } else {
     473                                usb_log_warning("Device(%u): Resetting unregistered endpoint %u %s.", xhci_dev->base.address, ep_num, usb_str_direction(dir));
     474                        }
     475                }
     476        }
     477
     478
    462479        fibril_mutex_lock(&ep->guard);
    463480        endpoint_activate_locked(ep, batch);
Note: See TracChangeset for help on using the changeset viewer.