drivers/thunderbolt/xdomain.c
Source file repositories/reference/linux-study-clean/drivers/thunderbolt/xdomain.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thunderbolt/xdomain.c- Extension
.c- Size
- 67946 bytes
- Lines
- 2606
- Domain
- Driver Families
- Bucket
- drivers/thunderbolt
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/delay.hlinux/kmod.hlinux/module.hlinux/pm_runtime.hlinux/prandom.hlinux/string_helpers.hlinux/utsname.hlinux/uuid.hlinux/workqueue.htb.h
Detected Declarations
struct xdomain_request_workstruct tb_xdomain_lookupfunction tb_is_xdomain_enabledfunction tb_xdomain_matchfunction tb_xdomain_copyfunction response_readyfunction __tb_xdomain_responsefunction tb_xdomain_responsefunction __tb_xdomain_requestfunction tb_xdomain_requestfunction tb_xdp_fill_headerfunction tb_xdp_handle_errorfunction tb_xdp_uuid_requestfunction tb_xdp_uuid_responsefunction tb_xdp_error_responsefunction tb_xdp_properties_requestfunction tb_xdp_properties_responsefunction tb_xdp_properties_changed_requestfunction tb_xdp_properties_changed_responsefunction tb_xdp_link_state_status_requestfunction tb_xdp_link_state_status_responsefunction tb_xdp_link_state_change_requestfunction tb_xdp_link_state_change_responsefunction tb_register_protocol_handlerfunction tb_unregister_protocol_handlerfunction update_property_blockfunction start_handshakefunction __stop_handshakefunction stop_handshakefunction tb_xdp_handle_requestfunction tb_xdp_schedule_requestfunction tb_register_service_driverfunction tb_unregister_service_driverfunction key_showfunction get_modaliasfunction modalias_showfunction prtcid_showfunction prtcvers_showfunction prtcrevs_showfunction prtcstns_showfunction tb_service_ueventfunction tb_service_releasefunction remove_missing_servicefunction find_servicefunction populate_servicefunction enumerate_servicesfunction populate_propertiesfunction tb_xdomain_update_link_attributes
Annotated Snippet
if (device_add(&xd->dev)) {
dev_err(&xd->dev, "failed to add XDomain device\n");
return -ENODEV;
}
dev_info(&xd->dev, "new host found, vendor=%#x device=%#x\n",
xd->vendor, xd->device);
if (xd->vendor_name && xd->device_name)
dev_info(&xd->dev, "%s %s\n", xd->vendor_name,
xd->device_name);
tb_xdomain_debugfs_init(xd);
} else {
kobject_uevent(&xd->dev.kobj, KOBJ_CHANGE);
}
enumerate_services(xd);
return 0;
err_free_dir:
tb_property_free_dir(dir);
err_free_block:
kfree(block);
mutex_unlock(&xd->lock);
return ret;
}
static void tb_xdomain_queue_uuid(struct tb_xdomain *xd)
{
xd->state = XDOMAIN_STATE_UUID;
xd->state_retries = XDOMAIN_RETRIES;
queue_delayed_work(xd->tb->wq, &xd->state_work,
msecs_to_jiffies(XDOMAIN_SHORT_TIMEOUT));
}
static void tb_xdomain_queue_link_status(struct tb_xdomain *xd)
{
xd->state = XDOMAIN_STATE_LINK_STATUS;
xd->state_retries = XDOMAIN_RETRIES;
queue_delayed_work(xd->tb->wq, &xd->state_work,
msecs_to_jiffies(XDOMAIN_DEFAULT_TIMEOUT));
}
static void tb_xdomain_queue_link_status2(struct tb_xdomain *xd)
{
xd->state = XDOMAIN_STATE_LINK_STATUS2;
xd->state_retries = XDOMAIN_RETRIES;
queue_delayed_work(xd->tb->wq, &xd->state_work,
msecs_to_jiffies(XDOMAIN_DEFAULT_TIMEOUT));
}
static void tb_xdomain_queue_bonding(struct tb_xdomain *xd)
{
if (memcmp(xd->local_uuid, xd->remote_uuid, UUID_SIZE) > 0) {
dev_dbg(&xd->dev, "we have higher UUID, other side bonds the lanes\n");
xd->state = XDOMAIN_STATE_BONDING_UUID_HIGH;
} else {
dev_dbg(&xd->dev, "we have lower UUID, bonding lanes\n");
xd->state = XDOMAIN_STATE_LINK_STATE_CHANGE;
}
xd->state_retries = XDOMAIN_RETRIES;
queue_delayed_work(xd->tb->wq, &xd->state_work,
msecs_to_jiffies(XDOMAIN_DEFAULT_TIMEOUT));
}
static void tb_xdomain_queue_bonding_uuid_low(struct tb_xdomain *xd)
{
xd->state = XDOMAIN_STATE_BONDING_UUID_LOW;
xd->state_retries = XDOMAIN_RETRIES;
queue_delayed_work(xd->tb->wq, &xd->state_work,
msecs_to_jiffies(XDOMAIN_DEFAULT_TIMEOUT));
}
static void tb_xdomain_queue_properties(struct tb_xdomain *xd)
{
xd->state = XDOMAIN_STATE_PROPERTIES;
xd->state_retries = XDOMAIN_RETRIES;
queue_delayed_work(xd->tb->wq, &xd->state_work,
msecs_to_jiffies(XDOMAIN_DEFAULT_TIMEOUT));
}
static void tb_xdomain_queue_properties_changed(struct tb_xdomain *xd)
{
xd->properties_changed_retries = XDOMAIN_RETRIES;
queue_delayed_work(xd->tb->wq, &xd->properties_changed_work,
msecs_to_jiffies(XDOMAIN_SHORT_TIMEOUT));
}
static void tb_xdomain_failed(struct tb_xdomain *xd)
Annotation
- Immediate include surface: `linux/device.h`, `linux/delay.h`, `linux/kmod.h`, `linux/module.h`, `linux/pm_runtime.h`, `linux/prandom.h`, `linux/string_helpers.h`, `linux/utsname.h`.
- Detected declarations: `struct xdomain_request_work`, `struct tb_xdomain_lookup`, `function tb_is_xdomain_enabled`, `function tb_xdomain_match`, `function tb_xdomain_copy`, `function response_ready`, `function __tb_xdomain_response`, `function tb_xdomain_response`, `function __tb_xdomain_request`, `function tb_xdomain_request`.
- Atlas domain: Driver Families / drivers/thunderbolt.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.