From nobody Sat Jul 25 03:45:59 2026 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BFA143B994A for ; Sun, 19 Jul 2026 18:03:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784484244; cv=none; b=JtbviHLGe3r4AJJpR9Ef/Gm4Hvn5bFa8b3ceH/Iz3X8LecIzliZgqdFP6TvaZ7JZ+OuYDgd7NlwBf3CXeNd6wD/5p7GtKZ0mRH6KjA8TmfS+/MJp1aEIwTJkrhoqHJ6hYHCz0Ga9pRl/PAfM/KS4BV7i6c2U8OQhyeAsDM9tI9U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784484244; c=relaxed/simple; bh=v9HeOFbg7yqaPJFAebJkoHX6/z4ZNAksuMZiGZTzcV8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=swyEj4Y9DAV5AthwIQZeYxWC7t3R3237YnHrTP21NWquZcPyZJnUoXCEBu1al5P/S9Z3YQJtKavRNRWZPHyPqL/HJzAnFrYwY7BYLw/Xo7FW3ocd3oR89o5wbsxM10xS/VUTkJgM4BTi7EW1UwelAGobwaetw2qoNtLYsanomKk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gg7MNV9C; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gg7MNV9C" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-2ced3386430so58019245ad.1 for ; Sun, 19 Jul 2026 11:03:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784484235; x=1785089035; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=SdVZ4aGJrm1DuTj3OJVvOnHsBpK+4e3jVQB95QmtQUM=; b=gg7MNV9CA9igFeOzIJfAXVNKOwkbLs9PG4eMCYQjLezdWaZeh7jVGLj5Bj+Ifn4bGZ 9k7C45ijMqgkKegBw2uAAYb2GPAqQ8ebq/LU9PHT/VfBPXsw4/R5BiIXxbb/h6EKYtGl jHGI7NRDvxstNnUchf2jW03fLgLCF4a97s4DP+uQ1hn2Kd3dmFBTLw9lNvT4mIC61tgW ZiI5dd/5sYZ1v3FyIwphdF9J1lp25UR/KdNFZItpiBWIJon9xb7I23APgu02mGWys9uZ VQWOEPF7tUF4JX95pBH7CI77gBwfNsugWDFHrFpz1euzx9cWfs26ekO/zsIKOxDppCUd uK4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784484235; x=1785089035; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=SdVZ4aGJrm1DuTj3OJVvOnHsBpK+4e3jVQB95QmtQUM=; b=fQ8f9vLIMx8BlHZYR2BwwnSCAzY3R/5DTghPFJJ3Bxj13bTjJrEfffq8dpDbe/rLJY d7T0KyVQgdS+5P4wDmzaxaKx2pRZbRbPDojsddyGuFcR0erSDHyWySuEa/E83fXRuSD5 L2mvJTWxhhy/mctvpLNr5LSdekuMXjaKT6OHtk0It/F/r/pfC2jsDhx7klXb440+jsR+ JHaoIZHC5g5YjMp0SukJiVh1OOPh6772mdpcQPi2HtJ0nV1QmCCfzCnwKFZq+Yw803VM ZnfP8pakKdbV0XNaOEMKW+6vJsrGRVKW0sQqr2GmFRDyOJqL6s0fBvhlQech1VDsh4Nr bwcg== X-Forwarded-Encrypted: i=1; AHgh+Rpd+Lo6aDdoC7DbhbbWJYg/jQFk/WU+UuobPVgw0X0UaTbDk+r7KvARzNRYFSi74R4T3bpEzz3NYd8r20U=@vger.kernel.org X-Gm-Message-State: AOJu0Ywst+abeRfB4p3wyRsWI6Hh9NPf6bd4DD3Ty3nljuwkvKZG0f89 BmlNUv0v3BBu2xWOpoFBesYatKAZbcBg/POFaaDHpmhcOlH4sYQA2f1EoLY2oDo= X-Gm-Gg: AfdE7cngSSZPnsw1bKiQ8e37aCShFdbFR95iNZ/DaO8q/7hiTONdCNTyxRQz5m+RMyk ZUgcPLCYjZtEIUTaYBYbkygCcDE9lRhqO/dj7mXkIQrkjzAPUA2aMuTuRdaPamspUkea5Wia4TU 5amd2qpCw79IB1Js1S43YoslCVXPQixzj5GuQ7iUihexXjhTs38O30rzclLMcPho2UAGYiId28P WbsT0J81VG7i7TnEsyKUx0YsvYVmgZ7G65psSUrXuwFakCb1eCuNd/vqRiyvTq9u7K4bdrtzb9+ 52veEAPbaephfRa857dEVZ+pJOzb9AcxDLwiRVlb6rp+wvnLY26trrAwXIAmH3EwrqDl6wRIDIf EfkumjUJ+BnKFpD2d1EAvLnfBeUHhz0LIfBb42nQfL86E5h6FPNiT/WiUTozeIocWexcsZ5hgFS 2Q+tMbVB9Seq+2BQra4NZXu/lN6YdYhlmP19O6kXvq X-Received: by 2002:a05:6a20:bca2:b0:3c3:bbe6:95c7 with SMTP id adf61e73a8af0-3c3bbe69a9amr6850926637.17.1784484235584; Sun, 19 Jul 2026 11:03:55 -0700 (PDT) Received: from at-Standard-PC-Q35-ICH9-2009.. ([106.194.66.250]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3142a02b7f2sm27967645eec.13.2026.07.19.11.03.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jul 2026 11:03:54 -0700 (PDT) From: Atharva Tiwari To: Cc: Atharva Tiwari , Bjorn Helgaas , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Andreas Noever , Mika Westerberg , Yehezkel Bernat , Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Jarkko Sakkinen , Mimi Zohar , Roberto Sassu , Dmitry Kasatkin , Eric Snowberg , Paul Moore , James Morris , "Serge E. Hallyn" , 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: [PATCH 1/2] treewide: Add a flag to detect the Apple T2 chip Date: Sun, 19 Jul 2026 14:03:03 -0400 Message-ID: <20260719180308.1398-2-atharvatiwarilinuxdev@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260719180308.1398-1-atharvatiwarilinuxdev@gmail.com> References: <20260719180308.1398-1-atharvatiwarilinuxdev@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a flag to detect Apple T2 chips on Intel Macs. Cache the result to avoid repeated checks. That will be used in upcoming patches. Signed-off-by: Atharva Tiwari --- arch/x86/pci/fixup.c | 10 +++++ include/linux/platform_data/x86/apple.h | 5 +++ security/integrity/platform_certs/load_uefi.c | 38 ++++--------------- 3 files changed, 23 insertions(+), 30 deletions(-) diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c index b301c6c8df75..fbd204ca4c6d 100644 --- a/arch/x86/pci/fixup.c +++ b/arch/x86/pci/fixup.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -995,6 +996,15 @@ static void asus_disable_nvme_d3cold(struct pci_dev *p= dev) } DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x9a09, asus_disable_nvme_d3c= old); =20 +bool has_t2_chip; +EXPORT_SYMBOL(has_t2_chip); + +static void apple_has_t2_chip(struct pci_dev *pdev) +{ + has_t2_chip =3D true; +} +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_APPLE, 0x1801, apple_has_t2_chip); + #ifdef CONFIG_SUSPEND /* * Root Ports on some AMD SoCs advertise PME_Support for D3hot and D3cold,= but diff --git a/include/linux/platform_data/x86/apple.h b/include/linux/platfo= rm_data/x86/apple.h index 079e816c3c21..a2ab63bd1eac 100644 --- a/include/linux/platform_data/x86/apple.h +++ b/include/linux/platform_data/x86/apple.h @@ -6,8 +6,13 @@ * x86_apple_machine - whether the machine is an x86 Apple Macintosh */ extern bool x86_apple_machine; +/** + * has_t2_chip - whether the machine has the Apple T2 chip + */ +extern bool has_t2_chip; #else #define x86_apple_machine false +#define has_t2_chip false #endif =20 #endif diff --git a/security/integrity/platform_certs/load_uefi.c b/security/integ= rity/platform_certs/load_uefi.c index c0d6948446c3..da57ac322e72 100644 --- a/security/integrity/platform_certs/load_uefi.c +++ b/security/integrity/platform_certs/load_uefi.c @@ -3,42 +3,16 @@ #include #include #include -#include #include #include #include #include +#include #include #include #include "../integrity.h" #include "keyring_handler.h" =20 -/* - * On T2 Macs reading the db and dbx efi variables to load UEFI Secure Boot - * certificates causes occurrence of a page fault in Apple's firmware and - * a crash disabling EFI runtime services. The following quirk skips readi= ng - * these variables. - */ -static const struct dmi_system_id uefi_skip_cert[] =3D { - { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookPro15,1") }, - { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookPro15,2") }, - { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookPro15,3") }, - { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookPro15,4") }, - { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookPro16,1") }, - { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookPro16,2") }, - { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookPro16,3") }, - { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookPro16,4") }, - { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookAir8,1") }, - { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookAir8,2") }, - { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookAir9,1") }, - { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "Macmini8,1") }, - { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacPro7,1") }, - { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "iMac20,1") }, - { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "iMac20,2") }, - { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "iMacPro1,1") }, - { } -}; - /* * Look to see if a UEFI variable called MokIgnoreDB exists and return tru= e if * it does. @@ -165,10 +139,14 @@ static int __init load_uefi_certs(void) unsigned long dbsize =3D 0, dbxsize =3D 0, mokxsize =3D 0; efi_status_t status; int rc =3D 0; - const struct dmi_system_id *dmi_id; =20 - dmi_id =3D dmi_first_match(uefi_skip_cert); - if (dmi_id) { + /* + * On T2 Macs reading the db and dbx efi variables to load UEFI Secure Bo= ot + * certificates causes occurrence of a page fault in Apple's firmware and + * a crash disabling EFI runtime services. The following quirk skips read= ing + * these variables. + */ + if (has_t2_chip) { pr_err("Reading UEFI Secure Boot Certs is not supported on T2 Macs.\n"); return false; } --=20 2.43.0 From nobody Sat Jul 25 03:45:59 2026 Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1C663BB13D for ; Sun, 19 Jul 2026 18:04:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784484253; cv=none; b=cefAJQxBveXAxbpz/E4W1tevJXdxVtMcyzFCzjldZOSWssYH2Rq7X+mCVi8Mo93uGcoYWFmugEQmeBm8XVl4Az7a8G1iBCk+nMAImkuNdwymb3C6ffNR3zS46EI4bptz0qNXpdeVbhxOwC0mFrVTzeAM4vidF8231WqF4Uo3NdE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784484253; c=relaxed/simple; bh=V0Tae/rKozWhabyRfdu4QuNkEaB8DkFkgOcQe8o5wq4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OUMrAyKvFm9cWQ6/DMwg1p3JBfShCE2AFwYPdsmeMNdZHeG4BVEwsYTV9a6KmZonAeDVGSrSJdj9yztDdMF62vpwNc6nezkQzLe0r1bBYVQq+FM9ia8wplrz2slPTVvFMDR5FUimLgR0WlPELJAEhQZuNyxgk41URENSdjevd9A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FfG43JtS; arc=none smtp.client-ip=209.85.215.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FfG43JtS" Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-cb5a6aa8cf4so1131015a12.3 for ; Sun, 19 Jul 2026 11:04:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784484246; x=1785089046; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=uWQkBHme3djyDjtoGqM4G+GNxyywodyr8gsYJac/hfw=; b=FfG43JtSl6k2dkdJv1ue1j48FkxIOoBrilaiKruWxYFM28947LGwWga39sjiHmMDIJ TgWB5f/dZ/YajU65sC5pzoJMBx/NjJsBsQ7QhEwLeT99YAPnm4FgfBcgXMMTwp76pBuk A19zIh+9Fxg05n1+gVcE9ygTvcwo57pK/ul5J/Ll+Xqk+bhLzG4czKkx3fTsCPH+Hbwg tLwsoFBEx6MOv4OVTM8uqVvKAjtIp0ZOuNeYLfXBwvPFGaZHCLXiHWlGObp2EmJj92gI FXUwej9BaUvPlm371En4fqgIjkZjUcnbWYof5ME9Ppkq1pSjL6G/pqWjaDKT/tTl8GVZ svgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784484246; x=1785089046; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=uWQkBHme3djyDjtoGqM4G+GNxyywodyr8gsYJac/hfw=; b=ILrQoUbX6Lp38vZiSkaWYTCCqPoAR5i/bf4wK9yA2ZIzjA3ta1GONdnXi5cmqPIFEs UVSGg1VcG8UYisuVCI2bNhQF9WBN5CaNHt5HORmhuoh9UUh5CJd8gWMjHPjf4oMzthKR 1rO++FjIQ7OfOGb7q4zP79mVc6lzBaNx1X17URIuSSg8VnvpMkS4/9GZ//YHC+GrfjH5 SGeGLWO/ysYPIGqW/sz1t5aGqtihL0Hp7/BP5i//HFhbOsZq3BnFeEM+7D5FsjSZ5wGt bN/YEBSo0TyVwMDE119actB1JlFDMR8aVmCq8N+y1NWr1pfWTV+v4UDrfU8KXcv6MOKU KP7A== X-Forwarded-Encrypted: i=1; AHgh+Ro48qbi9NZFPnEPkQJg2Pgnc+fsAuVHjiWqoSn2ryUtJM72Rj77lQcsWVz8RSWzTHKAk1vwGUPQyzQXL2E=@vger.kernel.org X-Gm-Message-State: AOJu0YzhE5EX/SrvzrV0suS/lNCrw53N0OzObEvTqaSQeGeygcI7xEw/ hDuSLMm2h0b94g/B3KnshvLJmc2z6ZHKUooJy/In+vpSNC8ca5HZFEQ= X-Gm-Gg: AfdE7ck5YIbwtMWpSlORmL79iTcMc7QuMzezSHDv75kkRknjB+bOqABf0chz+5YEemm 6WBtXrB7NzwX5I26r+6uG7f3NpS5dE+6rqcGcsZx14N+C1LSEfomRGo/qHc4gs4mtI5jRGbT8gY 5YleCy5ae7AxNpEWLwumg3pEGySgpnSJZ+uFX/Ct1IdWHxYIYHbjylYgiCWzRGth1Mmg828s5rJ ToKBj4KOyU7ksHdseOk2oNlBz/eyg18o6L30FPDYkWxybPdIogas0K49pf7JYv1fZZEdEanfcGt QbPaeoWJHB40tgPOhzKPJ1/GlnSy27U6hCeOnrzN7qSDDkEerSFbrarWktbFT9VF5qopvExwzXd cctzipV3fXqoSII60bnArZDFh6CLAHg8YzqgL4py2KpWvedqFBwFAtQjMZY1OVSErYUustAWKAv dESRCkMRiO3MPk/V8OEV4WK4RFVxZgnHtZFSykhjR9 X-Received: by 2002:a05:6a20:1713:b0:3c3:8651:b302 with SMTP id adf61e73a8af0-3c3ad7ac447mr8585778637.28.1784484246013; Sun, 19 Jul 2026 11:04:06 -0700 (PDT) Received: from at-Standard-PC-Q35-ICH9-2009.. ([106.194.66.250]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3142a02b7f2sm27967645eec.13.2026.07.19.11.03.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jul 2026 11:04:05 -0700 (PDT) From: Atharva Tiwari To: Cc: Atharva Tiwari , Andre Eikmeyer , Bjorn Helgaas , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Andreas Noever , Mika Westerberg , Yehezkel Bernat , Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Jarkko Sakkinen , Mimi Zohar , Roberto Sassu , Dmitry Kasatkin , Eric Snowberg , Paul Moore , James Morris , "Serge E. Hallyn" , 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: [PATCH 2/2] thunderbolt: Add device links for Apple T2 NHI Date: Sun, 19 Jul 2026 14:03:04 -0400 Message-ID: <20260719180308.1398-3-atharvatiwarilinuxdev@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260719180308.1398-1-atharvatiwarilinuxdev@gmail.com> References: <20260719180308.1398-1-atharvatiwarilinuxdev@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Andre Eikmeyer 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. Co-developed-by: Atharva Tiwari Signed-off-by: Atharva Tiwari Signed-off-by: Andre Eikmeyer --- drivers/thunderbolt/tb.c | 49 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c index c69c323e6952..26529141573a 100644 --- a/drivers/thunderbolt/tb.c +++ b/drivers/thunderbolt/tb.c @@ -6,6 +6,7 @@ * Copyright (C) 2019, Intel Corporation */ =20 +#include #include #include #include @@ -3310,6 +3311,54 @@ static bool tb_apple_add_links(struct tb_nhi *nhi) if (!x86_apple_machine) return false; =20 + /* On T2 Macs. 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 (has_t2_chip) { + struct acpi_device *adev; + unsigned int slot, func; + const struct device_link *link; + const char *bid; + + for (slot =3D 0; slot < 32; slot++) { + for (func =3D 0; func < 8; func++) { + pdev =3D pci_get_slot(nhi->pdev->bus, PCI_DEVFN(slot, func)); + if (!pdev) + continue; + + if (!pci_is_pcie(pdev) || pci_pcie_type(pdev) !=3D + PCI_EXP_TYPE_ROOT_PORT) + goto put_pdev; + + adev =3D ACPI_COMPANION(&pdev->dev); + if (!adev) + goto put_pdev; + + bid =3D acpi_device_bid(adev); + if (!bid || strncmp(bid, "TRP", 3) !=3D 0) + goto put_pdev; + + link =3D device_link_add(&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(&pdev->dev)); + ret =3D true; + } else + dev_warn(&nhi->pdev->dev, + "device link creation from %s failed\n", + dev_name(&pdev->dev)); + +put_pdev: + pci_dev_put(pdev); + } + } + return ret; + } + switch (nhi->pdev->device) { case PCI_DEVICE_ID_INTEL_LIGHT_RIDGE: case PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_4C: --=20 2.43.0