From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Atharva Tiwari <atharvatiwarilinuxdev@gmail.com>
Cc: "Andre Eikmeyer" <andre@negmaster.com>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Thomas Gleixner" <tglx@kernel.org>,
"Ingo Molnar" <mingo@redhat.com>,
"Borislav Petkov" <bp@alien8.de>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
"Andreas Noever" <andreas.noever@gmail.com>,
"Mika Westerberg" <westeri@kernel.org>,
"Yehezkel Bernat" <YehezkelShB@gmail.com>,
"Hans de Goede" <hansg@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Jarkko Sakkinen" <jarkko@kernel.org>,
"Mimi Zohar" <zohar@linux.ibm.com>,
"Roberto Sassu" <roberto.sassu@huawei.com>,
"Dmitry Kasatkin" <dmitry.kasatkin@gmail.com>,
"Eric Snowberg" <eric.snowberg@oracle.com>,
"Paul Moore" <paul@paul-moore.com>,
"James Morris" <jmorris@namei.org>,
"Serge E. Hallyn" <serge@hallyn.com>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-usb@vger.kernel.org, platform-driver-x86@vger.kernel.org,
linux-integrity@vger.kernel.org, keyrings@vger.kernel.org,
linux-security-module@vger.kernel.org
Subject: Re: [PATCH v4 2/2] thunderbolt: Add device links for Apple T2 NHI
Date: Mon, 27 Jul 2026 13:24:06 +0200 [thread overview]
Message-ID: <20260727112406.GI2365036@black.igk.intel.com> (raw)
In-Reply-To: <20260724164641.2239-3-atharvatiwarilinuxdev@gmail.com>
Hi,
On Fri, Jul 24, 2026 at 12:46:37PM -0400, Atharva Tiwari wrote:
> From: Andre Eikmeyer <andre@negmaster.com>
>
> Icelake Thunderbolt NHI on T2 Macs (2018-2020). The NHI and its
> associated PCIe root ports all sit directly on the root complex
> with no upstream port. Apple's ACPI tables name Thunderbolt root
> ports as TRP0, TRP1, etc. Find them and create device links back
> to the NHI so that PCIe tunnels can be re-established after sleep.
For Ice Lake we can just add the known PCI IDs without need to look into
ACPI at all. You can look how it was done in
pcie_has_usb4_host_interface().
> And on other Thunderbolt NHI's, like Titan Ridge, the default method
> is used to add device links.
Is this for another Mac then? A Titan Ride based one? That should be a
separate patch.
> Co-developed-by: Atharva Tiwari <atharvatiwarilinuxdev@gmail.com>
> Signed-off-by: Atharva Tiwari <atharvatiwarilinuxdev@gmail.com>
>
> Signed-off-by: Andre Eikmeyer <andre@negmaster.com>
> ---
> drivers/thunderbolt/tb.c | 58 ++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 56 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
> index c69c323e6952..625451ff3ea0 100644
> --- a/drivers/thunderbolt/tb.c
> +++ b/drivers/thunderbolt/tb.c
> @@ -6,9 +6,11 @@
> * Copyright (C) 2019, Intel Corporation
> */
>
> +#include <linux/acpi.h>
> #include <linux/slab.h>
> #include <linux/errno.h>
> #include <linux/delay.h>
> +#include <linux/pci.h>
> #include <linux/pm_runtime.h>
> #include <linux/platform_data/x86/apple.h>
>
> @@ -3305,21 +3307,73 @@ static const struct tb_cm_ops tb_cm_ops = {
> static bool tb_apple_add_links(struct tb_nhi *nhi)
> {
> struct pci_dev *upstream, *pdev;
> - bool ret;
> + bool ret = false;
>
> if (!x86_apple_machine)
> return false;
>
> + /* On T2 Macs with Icelake thunderbolt NHI's.
> + * the root ports are stored in ACPI as TRP0,
> + * TRP1, etc. Find them and create device links
> + * so that PCIe tunnels can be re-established after
> + * sleep.
> + */
> +#if IS_ENABLED(CONFIG_ACPI)
> + if (has_apple_t2_chip && (nhi->pdev->device == PCI_DEVICE_ID_INTEL_ICL_NHI0 ||
> + nhi->pdev->device == PCI_DEVICE_ID_INTEL_ICL_NHI1)) {
> + struct acpi_device *adev;
> + unsigned int slot, func;
> + const struct device_link *link;
> + const char *bid;
> +
> + for (slot = 0; slot < 32; slot++) {
> + for (func = 0; func < 8; func++) {
> + struct pci_dev *current_pdev __free(pci_dev_put) =
> + pci_get_slot(nhi->pdev->bus, PCI_DEVFN(slot, func));
> + if (!current_pdev)
> + continue;
> +
> + if (!pci_is_pcie(current_pdev) || pci_pcie_type(current_pdev) !=
> + PCI_EXP_TYPE_ROOT_PORT)
> + continue;
> +
> + adev = ACPI_COMPANION(¤t_pdev->dev);
> + if (!adev)
> + continue;
> +
> + bid = acpi_device_bid(adev);
> + if (strncmp(bid, "TRP", 3) != 0)
> + continue;
> +
> + link = device_link_add(¤t_pdev->dev, &nhi->pdev->dev,
> + DL_FLAG_AUTOREMOVE_SUPPLIER |
> + DL_FLAG_PM_RUNTIME);
> + if (link) {
> + dev_dbg(&nhi->pdev->dev, "created link from %s\n",
> + dev_name(¤t_pdev->dev));
> + ret = true;
> + } else {
> + dev_warn(&nhi->pdev->dev,
> + "device link creation from %s failed\n",
> + dev_name(¤t_pdev->dev));
> + }
> + }
> + }
> + return ret;
> + }
> +#endif
> +
> switch (nhi->pdev->device) {
> case PCI_DEVICE_ID_INTEL_LIGHT_RIDGE:
> case PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_4C:
> case PCI_DEVICE_ID_INTEL_FALCON_RIDGE_2C_NHI:
> case PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_NHI:
> + case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_2C_NHI:
> + case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_4C_NHI:
> break;
> default:
> return false;
> }
> -
> upstream = pci_upstream_bridge(nhi->pdev);
> while (upstream) {
> if (!pci_is_pcie(upstream))
> --
> 2.43.0
prev parent reply other threads:[~2026-07-27 11:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-24 16:46 [PATCH v4 0/2] Add Apple T2 NHI device links Atharva Tiwari
2026-07-24 16:46 ` [PATCH v4 1/2] treewide: Add a flag to detect the Apple T2 chip Atharva Tiwari
2026-07-24 16:46 ` [PATCH v4 2/2] thunderbolt: Add device links for Apple T2 NHI Atharva Tiwari
2026-07-27 11:24 ` Mika Westerberg [this message]
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=20260727112406.GI2365036@black.igk.intel.com \
--to=mika.westerberg@linux.intel.com \
--cc=YehezkelShB@gmail.com \
--cc=andre@negmaster.com \
--cc=andreas.noever@gmail.com \
--cc=atharvatiwarilinuxdev@gmail.com \
--cc=bhelgaas@google.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=dmitry.kasatkin@gmail.com \
--cc=eric.snowberg@oracle.com \
--cc=hansg@kernel.org \
--cc=hpa@zytor.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jarkko@kernel.org \
--cc=jmorris@namei.org \
--cc=keyrings@vger.kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=paul@paul-moore.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=roberto.sassu@huawei.com \
--cc=serge@hallyn.com \
--cc=tglx@kernel.org \
--cc=westeri@kernel.org \
--cc=x86@kernel.org \
--cc=zohar@linux.ibm.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