Lines Matching refs:sw

111 		if (tunnel->src_port->sw == in->sw &&  in tb_attach_bandwidth_group()
112 tunnel->dst_port->sw == out->sw) { in tb_attach_bandwidth_group()
181 static void tb_add_dp_resources(struct tb_switch *sw) in tb_add_dp_resources() argument
183 struct tb_cm *tcm = tb_priv(sw->tb); in tb_add_dp_resources()
186 tb_switch_for_each_port(sw, port) { in tb_add_dp_resources()
190 if (!tb_switch_query_dp_resource(sw, port)) in tb_add_dp_resources()
198 static void tb_remove_dp_resources(struct tb_switch *sw) in tb_remove_dp_resources() argument
200 struct tb_cm *tcm = tb_priv(sw->tb); in tb_remove_dp_resources()
204 tb_switch_for_each_port(sw, port) { in tb_remove_dp_resources()
206 tb_remove_dp_resources(port->remote->sw); in tb_remove_dp_resources()
210 if (port->sw == sw) { in tb_remove_dp_resources()
243 static void tb_switch_discover_tunnels(struct tb_switch *sw, in tb_switch_discover_tunnels() argument
247 struct tb *tb = sw->tb; in tb_switch_discover_tunnels()
250 tb_switch_for_each_port(sw, port) { in tb_switch_discover_tunnels()
281 tb_switch_for_each_port(sw, port) { in tb_switch_discover_tunnels()
283 tb_switch_discover_tunnels(port->remote->sw, list, in tb_switch_discover_tunnels()
298 struct tb_switch *parent = tunnel->dst_port->sw; in tb_discover_tunnels()
300 while (parent != tunnel->src_port->sw) { in tb_discover_tunnels()
309 pm_runtime_get_sync(&in->sw->dev); in tb_discover_tunnels()
310 pm_runtime_get_sync(&out->sw->dev); in tb_discover_tunnels()
319 if (tb_switch_is_usb4(port->sw)) in tb_port_configure_xdomain()
326 if (tb_switch_is_usb4(port->sw)) in tb_port_unconfigure_xdomain()
336 struct tb_switch *sw = port->sw; in tb_scan_xdomain() local
337 struct tb *tb = sw->tb; in tb_scan_xdomain()
351 xd = tb_xdomain_alloc(tb, &sw->dev, route, tb->root_switch->uuid, in tb_scan_xdomain()
354 tb_port_at(route, sw)->xdomain = xd; in tb_scan_xdomain()
360 static int tb_enable_tmu(struct tb_switch *sw) in tb_enable_tmu() argument
365 if (tb_switch_tmu_is_enabled(sw, sw->tmu.unidirectional_request)) in tb_enable_tmu()
368 ret = tb_switch_tmu_disable(sw); in tb_enable_tmu()
372 ret = tb_switch_tmu_post_time(sw); in tb_enable_tmu()
376 return tb_switch_tmu_enable(sw); in tb_enable_tmu()
384 static struct tb_port *tb_find_unused_port(struct tb_switch *sw, in tb_find_unused_port() argument
389 tb_switch_for_each_port(sw, port) { in tb_find_unused_port()
403 static struct tb_port *tb_find_usb3_down(struct tb_switch *sw, in tb_find_usb3_down() argument
408 down = usb4_switch_map_usb3_down(sw, port); in tb_find_usb3_down()
437 struct tb_switch *sw; in tb_find_first_usb3_tunnel() local
440 if (dst_port->sw->config.depth > src_port->sw->config.depth) in tb_find_first_usb3_tunnel()
441 sw = dst_port->sw; in tb_find_first_usb3_tunnel()
443 sw = src_port->sw; in tb_find_first_usb3_tunnel()
446 if (sw == tb->root_switch) in tb_find_first_usb3_tunnel()
450 port = tb_port_at(tb_route(sw), tb->root_switch); in tb_find_first_usb3_tunnel()
468 tb_route(src_port->sw), src_port->port, tb_route(dst_port->sw), in tb_available_bandwidth()
493 link_speed = port->sw->link_speed; in tb_available_bandwidth()
607 static int tb_tunnel_usb3(struct tb *tb, struct tb_switch *sw) in tb_tunnel_usb3() argument
609 struct tb_switch *parent = tb_switch_parent(sw); in tb_tunnel_usb3()
620 up = tb_switch_find_port(sw, TB_TYPE_USB3_UP); in tb_tunnel_usb3()
624 if (!sw->link_usb4) in tb_tunnel_usb3()
631 port = tb_port_at(tb_route(sw), parent); in tb_tunnel_usb3()
690 static int tb_create_usb3_tunnels(struct tb_switch *sw) in tb_create_usb3_tunnels() argument
698 if (tb_route(sw)) { in tb_create_usb3_tunnels()
699 ret = tb_tunnel_usb3(sw->tb, sw); in tb_create_usb3_tunnels()
704 tb_switch_for_each_port(sw, port) { in tb_create_usb3_tunnels()
707 ret = tb_create_usb3_tunnels(port->remote->sw); in tb_create_usb3_tunnels()
720 static void tb_scan_switch(struct tb_switch *sw) in tb_scan_switch() argument
724 pm_runtime_get_sync(&sw->dev); in tb_scan_switch()
726 tb_switch_for_each_port(sw, port) in tb_scan_switch()
729 pm_runtime_mark_last_busy(&sw->dev); in tb_scan_switch()
730 pm_runtime_put_autosuspend(&sw->dev); in tb_scan_switch()
738 struct tb_cm *tcm = tb_priv(port->sw->tb); in tb_scan_port()
740 struct tb_switch *sw; in tb_scan_port() local
749 tb_queue_hotplug(port->sw->tb, tb_route(port->sw), port->port, in tb_scan_port()
774 sw = tb_switch_alloc(port->sw->tb, &port->sw->dev, in tb_scan_port()
776 if (IS_ERR(sw)) { in tb_scan_port()
782 if (PTR_ERR(sw) == -EIO || PTR_ERR(sw) == -EADDRNOTAVAIL) in tb_scan_port()
787 if (tb_switch_configure(sw)) { in tb_scan_port()
788 tb_switch_put(sw); in tb_scan_port()
808 dev_set_uevent_suppress(&sw->dev, true); in tb_scan_port()
814 sw->rpm = sw->generation > 1; in tb_scan_port()
816 if (tb_switch_add(sw)) { in tb_scan_port()
817 tb_switch_put(sw); in tb_scan_port()
822 upstream_port = tb_upstream_port(sw); in tb_scan_port()
831 tb_switch_lane_bonding_enable(sw); in tb_scan_port()
833 tb_switch_configure_link(sw); in tb_scan_port()
838 ret = tb_switch_enable_clx(sw, TB_CL1); in tb_scan_port()
840 tb_sw_warn(sw, "failed to enable %s on upstream port\n", in tb_scan_port()
843 if (tb_switch_is_clx_enabled(sw, TB_CL1)) in tb_scan_port()
848 tb_switch_tmu_configure(sw, TB_SWITCH_TMU_RATE_NORMAL, true); in tb_scan_port()
851 tb_switch_tmu_configure(sw, TB_SWITCH_TMU_RATE_HIFI, false); in tb_scan_port()
853 if (tb_enable_tmu(sw)) in tb_scan_port()
854 tb_sw_warn(sw, "failed to enable TMU\n"); in tb_scan_port()
865 if (tcm->hotplug_active && tb_tunnel_usb3(sw->tb, sw)) in tb_scan_port()
866 tb_sw_warn(sw, "USB3 tunnel creation failed\n"); in tb_scan_port()
868 tb_add_dp_resources(sw); in tb_scan_port()
869 tb_scan_switch(sw); in tb_scan_port()
900 tb_switch_dealloc_dp_resource(src_port->sw, src_port); in tb_deactivate_and_free_tunnel()
902 pm_runtime_mark_last_busy(&dst_port->sw->dev); in tb_deactivate_and_free_tunnel()
903 pm_runtime_put_autosuspend(&dst_port->sw->dev); in tb_deactivate_and_free_tunnel()
904 pm_runtime_mark_last_busy(&src_port->sw->dev); in tb_deactivate_and_free_tunnel()
905 pm_runtime_put_autosuspend(&src_port->sw->dev); in tb_deactivate_and_free_tunnel()
941 static void tb_free_unplugged_children(struct tb_switch *sw) in tb_free_unplugged_children() argument
945 tb_switch_for_each_port(sw, port) { in tb_free_unplugged_children()
949 if (port->remote->sw->is_unplugged) { in tb_free_unplugged_children()
951 tb_remove_dp_resources(port->remote->sw); in tb_free_unplugged_children()
952 tb_switch_unconfigure_link(port->remote->sw); in tb_free_unplugged_children()
953 tb_switch_lane_bonding_disable(port->remote->sw); in tb_free_unplugged_children()
954 tb_switch_remove(port->remote->sw); in tb_free_unplugged_children()
959 tb_free_unplugged_children(port->remote->sw); in tb_free_unplugged_children()
964 static struct tb_port *tb_find_pcie_down(struct tb_switch *sw, in tb_find_pcie_down() argument
973 if (tb_switch_is_usb4(sw)) { in tb_find_pcie_down()
974 down = usb4_switch_map_pcie_down(sw, port); in tb_find_pcie_down()
975 } else if (!tb_route(sw)) { in tb_find_pcie_down()
983 if (tb_switch_is_cactus_ridge(sw) || in tb_find_pcie_down()
984 tb_switch_is_alpine_ridge(sw)) in tb_find_pcie_down()
986 else if (tb_switch_is_falcon_ridge(sw)) in tb_find_pcie_down()
988 else if (tb_switch_is_titan_ridge(sw)) in tb_find_pcie_down()
994 if (WARN_ON(index > sw->config.max_port_number)) in tb_find_pcie_down()
997 down = &sw->ports[index]; in tb_find_pcie_down()
1010 return tb_find_unused_port(sw, TB_TYPE_PCIE_DOWN); in tb_find_pcie_down()
1073 if (in->sw->config.depth < out->sw->config.depth) in tb_recalc_estimated_bandwidth_for_group()
1111 host_port = tb_route(in->sw) ? in tb_find_dp_out()
1112 tb_port_at(tb_route(in->sw), tb->root_switch) : NULL; in tb_find_dp_out()
1129 if (host_port && tb_route(port->sw)) { in tb_find_dp_out()
1132 p = tb_port_at(tb_route(port->sw), tb->root_switch); in tb_find_dp_out()
1212 pm_runtime_get_sync(&in->sw->dev); in tb_tunnel_dp()
1213 pm_runtime_get_sync(&out->sw->dev); in tb_tunnel_dp()
1215 if (tb_switch_alloc_dp_resource(in->sw, in)) { in tb_tunnel_dp()
1270 tb_switch_dealloc_dp_resource(in->sw, in); in tb_tunnel_dp()
1272 pm_runtime_mark_last_busy(&out->sw->dev); in tb_tunnel_dp()
1273 pm_runtime_put_autosuspend(&out->sw->dev); in tb_tunnel_dp()
1274 pm_runtime_mark_last_busy(&in->sw->dev); in tb_tunnel_dp()
1275 pm_runtime_put_autosuspend(&in->sw->dev); in tb_tunnel_dp()
1349 static int tb_disconnect_pci(struct tb *tb, struct tb_switch *sw) in tb_disconnect_pci() argument
1354 up = tb_switch_find_port(sw, TB_TYPE_PCIE_UP); in tb_disconnect_pci()
1362 tb_switch_xhci_disconnect(sw); in tb_disconnect_pci()
1370 static int tb_tunnel_pci(struct tb *tb, struct tb_switch *sw) in tb_tunnel_pci() argument
1377 up = tb_switch_find_port(sw, TB_TYPE_PCIE_UP); in tb_tunnel_pci()
1385 parent_sw = tb_to_switch(sw->dev.parent); in tb_tunnel_pci()
1386 port = tb_port_at(tb_route(sw), parent_sw); in tb_tunnel_pci()
1406 if (tb_switch_pcie_l1_enable(sw)) in tb_tunnel_pci()
1407 tb_sw_warn(sw, "failed to enable PCIe L1 for Titan Ridge\n"); in tb_tunnel_pci()
1409 if (tb_switch_xhci_connect(sw)) in tb_tunnel_pci()
1410 tb_sw_warn(sw, "failed to connect xHCI\n"); in tb_tunnel_pci()
1423 struct tb_switch *sw; in tb_approve_xdomain_paths() local
1425 sw = tb_to_switch(xd->dev.parent); in tb_approve_xdomain_paths()
1426 dst_port = tb_port_at(xd->route, sw); in tb_approve_xdomain_paths()
1457 struct tb_switch *sw; in __tb_disconnect_xdomain_paths() local
1459 sw = tb_to_switch(xd->dev.parent); in __tb_disconnect_xdomain_paths()
1460 dst_port = tb_port_at(xd->route, sw); in __tb_disconnect_xdomain_paths()
1501 struct tb_switch *sw; in tb_handle_hotplug() local
1511 sw = tb_switch_find_by_route(tb, ev->route); in tb_handle_hotplug()
1512 if (!sw) { in tb_handle_hotplug()
1518 if (ev->port > sw->config.max_port_number) { in tb_handle_hotplug()
1524 port = &sw->ports[ev->port]; in tb_handle_hotplug()
1531 pm_runtime_get_sync(&sw->dev); in tb_handle_hotplug()
1538 tb_sw_set_unplugged(port->remote->sw); in tb_handle_hotplug()
1540 tb_remove_dp_resources(port->remote->sw); in tb_handle_hotplug()
1541 tb_switch_tmu_disable(port->remote->sw); in tb_handle_hotplug()
1542 tb_switch_unconfigure_link(port->remote->sw); in tb_handle_hotplug()
1543 tb_switch_lane_bonding_disable(port->remote->sw); in tb_handle_hotplug()
1544 tb_switch_remove(port->remote->sw); in tb_handle_hotplug()
1571 tb_sw_dbg(sw, "xHCI disconnect request\n"); in tb_handle_hotplug()
1572 tb_switch_xhci_disconnect(sw); in tb_handle_hotplug()
1579 } else if (!port->port && sw->authorized) { in tb_handle_hotplug()
1580 tb_sw_dbg(sw, "xHCI connect request\n"); in tb_handle_hotplug()
1581 tb_switch_xhci_connect(sw); in tb_handle_hotplug()
1593 pm_runtime_mark_last_busy(&sw->dev); in tb_handle_hotplug()
1594 pm_runtime_put_autosuspend(&sw->dev); in tb_handle_hotplug()
1597 tb_switch_put(sw); in tb_handle_hotplug()
1731 struct tb_switch *sw; in tb_handle_dp_bandwidth_request() local
1739 sw = tb_switch_find_by_route(tb, ev->route); in tb_handle_dp_bandwidth_request()
1740 if (!sw) { in tb_handle_dp_bandwidth_request()
1746 in = &sw->ports[ev->port]; in tb_handle_dp_bandwidth_request()
1779 if (in->sw->config.depth < out->sw->config.depth) { in tb_handle_dp_bandwidth_request()
1895 struct tb_switch *sw = tb_to_switch(dev); in tb_scan_finalize_switch() local
1902 if (sw->boot) in tb_scan_finalize_switch()
1903 sw->authorized = 1; in tb_scan_finalize_switch()
1990 static void tb_restore_children(struct tb_switch *sw) in tb_restore_children() argument
1996 if (sw->is_unplugged) in tb_restore_children()
2003 ret = tb_switch_enable_clx(sw, TB_CL1); in tb_restore_children()
2005 tb_sw_warn(sw, "failed to re-enable %s on upstream port\n", in tb_restore_children()
2008 if (tb_switch_is_clx_enabled(sw, TB_CL1)) in tb_restore_children()
2013 tb_switch_tmu_configure(sw, TB_SWITCH_TMU_RATE_NORMAL, true); in tb_restore_children()
2016 tb_switch_tmu_configure(sw, TB_SWITCH_TMU_RATE_HIFI, false); in tb_restore_children()
2018 if (tb_enable_tmu(sw)) in tb_restore_children()
2019 tb_sw_warn(sw, "failed to restore TMU configuration\n"); in tb_restore_children()
2021 tb_switch_for_each_port(sw, port) { in tb_restore_children()
2026 tb_switch_lane_bonding_enable(port->remote->sw); in tb_restore_children()
2027 tb_switch_configure_link(port->remote->sw); in tb_restore_children()
2029 tb_restore_children(port->remote->sw); in tb_restore_children()
2092 static int tb_free_unplugged_xdomains(struct tb_switch *sw) in tb_free_unplugged_xdomains() argument
2097 tb_switch_for_each_port(sw, port) { in tb_free_unplugged_xdomains()
2107 ret += tb_free_unplugged_xdomains(port->remote->sw); in tb_free_unplugged_xdomains()