Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Geramy Loveless <gloveless@jqluv.com>
To: bhelgaas@google.com
Cc: mario.limonciello@amd.com, ilpo.jarvinen@linux.intel.com,
	christian.koenig@amd.com, cristi@ieee.org,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	Geramy Loveless <gloveless@jqluv.com>
Subject: [PATCH] PCI: mark Thunderbolt-attached devices as removable
Date: Tue, 28 Apr 2026 15:31:47 -0700	[thread overview]
Message-ID: <20260428223147.3092087-1-gloveless@jqluv.com> (raw)

pci_set_removable() only marks devices as removable if their upstream
bridge has the ACPI ExternalFacingPort property set.  Some firmware
(e.g. MSI MS-S1 MAX with AMD Strix Halo) does not set this property on
Thunderbolt root ports, so devices behind them are never marked
removable.  This causes all drivers that use dev_is_removable() to miss
eGPU-specific code paths.

Fall back to pci_is_thunderbolt_attached() when the parent is not
already marked removable.  set_pcie_thunderbolt() runs before
pci_set_removable() during device add, so the is_thunderbolt flag is
already available.

This fixes the problem at the PCI core level so all drivers benefit
from correct removable detection, not just individual drivers that add
their own Thunderbolt checks.

Signed-off-by: Geramy Loveless <gloveless@jqluv.com>
---
 drivers/pci/probe.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index bccc7a4bdd7..2387edc5b89 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1761,17 +1761,23 @@ static void pci_set_removable(struct pci_dev *dev)
 	if (!parent)
 		return;
 	/*
-	 * We (only) consider everything tunneled below an external_facing
-	 * device to be removable by the user. We're mainly concerned with
-	 * consumer platforms with user accessible thunderbolt ports that are
-	 * vulnerable to DMA attacks, and we expect those ports to be marked by
-	 * the firmware as external_facing. Devices in traditional hotplug
-	 * slots can technically be removed, but the expectation is that unless
-	 * the port is marked with external_facing, such devices are less
+	 * We consider everything tunneled below an external_facing device to
+	 * be removable by the user. We're mainly concerned with consumer
+	 * platforms with user accessible thunderbolt ports that are vulnerable
+	 * to DMA attacks, and we expect those ports to be marked by the
+	 * firmware as external_facing. Devices in traditional hotplug slots
+	 * can technically be removed, but the expectation is that unless the
+	 * port is marked with external_facing, such devices are less
 	 * accessible to user / may not be removed by end user, and thus not
 	 * exposed as "removable" to userspace.
+	 *
+	 * Some firmware does not set the ExternalFacingPort property on
+	 * Thunderbolt root ports.  In that case, fall back to checking
+	 * whether the device sits below a Thunderbolt controller, which
+	 * is itself inherently user-removable.
 	 */
-	if (dev_is_removable(&parent->dev)) {
+	if (dev_is_removable(&parent->dev) ||
+	    pci_is_thunderbolt_attached(dev)) {
 		dev_set_removable(&dev->dev, DEVICE_REMOVABLE);
 		return;
 	}
-- 
2.43.0


             reply	other threads:[~2026-04-28 22:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-28 22:31 Geramy Loveless [this message]
2026-05-05 16:00 ` [PATCH] PCI: mark Thunderbolt-attached devices as removable 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=20260428223147.3092087-1-gloveless@jqluv.com \
    --to=gloveless@jqluv.com \
    --cc=bhelgaas@google.com \
    --cc=christian.koenig@amd.com \
    --cc=cristi@ieee.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mario.limonciello@amd.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