linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mario Limonciello <mario.limonciello@amd.com>
To: <mathias.nyman@intel.com>, <mika.westerberg@linux.intel.com>,
	<linux-kernel@vger.kernel.org>
Cc: <Sanju.Mehta@amd.com>,
	Mario Limonciello <mario.limonciello@amd.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	<linux-usb@vger.kernel.org>
Subject: [PATCH 1/4] USB: ACPI: Look for `usb4-host-interface` property
Date: Wed, 5 Oct 2022 15:23:49 -0500	[thread overview]
Message-ID: <20221005202353.1269-2-mario.limonciello@amd.com> (raw)
In-Reply-To: <20221005202353.1269-1-mario.limonciello@amd.com>

For optimal power consumption of USB4 routers the XHCI PCIe endpoint
used for tunneling must be in D3.  Historically this is accomplished
by a long list of PCIe IDs that correspond to these endpoints.

The linux thunderbolt CM currently uses the `usb4-host-interface` ACPI
property to create a device link between the USB4 host router PCIe
endpoint and the XHCI PCIe endpoint.  The device link will move
the devices in out of D3 together.

To avoid having to maintain this never ending list of PCIe IDs, use
the existence of `usb4-host-interface` property on a USB port as a
proxy to allow runtime PM for these controllers.  The device links
will continue to be created when the CM initializes the USB4
host router and also discovers this property.

Link: https://learn.microsoft.com/en-us/windows-hardware/design/component-guidelines/usb4-acpi-requirements#port-mapping-_dsd-for-usb-3x-and-pcie
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
RFC v1->PATCH v1
 * Move this detection from Thunderbolt CM into USB core
---
 drivers/usb/core/usb-acpi.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c
index 6d93428432f13..f91ab4fd84cf8 100644
--- a/drivers/usb/core/usb-acpi.c
+++ b/drivers/usb/core/usb-acpi.c
@@ -177,6 +177,15 @@ usb_acpi_find_companion_for_port(struct usb_port *port_dev)
 		port_dev->connect_type = usb_acpi_get_connect_type(handle, pld);
 		ACPI_FREE(pld);
 	}
+	if (!acpi_dev_get_property(adev, "usb4-host-interface",
+				   ACPI_TYPE_ANY, NULL)) {
+		struct device *dev = &port_dev->dev;
+
+		while (dev && !dev_is_pci(dev))
+			dev = dev->parent;
+		if (dev)
+			pm_runtime_allow(dev);
+	}
 
 	return adev;
 }
-- 
2.34.1


  reply	other threads:[~2022-10-05 20:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-05 20:23 [PATCH 0/4] Enable runtime PM more broadly Mario Limonciello
2022-10-05 20:23 ` Mario Limonciello [this message]
2022-10-06  8:58   ` [PATCH 1/4] USB: ACPI: Look for `usb4-host-interface` property Mathias Nyman
2022-10-05 20:23 ` [PATCH 2/4] xhci-pci: Move PCI IDs for runtime allow into a table Mario Limonciello
2022-10-05 20:23 ` [PATCH 3/4] xhci-pci: Remove a number of controllers from the runtime PM allowlist Mario Limonciello
2022-10-05 20:23 ` [PATCH 4/4] xhci-pci: Allow host runtime PM as default for AMD Pink Sardine Mario Limonciello

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221005202353.1269-2-mario.limonciello@amd.com \
    --to=mario.limonciello@amd.com \
    --cc=Sanju.Mehta@amd.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=mika.westerberg@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).