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()
961 tb_tunnel_event(tb, TB_TUNNEL_LOW_BANDWIDTH, TB_TUNNEL_USB3, in tb_tunnel_usb3()
964 tunnel = tb_tunnel_alloc_usb3(tb, up, down, available_up, in tb_tunnel_usb3()
980 tb_reclaim_usb3_bandwidth(tb, down, up); in tb_tunnel_usb3()
988 tb_reclaim_usb3_bandwidth(tb, down, up); in tb_tunnel_usb3()
1002 ret = tb_tunnel_usb3(sw->tb, sw); in tb_create_usb3_tunnels()
1033 static int tb_configure_asym(struct tb *tb, struct tb_port *src_port, in tb_configure_asym() argument
1057 ret = tb_consumed_dp_bandwidth(tb, src_port, dst_port, up, in tb_configure_asym()
1139 static int tb_configure_sym(struct tb *tb, struct tb_port *src_port, in tb_configure_sym() argument
1167 ret = tb_consumed_dp_bandwidth(tb, src_port, dst_port, up, in tb_configure_sym()
1227 struct tb *tb = sw->tb; in tb_configure_link() local
1254 host_port = tb_port_at(tb_route(sw), tb->root_switch); in tb_configure_link()
1255 tb_configure_sym(tb, host_port, up, false); in tb_configure_link()
1283 struct tb_cm *tcm = tb_priv(port->sw->tb); in tb_scan_port()
1294 tb_queue_hotplug(port->sw->tb, tb_route(port->sw), port->port, in tb_scan_port()
1317 sw = tb_switch_alloc(port->sw->tb, &port->sw->dev, in tb_scan_port()
1410 if (tcm->hotplug_active && tb_tunnel_usb3(sw->tb, sw)) in tb_scan_port()
1427 struct tb *tb = group->tb; in tb_recalc_estimated_bandwidth_for_group() local
1431 tb_dbg(tb, "re-calculating bandwidth estimation for group %u\n", in tb_recalc_estimated_bandwidth_for_group()
1443 tunnel = tb_find_tunnel(tb, TB_TUNNEL_DP, in, NULL); in tb_recalc_estimated_bandwidth_for_group()
1456 ret = tb_release_unused_usb3_bandwidth(tb, in tb_recalc_estimated_bandwidth_for_group()
1466 ret = tb_available_bandwidth(tb, in, out, &estimated_up, in tb_recalc_estimated_bandwidth_for_group()
1501 tb_reclaim_usb3_bandwidth(tb, first_tunnel->src_port, in tb_recalc_estimated_bandwidth_for_group()
1504 tb_dbg(tb, "bandwidth estimation for group %u done\n", group->index); in tb_recalc_estimated_bandwidth_for_group()
1507 static void tb_recalc_estimated_bandwidth(struct tb *tb) in tb_recalc_estimated_bandwidth() argument
1509 struct tb_cm *tcm = tb_priv(tb); in tb_recalc_estimated_bandwidth()
1512 tb_dbg(tb, "bandwidth consumption changed, re-calculating estimated bandwidth\n"); in tb_recalc_estimated_bandwidth()
1521 tb_dbg(tb, "bandwidth re-calculation done\n"); in tb_recalc_estimated_bandwidth()
1527 tb_dbg(group->tb, "group %d released total %d Mb/s\n", group->index, in __release_group_bandwidth()
1554 tunnel = tb_find_tunnel(group->tb, TB_TUNNEL_DP, in, NULL); in __configure_group_sym()
1556 tb_configure_sym(group->tb, in, tunnel->dst_port, true); in __configure_group_sym()
1563 struct tb *tb = group->tb; in tb_bandwidth_group_release_work() local
1565 mutex_lock(&tb->lock); in tb_bandwidth_group_release_work()
1567 tb_recalc_estimated_bandwidth(tb); in tb_bandwidth_group_release_work()
1569 mutex_unlock(&tb->lock); in tb_bandwidth_group_release_work()
1579 group->tb = tcm_to_tb(tcm); in tb_init_bandwidth_groups()
1686 static void tb_discover_tunnels(struct tb *tb) in tb_discover_tunnels() argument
1688 struct tb_cm *tcm = tb_priv(tb); in tb_discover_tunnels()
1691 tb_switch_discover_tunnels(tb->root_switch, &tcm->tunnel_list, true); in tb_discover_tunnels()
1717 struct tb *tb; in tb_deactivate_and_free_tunnel() local
1725 tb = tunnel->tb; in tb_deactivate_and_free_tunnel()
1741 tb_configure_sym(tb, src_port, dst_port, true); in tb_deactivate_and_free_tunnel()
1750 tb_reclaim_usb3_bandwidth(tb, src_port, dst_port); in tb_deactivate_and_free_tunnel()
1767 static void tb_free_invalid_tunnels(struct tb *tb) in tb_free_invalid_tunnels() argument
1769 struct tb_cm *tcm = tb_priv(tb); in tb_free_invalid_tunnels()
1855 static struct tb_port *tb_find_dp_out(struct tb *tb, struct tb_port *in) in tb_find_dp_out() argument
1858 struct tb_cm *tcm = tb_priv(tb); in tb_find_dp_out()
1861 tb_port_at(tb_route(in->sw), tb->root_switch) : NULL; in tb_find_dp_out()
1887 p = tb_port_at(tb_route(port->sw), tb->root_switch); in tb_find_dp_out()
1902 struct tb *tb = data; in tb_dp_tunnel_active() local
1904 mutex_lock(&tb->lock); in tb_dp_tunnel_active()
1918 tb_reclaim_usb3_bandwidth(tb, in, out); in tb_dp_tunnel_active()
1923 tb_configure_asym(tb, in, out, consumed_up, in tb_dp_tunnel_active()
1929 tb_recalc_estimated_bandwidth(tb); in tb_dp_tunnel_active()
1956 tb_dp_resource_unavailable(tb, in, "DPRX negotiation failed"); in tb_dp_tunnel_active()
1958 mutex_unlock(&tb->lock); in tb_dp_tunnel_active()
1960 tb_domain_put(tb); in tb_dp_tunnel_active()
1963 static void tb_tunnel_one_dp(struct tb *tb, struct tb_port *in, in tb_tunnel_one_dp() argument
1967 struct tb_cm *tcm = tb_priv(tb); in tb_tunnel_one_dp()
2004 ret = tb_release_unused_usb3_bandwidth(tb, in, out); in tb_tunnel_one_dp()
2006 tb_warn(tb, "failed to release unused bandwidth\n"); in tb_tunnel_one_dp()
2010 ret = tb_available_bandwidth(tb, in, out, &available_up, &available_down, in tb_tunnel_one_dp()
2013 tb_tunnel_event(tb, TB_TUNNEL_NO_BANDWIDTH, TB_TUNNEL_DP, in, out); in tb_tunnel_one_dp()
2017 tb_dbg(tb, "available bandwidth for new DP tunnel %u/%u Mb/s\n", in tb_tunnel_one_dp()
2020 tunnel = tb_tunnel_alloc_dp(tb, in, out, link_nr, available_up, in tb_tunnel_one_dp()
2022 tb_domain_get(tb)); in tb_tunnel_one_dp()
2042 tb_reclaim_usb3_bandwidth(tb, in, out); in tb_tunnel_one_dp()
2043 tb_domain_put(tb); in tb_tunnel_one_dp()
2055 static void tb_tunnel_dp(struct tb *tb) in tb_tunnel_dp() argument
2057 struct tb_cm *tcm = tb_priv(tb); in tb_tunnel_dp()
2061 tb_dbg(tb, "DP tunneling disabled, not creating tunnel\n"); in tb_tunnel_dp()
2069 tb_dbg(tb, "looking for DP IN <-> DP OUT pairs:\n"); in tb_tunnel_dp()
2085 out = tb_find_dp_out(tb, port); in tb_tunnel_dp()
2087 tb_tunnel_one_dp(tb, in, out); in tb_tunnel_dp()
2093 tb_dbg(tb, "no suitable DP IN adapter available, not tunneling\n"); in tb_tunnel_dp()
2170 static void tb_dp_resource_unavailable(struct tb *tb, struct tb_port *port, in tb_dp_resource_unavailable() argument
2186 tunnel = tb_find_tunnel(tb, TB_TUNNEL_DP, in, out); in tb_dp_resource_unavailable()
2197 tb_recalc_estimated_bandwidth(tb); in tb_dp_resource_unavailable()
2198 tb_tunnel_dp(tb); in tb_dp_resource_unavailable()
2201 static void tb_dp_resource_available(struct tb *tb, struct tb_port *port) in tb_dp_resource_available() argument
2203 struct tb_cm *tcm = tb_priv(tb); in tb_dp_resource_available()
2220 tb_tunnel_dp(tb); in tb_dp_resource_available()
2223 static void tb_disconnect_and_release_dp(struct tb *tb) in tb_disconnect_and_release_dp() argument
2225 struct tb_cm *tcm = tb_priv(tb); in tb_disconnect_and_release_dp()
2246 static int tb_disconnect_pci(struct tb *tb, struct tb_switch *sw) in tb_disconnect_pci() argument
2255 tunnel = tb_find_tunnel(tb, TB_TUNNEL_PCI, NULL, up); in tb_disconnect_pci()
2267 static int tb_tunnel_pci(struct tb *tb, struct tb_switch *sw) in tb_tunnel_pci() argument
2270 struct tb_cm *tcm = tb_priv(tb); in tb_tunnel_pci()
2286 tunnel = tb_tunnel_alloc_pci(tb, up, down); in tb_tunnel_pci()
2311 static int tb_approve_xdomain_paths(struct tb *tb, struct tb_xdomain *xd, in tb_approve_xdomain_paths() argument
2315 struct tb_cm *tcm = tb_priv(tb); in tb_approve_xdomain_paths()
2323 nhi_port = tb_switch_find_port(tb->root_switch, TB_TYPE_NHI); in tb_approve_xdomain_paths()
2325 mutex_lock(&tb->lock); in tb_approve_xdomain_paths()
2333 tunnel = tb_tunnel_alloc_dma(tb, nhi_port, dst_port, transmit_path, in tb_approve_xdomain_paths()
2348 mutex_unlock(&tb->lock); in tb_approve_xdomain_paths()
2355 mutex_unlock(&tb->lock); in tb_approve_xdomain_paths()
2360 static void __tb_disconnect_xdomain_paths(struct tb *tb, struct tb_xdomain *xd, in __tb_disconnect_xdomain_paths() argument
2364 struct tb_cm *tcm = tb_priv(tb); in __tb_disconnect_xdomain_paths()
2371 nhi_port = tb_switch_find_port(tb->root_switch, TB_TYPE_NHI); in __tb_disconnect_xdomain_paths()
2392 static int tb_disconnect_xdomain_paths(struct tb *tb, struct tb_xdomain *xd, in tb_disconnect_xdomain_paths() argument
2397 mutex_lock(&tb->lock); in tb_disconnect_xdomain_paths()
2398 __tb_disconnect_xdomain_paths(tb, xd, transmit_path, in tb_disconnect_xdomain_paths()
2401 mutex_unlock(&tb->lock); in tb_disconnect_xdomain_paths()
2416 struct tb *tb = ev->tb; in tb_handle_hotplug() local
2417 struct tb_cm *tcm = tb_priv(tb); in tb_handle_hotplug()
2422 pm_runtime_get_sync(&tb->dev); in tb_handle_hotplug()
2424 mutex_lock(&tb->lock); in tb_handle_hotplug()
2428 sw = tb_switch_find_by_route(tb, ev->route); in tb_handle_hotplug()
2430 tb_warn(tb, in tb_handle_hotplug()
2436 tb_warn(tb, in tb_handle_hotplug()
2443 tb_dbg(tb, "hotplug event for upstream port %llx:%x (unplug: %d)\n", in tb_handle_hotplug()
2456 tb_free_invalid_tunnels(tb); in tb_handle_hotplug()
2467 tb_recalc_estimated_bandwidth(tb); in tb_handle_hotplug()
2468 tb_tunnel_dp(tb); in tb_handle_hotplug()
2483 __tb_disconnect_xdomain_paths(tb, xd, -1, -1, -1, -1); in tb_handle_hotplug()
2487 tb_dp_resource_unavailable(tb, port, "adapter unplug"); in tb_handle_hotplug()
2507 tb_dp_resource_available(tb, port); in tb_handle_hotplug()
2517 mutex_unlock(&tb->lock); in tb_handle_hotplug()
2519 pm_runtime_mark_last_busy(&tb->dev); in tb_handle_hotplug()
2520 pm_runtime_put_autosuspend(&tb->dev); in tb_handle_hotplug()
2532 struct tb *tb = tunnel->tb; in tb_alloc_dp_bandwidth() local
2620 tb_dbg(tb, "group %d reserved %d total %d Mb/s\n", in tb_alloc_dp_bandwidth()
2648 ret = tb_release_unused_usb3_bandwidth(tb, in, out); in tb_alloc_dp_bandwidth()
2657 ret = tb_available_bandwidth(tb, in, out, &available_up, &available_down, in tb_alloc_dp_bandwidth()
2675 ret = tb_configure_asym(tb, in, out, *requested_up, in tb_alloc_dp_bandwidth()
2678 tb_configure_sym(tb, in, out, true); in tb_alloc_dp_bandwidth()
2686 tb_configure_sym(tb, in, out, true); in tb_alloc_dp_bandwidth()
2698 tb_dbg(tb, "group %d released %d total %d Mb/s\n", in tb_alloc_dp_bandwidth()
2706 tb_reclaim_usb3_bandwidth(tb, in, out); in tb_alloc_dp_bandwidth()
2717 tb_tunnel_event(tb, TB_TUNNEL_NO_BANDWIDTH, TB_TUNNEL_DP, in, out); in tb_alloc_dp_bandwidth()
2728 struct tb *tb = ev->tb; in tb_handle_dp_bandwidth_request() local
2729 struct tb_cm *tcm = tb_priv(tb); in tb_handle_dp_bandwidth_request()
2733 pm_runtime_get_sync(&tb->dev); in tb_handle_dp_bandwidth_request()
2735 mutex_lock(&tb->lock); in tb_handle_dp_bandwidth_request()
2739 sw = tb_switch_find_by_route(tb, ev->route); in tb_handle_dp_bandwidth_request()
2741 tb_warn(tb, "bandwidth request from non-existent router %llx\n", in tb_handle_dp_bandwidth_request()
2754 tunnel = tb_find_tunnel(tb, TB_TUNNEL_DP, in, NULL); in tb_handle_dp_bandwidth_request()
2785 tb_recalc_estimated_bandwidth(tb); in tb_handle_dp_bandwidth_request()
2820 tb_queue_dp_bandwidth_request(tb, ev->route, in tb_handle_dp_bandwidth_request()
2838 tb_recalc_estimated_bandwidth(tb); in tb_handle_dp_bandwidth_request()
2844 mutex_unlock(&tb->lock); in tb_handle_dp_bandwidth_request()
2846 pm_runtime_mark_last_busy(&tb->dev); in tb_handle_dp_bandwidth_request()
2847 pm_runtime_put_autosuspend(&tb->dev); in tb_handle_dp_bandwidth_request()
2852 static void tb_queue_dp_bandwidth_request(struct tb *tb, u64 route, u8 port, in tb_queue_dp_bandwidth_request() argument
2861 ev->tb = tb; in tb_queue_dp_bandwidth_request()
2866 queue_delayed_work(tb->wq, &ev->work, delay); in tb_queue_dp_bandwidth_request()
2869 static void tb_handle_notification(struct tb *tb, u64 route, in tb_handle_notification() argument
2877 if (tb_cfg_ack_notification(tb->ctl, route, error)) in tb_handle_notification()
2878 tb_warn(tb, "could not ack notification on %llx\n", in tb_handle_notification()
2883 if (tb_cfg_ack_notification(tb->ctl, route, error)) in tb_handle_notification()
2884 tb_warn(tb, "could not ack notification on %llx\n", in tb_handle_notification()
2886 tb_queue_dp_bandwidth_request(tb, route, error->port, 0, 0); in tb_handle_notification()
2900 static void tb_handle_event(struct tb *tb, enum tb_cfg_pkg_type type, in tb_handle_event() argument
2908 tb_handle_notification(tb, route, (const struct cfg_error_pkg *)buf); in tb_handle_event()
2913 tb_warn(tb, "unexpected event %#x, ignoring\n", type); in tb_handle_event()
2917 if (tb_cfg_ack_plug(tb->ctl, route, pkg->port, pkg->unplug)) { in tb_handle_event()
2918 tb_warn(tb, "could not ack plug event on %llx:%x\n", route, in tb_handle_event()
2922 tb_queue_hotplug(tb, route, pkg->port, pkg->unplug); in tb_handle_event()
2925 static void tb_stop(struct tb *tb) in tb_stop() argument
2927 struct tb_cm *tcm = tb_priv(tb); in tb_stop()
2943 tb_switch_remove(tb->root_switch); in tb_stop()
2947 static void tb_deinit(struct tb *tb) in tb_deinit() argument
2949 struct tb_cm *tcm = tb_priv(tb); in tb_deinit()
2978 static int tb_start(struct tb *tb, bool reset) in tb_start() argument
2980 struct tb_cm *tcm = tb_priv(tb); in tb_start()
2984 tb->root_switch = tb_switch_alloc(tb, &tb->dev, 0); in tb_start()
2985 if (IS_ERR(tb->root_switch)) in tb_start()
2986 return PTR_ERR(tb->root_switch); in tb_start()
2996 tb->root_switch->no_nvm_upgrade = !tb_switch_is_usb4(tb->root_switch); in tb_start()
2998 tb->root_switch->rpm = tb_switch_is_usb4(tb->root_switch); in tb_start()
3000 ret = tb_switch_configure(tb->root_switch); in tb_start()
3002 tb_switch_put(tb->root_switch); in tb_start()
3007 ret = tb_switch_add(tb->root_switch); in tb_start()
3009 tb_switch_put(tb->root_switch); in tb_start()
3017 tb_switch_tmu_configure(tb->root_switch, TB_SWITCH_TMU_MODE_LOWRES); in tb_start()
3019 tb_switch_tmu_enable(tb->root_switch); in tb_start()
3027 if (reset && tb_switch_is_usb4(tb->root_switch)) { in tb_start()
3029 if (usb4_switch_version(tb->root_switch) == 1) in tb_start()
3030 tb_switch_reset(tb->root_switch); in tb_start()
3035 tb_scan_switch(tb->root_switch); in tb_start()
3037 tb_discover_tunnels(tb); in tb_start()
3039 tb_discover_dp_resources(tb); in tb_start()
3046 tb_create_usb3_tunnels(tb->root_switch); in tb_start()
3048 tb_add_dp_resources(tb->root_switch); in tb_start()
3049 tb_switch_enter_redrive(tb->root_switch); in tb_start()
3051 device_for_each_child(&tb->root_switch->dev, NULL, in tb_start()
3059 static int tb_suspend_noirq(struct tb *tb) in tb_suspend_noirq() argument
3061 struct tb_cm *tcm = tb_priv(tb); in tb_suspend_noirq()
3063 tb_dbg(tb, "suspending...\n"); in tb_suspend_noirq()
3064 tb_disconnect_and_release_dp(tb); in tb_suspend_noirq()
3065 tb_switch_exit_redrive(tb->root_switch); in tb_suspend_noirq()
3066 tb_switch_suspend(tb->root_switch, false); in tb_suspend_noirq()
3068 tb_dbg(tb, "suspend finished\n"); in tb_suspend_noirq()
3105 static int tb_resume_noirq(struct tb *tb) in tb_resume_noirq() argument
3107 struct tb_cm *tcm = tb_priv(tb); in tb_resume_noirq()
3112 tb_dbg(tb, "resuming...\n"); in tb_resume_noirq()
3118 if (!tb_switch_is_usb4(tb->root_switch)) in tb_resume_noirq()
3119 tb_switch_reset(tb->root_switch); in tb_resume_noirq()
3121 tb_switch_resume(tb->root_switch, false); in tb_resume_noirq()
3122 tb_free_invalid_tunnels(tb); in tb_resume_noirq()
3123 tb_free_unplugged_children(tb->root_switch); in tb_resume_noirq()
3124 tb_restore_children(tb->root_switch); in tb_resume_noirq()
3132 tb_switch_discover_tunnels(tb->root_switch, &tunnels, false); in tb_resume_noirq()
3155 tb_dbg(tb, "tunnels restarted, sleeping for 100ms\n"); in tb_resume_noirq()
3158 tb_switch_enter_redrive(tb->root_switch); in tb_resume_noirq()
3161 tb_dbg(tb, "resume finished\n"); in tb_resume_noirq()
3188 static int tb_freeze_noirq(struct tb *tb) in tb_freeze_noirq() argument
3190 struct tb_cm *tcm = tb_priv(tb); in tb_freeze_noirq()
3196 static int tb_thaw_noirq(struct tb *tb) in tb_thaw_noirq() argument
3198 struct tb_cm *tcm = tb_priv(tb); in tb_thaw_noirq()
3204 static void tb_complete(struct tb *tb) in tb_complete() argument
3211 mutex_lock(&tb->lock); in tb_complete()
3212 if (tb_free_unplugged_xdomains(tb->root_switch)) in tb_complete()
3213 tb_scan_switch(tb->root_switch); in tb_complete()
3214 mutex_unlock(&tb->lock); in tb_complete()
3217 static int tb_runtime_suspend(struct tb *tb) in tb_runtime_suspend() argument
3219 struct tb_cm *tcm = tb_priv(tb); in tb_runtime_suspend()
3221 mutex_lock(&tb->lock); in tb_runtime_suspend()
3226 tb_disconnect_and_release_dp(tb); in tb_runtime_suspend()
3227 tb_switch_exit_redrive(tb->root_switch); in tb_runtime_suspend()
3228 tb_switch_suspend(tb->root_switch, true); in tb_runtime_suspend()
3230 mutex_unlock(&tb->lock); in tb_runtime_suspend()
3238 struct tb *tb = tcm_to_tb(tcm); in tb_remove_work() local
3240 mutex_lock(&tb->lock); in tb_remove_work()
3241 if (tb->root_switch) { in tb_remove_work()
3242 tb_free_unplugged_children(tb->root_switch); in tb_remove_work()
3243 tb_free_unplugged_xdomains(tb->root_switch); in tb_remove_work()
3245 mutex_unlock(&tb->lock); in tb_remove_work()
3248 static int tb_runtime_resume(struct tb *tb) in tb_runtime_resume() argument
3250 struct tb_cm *tcm = tb_priv(tb); in tb_runtime_resume()
3253 mutex_lock(&tb->lock); in tb_runtime_resume()
3254 tb_switch_resume(tb->root_switch, true); in tb_runtime_resume()
3255 tb_free_invalid_tunnels(tb); in tb_runtime_resume()
3256 tb_restore_children(tb->root_switch); in tb_runtime_resume()
3259 tb_switch_enter_redrive(tb->root_switch); in tb_runtime_resume()
3261 mutex_unlock(&tb->lock); in tb_runtime_resume()
3268 queue_delayed_work(tb->wq, &tcm->remove_work, msecs_to_jiffies(50)); in tb_runtime_resume()
3358 struct tb *tb_probe(struct tb_nhi *nhi) in tb_probe()
3361 struct tb *tb; in tb_probe() local
3363 tb = tb_domain_alloc(nhi, TB_TIMEOUT, sizeof(*tcm)); in tb_probe()
3364 if (!tb) in tb_probe()
3368 tb->security_level = TB_SECURITY_USER; in tb_probe()
3370 tb->security_level = TB_SECURITY_NOPCIE; in tb_probe()
3372 tb->cm_ops = &tb_cm_ops; in tb_probe()
3374 tcm = tb_priv(tb); in tb_probe()
3380 tb_dbg(tb, "using software connection manager\n"); in tb_probe()
3388 tb_warn(tb, "device links to tunneled native ports are missing!\n"); in tb_probe()
3390 return tb; in tb_probe()