Lines Matching refs:xd
126 int tb_xdomain_response(struct tb_xdomain *xd, const void *response, in tb_xdomain_response() argument
129 return __tb_xdomain_response(xd->tb->ctl, response, size, type); in tb_xdomain_response()
178 int tb_xdomain_request(struct tb_xdomain *xd, const void *request, in tb_xdomain_request() argument
183 return __tb_xdomain_request(xd->tb->ctl, request, request_size, in tb_xdomain_request()
499 struct tb_xdomain *xd; in tb_xdp_handle_request() local
508 xd = tb_xdomain_find_by_uuid_locked(tb, &xchg->src_uuid); in tb_xdp_handle_request()
509 if (xd) { in tb_xdp_handle_request()
510 queue_delayed_work(tb->wq, &xd->get_properties_work, in tb_xdp_handle_request()
512 tb_xdomain_put(xd); in tb_xdp_handle_request()
671 struct tb_xdomain *xd = tb_service_parent(svc); in tb_service_release() local
673 ida_simple_remove(&xd->service_ids, svc->id); in tb_service_release()
688 struct tb_xdomain *xd = data; in remove_missing_service() local
695 if (!tb_property_find(xd->properties, svc->key, in remove_missing_service()
741 static void enumerate_services(struct tb_xdomain *xd) in enumerate_services() argument
751 device_for_each_child_reverse(&xd->dev, xd, remove_missing_service); in enumerate_services()
754 tb_property_for_each(xd->properties, p) { in enumerate_services()
759 dev = device_find_child(&xd->dev, p, find_service); in enumerate_services()
774 svc->id = ida_simple_get(&xd->service_ids, 0, 0, GFP_KERNEL); in enumerate_services()
777 svc->dev.parent = &xd->dev; in enumerate_services()
778 dev_set_name(&svc->dev, "%s.%d", dev_name(&xd->dev), svc->id); in enumerate_services()
787 static int populate_properties(struct tb_xdomain *xd, in populate_properties() argument
796 xd->device = p->value.immediate; in populate_properties()
801 xd->vendor = p->value.immediate; in populate_properties()
803 kfree(xd->device_name); in populate_properties()
804 xd->device_name = NULL; in populate_properties()
805 kfree(xd->vendor_name); in populate_properties()
806 xd->vendor_name = NULL; in populate_properties()
811 xd->device_name = kstrdup(p->value.text, GFP_KERNEL); in populate_properties()
814 xd->vendor_name = kstrdup(p->value.text, GFP_KERNEL); in populate_properties()
820 static void tb_xdomain_restore_paths(struct tb_xdomain *xd) in tb_xdomain_restore_paths() argument
822 if (!xd->resume) in tb_xdomain_restore_paths()
825 xd->resume = false; in tb_xdomain_restore_paths()
826 if (xd->transmit_path) { in tb_xdomain_restore_paths()
827 dev_dbg(&xd->dev, "re-establishing DMA path\n"); in tb_xdomain_restore_paths()
828 tb_domain_approve_xdomain_paths(xd->tb, xd); in tb_xdomain_restore_paths()
834 struct tb_xdomain *xd = container_of(work, typeof(*xd), in tb_xdomain_get_properties() local
837 struct tb *tb = xd->tb; in tb_xdomain_get_properties()
843 ret = tb_xdp_properties_request(tb->ctl, xd->route, xd->local_uuid, in tb_xdomain_get_properties()
844 xd->remote_uuid, xd->properties_retries, in tb_xdomain_get_properties()
847 if (xd->properties_retries-- > 0) { in tb_xdomain_get_properties()
848 queue_delayed_work(xd->tb->wq, &xd->get_properties_work, in tb_xdomain_get_properties()
852 dev_err(&xd->dev, in tb_xdomain_get_properties()
854 xd->remote_uuid); in tb_xdomain_get_properties()
859 xd->properties_retries = XDOMAIN_PROPERTIES_RETRIES; in tb_xdomain_get_properties()
861 mutex_lock(&xd->lock); in tb_xdomain_get_properties()
864 if (xd->properties && gen <= xd->property_block_gen) { in tb_xdomain_get_properties()
871 tb_xdomain_restore_paths(xd); in tb_xdomain_get_properties()
877 dev_err(&xd->dev, "failed to parse XDomain properties\n"); in tb_xdomain_get_properties()
881 ret = populate_properties(xd, dir); in tb_xdomain_get_properties()
883 dev_err(&xd->dev, "missing XDomain properties in response\n"); in tb_xdomain_get_properties()
888 if (xd->properties) { in tb_xdomain_get_properties()
889 tb_property_free_dir(xd->properties); in tb_xdomain_get_properties()
893 xd->properties = dir; in tb_xdomain_get_properties()
894 xd->property_block_gen = gen; in tb_xdomain_get_properties()
896 tb_xdomain_restore_paths(xd); in tb_xdomain_get_properties()
898 mutex_unlock(&xd->lock); in tb_xdomain_get_properties()
908 if (device_add(&xd->dev)) { in tb_xdomain_get_properties()
909 dev_err(&xd->dev, "failed to add XDomain device\n"); in tb_xdomain_get_properties()
913 kobject_uevent(&xd->dev.kobj, KOBJ_CHANGE); in tb_xdomain_get_properties()
916 enumerate_services(xd); in tb_xdomain_get_properties()
923 mutex_unlock(&xd->lock); in tb_xdomain_get_properties()
928 struct tb_xdomain *xd = container_of(work, typeof(*xd), in tb_xdomain_properties_changed() local
932 ret = tb_xdp_properties_changed_request(xd->tb->ctl, xd->route, in tb_xdomain_properties_changed()
933 xd->properties_changed_retries, xd->local_uuid); in tb_xdomain_properties_changed()
935 if (xd->properties_changed_retries-- > 0) in tb_xdomain_properties_changed()
936 queue_delayed_work(xd->tb->wq, in tb_xdomain_properties_changed()
937 &xd->properties_changed_work, in tb_xdomain_properties_changed()
942 xd->properties_changed_retries = XDOMAIN_PROPERTIES_CHANGED_RETRIES; in tb_xdomain_properties_changed()
948 struct tb_xdomain *xd = container_of(dev, struct tb_xdomain, dev); in device_show() local
950 return sprintf(buf, "%#x\n", xd->device); in device_show()
957 struct tb_xdomain *xd = container_of(dev, struct tb_xdomain, dev); in device_name_show() local
960 if (mutex_lock_interruptible(&xd->lock)) in device_name_show()
962 ret = sprintf(buf, "%s\n", xd->device_name ? xd->device_name : ""); in device_name_show()
963 mutex_unlock(&xd->lock); in device_name_show()
972 struct tb_xdomain *xd = container_of(dev, struct tb_xdomain, dev); in vendor_show() local
974 return sprintf(buf, "%#x\n", xd->vendor); in vendor_show()
981 struct tb_xdomain *xd = container_of(dev, struct tb_xdomain, dev); in vendor_name_show() local
984 if (mutex_lock_interruptible(&xd->lock)) in vendor_name_show()
986 ret = sprintf(buf, "%s\n", xd->vendor_name ? xd->vendor_name : ""); in vendor_name_show()
987 mutex_unlock(&xd->lock); in vendor_name_show()
996 struct tb_xdomain *xd = container_of(dev, struct tb_xdomain, dev); in unique_id_show() local
998 return sprintf(buf, "%pUb\n", xd->remote_uuid); in unique_id_show()
1022 struct tb_xdomain *xd = container_of(dev, struct tb_xdomain, dev); in tb_xdomain_release() local
1024 put_device(xd->dev.parent); in tb_xdomain_release()
1026 tb_property_free_dir(xd->properties); in tb_xdomain_release()
1027 ida_destroy(&xd->service_ids); in tb_xdomain_release()
1029 kfree(xd->local_uuid); in tb_xdomain_release()
1030 kfree(xd->remote_uuid); in tb_xdomain_release()
1031 kfree(xd->device_name); in tb_xdomain_release()
1032 kfree(xd->vendor_name); in tb_xdomain_release()
1033 kfree(xd); in tb_xdomain_release()
1036 static void start_handshake(struct tb_xdomain *xd) in start_handshake() argument
1038 xd->properties_retries = XDOMAIN_PROPERTIES_RETRIES; in start_handshake()
1039 xd->properties_changed_retries = XDOMAIN_PROPERTIES_CHANGED_RETRIES; in start_handshake()
1042 queue_delayed_work(xd->tb->wq, &xd->properties_changed_work, in start_handshake()
1044 queue_delayed_work(xd->tb->wq, &xd->get_properties_work, in start_handshake()
1048 static void stop_handshake(struct tb_xdomain *xd) in stop_handshake() argument
1050 xd->properties_retries = 0; in stop_handshake()
1051 xd->properties_changed_retries = 0; in stop_handshake()
1053 cancel_delayed_work_sync(&xd->get_properties_work); in stop_handshake()
1054 cancel_delayed_work_sync(&xd->properties_changed_work); in stop_handshake()
1065 struct tb_xdomain *xd = tb_to_xdomain(dev); in tb_xdomain_resume() local
1071 xd->resume = true; in tb_xdomain_resume()
1072 start_handshake(xd); in tb_xdomain_resume()
1104 struct tb_xdomain *xd; in tb_xdomain_alloc() local
1106 xd = kzalloc(sizeof(*xd), GFP_KERNEL); in tb_xdomain_alloc()
1107 if (!xd) in tb_xdomain_alloc()
1110 xd->tb = tb; in tb_xdomain_alloc()
1111 xd->route = route; in tb_xdomain_alloc()
1112 ida_init(&xd->service_ids); in tb_xdomain_alloc()
1113 mutex_init(&xd->lock); in tb_xdomain_alloc()
1114 INIT_DELAYED_WORK(&xd->get_properties_work, tb_xdomain_get_properties); in tb_xdomain_alloc()
1115 INIT_DELAYED_WORK(&xd->properties_changed_work, in tb_xdomain_alloc()
1118 xd->local_uuid = kmemdup(local_uuid, sizeof(uuid_t), GFP_KERNEL); in tb_xdomain_alloc()
1119 if (!xd->local_uuid) in tb_xdomain_alloc()
1122 xd->remote_uuid = kmemdup(remote_uuid, sizeof(uuid_t), GFP_KERNEL); in tb_xdomain_alloc()
1123 if (!xd->remote_uuid) in tb_xdomain_alloc()
1126 device_initialize(&xd->dev); in tb_xdomain_alloc()
1127 xd->dev.parent = get_device(parent); in tb_xdomain_alloc()
1128 xd->dev.bus = &tb_bus_type; in tb_xdomain_alloc()
1129 xd->dev.type = &tb_xdomain_type; in tb_xdomain_alloc()
1130 xd->dev.groups = xdomain_attr_groups; in tb_xdomain_alloc()
1131 dev_set_name(&xd->dev, "%u-%llx", tb->index, route); in tb_xdomain_alloc()
1137 pm_runtime_set_active(&xd->dev); in tb_xdomain_alloc()
1138 pm_runtime_get_noresume(&xd->dev); in tb_xdomain_alloc()
1139 pm_runtime_enable(&xd->dev); in tb_xdomain_alloc()
1141 return xd; in tb_xdomain_alloc()
1144 kfree(xd->local_uuid); in tb_xdomain_alloc()
1146 kfree(xd); in tb_xdomain_alloc()
1160 void tb_xdomain_add(struct tb_xdomain *xd) in tb_xdomain_add() argument
1163 start_handshake(xd); in tb_xdomain_add()
1180 void tb_xdomain_remove(struct tb_xdomain *xd) in tb_xdomain_remove() argument
1182 stop_handshake(xd); in tb_xdomain_remove()
1184 device_for_each_child_reverse(&xd->dev, xd, unregister_service); in tb_xdomain_remove()
1191 pm_runtime_disable(&xd->dev); in tb_xdomain_remove()
1192 pm_runtime_put_noidle(&xd->dev); in tb_xdomain_remove()
1193 pm_runtime_set_suspended(&xd->dev); in tb_xdomain_remove()
1195 if (!device_is_registered(&xd->dev)) in tb_xdomain_remove()
1196 put_device(&xd->dev); in tb_xdomain_remove()
1198 device_unregister(&xd->dev); in tb_xdomain_remove()
1217 int tb_xdomain_enable_paths(struct tb_xdomain *xd, u16 transmit_path, in tb_xdomain_enable_paths() argument
1223 mutex_lock(&xd->lock); in tb_xdomain_enable_paths()
1225 if (xd->transmit_path) { in tb_xdomain_enable_paths()
1226 ret = xd->transmit_path == transmit_path ? 0 : -EBUSY; in tb_xdomain_enable_paths()
1230 xd->transmit_path = transmit_path; in tb_xdomain_enable_paths()
1231 xd->transmit_ring = transmit_ring; in tb_xdomain_enable_paths()
1232 xd->receive_path = receive_path; in tb_xdomain_enable_paths()
1233 xd->receive_ring = receive_ring; in tb_xdomain_enable_paths()
1235 ret = tb_domain_approve_xdomain_paths(xd->tb, xd); in tb_xdomain_enable_paths()
1238 mutex_unlock(&xd->lock); in tb_xdomain_enable_paths()
1253 int tb_xdomain_disable_paths(struct tb_xdomain *xd) in tb_xdomain_disable_paths() argument
1257 mutex_lock(&xd->lock); in tb_xdomain_disable_paths()
1258 if (xd->transmit_path) { in tb_xdomain_disable_paths()
1259 xd->transmit_path = 0; in tb_xdomain_disable_paths()
1260 xd->transmit_ring = 0; in tb_xdomain_disable_paths()
1261 xd->receive_path = 0; in tb_xdomain_disable_paths()
1262 xd->receive_ring = 0; in tb_xdomain_disable_paths()
1264 ret = tb_domain_disconnect_xdomain_paths(xd->tb, xd); in tb_xdomain_disable_paths()
1266 mutex_unlock(&xd->lock); in tb_xdomain_disable_paths()
1286 struct tb_xdomain *xd; in switch_find_xdomain() local
1292 xd = port->xdomain; in switch_find_xdomain()
1295 if (uuid_equal(xd->remote_uuid, lookup->uuid)) in switch_find_xdomain()
1296 return xd; in switch_find_xdomain()
1298 lookup->link == xd->link && in switch_find_xdomain()
1299 lookup->depth == xd->depth) { in switch_find_xdomain()
1300 return xd; in switch_find_xdomain()
1302 lookup->route == xd->route) { in switch_find_xdomain()
1303 return xd; in switch_find_xdomain()
1306 xd = switch_find_xdomain(port->remote->sw, lookup); in switch_find_xdomain()
1307 if (xd) in switch_find_xdomain()
1308 return xd; in switch_find_xdomain()
1333 struct tb_xdomain *xd; in tb_xdomain_find_by_uuid() local
1338 xd = switch_find_xdomain(tb->root_switch, &lookup); in tb_xdomain_find_by_uuid()
1339 return tb_xdomain_get(xd); in tb_xdomain_find_by_uuid()
1363 struct tb_xdomain *xd; in tb_xdomain_find_by_link_depth() local
1369 xd = switch_find_xdomain(tb->root_switch, &lookup); in tb_xdomain_find_by_link_depth()
1370 return tb_xdomain_get(xd); in tb_xdomain_find_by_link_depth()
1391 struct tb_xdomain *xd; in tb_xdomain_find_by_route() local
1396 xd = switch_find_xdomain(tb->root_switch, &lookup); in tb_xdomain_find_by_route()
1397 return tb_xdomain_get(xd); in tb_xdomain_find_by_route()
1477 struct tb_xdomain *xd; in update_xdomain() local
1479 xd = tb_to_xdomain(dev); in update_xdomain()
1480 if (xd) { in update_xdomain()
1481 queue_delayed_work(xd->tb->wq, &xd->properties_changed_work, in update_xdomain()