Lines Matching refs:hubd
502 static int hubd_cleanup(dev_info_t *dip, hubd_t *hubd);
503 static int hubd_check_ports(hubd_t *hubd);
505 static int hubd_open_intr_pipe(hubd_t *hubd);
506 static void hubd_start_polling(hubd_t *hubd, int always);
507 static void hubd_stop_polling(hubd_t *hubd);
508 static void hubd_close_intr_pipe(hubd_t *hubd);
516 hubd_t *hubd,
522 static int hubd_delete_child(hubd_t *hubd, usb_port_t port, uint_t flag,
525 static int hubd_get_hub_descriptor(hubd_t *hubd);
527 static int hubd_set_hub_depth(hubd_t *hubd);
529 static int hubd_get_hub_status_words(hubd_t *hubd, uint16_t *status);
531 static int hubd_reset_port(hubd_t *hubd, usb_port_t port);
533 static int hubd_get_hub_status(hubd_t *hubd);
535 static int hubd_handle_port_connect(hubd_t *hubd, usb_port_t port);
537 static int hubd_disable_port(hubd_t *hubd, usb_port_t port);
539 static int hubd_enable_port(hubd_t *hubd, usb_port_t port);
540 static int hubd_recover_disabled_port(hubd_t *hubd, usb_port_t port);
542 static int hubd_determine_port_status(hubd_t *hubd, usb_port_t port,
546 static int hubd_enable_all_port_power(hubd_t *hubd);
547 static int hubd_disable_all_port_power(hubd_t *hubd);
548 static int hubd_disable_port_power(hubd_t *hubd, usb_port_t port);
549 static int hubd_enable_port_power(hubd_t *hubd, usb_port_t port);
551 static void hubd_free_usba_device(hubd_t *hubd, usba_device_t *usba_device);
553 static int hubd_can_suspend(hubd_t *hubd);
554 static void hubd_restore_device_state(dev_info_t *dip, hubd_t *hubd);
555 static int hubd_setdevaddr(hubd_t *hubd, usb_port_t port);
556 static void hubd_setdevconfig(hubd_t *hubd, usb_port_t port);
558 static int hubd_register_events(hubd_t *hubd);
559 static void hubd_do_callback(hubd_t *hubd, dev_info_t *dip,
561 static void hubd_run_callbacks(hubd_t *hubd, usba_event_t type);
562 static void hubd_post_event(hubd_t *hubd, usb_port_t port, usba_event_t type);
563 static void hubd_create_pm_components(dev_info_t *dip, hubd_t *hubd);
569 static int hubd_cpr_suspend(hubd_t *hubd);
572 static int hubd_check_same_device(hubd_t *hubd, usb_port_t port);
574 static int hubd_init_power_budget(hubd_t *hubd);
629 hubd_pm_busy_component(hubd_t *hubd, dev_info_t *dip, int component) in hubd_pm_busy_component() argument
631 if (hubd->h_hubpm != NULL) { in hubd_pm_busy_component()
632 hubd->h_hubpm->hubp_busy_pm++; in hubd_pm_busy_component()
633 mutex_exit(HUBD_MUTEX(hubd)); in hubd_pm_busy_component()
635 mutex_enter(HUBD_MUTEX(hubd)); in hubd_pm_busy_component()
636 hubd->h_hubpm->hubp_busy_pm--; in hubd_pm_busy_component()
637 mutex_exit(HUBD_MUTEX(hubd)); in hubd_pm_busy_component()
639 mutex_enter(HUBD_MUTEX(hubd)); in hubd_pm_busy_component()
640 USB_DPRINTF_L4(DPRINT_MASK_PM, hubd->h_log_handle, in hubd_pm_busy_component()
641 "hubd_pm_busy_component: %d", hubd->h_hubpm->hubp_busy_pm); in hubd_pm_busy_component()
648 hubd_pm_idle_component(hubd_t *hubd, dev_info_t *dip, int component) in hubd_pm_idle_component() argument
650 if (hubd->h_hubpm != NULL) { in hubd_pm_idle_component()
651 mutex_exit(HUBD_MUTEX(hubd)); in hubd_pm_idle_component()
653 mutex_enter(HUBD_MUTEX(hubd)); in hubd_pm_idle_component()
654 ASSERT(hubd->h_hubpm->hubp_busy_pm > 0); in hubd_pm_idle_component()
655 hubd->h_hubpm->hubp_busy_pm--; in hubd_pm_idle_component()
656 mutex_exit(HUBD_MUTEX(hubd)); in hubd_pm_idle_component()
658 mutex_enter(HUBD_MUTEX(hubd)); in hubd_pm_idle_component()
659 USB_DPRINTF_L4(DPRINT_MASK_PM, hubd->h_log_handle, in hubd_pm_idle_component()
660 "hubd_pm_idle_component: %d", hubd->h_hubpm->hubp_busy_pm); in hubd_pm_idle_component()
669 hubd_set_child_pwrlvl(hubd_t *hubd, usb_port_t port, uint8_t power) in hubd_set_child_pwrlvl() argument
675 USB_DPRINTF_L4(DPRINT_MASK_PM, hubd->h_log_handle, in hubd_set_child_pwrlvl()
679 mutex_enter(HUBD_MUTEX(hubd)); in hubd_set_child_pwrlvl()
680 hubpm = hubd->h_hubpm; in hubd_set_child_pwrlvl()
683 for (portno = 1; portno <= hubd->h_nports; portno++) { in hubd_set_child_pwrlvl()
688 pwr = hubd->h_hubpm->hubp_child_pwrstate[port]; in hubd_set_child_pwrlvl()
689 hubd->h_hubpm->hubp_child_pwrstate[port] = power; in hubd_set_child_pwrlvl()
692 USB_DPRINTF_L4(DPRINT_MASK_PM, hubd->h_log_handle, in hubd_set_child_pwrlvl()
698 (void) hubd_pm_busy_component(hubd, hubd->h_dip, 0); in hubd_set_child_pwrlvl()
701 (void) hubd_pm_idle_component(hubd, hubd->h_dip, 0); in hubd_set_child_pwrlvl()
703 mutex_exit(HUBD_MUTEX(hubd)); in hubd_set_child_pwrlvl()
711 hubd_child_dip2port(hubd_t *hubd, dev_info_t *dip) in hubd_child_dip2port() argument
715 mutex_enter(HUBD_MUTEX(hubd)); in hubd_child_dip2port()
716 for (port = 1; port <= hubd->h_nports; port++) { in hubd_child_dip2port()
717 if (hubd->h_children_dips[port] == dip) { in hubd_child_dip2port()
722 ASSERT(port <= hubd->h_nports); in hubd_child_dip2port()
723 mutex_exit(HUBD_MUTEX(hubd)); in hubd_child_dip2port()
734 hubd_can_suspend(hubd_t *hubd) in hubd_can_suspend() argument
740 hubpm = hubd->h_hubpm; in hubd_can_suspend()
742 if (DEVI_IS_DETACHING(hubd->h_dip)) { in hubd_can_suspend()
758 (port <= hubd->h_nports); port++) { in hubd_can_suspend()
762 USB_DPRINTF_L4(DPRINT_MASK_PM, hubd->h_log_handle, in hubd_can_suspend()
773 hubd_resume_port(hubd_t *hubd, usb_port_t port) in hubd_resume_port() argument
782 mutex_enter(HUBD_MUTEX(hubd)); in hubd_resume_port()
784 USB_DPRINTF_L4(DPRINT_MASK_PM, hubd->h_log_handle, in hubd_resume_port()
786 hubd->h_dev_state, usb_str_dev_state(hubd->h_dev_state)); in hubd_resume_port()
788 switch (hubd->h_dev_state) { in hubd_resume_port()
794 if ((hubd->h_port_state[port] & PORT_STATUS_PSS) == 0) { in hubd_resume_port()
798 USB_DPRINTF_L2(DPRINT_MASK_PM, hubd->h_log_handle, in hubd_resume_port()
807 mutex_exit(HUBD_MUTEX(hubd)); in hubd_resume_port()
808 if ((rval = usb_pipe_sync_ctrl_xfer(hubd->h_dip, in hubd_resume_port()
809 hubd->h_default_pipe, in hubd_resume_port()
816 USB_DPRINTF_L2(DPRINT_MASK_PM, hubd->h_log_handle, in hubd_resume_port()
821 mutex_enter(HUBD_MUTEX(hubd)); in hubd_resume_port()
824 (void) hubd_determine_port_status(hubd, port, in hubd_resume_port()
837 if (((hubd->h_port_state[port] & PORT_STATUS_CCS) == 0) || in hubd_resume_port()
838 ((hubd->h_port_state[port] & PORT_STATUS_PSS) == 0)) { in hubd_resume_port()
845 USB_DPRINTF_L2(DPRINT_MASK_PM, hubd->h_log_handle, in hubd_resume_port()
853 hubd->h_hotplug_thread++; in hubd_resume_port()
854 hubd_stop_polling(hubd); in hubd_resume_port()
858 mutex_exit(HUBD_MUTEX(hubd)); in hubd_resume_port()
859 rval = usb_pipe_sync_ctrl_xfer(hubd->h_dip, in hubd_resume_port()
860 hubd->h_default_pipe, in hubd_resume_port()
867 mutex_enter(HUBD_MUTEX(hubd)); in hubd_resume_port()
870 hubd->h_log_handle, in hubd_resume_port()
881 mutex_exit(HUBD_MUTEX(hubd)); in hubd_resume_port()
883 mutex_enter(HUBD_MUTEX(hubd)); in hubd_resume_port()
884 (void) hubd_determine_port_status(hubd, port, in hubd_resume_port()
897 hubd->h_hotplug_thread--; in hubd_resume_port()
898 hubd_start_polling(hubd, 0); in hubd_resume_port()
909 USB_DPRINTF_L2(DPRINT_MASK_PM, hubd->h_log_handle, in hubd_resume_port()
914 mutex_exit(HUBD_MUTEX(hubd)); in hubd_resume_port()
924 hubd_suspend_port(hubd_t *hubd, usb_port_t port) in hubd_suspend_port() argument
933 USB_DPRINTF_L4(DPRINT_MASK_PM, hubd->h_log_handle, in hubd_suspend_port()
936 mutex_enter(HUBD_MUTEX(hubd)); in hubd_suspend_port()
938 switch (hubd->h_dev_state) { in hubd_suspend_port()
953 hubd->h_hotplug_thread++; in hubd_suspend_port()
954 hubd_stop_polling(hubd); in hubd_suspend_port()
963 mutex_exit(HUBD_MUTEX(hubd)); in hubd_suspend_port()
964 if ((rval = usb_pipe_sync_ctrl_xfer(hubd->h_dip, in hubd_suspend_port()
965 hubd->h_default_pipe, in hubd_suspend_port()
974 hubd->h_log_handle, in hubd_suspend_port()
987 mutex_enter(HUBD_MUTEX(hubd)); in hubd_suspend_port()
988 (void) hubd_determine_port_status(hubd, port, in hubd_suspend_port()
997 hubd->h_log_handle, in hubd_suspend_port()
1003 hubd->h_hotplug_thread--; in hubd_suspend_port()
1004 hubd_start_polling(hubd, 0); in hubd_suspend_port()
1017 USB_DPRINTF_L2(DPRINT_MASK_PM, hubd->h_log_handle, in hubd_suspend_port()
1022 mutex_exit(HUBD_MUTEX(hubd)); in hubd_suspend_port()
1032 hubd_post_attach(hubd_t *hubd, usb_port_t port, struct attachspec *as) in hubd_post_attach() argument
1036 USB_DPRINTF_L4(DPRINT_MASK_ATTA, hubd->h_log_handle, in hubd_post_attach()
1048 mutex_enter(HUBD_MUTEX(hubd)); in hubd_post_attach()
1049 dip = hubd->h_children_dips[port]; in hubd_post_attach()
1050 mutex_exit(HUBD_MUTEX(hubd)); in hubd_post_attach()
1052 hubd_set_child_pwrlvl(hubd, port, USB_DEV_OS_FULL_PWR); in hubd_post_attach()
1059 hubd_post_detach(hubd_t *hubd, usb_port_t port, struct detachspec *ds) in hubd_post_detach() argument
1061 USB_DPRINTF_L4(DPRINT_MASK_ATTA, hubd->h_log_handle, in hubd_post_detach()
1068 mutex_enter(HUBD_MUTEX(hubd)); in hubd_post_detach()
1070 usba_device_t *usba_device = hubd->h_usba_devices[port]; in hubd_post_detach()
1071 dev_info_t *pdip = hubd->h_dip; in hubd_post_detach()
1072 mutex_exit(HUBD_MUTEX(hubd)); in hubd_post_detach()
1081 hubd_set_child_pwrlvl(hubd, port, USB_DEV_OS_PWR_OFF); in hubd_post_detach()
1088 mutex_exit(HUBD_MUTEX(hubd)); in hubd_post_detach()
1100 hubd_post_power(hubd_t *hubd, usb_port_t port, pm_bp_child_pwrchg_t *bpc, in hubd_post_power() argument
1105 USB_DPRINTF_L4(DPRINT_MASK_PM, hubd->h_log_handle, in hubd_post_power()
1111 hubd_set_child_pwrlvl(hubd, port, bpc->bpc_nlevel); in hubd_post_power()
1116 retval = hubd_suspend_port(hubd, port); in hubd_post_power()
1120 retval = hubd_resume_port(hubd, port); in hubd_post_power()
1125 hubd_set_child_pwrlvl(hubd, port, bpc->bpc_olevel); in hubd_post_power()
1133 retval = hubd_suspend_port(hubd, port); in hubd_post_power()
1155 hubd_t *hubd; in usba_hubdi_bus_ctl() local
1160 hubd = hubd_get_soft_state(dip); in usba_hubdi_bus_ctl()
1162 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_bus_ctl()
1165 hubd->h_bus_ctls++; in usba_hubdi_bus_ctl()
1166 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_bus_ctl()
1168 USB_DPRINTF_L3(DPRINT_MASK_HUBDI, hubd->h_log_handle, in usba_hubdi_bus_ctl()
1176 port = hubd_child_dip2port(hubd, rdip); in usba_hubdi_bus_ctl()
1184 ndi_devi_enter(hubd->h_dip); in usba_hubdi_bus_ctl()
1188 USB_DPRINTF_L4(DPRINT_MASK_PM, hubd->h_log_handle, in usba_hubdi_bus_ctl()
1192 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_bus_ctl()
1193 hubd->h_port_state[port] |= HUBD_CHILD_ATTACHING; in usba_hubdi_bus_ctl()
1196 (void) hubd_pm_busy_component(hubd, dip, 0); in usba_hubdi_bus_ctl()
1197 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_bus_ctl()
1205 rval = hubd_resume_port(hubd, port); in usba_hubdi_bus_ctl()
1212 USB_DPRINTF_L4(DPRINT_MASK_PM, hubd->h_log_handle, in usba_hubdi_bus_ctl()
1216 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_bus_ctl()
1217 hubd->h_port_state[port] &= ~HUBD_CHILD_ATTACHING; in usba_hubdi_bus_ctl()
1218 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_bus_ctl()
1220 hubd_post_attach(hubd, port, (struct attachspec *)arg); in usba_hubdi_bus_ctl()
1222 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_bus_ctl()
1225 (void) hubd_pm_idle_component(hubd, dip, 0); in usba_hubdi_bus_ctl()
1226 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_bus_ctl()
1228 ndi_devi_exit(hubd->h_dip); in usba_hubdi_bus_ctl()
1233 port = hubd_child_dip2port(hubd, rdip); in usba_hubdi_bus_ctl()
1241 ndi_devi_enter(hubd->h_dip); in usba_hubdi_bus_ctl()
1245 USB_DPRINTF_L4(DPRINT_MASK_PM, hubd->h_log_handle, in usba_hubdi_bus_ctl()
1249 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_bus_ctl()
1250 hubd->h_port_state[port] |= HUBD_CHILD_DETACHING; in usba_hubdi_bus_ctl()
1253 (void) hubd_pm_busy_component(hubd, dip, 0); in usba_hubdi_bus_ctl()
1255 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_bus_ctl()
1260 USB_DPRINTF_L4(DPRINT_MASK_PM, hubd->h_log_handle, in usba_hubdi_bus_ctl()
1264 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_bus_ctl()
1265 hubd->h_port_state[port] &= ~HUBD_CHILD_DETACHING; in usba_hubdi_bus_ctl()
1266 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_bus_ctl()
1269 hubd_post_detach(hubd, port, (struct detachspec *)arg); in usba_hubdi_bus_ctl()
1271 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_bus_ctl()
1272 (void) hubd_pm_idle_component(hubd, dip, 0); in usba_hubdi_bus_ctl()
1273 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_bus_ctl()
1277 ndi_devi_exit(hubd->h_dip); in usba_hubdi_bus_ctl()
1285 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_bus_ctl()
1286 hubd->h_bus_ctls--; in usba_hubdi_bus_ctl()
1287 ASSERT(hubd->h_bus_ctls >= 0); in usba_hubdi_bus_ctl()
1288 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_bus_ctl()
1299 hubd_config_one(hubd_t *hubd, int port) in hubd_config_one() argument
1301 dev_info_t *hdip = hubd->h_dip; in hubd_config_one()
1302 dev_info_t *rh_dip = hubd->h_usba_device->usb_root_hub_dip; in hubd_config_one()
1305 USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_config_one()
1320 mutex_enter(HUBD_MUTEX(hubd)); in hubd_config_one()
1322 hubd_pm_busy_component(hubd, hubd->h_dip, 0); in hubd_config_one()
1324 if (!hubd->h_children_dips[port]) { in hubd_config_one()
1327 (void) hubd_determine_port_status(hubd, port, in hubd_config_one()
1331 online_child |= (hubd_handle_port_connect(hubd, in hubd_config_one()
1339 mutex_exit(HUBD_MUTEX(hubd)); in hubd_config_one()
1346 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_config_one()
1349 (void) ndi_devi_online(hubd->h_dip, 0); in hubd_config_one()
1352 mutex_enter(HUBD_MUTEX(hubd)); in hubd_config_one()
1354 (void) hubd_pm_idle_component(hubd, hubd->h_dip, 0); in hubd_config_one()
1356 USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_config_one()
1359 mutex_exit(HUBD_MUTEX(hubd)); in hubd_config_one()
1373 hubd_t *hubd = hubd_get_soft_state(dip); in hubd_bus_config() local
1377 USB_DPRINTF_L4(DPRINT_MASK_PM, hubd->h_log_handle, in hubd_bus_config()
1389 USB_DPRINTF_L2(DPRINT_MASK_PM, hubd->h_log_handle, in hubd_bus_config()
1401 found = hubd_config_one(hubd, port); in hubd_bus_config()
1408 ndi_devi_enter(hubd->h_dip); in hubd_bus_config()
1410 ndi_devi_exit(hubd->h_dip); in hubd_bus_config()
1420 hubd_t *hubd = hubd_get_soft_state(dip); in hubd_bus_unconfig() local
1425 USB_DPRINTF_L4(DPRINT_MASK_PM, hubd->h_log_handle, in hubd_bus_unconfig()
1442 mutex_enter(HUBD_MUTEX(hubd)); in hubd_bus_unconfig()
1443 for (port = 1; port <= hubd->h_nports; port++) { in hubd_bus_unconfig()
1444 hubd->h_port_state[port] |= HUBD_CHILD_ZAP; in hubd_bus_unconfig()
1446 mutex_exit(HUBD_MUTEX(hubd)); in hubd_bus_unconfig()
1457 mutex_enter(HUBD_MUTEX(hubd)); in hubd_bus_unconfig()
1459 hubd->h_children_dips[port] = cdip; in hubd_bus_unconfig()
1460 hubd->h_port_state[port] &= ~HUBD_CHILD_ZAP; in hubd_bus_unconfig()
1461 mutex_exit(HUBD_MUTEX(hubd)); in hubd_bus_unconfig()
1465 mutex_enter(HUBD_MUTEX(hubd)); in hubd_bus_unconfig()
1466 for (port = 1; port <= hubd->h_nports; port++) { in hubd_bus_unconfig()
1467 if (hubd->h_port_state[port] & HUBD_CHILD_ZAP) { in hubd_bus_unconfig()
1469 hubd_free_usba_device(hubd, hubd->h_usba_devices[port]); in hubd_bus_unconfig()
1470 hubd->h_children_dips[port] = NULL; in hubd_bus_unconfig()
1471 hubd->h_port_state[port] &= ~HUBD_CHILD_ZAP; in hubd_bus_unconfig()
1474 mutex_exit(HUBD_MUTEX(hubd)); in hubd_bus_unconfig()
1478 USB_DPRINTF_L4(DPRINT_MASK_PM, hubd->h_log_handle, in hubd_bus_unconfig()
1490 hubd_t *hubd; in hubd_bus_power() local
1497 hubd = hubd_get_soft_state(dip); in hubd_bus_power()
1499 USB_DPRINTF_L4(DPRINT_MASK_HUBDI, hubd->h_log_handle, in hubd_bus_power()
1505 mutex_enter(HUBD_MUTEX(hubd)); in hubd_bus_power()
1506 hubd->h_bus_pwr++; in hubd_bus_power()
1507 mutex_exit(HUBD_MUTEX(hubd)); in hubd_bus_power()
1511 port = hubd_child_dip2port(hubd, bpc->bpc_dip); in hubd_bus_power()
1512 USB_DPRINTF_L3(DPRINT_MASK_HUBDI, hubd->h_log_handle, in hubd_bus_power()
1517 mutex_enter(HUBD_MUTEX(hubd)); in hubd_bus_power()
1523 hubd_pm_busy_component(hubd, dip, 0); in hubd_bus_power()
1529 if ((hubd->h_dev_state == USB_DEV_PWRED_DOWN) && in hubd_bus_power()
1530 hubd->h_hubpm->hubp_wakeup_enabled) { in hubd_bus_power()
1531 mutex_exit(HUBD_MUTEX(hubd)); in hubd_bus_power()
1543 mutex_enter(HUBD_MUTEX(hubd)); in hubd_bus_power()
1544 hubd_pm_idle_component(hubd, dip, 0); in hubd_bus_power()
1545 mutex_exit(HUBD_MUTEX(hubd)); in hubd_bus_power()
1549 mutex_enter(HUBD_MUTEX(hubd)); in hubd_bus_power()
1553 hubd->h_port_state[port] |= HUBD_CHILD_PWRLVL_CHNG; in hubd_bus_power()
1554 mutex_exit(HUBD_MUTEX(hubd)); in hubd_bus_power()
1562 rval = hubd_resume_port(hubd, port); in hubd_bus_power()
1567 mutex_enter(HUBD_MUTEX(hubd)); in hubd_bus_power()
1568 hubd->h_port_state[port] &= in hubd_bus_power()
1570 hubd_pm_idle_component(hubd, dip, 0); in hubd_bus_power()
1571 mutex_exit(HUBD_MUTEX(hubd)); in hubd_bus_power()
1579 port = hubd_child_dip2port(hubd, bpc->bpc_dip); in hubd_bus_power()
1580 USB_DPRINTF_L3(DPRINT_MASK_HUBDI, hubd->h_log_handle, in hubd_bus_power()
1584 mutex_enter(HUBD_MUTEX(hubd)); in hubd_bus_power()
1585 hubd->h_port_state[port] &= ~HUBD_CHILD_PWRLVL_CHNG; in hubd_bus_power()
1586 mutex_exit(HUBD_MUTEX(hubd)); in hubd_bus_power()
1589 rval = hubd_post_power(hubd, port, bpc, *(int *)result); in hubd_bus_power()
1595 mutex_enter(HUBD_MUTEX(hubd)); in hubd_bus_power()
1601 hubd_pm_idle_component(hubd, dip, 0); in hubd_bus_power()
1603 mutex_exit(HUBD_MUTEX(hubd)); in hubd_bus_power()
1612 mutex_enter(HUBD_MUTEX(hubd)); in hubd_bus_power()
1613 hubd->h_bus_pwr--; in hubd_bus_power()
1614 mutex_exit(HUBD_MUTEX(hubd)); in hubd_bus_power()
1624 hubd_pwrlvl0(hubd_t *hubd) in hubd_pwrlvl0() argument
1629 if (hubd->h_hotplug_thread || hubd->h_hubpm->hubp_busy_pm || in hubd_pwrlvl0()
1630 (hubd_can_suspend(hubd) == USB_FAILURE)) { in hubd_pwrlvl0()
1635 switch (hubd->h_dev_state) { in hubd_pwrlvl0()
1637 hubpm = hubd->h_hubpm; in hubd_pwrlvl0()
1644 hubd->h_dev_state = USB_DEV_PWRED_DOWN; in hubd_pwrlvl0()
1651 if (usba_is_root_hub(hubd->h_dip)) { in hubd_pwrlvl0()
1653 USB_DPRINTF_L2(DPRINT_MASK_PM, hubd->h_log_handle, in hubd_pwrlvl0()
1656 hubd_stop_polling(hubd); in hubd_pwrlvl0()
1660 (void) usb_set_device_pwrlvl3(hubd->h_dip); in hubd_pwrlvl0()
1677 hubd_pwrlvl1(hubd_t *hubd) in hubd_pwrlvl1() argument
1680 (void) usb_set_device_pwrlvl2(hubd->h_dip); in hubd_pwrlvl1()
1688 hubd_pwrlvl2(hubd_t *hubd) in hubd_pwrlvl2() argument
1691 (void) usb_set_device_pwrlvl1(hubd->h_dip); in hubd_pwrlvl2()
1698 hubd_pwrlvl3(hubd_t *hubd) in hubd_pwrlvl3() argument
1703 USB_DPRINTF_L2(DPRINT_MASK_PM, hubd->h_log_handle, "hubd_pwrlvl3"); in hubd_pwrlvl3()
1705 hubpm = hubd->h_hubpm; in hubd_pwrlvl3()
1706 switch (hubd->h_dev_state) { in hubd_pwrlvl3()
1709 if (usba_is_root_hub(hubd->h_dip)) { in hubd_pwrlvl3()
1712 hubd->h_log_handle, in hubd_pwrlvl3()
1716 rval = usb_set_device_pwrlvl0(hubd->h_dip); in hubd_pwrlvl3()
1718 hubd->h_dev_state = USB_DEV_ONLINE; in hubd_pwrlvl3()
1721 hubd_start_polling(hubd, 0); in hubd_pwrlvl3()
1740 USB_DPRINTF_L2(DPRINT_MASK_PM, hubd->h_log_handle, in hubd_pwrlvl3()
1741 "hubd_pwrlvl3: Illegal dev_state=%d", hubd->h_dev_state); in hubd_pwrlvl3()
1753 hubd_t *hubd; in usba_hubdi_power() local
1757 hubd = hubd_get_soft_state(dip); in usba_hubdi_power()
1758 USB_DPRINTF_L3(DPRINT_MASK_HUBDI, hubd->h_log_handle, in usba_hubdi_power()
1763 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_power()
1764 hubpm = hubd->h_hubpm; in usba_hubdi_power()
1768 USB_DPRINTF_L2(DPRINT_MASK_HUBDI, hubd->h_log_handle, in usba_hubdi_power()
1771 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_power()
1780 retval = hubd_pwrlvl0(hubd); in usba_hubdi_power()
1784 retval = hubd_pwrlvl1(hubd); in usba_hubdi_power()
1788 retval = hubd_pwrlvl2(hubd); in usba_hubdi_power()
1792 retval = hubd_pwrlvl3(hubd); in usba_hubdi_power()
1800 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_power()
1823 hubd_t *hubd = NULL; in usba_hubdi_attach() local
1854 hubd = hubd_get_soft_state(dip); in usba_hubdi_attach()
1879 hubd = hubd_get_soft_state(dip); in usba_hubdi_attach()
1880 if (hubd == NULL) { in usba_hubdi_attach()
1885 hubd->h_log_handle = usb_alloc_log_hdl(dip, log_name, &hubd_errlevel, in usba_hubdi_attach()
1888 hubd->h_usba_device = child_ud = usba_get_usba_device(dip); in usba_hubdi_attach()
1889 hubd->h_dip = dip; in usba_hubdi_attach()
1890 hubd->h_instance = instance; in usba_hubdi_attach()
1902 USB_DPRINTF_L0(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_attach()
1907 hubd->h_pipe_policy.pp_max_async_reqs = 1; in usba_hubdi_attach()
1911 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_attach()
1917 if (usb_get_dev_data(dip, &hubd->h_dev_data, in usba_hubdi_attach()
1919 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_attach()
1925 if ((ep_data = usb_lookup_ep_data(dip, hubd->h_dev_data, in usba_hubdi_attach()
1926 hubd->h_dev_data->dev_curr_if, 0, 0, in usba_hubdi_attach()
1928 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_attach()
1935 &hubd->h_ep1_xdescr) != USB_SUCCESS) { in usba_hubdi_attach()
1939 hubd->h_default_pipe = hubd->h_dev_data->dev_default_ph; in usba_hubdi_attach()
1941 mutex_init(HUBD_MUTEX(hubd), NULL, MUTEX_DRIVER, in usba_hubdi_attach()
1942 hubd->h_dev_data->dev_iblock_cookie); in usba_hubdi_attach()
1943 cv_init(&hubd->h_cv_reset_port, NULL, CV_DRIVER, NULL); in usba_hubdi_attach()
1944 cv_init(&hubd->h_cv_hotplug_dev, NULL, CV_DRIVER, NULL); in usba_hubdi_attach()
1946 hubd->h_init_state |= HUBD_LOCKS_DONE; in usba_hubdi_attach()
1948 usb_free_descr_tree(dip, hubd->h_dev_data); in usba_hubdi_attach()
1955 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_attach()
1960 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_attach()
1961 hubd->h_init_state |= HUBD_HUBDI_REGISTERED; in usba_hubdi_attach()
1962 hubd->h_dev_state = USB_DEV_ONLINE; in usba_hubdi_attach()
1963 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_attach()
1966 hubd_create_pm_components(dip, hubd); in usba_hubdi_attach()
1974 (void) ndi_event_alloc_hdl(dip, 0, &hubd->h_ndi_event_hdl, NDI_SLEEP); in usba_hubdi_attach()
1977 if (ndi_event_bind_set(hubd->h_ndi_event_hdl, &hubd_ndi_events, in usba_hubdi_attach()
1979 USB_DPRINTF_L3(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_attach()
1986 if (hubd_register_events(hubd) != USB_SUCCESS) { in usba_hubdi_attach()
1987 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_attach()
1993 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_attach()
1994 hubd->h_init_state |= HUBD_EVENTS_REGISTERED; in usba_hubdi_attach()
1996 if (hubd_get_hub_descriptor(hubd) != USB_SUCCESS) { in usba_hubdi_attach()
1997 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_attach()
2011 if (hubd->h_usba_device->usb_hcdi_ops->usba_hcdi_hub_update != NULL && in usba_hubdi_attach()
2015 usba_device_t *ud = hubd->h_usba_device; in usba_hubdi_attach()
2017 chars = (hubd->h_hub_chars & HUB_CHARS_TT_THINK_TIME) >> in usba_hubdi_attach()
2020 hubd->h_nports, chars); in usba_hubdi_attach()
2022 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_attach()
2027 if (hubd_set_hub_depth(hubd) != USB_SUCCESS) { in usba_hubdi_attach()
2035 hubd->h_ignore_pwr_budget = B_TRUE; in usba_hubdi_attach()
2037 hubd->h_ignore_pwr_budget = B_FALSE; in usba_hubdi_attach()
2040 if (hubd_init_power_budget(hubd) != USB_SUCCESS) { in usba_hubdi_attach()
2041 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_attach()
2043 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_attach()
2050 if (hubd_check_ports(hubd) != USB_SUCCESS) { in usba_hubdi_attach()
2051 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_attach()
2053 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_attach()
2061 hubd->h_ancestry_str = (char *)kmem_zalloc(HUBD_APID_NAMELEN, KM_SLEEP); in usba_hubdi_attach()
2062 hubd_get_ancestry_str(hubd); in usba_hubdi_attach()
2064 USB_DPRINTF_L4(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_attach()
2065 "#ports=0x%x", hubd->h_nports); in usba_hubdi_attach()
2067 for (i = 1; i <= hubd->h_nports; i++) { in usba_hubdi_attach()
2071 hubd->h_ancestry_str, i); in usba_hubdi_attach()
2072 USB_DPRINTF_L4(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_attach()
2077 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_attach()
2080 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_attach()
2086 ports_count = hubd->h_nports; in usba_hubdi_attach()
2087 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_attach()
2093 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_attach()
2099 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_attach()
2100 hubd->h_init_state |= HUBD_MINOR_NODE_CREATED; in usba_hubdi_attach()
2101 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_attach()
2105 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_attach()
2118 hubd->h_cleanup_enabled = B_TRUE; in usba_hubdi_attach()
2119 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_attach()
2120 hubd_pm_idle_component(hubd, dip, 0); in usba_hubdi_attach()
2121 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_attach()
2135 if (hubd != NULL) { in usba_hubdi_attach()
2136 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_attach()
2137 hubd_pm_idle_component(hubd, dip, 0); in usba_hubdi_attach()
2138 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_attach()
2140 rval = hubd_cleanup(dip, hubd); in usba_hubdi_attach()
2154 hubd_t *hubd = hubd_get_soft_state(dip); in usba_hubdi_detach() local
2157 USB_DPRINTF_L4(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_detach()
2162 rval = hubd_cleanup(dip, hubd); in usba_hubdi_detach()
2166 rval = hubd_cpr_suspend(hubd); in usba_hubdi_detach()
2180 hubd_setdevaddr(hubd_t *hubd, usb_port_t port) in hubd_setdevaddr() argument
2192 USB_DPRINTF_L4(DPRINT_MASK_ATTA, hubd->h_log_handle, in hubd_setdevaddr()
2195 ASSERT(mutex_owned(HUBD_MUTEX(hubd))); in hubd_setdevaddr()
2197 child_dip = hubd->h_children_dips[port]; in hubd_setdevaddr()
2198 address = hubd->h_usba_devices[port]->usb_addr; in hubd_setdevaddr()
2199 usba_device = hubd->h_usba_devices[port]; in hubd_setdevaddr()
2202 mutex_exit(HUBD_MUTEX(hubd)); in hubd_setdevaddr()
2206 mutex_enter(HUBD_MUTEX(hubd)); in hubd_setdevaddr()
2213 mutex_exit(HUBD_MUTEX(hubd)); in hubd_setdevaddr()
2216 mutex_enter(HUBD_MUTEX(hubd)); in hubd_setdevaddr()
2231 mutex_exit(HUBD_MUTEX(hubd)); in hubd_setdevaddr()
2240 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in hubd_setdevaddr()
2255 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in hubd_setdevaddr()
2275 mutex_enter(HUBD_MUTEX(hubd)); in hubd_setdevaddr()
2288 hubd_setdevconfig(hubd_t *hubd, usb_port_t port) in hubd_setdevconfig() argument
2298 USB_DPRINTF_L4(DPRINT_MASK_ATTA, hubd->h_log_handle, in hubd_setdevconfig()
2301 ASSERT(mutex_owned(HUBD_MUTEX(hubd))); in hubd_setdevconfig()
2303 child_dip = hubd->h_children_dips[port]; in hubd_setdevconfig()
2304 usba_device = hubd->h_usba_devices[port]; in hubd_setdevconfig()
2305 config_value = hubd->h_usba_devices[port]->usb_cfg_value; in hubd_setdevconfig()
2306 mutex_exit(HUBD_MUTEX(hubd)); in hubd_setdevconfig()
2322 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in hubd_setdevconfig()
2334 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in hubd_setdevconfig()
2337 mutex_enter(HUBD_MUTEX(hubd)); in hubd_setdevconfig()
2346 hubd_t *hubd; in hubd_check_disconnected_ports() local
2370 hubd = hubd_get_soft_state(dip); in hubd_check_disconnected_ports()
2371 if (hubd == NULL) { in hubd_check_disconnected_ports()
2380 mutex_enter(HUBD_MUTEX(hubd)); in hubd_check_disconnected_ports()
2381 for (port = 1; port <= hubd->h_nports; port++) { in hubd_check_disconnected_ports()
2382 dev_info_t *cdip = hubd->h_children_dips[port]; in hubd_check_disconnected_ports()
2388 (void) hubd_delete_child(hubd, port, NDI_DEVI_REMOVE, in hubd_check_disconnected_ports()
2391 mutex_exit(HUBD_MUTEX(hubd)); in hubd_check_disconnected_ports()
2530 hubd_restore_device_state(dev_info_t *dip, hubd_t *hubd) in hubd_restore_device_state() argument
2541 USB_DPRINTF_L4(DPRINT_MASK_ATTA, hubd->h_log_handle, in hubd_restore_device_state()
2544 mutex_enter(HUBD_MUTEX(hubd)); in hubd_restore_device_state()
2545 hub_prev_state = hubd->h_dev_state; in hubd_restore_device_state()
2549 (void) hubd_pm_busy_component(hubd, dip, 0); in hubd_restore_device_state()
2550 mutex_exit(HUBD_MUTEX(hubd)); in hubd_restore_device_state()
2555 (usb_check_same_device(dip, hubd->h_log_handle, USB_LOG_L0, in hubd_restore_device_state()
2560 mutex_enter(HUBD_MUTEX(hubd)); in hubd_restore_device_state()
2561 hubd->h_dev_state = USB_DEV_DISCONNECTED; in hubd_restore_device_state()
2562 (void) hubd_pm_idle_component(hubd, dip, 0); in hubd_restore_device_state()
2563 mutex_exit(HUBD_MUTEX(hubd)); in hubd_restore_device_state()
2570 mutex_enter(HUBD_MUTEX(hubd)); in hubd_restore_device_state()
2572 rval = hubd_disable_all_port_power(hubd); in hubd_restore_device_state()
2574 USB_DPRINTF_L3(DPRINT_MASK_ATTA, hubd->h_log_handle, in hubd_restore_device_state()
2580 mutex_exit(HUBD_MUTEX(hubd)); in hubd_restore_device_state()
2582 mutex_enter(HUBD_MUTEX(hubd)); in hubd_restore_device_state()
2585 if (hubd_enable_all_port_power(hubd) != USB_SUCCESS) { in hubd_restore_device_state()
2586 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in hubd_restore_device_state()
2590 (void) hubd_disable_all_port_power(hubd); in hubd_restore_device_state()
2592 (void) hubd_pm_idle_component(hubd, dip, 0); in hubd_restore_device_state()
2593 mutex_exit(HUBD_MUTEX(hubd)); in hubd_restore_device_state()
2602 mutex_exit(HUBD_MUTEX(hubd)); in hubd_restore_device_state()
2604 mutex_enter(HUBD_MUTEX(hubd)); in hubd_restore_device_state()
2606 hubd->h_dev_state = USB_DEV_HUB_STATE_RECOVER; in hubd_restore_device_state()
2608 for (port = 1; port <= hubd->h_nports; port++) { in hubd_restore_device_state()
2609 USB_DPRINTF_L3(DPRINT_MASK_ATTA, hubd->h_log_handle, in hubd_restore_device_state()
2617 ch_dip = hubd->h_children_dips[port]; in hubd_restore_device_state()
2620 (void) hubd_determine_port_status(hubd, port, in hubd_restore_device_state()
2631 (void) hubd_reset_port(hubd, port); in hubd_restore_device_state()
2634 (void) hubd_enable_port(hubd, port); in hubd_restore_device_state()
2637 mutex_exit(HUBD_MUTEX(hubd)); in hubd_restore_device_state()
2640 mutex_enter(HUBD_MUTEX(hubd)); in hubd_restore_device_state()
2643 rval = hubd_setdevaddr(hubd, port); in hubd_restore_device_state()
2648 hubd_setdevconfig(hubd, port); in hubd_restore_device_state()
2652 mutex_exit(HUBD_MUTEX(hubd)); in hubd_restore_device_state()
2653 hubd_post_event(hubd, port, in hubd_restore_device_state()
2655 mutex_enter(HUBD_MUTEX(hubd)); in hubd_restore_device_state()
2662 mutex_exit(HUBD_MUTEX(hubd)); in hubd_restore_device_state()
2673 mutex_enter(HUBD_MUTEX(hubd)); in hubd_restore_device_state()
2682 mutex_exit(HUBD_MUTEX(hubd)); in hubd_restore_device_state()
2685 hubd->h_log_handle, in hubd_restore_device_state()
2693 mutex_enter(HUBD_MUTEX(hubd)); in hubd_restore_device_state()
2697 (void) hubd_determine_port_status(hubd, port, in hubd_restore_device_state()
2709 (void) hubd_reset_port(hubd, port); in hubd_restore_device_state()
2711 (void) hubd_determine_port_status(hubd, port, in hubd_restore_device_state()
2722 (void) hubd_toggle_port(hubd, port); in hubd_restore_device_state()
2725 hubd->h_log_handle, in hubd_restore_device_state()
2737 if (hubd->h_hubpm->hubp_wakeup_enabled) { in hubd_restore_device_state()
2738 mutex_exit(HUBD_MUTEX(hubd)); in hubd_restore_device_state()
2739 (void) usb_handle_remote_wakeup(hubd->h_dip, in hubd_restore_device_state()
2741 mutex_enter(HUBD_MUTEX(hubd)); in hubd_restore_device_state()
2744 hubd->h_dev_state = USB_DEV_ONLINE; in hubd_restore_device_state()
2745 hubd_start_polling(hubd, 0); in hubd_restore_device_state()
2746 (void) hubd_pm_idle_component(hubd, dip, 0); in hubd_restore_device_state()
2747 mutex_exit(HUBD_MUTEX(hubd)); in hubd_restore_device_state()
2760 hubd_cleanup(dev_info_t *dip, hubd_t *hubd) in hubd_cleanup() argument
2768 USB_DPRINTF_L4(DPRINT_MASK_ATTA, hubd->h_log_handle, in hubd_cleanup()
2771 if ((hubd->h_init_state & HUBD_LOCKS_DONE) == 0) { in hubd_cleanup()
2778 mutex_enter(HUBD_MUTEX(hubd)); in hubd_cleanup()
2782 dev_info_t *rh_dip = hubd->h_usba_device->usb_root_hub_dip; in hubd_cleanup()
2790 if (hubd->h_bus_ctls || hubd->h_bus_pwr || in hubd_cleanup()
2791 hubd->h_hotplug_thread) { in hubd_cleanup()
2792 mutex_exit(HUBD_MUTEX(hubd)); in hubd_cleanup()
2795 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in hubd_cleanup()
2809 if (hubd->h_cleanup_needed || in hubd_cleanup()
2810 hubd->h_cleanup_active) { in hubd_cleanup()
2811 mutex_exit(HUBD_MUTEX(hubd)); in hubd_cleanup()
2815 hubd->h_log_handle, in hubd_cleanup()
2824 old_dev_state = hubd->h_dev_state; in hubd_cleanup()
2825 hubd->h_dev_state = USB_DEV_DISCONNECTED; in hubd_cleanup()
2827 USB_DPRINTF_L4(DPRINT_MASK_ATTA, hubd->h_log_handle, in hubd_cleanup()
2829 hubd_close_intr_pipe(hubd); in hubd_cleanup()
2831 ASSERT((hubd->h_bus_ctls || hubd->h_bus_pwr || in hubd_cleanup()
2832 hubd->h_hotplug_thread) == 0); in hubd_cleanup()
2833 mutex_exit(HUBD_MUTEX(hubd)); in hubd_cleanup()
2839 if (hubd->h_ndi_event_hdl) { in hubd_cleanup()
2841 rval = ndi_event_free_hdl(hubd->h_ndi_event_hdl); in hubd_cleanup()
2849 USB_DPRINTF_L2(DPRINT_MASK_ALL, hubd->h_log_handle, in hubd_cleanup()
2858 mutex_enter(HUBD_MUTEX(hubd)); in hubd_cleanup()
2860 if (hubd->h_init_state & HUBD_CHILDREN_CREATED) { in hubd_cleanup()
2862 for (port = 1; port <= hubd->h_nports; port++) { in hubd_cleanup()
2863 ASSERT(hubd->h_usba_devices[port] == NULL); in hubd_cleanup()
2864 ASSERT(hubd->h_children_dips[port] == NULL); in hubd_cleanup()
2867 kmem_free(hubd->h_children_dips, hubd->h_cd_list_length); in hubd_cleanup()
2868 kmem_free(hubd->h_usba_devices, hubd->h_cd_list_length); in hubd_cleanup()
2879 if (hubd->h_init_state & HUBD_EVENTS_REGISTERED) { in hubd_cleanup()
2880 mutex_exit(HUBD_MUTEX(hubd)); in hubd_cleanup()
2882 hubd_unregister_cpr_callback(hubd); in hubd_cleanup()
2883 mutex_enter(HUBD_MUTEX(hubd)); in hubd_cleanup()
2887 hubd->h_dev_state = old_dev_state; in hubd_cleanup()
2888 hubpm = hubd->h_hubpm; in hubd_cleanup()
2890 if ((hubpm) && (hubd->h_dev_state != USB_DEV_DISCONNECTED)) { in hubd_cleanup()
2891 (void) hubd_pm_busy_component(hubd, dip, 0); in hubd_cleanup()
2892 mutex_exit(HUBD_MUTEX(hubd)); in hubd_cleanup()
2893 if (hubd->h_hubpm->hubp_wakeup_enabled) { in hubd_cleanup()
2900 if ((rval = usb_handle_remote_wakeup(hubd->h_dip, in hubd_cleanup()
2903 hubd->h_log_handle, in hubd_cleanup()
2909 (void) pm_lower_power(hubd->h_dip, 0, USB_DEV_OS_PWR_OFF); in hubd_cleanup()
2911 mutex_enter(HUBD_MUTEX(hubd)); in hubd_cleanup()
2912 (void) hubd_pm_idle_component(hubd, dip, 0); in hubd_cleanup()
2922 mutex_exit(HUBD_MUTEX(hubd)); in hubd_cleanup()
2924 USB_DPRINTF_L4(DPRINT_MASK_ATTA, hubd->h_log_handle, in hubd_cleanup()
2927 if (hubd->h_init_state & HUBD_HUBDI_REGISTERED) { in hubd_cleanup()
2932 if (hubd->h_init_state & HUBD_LOCKS_DONE) { in hubd_cleanup()
2933 mutex_destroy(HUBD_MUTEX(hubd)); in hubd_cleanup()
2934 cv_destroy(&hubd->h_cv_reset_port); in hubd_cleanup()
2935 cv_destroy(&hubd->h_cv_hotplug_dev); in hubd_cleanup()
2940 if (hubd->h_init_state & HUBD_MINOR_NODE_CREATED) { in hubd_cleanup()
2945 usb_pipe_close(dip, hubd->h_default_pipe, in hubd_cleanup()
2950 if (hubd->h_ancestry_str) { in hubd_cleanup()
2951 kmem_free(hubd->h_ancestry_str, HUBD_APID_NAMELEN); in hubd_cleanup()
2954 usb_client_detach(dip, hubd->h_dev_data); in hubd_cleanup()
2956 usb_free_log_hdl(hubd->h_log_handle); in hubd_cleanup()
2976 hubd_determine_port_connection(hubd_t *hubd) in hubd_determine_port_connection() argument
2983 ASSERT(mutex_owned(HUBD_MUTEX(hubd))); in hubd_determine_port_connection()
2985 for (port = 1; port <= hubd->h_nports; port++) { in hubd_determine_port_connection()
2987 (void) hubd_determine_port_status(hubd, port, &status, in hubd_determine_port_connection()
3021 hubd_check_ports(hubd_t *hubd) in hubd_check_ports() argument
3027 ASSERT(mutex_owned(HUBD_MUTEX(hubd))); in hubd_check_ports()
3029 USB_DPRINTF_L4(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_check_ports()
3030 "hubd_check_ports: addr=0x%x", usb_get_addr(hubd->h_dip)); in hubd_check_ports()
3035 if ((rval = hubd_disable_all_port_power(hubd)) != USB_SUCCESS) { in hubd_check_ports()
3038 (void) hubd_disable_all_port_power(hubd); in hubd_check_ports()
3047 mutex_exit(HUBD_MUTEX(hubd)); in hubd_check_ports()
3049 mutex_enter(HUBD_MUTEX(hubd)); in hubd_check_ports()
3054 if ((rval = hubd_enable_all_port_power(hubd)) != USB_SUCCESS) { in hubd_check_ports()
3056 (void) hubd_disable_all_port_power(hubd); in hubd_check_ports()
3062 mutex_exit(HUBD_MUTEX(hubd)); in hubd_check_ports()
3064 mutex_enter(HUBD_MUTEX(hubd)); in hubd_check_ports()
3071 hubd->h_cd_list_length = in hubd_check_ports()
3072 (sizeof (dev_info_t **)) * (hubd->h_nports + 1); in hubd_check_ports()
3074 hubd->h_children_dips = (dev_info_t **)kmem_zalloc( in hubd_check_ports()
3075 hubd->h_cd_list_length, KM_SLEEP); in hubd_check_ports()
3076 hubd->h_usba_devices = (usba_device_t **)kmem_zalloc( in hubd_check_ports()
3077 hubd->h_cd_list_length, KM_SLEEP); in hubd_check_ports()
3079 hubd->h_init_state |= HUBD_CHILDREN_CREATED; in hubd_check_ports()
3081 mutex_exit(HUBD_MUTEX(hubd)); in hubd_check_ports()
3084 mutex_enter(HUBD_MUTEX(hubd)); in hubd_check_ports()
3086 if ((rval = hubd_open_intr_pipe(hubd)) != USB_SUCCESS) { in hubd_check_ports()
3092 hubd_start_polling(hubd, 0); in hubd_check_ports()
3104 port_change = hubd_determine_port_connection(hubd); in hubd_check_ports()
3106 if (port_change != 0 || hubd->h_port_change != 0) { in hubd_check_ports()
3107 hubd_pm_busy_component(hubd, hubd->h_dip, 0); in hubd_check_ports()
3109 arg->hubd = hubd; in hubd_check_ports()
3111 hubd->h_port_change |= port_change; in hubd_check_ports()
3113 USB_DPRINTF_L3(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_check_ports()
3115 hubd->h_port_change); in hubd_check_ports()
3117 if (usb_async_req(hubd->h_dip, hubd_hotplug_thread, in hubd_check_ports()
3119 hubd->h_hotplug_thread++; in hubd_check_ports()
3122 hubd_pm_idle_component(hubd, hubd->h_dip, 0); in hubd_check_ports()
3129 USB_DPRINTF_L4(DPRINT_MASK_ATTA, hubd->h_log_handle, in hubd_check_ports()
3140 hubd_get_hub_descriptor(hubd_t *hubd) in hubd_get_hub_descriptor() argument
3149 USB_DPRINTF_L4(DPRINT_MASK_HUB, hubd->h_log_handle, in hubd_get_hub_descriptor()
3152 if ((hubd->h_dev_data->dev_descr->idVendor == USB_HUB_INTEL_VID) && in hubd_get_hub_descriptor()
3153 (hubd->h_dev_data->dev_descr->idProduct == USB_HUB_INTEL_PID)) { in hubd_get_hub_descriptor()
3157 ASSERT(mutex_owned(HUBD_MUTEX(hubd))); in hubd_get_hub_descriptor()
3158 ASSERT(hubd->h_default_pipe != 0); in hubd_get_hub_descriptor()
3160 mutex_exit(HUBD_MUTEX(hubd)); in hubd_get_hub_descriptor()
3167 if (hubd->h_usba_device->usb_port_status >= USBA_SUPER_SPEED_DEV) { in hubd_get_hub_descriptor()
3179 if ((rval = usb_pipe_sync_ctrl_xfer(hubd->h_dip, in hubd_get_hub_descriptor()
3180 hubd->h_default_pipe, in hubd_get_hub_descriptor()
3188 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in hubd_get_hub_descriptor()
3192 mutex_enter(HUBD_MUTEX(hubd)); in hubd_get_hub_descriptor()
3204 rval = usb_pipe_sync_ctrl_xfer(hubd->h_dip, in hubd_get_hub_descriptor()
3205 hubd->h_default_pipe, in hubd_get_hub_descriptor()
3219 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in hubd_get_hub_descriptor()
3225 mutex_enter(HUBD_MUTEX(hubd)); in hubd_get_hub_descriptor()
3231 mutex_enter(HUBD_MUTEX(hubd)); in hubd_get_hub_descriptor()
3240 if (hubd->h_usba_device->usb_port_status >= USBA_SUPER_SPEED_DEV) { in hubd_get_hub_descriptor()
3252 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in hubd_get_hub_descriptor()
3258 hubd->h_nports = hub_descr.bNbrPorts; in hubd_get_hub_descriptor()
3259 hubd->h_hub_chars = hub_descr.wHubCharacteristics; in hubd_get_hub_descriptor()
3260 hubd->h_power_good = hub_descr.bPwrOn2PwrGood; in hubd_get_hub_descriptor()
3261 hubd->h_current = hub_descr.bHubContrCurrent; in hubd_get_hub_descriptor()
3267 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in hubd_get_hub_descriptor()
3273 hubd->h_nports = hub_descr.bNbrPorts; in hubd_get_hub_descriptor()
3274 hubd->h_hub_chars = hub_descr.wHubCharacteristics; in hubd_get_hub_descriptor()
3275 hubd->h_power_good = hub_descr.bPwrOn2PwrGood; in hubd_get_hub_descriptor()
3276 hubd->h_current = hub_descr.bHubContrCurrent; in hubd_get_hub_descriptor()
3281 USB_DPRINTF_L4(DPRINT_MASK_ATTA, hubd->h_log_handle, in hubd_get_hub_descriptor()
3284 hubd->h_nports, hubd->h_hub_chars, in hubd_get_hub_descriptor()
3285 hubd->h_power_good, hubd->h_current); in hubd_get_hub_descriptor()
3287 if (hubd->h_nports > MAX_PORTS) { in hubd_get_hub_descriptor()
3288 USB_DPRINTF_L0(DPRINT_MASK_ATTA, hubd->h_log_handle, in hubd_get_hub_descriptor()
3291 MAX_PORTS, MAX_PORTS, hubd->h_nports); in hubd_get_hub_descriptor()
3293 hubd->h_nports = MAX_PORTS; in hubd_get_hub_descriptor()
3300 hubd_set_hub_depth(hubd_t *hubd) in hubd_set_hub_depth() argument
3313 if (hubd->h_usba_device->usb_port_status < USBA_SUPER_SPEED_DEV || in hubd_set_hub_depth()
3314 usba_is_root_hub(hubd->h_dip)) in hubd_set_hub_depth()
3318 ud = hubd->h_usba_device; in hubd_set_hub_depth()
3328 ud = hubd->h_usba_device; in hubd_set_hub_depth()
3348 if ((rval = usb_pipe_sync_ctrl_xfer(hubd->h_dip, in hubd_set_hub_depth()
3349 hubd->h_default_pipe, in hubd_set_hub_depth()
3357 USB_DPRINTF_L2(DPRINT_MASK_HUB, hubd->h_log_handle, in hubd_set_hub_depth()
3369 hubd_get_hub_status_words(hubd_t *hubd, uint16_t *status) in hubd_get_hub_status_words() argument
3375 ASSERT(mutex_owned(HUBD_MUTEX(hubd))); in hubd_get_hub_status_words()
3377 mutex_exit(HUBD_MUTEX(hubd)); in hubd_get_hub_status_words()
3379 if (usb_pipe_sync_ctrl_xfer(hubd->h_dip, hubd->h_default_pipe, in hubd_get_hub_status_words()
3387 USB_DPRINTF_L2(DPRINT_MASK_HUB, hubd->h_log_handle, in hubd_get_hub_status_words()
3395 mutex_enter(HUBD_MUTEX(hubd)); in hubd_get_hub_status_words()
3400 mutex_enter(HUBD_MUTEX(hubd)); in hubd_get_hub_status_words()
3405 USB_DPRINTF_L3(DPRINT_MASK_HUB, hubd->h_log_handle, in hubd_get_hub_status_words()
3420 hubd_open_intr_pipe(hubd_t *hubd) in hubd_open_intr_pipe() argument
3424 USB_DPRINTF_L4(DPRINT_MASK_HUB, hubd->h_log_handle, in hubd_open_intr_pipe()
3427 ASSERT(hubd->h_intr_pipe_state == HUBD_INTR_PIPE_IDLE); in hubd_open_intr_pipe()
3429 hubd->h_intr_pipe_state = HUBD_INTR_PIPE_OPENING; in hubd_open_intr_pipe()
3430 mutex_exit(HUBD_MUTEX(hubd)); in hubd_open_intr_pipe()
3432 if ((rval = usb_pipe_xopen(hubd->h_dip, in hubd_open_intr_pipe()
3433 &hubd->h_ep1_xdescr, &hubd->h_pipe_policy, in hubd_open_intr_pipe()
3434 0, &hubd->h_ep1_ph)) != USB_SUCCESS) { in hubd_open_intr_pipe()
3435 USB_DPRINTF_L2(DPRINT_MASK_HUB, hubd->h_log_handle, in hubd_open_intr_pipe()
3438 mutex_enter(HUBD_MUTEX(hubd)); in hubd_open_intr_pipe()
3439 hubd->h_intr_pipe_state = HUBD_INTR_PIPE_IDLE; in hubd_open_intr_pipe()
3444 mutex_enter(HUBD_MUTEX(hubd)); in hubd_open_intr_pipe()
3445 hubd->h_intr_pipe_state = HUBD_INTR_PIPE_ACTIVE; in hubd_open_intr_pipe()
3447 USB_DPRINTF_L4(DPRINT_MASK_HUB, hubd->h_log_handle, in hubd_open_intr_pipe()
3448 "open intr pipe succeeded, ph=0x%p", (void *)hubd->h_ep1_ph); in hubd_open_intr_pipe()
3459 hubd_start_polling(hubd_t *hubd, int always) in hubd_start_polling() argument
3465 USB_DPRINTF_L4(DPRINT_MASK_HUB, hubd->h_log_handle, in hubd_start_polling()
3468 always, hubd->h_dev_state, hubd->h_intr_pipe_state, in hubd_start_polling()
3469 hubd->h_hotplug_thread, (void *)hubd->h_ep1_ph); in hubd_start_polling()
3476 ((hubd->h_dev_state == USB_DEV_ONLINE) && in hubd_start_polling()
3477 (hubd->h_intr_pipe_state == HUBD_INTR_PIPE_ACTIVE) && in hubd_start_polling()
3478 (hubd->h_hotplug_thread == 0) && hubd->h_ep1_ph)) { in hubd_start_polling()
3479 USB_DPRINTF_L4(DPRINT_MASK_HUB, hubd->h_log_handle, in hubd_start_polling()
3482 reqp = usb_alloc_intr_req(hubd->h_dip, 0, USB_FLAGS_SLEEP); in hubd_start_polling()
3484 reqp->intr_client_private = (usb_opaque_t)hubd; in hubd_start_polling()
3487 reqp->intr_len = hubd->h_ep1_xdescr.uex_ep.wMaxPacketSize; in hubd_start_polling()
3490 mutex_exit(HUBD_MUTEX(hubd)); in hubd_start_polling()
3491 if ((rval = usb_pipe_intr_xfer(hubd->h_ep1_ph, reqp, in hubd_start_polling()
3493 USB_DPRINTF_L2(DPRINT_MASK_HUB, hubd->h_log_handle, in hubd_start_polling()
3498 rval = usb_pipe_get_state(hubd->h_ep1_ph, &pipe_state, in hubd_start_polling()
3501 USB_DPRINTF_L2(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_start_polling()
3504 USB_DPRINTF_L4(DPRINT_MASK_HUB, hubd->h_log_handle, in hubd_start_polling()
3507 mutex_enter(HUBD_MUTEX(hubd)); in hubd_start_polling()
3517 hubd_stop_polling(hubd_t *hubd) in hubd_stop_polling() argument
3522 if (hubd->h_ep1_ph) { in hubd_stop_polling()
3523 USB_DPRINTF_L4(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_stop_polling()
3525 hubd->h_intr_pipe_state = HUBD_INTR_PIPE_STOPPED; in hubd_stop_polling()
3526 mutex_exit(HUBD_MUTEX(hubd)); in hubd_stop_polling()
3528 usb_pipe_stop_intr_polling(hubd->h_ep1_ph, USB_FLAGS_SLEEP); in hubd_stop_polling()
3529 rval = usb_pipe_get_state(hubd->h_ep1_ph, &pipe_state, in hubd_stop_polling()
3533 USB_DPRINTF_L2(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_stop_polling()
3536 mutex_enter(HUBD_MUTEX(hubd)); in hubd_stop_polling()
3537 if (hubd->h_intr_pipe_state == HUBD_INTR_PIPE_STOPPED) { in hubd_stop_polling()
3538 hubd->h_intr_pipe_state = HUBD_INTR_PIPE_ACTIVE; in hubd_stop_polling()
3550 hubd_close_intr_pipe(hubd_t *hubd) in hubd_close_intr_pipe() argument
3552 USB_DPRINTF_L4(DPRINT_MASK_HUB, hubd->h_log_handle, in hubd_close_intr_pipe()
3559 hubd->h_intr_pipe_state = HUBD_INTR_PIPE_CLOSING; in hubd_close_intr_pipe()
3561 ASSERT(hubd->h_hotplug_thread == 0); in hubd_close_intr_pipe()
3563 if (hubd->h_ep1_ph) { in hubd_close_intr_pipe()
3564 mutex_exit(HUBD_MUTEX(hubd)); in hubd_close_intr_pipe()
3565 usb_pipe_close(hubd->h_dip, hubd->h_ep1_ph, USB_FLAGS_SLEEP, in hubd_close_intr_pipe()
3567 mutex_enter(HUBD_MUTEX(hubd)); in hubd_close_intr_pipe()
3568 hubd->h_ep1_ph = NULL; in hubd_close_intr_pipe()
3571 hubd->h_intr_pipe_state = HUBD_INTR_PIPE_IDLE; in hubd_close_intr_pipe()
3585 hubd_t *hubd = (hubd_t *)(reqp->intr_client_private); in hubd_exception_cb() local
3587 USB_DPRINTF_L2(DPRINT_MASK_CALLBACK, hubd->h_log_handle, in hubd_exception_cb()
3595 mutex_enter(HUBD_MUTEX(hubd)); in hubd_exception_cb()
3596 (void) hubd_pm_busy_component(hubd, hubd->h_dip, 0); in hubd_exception_cb()
3601 if ((hubd->h_intr_pipe_state == HUBD_INTR_PIPE_ACTIVE) && in hubd_exception_cb()
3602 (hubd->h_port_reset_wait == 0)) { in hubd_exception_cb()
3603 hubd_start_polling(hubd, 0); in hubd_exception_cb()
3619 (void) hubd_pm_idle_component(hubd, hubd->h_dip, 0); in hubd_exception_cb()
3620 mutex_exit(HUBD_MUTEX(hubd)); in hubd_exception_cb()
3660 hubd_t *hubd = (hubd_t *)(reqp->intr_client_private); in hubd_read_cb() local
3666 USB_DPRINTF_L4(DPRINT_MASK_HUB, hubd->h_log_handle, in hubd_read_cb()
3686 mutex_enter(HUBD_MUTEX(hubd)); in hubd_read_cb()
3688 if ((hubd->h_dev_state == USB_DEV_SUSPENDED) || in hubd_read_cb()
3689 (hubd->h_intr_pipe_state != HUBD_INTR_PIPE_ACTIVE)) { in hubd_read_cb()
3690 mutex_exit(HUBD_MUTEX(hubd)); in hubd_read_cb()
3697 ASSERT(hubd->h_ep1_ph == pipe); in hubd_read_cb()
3718 hubd->h_port_change |= port_change & in hubd_read_cb()
3719 ~hubd->h_port_reset_wait; in hubd_read_cb()
3721 USB_DPRINTF_L3(DPRINT_MASK_CALLBACK, hubd->h_log_handle, in hubd_read_cb()
3723 hubd->h_port_change, hubd->h_port_reset_wait); in hubd_read_cb()
3726 if (hubd->h_port_reset_wait & port_change) { in hubd_read_cb()
3727 hubd->h_port_reset_wait = 0; in hubd_read_cb()
3728 cv_signal(&hubd->h_cv_reset_port); in hubd_read_cb()
3735 if ((hubd->h_dev_state == USB_DEV_ONLINE) && in hubd_read_cb()
3736 (!DEVI_IS_ATTACHING(hubd->h_dip)) && in hubd_read_cb()
3737 (!DEVI_IS_DETACHING(hubd->h_dip)) && in hubd_read_cb()
3738 (hubd->h_port_change) && in hubd_read_cb()
3739 (hubd->h_hotplug_thread == 0)) { in hubd_read_cb()
3740 USB_DPRINTF_L3(DPRINT_MASK_CALLBACK, hubd->h_log_handle, in hubd_read_cb()
3742 "dev_state=%d", hubd->h_dev_state); in hubd_read_cb()
3749 (void) hubd_pm_busy_component(hubd, hubd->h_dip, 0); in hubd_read_cb()
3751 arg->hubd = hubd; in hubd_read_cb()
3754 if (usb_async_req(hubd->h_dip, in hubd_read_cb()
3757 hubd->h_hotplug_thread++; in hubd_read_cb()
3761 (void) hubd_pm_idle_component(hubd, in hubd_read_cb()
3762 hubd->h_dip, 0); in hubd_read_cb()
3766 mutex_exit(HUBD_MUTEX(hubd)); in hubd_read_cb()
3787 hubd_t *hubd = hd_arg->hubd; in hubd_hotplug_thread() local
3793 dev_info_t *hdip = hubd->h_dip; in hubd_hotplug_thread()
3794 dev_info_t *rh_dip = hubd->h_usba_device->usb_root_hub_dip; in hubd_hotplug_thread()
3801 USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_hotplug_thread()
3823 mutex_enter(HUBD_MUTEX(hubd)); in hubd_hotplug_thread()
3824 if (hubd->h_bus_pwr || (hubd->h_hotplug_thread > 1)) { in hubd_hotplug_thread()
3825 hubd->h_hotplug_thread--; in hubd_hotplug_thread()
3828 hubd_pm_idle_component(hubd, hubd->h_dip, 0); in hubd_hotplug_thread()
3829 mutex_exit(HUBD_MUTEX(hubd)); in hubd_hotplug_thread()
3831 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_hotplug_thread()
3837 mutex_exit(HUBD_MUTEX(hubd)); in hubd_hotplug_thread()
3841 mutex_enter(HUBD_MUTEX(hubd)); in hubd_hotplug_thread()
3845 if (hubd->h_dev_state == USB_DEV_PWRED_DOWN) { in hubd_hotplug_thread()
3846 hubpm = hubd->h_hubpm; in hubd_hotplug_thread()
3851 mutex_exit(HUBD_MUTEX(hubd)); in hubd_hotplug_thread()
3853 USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_hotplug_thread()
3859 mutex_enter(HUBD_MUTEX(hubd)); in hubd_hotplug_thread()
3860 hubd->h_dev_state = USB_DEV_ONLINE; in hubd_hotplug_thread()
3864 USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_hotplug_thread()
3868 mutex_exit(HUBD_MUTEX(hubd)); in hubd_hotplug_thread()
3881 mutex_enter(HUBD_MUTEX(hubd)); in hubd_hotplug_thread()
3883 ASSERT(hubd->h_intr_pipe_state == HUBD_INTR_PIPE_ACTIVE); in hubd_hotplug_thread()
3885 nports = hubd->h_nports; in hubd_hotplug_thread()
3887 hubd_stop_polling(hubd); in hubd_hotplug_thread()
3889 while ((hubd->h_dev_state == USB_DEV_ONLINE) && in hubd_hotplug_thread()
3890 (hubd->h_port_change)) { in hubd_hotplug_thread()
3895 if (hubd->h_port_change & HUB_CHANGE_STATUS) { in hubd_hotplug_thread()
3896 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_hotplug_thread()
3903 hubd->h_port_change &= ~HUB_CHANGE_STATUS; in hubd_hotplug_thread()
3910 (void) hubd_get_hub_status(hubd); in hubd_hotplug_thread()
3919 (hubd->h_port_state[port] & PORT_STATUS_CCS) && in hubd_hotplug_thread()
3920 (hubd->h_children_dips[port]); in hubd_hotplug_thread()
3922 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_hotplug_thread()
3925 port, port_mask, hubd->h_port_change, in hubd_hotplug_thread()
3931 if ((hubd->h_port_change & port_mask) == 0) { in hubd_hotplug_thread()
3935 hubd->h_port_change &= ~port_mask; in hubd_hotplug_thread()
3938 (void) hubd_determine_port_status(hubd, port, in hubd_hotplug_thread()
3941 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_hotplug_thread()
3949 hubd->h_log_handle, in hubd_hotplug_thread()
3961 (hubd_recover_disabled_port(hubd, in hubd_hotplug_thread()
3974 (hubd_handle_port_connect(hubd, in hubd_hotplug_thread()
3985 child_dip = hubd->h_children_dips[port]; in hubd_hotplug_thread()
3987 mutex_exit(HUBD_MUTEX(hubd)); in hubd_hotplug_thread()
4003 hubd_post_event(hubd, port, in hubd_hotplug_thread()
4005 mutex_enter(HUBD_MUTEX(hubd)); in hubd_hotplug_thread()
4013 hubd, port) == USB_SUCCESS); in hubd_hotplug_thread()
4015 mutex_exit(HUBD_MUTEX(hubd)); in hubd_hotplug_thread()
4019 mutex_enter(HUBD_MUTEX(hubd)); in hubd_hotplug_thread()
4022 mutex_exit(HUBD_MUTEX(hubd)); in hubd_hotplug_thread()
4023 hubd_post_event(hubd, port, in hubd_hotplug_thread()
4025 mutex_enter(HUBD_MUTEX(hubd)); in hubd_hotplug_thread()
4037 hubd->h_children_dips[port]) { in hubd_hotplug_thread()
4042 dip = hubd->h_children_dips[port]; in hubd_hotplug_thread()
4061 hubd->h_port_state[port] |= in hubd_hotplug_thread()
4064 mutex_exit(HUBD_MUTEX(hubd)); in hubd_hotplug_thread()
4072 mutex_enter(HUBD_MUTEX(hubd)); in hubd_hotplug_thread()
4082 hubd->h_log_handle, in hubd_hotplug_thread()
4096 (void) hubd_enable_port_power(hubd, in hubd_hotplug_thread()
4104 mutex_exit(HUBD_MUTEX(hubd)); in hubd_hotplug_thread()
4106 mutex_enter(HUBD_MUTEX(hubd)); in hubd_hotplug_thread()
4113 mutex_exit(HUBD_MUTEX(hubd)); in hubd_hotplug_thread()
4124 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_hotplug_thread()
4127 (void) ndi_devi_online(hubd->h_dip, 0); in hubd_hotplug_thread()
4132 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_hotplug_thread()
4135 hubd_schedule_cleanup(hubd->h_usba_device->usb_root_hub_dip); in hubd_hotplug_thread()
4138 mutex_enter(HUBD_MUTEX(hubd)); in hubd_hotplug_thread()
4142 old_state = hubd->h_dev_state; in hubd_hotplug_thread()
4143 hubd->h_dev_state = USB_DEV_HUB_CHILD_PWRLVL; in hubd_hotplug_thread()
4145 if (hubd->h_port_state[port] & HUBD_CHILD_RAISE_POWER) { in hubd_hotplug_thread()
4146 dev_info_t *dip = hubd->h_children_dips[port]; in hubd_hotplug_thread()
4148 mutex_exit(HUBD_MUTEX(hubd)); in hubd_hotplug_thread()
4158 mutex_enter(HUBD_MUTEX(hubd)); in hubd_hotplug_thread()
4159 hubd->h_port_state[port] &= in hubd_hotplug_thread()
4167 if (hubd->h_dev_state == USB_DEV_HUB_CHILD_PWRLVL) { in hubd_hotplug_thread()
4168 hubd->h_dev_state = old_state; in hubd_hotplug_thread()
4182 if (hubd->h_reset_port[port]) { in hubd_hotplug_thread()
4188 hubd_start_polling(hubd, HUBD_ALWAYS_START_POLLING); in hubd_hotplug_thread()
4200 hubd->h_hotplug_thread--; in hubd_hotplug_thread()
4203 (void) hubd_pm_idle_component(hubd, hubd->h_dip, 0); in hubd_hotplug_thread()
4205 cv_broadcast(&hubd->h_cv_hotplug_dev); in hubd_hotplug_thread()
4207 USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_hotplug_thread()
4210 mutex_exit(HUBD_MUTEX(hubd)); in hubd_hotplug_thread()
4223 hubd_handle_port_connect(hubd_t *hubd, usb_port_t port) in hubd_handle_port_connect() argument
4238 usba_device = hubd->h_usba_device; in hubd_handle_port_connect()
4262 mutex_exit(HUBD_MUTEX(hubd)); in hubd_handle_port_connect()
4264 mutex_enter(HUBD_MUTEX(hubd)); in hubd_handle_port_connect()
4269 for (retry = 0; (hubd->h_dev_state == USB_DEV_ONLINE) && in hubd_handle_port_connect()
4271 USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_handle_port_connect()
4274 if ((rval = hubd_reset_port(hubd, port)) != USB_SUCCESS) { in hubd_handle_port_connect()
4275 (void) hubd_determine_port_status(hubd, in hubd_handle_port_connect()
4296 (void) hubd_enable_port(hubd, port); in hubd_handle_port_connect()
4304 mutex_exit(HUBD_MUTEX(hubd)); in hubd_handle_port_connect()
4306 mutex_enter(HUBD_MUTEX(hubd)); in hubd_handle_port_connect()
4315 (void) hubd_enable_port(hubd, port); in hubd_handle_port_connect()
4318 if ((rval = hubd_determine_port_status(hubd, port, &status, in hubd_handle_port_connect()
4321 USB_DPRINTF_L2(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_handle_port_connect()
4324 (void) hubd_disable_port(hubd, port); in hubd_handle_port_connect()
4330 USB_DPRINTF_L0(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_handle_port_connect()
4333 (void) hubd_disable_port(hubd, port); in hubd_handle_port_connect()
4336 (void) hubd_determine_port_status(hubd, in hubd_handle_port_connect()
4344 USB_DPRINTF_L2(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_handle_port_connect()
4357 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_handle_port_connect()
4366 if (hubd->h_children_dips[port]) { in hubd_handle_port_connect()
4368 rval = hubd_setdevaddr(hubd, port); in hubd_handle_port_connect()
4376 mutex_exit(HUBD_MUTEX(hubd)); in hubd_handle_port_connect()
4379 mutex_enter(HUBD_MUTEX(hubd)); in hubd_handle_port_connect()
4387 if ((hubd->h_reset_port[port]) && in hubd_handle_port_connect()
4388 (hubd_check_same_device(hubd, in hubd_handle_port_connect()
4399 hubd_setdevconfig(hubd, port); in hubd_handle_port_connect()
4407 if (hubd->h_reset_port[port]) { in hubd_handle_port_connect()
4416 mutex_exit(HUBD_MUTEX(hubd)); in hubd_handle_port_connect()
4417 hubd_post_event(hubd, port, in hubd_handle_port_connect()
4419 mutex_enter(HUBD_MUTEX(hubd)); in hubd_handle_port_connect()
4436 rval = hubd_create_child(hubd->h_dip, in hubd_handle_port_connect()
4437 hubd, in hubd_handle_port_connect()
4438 hubd->h_usba_device, in hubd_handle_port_connect()
4442 usba_update_hotplug_stats(hubd->h_dip, in hubd_handle_port_connect()
4445 hubd->h_total_hotplug_success++; in hubd_handle_port_connect()
4450 hubd->h_log_handle, in hubd_handle_port_connect()
4465 USB_DPRINTF_L2(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_handle_port_connect()
4468 (void) hubd_disable_port(hubd, port); in hubd_handle_port_connect()
4470 mutex_exit(HUBD_MUTEX(hubd)); in hubd_handle_port_connect()
4472 mutex_enter(HUBD_MUTEX(hubd)); in hubd_handle_port_connect()
4475 USB_DPRINTF_L2(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_handle_port_connect()
4492 hubd->h_log_handle, in hubd_handle_port_connect()
4497 hubd->h_log_handle, in hubd_handle_port_connect()
4501 (void) hubd_disable_port(hubd, port); in hubd_handle_port_connect()
4502 usba_update_hotplug_stats(hubd->h_dip, in hubd_handle_port_connect()
4504 hubd->h_total_hotplug_failure++; in hubd_handle_port_connect()
4511 (void) hubd_disable_port(hubd, port); in hubd_handle_port_connect()
4514 (void) hubd_determine_port_status(hubd, in hubd_handle_port_connect()
4527 hubd_get_hub_status(hubd_t *hubd) in hubd_get_hub_status() argument
4541 USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_get_hub_status()
4544 ASSERT(mutex_owned(HUBD_MUTEX(hubd))); in hubd_get_hub_status()
4546 if ((hubd_get_hub_status_words(hubd, stword)) != USB_SUCCESS) { in hubd_get_hub_status()
4553 mutex_exit(HUBD_MUTEX(hubd)); in hubd_get_hub_status()
4556 usb_cfg = usb_get_raw_cfg_data(hubd->h_dip, &cfg_length); in hubd_get_hub_status()
4564 USB_DPRINTF_L2(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_get_hub_status()
4567 mutex_enter(HUBD_MUTEX(hubd)); in hubd_get_hub_status()
4592 hubd->h_log_handle, in hubd_get_hub_status()
4601 hubd->h_log_handle, in hubd_get_hub_status()
4610 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_get_hub_status()
4613 if ((rval = usb_pipe_sync_ctrl_xfer(hubd->h_dip, in hubd_get_hub_status()
4614 hubd->h_default_pipe, in hubd_get_hub_status()
4623 hubd->h_log_handle, in hubd_get_hub_status()
4635 if (usba_is_root_hub(hubd->h_dip)) { in hubd_get_hub_status()
4643 hubd->h_log_handle, in hubd_get_hub_status()
4660 hubd->h_log_handle, in hubd_get_hub_status()
4669 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_get_hub_status()
4672 if ((rval = usb_pipe_sync_ctrl_xfer(hubd->h_dip, in hubd_get_hub_status()
4673 hubd->h_default_pipe, in hubd_get_hub_status()
4682 hubd->h_log_handle, in hubd_get_hub_status()
4693 if (!usba_is_root_hub(hubd->h_dip)) { in hubd_get_hub_status()
4695 mutex_enter(HUBD_MUTEX(hubd)); in hubd_get_hub_status()
4701 (void) hubd_determine_port_status(hubd, 1, &status, in hubd_get_hub_status()
4708 for (port = 1; port <= hubd->h_nports; port++) { in hubd_get_hub_status()
4709 (void) hubd_enable_port_power(hubd, port); in hubd_get_hub_status()
4712 mutex_exit(HUBD_MUTEX(hubd)); in hubd_get_hub_status()
4722 mutex_enter(HUBD_MUTEX(hubd)); in hubd_get_hub_status()
4733 hubd_status_uniform(hubd_t *hubd, usb_port_t port, uint16_t *status, in hubd_status_uniform() argument
4738 hubd->h_port_raw[port] = os; in hubd_status_uniform()
4740 if (hubd->h_usba_device->usb_port_status >= USBA_SUPER_SPEED_DEV) { in hubd_status_uniform()
4750 if (usba_is_root_hub(hubd->h_dip)) { in hubd_status_uniform()
4791 hubd_reset_port(hubd_t *hubd, usb_port_t port) in hubd_reset_port() argument
4803 USB_DPRINTF_L4(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_reset_port()
4806 ASSERT(mutex_owned(HUBD_MUTEX(hubd))); in hubd_reset_port()
4808 hubd->h_port_reset_wait |= port_mask; in hubd_reset_port()
4810 mutex_exit(HUBD_MUTEX(hubd)); in hubd_reset_port()
4812 if ((rval = usb_pipe_sync_ctrl_xfer(hubd->h_dip, in hubd_reset_port()
4813 hubd->h_default_pipe, in hubd_reset_port()
4821 USB_DPRINTF_L2(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_reset_port()
4825 mutex_enter(HUBD_MUTEX(hubd)); in hubd_reset_port()
4830 mutex_enter(HUBD_MUTEX(hubd)); in hubd_reset_port()
4832 USB_DPRINTF_L4(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_reset_port()
4848 hubd->h_port_reset_wait |= port_mask; in hubd_reset_port()
4852 hubd_start_polling(hubd, HUBD_ALWAYS_START_POLLING); in hubd_reset_port()
4858 delta = cv_reltimedwait(&hubd->h_cv_reset_port, in hubd_reset_port()
4859 &hubd->h_mutex, delta, TR_CLOCK_TICK); in hubd_reset_port()
4861 hubd->h_port_reset_wait &= ~port_mask; in hubd_reset_port()
4863 hubd_stop_polling(hubd); in hubd_reset_port()
4868 mutex_exit(HUBD_MUTEX(hubd)); in hubd_reset_port()
4869 if ((rval = usb_pipe_sync_ctrl_xfer(hubd->h_dip, in hubd_reset_port()
4870 hubd->h_default_pipe, in hubd_reset_port()
4879 hubd->h_log_handle, in hubd_reset_port()
4887 mutex_enter(HUBD_MUTEX(hubd)); in hubd_reset_port()
4897 hubd_status_uniform(hubd, port, &status, NULL); in hubd_reset_port()
4905 mutex_enter(HUBD_MUTEX(hubd)); in hubd_reset_port()
4911 USB_DPRINTF_L3(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_reset_port()
4913 mutex_enter(HUBD_MUTEX(hubd)); in hubd_reset_port()
4917 USB_DPRINTF_L3(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_reset_port()
4922 USB_DPRINTF_L3(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_reset_port()
4925 if (usb_pipe_sync_ctrl_xfer(hubd->h_dip, in hubd_reset_port()
4926 hubd->h_default_pipe, in hubd_reset_port()
4935 hubd->h_log_handle, in hubd_reset_port()
4947 USB_DPRINTF_L3(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_reset_port()
4950 if (usb_pipe_sync_ctrl_xfer(hubd->h_dip, in hubd_reset_port()
4951 hubd->h_default_pipe, in hubd_reset_port()
4960 hubd->h_log_handle, in hubd_reset_port()
4968 mutex_enter(HUBD_MUTEX(hubd)); in hubd_reset_port()
4982 hubd_enable_port(hubd_t *hubd, usb_port_t port) in hubd_enable_port() argument
4988 USB_DPRINTF_L4(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_enable_port()
4991 ASSERT(mutex_owned(HUBD_MUTEX(hubd))); in hubd_enable_port()
4993 mutex_exit(HUBD_MUTEX(hubd)); in hubd_enable_port()
4996 if (!usba_is_root_hub(hubd->h_dip)) { in hubd_enable_port()
4997 mutex_enter(HUBD_MUTEX(hubd)); in hubd_enable_port()
5002 if ((rval = usb_pipe_sync_ctrl_xfer(hubd->h_dip, in hubd_enable_port()
5003 hubd->h_default_pipe, in hubd_enable_port()
5011 USB_DPRINTF_L2(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_enable_port()
5016 mutex_enter(HUBD_MUTEX(hubd)); in hubd_enable_port()
5018 USB_DPRINTF_L4(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_enable_port()
5029 hubd_disable_port(hubd_t *hubd, usb_port_t port) in hubd_disable_port() argument
5035 USB_DPRINTF_L4(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_disable_port()
5038 ASSERT(mutex_owned(HUBD_MUTEX(hubd))); in hubd_disable_port()
5040 mutex_exit(HUBD_MUTEX(hubd)); in hubd_disable_port()
5042 if ((rval = usb_pipe_sync_ctrl_xfer(hubd->h_dip, in hubd_disable_port()
5043 hubd->h_default_pipe, in hubd_disable_port()
5051 USB_DPRINTF_L2(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_disable_port()
5054 mutex_enter(HUBD_MUTEX(hubd)); in hubd_disable_port()
5059 USB_DPRINTF_L3(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_disable_port()
5062 if ((rval = usb_pipe_sync_ctrl_xfer(hubd->h_dip, in hubd_disable_port()
5063 hubd->h_default_pipe, in hubd_disable_port()
5072 hubd->h_log_handle, in hubd_disable_port()
5077 mutex_enter(HUBD_MUTEX(hubd)); in hubd_disable_port()
5082 mutex_enter(HUBD_MUTEX(hubd)); in hubd_disable_port()
5092 hubd_determine_port_status(hubd_t *hubd, usb_port_t port, uint16_t *status, in hubd_determine_port_status() argument
5112 USB_DPRINTF_L4(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_determine_port_status()
5114 hubd->h_port_state[port], ack_flag); in hubd_determine_port_status()
5116 ASSERT(mutex_owned(HUBD_MUTEX(hubd))); in hubd_determine_port_status()
5118 mutex_exit(HUBD_MUTEX(hubd)); in hubd_determine_port_status()
5120 if ((rval = usb_pipe_sync_ctrl_xfer(hubd->h_dip, in hubd_determine_port_status()
5121 hubd->h_default_pipe, in hubd_determine_port_status()
5129 USB_DPRINTF_L2(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_determine_port_status()
5137 mutex_enter(HUBD_MUTEX(hubd)); in hubd_determine_port_status()
5142 mutex_enter(HUBD_MUTEX(hubd)); in hubd_determine_port_status()
5144 USB_DPRINTF_L2(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_determine_port_status()
5155 hubd_status_uniform(hubd, port, status, speed); in hubd_determine_port_status()
5157 USB_DPRINTF_L3(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_determine_port_status()
5163 USB_DPRINTF_L3(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_determine_port_status()
5166 hubd->h_port_state[port] |= (PORT_STATUS_CCS & ack_flag); in hubd_determine_port_status()
5168 USB_DPRINTF_L3(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_determine_port_status()
5171 hubd->h_port_state[port] &= ~(PORT_STATUS_CCS & ack_flag); in hubd_determine_port_status()
5175 USB_DPRINTF_L3(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_determine_port_status()
5178 hubd->h_port_state[port] |= (PORT_STATUS_PES & ack_flag); in hubd_determine_port_status()
5180 USB_DPRINTF_L3(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_determine_port_status()
5183 hubd->h_port_state[port] &= ~(PORT_STATUS_PES & ack_flag); in hubd_determine_port_status()
5187 USB_DPRINTF_L3(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_determine_port_status()
5190 hubd->h_port_state[port] |= (PORT_STATUS_PSS & ack_flag); in hubd_determine_port_status()
5192 USB_DPRINTF_L3(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_determine_port_status()
5195 hubd->h_port_state[port] &= ~(PORT_STATUS_PSS & ack_flag); in hubd_determine_port_status()
5199 USB_DPRINTF_L3(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_determine_port_status()
5202 hubd->h_port_state[port] |= (PORT_CHANGE_PRSC & ack_flag); in hubd_determine_port_status()
5205 hubd->h_port_state[port] &= ~(PORT_CHANGE_PRSC & ack_flag); in hubd_determine_port_status()
5209 USB_DPRINTF_L2(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_determine_port_status()
5212 hubd->h_port_state[port] |= (PORT_STATUS_POCI & ack_flag); in hubd_determine_port_status()
5215 hubd->h_port_state[port] &= ~(PORT_STATUS_POCI & ack_flag); in hubd_determine_port_status()
5219 USB_DPRINTF_L3(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_determine_port_status()
5222 hubd->h_port_state[port] |= (PORT_STATUS_PRS & ack_flag); in hubd_determine_port_status()
5224 USB_DPRINTF_L3(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_determine_port_status()
5227 hubd->h_port_state[port] &= ~(PORT_STATUS_PRS & ack_flag); in hubd_determine_port_status()
5230 USB_DPRINTF_L3(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_determine_port_status()
5233 hubd->h_port_state[port] |= (PORT_STATUS_PPS & ack_flag); in hubd_determine_port_status()
5235 USB_DPRINTF_L3(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_determine_port_status()
5238 hubd->h_port_state[port] &= ~(PORT_STATUS_PPS & ack_flag); in hubd_determine_port_status()
5245 mutex_exit(HUBD_MUTEX(hubd)); in hubd_determine_port_status()
5247 USB_DPRINTF_L3(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_determine_port_status()
5249 if ((rval = usb_pipe_sync_ctrl_xfer(hubd->h_dip, in hubd_determine_port_status()
5250 hubd->h_default_pipe, in hubd_determine_port_status()
5259 hubd->h_log_handle, in hubd_determine_port_status()
5266 USB_DPRINTF_L3(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_determine_port_status()
5268 if ((rval = usb_pipe_sync_ctrl_xfer(hubd->h_dip, in hubd_determine_port_status()
5269 hubd->h_default_pipe, in hubd_determine_port_status()
5278 hubd->h_log_handle, in hubd_determine_port_status()
5285 USB_DPRINTF_L3(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_determine_port_status()
5288 if ((rval = usb_pipe_sync_ctrl_xfer(hubd->h_dip, in hubd_determine_port_status()
5289 hubd->h_default_pipe, in hubd_determine_port_status()
5298 hubd->h_log_handle, in hubd_determine_port_status()
5305 USB_DPRINTF_L3(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_determine_port_status()
5308 if ((rval = usb_pipe_sync_ctrl_xfer(hubd->h_dip, in hubd_determine_port_status()
5309 hubd->h_default_pipe, in hubd_determine_port_status()
5318 hubd->h_log_handle, in hubd_determine_port_status()
5325 USB_DPRINTF_L3(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_determine_port_status()
5327 if ((rval = usb_pipe_sync_ctrl_xfer(hubd->h_dip, in hubd_determine_port_status()
5328 hubd->h_default_pipe, in hubd_determine_port_status()
5337 hubd->h_log_handle, in hubd_determine_port_status()
5344 USB_DPRINTF_L3(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_determine_port_status()
5346 if ((rval = usb_pipe_sync_ctrl_xfer(hubd->h_dip, in hubd_determine_port_status()
5347 hubd->h_default_pipe, in hubd_determine_port_status()
5356 hubd->h_log_handle, in hubd_determine_port_status()
5363 USB_DPRINTF_L3(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_determine_port_status()
5365 if ((rval = usb_pipe_sync_ctrl_xfer(hubd->h_dip, in hubd_determine_port_status()
5366 hubd->h_default_pipe, in hubd_determine_port_status()
5375 hubd->h_log_handle, in hubd_determine_port_status()
5382 USB_DPRINTF_L3(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_determine_port_status()
5384 if ((rval = usb_pipe_sync_ctrl_xfer(hubd->h_dip, in hubd_determine_port_status()
5385 hubd->h_default_pipe, in hubd_determine_port_status()
5394 hubd->h_log_handle, in hubd_determine_port_status()
5400 mutex_enter(HUBD_MUTEX(hubd)); in hubd_determine_port_status()
5403 USB_DPRINTF_L4(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_determine_port_status()
5404 "new port%d state 0x%x", port, hubd->h_port_state[port]); in hubd_determine_port_status()
5418 hubd_recover_disabled_port(hubd_t *hubd, usb_port_t port) in hubd_recover_disabled_port() argument
5425 (void) hubd_enable_port(hubd, port); in hubd_recover_disabled_port()
5428 (void) hubd_determine_port_status(hubd, port, &status, &change, NULL, in hubd_recover_disabled_port()
5432 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_recover_disabled_port()
5436 mutex_exit(HUBD_MUTEX(hubd)); in hubd_recover_disabled_port()
5437 hubd_post_event(hubd, port, USBA_EVENT_TAG_HOT_REMOVAL); in hubd_recover_disabled_port()
5438 mutex_enter(HUBD_MUTEX(hubd)); in hubd_recover_disabled_port()
5441 rval = hubd_handle_port_connect(hubd, port); in hubd_recover_disabled_port()
5443 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_recover_disabled_port()
5455 hubd_enable_all_port_power(hubd_t *hubd) in hubd_enable_all_port_power() argument
5463 USB_DPRINTF_L4(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_enable_all_port_power()
5466 ASSERT(mutex_owned(HUBD_MUTEX(hubd))); in hubd_enable_all_port_power()
5477 if ((hubd->h_hub_chars & HUB_CHARS_NO_POWER_SWITCHING) || in hubd_enable_all_port_power()
5478 (hubd->h_power_good == 0)) { in hubd_enable_all_port_power()
5482 hubd->h_power_good) * 2 * 1000; in hubd_enable_all_port_power()
5485 USB_DPRINTF_L4(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_enable_all_port_power()
5487 hubd->h_power_good, wait); in hubd_enable_all_port_power()
5493 for (port = 1; port <= hubd->h_nports; port++) { in hubd_enable_all_port_power()
5499 hubd->h_log_handle, in hubd_enable_all_port_power()
5502 (void) hubd_enable_port_power(hubd, port); in hubd_enable_all_port_power()
5505 mutex_exit(HUBD_MUTEX(hubd)); in hubd_enable_all_port_power()
5507 mutex_enter(HUBD_MUTEX(hubd)); in hubd_enable_all_port_power()
5513 for (port = 1; port <= hubd->h_nports; port++) { in hubd_enable_all_port_power()
5516 (void) hubd_determine_port_status(hubd, port, in hubd_enable_all_port_power()
5522 USB_DPRINTF_L2(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_enable_all_port_power()
5526 (void) hubd_enable_port_power(hubd, port); in hubd_enable_all_port_power()
5528 mutex_exit(HUBD_MUTEX(hubd)); in hubd_enable_all_port_power()
5530 mutex_enter(HUBD_MUTEX(hubd)); in hubd_enable_all_port_power()
5533 (void) hubd_determine_port_status(hubd, port, in hubd_enable_all_port_power()
5540 USB_DPRINTF_L2(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_enable_all_port_power()
5555 hubd_enable_port_power(hubd_t *hubd, usb_port_t port) in hubd_enable_port_power() argument
5561 USB_DPRINTF_L4(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_enable_port_power()
5564 ASSERT(mutex_owned(HUBD_MUTEX(hubd))); in hubd_enable_port_power()
5565 ASSERT(hubd->h_default_pipe != 0); in hubd_enable_port_power()
5567 mutex_exit(HUBD_MUTEX(hubd)); in hubd_enable_port_power()
5569 if ((rval = usb_pipe_sync_ctrl_xfer(hubd->h_dip, in hubd_enable_port_power()
5570 hubd->h_default_pipe, in hubd_enable_port_power()
5577 USB_DPRINTF_L2(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_enable_port_power()
5580 mutex_enter(HUBD_MUTEX(hubd)); in hubd_enable_port_power()
5584 mutex_enter(HUBD_MUTEX(hubd)); in hubd_enable_port_power()
5585 hubd->h_port_state[port] |= PORT_STATUS_PPS; in hubd_enable_port_power()
5596 hubd_disable_all_port_power(hubd_t *hubd) in hubd_disable_all_port_power() argument
5600 USB_DPRINTF_L4(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_disable_all_port_power()
5603 ASSERT(mutex_owned(HUBD_MUTEX(hubd))); in hubd_disable_all_port_power()
5608 for (port = 1; port <= hubd->h_nports; port++) { in hubd_disable_all_port_power()
5609 (void) hubd_disable_port_power(hubd, port); in hubd_disable_all_port_power()
5621 hubd_disable_port_power(hubd_t *hubd, usb_port_t port) in hubd_disable_port_power() argument
5627 USB_DPRINTF_L4(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_disable_port_power()
5630 ASSERT(mutex_owned(HUBD_MUTEX(hubd))); in hubd_disable_port_power()
5632 mutex_exit(HUBD_MUTEX(hubd)); in hubd_disable_port_power()
5634 if ((rval = usb_pipe_sync_ctrl_xfer(hubd->h_dip, in hubd_disable_port_power()
5635 hubd->h_default_pipe, in hubd_disable_port_power()
5642 USB_DPRINTF_L2(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_disable_port_power()
5646 mutex_enter(HUBD_MUTEX(hubd)); in hubd_disable_port_power()
5651 mutex_enter(HUBD_MUTEX(hubd)); in hubd_disable_port_power()
5653 hubd->h_port_state[port] &= ~PORT_STATUS_PPS; in hubd_disable_port_power()
5665 hubd_select_device_configuration(hubd_t *hubd, usb_port_t port, in hubd_select_device_configuration() argument
5692 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_select_device_configuration()
5705 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_select_device_configuration()
5720 USB_DPRINTF_L2(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_select_device_configuration()
5741 hubd_get_this_config_cloud(hubd_t *hubd, dev_info_t *dip, in hubd_get_this_config_cloud() argument
5753 USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_get_this_config_cloud()
5780 USB_DPRINTF_L2(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_get_this_config_cloud()
5800 hubd->h_log_handle, in hubd_get_this_config_cloud()
5810 hubd->h_log_handle, in hubd_get_this_config_cloud()
5838 hubd->h_log_handle, in hubd_get_this_config_cloud()
5866 hubd->h_log_handle, in hubd_get_this_config_cloud()
5890 hubd->h_log_handle, in hubd_get_this_config_cloud()
5905 USB_DPRINTF_L2(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_get_this_config_cloud()
5928 hubd_get_all_device_config_cloud(hubd_t *hubd, dev_info_t *dip, in hubd_get_all_device_config_cloud() argument
5939 USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_get_all_device_config_cloud()
5964 rval = hubd_get_this_config_cloud(hubd, dip, child_ud, in hubd_get_all_device_config_cloud()
5980 hubd_ready_device(hubd_t *hubd, dev_info_t *child_dip, usba_device_t *child_ud, in hubd_ready_device() argument
5990 USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_ready_device()
6063 hubd_t *hubd, in hubd_create_child() argument
6089 USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_create_child()
6092 ASSERT(mutex_owned(HUBD_MUTEX(hubd))); in hubd_create_child()
6093 ASSERT(hubd->h_usba_devices[port] == NULL); in hubd_create_child()
6095 mutex_exit(HUBD_MUTEX(hubd)); in hubd_create_child()
6111 USB_DPRINTF_L2(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_create_child()
6120 parent_ud = hubd->h_usba_device; in hubd_create_child()
6184 USB_DPRINTF_L2(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_create_child()
6198 USB_DPRINTF_L2(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_create_child()
6207 USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_create_child()
6236 USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_create_child()
6249 USB_DPRINTF_L2(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_create_child()
6266 USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_create_child()
6273 USB_DPRINTF_L2(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_create_child()
6280 USB_DPRINTF_L2(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_create_child()
6302 USB_DPRINTF_L2(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_create_child()
6312 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_create_child()
6341 USB_DPRINTF_L2(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_create_child()
6352 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_create_child()
6368 hubd->h_log_handle, in hubd_create_child()
6393 hubd->h_log_handle, in hubd_create_child()
6408 USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_create_child()
6419 USB_DPRINTF_L2(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_create_child()
6438 USB_DPRINTF_L2(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_create_child()
6464 rval = hubd_get_all_device_config_cloud(hubd, child_dip, child_ud); in hubd_create_child()
6466 USB_DPRINTF_L2(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_create_child()
6473 user_conf_index = hubd_select_device_configuration(hubd, port, in hubd_create_child()
6479 USB_DPRINTF_L2(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_create_child()
6529 hubd->h_log_handle, in hubd_create_child()
6567 child_dip = hubd_ready_device(hubd, child_dip, in hubd_create_child()
6574 mutex_enter(HUBD_MUTEX(hubd)); in hubd_create_child()
6575 hubd->h_children_dips[port] = child_dip; in hubd_create_child()
6576 mutex_exit(HUBD_MUTEX(hubd)); in hubd_create_child()
6590 child_dip = hubd_ready_device(hubd, child_dip, in hubd_create_child()
6597 mutex_enter(HUBD_MUTEX(hubd)); in hubd_create_child()
6598 hubd->h_children_dips[port] = child_dip; in hubd_create_child()
6599 mutex_exit(HUBD_MUTEX(hubd)); in hubd_create_child()
6635 child_dip = hubd_ready_device(hubd, child_dip, in hubd_create_child()
6637 mutex_enter(HUBD_MUTEX(hubd)); in hubd_create_child()
6638 hubd->h_children_dips[port] = child_dip; in hubd_create_child()
6639 mutex_exit(HUBD_MUTEX(hubd)); in hubd_create_child()
6650 child_dip = hubd_ready_device(hubd, child_dip, in hubd_create_child()
6657 mutex_enter(HUBD_MUTEX(hubd)); in hubd_create_child()
6658 hubd->h_children_dips[port] = child_dip; in hubd_create_child()
6659 mutex_exit(HUBD_MUTEX(hubd)); in hubd_create_child()
6666 mutex_enter(HUBD_MUTEX(hubd)); in hubd_create_child()
6667 if (hubd->h_usba_devices[port] == NULL) { in hubd_create_child()
6668 hubd->h_usba_devices[port] = usba_get_usba_device(child_dip); in hubd_create_child()
6670 ASSERT(hubd->h_usba_devices[port] == in hubd_create_child()
6678 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_create_child()
6681 mutex_enter(HUBD_MUTEX(hubd)); in hubd_create_child()
6682 hubd->h_children_dips[port] = NULL; in hubd_create_child()
6683 mutex_exit(HUBD_MUTEX(hubd)); in hubd_create_child()
6706 USB_DPRINTF_L2(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_create_child()
6718 mutex_enter(HUBD_MUTEX(hubd)); in hubd_create_child()
6719 if (hubd->h_usba_devices[port] == NULL) { in hubd_create_child()
6720 mutex_exit(HUBD_MUTEX(hubd)); in hubd_create_child()
6723 hubd_free_usba_device(hubd, hubd->h_usba_devices[port]); in hubd_create_child()
6724 mutex_exit(HUBD_MUTEX(hubd)); in hubd_create_child()
6728 mutex_enter(HUBD_MUTEX(hubd)); in hubd_create_child()
6741 hubd_delete_child(hubd_t *hubd, usb_port_t port, uint_t flag, boolean_t retry) in hubd_delete_child() argument
6747 child_dip = hubd->h_children_dips[port]; in hubd_delete_child()
6748 usba_device = hubd->h_usba_devices[port]; in hubd_delete_child()
6750 USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_delete_child()
6754 mutex_exit(HUBD_MUTEX(hubd)); in hubd_delete_child()
6756 USB_DPRINTF_L2(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_delete_child()
6762 usba_hubdi_incr_power_budget(hubd->h_dip, usba_device); in hubd_delete_child()
6774 mutex_enter(HUBD_MUTEX(hubd)); in hubd_delete_child()
6775 if (hubd->h_children_dips[port] == child_dip) { in hubd_delete_child()
6777 hubd->h_usba_devices[port]; in hubd_delete_child()
6778 hubd->h_children_dips[port] = NULL; in hubd_delete_child()
6780 mutex_exit(HUBD_MUTEX(hubd)); in hubd_delete_child()
6787 mutex_enter(HUBD_MUTEX(hubd)); in hubd_delete_child()
6788 hubd->h_usba_devices[port] = NULL; in hubd_delete_child()
6791 mutex_exit(HUBD_MUTEX(hubd)); in hubd_delete_child()
6799 mutex_enter(HUBD_MUTEX(hubd)); in hubd_delete_child()
6811 hubd_free_usba_device(hubd_t *hubd, usba_device_t *usba_device) in hubd_free_usba_device() argument
6813 USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_free_usba_device()
6815 (void *)hubd, (void *)usba_device); in hubd_free_usba_device()
6819 dev_info_t *dip = hubd->h_children_dips[port]; in hubd_free_usba_device()
6827 hubd->h_usba_devices[port] = NULL; in hubd_free_usba_device()
6829 mutex_exit(HUBD_MUTEX(hubd)); in hubd_free_usba_device()
6831 mutex_enter(HUBD_MUTEX(hubd)); in hubd_free_usba_device()
6847 hubd_t *hubd = (hubd_t *)hubd_get_soft_state(dip); in hubd_busop_get_eventcookie() local
6849 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_busop_get_eventcookie()
6852 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_busop_get_eventcookie()
6858 return (ndi_event_retrieve_cookie(hubd->h_ndi_event_hdl, in hubd_busop_get_eventcookie()
6870 hubd_t *hubd = (hubd_t *)hubd_get_soft_state(dip); in hubd_busop_add_eventcall() local
6871 usb_port_t port = hubd_child_dip2port(hubd, rdip); in hubd_busop_add_eventcall()
6873 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_busop_add_eventcall()
6877 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_busop_add_eventcall()
6881 ndi_event_cookie_to_name(hubd->h_ndi_event_hdl, cookie)); in hubd_busop_add_eventcall()
6884 switch (ndi_event_cookie_to_tag(hubd->h_ndi_event_hdl, cookie)) { in hubd_busop_add_eventcall()
6886 mutex_enter(HUBD_MUTEX(hubd)); in hubd_busop_add_eventcall()
6887 hubd->h_child_events[port] |= HUBD_CHILD_EVENT_DISCONNECT; in hubd_busop_add_eventcall()
6888 mutex_exit(HUBD_MUTEX(hubd)); in hubd_busop_add_eventcall()
6892 mutex_enter(HUBD_MUTEX(hubd)); in hubd_busop_add_eventcall()
6893 hubd->h_child_events[port] |= HUBD_CHILD_EVENT_PRESUSPEND; in hubd_busop_add_eventcall()
6894 mutex_exit(HUBD_MUTEX(hubd)); in hubd_busop_add_eventcall()
6903 return (ndi_event_add_callback(hubd->h_ndi_event_hdl, in hubd_busop_add_eventcall()
6911 hubd_t *hubd = (hubd_t *)hubd_get_soft_state(dip); in hubd_busop_remove_eventcall() local
6914 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_busop_remove_eventcall()
6918 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_busop_remove_eventcall()
6923 ndi_event_cookie_to_name(hubd->h_ndi_event_hdl, in hubd_busop_remove_eventcall()
6927 return (ndi_event_remove_callback(hubd->h_ndi_event_hdl, cb_id)); in hubd_busop_remove_eventcall()
6938 hubd_do_callback(hubd_t *hubd, dev_info_t *cdip, ddi_eventcookie_t cookie) in hubd_do_callback() argument
6940 USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_do_callback()
6943 (void) ndi_event_do_callback(hubd->h_ndi_event_hdl, cdip, cookie, NULL); in hubd_do_callback()
6952 hubd_run_callbacks(hubd_t *hubd, usba_event_t type) in hubd_run_callbacks() argument
6956 USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_run_callbacks()
6959 mutex_enter(HUBD_MUTEX(hubd)); in hubd_run_callbacks()
6960 for (port = 1; port <= hubd->h_nports; port++) { in hubd_run_callbacks()
6966 if (hubd->h_children_dips[port]) { in hubd_run_callbacks()
6967 mutex_exit(HUBD_MUTEX(hubd)); in hubd_run_callbacks()
6968 hubd_post_event(hubd, port, type); in hubd_run_callbacks()
6969 mutex_enter(HUBD_MUTEX(hubd)); in hubd_run_callbacks()
6972 mutex_exit(HUBD_MUTEX(hubd)); in hubd_run_callbacks()
6981 hubd_post_event(hubd_t *hubd, usb_port_t port, usba_event_t type) in hubd_post_event() argument
6988 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_post_event()
6990 ndi_event_tag_to_name(hubd->h_ndi_event_hdl, type)); in hubd_post_event()
6992 cookie = ndi_event_tag_to_cookie(hubd->h_ndi_event_hdl, type); in hubd_post_event()
6993 rm_cookie = ndi_event_tag_to_cookie(hubd->h_ndi_event_hdl, in hubd_post_event()
6995 suspend_cookie = ndi_event_tag_to_cookie(hubd->h_ndi_event_hdl, in hubd_post_event()
7004 mutex_enter(HUBD_MUTEX(hubd)); in hubd_post_event()
7005 dip = hubd->h_children_dips[port]; in hubd_post_event()
7006 usba_device = hubd->h_usba_devices[port]; in hubd_post_event()
7007 mutex_exit(HUBD_MUTEX(hubd)); in hubd_post_event()
7012 mutex_enter(HUBD_MUTEX(hubd)); in hubd_post_event()
7013 hubd->h_child_events[port] &= ~HUBD_CHILD_EVENT_DISCONNECT; in hubd_post_event()
7014 mutex_exit(HUBD_MUTEX(hubd)); in hubd_post_event()
7016 hubd_do_callback(hubd, dip, cookie); in hubd_post_event()
7030 mutex_enter(HUBD_MUTEX(hubd)); in hubd_post_event()
7031 hubd->h_child_events[port] &= ~HUBD_CHILD_EVENT_PRESUSPEND; in hubd_post_event()
7032 mutex_exit(HUBD_MUTEX(hubd)); in hubd_post_event()
7034 hubd_do_callback(hubd, dip, cookie); in hubd_post_event()
7046 mutex_enter(HUBD_MUTEX(hubd)); in hubd_post_event()
7047 if (hubd->h_child_events[port] & HUBD_CHILD_EVENT_DISCONNECT) { in hubd_post_event()
7049 hubd->h_child_events[port] &= in hubd_post_event()
7051 mutex_exit(HUBD_MUTEX(hubd)); in hubd_post_event()
7052 hubd_do_callback(hubd, dip, rm_cookie); in hubd_post_event()
7054 mutex_enter(HUBD_MUTEX(hubd)); in hubd_post_event()
7056 mutex_exit(HUBD_MUTEX(hubd)); in hubd_post_event()
7069 hubd->h_log_handle, in hubd_post_event()
7073 hubd_do_callback(hubd, dip, cookie); in hubd_post_event()
7081 mutex_enter(HUBD_MUTEX(hubd)); in hubd_post_event()
7082 hubd->h_child_events[port] |= HUBD_CHILD_EVENT_DISCONNECT; in hubd_post_event()
7083 mutex_exit(HUBD_MUTEX(hubd)); in hubd_post_event()
7091 mutex_enter(HUBD_MUTEX(hubd)); in hubd_post_event()
7092 if (hubd->h_child_events[port] & HUBD_CHILD_EVENT_PRESUSPEND) { in hubd_post_event()
7094 hubd->h_port_state[port] &= in hubd_post_event()
7096 mutex_exit(HUBD_MUTEX(hubd)); in hubd_post_event()
7097 hubd_do_callback(hubd, dip, suspend_cookie); in hubd_post_event()
7098 mutex_enter(HUBD_MUTEX(hubd)); in hubd_post_event()
7100 mutex_exit(HUBD_MUTEX(hubd)); in hubd_post_event()
7111 hubd_do_callback(hubd, dip, cookie); in hubd_post_event()
7118 mutex_enter(HUBD_MUTEX(hubd)); in hubd_post_event()
7119 hubd->h_child_events[port] |= HUBD_CHILD_EVENT_PRESUSPEND; in hubd_post_event()
7120 mutex_exit(HUBD_MUTEX(hubd)); in hubd_post_event()
7132 hubd_t *hubd = (hubd_t *)hubd_get_soft_state(dip); in hubd_disconnect_event_cb() local
7137 USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_disconnect_event_cb()
7142 mutex_enter(HUBD_MUTEX(hubd)); in hubd_disconnect_event_cb()
7143 switch (hubd->h_dev_state) { in hubd_disconnect_event_cb()
7146 hubd->h_dev_state = USB_DEV_DISCONNECTED; in hubd_disconnect_event_cb()
7148 hubd_stop_polling(hubd); in hubd_disconnect_event_cb()
7153 mutex_exit(HUBD_MUTEX(hubd)); in hubd_disconnect_event_cb()
7154 hubd_run_callbacks(hubd, tag); in hubd_disconnect_event_cb()
7155 mutex_enter(HUBD_MUTEX(hubd)); in hubd_disconnect_event_cb()
7158 nports = hubd->h_nports; in hubd_disconnect_event_cb()
7160 usba_dev = hubd->h_usba_devices[port]; in hubd_disconnect_event_cb()
7162 mutex_exit(HUBD_MUTEX(hubd)); in hubd_disconnect_event_cb()
7164 mutex_enter(HUBD_MUTEX(hubd)); in hubd_disconnect_event_cb()
7171 USB_DPRINTF_L2(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_disconnect_event_cb()
7176 USB_DPRINTF_L2(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_disconnect_event_cb()
7178 hubd->h_dev_state); in hubd_disconnect_event_cb()
7182 mutex_exit(HUBD_MUTEX(hubd)); in hubd_disconnect_event_cb()
7210 hubd_t *hubd = (hubd_t *)hubd_get_soft_state(dip); in hubd_pre_suspend_event_cb() local
7212 USB_DPRINTF_L4(DPRINT_MASK_EVENTS, hubd->h_log_handle, in hubd_pre_suspend_event_cb()
7216 mutex_enter(HUBD_MUTEX(hubd)); in hubd_pre_suspend_event_cb()
7217 hubd->h_hotplug_thread++; in hubd_pre_suspend_event_cb()
7218 hubd_stop_polling(hubd); in hubd_pre_suspend_event_cb()
7221 (void) hubd_pm_busy_component(hubd, hubd->h_dip, 0); in hubd_pre_suspend_event_cb()
7222 mutex_exit(HUBD_MUTEX(hubd)); in hubd_pre_suspend_event_cb()
7225 hubd_run_callbacks(hubd, USBA_EVENT_TAG_PRE_SUSPEND); in hubd_pre_suspend_event_cb()
7239 hubd_t *hubd = (hubd_t *)hubd_get_soft_state(dip); in hubd_post_resume_event_cb() local
7241 USB_DPRINTF_L4(DPRINT_MASK_EVENTS, hubd->h_log_handle, in hubd_post_resume_event_cb()
7245 hubd_run_callbacks(hubd, USBA_EVENT_TAG_POST_RESUME); in hubd_post_resume_event_cb()
7248 mutex_enter(HUBD_MUTEX(hubd)); in hubd_post_resume_event_cb()
7251 (void) hubd_pm_idle_component(hubd, hubd->h_dip, 0); in hubd_post_resume_event_cb()
7254 hubd->h_hotplug_thread--; in hubd_post_resume_event_cb()
7257 hubd_start_polling(hubd, 0); in hubd_post_resume_event_cb()
7258 mutex_exit(HUBD_MUTEX(hubd)); in hubd_post_resume_event_cb()
7269 hubd_cpr_suspend(hubd_t *hubd) in hubd_cpr_suspend() argument
7276 USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_cpr_suspend()
7280 mutex_enter(HUBD_MUTEX(hubd)); in hubd_cpr_suspend()
7281 hubd_pm_busy_component(hubd, hubd->h_dip, 0); in hubd_cpr_suspend()
7282 mutex_exit(HUBD_MUTEX(hubd)); in hubd_cpr_suspend()
7285 (void) pm_raise_power(hubd->h_dip, 0, USB_DEV_OS_FULL_PWR); in hubd_cpr_suspend()
7286 mutex_enter(HUBD_MUTEX(hubd)); in hubd_cpr_suspend()
7288 switch (hubd->h_dev_state) { in hubd_cpr_suspend()
7293 nports = hubd->h_nports; in hubd_cpr_suspend()
7295 usba_dev = hubd->h_usba_devices[port]; in hubd_cpr_suspend()
7303 USB_DPRINTF_L2(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_cpr_suspend()
7313 if ((hubd->h_hotplug_thread > 1) || in hubd_cpr_suspend()
7314 (hubd->h_cleanup_active == B_TRUE)) { in hubd_cpr_suspend()
7316 hubd->h_log_handle, in hubd_cpr_suspend()
7324 hubd_stop_polling(hubd); in hubd_cpr_suspend()
7328 usba_dev = hubd->h_usba_devices[port]; in hubd_cpr_suspend()
7330 mutex_exit(HUBD_MUTEX(hubd)); in hubd_cpr_suspend()
7332 if (hubd_suspend_port(hubd, port)) { in hubd_cpr_suspend()
7335 hubd->h_log_handle, in hubd_cpr_suspend()
7339 mutex_enter(HUBD_MUTEX(hubd)); in hubd_cpr_suspend()
7343 hubd->h_dev_state = USB_DEV_SUSPENDED; in hubd_cpr_suspend()
7349 if (usba_is_root_hub(hubd->h_dip)) { in hubd_cpr_suspend()
7350 mutex_exit(HUBD_MUTEX(hubd)); in hubd_cpr_suspend()
7352 usba_get_usba_device(hubd->h_dip)); in hubd_cpr_suspend()
7353 mutex_enter(HUBD_MUTEX(hubd)); in hubd_cpr_suspend()
7361 USB_DPRINTF_L2(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_cpr_suspend()
7363 hubd->h_dev_state); in hubd_cpr_suspend()
7368 hubd_pm_idle_component(hubd, hubd->h_dip, 0); in hubd_cpr_suspend()
7369 mutex_exit(HUBD_MUTEX(hubd)); in hubd_cpr_suspend()
7401 hubd_t *hubd = (hubd_t *)hubd_get_soft_state(dip); in hubd_restore_state_cb() local
7403 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_restore_state_cb()
7407 hubd_restore_device_state(dip, hubd); in hubd_restore_state_cb()
7417 hubd_register_events(hubd_t *hubd) in hubd_register_events() argument
7421 if (usba_is_root_hub(hubd->h_dip)) { in hubd_register_events()
7422 hubd_register_cpr_callback(hubd); in hubd_register_events()
7424 rval = usb_register_event_cbs(hubd->h_dip, &hubd_events, 0); in hubd_register_events()
7444 hubd_t *hubd = cpr_cb->statep; in hubd_cpr_post_user_callb() local
7447 USB_DPRINTF_L4(DPRINT_MASK_EVENTS, hubd->h_log_handle, in hubd_cpr_post_user_callb()
7452 USB_DPRINTF_L3(DPRINT_MASK_EVENTS, hubd->h_log_handle, in hubd_cpr_post_user_callb()
7455 mutex_enter(HUBD_MUTEX(hubd)); in hubd_cpr_post_user_callb()
7458 hubd->h_cleanup_enabled = B_FALSE; in hubd_cpr_post_user_callb()
7461 while ((hubd->h_cleanup_active == B_TRUE) && (retry++ < 3)) { in hubd_cpr_post_user_callb()
7462 mutex_exit(HUBD_MUTEX(hubd)); in hubd_cpr_post_user_callb()
7465 USB_DPRINTF_L2(DPRINT_MASK_EVENTS, hubd->h_log_handle, in hubd_cpr_post_user_callb()
7468 mutex_enter(HUBD_MUTEX(hubd)); in hubd_cpr_post_user_callb()
7471 mutex_exit(HUBD_MUTEX(hubd)); in hubd_cpr_post_user_callb()
7474 (void) hubd_pre_suspend_event_cb(hubd->h_dip); in hubd_cpr_post_user_callb()
7478 USB_DPRINTF_L3(DPRINT_MASK_EVENTS, hubd->h_log_handle, in hubd_cpr_post_user_callb()
7482 (void) hubd_post_resume_event_cb(hubd->h_dip); in hubd_cpr_post_user_callb()
7485 mutex_enter(HUBD_MUTEX(hubd)); in hubd_cpr_post_user_callb()
7486 hubd->h_cleanup_enabled = B_TRUE; in hubd_cpr_post_user_callb()
7487 mutex_exit(HUBD_MUTEX(hubd)); in hubd_cpr_post_user_callb()
7489 hubd_schedule_cleanup(hubd->h_usba_device->usb_root_hub_dip); in hubd_cpr_post_user_callb()
7502 hubd_register_cpr_callback(hubd_t *hubd) in hubd_register_cpr_callback() argument
7504 USB_DPRINTF_L4(DPRINT_MASK_EVENTS, hubd->h_log_handle, in hubd_register_cpr_callback()
7507 mutex_enter(HUBD_MUTEX(hubd)); in hubd_register_cpr_callback()
7508 hubd->h_cpr_cb = in hubd_register_cpr_callback()
7510 mutex_exit(HUBD_MUTEX(hubd)); in hubd_register_cpr_callback()
7511 mutex_init(&hubd->h_cpr_cb->lockp, NULL, MUTEX_DRIVER, in hubd_register_cpr_callback()
7512 hubd->h_dev_data->dev_iblock_cookie); in hubd_register_cpr_callback()
7513 hubd->h_cpr_cb->statep = hubd; in hubd_register_cpr_callback()
7514 hubd->h_cpr_cb->cpr.cc_lockp = &hubd->h_cpr_cb->lockp; in hubd_register_cpr_callback()
7515 hubd->h_cpr_cb->cpr.cc_id = callb_add(hubd_cpr_post_user_callb, in hubd_register_cpr_callback()
7516 (void *)hubd->h_cpr_cb, CB_CL_CPR_POST_USER, "hubd"); in hubd_register_cpr_callback()
7522 hubd_unregister_cpr_callback(hubd_t *hubd) in hubd_unregister_cpr_callback() argument
7524 USB_DPRINTF_L4(DPRINT_MASK_EVENTS, hubd->h_log_handle, in hubd_unregister_cpr_callback()
7527 if (hubd->h_cpr_cb) { in hubd_unregister_cpr_callback()
7528 (void) callb_delete(hubd->h_cpr_cb->cpr.cc_id); in hubd_unregister_cpr_callback()
7529 mutex_destroy(&hubd->h_cpr_cb->lockp); in hubd_unregister_cpr_callback()
7530 mutex_enter(HUBD_MUTEX(hubd)); in hubd_unregister_cpr_callback()
7531 kmem_free(hubd->h_cpr_cb, sizeof (hubd_cpr_t)); in hubd_unregister_cpr_callback()
7532 mutex_exit(HUBD_MUTEX(hubd)); in hubd_unregister_cpr_callback()
7543 hubd_create_pm_components(dev_info_t *dip, hubd_t *hubd) in hubd_create_pm_components() argument
7547 USB_DPRINTF_L4(DPRINT_MASK_PM, hubd->h_log_handle, in hubd_create_pm_components()
7553 hubd->h_hubpm = hubpm; in hubd_create_pm_components()
7554 hubpm->hubp_hubd = hubd; in hubd_create_pm_components()
7575 USB_DPRINTF_L2(DPRINT_MASK_PM, hubd->h_log_handle, in hubd_create_pm_components()
7581 mutex_enter(HUBD_MUTEX(hubd)); in hubd_create_pm_components()
7586 hubd_pm_busy_component(hubd, dip, 0); in hubd_create_pm_components()
7587 mutex_exit(HUBD_MUTEX(hubd)); in hubd_create_pm_components()
7595 USB_DPRINTF_L4(DPRINT_MASK_PM, hubd->h_log_handle, in hubd_create_pm_components()
7608 hubd_t *hubd; in usba_hubdi_open() local
7613 hubd = hubd_get_soft_state(dip); in usba_hubdi_open()
7614 if (hubd == NULL) { in usba_hubdi_open()
7618 USB_DPRINTF_L4(DPRINT_MASK_CBOPS, hubd->h_log_handle, in usba_hubdi_open()
7621 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_open()
7622 if ((flags & FEXCL) && (hubd->h_softstate & HUBD_SS_ISOPEN)) { in usba_hubdi_open()
7623 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_open()
7628 hubd->h_softstate |= HUBD_SS_ISOPEN; in usba_hubdi_open()
7629 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_open()
7631 USB_DPRINTF_L4(DPRINT_MASK_CBOPS, hubd->h_log_handle, "opened"); in usba_hubdi_open()
7642 hubd_t *hubd; in usba_hubdi_close() local
7648 hubd = hubd_get_soft_state(dip); in usba_hubdi_close()
7650 if (hubd == NULL) { in usba_hubdi_close()
7654 USB_DPRINTF_L4(DPRINT_MASK_CBOPS, hubd->h_log_handle, "hubd_close:"); in usba_hubdi_close()
7656 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_close()
7657 hubd->h_softstate &= ~HUBD_SS_ISOPEN; in usba_hubdi_close()
7658 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_close()
7660 USB_DPRINTF_L4(DPRINT_MASK_CBOPS, hubd->h_log_handle, "closed"); in usba_hubdi_close()
7676 hubd_t *hubd; in usba_hubdi_ioctl() local
7684 if ((hubd = hubd_get_soft_state(self)) == NULL) { in usba_hubdi_ioctl()
7689 rh_dip = hubd->h_usba_device->usb_root_hub_dip; in usba_hubdi_ioctl()
7691 USB_DPRINTF_L4(DPRINT_MASK_CBOPS, hubd->h_log_handle, in usba_hubdi_ioctl()
7708 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_ioctl()
7714 if (hubd->h_dev_state == USB_DEV_DISCONNECTED) { in usba_hubdi_ioctl()
7715 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_ioctl()
7717 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_ioctl()
7727 if ((port = hubd_get_port_num(hubd, dcp)) == 0) { in usba_hubdi_ioctl()
7728 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_ioctl()
7730 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_ioctl()
7743 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_ioctl()
7752 if (hubd->h_dev_state == USB_DEV_SUSPENDED) { in usba_hubdi_ioctl()
7753 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_ioctl()
7761 if (hubd->h_reset_port[port]) { in usba_hubdi_ioctl()
7762 USB_DPRINTF_L2(DPRINT_MASK_CBOPS, hubd->h_log_handle, in usba_hubdi_ioctl()
7764 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_ioctl()
7772 hubd_pm_busy_component(hubd, hubd->h_dip, 0); in usba_hubdi_ioctl()
7773 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_ioctl()
7776 (void) pm_raise_power(hubd->h_dip, 0, USB_DEV_OS_FULL_PWR); in usba_hubdi_ioctl()
7780 ndi_devi_enter(hubd->h_dip); in usba_hubdi_ioctl()
7782 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_ioctl()
7784 hubd->h_hotplug_thread++; in usba_hubdi_ioctl()
7787 if (hubd->h_ep1_ph) { in usba_hubdi_ioctl()
7788 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_ioctl()
7789 (void) usb_pipe_get_state(hubd->h_ep1_ph, &prev_pipe_state, in usba_hubdi_ioctl()
7791 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_ioctl()
7794 hubd_stop_polling(hubd); in usba_hubdi_ioctl()
7800 if (hubd_delete_child(hubd, port, in usba_hubdi_ioctl()
7807 if (hubd_delete_child(hubd, port, in usba_hubdi_ioctl()
7815 if (hubd_toggle_port(hubd, port) != USB_SUCCESS) { in usba_hubdi_ioctl()
7821 (void) hubd_handle_port_connect(hubd, port); in usba_hubdi_ioctl()
7822 child_dip = hubd_get_child_dip(hubd, port); in usba_hubdi_ioctl()
7823 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_ioctl()
7825 ndi_devi_exit(hubd->h_dip); in usba_hubdi_ioctl()
7838 ndi_devi_enter(hubd->h_dip); in usba_hubdi_ioctl()
7840 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_ioctl()
7844 switch (hubd_cfgadm_state(hubd, port)) { in usba_hubdi_ioctl()
7883 USB_DPRINTF_L4(DPRINT_MASK_CBOPS, hubd->h_log_handle, in usba_hubdi_ioctl()
7929 USB_DPRINTF_L3(DPRINT_MASK_CBOPS, hubd->h_log_handle, in usba_hubdi_ioctl()
7955 hubd->h_log_handle, in usba_hubdi_ioctl()
7965 if ((child_dip = hubd_get_child_dip(hubd, in usba_hubdi_ioctl()
7975 hubd->h_log_handle, in usba_hubdi_ioctl()
7987 hubd->h_log_handle, in usba_hubdi_ioctl()
8002 USB_DPRINTF_L4(DPRINT_MASK_CBOPS, hubd->h_log_handle, in usba_hubdi_ioctl()
8006 if ((child_dip = hubd_get_child_dip(hubd, ioc.port)) == in usba_hubdi_ioctl()
8036 hubd->h_log_handle, in usba_hubdi_ioctl()
8053 hubd->h_log_handle, in usba_hubdi_ioctl()
8062 hubd->h_log_handle, in usba_hubdi_ioctl()
8071 hubd->h_log_handle, in usba_hubdi_ioctl()
8081 hubd->h_log_handle, in usba_hubdi_ioctl()
8096 if ((child_dip = hubd_get_child_dip(hubd, ioc.port)) == in usba_hubdi_ioctl()
8109 USB_DPRINTF_L4(DPRINT_MASK_CBOPS, hubd->h_log_handle, in usba_hubdi_ioctl()
8116 hubd->h_log_handle, in usba_hubdi_ioctl()
8125 hubd->h_log_handle, in usba_hubdi_ioctl()
8135 hubd->h_log_handle, in usba_hubdi_ioctl()
8157 USB_DPRINTF_L4(DPRINT_MASK_CBOPS, hubd->h_log_handle, in usba_hubdi_ioctl()
8165 if ((child_dip = hubd_get_child_dip(hubd, ioc.port)) == in usba_hubdi_ioctl()
8181 hubd->h_log_handle, in usba_hubdi_ioctl()
8190 hubd->h_log_handle, in usba_hubdi_ioctl()
8199 hubd->h_log_handle, in usba_hubdi_ioctl()
8213 USB_DPRINTF_L4(DPRINT_MASK_CBOPS, hubd->h_log_handle, in usba_hubdi_ioctl()
8217 if ((child_dip = hubd_get_child_dip(hubd, ioc.port)) == in usba_hubdi_ioctl()
8230 USB_DPRINTF_L4(DPRINT_MASK_CBOPS, hubd->h_log_handle, in usba_hubdi_ioctl()
8238 hubd->h_log_handle, in usba_hubdi_ioctl()
8245 hubd->h_log_handle, in usba_hubdi_ioctl()
8251 hubd->h_log_handle, in usba_hubdi_ioctl()
8262 USB_DPRINTF_L3(DPRINT_MASK_CBOPS, hubd->h_log_handle, in usba_hubdi_ioctl()
8267 hubd->h_log_handle, in usba_hubdi_ioctl()
8289 hubd->h_hotplug_thread--; in usba_hubdi_ioctl()
8291 if ((hubd->h_dev_state == USB_DEV_ONLINE) && in usba_hubdi_ioctl()
8292 hubd->h_ep1_ph && (prev_pipe_state == USB_PIPE_STATE_ACTIVE)) { in usba_hubdi_ioctl()
8293 hubd_start_polling(hubd, 0); in usba_hubdi_ioctl()
8295 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_ioctl()
8297 ndi_devi_exit(hubd->h_dip); in usba_hubdi_ioctl()
8301 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_ioctl()
8302 hubd_pm_idle_component(hubd, hubd->h_dip, 0); in usba_hubdi_ioctl()
8303 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_ioctl()
8324 hubd_get_ancestry_str(hubd_t *hubd) in hubd_get_ancestry_str() argument
8331 USB_DPRINTF_L4(DPRINT_MASK_ATTA, hubd->h_log_handle, in hubd_get_ancestry_str()
8332 "hubd_get_ancestry_str: hubd=0x%p", (void *)hubd); in hubd_get_ancestry_str()
8334 ASSERT(mutex_owned(HUBD_MUTEX(hubd))); in hubd_get_ancestry_str()
8344 if (usba_is_root_hub(hubd->h_dip)) { in hubd_get_ancestry_str()
8345 hubd->h_ancestry_str[0] = '\0'; in hubd_get_ancestry_str()
8347 port = hubd->h_usba_device->usb_port; in hubd_get_ancestry_str()
8348 mutex_exit(HUBD_MUTEX(hubd)); in hubd_get_ancestry_str()
8350 pdip = ddi_get_parent(hubd->h_dip); in hubd_get_ancestry_str()
8367 mutex_enter(HUBD_MUTEX(hubd)); in hubd_get_ancestry_str()
8368 (void) strcpy(hubd->h_ancestry_str, ap_name); in hubd_get_ancestry_str()
8369 (void) strcat(hubd->h_ancestry_str, "."); in hubd_get_ancestry_str()
8376 hubd_get_port_num(hubd_t *hubd, struct devctl_iocdata *dcp) in hubd_get_port_num() argument
8380 ASSERT(mutex_owned(HUBD_MUTEX(hubd))); in hubd_get_port_num()
8384 USB_DPRINTF_L2(DPRINT_MASK_CBOPS, hubd->h_log_handle, in hubd_get_port_num()
8389 USB_DPRINTF_L4(DPRINT_MASK_CBOPS, hubd->h_log_handle, in hubd_get_port_num()
8390 "hubd_get_port_num: hubd=0x%p, port=%d", (void *)hubd, port); in hubd_get_port_num()
8398 hubd_get_child_dip(hubd_t *hubd, usb_port_t port) in hubd_get_child_dip() argument
8400 dev_info_t *child_dip = hubd->h_children_dips[port]; in hubd_get_child_dip()
8402 USB_DPRINTF_L4(DPRINT_MASK_CBOPS, hubd->h_log_handle, in hubd_get_child_dip()
8403 "hubd_get_child_dip: hubd=0x%p, port=%d", (void *)hubd, port); in hubd_get_child_dip()
8405 ASSERT(mutex_owned(HUBD_MUTEX(hubd))); in hubd_get_child_dip()
8424 hubd_cfgadm_state(hubd_t *hubd, usb_port_t port) in hubd_cfgadm_state() argument
8427 dev_info_t *child_dip = hubd_get_child_dip(hubd, port); in hubd_cfgadm_state()
8430 if (hubd->h_port_state[port] & PORT_STATUS_CCS) { in hubd_cfgadm_state()
8452 if (hubd->h_port_state[port] & PORT_STATUS_CCS) { in hubd_cfgadm_state()
8461 USB_DPRINTF_L4(DPRINT_MASK_CBOPS, hubd->h_log_handle, in hubd_cfgadm_state()
8463 (void *)hubd, port, state); in hubd_cfgadm_state()
8473 hubd_toggle_port(hubd_t *hubd, usb_port_t port) in hubd_toggle_port() argument
8480 USB_DPRINTF_L4(DPRINT_MASK_CBOPS, hubd->h_log_handle, in hubd_toggle_port()
8481 "hubd_toggle_port: hubd=0x%p, port=%d", (void *)hubd, port); in hubd_toggle_port()
8483 if ((hubd_disable_port_power(hubd, port)) != USB_SUCCESS) { in hubd_toggle_port()
8492 mutex_exit(HUBD_MUTEX(hubd)); in hubd_toggle_port()
8494 mutex_enter(HUBD_MUTEX(hubd)); in hubd_toggle_port()
8505 if ((hubd->h_hub_chars & HUB_CHARS_NO_POWER_SWITCHING) || in hubd_toggle_port()
8506 (hubd->h_power_good == 0)) { in hubd_toggle_port()
8510 hubd->h_power_good) * 2 * 1000; in hubd_toggle_port()
8513 USB_DPRINTF_L3(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_toggle_port()
8515 hubd->h_power_good, wait); in hubd_toggle_port()
8520 (void) hubd_enable_port_power(hubd, port); in hubd_toggle_port()
8522 mutex_exit(HUBD_MUTEX(hubd)); in hubd_toggle_port()
8524 mutex_enter(HUBD_MUTEX(hubd)); in hubd_toggle_port()
8527 (void) hubd_determine_port_status(hubd, port, in hubd_toggle_port()
8540 USB_DPRINTF_L2(DPRINT_MASK_PORT, hubd->h_log_handle, in hubd_toggle_port()
8565 hubd_init_power_budget(hubd_t *hubd) in hubd_init_power_budget() argument
8574 if (hubd->h_ignore_pwr_budget) { in hubd_init_power_budget()
8579 USB_DPRINTF_L4(DPRINT_MASK_HUB, hubd->h_log_handle, in hubd_init_power_budget()
8582 ASSERT(mutex_owned(HUBD_MUTEX(hubd))); in hubd_init_power_budget()
8583 ASSERT(hubd->h_default_pipe != 0); in hubd_init_power_budget()
8584 mutex_exit(HUBD_MUTEX(hubd)); in hubd_init_power_budget()
8587 if ((usb_get_status(hubd->h_dip, hubd->h_default_pipe, in hubd_init_power_budget()
8590 mutex_enter(HUBD_MUTEX(hubd)); in hubd_init_power_budget()
8595 hubd_ud = usba_get_usba_device(hubd->h_dip); in hubd_init_power_budget()
8601 USB_DPRINTF_L2(DPRINT_MASK_HUB, hubd->h_log_handle, in hubd_init_power_budget()
8603 mutex_enter(HUBD_MUTEX(hubd)); in hubd_init_power_budget()
8608 mutex_enter(HUBD_MUTEX(hubd)); in hubd_init_power_budget()
8610 hubd->h_local_pwr_capable = (cfg_descr.bmAttributes & in hubd_init_power_budget()
8613 if (hubd->h_local_pwr_capable) { in hubd_init_power_budget()
8614 USB_DPRINTF_L3(DPRINT_MASK_HUB, hubd->h_log_handle, in hubd_init_power_budget()
8618 hubd->h_local_pwr_on = (status & in hubd_init_power_budget()
8619 USB_DEV_SLF_PWRD_STATUS) && hubd->h_local_pwr_capable; in hubd_init_power_budget()
8621 if (hubd->h_local_pwr_on) { in hubd_init_power_budget()
8622 USB_DPRINTF_L3(DPRINT_MASK_HUB, hubd->h_log_handle, in hubd_init_power_budget()
8625 hubd->h_pwr_limit = (USB_PWR_UNIT_LOAD * in hubd_init_power_budget()
8628 hubd->h_pwr_limit = (USB_PWR_UNIT_LOAD * in hubd_init_power_budget()
8631 hubd->h_pwr_left = (USB_PWR_UNIT_LOAD * in hubd_init_power_budget()
8634 ASSERT(!usba_is_root_hub(hubd->h_dip)); in hubd_init_power_budget()
8636 if (!usba_is_root_hub(hubd->h_dip)) { in hubd_init_power_budget()
8641 mutex_exit(HUBD_MUTEX(hubd)); in hubd_init_power_budget()
8643 pdip = ddi_get_parent(hubd->h_dip); in hubd_init_power_budget()
8651 hubd->h_log_handle, in hubd_init_power_budget()
8656 mutex_enter(HUBD_MUTEX(hubd)); in hubd_init_power_budget()
8663 mutex_enter(HUBD_MUTEX(hubd)); in hubd_init_power_budget()
8665 USB_DPRINTF_L3(DPRINT_MASK_HUB, hubd->h_log_handle, in hubd_init_power_budget()
8668 USB_DPRINTF_L3(DPRINT_MASK_HUB, hubd->h_log_handle, in hubd_init_power_budget()
8677 hubd->h_pwr_left -= hubd->h_current / USB_CFG_DESCR_PWR_UNIT; in hubd_init_power_budget()
8678 if (hubd->h_pwr_left < 0) { in hubd_init_power_budget()
8679 USB_DPRINTF_L2(DPRINT_MASK_HUB, hubd->h_log_handle, in hubd_init_power_budget()
8703 hubd_t *hubd; in usba_hubdi_check_power_budget() local
8705 if ((hubd = hubd_get_soft_state(dip)) == NULL) { in usba_hubdi_check_power_budget()
8710 if (hubd->h_ignore_pwr_budget) { in usba_hubdi_check_power_budget()
8715 USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in usba_hubdi_check_power_budget()
8720 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_check_power_budget()
8721 pwr_limit = hubd->h_pwr_limit; in usba_hubdi_check_power_budget()
8722 if (hubd->h_local_pwr_on == B_FALSE) { in usba_hubdi_check_power_budget()
8723 pwr_left = hubd->h_pwr_left; in usba_hubdi_check_power_budget()
8726 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_check_power_budget()
8728 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in usba_hubdi_check_power_budget()
8737 USB_DPRINTF_L2(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in usba_hubdi_check_power_budget()
8745 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in usba_hubdi_check_power_budget()
8752 USB_DPRINTF_L1(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in usba_hubdi_check_power_budget()
8778 hubd_t *hubd = hubd_get_soft_state(dip); in usba_hubdi_incr_power_budget() local
8780 ASSERT(hubd != NULL); in usba_hubdi_incr_power_budget()
8782 if (hubd->h_ignore_pwr_budget) { in usba_hubdi_incr_power_budget()
8787 USB_DPRINTF_L4(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_incr_power_budget()
8791 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_incr_power_budget()
8792 if (hubd->h_local_pwr_on == B_TRUE) { in usba_hubdi_incr_power_budget()
8793 USB_DPRINTF_L3(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_incr_power_budget()
8796 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_incr_power_budget()
8800 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_incr_power_budget()
8811 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_incr_power_budget()
8812 hubd->h_pwr_left += pwr_value; in usba_hubdi_incr_power_budget()
8814 USB_DPRINTF_L3(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_incr_power_budget()
8817 hubd->h_pwr_left * USB_CFG_DESCR_PWR_UNIT, in usba_hubdi_incr_power_budget()
8820 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_incr_power_budget()
8839 hubd_t *hubd = hubd_get_soft_state(dip); in usba_hubdi_decr_power_budget() local
8841 ASSERT(hubd != NULL); in usba_hubdi_decr_power_budget()
8843 if (hubd->h_ignore_pwr_budget) { in usba_hubdi_decr_power_budget()
8848 USB_DPRINTF_L4(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_decr_power_budget()
8852 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_decr_power_budget()
8853 if (hubd->h_local_pwr_on == B_TRUE) { in usba_hubdi_decr_power_budget()
8854 USB_DPRINTF_L3(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_decr_power_budget()
8857 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_decr_power_budget()
8861 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_decr_power_budget()
8876 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_decr_power_budget()
8878 hubd->h_pwr_left -= pwr_value; in usba_hubdi_decr_power_budget()
8879 ASSERT(hubd->h_pwr_left >= 0); in usba_hubdi_decr_power_budget()
8881 USB_DPRINTF_L3(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_decr_power_budget()
8884 hubd->h_pwr_left * USB_CFG_DESCR_PWR_UNIT, in usba_hubdi_decr_power_budget()
8887 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_decr_power_budget()
8899 hubd_wait_for_hotplug_exit(hubd_t *hubd) in hubd_wait_for_hotplug_exit() argument
8904 ASSERT(mutex_owned(HUBD_MUTEX(hubd))); in hubd_wait_for_hotplug_exit()
8906 if (hubd->h_hotplug_thread) { in hubd_wait_for_hotplug_exit()
8907 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_wait_for_hotplug_exit()
8909 rval = cv_reltimedwait(&hubd->h_cv_hotplug_dev, in hubd_wait_for_hotplug_exit()
8910 &hubd->h_mutex, until, TR_CLOCK_TICK); in hubd_wait_for_hotplug_exit()
8912 if ((rval <= 0) && (hubd->h_hotplug_thread)) { in hubd_wait_for_hotplug_exit()
8933 hubd_t *hubd = hd_arg->hubd; in hubd_reset_thread() local
8937 dev_info_t *hdip = hubd->h_dip; in hubd_reset_thread()
8938 dev_info_t *rh_dip = hubd->h_usba_device->usb_root_hub_dip; in hubd_reset_thread()
8946 USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_reset_thread()
8951 mutex_enter(HUBD_MUTEX(hubd)); in hubd_reset_thread()
8953 child_dip = hubd->h_children_dips[reset_port]; in hubd_reset_thread()
8960 if (hubd->h_bus_pwr) { in hubd_reset_thread()
8961 USB_DPRINTF_L0(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_reset_thread()
8969 if (hubd_wait_for_hotplug_exit(hubd) == USB_FAILURE) { in hubd_reset_thread()
8972 hubd->h_log_handle, "Time out when resetting the device" in hubd_reset_thread()
8979 hubd->h_hotplug_thread++; in hubd_reset_thread()
8983 (hubd->h_dev_state == USB_DEV_PWRED_DOWN)) { in hubd_reset_thread()
8984 hubpm = hubd->h_hubpm; in hubd_reset_thread()
8989 mutex_exit(HUBD_MUTEX(hubd)); in hubd_reset_thread()
8991 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_reset_thread()
8997 mutex_enter(HUBD_MUTEX(hubd)); in hubd_reset_thread()
8998 hubd->h_dev_state = USB_DEV_ONLINE; in hubd_reset_thread()
9001 mutex_exit(HUBD_MUTEX(hubd)); in hubd_reset_thread()
9013 mutex_enter(HUBD_MUTEX(hubd)); in hubd_reset_thread()
9019 if (hubd->h_children_dips[reset_port]) { in hubd_reset_thread()
9020 mutex_exit(HUBD_MUTEX(hubd)); in hubd_reset_thread()
9022 hubd_post_event(hubd, reset_port, USBA_EVENT_TAG_HOT_REMOVAL); in hubd_reset_thread()
9043 mutex_enter(HUBD_MUTEX(hubd)); in hubd_reset_thread()
9044 rval = hubd_delete_child(hubd, reset_port, in hubd_reset_thread()
9046 mutex_exit(HUBD_MUTEX(hubd)); in hubd_reset_thread()
9058 mutex_enter(HUBD_MUTEX(hubd)); in hubd_reset_thread()
9061 if ((rval != USB_SUCCESS) && (hubd_delete_child(hubd, in hubd_reset_thread()
9063 USB_DPRINTF_L0(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_reset_thread()
9069 mutex_exit(HUBD_MUTEX(hubd)); in hubd_reset_thread()
9071 hubd_post_event(hubd, reset_port, in hubd_reset_thread()
9073 mutex_enter(HUBD_MUTEX(hubd)); in hubd_reset_thread()
9075 (void) hubd_determine_port_status(hubd, reset_port, in hubd_reset_thread()
9080 online_child |= (hubd_handle_port_connect(hubd, in hubd_reset_thread()
9087 mutex_exit(HUBD_MUTEX(hubd)); in hubd_reset_thread()
9098 USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_reset_thread()
9101 (void) ndi_devi_online(hubd->h_dip, 0); in hubd_reset_thread()
9104 mutex_enter(HUBD_MUTEX(hubd)); in hubd_reset_thread()
9107 hubd->h_hotplug_thread--; in hubd_reset_thread()
9109 hubd_start_polling(hubd, 0); in hubd_reset_thread()
9112 (void) hubd_pm_idle_component(hubd, hubd->h_dip, 0); in hubd_reset_thread()
9114 USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle, in hubd_reset_thread()
9115 "hubd_reset_thread: exit, %d", hubd->h_hotplug_thread); in hubd_reset_thread()
9117 hubd->h_reset_port[reset_port] = B_FALSE; in hubd_reset_thread()
9119 mutex_exit(HUBD_MUTEX(hubd)); in hubd_reset_thread()
9131 hubd_check_same_device(hubd_t *hubd, usb_port_t port) in hubd_check_same_device() argument
9133 dev_info_t *dip = hubd->h_children_dips[port]; in hubd_check_same_device()
9137 ASSERT(mutex_owned(HUBD_MUTEX(hubd))); in hubd_check_same_device()
9139 mutex_exit(HUBD_MUTEX(hubd)); in hubd_check_same_device()
9149 hubd->h_log_handle, USB_LOG_L0, in hubd_check_same_device()
9155 mutex_enter(HUBD_MUTEX(hubd)); in hubd_check_same_device()
9167 hubd_t *hubd; in usba_hubdi_reset_device() local
9205 if ((hubd = hubd_get_soft_state(hdip)) == NULL) { in usba_hubdi_reset_device()
9212 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_reset_device()
9215 if ((hubd->h_dev_state == USB_DEV_DISCONNECTED) || in usba_hubdi_reset_device()
9216 (hubd->h_dev_state == USB_DEV_SUSPENDED)) { in usba_hubdi_reset_device()
9217 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_reset_device()
9220 hubd->h_dev_state, (void *)dip); in usba_hubdi_reset_device()
9221 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_reset_device()
9226 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_reset_device()
9228 port = hubd_child_dip2port(hubd, dip); in usba_hubdi_reset_device()
9230 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_reset_device()
9232 if (hubd->h_reset_port[port]) { in usba_hubdi_reset_device()
9233 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_reset_device()
9235 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_reset_device()
9246 usba_device = hubd->h_usba_devices[port]; in usba_hubdi_reset_device()
9247 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_reset_device()
9250 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_reset_device()
9263 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_reset_device()
9269 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_reset_device()
9273 if (hubd->h_port_state[port] & HUBD_CHILD_DETACHING) { in usba_hubdi_reset_device()
9274 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_reset_device()
9277 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_reset_device()
9282 hubd->h_reset_port[port] = B_TRUE; in usba_hubdi_reset_device()
9283 hdip = hubd->h_dip; in usba_hubdi_reset_device()
9284 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_reset_device()
9289 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_reset_device()
9290 hubd_pm_busy_component(hubd, hdip, 0); in usba_hubdi_reset_device()
9291 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_reset_device()
9294 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_reset_device()
9296 hubd->h_hotplug_thread++; in usba_hubdi_reset_device()
9299 if (hubd->h_ep1_ph) { in usba_hubdi_reset_device()
9300 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_reset_device()
9301 (void) usb_pipe_get_state(hubd->h_ep1_ph, &prev_pipe_state, in usba_hubdi_reset_device()
9303 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_reset_device()
9306 hubd_stop_polling(hubd); in usba_hubdi_reset_device()
9312 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_reset_device()
9315 arg->hubd = hubd; in usba_hubdi_reset_device()
9317 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_reset_device()
9321 hubd->h_hotplug_thread--; in usba_hubdi_reset_device()
9322 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_reset_device()
9326 USB_DPRINTF_L2(DPRINT_MASK_ATTA, hubd->h_log_handle, in usba_hubdi_reset_device()
9341 if ((rval = hubd_handle_port_connect(hubd, port)) in usba_hubdi_reset_device()
9343 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_reset_device()
9347 mutex_enter(HUBD_MUTEX(hubd)); in usba_hubdi_reset_device()
9350 hubd->h_log_handle, "failed to reopen " in usba_hubdi_reset_device()
9358 (void) hubd_disable_port(hubd, port); in usba_hubdi_reset_device()
9369 hubd->h_hotplug_thread--; in usba_hubdi_reset_device()
9371 if ((hubd->h_dev_state == USB_DEV_ONLINE) && hubd->h_ep1_ph && in usba_hubdi_reset_device()
9373 hubd_start_polling(hubd, 0); in usba_hubdi_reset_device()
9376 hubd_pm_idle_component(hubd, hdip, 0); in usba_hubdi_reset_device()
9379 hubd->h_reset_port[port] = B_FALSE; in usba_hubdi_reset_device()
9381 mutex_exit(HUBD_MUTEX(hubd)); in usba_hubdi_reset_device()