Changeset 8fe29a7c in mainline


Ignore:
Timestamp:
2018-01-18T17:12:53Z (6 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
41abf3c
Parents:
fb28cde
Message:

xhci: clear endpoint halted condition

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

Legend:

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

    rfb28cde r8fe29a7c  
    316316}
    317317
     318uint8_t xhci_endpoint_get_state(xhci_endpoint_t *ep)
     319{
     320        assert(ep);
     321
     322        xhci_device_t *dev = xhci_device_get(ep->base.device);
     323        if (!dev->slot_id)
     324                return EP_STATE_DISABLED;
     325
     326        unsigned idx = xhci_endpoint_index(ep);
     327        xhci_device_ctx_t *ctx = dev->dev_ctx.virt;
     328        xhci_ep_ctx_t *ep_ctx = &ctx->endpoint_ctx[idx];
     329
     330        return XHCI_EP_STATE(*ep_ctx);
     331}
     332
     333/**
     334 * Clear endpoint halt condition by resetting the endpoint and skipping the
     335 * offending transfer.
     336 */
     337int xhci_endpoint_clear_halt(xhci_endpoint_t *ep, unsigned stream_id)
     338{
     339        int err;
     340
     341        xhci_device_t * const dev = xhci_device_get(ep->base.device);
     342        xhci_bus_t * const bus = bus_to_xhci_bus(dev->base.bus);
     343        xhci_hc_t * const hc = bus->hc;
     344
     345        const unsigned slot_id = dev->slot_id;
     346        const unsigned dci = xhci_endpoint_dci(ep);
     347
     348        if ((err = hc_reset_endpoint(hc, slot_id, dci)))
     349                return err;
     350
     351        uintptr_t addr;
     352
     353        xhci_trb_ring_reset_dequeue_state(&ep->ring, &addr);
     354
     355        if ((err = xhci_cmd_sync_inline(hc, SET_TR_DEQUEUE_POINTER,
     356                            .slot_id = slot_id,
     357                            .endpoint_id = dci,
     358                            .stream_id = stream_id,
     359                            .dequeue_ptr = addr,
     360                        )))
     361                return err;
     362
     363        return EOK;
     364}
     365
    318366/**
    319367 * @}
  • uspace/drv/bus/usb/xhci/endpoint.h

    rfb28cde r8fe29a7c  
    6363        EP_TYPE_BULK_IN = 6,
    6464        EP_TYPE_INTERRUPT_IN = 7
     65};
     66
     67enum {
     68        EP_STATE_DISABLED = 0,
     69        EP_STATE_RUNNING = 1,
     70        EP_STATE_HALTED = 2,
     71        EP_STATE_STOPPED = 3,
     72        EP_STATE_ERROR = 4,
    6573};
    6674
     
    141149
    142150void xhci_setup_endpoint_context(xhci_endpoint_t *, xhci_ep_ctx_t *);
     151int xhci_endpoint_clear_halt(xhci_endpoint_t *, unsigned);
    143152
    144153static inline xhci_device_t * xhci_device_get(device_t *dev)
     
    160169}
    161170
     171uint8_t xhci_endpoint_get_state(xhci_endpoint_t *ep);
     172
    162173#endif
    163174
  • uspace/drv/bus/usb/xhci/transfers.c

    rfb28cde r8fe29a7c  
    358358
    359359                case XHCI_TRBC_BABBLE_DETECTED_ERROR:
    360                         usb_log_warning("Babble detected during the transfer. Resetting endpoint.");
     360                        usb_log_warning("Babble detected during the transfer.");
    361361                        batch->error = EAGAIN;
    362362                        batch->transfered_size = 0;
    363                         hc_reset_endpoint(hc, slot_id, ep_dci);
    364363                        break;
    365364
    366365                case XHCI_TRBC_USB_TRANSACTION_ERROR:
    367                         usb_log_warning("USB Transaction error. Resetting endpoint.");
     366                        usb_log_warning("USB Transaction error.");
    368367                        batch->error = ESTALL;
    369368                        batch->transfered_size = 0;
    370                         hc_reset_endpoint(hc, slot_id, ep_dci);
    371369                        break;
    372370
     
    392390                        usb_log_warning("Transfer not successfull: %u", completion_code);
    393391                        batch->error = EIO;
     392        }
     393
     394       
     395        if (xhci_endpoint_get_state(ep) == EP_STATE_HALTED) {
     396                usb_log_debug("Endpoint halted, resetting endpoint.");
     397                xhci_endpoint_clear_halt(ep, batch->target.stream);
     398               
    394399        }
    395400
Note: See TracChangeset for help on using the changeset viewer.