mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vidya Sagar <vidyas@nvidia.com>
To: Bjorn Helgaas <bhelgaas@google.com>,
	Dan Williams <djbw@kernel.org>,
	"Dave Jiang" <dave.jiang@intel.com>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>,
	Joerg Roedel <joerg.roedel@amd.com>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	"Nicolin Chen" <nicolinc@nvidia.com>,
	Kevin Tian <kevin.tian@intel.com>
Cc: <vsethi@nvidia.com>, <kthota@nvidia.com>,
	<mmaddireddy@nvidia.com>, <kumarahul@nvidia.com>,
	<sagar.tv@gmail.com>, <linux-pci@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, Vidya Sagar <vidyas@nvidia.com>
Subject: [PATCH V1 1/4] PCI/CXL: Don't offer 'cxl_bus' reset where a bus reset can't work
Date: Thu, 19 Nov 2026 15:36:25 +0530	[thread overview]
Message-ID: <20261119100628.1948990-2-vidyas@nvidia.com> (raw)
In-Reply-To: <20261119100628.1948990-1-vidyas@nvidia.com>

cxl_reset_bus_function() reports the "cxl_bus" reset method as supported
whenever the device's upstream bridge has a CXL Port DVSEC.  The reset
itself goes through pci_reset_bus_function(), which can only reset the
device through a hotplug slot or a Secondary Bus Reset of the parent
bridge.  It returns -ENOTTY when neither is possible, e.g., when other
functions share the device's bus, when the device is a bridge, or when it
has PCI_DEV_FLAGS_NO_BUS_RESET.

"cxl_bus" is then listed in "reset_method" but always fails.  For example,
on function 1 of a 4-function ConnectX-8 below a CXL-capable Root Port
without a hotplug slot, "bus" is correctly not offered, but "cxl_bus" is:

  # cat /sys/bus/pci/devices/0001:01:00.1/reset_method
  flr cxl_bus
  # echo cxl_bus > /sys/bus/pci/devices/0001:01:00.1/reset_method
  # echo 1 > /sys/bus/pci/devices/0001:01:00.1/reset
  bash: echo: write error: Inappropriate ioctl for device

Each attempt still temporarily sets "Unmask SBR" in the Root Port and runs
the IOMMU reset prepare/done hooks, although no reset happens.

Move the slot and parent bus reset from pci_reset_bus_function() into a
new __pci_reset_bus_function() and use it for the "cxl_bus" probe.  The
probe now makes the same slot and parent-bus checks as the "bus" probe.
"cxl_bus" is then offered under the same conditions as "bus", except for
the CXL SBR mask that "cxl_bus" exists to clear.

Fixes: 53c49b6e6dd2 ("PCI/CXL: Add 'cxl_bus' reset method for devices below CXL Ports")
Signed-off-by: Vidya Sagar <vidyas@nvidia.com>
---
 drivers/pci/pci.c | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 7c6f2aba8144..921d076c4c1d 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -5030,6 +5030,21 @@ static bool cxl_sbr_masked(struct pci_dev *dev)
 	return true;
 }
 
+/*
+ * Reset "dev" through its hotplug slot or, failing that, a Secondary Bus
+ * Reset of its parent bridge.  Callers deal with CXL SBR masking.
+ */
+static int __pci_reset_bus_function(struct pci_dev *dev, bool probe)
+{
+	int rc;
+
+	rc = pci_dev_reset_slot_function(dev, probe);
+	if (rc != -ENOTTY)
+		return rc;
+
+	return pci_parent_bus_reset(dev, probe);
+}
+
 static int pci_reset_bus_function(struct pci_dev *dev, bool probe)
 {
 	struct pci_dev *bridge = pci_upstream_bridge(dev);
@@ -5048,12 +5063,8 @@ static int pci_reset_bus_function(struct pci_dev *dev, bool probe)
 		return rc;
 	}
 
-	rc = pci_dev_reset_slot_function(dev, probe);
-	if (rc != -ENOTTY)
-		goto done;
+	rc = __pci_reset_bus_function(dev, probe);
 
-	rc = pci_parent_bus_reset(dev, probe);
-done:
 	pci_dev_reset_iommu_done(dev);
 	return rc;
 }
@@ -5072,8 +5083,12 @@ static int cxl_reset_bus_function(struct pci_dev *dev, bool probe)
 	if (!dvsec)
 		return -ENOTTY;
 
+	/*
+	 * Unmasking SBR only helps if a slot or bus reset can reach "dev" at
+	 * all, e.g., not when other functions share its bus.
+	 */
 	if (probe)
-		return 0;
+		return __pci_reset_bus_function(dev, probe);
 
 	rc = pci_read_config_word(bridge, dvsec + PCI_DVSEC_CXL_PORT_CTL, &reg);
 	if (rc)
-- 
2.43.0


  reply	other threads:[~2026-11-19 10:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 10:06 [PATCH V1 0/4] PCI: Don't list reset methods that can't reset the device Vidya Sagar
2026-11-19 10:06 ` Vidya Sagar [this message]
2026-11-19 10:06 ` [PATCH V1 2/4] PCI: Don't run IOMMU reset hooks when only probing reset methods Vidya Sagar
2026-11-19 10:06 ` [PATCH V1 3/4] PCI/sysfs: Take the device lock when setting " Vidya Sagar
2026-11-19 10:06 ` [PATCH V1 4/4] PCI: Re-check function 0 reset methods after scanning its slot Vidya Sagar

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=20261119100628.1948990-2-vidyas@nvidia.com \
    --to=vidyas@nvidia.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=bhelgaas@google.com \
    --cc=dave.jiang@intel.com \
    --cc=djbw@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=joerg.roedel@amd.com \
    --cc=kevin.tian@intel.com \
    --cc=kthota@nvidia.com \
    --cc=kumarahul@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mmaddireddy@nvidia.com \
    --cc=nicolinc@nvidia.com \
    --cc=sagar.tv@gmail.com \
    --cc=vsethi@nvidia.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

all inboxes | Powered by JetHome®