Changeset 9620a54 in mainline for uspace/drv/bus/usb/xhci/bus.c
- Timestamp:
- 2017-10-29T10:51:59Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d33dc780
- Parents:
- 62f8025
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/bus.c
r62f8025 r9620a54 121 121 endpoint_del_ref(ep0_base); 122 122 err_slot: 123 hc_disable_slot(hc, dev ->slot_id);123 hc_disable_slot(hc, dev); 124 124 return err; 125 125 } … … 189 189 190 190 /* Block creation of new endpoints and transfers. */ 191 usb_log_debug2("Device '%s' going offline.", ddf_fun_get_name(dev->fun));191 usb_log_debug2("Device " XHCI_DEV_FMT " going offline.", XHCI_DEV_ARGS(*xhci_dev)); 192 192 fibril_mutex_lock(&dev->guard); 193 193 xhci_dev->online = false; … … 195 195 196 196 /* Abort running transfers. */ 197 usb_log_debug2("Aborting all active transfers to '%s'.", ddf_fun_get_name(dev->fun));197 usb_log_debug2("Aborting all active transfers to device " XHCI_DEV_FMT ".", XHCI_DEV_ARGS(*xhci_dev)); 198 198 for (size_t i = 0; i < ARRAY_SIZE(xhci_dev->endpoints); ++i) { 199 199 xhci_endpoint_t *ep = xhci_dev->endpoints[i]; … … 203 203 /* FIXME: This is racy. */ 204 204 if ((err = xhci_transfer_abort(&ep->active_transfer))) { 205 usb_log_warning("Failed to abort active %s transfer to " 206 " endpoint %d of detached device '%s': %s", 207 usb_str_transfer_type(ep->base.transfer_type), 208 ep->base.endpoint, ddf_fun_get_name(dev->fun), 205 usb_log_warning("Failed to abort active transfer to " 206 " endpoint " XHCI_EP_FMT ": %s", XHCI_EP_ARGS(*ep), 209 207 str_error(err)); 210 208 } … … 215 213 /* Make DDF (and all drivers) forget about the device. */ 216 214 if ((err = ddf_fun_unbind(dev->fun))) { 217 usb_log_warning("Failed to unbind DDF function of device '%s': %s", 218 ddf_fun_get_name(dev->fun), str_error(err)); 219 } 220 221 /* Unregister remaining endpoints. */ 215 usb_log_warning("Failed to unbind DDF function of device " XHCI_DEV_FMT ": %s", 216 XHCI_DEV_ARGS(*xhci_dev), str_error(err)); 217 } 218 219 /* Disable the slot, dropping all endpoints. */ 220 const uint32_t slot_id = xhci_dev->slot_id; 221 if ((err = hc_disable_slot(hc, xhci_dev))) { 222 usb_log_warning("Failed to disable slot of device " XHCI_DEV_FMT ": %s", 223 XHCI_DEV_ARGS(*xhci_dev), str_error(err)); 224 } 225 226 bus->devices_by_slot[slot_id] = NULL; 227 228 /* Unregister remaining endpoints, freeing memory. */ 222 229 for (unsigned i = 0; i < ARRAY_SIZE(xhci_dev->endpoints); ++i) { 223 230 if (!xhci_dev->endpoints[i]) … … 225 232 226 233 if ((err = unregister_endpoint(&bus->base, &xhci_dev->endpoints[i]->base))) { 227 usb_log_warning("Failed to unregister EP (%u:%u): %s", dev->address, i, str_error(err)); 234 usb_log_warning("Failed to unregister endpoint " XHCI_EP_FMT ": %s", 235 XHCI_EP_ARGS(*xhci_dev->endpoints[i]), str_error(err)); 228 236 } 229 237 } 230 231 // XXX: Ugly here. Move to device_destroy at endpoint.c?232 if ((err = hc_disable_slot(hc, xhci_dev->slot_id))) {233 usb_log_warning("Failed to disable slot %d for device '%s': %s",234 xhci_dev->slot_id, ddf_fun_get_name(dev->fun), str_error(err));235 }236 237 free32(xhci_dev->dev_ctx);238 hc->dcbaa[xhci_dev->slot_id] = 0;239 240 bus->devices_by_slot[xhci_dev->slot_id] = NULL;241 238 242 239 /* Destroy DDF device. */ … … 291 288 /* Transition the device from the Addressed to the Configured state. */ 292 289 if ((err = hc_configure_device(hc, dev->slot_id))) { 293 usb_log_warning("Failed to configure device %d.", dev_base->address);290 usb_log_warning("Failed to configure device " XHCI_DEV_FMT ".", XHCI_DEV_ARGS(*dev)); 294 291 } 295 292 296 293 /* Block creation of new endpoints and transfers. */ 297 usb_log_debug2("Device '%s' going online.", ddf_fun_get_name(dev_base->fun));294 usb_log_debug2("Device " XHCI_DEV_FMT " going online.", XHCI_DEV_ARGS(*dev)); 298 295 fibril_mutex_lock(&dev_base->guard); 299 296 dev->online = true; … … 326 323 327 324 /* Block creation of new endpoints and transfers. */ 328 usb_log_debug2("Device '%s' going offline.", ddf_fun_get_name(dev_base->fun));325 usb_log_debug2("Device " XHCI_DEV_FMT " going offline.", XHCI_DEV_ARGS(*dev)); 329 326 fibril_mutex_lock(&dev_base->guard); 330 327 dev->online = false; … … 347 344 /* Issue one HC command to simultaneously drop all endpoints except zero. */ 348 345 if ((err = hc_deconfigure_device(hc, dev->slot_id))) { 349 usb_log_warning("Failed to deconfigure device %d.", dev_base->address); 346 usb_log_warning("Failed to deconfigure device " XHCI_DEV_FMT ".", 347 XHCI_DEV_ARGS(*dev)); 350 348 } 351 349 352 350 /* Tear down TRB ring / PSA. */ 353 /* TODO: Make this method "noexcept" */354 351 for (unsigned i = 1; i < ARRAY_SIZE(endpoints); ++i) { 355 352 if (!endpoints[i]) 356 353 continue; 357 354 358 if ((err = xhci_endpoint_free_transfer_ds(endpoints[i]))) { 359 usb_log_warning("Failed to free resources of EP (%u:%u): %s", dev_base->address, i, str_error(err)); 360 } 355 xhci_endpoint_free_transfer_ds(endpoints[i]); 361 356 } 362 357 … … 404 399 goto err_prepared; 405 400 406 usb_log_info("Endpoint (%d:%d) registered to XHCI bus.", dev->base.address, ep->base.endpoint);401 usb_log_info("Endpoint " XHCI_EP_FMT " registered to XHCI bus.", XHCI_EP_ARGS(*ep)); 407 402 408 403 xhci_ep_ctx_t ep_ctx; … … 428 423 xhci_device_t *dev = xhci_device_get(ep_base->device); 429 424 430 usb_log_info("Endpoint (%d:%d) unregistered from XHCI bus.", dev->base.address, ep->base.endpoint);425 usb_log_info("Endpoint " XHCI_EP_FMT " unregistered from XHCI bus.", XHCI_EP_ARGS(*ep)); 431 426 432 427 xhci_device_remove_endpoint(ep); 433 428 434 /* Drop the endpoint. */ 435 if ((err = hc_drop_endpoint(bus->hc, dev->slot_id, xhci_endpoint_index(ep)))) { 436 usb_log_error("Failed to drop endpoint: %s", str_error(err)); 429 /* If device slot is still available, drop the endpoint. */ 430 if (dev->slot_id) { 431 if ((err = hc_drop_endpoint(bus->hc, dev->slot_id, xhci_endpoint_index(ep)))) { 432 usb_log_error("Failed to drop endpoint " XHCI_EP_FMT ": %s", XHCI_EP_ARGS(*ep), str_error(err)); 433 } 434 } else { 435 usb_log_debug("Not going to drop endpoint " XHCI_EP_FMT " because" 436 " the slot has already been disabled.", XHCI_EP_ARGS(*ep)); 437 437 } 438 438 439 439 /* Tear down TRB ring / PSA. */ 440 /* TODO: Make this method "noexcept" */ 441 if ((err = xhci_endpoint_free_transfer_ds(ep))) { 442 usb_log_error("Failed to free resources of an endpoint."); 443 } 440 xhci_endpoint_free_transfer_ds(ep); 444 441 445 442 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.