Changeset 8fe29a7c in mainline
- Timestamp:
- 2018-01-18T17:12:53Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 41abf3c
- Parents:
- fb28cde
- Location:
- uspace/drv/bus/usb/xhci
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/endpoint.c
rfb28cde r8fe29a7c 316 316 } 317 317 318 uint8_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 */ 337 int 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 318 366 /** 319 367 * @} -
uspace/drv/bus/usb/xhci/endpoint.h
rfb28cde r8fe29a7c 63 63 EP_TYPE_BULK_IN = 6, 64 64 EP_TYPE_INTERRUPT_IN = 7 65 }; 66 67 enum { 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, 65 73 }; 66 74 … … 141 149 142 150 void xhci_setup_endpoint_context(xhci_endpoint_t *, xhci_ep_ctx_t *); 151 int xhci_endpoint_clear_halt(xhci_endpoint_t *, unsigned); 143 152 144 153 static inline xhci_device_t * xhci_device_get(device_t *dev) … … 160 169 } 161 170 171 uint8_t xhci_endpoint_get_state(xhci_endpoint_t *ep); 172 162 173 #endif 163 174 -
uspace/drv/bus/usb/xhci/transfers.c
rfb28cde r8fe29a7c 358 358 359 359 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."); 361 361 batch->error = EAGAIN; 362 362 batch->transfered_size = 0; 363 hc_reset_endpoint(hc, slot_id, ep_dci);364 363 break; 365 364 366 365 case XHCI_TRBC_USB_TRANSACTION_ERROR: 367 usb_log_warning("USB Transaction error. Resetting endpoint.");366 usb_log_warning("USB Transaction error."); 368 367 batch->error = ESTALL; 369 368 batch->transfered_size = 0; 370 hc_reset_endpoint(hc, slot_id, ep_dci);371 369 break; 372 370 … … 392 390 usb_log_warning("Transfer not successfull: %u", completion_code); 393 391 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 394 399 } 395 400
Note:
See TracChangeset
for help on using the changeset viewer.