• Home
  • Raw
  • Download

Lines Matching +full:0 +full:xd

47 	UUID_INIT(0xb638d70e, 0x42ff, 0x40bb,
48 0x97, 0xc2, 0x90, 0xe2, 0xc0, 0xb2, 0xff, 0x07);
87 req->result.err = 0; in tb_xdomain_copy()
116 * @xd: XDomain to send the message
124 * Return: %0 in case of success and negative errno in case of failure
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()
163 * @xd: XDomain to send the request
176 * Return: %0 in case of success and negative errno in case of failure
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()
209 return 0; in tb_xdp_handle_error()
225 return 0; in tb_xdp_handle_error()
233 memset(&res, 0, sizeof(res)); in tb_xdp_error_response()
258 memset(&req, 0, sizeof(req)); in tb_xdp_properties_request()
264 len = 0; in tb_xdp_properties_request()
265 data_len = 0; in tb_xdp_properties_request()
351 return 0; in tb_xdp_properties_response()
396 memset(&req, 0, sizeof(req)); in tb_xdp_properties_changed_request()
401 memset(&res, 0, sizeof(res)); in tb_xdp_properties_changed_request()
417 memset(&res, 0, sizeof(res)); in tb_xdp_properties_changed_response()
444 return 0; in tb_register_protocol_handler()
470 int ret = 0; in tb_xdp_handle_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()
636 return sprintf(buf, "0x%08x\n", svc->prtcstns); in prtcstns_show()
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
693 return 0; in remove_missing_service()
695 if (!tb_property_find(xd->properties, svc->key, in remove_missing_service()
699 return 0; in remove_missing_service()
709 return 0; in find_service()
738 return 0; in populate_service()
741 static void enumerate_services(struct tb_xdomain *xd) in enumerate_services() argument
752 device_for_each_child_reverse(&xd->dev, xd, remove_missing_service); in enumerate_services()
755 tb_property_for_each(xd->properties, p) { in enumerate_services()
760 dev = device_find_child(&xd->dev, p, find_service); in enumerate_services()
775 id = ida_simple_get(&xd->service_ids, 0, 0, GFP_KERNEL); in enumerate_services()
776 if (id < 0) { in enumerate_services()
783 svc->dev.parent = &xd->dev; in enumerate_services()
784 dev_set_name(&svc->dev, "%s.%d", dev_name(&xd->dev), svc->id); in enumerate_services()
793 static int populate_properties(struct tb_xdomain *xd, in populate_properties() argument
802 xd->device = p->value.immediate; in populate_properties()
807 xd->vendor = p->value.immediate; in populate_properties()
809 kfree(xd->device_name); in populate_properties()
810 xd->device_name = NULL; in populate_properties()
811 kfree(xd->vendor_name); in populate_properties()
812 xd->vendor_name = NULL; in populate_properties()
817 xd->device_name = kstrdup(p->value.text, GFP_KERNEL); in populate_properties()
820 xd->vendor_name = kstrdup(p->value.text, GFP_KERNEL); in populate_properties()
822 return 0; in populate_properties()
825 /* Called with @xd->lock held */
826 static void tb_xdomain_restore_paths(struct tb_xdomain *xd) in tb_xdomain_restore_paths() argument
828 if (!xd->resume) in tb_xdomain_restore_paths()
831 xd->resume = false; in tb_xdomain_restore_paths()
832 if (xd->transmit_path) { in tb_xdomain_restore_paths()
833 dev_dbg(&xd->dev, "re-establishing DMA path\n"); in tb_xdomain_restore_paths()
834 tb_domain_approve_xdomain_paths(xd->tb, xd); in tb_xdomain_restore_paths()
840 struct tb_xdomain *xd = container_of(work, typeof(*xd), in tb_xdomain_get_properties() local
843 struct tb *tb = xd->tb; in tb_xdomain_get_properties()
846 u32 gen = 0; in tb_xdomain_get_properties()
849 ret = tb_xdp_properties_request(tb->ctl, xd->route, xd->local_uuid, in tb_xdomain_get_properties()
850 xd->remote_uuid, xd->properties_retries, in tb_xdomain_get_properties()
852 if (ret < 0) { in tb_xdomain_get_properties()
853 if (xd->properties_retries-- > 0) { in tb_xdomain_get_properties()
854 queue_delayed_work(xd->tb->wq, &xd->get_properties_work, in tb_xdomain_get_properties()
858 dev_err(&xd->dev, in tb_xdomain_get_properties()
860 xd->remote_uuid); in tb_xdomain_get_properties()
865 xd->properties_retries = XDOMAIN_PROPERTIES_RETRIES; in tb_xdomain_get_properties()
867 mutex_lock(&xd->lock); in tb_xdomain_get_properties()
870 if (xd->properties && gen <= xd->property_block_gen) { in tb_xdomain_get_properties()
877 tb_xdomain_restore_paths(xd); in tb_xdomain_get_properties()
883 dev_err(&xd->dev, "failed to parse XDomain properties\n"); in tb_xdomain_get_properties()
887 ret = populate_properties(xd, dir); in tb_xdomain_get_properties()
889 dev_err(&xd->dev, "missing XDomain properties in response\n"); in tb_xdomain_get_properties()
894 if (xd->properties) { in tb_xdomain_get_properties()
895 tb_property_free_dir(xd->properties); in tb_xdomain_get_properties()
899 xd->properties = dir; in tb_xdomain_get_properties()
900 xd->property_block_gen = gen; in tb_xdomain_get_properties()
902 tb_xdomain_restore_paths(xd); in tb_xdomain_get_properties()
904 mutex_unlock(&xd->lock); in tb_xdomain_get_properties()
914 if (device_add(&xd->dev)) { in tb_xdomain_get_properties()
915 dev_err(&xd->dev, "failed to add XDomain device\n"); in tb_xdomain_get_properties()
919 kobject_uevent(&xd->dev.kobj, KOBJ_CHANGE); in tb_xdomain_get_properties()
922 enumerate_services(xd); in tb_xdomain_get_properties()
929 mutex_unlock(&xd->lock); in tb_xdomain_get_properties()
934 struct tb_xdomain *xd = container_of(work, typeof(*xd), in tb_xdomain_properties_changed() local
938 ret = tb_xdp_properties_changed_request(xd->tb->ctl, xd->route, in tb_xdomain_properties_changed()
939 xd->properties_changed_retries, xd->local_uuid); in tb_xdomain_properties_changed()
941 if (xd->properties_changed_retries-- > 0) in tb_xdomain_properties_changed()
942 queue_delayed_work(xd->tb->wq, in tb_xdomain_properties_changed()
943 &xd->properties_changed_work, in tb_xdomain_properties_changed()
948 xd->properties_changed_retries = XDOMAIN_PROPERTIES_CHANGED_RETRIES; in tb_xdomain_properties_changed()
954 struct tb_xdomain *xd = container_of(dev, struct tb_xdomain, dev); in device_show() local
956 return sprintf(buf, "%#x\n", xd->device); in device_show()
963 struct tb_xdomain *xd = container_of(dev, struct tb_xdomain, dev); in device_name_show() local
966 if (mutex_lock_interruptible(&xd->lock)) in device_name_show()
968 ret = sprintf(buf, "%s\n", xd->device_name ? xd->device_name : ""); in device_name_show()
969 mutex_unlock(&xd->lock); in device_name_show()
978 struct tb_xdomain *xd = container_of(dev, struct tb_xdomain, dev); in vendor_show() local
980 return sprintf(buf, "%#x\n", xd->vendor); in vendor_show()
987 struct tb_xdomain *xd = container_of(dev, struct tb_xdomain, dev); in vendor_name_show() local
990 if (mutex_lock_interruptible(&xd->lock)) in vendor_name_show()
992 ret = sprintf(buf, "%s\n", xd->vendor_name ? xd->vendor_name : ""); in vendor_name_show()
993 mutex_unlock(&xd->lock); in vendor_name_show()
1002 struct tb_xdomain *xd = container_of(dev, struct tb_xdomain, dev); in unique_id_show() local
1004 return sprintf(buf, "%pUb\n", xd->remote_uuid); in unique_id_show()
1028 struct tb_xdomain *xd = container_of(dev, struct tb_xdomain, dev); in tb_xdomain_release() local
1030 put_device(xd->dev.parent); in tb_xdomain_release()
1032 tb_property_free_dir(xd->properties); in tb_xdomain_release()
1033 ida_destroy(&xd->service_ids); in tb_xdomain_release()
1035 kfree(xd->local_uuid); in tb_xdomain_release()
1036 kfree(xd->remote_uuid); in tb_xdomain_release()
1037 kfree(xd->device_name); in tb_xdomain_release()
1038 kfree(xd->vendor_name); in tb_xdomain_release()
1039 kfree(xd); in tb_xdomain_release()
1042 static void start_handshake(struct tb_xdomain *xd) in start_handshake() argument
1044 xd->properties_retries = XDOMAIN_PROPERTIES_RETRIES; in start_handshake()
1045 xd->properties_changed_retries = XDOMAIN_PROPERTIES_CHANGED_RETRIES; in start_handshake()
1048 queue_delayed_work(xd->tb->wq, &xd->properties_changed_work, in start_handshake()
1050 queue_delayed_work(xd->tb->wq, &xd->get_properties_work, in start_handshake()
1054 static void stop_handshake(struct tb_xdomain *xd) in stop_handshake() argument
1056 xd->properties_retries = 0; in stop_handshake()
1057 xd->properties_changed_retries = 0; in stop_handshake()
1059 cancel_delayed_work_sync(&xd->get_properties_work); in stop_handshake()
1060 cancel_delayed_work_sync(&xd->properties_changed_work); in stop_handshake()
1066 return 0; in tb_xdomain_suspend()
1071 struct tb_xdomain *xd = tb_to_xdomain(dev); in tb_xdomain_resume() local
1077 xd->resume = true; in tb_xdomain_resume()
1078 start_handshake(xd); in tb_xdomain_resume()
1080 return 0; in tb_xdomain_resume()
1110 struct tb_xdomain *xd; in tb_xdomain_alloc() local
1112 xd = kzalloc(sizeof(*xd), GFP_KERNEL); in tb_xdomain_alloc()
1113 if (!xd) in tb_xdomain_alloc()
1116 xd->tb = tb; in tb_xdomain_alloc()
1117 xd->route = route; in tb_xdomain_alloc()
1118 ida_init(&xd->service_ids); in tb_xdomain_alloc()
1119 mutex_init(&xd->lock); in tb_xdomain_alloc()
1120 INIT_DELAYED_WORK(&xd->get_properties_work, tb_xdomain_get_properties); in tb_xdomain_alloc()
1121 INIT_DELAYED_WORK(&xd->properties_changed_work, in tb_xdomain_alloc()
1124 xd->local_uuid = kmemdup(local_uuid, sizeof(uuid_t), GFP_KERNEL); in tb_xdomain_alloc()
1125 if (!xd->local_uuid) in tb_xdomain_alloc()
1128 xd->remote_uuid = kmemdup(remote_uuid, sizeof(uuid_t), GFP_KERNEL); in tb_xdomain_alloc()
1129 if (!xd->remote_uuid) in tb_xdomain_alloc()
1132 device_initialize(&xd->dev); in tb_xdomain_alloc()
1133 xd->dev.parent = get_device(parent); in tb_xdomain_alloc()
1134 xd->dev.bus = &tb_bus_type; in tb_xdomain_alloc()
1135 xd->dev.type = &tb_xdomain_type; in tb_xdomain_alloc()
1136 xd->dev.groups = xdomain_attr_groups; in tb_xdomain_alloc()
1137 dev_set_name(&xd->dev, "%u-%llx", tb->index, route); in tb_xdomain_alloc()
1143 pm_runtime_set_active(&xd->dev); in tb_xdomain_alloc()
1144 pm_runtime_get_noresume(&xd->dev); in tb_xdomain_alloc()
1145 pm_runtime_enable(&xd->dev); in tb_xdomain_alloc()
1147 return xd; in tb_xdomain_alloc()
1150 kfree(xd->local_uuid); in tb_xdomain_alloc()
1152 kfree(xd); in tb_xdomain_alloc()
1159 * @xd: XDomain to add
1166 void tb_xdomain_add(struct tb_xdomain *xd) in tb_xdomain_add() argument
1169 start_handshake(xd); in tb_xdomain_add()
1175 return 0; in unregister_service()
1180 * @xd: XDomain to remove
1183 * along with any services from the bus. When the last reference to @xd
1186 void tb_xdomain_remove(struct tb_xdomain *xd) in tb_xdomain_remove() argument
1188 stop_handshake(xd); in tb_xdomain_remove()
1190 device_for_each_child_reverse(&xd->dev, xd, unregister_service); in tb_xdomain_remove()
1197 pm_runtime_disable(&xd->dev); in tb_xdomain_remove()
1198 pm_runtime_put_noidle(&xd->dev); in tb_xdomain_remove()
1199 pm_runtime_set_suspended(&xd->dev); in tb_xdomain_remove()
1201 if (!device_is_registered(&xd->dev)) in tb_xdomain_remove()
1202 put_device(&xd->dev); in tb_xdomain_remove()
1204 device_unregister(&xd->dev); in tb_xdomain_remove()
1209 * @xd: XDomain connection
1221 * Return: %0 in case of success and negative errno in case of error
1223 int tb_xdomain_enable_paths(struct tb_xdomain *xd, u16 transmit_path, in tb_xdomain_enable_paths() argument
1229 mutex_lock(&xd->lock); in tb_xdomain_enable_paths()
1231 if (xd->transmit_path) { in tb_xdomain_enable_paths()
1232 ret = xd->transmit_path == transmit_path ? 0 : -EBUSY; in tb_xdomain_enable_paths()
1236 xd->transmit_path = transmit_path; in tb_xdomain_enable_paths()
1237 xd->transmit_ring = transmit_ring; in tb_xdomain_enable_paths()
1238 xd->receive_path = receive_path; in tb_xdomain_enable_paths()
1239 xd->receive_ring = receive_ring; in tb_xdomain_enable_paths()
1241 ret = tb_domain_approve_xdomain_paths(xd->tb, xd); in tb_xdomain_enable_paths()
1244 mutex_unlock(&xd->lock); in tb_xdomain_enable_paths()
1252 * @xd: XDomain connection
1257 * Return: %0 in case of success and negative errno in case of error
1259 int tb_xdomain_disable_paths(struct tb_xdomain *xd) in tb_xdomain_disable_paths() argument
1261 int ret = 0; in tb_xdomain_disable_paths()
1263 mutex_lock(&xd->lock); in tb_xdomain_disable_paths()
1264 if (xd->transmit_path) { in tb_xdomain_disable_paths()
1265 xd->transmit_path = 0; in tb_xdomain_disable_paths()
1266 xd->transmit_ring = 0; in tb_xdomain_disable_paths()
1267 xd->receive_path = 0; in tb_xdomain_disable_paths()
1268 xd->receive_ring = 0; in tb_xdomain_disable_paths()
1270 ret = tb_domain_disconnect_xdomain_paths(xd->tb, xd); in tb_xdomain_disable_paths()
1272 mutex_unlock(&xd->lock); in tb_xdomain_disable_paths()
1292 struct tb_xdomain *xd; in switch_find_xdomain() local
1298 xd = port->xdomain; in switch_find_xdomain()
1301 if (uuid_equal(xd->remote_uuid, lookup->uuid)) in switch_find_xdomain()
1302 return xd; in switch_find_xdomain()
1304 lookup->link == xd->link && in switch_find_xdomain()
1305 lookup->depth == xd->depth) { in switch_find_xdomain()
1306 return xd; in switch_find_xdomain()
1308 lookup->route == xd->route) { in switch_find_xdomain()
1309 return xd; in switch_find_xdomain()
1312 xd = switch_find_xdomain(port->remote->sw, lookup); in switch_find_xdomain()
1313 if (xd) in switch_find_xdomain()
1314 return xd; in switch_find_xdomain()
1339 struct tb_xdomain *xd; in tb_xdomain_find_by_uuid() local
1341 memset(&lookup, 0, sizeof(lookup)); in tb_xdomain_find_by_uuid()
1344 xd = switch_find_xdomain(tb->root_switch, &lookup); in tb_xdomain_find_by_uuid()
1345 return tb_xdomain_get(xd); in tb_xdomain_find_by_uuid()
1369 struct tb_xdomain *xd; in tb_xdomain_find_by_link_depth() local
1371 memset(&lookup, 0, sizeof(lookup)); in tb_xdomain_find_by_link_depth()
1375 xd = switch_find_xdomain(tb->root_switch, &lookup); in tb_xdomain_find_by_link_depth()
1376 return tb_xdomain_get(xd); in tb_xdomain_find_by_link_depth()
1397 struct tb_xdomain *xd; in tb_xdomain_find_by_route() local
1399 memset(&lookup, 0, sizeof(lookup)); in tb_xdomain_find_by_route()
1402 xd = switch_find_xdomain(tb->root_switch, &lookup); in tb_xdomain_find_by_route()
1403 return tb_xdomain_get(xd); in tb_xdomain_find_by_route()
1413 int ret = 0; in tb_xdomain_handle_request()
1449 return ret > 0; in tb_xdomain_handle_request()
1457 ret = tb_property_format_dir(xdomain_property_dir, NULL, 0); in rebuild_property_block()
1458 if (ret < 0) in rebuild_property_block()
1478 return 0; in rebuild_property_block()
1483 struct tb_xdomain *xd; in update_xdomain() local
1485 xd = tb_to_xdomain(dev); in update_xdomain()
1486 if (xd) { in update_xdomain()
1487 queue_delayed_work(xd->tb->wq, &xd->properties_changed_work, in update_xdomain()
1491 return 0; in update_xdomain()
1522 * Return: %0 on success and negative errno on failure
1553 return 0; in tb_register_property_dir()
1571 int ret = 0; in tb_unregister_property_dir()
1599 tb_property_add_immediate(xdomain_property_dir, "deviceid", 0x1); in tb_xdomain_init()
1602 tb_property_add_immediate(xdomain_property_dir, "devicerv", 0x80000100); in tb_xdomain_init()