Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 30fc56f in mainline


Ignore:
Timestamp:
2018-01-11T09:38:40Z (4 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master
Children:
92caadd
Parents:
53a9d02
git-author:
Ondřej Hlavatý <aearsis@…> (2018-01-11 09:38:32)
git-committer:
Ondřej Hlavatý <aearsis@…> (2018-01-11 09:38:40)
Message:

xhci: stop endpoint on unregister

Location:
uspace/drv/bus/usb/xhci
Files:
4 edited

Legend:

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

    r53a9d02 r30fc56f  
    323323
    324324/**
     325 * Abort a transfer on an endpoint.
     326 */
     327static int endpoint_abort(endpoint_t *ep)
     328{
     329        xhci_bus_t *bus = bus_to_xhci_bus(endpoint_get_bus(ep));
     330        xhci_device_t *dev = xhci_device_get(ep->device);
     331
     332        usb_transfer_batch_t *batch = NULL;
     333        fibril_mutex_lock(&ep->guard);
     334        if (ep->active_batch) {
     335                if (dev->slot_id) {
     336                        const int err = hc_stop_endpoint(bus->hc, dev->slot_id, xhci_endpoint_dci(xhci_endpoint_get(ep)));
     337                        if (err) {
     338                                usb_log_warning("Failed to stop endpoint %u of device " XHCI_DEV_FMT ": %s",
     339                                    ep->endpoint, XHCI_DEV_ARGS(*dev), str_error(err));
     340                        }
     341
     342                        endpoint_wait_timeout_locked(ep, 2000);
     343                }
     344
     345                batch = ep->active_batch;
     346                if (batch) {
     347                        endpoint_deactivate_locked(ep);
     348                }
     349        }
     350        fibril_mutex_unlock(&ep->guard);
     351
     352        if (batch) {
     353                batch->error = EINTR;
     354                batch->transfered_size = 0;
     355                usb_transfer_batch_finish(batch);
     356        }
     357        return EOK;
     358}
     359
     360/**
    325361 * Unregister an endpoint. If the device is still available, inform the xHC
    326362 * about it.
     
    335371        xhci_device_t *dev = xhci_device_get(ep_base->device);
    336372
     373        endpoint_abort(ep_base);
     374
    337375        /* If device slot is still available, drop the endpoint. */
    338376        if (dev->slot_id) {
     377
    339378                if ((err = hc_drop_endpoint(bus->hc, dev->slot_id, xhci_endpoint_index(ep)))) {
    340379                        usb_log_error("Failed to drop endpoint " XHCI_EP_FMT ": %s", XHCI_EP_ARGS(*ep), str_error(err));
  • uspace/drv/bus/usb/xhci/commands.c

    r53a9d02 r30fc56f  
    353353        case XHCI_TRB_TYPE_EVALUATE_CONTEXT_CMD:
    354354        case XHCI_TRB_TYPE_RESET_ENDPOINT_CMD:
    355                 break;
    356355        case XHCI_TRB_TYPE_STOP_ENDPOINT_CMD:
    357                 // Note: If the endpoint was in the middle of a transfer, then the xHC
    358                 //       will add a Transfer TRB before the Event TRB, research that and
    359                 //       handle it appropriately!
    360                 break;
    361356        case XHCI_TRB_TYPE_RESET_DEVICE_CMD:
    362357                break;
  • uspace/drv/bus/usb/xhci/hc.c

    r53a9d02 r30fc56f  
    852852
    853853/**
     854 * Instruct xHC to stop running a transfer ring on an endpoint.
     855 *
     856 * @param slot_id Slot ID assigned to the device.
     857 * @param ep_idx Endpoint index (number + direction) in question
     858 */
     859int hc_stop_endpoint(xhci_hc_t *hc, uint32_t slot_id, uint8_t ep_idx)
     860{
     861
     862        return xhci_cmd_sync_inline(hc, STOP_ENDPOINT, .slot_id = slot_id, .endpoint_id = ep_idx);
     863}
     864
     865/**
    854866 * @}
    855867 */
  • uspace/drv/bus/usb/xhci/hc.h

    r53a9d02 r30fc56f  
    115115int hc_drop_endpoint(xhci_hc_t *, uint32_t, uint8_t);
    116116int hc_update_endpoint(xhci_hc_t *, uint32_t, uint8_t, xhci_ep_ctx_t *);
     117int hc_stop_endpoint(xhci_hc_t *, uint32_t , uint8_t);
    117118
    118119int hc_status(bus_t *, uint32_t *);
Note: See TracChangeset for help on using the changeset viewer.