drivers/thunderbolt/acpi.c
Source file repositories/reference/linux-study-clean/drivers/thunderbolt/acpi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thunderbolt/acpi.c- Extension
.c- Size
- 10006 bytes
- Lines
- 369
- Domain
- Driver Families
- Bucket
- drivers/thunderbolt
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/acpi.hlinux/pm_runtime.htb.h
Detected Declarations
function Copyrightfunction pci_pcie_typefunction tb_acpi_add_linksfunction tb_acpi_is_nativefunction tb_acpi_may_tunnel_usb3function tb_acpi_may_tunnel_dpfunction tb_acpi_may_tunnel_pciefunction tb_acpi_is_xdomain_allowedfunction tb_acpi_retimer_set_powerfunction tb_acpi_power_on_retimersfunction tb_acpi_power_off_retimersfunction tb_acpi_bus_matchfunction tb_acpi_setupfunction tb_acpi_initfunction tb_acpi_exit
Annotated Snippet
pci_pcie_type(pdev) == PCI_EXP_TYPE_DOWNSTREAM)) {
const struct device_link *link;
/*
* Make them both active first to make sure the NHI does
* not runtime suspend before the consumer. The
* pm_runtime_put() below then allows the consumer to
* runtime suspend again (which then allows NHI runtime
* suspend too now that the device link is established).
*/
pm_runtime_get_sync(&pdev->dev);
link = device_link_add(&pdev->dev, &nhi->pdev->dev,
DL_FLAG_AUTOREMOVE_SUPPLIER |
DL_FLAG_RPM_ACTIVE |
DL_FLAG_PM_RUNTIME);
if (link) {
dev_dbg(&nhi->pdev->dev, "created link from %s\n",
dev_name(&pdev->dev));
*(bool *)ret = true;
} else {
dev_warn(&nhi->pdev->dev, "device link creation from %s failed\n",
dev_name(&pdev->dev));
}
pm_runtime_put(&pdev->dev);
}
out_put:
fwnode_handle_put(fwnode);
return AE_OK;
}
/**
* tb_acpi_add_links() - Add device links based on ACPI description
* @nhi: Pointer to NHI
*
* Goes over ACPI namespace finding tunneled ports that reference to
* @nhi ACPI node. For each reference a device link is added. The link
* is automatically removed by the driver core.
*
* Returns %true if at least one link was created, %false otherwise.
*/
bool tb_acpi_add_links(struct tb_nhi *nhi)
{
acpi_status status;
bool ret = false;
if (!has_acpi_companion(&nhi->pdev->dev))
return false;
/*
* Find all devices that have usb4-host-controller interface
* property that references to this NHI.
*/
status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 32,
tb_acpi_add_link, NULL, nhi, (void **)&ret);
if (ACPI_FAILURE(status)) {
dev_warn(&nhi->pdev->dev, "failed to enumerate tunneled ports\n");
return false;
}
return ret;
}
/**
* tb_acpi_is_native() - Did the platform grant native TBT/USB4 control
*
* Return: %true if the platform granted OS native control over
* TBT/USB4, %false otherwise.
*
* When returned %true, software based connection manager can be used,
* otherwise there is firmware based connection manager running.
*/
bool tb_acpi_is_native(void)
{
return osc_sb_native_usb4_support_confirmed &&
osc_sb_native_usb4_control;
}
/**
* tb_acpi_may_tunnel_usb3() - Is USB3 tunneling allowed by the platform
*
* Return: %true if software based connection manager is used and
* platform allows native USB 3.x tunneling, %false otherwise.
*/
bool tb_acpi_may_tunnel_usb3(void)
{
if (tb_acpi_is_native())
return osc_sb_native_usb4_control & OSC_USB_USB3_TUNNELING;
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/pm_runtime.h`, `tb.h`.
- Detected declarations: `function Copyright`, `function pci_pcie_type`, `function tb_acpi_add_links`, `function tb_acpi_is_native`, `function tb_acpi_may_tunnel_usb3`, `function tb_acpi_may_tunnel_dp`, `function tb_acpi_may_tunnel_pcie`, `function tb_acpi_is_xdomain_allowed`, `function tb_acpi_retimer_set_power`, `function tb_acpi_power_on_retimers`.
- Atlas domain: Driver Families / drivers/thunderbolt.
- Implementation status: source implementation candidate.
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.