source: mainline/uspace/drv/bus/usb/xhci/transfers.c@ 60d3f35

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 60d3f35 was 609f3f73, checked in by Ondřej Hlavatý <aearsis@…>, 8 years ago

xhci: reset endpoint on ClearFeature(ENDPOINT_HALT) request

  • Property mode set to 100644
File size: 14.9 KB
RevLine 
[e9e24f2]1/*
2 * Copyright (c) 2017 Michal Staruch
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup drvusbxhci
30 * @{
31 */
32/** @file
33 * @brief The host controller transfer ring management
34 */
35
36#include <usb/debug.h>
[dcf0597]37#include <usb/request.h>
[41924f30]38#include "endpoint.h"
[e9e24f2]39#include "hc.h"
40#include "hw_struct/trb.h"
[47e9494]41#include "streams.h"
[e9e24f2]42#include "transfers.h"
43#include "trb_ring.h"
44
[dbf32b1]45typedef enum {
46 STAGE_OUT,
47 STAGE_IN,
48} stage_dir_flag_t;
49
50#define REQUEST_TYPE_DTD (0x80)
51#define REQUEST_TYPE_IS_DEVICE_TO_HOST(rq) ((rq) & REQUEST_TYPE_DTD)
52
[e9e24f2]53
[dbf32b1]54/** Get direction flag of data stage.
55 * See Table 7 of xHCI specification.
56 */
57static inline stage_dir_flag_t get_status_direction_flag(xhci_trb_t* trb,
58 uint8_t bmRequestType, uint16_t wLength)
[e9e24f2]59{
60 /* See Table 7 of xHCI specification */
[dbf32b1]61 return REQUEST_TYPE_IS_DEVICE_TO_HOST(bmRequestType) && (wLength > 0)
62 ? STAGE_OUT
63 : STAGE_IN;
[e9e24f2]64}
65
[dbf32b1]66typedef enum {
67 DATA_STAGE_NO = 0,
68 DATA_STAGE_OUT = 2,
69 DATA_STAGE_IN = 3,
70} data_stage_type_t;
71
72/** Get transfer type flag.
73 * See Table 8 of xHCI specification.
74 */
75static inline data_stage_type_t get_transfer_type(xhci_trb_t* trb, uint8_t
76 bmRequestType, uint16_t wLength)
[e9e24f2]77{
[dbf32b1]78 if (wLength == 0)
79 return DATA_STAGE_NO;
80
[e9e24f2]81 /* See Table 7 of xHCI specification */
[dbf32b1]82 return REQUEST_TYPE_IS_DEVICE_TO_HOST(bmRequestType)
83 ? DATA_STAGE_IN
84 : DATA_STAGE_NO;
[e9e24f2]85}
86
[d7869d7e]87static inline bool configure_endpoint_needed(usb_device_request_setup_packet_t *setup)
88{
89 usb_request_type_t request_type = SETUP_REQUEST_TYPE_GET_TYPE(setup->request_type);
90
[dbf32b1]91 return request_type == USB_REQUEST_TYPE_STANDARD &&
92 (setup->request == USB_DEVREQ_SET_CONFIGURATION
93 || setup->request == USB_DEVREQ_SET_INTERFACE);
[d7869d7e]94}
95
[2b61945]96/**
[eb928c4]97 * Create a xHCI-specific transfer batch.
98 *
99 * Bus callback.
[2b61945]100 */
[eb928c4]101usb_transfer_batch_t * xhci_transfer_create(endpoint_t* ep)
[e9e24f2]102{
[17873ac7]103 xhci_transfer_t *transfer = calloc(1, sizeof(xhci_transfer_t));
104 if (!transfer)
105 return NULL;
[e9e24f2]106
[5fd9c30]107 usb_transfer_batch_init(&transfer->batch, ep);
[eb928c4]108 return &transfer->batch;
[e9e24f2]109}
110
[eb928c4]111/**
112 * Destroy a xHCI transfer.
113 */
114void xhci_transfer_destroy(usb_transfer_batch_t* batch)
[5fd9c30]115{
[eb928c4]116 xhci_transfer_t *transfer = xhci_transfer_from_batch(batch);
[2770b66]117
[b80c1ab]118 dma_buffer_free(&transfer->hc_buffer);
[a0e09ef]119 free(transfer);
[e9e24f2]120}
121
[5fd9c30]122static xhci_trb_ring_t *get_ring(xhci_hc_t *hc, xhci_transfer_t *transfer)
[e9e24f2]123{
[47e9494]124 xhci_endpoint_t *ep = xhci_endpoint_get(transfer->batch.ep);
125 if (ep->primary_stream_data_size == 0) return &ep->ring;
126 uint32_t stream_id = transfer->batch.target.stream;
127
128 xhci_stream_data_t *stream_data = xhci_get_stream_ctx_data(ep, stream_id);
129 if (stream_data == NULL) {
130 usb_log_warning("No transfer ring was found for stream %u.", stream_id);
131 return NULL;
132 }
133
134 return &stream_data->ring;
[5fd9c30]135}
[e9e24f2]136
[5fd9c30]137static int schedule_control(xhci_hc_t* hc, xhci_transfer_t* transfer)
138{
139 usb_transfer_batch_t *batch = &transfer->batch;
140 xhci_trb_ring_t *ring = get_ring(hc, transfer);
141 xhci_endpoint_t *xhci_ep = xhci_endpoint_get(transfer->batch.ep);
[2770b66]142
[5fd9c30]143 usb_device_request_setup_packet_t* setup = &batch->setup.packet;
[e9e24f2]144
[5fd9c30]145 xhci_trb_t trbs[3];
146 int trbs_used = 0;
[e9e24f2]147
[d1d7a92]148 xhci_trb_t *trb_setup = trbs + trbs_used++;
149 xhci_trb_clean(trb_setup);
150
151 TRB_CTRL_SET_SETUP_WVALUE(*trb_setup, setup->value);
152 TRB_CTRL_SET_SETUP_WLENGTH(*trb_setup, setup->length);
153 TRB_CTRL_SET_SETUP_WINDEX(*trb_setup, setup->index);
154 TRB_CTRL_SET_SETUP_BREQ(*trb_setup, setup->request);
155 TRB_CTRL_SET_SETUP_BMREQTYPE(*trb_setup, setup->request_type);
[e9e24f2]156
[eaf5e86]157 /* Size of the setup packet is always 8 */
[d1d7a92]158 TRB_CTRL_SET_XFER_LEN(*trb_setup, 8);
[e9e24f2]159
[eaf5e86]160 /* Immediate data */
[d1d7a92]161 TRB_CTRL_SET_IDT(*trb_setup, 1);
162 TRB_CTRL_SET_TRB_TYPE(*trb_setup, XHCI_TRB_TYPE_SETUP_STAGE);
163 TRB_CTRL_SET_TRT(*trb_setup, get_transfer_type(trb_setup, setup->request_type, setup->length));
[e9e24f2]164
[eaf5e86]165 /* Data stage */
[d1d7a92]166 xhci_trb_t *trb_data = NULL;
[eaf5e86]167 if (setup->length > 0) {
[5fd9c30]168 trb_data = trbs + trbs_used++;
169 xhci_trb_clean(trb_data);
[d1d7a92]170
[b80c1ab]171 trb_data->parameter = host2xhci(64, transfer->hc_buffer.phys);
[e9e24f2]172
[eaf5e86]173 // data size (sent for OUT, or buffer size)
[d1d7a92]174 TRB_CTRL_SET_XFER_LEN(*trb_data, batch->buffer_size);
[eaf5e86]175 // FIXME: TD size 4.11.2.4
[d1d7a92]176 TRB_CTRL_SET_TD_SIZE(*trb_data, 1);
[e9e24f2]177
[eaf5e86]178 // Some more fields here, no idea what they mean
[d1d7a92]179 TRB_CTRL_SET_TRB_TYPE(*trb_data, XHCI_TRB_TYPE_DATA_STAGE);
[e9e24f2]180
[5fd9c30]181 int stage_dir = REQUEST_TYPE_IS_DEVICE_TO_HOST(setup->request_type)
[dbf32b1]182 ? STAGE_IN : STAGE_OUT;
[5fd9c30]183 TRB_CTRL_SET_DIR(*trb_data, stage_dir);
[eaf5e86]184 }
[e9e24f2]185
[eaf5e86]186 /* Status stage */
[d1d7a92]187 xhci_trb_t *trb_status = trbs + trbs_used++;
188 xhci_trb_clean(trb_status);
[e9e24f2]189
[eaf5e86]190 // FIXME: Evaluate next TRB? 4.12.3
[d1d7a92]191 // TRB_CTRL_SET_ENT(*trb_status, 1);
[e9e24f2]192
[d1d7a92]193 TRB_CTRL_SET_IOC(*trb_status, 1);
194 TRB_CTRL_SET_TRB_TYPE(*trb_status, XHCI_TRB_TYPE_STATUS_STAGE);
195 TRB_CTRL_SET_DIR(*trb_status, get_status_direction_flag(trb_setup, setup->request_type, setup->length));
[e9e24f2]196
[d7869d7e]197 // Issue a Configure Endpoint command, if needed.
198 if (configure_endpoint_needed(setup)) {
[a4e7e6e1]199 const int err = hc_configure_device(xhci_ep_to_dev(xhci_ep));
[5fd9c30]200 if (err)
201 return err;
[d7869d7e]202 }
203
[5fd9c30]204 return xhci_trb_ring_enqueue_multiple(ring, trbs, trbs_used, &transfer->interrupt_trb_phys);
[e9e24f2]205}
206
[5fd9c30]207static int schedule_bulk(xhci_hc_t* hc, xhci_transfer_t *transfer)
[9b2f69e]208{
[42bc933]209 xhci_trb_t trb;
[dbf32b1]210 xhci_trb_clean(&trb);
[b80c1ab]211 trb.parameter = host2xhci(64, transfer->hc_buffer.phys);
[42bc933]212
213 // data size (sent for OUT, or buffer size)
[5fd9c30]214 TRB_CTRL_SET_XFER_LEN(trb, transfer->batch.buffer_size);
[42bc933]215
[47e9494]216 /* The stream-enabled endpoints need to chain ED trb */
217 xhci_endpoint_t *ep = xhci_endpoint_get(transfer->batch.ep);
218 if (!ep->primary_stream_data_size) {
219 // FIXME: TD size 4.11.2.4
220 TRB_CTRL_SET_TD_SIZE(trb, 1);
[42bc933]221
[47e9494]222 // we want an interrupt after this td is done
223 TRB_CTRL_SET_IOC(trb, 1);
224 TRB_CTRL_SET_TRB_TYPE(trb, XHCI_TRB_TYPE_NORMAL);
[42bc933]225
[47e9494]226 xhci_trb_ring_t* ring = get_ring(hc, transfer);
227 return xhci_trb_ring_enqueue(ring, &trb, &transfer->interrupt_trb_phys);
228 }
229 else {
230 TRB_CTRL_SET_TD_SIZE(trb, 2);
231 TRB_CTRL_SET_TRB_TYPE(trb, XHCI_TRB_TYPE_NORMAL);
232 TRB_CTRL_SET_CHAIN(trb, 1);
233 TRB_CTRL_SET_ENT(trb, 1);
[42bc933]234
[47e9494]235 xhci_trb_ring_t* ring = get_ring(hc, transfer);
[4cc0c2e0]236 if (!ring) {
237 return EINVAL;
238 }
239
[47e9494]240 int err = xhci_trb_ring_enqueue(ring, &trb, &transfer->interrupt_trb_phys);
241
242 if (err) {
243 return err;
244 }
245
246 xhci_trb_clean(&trb);
247 trb.parameter = host2xhci(64, (uintptr_t) transfer);
248 TRB_CTRL_SET_TRB_TYPE(trb, XHCI_TRB_TYPE_EVENT_DATA);
249 TRB_CTRL_SET_IOC(trb, 1);
250
251 return xhci_trb_ring_enqueue(ring, &trb, &transfer->interrupt_trb_phys);
252 }
[42bc933]253}
254
[5fd9c30]255static int schedule_interrupt(xhci_hc_t* hc, xhci_transfer_t* transfer)
[9b2f69e]256{
257 xhci_trb_t trb;
[dbf32b1]258 xhci_trb_clean(&trb);
[b80c1ab]259 trb.parameter = host2xhci(64, transfer->hc_buffer.phys);
[9b2f69e]260
261 // data size (sent for OUT, or buffer size)
[5fd9c30]262 TRB_CTRL_SET_XFER_LEN(trb, transfer->batch.buffer_size);
[9b2f69e]263 // FIXME: TD size 4.11.2.4
264 TRB_CTRL_SET_TD_SIZE(trb, 1);
265
266 // we want an interrupt after this td is done
267 TRB_CTRL_SET_IOC(trb, 1);
268
269 TRB_CTRL_SET_TRB_TYPE(trb, XHCI_TRB_TYPE_NORMAL);
270
[2b61945]271 xhci_trb_ring_t* ring = get_ring(hc, transfer);
[9b2f69e]272
[5fd9c30]273 return xhci_trb_ring_enqueue(ring, &trb, &transfer->interrupt_trb_phys);
[9b2f69e]274}
275
[708d8fcd]276static int schedule_isochronous(xhci_transfer_t* transfer)
[d3086873]277{
[708d8fcd]278 endpoint_t *ep = transfer->batch.ep;
[d3086873]279
[708d8fcd]280 return ep->direction == USB_DIRECTION_OUT
281 ? isoch_schedule_out(transfer)
282 : isoch_schedule_in(transfer);
[1252e81]283}
284
[e9e24f2]285int xhci_handle_transfer_event(xhci_hc_t* hc, xhci_trb_t* trb)
286{
287 uintptr_t addr = trb->parameter;
[2b61945]288 const unsigned slot_id = XHCI_DWORD_EXTRACT(trb->control, 31, 24);
289 const unsigned ep_dci = XHCI_DWORD_EXTRACT(trb->control, 20, 16);
[e9e24f2]290
[2b61945]291 xhci_device_t *dev = hc->bus.devices_by_slot[slot_id];
292 if (!dev) {
[9620a54]293 usb_log_error("Transfer event on disabled slot %u", slot_id);
[2b61945]294 return ENOENT;
[e9e24f2]295 }
296
[2b61945]297 const usb_endpoint_t ep_num = ep_dci / 2;
[1ed3eb4]298 const usb_endpoint_t dir = ep_dci % 2 ? USB_DIRECTION_IN : USB_DIRECTION_OUT;
[41abf3c]299 /* Creating temporary reference */
[1ed3eb4]300 endpoint_t *ep_base = bus_find_endpoint(&dev->base, ep_num, dir);
301 if (!ep_base) {
302 usb_log_error("Transfer event on dropped endpoint %u %s of device "
303 XHCI_DEV_FMT, ep_num, usb_str_direction(dir), XHCI_DEV_ARGS(*dev));
[e9e24f2]304 return ENOENT;
305 }
[1ed3eb4]306 xhci_endpoint_t *ep = xhci_endpoint_get(ep_base);
[e9e24f2]307
[47e9494]308 usb_transfer_batch_t *batch;
309 xhci_transfer_t *transfer;
[2b61945]310
[47e9494]311 if (TRB_EVENT_DATA(*trb)) {
312 assert(ep->base.transfer_type != USB_TRANSFER_ISOCHRONOUS);
313 /* We are received transfer pointer instead - work with that */
314 transfer = (xhci_transfer_t *) addr;
315 xhci_trb_ring_t * ring = get_ring(hc, transfer);
316 xhci_trb_ring_update_dequeue(ring, transfer->interrupt_trb_phys);
317 batch = &transfer->batch;
[d3086873]318
[47e9494]319 fibril_mutex_lock(&ep->base.guard);
320 endpoint_deactivate_locked(&ep->base);
321 fibril_mutex_unlock(&ep->base.guard);
322 }
323 else {
324 xhci_trb_ring_update_dequeue(&ep->ring, addr);
325
326 if (ep->base.transfer_type == USB_TRANSFER_ISOCHRONOUS) {
327 isoch_handle_transfer_event(hc, ep, trb);
[41abf3c]328 /* Dropping temporary reference */
[47e9494]329 endpoint_del_ref(&ep->base);
330 return EOK;
331 }
332
333 fibril_mutex_lock(&ep->base.guard);
334 batch = ep->base.active_batch;
335 if (!batch) {
336 fibril_mutex_unlock(&ep->base.guard);
[41abf3c]337 /* Dropping temporary reference */
[47e9494]338 endpoint_del_ref(&ep->base);
339 return ENOENT;
340 }
341
342 transfer = xhci_transfer_from_batch(batch);
343
344 endpoint_deactivate_locked(&ep->base);
[17873ac7]345 fibril_mutex_unlock(&ep->base.guard);
346 }
[5fd9c30]347
[6d91888]348 const xhci_trb_completion_code_t completion_code = TRB_COMPLETION_CODE(*trb);
349 switch (completion_code) {
350 case XHCI_TRBC_SHORT_PACKET:
351 case XHCI_TRBC_SUCCESS:
352 batch->error = EOK;
353 batch->transfered_size = batch->buffer_size - TRB_TRANSFER_LENGTH(*trb);
354 break;
355
[feabe163]356 case XHCI_TRBC_DATA_BUFFER_ERROR:
357 usb_log_warning("Transfer ended with data buffer error.");
358 batch->error = EAGAIN;
359 batch->transfered_size = 0;
360 break;
361
362 case XHCI_TRBC_BABBLE_DETECTED_ERROR:
[8fe29a7c]363 usb_log_warning("Babble detected during the transfer.");
[feabe163]364 batch->error = EAGAIN;
365 batch->transfered_size = 0;
366 break;
367
368 case XHCI_TRBC_USB_TRANSACTION_ERROR:
[8fe29a7c]369 usb_log_warning("USB Transaction error.");
[feabe163]370 batch->error = ESTALL;
371 batch->transfered_size = 0;
372 break;
373
374 case XHCI_TRBC_TRB_ERROR:
375 usb_log_error("Invalid transfer parameters.");
376 batch->error = EINVAL;
377 batch->transfered_size = 0;
378 break;
379
380 case XHCI_TRBC_STALL_ERROR:
381 usb_log_warning("Stall condition detected.");
382 batch->error = ESTALL;
383 batch->transfered_size = 0;
384 break;
385
386 case XHCI_TRBC_SPLIT_TRANSACTION_ERROR:
387 usb_log_error("Split transcation error detected.");
388 batch->error = EAGAIN;
389 batch->transfered_size = 0;
390 break;
391
[6d91888]392 default:
393 usb_log_warning("Transfer not successfull: %u", completion_code);
394 batch->error = EIO;
395 }
396
[5fd9c30]397 if (batch->dir == USB_DIRECTION_IN) {
398 assert(batch->buffer);
399 assert(batch->transfered_size <= batch->buffer_size);
[b80c1ab]400 memcpy(batch->buffer, transfer->hc_buffer.virt, batch->transfered_size);
[5fd9c30]401 }
402
403 usb_transfer_batch_finish(batch);
[41abf3c]404 /* Dropping temporary reference */
[1ed3eb4]405 endpoint_del_ref(&ep->base);
[e9e24f2]406 return EOK;
407}
[5fd9c30]408
409typedef int (*transfer_handler)(xhci_hc_t *, xhci_transfer_t *);
410
411static const transfer_handler transfer_handlers[] = {
412 [USB_TRANSFER_CONTROL] = schedule_control,
[d3086873]413 [USB_TRANSFER_ISOCHRONOUS] = NULL,
[5fd9c30]414 [USB_TRANSFER_BULK] = schedule_bulk,
415 [USB_TRANSFER_INTERRUPT] = schedule_interrupt,
416};
417
418int xhci_transfer_schedule(xhci_hc_t *hc, usb_transfer_batch_t *batch)
419{
420 assert(hc);
[17873ac7]421 endpoint_t *ep = batch->ep;
[5fd9c30]422
423 xhci_transfer_t *transfer = xhci_transfer_from_batch(batch);
[17873ac7]424 xhci_endpoint_t *xhci_ep = xhci_endpoint_get(ep);
[a4e26882]425 xhci_device_t *xhci_dev = xhci_ep_to_dev(xhci_ep);
426
[7010861]427 // FIXME: find a better way to check if the ring is not initialized
428 if (!xhci_ep->ring.segment_count) {
[9620a54]429 usb_log_error("Ring not initialized for endpoint " XHCI_EP_FMT,
[ef1a3a8]430 XHCI_EP_ARGS(*xhci_ep));
[7010861]431 return EINVAL;
432 }
433
[d3086873]434 // Isochronous transfer needs to be handled differently
[deb2e55]435 if (batch->ep->transfer_type == USB_TRANSFER_ISOCHRONOUS) {
[708d8fcd]436 return schedule_isochronous(transfer);
[d3086873]437 }
438
[5fd9c30]439 const usb_transfer_type_t type = batch->ep->transfer_type;
440 assert(transfer_handlers[type]);
441
442 if (batch->buffer_size > 0) {
[b80c1ab]443 if (dma_buffer_alloc(&transfer->hc_buffer, batch->buffer_size))
[17873ac7]444 return ENOMEM;
[5fd9c30]445 }
446
447 if (batch->dir != USB_DIRECTION_IN) {
448 // Sending stuff from host to device, we need to copy the actual data.
[b80c1ab]449 memcpy(transfer->hc_buffer.virt, batch->buffer, batch->buffer_size);
[5fd9c30]450 }
451
[609f3f73]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
[17873ac7]479 fibril_mutex_lock(&ep->guard);
480 endpoint_activate_locked(ep, batch);
[5fd9c30]481 const int err = transfer_handlers[batch->ep->transfer_type](hc, transfer);
[17873ac7]482
483 if (err) {
484 endpoint_deactivate_locked(ep);
485 fibril_mutex_unlock(&ep->guard);
[5fd9c30]486 return err;
[17873ac7]487 }
488
489 /* After the critical section, the transfer can already be finished or aborted. */
490 transfer = NULL; batch = NULL;
491 fibril_mutex_unlock(&ep->guard);
[5fd9c30]492
[a4e26882]493 const uint8_t slot_id = xhci_dev->slot_id;
[47e9494]494 /* EP Doorbells start at 1 */
495 const uint8_t target = (xhci_endpoint_index(xhci_ep) + 1) | (batch->target.stream << 16);
[708d8fcd]496 hc_ring_doorbell(hc, slot_id, target);
497 return EOK;
[5fd9c30]498}
Note: See TracBrowser for help on using the repository browser.