Lines Matching full:sw
45 static struct nvm_auth_status *__nvm_get_auth_status(const struct tb_switch *sw) in __nvm_get_auth_status() argument
50 if (uuid_equal(&st->uuid, sw->uuid)) in __nvm_get_auth_status()
57 static void nvm_get_auth_status(const struct tb_switch *sw, u32 *status) in nvm_get_auth_status() argument
62 st = __nvm_get_auth_status(sw); in nvm_get_auth_status()
68 static void nvm_set_auth_status(const struct tb_switch *sw, u32 status) in nvm_set_auth_status() argument
72 if (WARN_ON(!sw->uuid)) in nvm_set_auth_status()
76 st = __nvm_get_auth_status(sw); in nvm_set_auth_status()
83 memcpy(&st->uuid, sw->uuid, sizeof(st->uuid)); in nvm_set_auth_status()
93 static void nvm_clear_auth_status(const struct tb_switch *sw) in nvm_clear_auth_status() argument
98 st = __nvm_get_auth_status(sw); in nvm_clear_auth_status()
106 static int nvm_validate_and_write(struct tb_switch *sw) in nvm_validate_and_write() argument
109 const u8 *buf = sw->nvm->buf; in nvm_validate_and_write()
116 image_size = sw->nvm->buf_data_size; in nvm_validate_and_write()
140 if (!sw->safe_mode) { in nvm_validate_and_write()
148 if (device_id != sw->config.device_id) in nvm_validate_and_write()
151 if (sw->generation < 3) { in nvm_validate_and_write()
153 ret = dma_port_flash_write(sw->dma_port, in nvm_validate_and_write()
165 return dma_port_flash_write(sw->dma_port, 0, buf, image_size); in nvm_validate_and_write()
168 static int nvm_authenticate_host(struct tb_switch *sw) in nvm_authenticate_host() argument
177 if (!sw->safe_mode) { in nvm_authenticate_host()
180 ret = tb_domain_disconnect_all_paths(sw->tb); in nvm_authenticate_host()
187 ret = dma_port_flash_update_auth(sw->dma_port); in nvm_authenticate_host()
195 tb_sw_warn(sw, "failed to authenticate NVM, power cycling\n"); in nvm_authenticate_host()
196 if (dma_port_flash_update_auth_status(sw->dma_port, &status) > 0) in nvm_authenticate_host()
197 nvm_set_auth_status(sw, status); in nvm_authenticate_host()
204 dma_port_power_cycle(sw->dma_port); in nvm_authenticate_host()
208 static int nvm_authenticate_device(struct tb_switch *sw) in nvm_authenticate_device() argument
212 ret = dma_port_flash_update_auth(sw->dma_port); in nvm_authenticate_device()
233 ret = dma_port_flash_update_auth_status(sw->dma_port, &status); in nvm_authenticate_device()
238 tb_sw_warn(sw, "failed to authenticate NVM\n"); in nvm_authenticate_device()
239 nvm_set_auth_status(sw, status); in nvm_authenticate_device()
242 tb_sw_info(sw, "power cycling the switch now\n"); in nvm_authenticate_device()
243 dma_port_power_cycle(sw->dma_port); in nvm_authenticate_device()
256 struct tb_switch *sw = priv; in tb_switch_nvm_read() local
259 pm_runtime_get_sync(&sw->dev); in tb_switch_nvm_read()
260 ret = dma_port_flash_read(sw->dma_port, offset, val, bytes); in tb_switch_nvm_read()
261 pm_runtime_mark_last_busy(&sw->dev); in tb_switch_nvm_read()
262 pm_runtime_put_autosuspend(&sw->dev); in tb_switch_nvm_read()
276 struct tb_switch *sw = priv; in tb_switch_nvm_write() local
279 if (!mutex_trylock(&sw->tb->lock)) in tb_switch_nvm_write()
288 if (!sw->nvm->buf) { in tb_switch_nvm_write()
289 sw->nvm->buf = vmalloc(NVM_MAX_SIZE); in tb_switch_nvm_write()
290 if (!sw->nvm->buf) { in tb_switch_nvm_write()
296 sw->nvm->buf_data_size = offset + bytes; in tb_switch_nvm_write()
297 memcpy(sw->nvm->buf + offset, val, bytes); in tb_switch_nvm_write()
300 mutex_unlock(&sw->tb->lock); in tb_switch_nvm_write()
305 static struct nvmem_device *register_nvmem(struct tb_switch *sw, int id, in register_nvmem() argument
327 config.dev = &sw->dev; in register_nvmem()
329 config.priv = sw; in register_nvmem()
334 static int tb_switch_nvm_add(struct tb_switch *sw) in tb_switch_nvm_add() argument
341 if (!sw->dma_port) in tb_switch_nvm_add()
355 if (!sw->safe_mode) { in tb_switch_nvm_add()
358 ret = dma_port_flash_read(sw->dma_port, NVM_FLASH_SIZE, &val, in tb_switch_nvm_add()
363 hdr_size = sw->generation < 3 ? SZ_8K : SZ_16K; in tb_switch_nvm_add()
367 ret = dma_port_flash_read(sw->dma_port, NVM_VERSION, &val, in tb_switch_nvm_add()
375 nvm_dev = register_nvmem(sw, nvm->id, nvm_size, true); in tb_switch_nvm_add()
383 nvm_dev = register_nvmem(sw, nvm->id, NVM_MAX_SIZE, false); in tb_switch_nvm_add()
390 sw->nvm = nvm; in tb_switch_nvm_add()
403 static void tb_switch_nvm_remove(struct tb_switch *sw) in tb_switch_nvm_remove() argument
407 nvm = sw->nvm; in tb_switch_nvm_remove()
408 sw->nvm = NULL; in tb_switch_nvm_remove()
415 nvm_clear_auth_status(sw); in tb_switch_nvm_remove()
616 tb_dump_port(port->sw->tb, &port->config); in tb_init_port()
625 static void tb_dump_switch(struct tb *tb, struct tb_regs_switch_header *sw) in tb_dump_switch() argument
629 sw->vendor_id, sw->device_id, sw->revision, in tb_dump_switch()
630 sw->thunderbolt_version); in tb_dump_switch()
631 tb_info(tb, " Max Port Number: %d\n", sw->max_port_number); in tb_dump_switch()
635 sw->upstream_port_number, sw->depth, in tb_dump_switch()
636 (((u64) sw->route_hi) << 32) | sw->route_lo, in tb_dump_switch()
637 sw->enabled, sw->plug_events_delay); in tb_dump_switch()
640 sw->__unknown1, sw->__unknown4); in tb_dump_switch()
674 static int tb_plug_events_active(struct tb_switch *sw, bool active) in tb_plug_events_active() argument
679 if (!sw->config.enabled) in tb_plug_events_active()
682 sw->config.plug_events_delay = 0xff; in tb_plug_events_active()
683 res = tb_sw_write(sw, ((u32 *) &sw->config) + 4, TB_CFG_SWITCH, 4, 1); in tb_plug_events_active()
687 res = tb_sw_read(sw, &data, TB_CFG_SWITCH, sw->cap_plug_events + 1, 1); in tb_plug_events_active()
693 switch (sw->config.device_id) { in tb_plug_events_active()
704 return tb_sw_write(sw, &data, TB_CFG_SWITCH, in tb_plug_events_active()
705 sw->cap_plug_events + 1, 1); in tb_plug_events_active()
712 struct tb_switch *sw = tb_to_switch(dev); in authorized_show() local
714 return sprintf(buf, "%u\n", sw->authorized); in authorized_show()
717 static int tb_switch_set_authorized(struct tb_switch *sw, unsigned int val) in tb_switch_set_authorized() argument
721 if (!mutex_trylock(&sw->tb->lock)) in tb_switch_set_authorized()
724 if (sw->authorized) in tb_switch_set_authorized()
733 pm_runtime_get_sync(&sw->dev); in tb_switch_set_authorized()
738 if (sw->key) in tb_switch_set_authorized()
739 ret = tb_domain_approve_switch_key(sw->tb, sw); in tb_switch_set_authorized()
741 ret = tb_domain_approve_switch(sw->tb, sw); in tb_switch_set_authorized()
746 if (sw->key) in tb_switch_set_authorized()
747 ret = tb_domain_challenge_switch_key(sw->tb, sw); in tb_switch_set_authorized()
754 pm_runtime_mark_last_busy(&sw->dev); in tb_switch_set_authorized()
755 pm_runtime_put_autosuspend(&sw->dev); in tb_switch_set_authorized()
759 sw->authorized = val; in tb_switch_set_authorized()
761 kobject_uevent(&sw->dev.kobj, KOBJ_CHANGE); in tb_switch_set_authorized()
765 mutex_unlock(&sw->tb->lock); in tb_switch_set_authorized()
773 struct tb_switch *sw = tb_to_switch(dev); in authorized_store() local
783 ret = tb_switch_set_authorized(sw, val); in authorized_store()
792 struct tb_switch *sw = tb_to_switch(dev); in boot_show() local
794 return sprintf(buf, "%u\n", sw->boot); in boot_show()
801 struct tb_switch *sw = tb_to_switch(dev); in device_show() local
803 return sprintf(buf, "%#x\n", sw->device); in device_show()
810 struct tb_switch *sw = tb_to_switch(dev); in device_name_show() local
812 return sprintf(buf, "%s\n", sw->device_name ? sw->device_name : ""); in device_name_show()
819 struct tb_switch *sw = tb_to_switch(dev); in key_show() local
822 if (!mutex_trylock(&sw->tb->lock)) in key_show()
825 if (sw->key) in key_show()
826 ret = sprintf(buf, "%*phN\n", TB_SWITCH_KEY_SIZE, sw->key); in key_show()
830 mutex_unlock(&sw->tb->lock); in key_show()
837 struct tb_switch *sw = tb_to_switch(dev); in key_store() local
847 if (!mutex_trylock(&sw->tb->lock)) in key_store()
850 if (sw->authorized) { in key_store()
853 kfree(sw->key); in key_store()
855 sw->key = NULL; in key_store()
857 sw->key = kmemdup(key, sizeof(key), GFP_KERNEL); in key_store()
858 if (!sw->key) in key_store()
863 mutex_unlock(&sw->tb->lock); in key_store()
868 static void nvm_authenticate_start(struct tb_switch *sw) in nvm_authenticate_start() argument
878 root_port = pci_find_pcie_root_port(sw->tb->nhi->pdev); in nvm_authenticate_start()
883 static void nvm_authenticate_complete(struct tb_switch *sw) in nvm_authenticate_complete() argument
887 root_port = pci_find_pcie_root_port(sw->tb->nhi->pdev); in nvm_authenticate_complete()
895 struct tb_switch *sw = tb_to_switch(dev); in nvm_authenticate_show() local
898 nvm_get_auth_status(sw, &status); in nvm_authenticate_show()
905 struct tb_switch *sw = tb_to_switch(dev); in nvm_authenticate_store() local
909 if (!mutex_trylock(&sw->tb->lock)) in nvm_authenticate_store()
913 if (!sw->nvm) { in nvm_authenticate_store()
923 nvm_clear_auth_status(sw); in nvm_authenticate_store()
926 if (!sw->nvm->buf) { in nvm_authenticate_store()
931 pm_runtime_get_sync(&sw->dev); in nvm_authenticate_store()
932 ret = nvm_validate_and_write(sw); in nvm_authenticate_store()
934 pm_runtime_mark_last_busy(&sw->dev); in nvm_authenticate_store()
935 pm_runtime_put_autosuspend(&sw->dev); in nvm_authenticate_store()
939 sw->nvm->authenticating = true; in nvm_authenticate_store()
941 if (!tb_route(sw)) { in nvm_authenticate_store()
946 nvm_authenticate_start(sw); in nvm_authenticate_store()
947 ret = nvm_authenticate_host(sw); in nvm_authenticate_store()
949 ret = nvm_authenticate_device(sw); in nvm_authenticate_store()
951 pm_runtime_mark_last_busy(&sw->dev); in nvm_authenticate_store()
952 pm_runtime_put_autosuspend(&sw->dev); in nvm_authenticate_store()
956 mutex_unlock(&sw->tb->lock); in nvm_authenticate_store()
967 struct tb_switch *sw = tb_to_switch(dev); in nvm_version_show() local
970 if (!mutex_trylock(&sw->tb->lock)) in nvm_version_show()
973 if (sw->safe_mode) in nvm_version_show()
975 else if (!sw->nvm) in nvm_version_show()
978 ret = sprintf(buf, "%x.%x\n", sw->nvm->major, sw->nvm->minor); in nvm_version_show()
980 mutex_unlock(&sw->tb->lock); in nvm_version_show()
989 struct tb_switch *sw = tb_to_switch(dev); in vendor_show() local
991 return sprintf(buf, "%#x\n", sw->vendor); in vendor_show()
998 struct tb_switch *sw = tb_to_switch(dev); in vendor_name_show() local
1000 return sprintf(buf, "%s\n", sw->vendor_name ? sw->vendor_name : ""); in vendor_name_show()
1007 struct tb_switch *sw = tb_to_switch(dev); in unique_id_show() local
1009 return sprintf(buf, "%pUb\n", sw->uuid); in unique_id_show()
1031 struct tb_switch *sw = tb_to_switch(dev); in switch_attr_is_visible() local
1034 if (tb_route(sw) && in switch_attr_is_visible()
1035 sw->tb->security_level == TB_SECURITY_SECURE && in switch_attr_is_visible()
1036 sw->security_level == TB_SECURITY_SECURE) in switch_attr_is_visible()
1041 if (sw->dma_port) in switch_attr_is_visible()
1045 if (tb_route(sw)) in switch_attr_is_visible()
1050 return sw->safe_mode ? 0 : attr->mode; in switch_attr_is_visible()
1065 struct tb_switch *sw = tb_to_switch(dev); in tb_switch_release() local
1067 dma_port_free(sw->dma_port); in tb_switch_release()
1069 kfree(sw->uuid); in tb_switch_release()
1070 kfree(sw->device_name); in tb_switch_release()
1071 kfree(sw->vendor_name); in tb_switch_release()
1072 kfree(sw->ports); in tb_switch_release()
1073 kfree(sw->drom); in tb_switch_release()
1074 kfree(sw->key); in tb_switch_release()
1075 kfree(sw); in tb_switch_release()
1103 static int tb_switch_get_generation(struct tb_switch *sw) in tb_switch_get_generation() argument
1105 switch (sw->config.device_id) { in tb_switch_get_generation()
1136 tb_sw_warn(sw, "unsupported switch device id %#x\n", in tb_switch_get_generation()
1137 sw->config.device_id); in tb_switch_get_generation()
1160 struct tb_switch *sw; in tb_switch_alloc() local
1165 sw = kzalloc(sizeof(*sw), GFP_KERNEL); in tb_switch_alloc()
1166 if (!sw) in tb_switch_alloc()
1169 sw->tb = tb; in tb_switch_alloc()
1170 if (tb_cfg_read(tb->ctl, &sw->config, route, 0, TB_CFG_SWITCH, 0, 5)) in tb_switch_alloc()
1174 tb_dump_switch(tb, &sw->config); in tb_switch_alloc()
1177 sw->config.upstream_port_number = upstream_port; in tb_switch_alloc()
1178 sw->config.depth = tb_route_length(route); in tb_switch_alloc()
1179 sw->config.route_lo = route; in tb_switch_alloc()
1180 sw->config.route_hi = route >> 32; in tb_switch_alloc()
1181 sw->config.enabled = 0; in tb_switch_alloc()
1184 sw->ports = kcalloc(sw->config.max_port_number + 1, sizeof(*sw->ports), in tb_switch_alloc()
1186 if (!sw->ports) in tb_switch_alloc()
1189 for (i = 0; i <= sw->config.max_port_number; i++) { in tb_switch_alloc()
1191 sw->ports[i].sw = sw; in tb_switch_alloc()
1192 sw->ports[i].port = i; in tb_switch_alloc()
1195 sw->generation = tb_switch_get_generation(sw); in tb_switch_alloc()
1197 cap = tb_switch_find_vse_cap(sw, TB_VSE_CAP_PLUG_EVENTS); in tb_switch_alloc()
1199 tb_sw_warn(sw, "cannot find TB_VSE_CAP_PLUG_EVENTS aborting\n"); in tb_switch_alloc()
1202 sw->cap_plug_events = cap; in tb_switch_alloc()
1206 sw->authorized = true; in tb_switch_alloc()
1208 device_initialize(&sw->dev); in tb_switch_alloc()
1209 sw->dev.parent = parent; in tb_switch_alloc()
1210 sw->dev.bus = &tb_bus_type; in tb_switch_alloc()
1211 sw->dev.type = &tb_switch_type; in tb_switch_alloc()
1212 sw->dev.groups = switch_groups; in tb_switch_alloc()
1213 dev_set_name(&sw->dev, "%u-%llx", tb->index, tb_route(sw)); in tb_switch_alloc()
1215 return sw; in tb_switch_alloc()
1218 kfree(sw->ports); in tb_switch_alloc()
1219 kfree(sw); in tb_switch_alloc()
1241 struct tb_switch *sw; in tb_switch_alloc_safe_mode() local
1243 sw = kzalloc(sizeof(*sw), GFP_KERNEL); in tb_switch_alloc_safe_mode()
1244 if (!sw) in tb_switch_alloc_safe_mode()
1247 sw->tb = tb; in tb_switch_alloc_safe_mode()
1248 sw->config.depth = tb_route_length(route); in tb_switch_alloc_safe_mode()
1249 sw->config.route_hi = upper_32_bits(route); in tb_switch_alloc_safe_mode()
1250 sw->config.route_lo = lower_32_bits(route); in tb_switch_alloc_safe_mode()
1251 sw->safe_mode = true; in tb_switch_alloc_safe_mode()
1253 device_initialize(&sw->dev); in tb_switch_alloc_safe_mode()
1254 sw->dev.parent = parent; in tb_switch_alloc_safe_mode()
1255 sw->dev.bus = &tb_bus_type; in tb_switch_alloc_safe_mode()
1256 sw->dev.type = &tb_switch_type; in tb_switch_alloc_safe_mode()
1257 sw->dev.groups = switch_groups; in tb_switch_alloc_safe_mode()
1258 dev_set_name(&sw->dev, "%u-%llx", tb->index, tb_route(sw)); in tb_switch_alloc_safe_mode()
1260 return sw; in tb_switch_alloc_safe_mode()
1265 * @sw: Switch to configure
1273 int tb_switch_configure(struct tb_switch *sw) in tb_switch_configure() argument
1275 struct tb *tb = sw->tb; in tb_switch_configure()
1279 route = tb_route(sw); in tb_switch_configure()
1282 route, tb_route_length(route), sw->config.upstream_port_number); in tb_switch_configure()
1284 if (sw->config.vendor_id != PCI_VENDOR_ID_INTEL) in tb_switch_configure()
1285 tb_sw_warn(sw, "unknown switch vendor id %#x\n", in tb_switch_configure()
1286 sw->config.vendor_id); in tb_switch_configure()
1288 sw->config.enabled = 1; in tb_switch_configure()
1291 ret = tb_sw_write(sw, 1 + (u32 *)&sw->config, TB_CFG_SWITCH, 1, 3); in tb_switch_configure()
1295 return tb_plug_events_active(sw, true); in tb_switch_configure()
1298 static int tb_switch_set_uuid(struct tb_switch *sw) in tb_switch_set_uuid() argument
1304 if (sw->uuid) in tb_switch_set_uuid()
1311 cap = tb_switch_find_vse_cap(sw, TB_VSE_CAP_LINK_CONTROLLER); in tb_switch_set_uuid()
1313 ret = tb_sw_read(sw, uuid, TB_CFG_SWITCH, cap + 3, 4); in tb_switch_set_uuid()
1323 uuid[0] = sw->uid & 0xffffffff; in tb_switch_set_uuid()
1324 uuid[1] = (sw->uid >> 32) & 0xffffffff; in tb_switch_set_uuid()
1329 sw->uuid = kmemdup(uuid, sizeof(uuid), GFP_KERNEL); in tb_switch_set_uuid()
1330 if (!sw->uuid) in tb_switch_set_uuid()
1335 static int tb_switch_add_dma_port(struct tb_switch *sw) in tb_switch_add_dma_port() argument
1340 switch (sw->generation) { in tb_switch_add_dma_port()
1343 if (tb_route(sw)) in tb_switch_add_dma_port()
1348 ret = tb_switch_set_uuid(sw); in tb_switch_add_dma_port()
1358 if (!sw->safe_mode) in tb_switch_add_dma_port()
1363 if (sw->no_nvm_upgrade) in tb_switch_add_dma_port()
1366 sw->dma_port = dma_port_alloc(sw); in tb_switch_add_dma_port()
1367 if (!sw->dma_port) in tb_switch_add_dma_port()
1376 nvm_get_auth_status(sw, &status); in tb_switch_add_dma_port()
1378 if (!tb_route(sw)) in tb_switch_add_dma_port()
1379 nvm_authenticate_complete(sw); in tb_switch_add_dma_port()
1388 ret = dma_port_flash_update_auth_status(sw->dma_port, &status); in tb_switch_add_dma_port()
1393 if (!tb_route(sw)) in tb_switch_add_dma_port()
1394 nvm_authenticate_complete(sw); in tb_switch_add_dma_port()
1397 tb_sw_info(sw, "switch flash authentication failed\n"); in tb_switch_add_dma_port()
1398 nvm_set_auth_status(sw, status); in tb_switch_add_dma_port()
1401 tb_sw_info(sw, "power cycling the switch now\n"); in tb_switch_add_dma_port()
1402 dma_port_power_cycle(sw->dma_port); in tb_switch_add_dma_port()
1413 * @sw: Switch to add
1423 int tb_switch_add(struct tb_switch *sw) in tb_switch_add() argument
1434 ret = tb_switch_add_dma_port(sw); in tb_switch_add()
1438 if (!sw->safe_mode) { in tb_switch_add()
1440 ret = tb_drom_read(sw); in tb_switch_add()
1442 tb_sw_warn(sw, "tb_eeprom_read_rom failed\n"); in tb_switch_add()
1445 tb_sw_info(sw, "uid: %#llx\n", sw->uid); in tb_switch_add()
1447 ret = tb_switch_set_uuid(sw); in tb_switch_add()
1451 for (i = 0; i <= sw->config.max_port_number; i++) { in tb_switch_add()
1452 if (sw->ports[i].disabled) { in tb_switch_add()
1453 tb_port_info(&sw->ports[i], "disabled by eeprom\n"); in tb_switch_add()
1456 ret = tb_init_port(&sw->ports[i]); in tb_switch_add()
1462 ret = device_add(&sw->dev); in tb_switch_add()
1466 ret = tb_switch_nvm_add(sw); in tb_switch_add()
1468 device_del(&sw->dev); in tb_switch_add()
1472 pm_runtime_set_active(&sw->dev); in tb_switch_add()
1473 if (sw->rpm) { in tb_switch_add()
1474 pm_runtime_set_autosuspend_delay(&sw->dev, TB_AUTOSUSPEND_DELAY); in tb_switch_add()
1475 pm_runtime_use_autosuspend(&sw->dev); in tb_switch_add()
1476 pm_runtime_mark_last_busy(&sw->dev); in tb_switch_add()
1477 pm_runtime_enable(&sw->dev); in tb_switch_add()
1478 pm_request_autosuspend(&sw->dev); in tb_switch_add()
1486 * @sw: Switch to remove
1492 void tb_switch_remove(struct tb_switch *sw) in tb_switch_remove() argument
1496 if (sw->rpm) { in tb_switch_remove()
1497 pm_runtime_get_sync(&sw->dev); in tb_switch_remove()
1498 pm_runtime_disable(&sw->dev); in tb_switch_remove()
1502 for (i = 1; i <= sw->config.max_port_number; i++) { in tb_switch_remove()
1503 if (tb_is_upstream_port(&sw->ports[i])) in tb_switch_remove()
1505 if (sw->ports[i].remote) in tb_switch_remove()
1506 tb_switch_remove(sw->ports[i].remote->sw); in tb_switch_remove()
1507 sw->ports[i].remote = NULL; in tb_switch_remove()
1508 if (sw->ports[i].xdomain) in tb_switch_remove()
1509 tb_xdomain_remove(sw->ports[i].xdomain); in tb_switch_remove()
1510 sw->ports[i].xdomain = NULL; in tb_switch_remove()
1513 if (!sw->is_unplugged) in tb_switch_remove()
1514 tb_plug_events_active(sw, false); in tb_switch_remove()
1516 tb_switch_nvm_remove(sw); in tb_switch_remove()
1517 device_unregister(&sw->dev); in tb_switch_remove()
1523 void tb_sw_set_unplugged(struct tb_switch *sw) in tb_sw_set_unplugged() argument
1526 if (sw == sw->tb->root_switch) { in tb_sw_set_unplugged()
1527 tb_sw_WARN(sw, "cannot unplug root switch\n"); in tb_sw_set_unplugged()
1530 if (sw->is_unplugged) { in tb_sw_set_unplugged()
1531 tb_sw_WARN(sw, "is_unplugged already set\n"); in tb_sw_set_unplugged()
1534 sw->is_unplugged = true; in tb_sw_set_unplugged()
1535 for (i = 0; i <= sw->config.max_port_number; i++) { in tb_sw_set_unplugged()
1536 if (!tb_is_upstream_port(&sw->ports[i]) && sw->ports[i].remote) in tb_sw_set_unplugged()
1537 tb_sw_set_unplugged(sw->ports[i].remote->sw); in tb_sw_set_unplugged()
1541 int tb_switch_resume(struct tb_switch *sw) in tb_switch_resume() argument
1544 tb_sw_info(sw, "resuming switch\n"); in tb_switch_resume()
1550 if (tb_route(sw)) { in tb_switch_resume()
1553 err = tb_drom_read_uid_only(sw, &uid); in tb_switch_resume()
1555 tb_sw_warn(sw, "uid read failed\n"); in tb_switch_resume()
1558 if (sw->uid != uid) { in tb_switch_resume()
1559 tb_sw_info(sw, in tb_switch_resume()
1561 sw->uid, uid); in tb_switch_resume()
1567 err = tb_sw_write(sw, 1 + (u32 *) &sw->config, TB_CFG_SWITCH, 1, 3); in tb_switch_resume()
1571 err = tb_plug_events_active(sw, true); in tb_switch_resume()
1576 for (i = 1; i <= sw->config.max_port_number; i++) { in tb_switch_resume()
1577 struct tb_port *port = &sw->ports[i]; in tb_switch_resume()
1583 || tb_switch_resume(port->remote->sw)) { in tb_switch_resume()
1586 tb_sw_set_unplugged(port->remote->sw); in tb_switch_resume()
1592 void tb_switch_suspend(struct tb_switch *sw) in tb_switch_suspend() argument
1595 err = tb_plug_events_active(sw, false); in tb_switch_suspend()
1599 for (i = 1; i <= sw->config.max_port_number; i++) { in tb_switch_suspend()
1600 if (!tb_is_upstream_port(&sw->ports[i]) && sw->ports[i].remote) in tb_switch_suspend()
1601 tb_switch_suspend(sw->ports[i].remote->sw); in tb_switch_suspend()
1619 struct tb_switch *sw = tb_to_switch(dev); in tb_switch_match() local
1622 if (!sw) in tb_switch_match()
1624 if (sw->tb != lookup->tb) in tb_switch_match()
1628 return !memcmp(sw->uuid, lookup->uuid, sizeof(*lookup->uuid)); in tb_switch_match()
1631 return sw->config.route_lo == lower_32_bits(lookup->route) && in tb_switch_match()
1632 sw->config.route_hi == upper_32_bits(lookup->route); in tb_switch_match()
1637 return !sw->depth; in tb_switch_match()
1639 return sw->link == lookup->link && sw->depth == lookup->depth; in tb_switch_match()