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.

Dependency Surface

Detected Declarations

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

Implementation Notes