Lines Matching refs:tb
72 static inline struct tb *tcm_to_tb(struct tb_cm *tcm) in tcm_to_tb()
74 return ((void *)tcm - sizeof(struct tb)); in tcm_to_tb()
79 struct tb *tb; member
88 static void tb_dp_resource_unavailable(struct tb *tb, struct tb_port *port,
90 static void tb_queue_dp_bandwidth_request(struct tb *tb, u64 route, u8 port,
93 static void tb_queue_hotplug(struct tb *tb, u64 route, u8 port, bool unplug) in tb_queue_hotplug() argument
101 ev->tb = tb; in tb_queue_hotplug()
106 queue_delayed_work(tb->wq, &ev->work, 0); in tb_queue_hotplug()
113 struct tb_cm *tcm = tb_priv(sw->tb); in tb_add_dp_resources()
140 struct tb_cm *tcm = tb_priv(sw->tb); in tb_remove_dp_resources()
157 static void tb_discover_dp_resource(struct tb *tb, struct tb_port *port) in tb_discover_dp_resource() argument
159 struct tb_cm *tcm = tb_priv(tb); in tb_discover_dp_resource()
172 static void tb_discover_dp_resources(struct tb *tb) in tb_discover_dp_resources() argument
174 struct tb_cm *tcm = tb_priv(tb); in tb_discover_dp_resources()
179 tb_discover_dp_resource(tb, tunnel->dst_port); in tb_discover_dp_resources()
186 struct tb_cm *tcm = tb_priv(sw->tb); in tb_enable_clx()
299 sw = tunnel->tb->root_switch; in tb_increase_tmu_accuracy()
315 static bool tb_tmu_hifi_uni_required(struct tb *tb) in tb_tmu_hifi_uni_required() argument
317 return device_for_each_child(&tb->dev, NULL, in tb_tmu_hifi_uni_required()
346 if (tb_tmu_hifi_uni_required(sw->tb)) in tb_enable_tmu()
382 struct tb *tb = sw->tb; in tb_switch_discover_tunnels() local
390 tunnel = tb_tunnel_discover_dp(tb, port, alloc_hopids); in tb_switch_discover_tunnels()
395 tunnel = tb_tunnel_discover_pci(tb, port, alloc_hopids); in tb_switch_discover_tunnels()
399 tunnel = tb_tunnel_discover_usb3(tb, port, alloc_hopids); in tb_switch_discover_tunnels()
436 struct tb *tb = sw->tb; in tb_scan_xdomain() local
444 xd = tb_xdomain_find_by_route(tb, route); in tb_scan_xdomain()
450 xd = tb_xdomain_alloc(tb, &sw->dev, route, tb->root_switch->uuid, in tb_scan_xdomain()
494 static struct tb_tunnel *tb_find_tunnel(struct tb *tb, enum tb_tunnel_type type, in tb_find_tunnel() argument
498 struct tb_cm *tcm = tb_priv(tb); in tb_find_tunnel()
512 static struct tb_tunnel *tb_find_first_usb3_tunnel(struct tb *tb, in tb_find_first_usb3_tunnel() argument
526 if (sw == tb->root_switch) in tb_find_first_usb3_tunnel()
530 port = tb_port_at(tb_route(sw), tb->root_switch); in tb_find_first_usb3_tunnel()
532 usb3_down = usb4_switch_map_usb3_down(tb->root_switch, port); in tb_find_first_usb3_tunnel()
536 return tb_find_tunnel(tb, TB_TUNNEL_USB3, usb3_down, NULL); in tb_find_first_usb3_tunnel()
553 static int tb_consumed_usb3_pcie_bandwidth(struct tb *tb, in tb_consumed_usb3_pcie_bandwidth() argument
565 tunnel = tb_find_first_usb3_tunnel(tb, src_port, dst_port); in tb_consumed_usb3_pcie_bandwidth()
605 static int tb_consumed_dp_bandwidth(struct tb *tb, in tb_consumed_dp_bandwidth() argument
613 struct tb_cm *tcm = tb_priv(tb); in tb_consumed_dp_bandwidth()
705 static int tb_maximum_bandwidth(struct tb *tb, struct tb_port *src_port, in tb_maximum_bandwidth() argument
811 static int tb_available_bandwidth(struct tb *tb, struct tb_port *src_port, in tb_available_bandwidth() argument
828 ret = tb_maximum_bandwidth(tb, src_port, dst_port, port, in tb_available_bandwidth()
833 ret = tb_consumed_usb3_pcie_bandwidth(tb, src_port, dst_port, in tb_available_bandwidth()
841 ret = tb_consumed_dp_bandwidth(tb, src_port, dst_port, port, in tb_available_bandwidth()
862 static int tb_release_unused_usb3_bandwidth(struct tb *tb, in tb_release_unused_usb3_bandwidth() argument
868 tunnel = tb_find_first_usb3_tunnel(tb, src_port, dst_port); in tb_release_unused_usb3_bandwidth()
872 static void tb_reclaim_usb3_bandwidth(struct tb *tb, struct tb_port *src_port, in tb_reclaim_usb3_bandwidth() argument
878 tunnel = tb_find_first_usb3_tunnel(tb, src_port, dst_port); in tb_reclaim_usb3_bandwidth()
888 ret = tb_available_bandwidth(tb, tunnel->src_port, tunnel->dst_port, in tb_reclaim_usb3_bandwidth()
901 static int tb_tunnel_usb3(struct tb *tb, struct tb_switch *sw) in tb_tunnel_usb3() argument
906 struct tb_cm *tcm = tb_priv(tb); in tb_tunnel_usb3()
910 tb_dbg(tb, "USB3 tunneling disabled, not creating tunnel\n"); in tb_tunnel_usb3()
942 ret = tb_release_unused_usb3_bandwidth(tb, down, up); in tb_tunnel_usb3()
947 ret = tb_available_bandwidth(tb, down, up, &available_up, &available_down, in tb_tunnel_usb3()
955 tunnel = tb_tunnel_alloc_usb3(tb, up, down, available_up, in tb_tunnel_usb3()
971 tb_reclaim_usb3_bandwidth(tb, down, up); in tb_tunnel_usb3()
979 tb_reclaim_usb3_bandwidth(tb, down, up); in tb_tunnel_usb3()
993 ret = tb_tunnel_usb3(sw->tb, sw); in tb_create_usb3_tunnels()
1024 static int tb_configure_asym(struct tb *tb, struct tb_port *src_port, in tb_configure_asym() argument
1048 ret = tb_consumed_dp_bandwidth(tb, src_port, dst_port, up, in tb_configure_asym()
1130 static int tb_configure_sym(struct tb *tb, struct tb_port *src_port, in tb_configure_sym() argument
1158 ret = tb_consumed_dp_bandwidth(tb, src_port, dst_port, up, in tb_configure_sym()
1218 struct tb *tb = sw->tb; in tb_configure_link() local
1245 host_port = tb_port_at(tb_route(sw), tb->root_switch); in tb_configure_link()
1246 tb_configure_sym(tb, host_port, up, false); in tb_configure_link()
1274 struct tb_cm *tcm = tb_priv(port->sw->tb); in tb_scan_port()
1285 tb_queue_hotplug(port->sw->tb, tb_route(port->sw), port->port, in tb_scan_port()
1308 sw = tb_switch_alloc(port->sw->tb, &port->sw->dev, in tb_scan_port()
1401 if (tcm->hotplug_active && tb_tunnel_usb3(sw->tb, sw)) in tb_scan_port()
1418 struct tb *tb = group->tb; in tb_recalc_estimated_bandwidth_for_group() local
1422 tb_dbg(tb, "re-calculating bandwidth estimation for group %u\n", in tb_recalc_estimated_bandwidth_for_group()
1434 tunnel = tb_find_tunnel(tb, TB_TUNNEL_DP, in, NULL); in tb_recalc_estimated_bandwidth_for_group()
1447 ret = tb_release_unused_usb3_bandwidth(tb, in tb_recalc_estimated_bandwidth_for_group()
1457 ret = tb_available_bandwidth(tb, in, out, &estimated_up, in tb_recalc_estimated_bandwidth_for_group()
1492 tb_reclaim_usb3_bandwidth(tb, first_tunnel->src_port, in tb_recalc_estimated_bandwidth_for_group()
1495 tb_dbg(tb, "bandwidth estimation for group %u done\n", group->index); in tb_recalc_estimated_bandwidth_for_group()
1498 static void tb_recalc_estimated_bandwidth(struct tb *tb) in tb_recalc_estimated_bandwidth() argument
1500 struct tb_cm *tcm = tb_priv(tb); in tb_recalc_estimated_bandwidth()
1503 tb_dbg(tb, "bandwidth consumption changed, re-calculating estimated bandwidth\n"); in tb_recalc_estimated_bandwidth()
1512 tb_dbg(tb, "bandwidth re-calculation done\n"); in tb_recalc_estimated_bandwidth()
1518 tb_dbg(group->tb, "group %d released total %d Mb/s\n", group->index, in __release_group_bandwidth()
1545 tunnel = tb_find_tunnel(group->tb, TB_TUNNEL_DP, in, NULL); in __configure_group_sym()
1547 tb_configure_sym(group->tb, in, tunnel->dst_port, true); in __configure_group_sym()
1554 struct tb *tb = group->tb; in tb_bandwidth_group_release_work() local
1556 mutex_lock(&tb->lock); in tb_bandwidth_group_release_work()
1558 tb_recalc_estimated_bandwidth(tb); in tb_bandwidth_group_release_work()
1560 mutex_unlock(&tb->lock); in tb_bandwidth_group_release_work()
1570 group->tb = tcm_to_tb(tcm); in tb_init_bandwidth_groups()
1677 static void tb_discover_tunnels(struct tb *tb) in tb_discover_tunnels() argument
1679 struct tb_cm *tcm = tb_priv(tb); in tb_discover_tunnels()
1682 tb_switch_discover_tunnels(tb->root_switch, &tcm->tunnel_list, true); in tb_discover_tunnels()
1708 struct tb *tb; in tb_deactivate_and_free_tunnel() local
1716 tb = tunnel->tb; in tb_deactivate_and_free_tunnel()
1732 tb_configure_sym(tb, src_port, dst_port, true); in tb_deactivate_and_free_tunnel()
1741 tb_reclaim_usb3_bandwidth(tb, src_port, dst_port); in tb_deactivate_and_free_tunnel()
1758 static void tb_free_invalid_tunnels(struct tb *tb) in tb_free_invalid_tunnels() argument
1760 struct tb_cm *tcm = tb_priv(tb); in tb_free_invalid_tunnels()
1846 static struct tb_port *tb_find_dp_out(struct tb *tb, struct tb_port *in) in tb_find_dp_out() argument
1849 struct tb_cm *tcm = tb_priv(tb); in tb_find_dp_out()
1852 tb_port_at(tb_route(in->sw), tb->root_switch) : NULL; in tb_find_dp_out()
1878 p = tb_port_at(tb_route(port->sw), tb->root_switch); in tb_find_dp_out()
1893 struct tb *tb = data; in tb_dp_tunnel_active() local
1895 mutex_lock(&tb->lock); in tb_dp_tunnel_active()
1909 tb_reclaim_usb3_bandwidth(tb, in, out); in tb_dp_tunnel_active()
1914 tb_configure_asym(tb, in, out, consumed_up, in tb_dp_tunnel_active()
1920 tb_recalc_estimated_bandwidth(tb); in tb_dp_tunnel_active()
1947 tb_dp_resource_unavailable(tb, in, "DPRX negotiation failed"); in tb_dp_tunnel_active()
1949 mutex_unlock(&tb->lock); in tb_dp_tunnel_active()
1951 tb_domain_put(tb); in tb_dp_tunnel_active()
1954 static void tb_tunnel_one_dp(struct tb *tb, struct tb_port *in, in tb_tunnel_one_dp() argument
1958 struct tb_cm *tcm = tb_priv(tb); in tb_tunnel_one_dp()
1995 ret = tb_release_unused_usb3_bandwidth(tb, in, out); in tb_tunnel_one_dp()
1997 tb_warn(tb, "failed to release unused bandwidth\n"); in tb_tunnel_one_dp()
2001 ret = tb_available_bandwidth(tb, in, out, &available_up, &available_down, in tb_tunnel_one_dp()
2006 tb_dbg(tb, "available bandwidth for new DP tunnel %u/%u Mb/s\n", in tb_tunnel_one_dp()
2009 tunnel = tb_tunnel_alloc_dp(tb, in, out, link_nr, available_up, in tb_tunnel_one_dp()
2011 tb_domain_get(tb)); in tb_tunnel_one_dp()
2031 tb_reclaim_usb3_bandwidth(tb, in, out); in tb_tunnel_one_dp()
2032 tb_domain_put(tb); in tb_tunnel_one_dp()
2044 static void tb_tunnel_dp(struct tb *tb) in tb_tunnel_dp() argument
2046 struct tb_cm *tcm = tb_priv(tb); in tb_tunnel_dp()
2050 tb_dbg(tb, "DP tunneling disabled, not creating tunnel\n"); in tb_tunnel_dp()
2058 tb_dbg(tb, "looking for DP IN <-> DP OUT pairs:\n"); in tb_tunnel_dp()
2074 out = tb_find_dp_out(tb, port); in tb_tunnel_dp()
2076 tb_tunnel_one_dp(tb, in, out); in tb_tunnel_dp()
2082 tb_dbg(tb, "no suitable DP IN adapter available, not tunneling\n"); in tb_tunnel_dp()
2159 static void tb_dp_resource_unavailable(struct tb *tb, struct tb_port *port, in tb_dp_resource_unavailable() argument
2175 tunnel = tb_find_tunnel(tb, TB_TUNNEL_DP, in, out); in tb_dp_resource_unavailable()
2186 tb_recalc_estimated_bandwidth(tb); in tb_dp_resource_unavailable()
2187 tb_tunnel_dp(tb); in tb_dp_resource_unavailable()
2190 static void tb_dp_resource_available(struct tb *tb, struct tb_port *port) in tb_dp_resource_available() argument
2192 struct tb_cm *tcm = tb_priv(tb); in tb_dp_resource_available()
2209 tb_tunnel_dp(tb); in tb_dp_resource_available()
2212 static void tb_disconnect_and_release_dp(struct tb *tb) in tb_disconnect_and_release_dp() argument
2214 struct tb_cm *tcm = tb_priv(tb); in tb_disconnect_and_release_dp()
2235 static int tb_disconnect_pci(struct tb *tb, struct tb_switch *sw) in tb_disconnect_pci() argument
2244 tunnel = tb_find_tunnel(tb, TB_TUNNEL_PCI, NULL, up); in tb_disconnect_pci()
2256 static int tb_tunnel_pci(struct tb *tb, struct tb_switch *sw) in tb_tunnel_pci() argument
2259 struct tb_cm *tcm = tb_priv(tb); in tb_tunnel_pci()
2275 tunnel = tb_tunnel_alloc_pci(tb, up, down); in tb_tunnel_pci()
2300 static int tb_approve_xdomain_paths(struct tb *tb, struct tb_xdomain *xd, in tb_approve_xdomain_paths() argument
2304 struct tb_cm *tcm = tb_priv(tb); in tb_approve_xdomain_paths()
2312 nhi_port = tb_switch_find_port(tb->root_switch, TB_TYPE_NHI); in tb_approve_xdomain_paths()
2314 mutex_lock(&tb->lock); in tb_approve_xdomain_paths()
2322 tunnel = tb_tunnel_alloc_dma(tb, nhi_port, dst_port, transmit_path, in tb_approve_xdomain_paths()
2337 mutex_unlock(&tb->lock); in tb_approve_xdomain_paths()
2344 mutex_unlock(&tb->lock); in tb_approve_xdomain_paths()
2349 static void __tb_disconnect_xdomain_paths(struct tb *tb, struct tb_xdomain *xd, in __tb_disconnect_xdomain_paths() argument
2353 struct tb_cm *tcm = tb_priv(tb); in __tb_disconnect_xdomain_paths()
2360 nhi_port = tb_switch_find_port(tb->root_switch, TB_TYPE_NHI); in __tb_disconnect_xdomain_paths()
2381 static int tb_disconnect_xdomain_paths(struct tb *tb, struct tb_xdomain *xd, in tb_disconnect_xdomain_paths() argument
2386 mutex_lock(&tb->lock); in tb_disconnect_xdomain_paths()
2387 __tb_disconnect_xdomain_paths(tb, xd, transmit_path, in tb_disconnect_xdomain_paths()
2390 mutex_unlock(&tb->lock); in tb_disconnect_xdomain_paths()
2405 struct tb *tb = ev->tb; in tb_handle_hotplug() local
2406 struct tb_cm *tcm = tb_priv(tb); in tb_handle_hotplug()
2411 pm_runtime_get_sync(&tb->dev); in tb_handle_hotplug()
2413 mutex_lock(&tb->lock); in tb_handle_hotplug()
2417 sw = tb_switch_find_by_route(tb, ev->route); in tb_handle_hotplug()
2419 tb_warn(tb, in tb_handle_hotplug()
2425 tb_warn(tb, in tb_handle_hotplug()
2432 tb_dbg(tb, "hotplug event for upstream port %llx:%x (unplug: %d)\n", in tb_handle_hotplug()
2445 tb_free_invalid_tunnels(tb); in tb_handle_hotplug()
2456 tb_recalc_estimated_bandwidth(tb); in tb_handle_hotplug()
2457 tb_tunnel_dp(tb); in tb_handle_hotplug()
2472 __tb_disconnect_xdomain_paths(tb, xd, -1, -1, -1, -1); in tb_handle_hotplug()
2476 tb_dp_resource_unavailable(tb, port, "adapter unplug"); in tb_handle_hotplug()
2496 tb_dp_resource_available(tb, port); in tb_handle_hotplug()
2506 mutex_unlock(&tb->lock); in tb_handle_hotplug()
2508 pm_runtime_mark_last_busy(&tb->dev); in tb_handle_hotplug()
2509 pm_runtime_put_autosuspend(&tb->dev); in tb_handle_hotplug()
2521 struct tb *tb = tunnel->tb; in tb_alloc_dp_bandwidth() local
2609 tb_dbg(tb, "group %d reserved %d total %d Mb/s\n", in tb_alloc_dp_bandwidth()
2633 ret = tb_release_unused_usb3_bandwidth(tb, in, out); in tb_alloc_dp_bandwidth()
2642 ret = tb_available_bandwidth(tb, in, out, &available_up, &available_down, in tb_alloc_dp_bandwidth()
2660 ret = tb_configure_asym(tb, in, out, *requested_up, in tb_alloc_dp_bandwidth()
2663 tb_configure_sym(tb, in, out, true); in tb_alloc_dp_bandwidth()
2671 tb_configure_sym(tb, in, out, true); in tb_alloc_dp_bandwidth()
2683 tb_dbg(tb, "group %d released %d total %d Mb/s\n", in tb_alloc_dp_bandwidth()
2691 tb_reclaim_usb3_bandwidth(tb, in, out); in tb_alloc_dp_bandwidth()
2712 struct tb *tb = ev->tb; in tb_handle_dp_bandwidth_request() local
2713 struct tb_cm *tcm = tb_priv(tb); in tb_handle_dp_bandwidth_request()
2717 pm_runtime_get_sync(&tb->dev); in tb_handle_dp_bandwidth_request()
2719 mutex_lock(&tb->lock); in tb_handle_dp_bandwidth_request()
2723 sw = tb_switch_find_by_route(tb, ev->route); in tb_handle_dp_bandwidth_request()
2725 tb_warn(tb, "bandwidth request from non-existent router %llx\n", in tb_handle_dp_bandwidth_request()
2738 tunnel = tb_find_tunnel(tb, TB_TUNNEL_DP, in, NULL); in tb_handle_dp_bandwidth_request()
2769 tb_recalc_estimated_bandwidth(tb); in tb_handle_dp_bandwidth_request()
2804 tb_queue_dp_bandwidth_request(tb, ev->route, in tb_handle_dp_bandwidth_request()
2822 tb_recalc_estimated_bandwidth(tb); in tb_handle_dp_bandwidth_request()
2828 mutex_unlock(&tb->lock); in tb_handle_dp_bandwidth_request()
2830 pm_runtime_mark_last_busy(&tb->dev); in tb_handle_dp_bandwidth_request()
2831 pm_runtime_put_autosuspend(&tb->dev); in tb_handle_dp_bandwidth_request()
2836 static void tb_queue_dp_bandwidth_request(struct tb *tb, u64 route, u8 port, in tb_queue_dp_bandwidth_request() argument
2845 ev->tb = tb; in tb_queue_dp_bandwidth_request()
2850 queue_delayed_work(tb->wq, &ev->work, delay); in tb_queue_dp_bandwidth_request()
2853 static void tb_handle_notification(struct tb *tb, u64 route, in tb_handle_notification() argument
2861 if (tb_cfg_ack_notification(tb->ctl, route, error)) in tb_handle_notification()
2862 tb_warn(tb, "could not ack notification on %llx\n", in tb_handle_notification()
2867 if (tb_cfg_ack_notification(tb->ctl, route, error)) in tb_handle_notification()
2868 tb_warn(tb, "could not ack notification on %llx\n", in tb_handle_notification()
2870 tb_queue_dp_bandwidth_request(tb, route, error->port, 0, 0); in tb_handle_notification()
2884 static void tb_handle_event(struct tb *tb, enum tb_cfg_pkg_type type, in tb_handle_event() argument
2892 tb_handle_notification(tb, route, (const struct cfg_error_pkg *)buf); in tb_handle_event()
2897 tb_warn(tb, "unexpected event %#x, ignoring\n", type); in tb_handle_event()
2901 if (tb_cfg_ack_plug(tb->ctl, route, pkg->port, pkg->unplug)) { in tb_handle_event()
2902 tb_warn(tb, "could not ack plug event on %llx:%x\n", route, in tb_handle_event()
2906 tb_queue_hotplug(tb, route, pkg->port, pkg->unplug); in tb_handle_event()
2909 static void tb_stop(struct tb *tb) in tb_stop() argument
2911 struct tb_cm *tcm = tb_priv(tb); in tb_stop()
2927 tb_switch_remove(tb->root_switch); in tb_stop()
2931 static void tb_deinit(struct tb *tb) in tb_deinit() argument
2933 struct tb_cm *tcm = tb_priv(tb); in tb_deinit()
2962 static int tb_start(struct tb *tb, bool reset) in tb_start() argument
2964 struct tb_cm *tcm = tb_priv(tb); in tb_start()
2968 tb->root_switch = tb_switch_alloc(tb, &tb->dev, 0); in tb_start()
2969 if (IS_ERR(tb->root_switch)) in tb_start()
2970 return PTR_ERR(tb->root_switch); in tb_start()
2980 tb->root_switch->no_nvm_upgrade = !tb_switch_is_usb4(tb->root_switch); in tb_start()
2982 tb->root_switch->rpm = tb_switch_is_usb4(tb->root_switch); in tb_start()
2984 ret = tb_switch_configure(tb->root_switch); in tb_start()
2986 tb_switch_put(tb->root_switch); in tb_start()
2991 ret = tb_switch_add(tb->root_switch); in tb_start()
2993 tb_switch_put(tb->root_switch); in tb_start()
3001 tb_switch_tmu_configure(tb->root_switch, TB_SWITCH_TMU_MODE_LOWRES); in tb_start()
3003 tb_switch_tmu_enable(tb->root_switch); in tb_start()
3011 if (reset && tb_switch_is_usb4(tb->root_switch)) { in tb_start()
3013 if (usb4_switch_version(tb->root_switch) == 1) in tb_start()
3014 tb_switch_reset(tb->root_switch); in tb_start()
3019 tb_scan_switch(tb->root_switch); in tb_start()
3021 tb_discover_tunnels(tb); in tb_start()
3023 tb_discover_dp_resources(tb); in tb_start()
3030 tb_create_usb3_tunnels(tb->root_switch); in tb_start()
3032 tb_add_dp_resources(tb->root_switch); in tb_start()
3033 tb_switch_enter_redrive(tb->root_switch); in tb_start()
3035 device_for_each_child(&tb->root_switch->dev, NULL, in tb_start()
3043 static int tb_suspend_noirq(struct tb *tb) in tb_suspend_noirq() argument
3045 struct tb_cm *tcm = tb_priv(tb); in tb_suspend_noirq()
3047 tb_dbg(tb, "suspending...\n"); in tb_suspend_noirq()
3048 tb_disconnect_and_release_dp(tb); in tb_suspend_noirq()
3049 tb_switch_exit_redrive(tb->root_switch); in tb_suspend_noirq()
3050 tb_switch_suspend(tb->root_switch, false); in tb_suspend_noirq()
3052 tb_dbg(tb, "suspend finished\n"); in tb_suspend_noirq()
3089 static int tb_resume_noirq(struct tb *tb) in tb_resume_noirq() argument
3091 struct tb_cm *tcm = tb_priv(tb); in tb_resume_noirq()
3096 tb_dbg(tb, "resuming...\n"); in tb_resume_noirq()
3102 if (!tb_switch_is_usb4(tb->root_switch)) in tb_resume_noirq()
3103 tb_switch_reset(tb->root_switch); in tb_resume_noirq()
3105 tb_switch_resume(tb->root_switch, false); in tb_resume_noirq()
3106 tb_free_invalid_tunnels(tb); in tb_resume_noirq()
3107 tb_free_unplugged_children(tb->root_switch); in tb_resume_noirq()
3108 tb_restore_children(tb->root_switch); in tb_resume_noirq()
3116 tb_switch_discover_tunnels(tb->root_switch, &tunnels, false); in tb_resume_noirq()
3139 tb_dbg(tb, "tunnels restarted, sleeping for 100ms\n"); in tb_resume_noirq()
3142 tb_switch_enter_redrive(tb->root_switch); in tb_resume_noirq()
3145 tb_dbg(tb, "resume finished\n"); in tb_resume_noirq()
3172 static int tb_freeze_noirq(struct tb *tb) in tb_freeze_noirq() argument
3174 struct tb_cm *tcm = tb_priv(tb); in tb_freeze_noirq()
3180 static int tb_thaw_noirq(struct tb *tb) in tb_thaw_noirq() argument
3182 struct tb_cm *tcm = tb_priv(tb); in tb_thaw_noirq()
3188 static void tb_complete(struct tb *tb) in tb_complete() argument
3195 mutex_lock(&tb->lock); in tb_complete()
3196 if (tb_free_unplugged_xdomains(tb->root_switch)) in tb_complete()
3197 tb_scan_switch(tb->root_switch); in tb_complete()
3198 mutex_unlock(&tb->lock); in tb_complete()
3201 static int tb_runtime_suspend(struct tb *tb) in tb_runtime_suspend() argument
3203 struct tb_cm *tcm = tb_priv(tb); in tb_runtime_suspend()
3205 mutex_lock(&tb->lock); in tb_runtime_suspend()
3210 tb_disconnect_and_release_dp(tb); in tb_runtime_suspend()
3211 tb_switch_exit_redrive(tb->root_switch); in tb_runtime_suspend()
3212 tb_switch_suspend(tb->root_switch, true); in tb_runtime_suspend()
3214 mutex_unlock(&tb->lock); in tb_runtime_suspend()
3222 struct tb *tb = tcm_to_tb(tcm); in tb_remove_work() local
3224 mutex_lock(&tb->lock); in tb_remove_work()
3225 if (tb->root_switch) { in tb_remove_work()
3226 tb_free_unplugged_children(tb->root_switch); in tb_remove_work()
3227 tb_free_unplugged_xdomains(tb->root_switch); in tb_remove_work()
3229 mutex_unlock(&tb->lock); in tb_remove_work()
3232 static int tb_runtime_resume(struct tb *tb) in tb_runtime_resume() argument
3234 struct tb_cm *tcm = tb_priv(tb); in tb_runtime_resume()
3237 mutex_lock(&tb->lock); in tb_runtime_resume()
3238 tb_switch_resume(tb->root_switch, true); in tb_runtime_resume()
3239 tb_free_invalid_tunnels(tb); in tb_runtime_resume()
3240 tb_restore_children(tb->root_switch); in tb_runtime_resume()
3243 tb_switch_enter_redrive(tb->root_switch); in tb_runtime_resume()
3245 mutex_unlock(&tb->lock); in tb_runtime_resume()
3252 queue_delayed_work(tb->wq, &tcm->remove_work, msecs_to_jiffies(50)); in tb_runtime_resume()
3342 struct tb *tb_probe(struct tb_nhi *nhi) in tb_probe()
3345 struct tb *tb; in tb_probe() local
3347 tb = tb_domain_alloc(nhi, TB_TIMEOUT, sizeof(*tcm)); in tb_probe()
3348 if (!tb) in tb_probe()
3352 tb->security_level = TB_SECURITY_USER; in tb_probe()
3354 tb->security_level = TB_SECURITY_NOPCIE; in tb_probe()
3356 tb->cm_ops = &tb_cm_ops; in tb_probe()
3358 tcm = tb_priv(tb); in tb_probe()
3364 tb_dbg(tb, "using software connection manager\n"); in tb_probe()
3372 tb_warn(tb, "device links to tunneled native ports are missing!\n"); in tb_probe()
3374 return tb; in tb_probe()