Changeset 17873ac7 in mainline for uspace/drv/bus/usb/xhci/transfers.c
- Timestamp:
- 2017-10-31T19:06:57Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 479e32d
- Parents:
- a312d8f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/transfers.c
ra312d8f r17873ac7 101 101 xhci_transfer_t* xhci_transfer_create(endpoint_t* ep) 102 102 { 103 xhci_endpoint_t *xhci_ep = xhci_endpoint_get(ep); 104 xhci_transfer_t *transfer = &xhci_ep->active_transfer; 105 106 /* Do not access the transfer yet, it may be still in use. */ 103 xhci_transfer_t *transfer = calloc(1, sizeof(xhci_transfer_t)); 104 if (!transfer) 105 return NULL; 107 106 108 107 usb_transfer_batch_init(&transfer->batch, ep); 109 assert(ep->active);110 111 /* Clean just our data. */112 memset(((void *) transfer) + sizeof(usb_transfer_batch_t), 0,113 sizeof(xhci_transfer_t) - sizeof(usb_transfer_batch_t));114 115 108 return transfer; 116 109 } … … 246 239 usb_log_error("Isochronous transfers are not yet implemented!"); 247 240 return ENOTSUP; 248 }249 250 int xhci_transfer_abort(xhci_transfer_t *transfer)251 {252 usb_transfer_batch_t *batch = &transfer->batch;253 batch->error = EAGAIN;254 batch->transfered_size = 0;255 usb_transfer_batch_finish(batch);256 return EOK;257 241 } 258 242 … … 277 261 } 278 262 279 xhci_transfer_t *transfer = &ep->active_transfer; 280 281 /** FIXME: This is racy. Do we care? */ 263 /* FIXME: This is racy. Do we care? */ 282 264 ep->ring.dequeue = addr; 283 265 284 usb_transfer_batch_t *batch = &transfer->batch; 266 fibril_mutex_lock(&ep->base.guard); 267 usb_transfer_batch_t *batch = ep->base.active_batch; 268 if (!batch) { 269 fibril_mutex_unlock(&ep->base.guard); 270 return ENOENT; 271 } 285 272 286 273 batch->error = (TRB_COMPLETION_CODE(*trb) == XHCI_TRBC_SUCCESS) ? EOK : ENAK; 287 274 batch->transfered_size = batch->buffer_size - TRB_TRANSFER_LENGTH(*trb); 275 usb_transfer_batch_reset_toggle(batch); 276 endpoint_deactivate_locked(&ep->base); 277 fibril_mutex_unlock(&ep->base.guard); 278 279 xhci_transfer_t *transfer = xhci_transfer_from_batch(batch); 288 280 289 281 if (batch->dir == USB_DIRECTION_IN) { … … 309 301 { 310 302 assert(hc); 303 endpoint_t *ep = batch->ep; 311 304 312 305 xhci_transfer_t *transfer = xhci_transfer_from_batch(batch); 313 xhci_endpoint_t *xhci_ep = xhci_endpoint_get(batch->ep); 314 assert(xhci_ep); 315 306 xhci_endpoint_t *xhci_ep = xhci_endpoint_get(ep); 316 307 xhci_device_t *xhci_dev = xhci_ep_to_dev(xhci_ep); 317 308 318 309 /* Offline devices don't schedule transfers other than on EP0. */ 319 if (!xhci_dev->online && xhci_ep->base.endpoint) {310 if (!xhci_dev->online && ep->endpoint > 0) { 320 311 return EAGAIN; 321 312 } … … 334 325 if (batch->buffer_size > 0) { 335 326 transfer->hc_buffer = malloc32(batch->buffer_size); 336 } 337 327 if (!transfer->hc_buffer) 328 return ENOMEM; 329 } 338 330 339 331 if (batch->dir != USB_DIRECTION_IN) { … … 342 334 } 343 335 336 fibril_mutex_lock(&ep->guard); 337 endpoint_activate_locked(ep, batch); 344 338 const int err = transfer_handlers[batch->ep->transfer_type](hc, transfer); 345 if (err) 339 340 if (err) { 341 endpoint_deactivate_locked(ep); 342 fibril_mutex_unlock(&ep->guard); 346 343 return err; 344 } 345 346 /* After the critical section, the transfer can already be finished or aborted. */ 347 transfer = NULL; batch = NULL; 348 fibril_mutex_unlock(&ep->guard); 347 349 348 350 const uint8_t slot_id = xhci_dev->slot_id;
Note:
See TracChangeset
for help on using the changeset viewer.