Changes in / [85c47729:8b74997f] in mainline
- Location:
- uspace
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/ohci/root_hub.c
r85c47729 r8b74997f 249 249 opResult = EINVAL; 250 250 } 251 usb_transfer_batch_finish _error(request, opResult);251 usb_transfer_batch_finish(request, opResult); 252 252 return EOK; 253 253 } … … 863 863 } 864 864 865 866 867 865 868 /** 866 869 * @} -
uspace/drv/uhci-hcd/hc.c
r85c47729 r8b74997f 332 332 instance->transfers[batch->speed][batch->transfer_type]; 333 333 assert(list); 334 if (batch->transfer_type == USB_TRANSFER_CONTROL) { 335 usb_device_keeper_use_control( 336 &instance->manager, batch->target); 337 } 334 338 transfer_list_add_batch(list, batch); 335 339 … … 369 373 usb_transfer_batch_t *batch = 370 374 list_get_instance(item, usb_transfer_batch_t, link); 371 usb_transfer_batch_finish(batch); 375 switch (batch->transfer_type) 376 { 377 case USB_TRANSFER_CONTROL: 378 usb_device_keeper_release_control( 379 &instance->manager, batch->target); 380 break; 381 case USB_TRANSFER_INTERRUPT: 382 case USB_TRANSFER_ISOCHRONOUS: { 383 /* 384 int ret = bandwidth_free(&instance->bandwidth, 385 batch->target.address, 386 batch->target.endpoint, 387 batch->direction); 388 if (ret != EOK) 389 usb_log_warning("Failed(%d) to free " 390 "reserved bw: %s.\n", ret, 391 str_error(ret)); 392 */ 393 } 394 default: 395 break; 396 } 397 batch->next_step(batch); 372 398 } 373 399 } -
uspace/drv/uhci-hcd/transfer_list.c
r85c47729 r8b74997f 132 132 } 133 133 /*----------------------------------------------------------------------------*/ 134 /** Create list for finished batches. 135 * 136 * @param[in] instance List to use. 137 * @param[in] done list to fill 134 /** Check list for finished batches. 135 * 136 * @param[in] instance List to use. 137 * @return Error code 138 * 139 * Creates a local list of finished batches and calls next_step on each and 140 * every one. This is safer because next_step may theoretically access 141 * this transfer list leading to the deadlock if its done inline. 138 142 */ 139 143 void transfer_list_remove_finished(transfer_list_t *instance, link_t *done) … … 157 161 } 158 162 fibril_mutex_unlock(&instance->guard); 163 159 164 } 160 165 /*----------------------------------------------------------------------------*/ … … 171 176 list_get_instance(current, usb_transfer_batch_t, link); 172 177 transfer_list_remove_batch(instance, batch); 173 usb_transfer_batch_finish _error(batch, EIO);178 usb_transfer_batch_finish(batch, EIO); 174 179 } 175 180 fibril_mutex_unlock(&instance->guard); -
uspace/lib/usb/include/usb/host/batch.h
r85c47729 r8b74997f 92 92 void usb_transfer_batch_call_in(usb_transfer_batch_t *instance); 93 93 void usb_transfer_batch_call_out(usb_transfer_batch_t *instance); 94 void usb_transfer_batch_finish(usb_transfer_batch_t *instance); 95 96 static inline void usb_transfer_batch_finish_error( 97 usb_transfer_batch_t *instance, int error) 98 { 99 assert(instance); 100 instance->error = error; 101 usb_transfer_batch_finish(instance); 102 } 94 void usb_transfer_batch_finish(usb_transfer_batch_t *instance, int error); 103 95 104 96 #endif -
uspace/lib/usb/include/usb/host/device_keeper.h
r85c47729 r8b74997f 96 96 usb_speed_t usb_device_keeper_get_speed(usb_device_keeper_t *instance, 97 97 usb_address_t address); 98 99 void usb_device_keeper_use_control(usb_device_keeper_t *instance, 100 usb_target_t target); 101 102 void usb_device_keeper_release_control(usb_device_keeper_t *instance, 103 usb_target_t target); 104 98 105 #endif 99 106 /** -
uspace/lib/usb/include/usb/host/endpoint.h
r85c47729 r8b74997f 39 39 #include <bool.h> 40 40 #include <adt/list.h> 41 #include <fibril_synch.h>42 43 41 #include <usb/usb.h> 44 42 … … 50 48 usb_speed_t speed; 51 49 size_t max_packet_size; 50 bool active; 52 51 unsigned toggle:1; 53 fibril_mutex_t guard;54 fibril_condvar_t avail;55 volatile bool active;56 52 link_t same_device_eps; 57 53 } endpoint_t; … … 62 58 63 59 void endpoint_destroy(endpoint_t *instance); 64 65 void endpoint_use(endpoint_t *instance);66 67 void endpoint_release(endpoint_t *instance);68 60 69 61 int endpoint_toggle_get(endpoint_t *instance); -
uspace/lib/usb/src/host/batch.c
r85c47729 r8b74997f 79 79 instance->error = EOK; 80 80 instance->ep = ep; 81 endpoint_use(instance->ep);82 81 } 83 82 /*----------------------------------------------------------------------------*/ … … 87 86 * 88 87 */ 89 void usb_transfer_batch_finish(usb_transfer_batch_t *instance )88 void usb_transfer_batch_finish(usb_transfer_batch_t *instance, int error) 90 89 { 91 90 assert(instance); 92 assert(instance->ep); 93 endpoint_release(instance->ep); 91 instance->error = error; 94 92 instance->next_step(instance); 95 93 } -
uspace/lib/usb/src/host/device_keeper.c
r85c47729 r8b74997f 264 264 return instance->devices[address].speed; 265 265 } 266 /*----------------------------------------------------------------------------*/ 267 void usb_device_keeper_use_control( 268 usb_device_keeper_t *instance, usb_target_t target) 269 { 270 assert(instance); 271 const uint16_t ep = 1 << target.endpoint; 272 fibril_mutex_lock(&instance->guard); 273 while (instance->devices[target.address].control_used & ep) { 274 fibril_condvar_wait(&instance->change, &instance->guard); 275 } 276 instance->devices[target.address].control_used |= ep; 277 fibril_mutex_unlock(&instance->guard); 278 } 279 /*----------------------------------------------------------------------------*/ 280 void usb_device_keeper_release_control( 281 usb_device_keeper_t *instance, usb_target_t target) 282 { 283 assert(instance); 284 const uint16_t ep = 1 << target.endpoint; 285 fibril_mutex_lock(&instance->guard); 286 assert((instance->devices[target.address].control_used & ep) != 0); 287 instance->devices[target.address].control_used &= ~ep; 288 fibril_mutex_unlock(&instance->guard); 289 fibril_condvar_signal(&instance->change); 290 } 266 291 /** 267 292 * @} -
uspace/lib/usb/src/host/endpoint.c
r85c47729 r8b74997f 34 34 */ 35 35 36 #include <assert.h>37 36 #include <errno.h> 38 37 #include <usb/host/endpoint.h> … … 50 49 instance->max_packet_size = max_packet_size; 51 50 instance->toggle = 0; 52 instance->active = false;53 fibril_mutex_initialize(&instance->guard);54 fibril_condvar_initialize(&instance->avail);55 51 link_initialize(&instance->same_device_eps); 56 52 return EOK; … … 60 56 { 61 57 assert(instance); 62 assert(!instance->active);63 58 list_remove(&instance->same_device_eps); 64 59 free(instance); 65 }66 /*----------------------------------------------------------------------------*/67 void endpoint_use(endpoint_t *instance)68 {69 assert(instance);70 fibril_mutex_lock(&instance->guard);71 while (instance->active)72 fibril_condvar_wait(&instance->avail, &instance->guard);73 instance->active = true;74 fibril_mutex_unlock(&instance->guard);75 }76 /*----------------------------------------------------------------------------*/77 void endpoint_release(endpoint_t *instance)78 {79 assert(instance);80 fibril_mutex_lock(&instance->guard);81 instance->active = false;82 fibril_mutex_unlock(&instance->guard);83 fibril_condvar_signal(&instance->avail);84 60 } 85 61 /*----------------------------------------------------------------------------*/
Note:
See TracChangeset
for help on using the changeset viewer.