From: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>
To: linux-hyperv@vger.kernel.org
Cc: "Haiyang Zhang" <haiyangz@microsoft.com>,
"Wei Liu" <wei.liu@kernel.org>,
"Dexuan Cui" <decui@microsoft.com>,
"Jonathan Corbet" <corbet@lwn.net>,
"Randy Dunlap" <rdunlap@infradead.org>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
linux-doc@vger.kernel.org, linux-pci@vger.kernel.org,
"Hamza Mahfooz" <hamzamahfooz@linux.microsoft.com>
Subject: [PATCH 1/2] PCI: use reset_root_port() for bus reset of devices on a root bus
Date: Fri, 16 Oct 2026 19:59:39 -0400 [thread overview]
Message-ID: <20261016235940.942090-1-hamzamahfooz@linux.microsoft.com> (raw)
The "bus" reset method resets a device by asserting Secondary Bus Reset
on its upstream bridge, so it is not available for a device on a root
bus, which has no upstream bridge.
Some platforms have no Root Ports and expose PCI devices directly on a
root bus, e.g., Hyper-V vPCI places each assigned PCI function directly
on the root bus of a virtual host bridge. Such a device has no reset
method at all if it supports neither FLR nor PM reset, even if the
platform is able to reset it.
pci_host_bridge::reset_root_port() already allows a host bridge to reset
a device on a root bus in a platform-specific way, so far only in place
of a Secondary Bus Reset by a Root Port. Use it for the "bus" reset
method of a device that is the only device on a root bus, and wait for
the device to become ready afterwards, as is done for other reset
methods.
Signed-off-by: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>
---
drivers/pci/pci.c | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 8cc6a89130b5..fd4e958d6b99 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4924,18 +4924,46 @@ int pci_bridge_secondary_bus_reset(struct pci_dev *dev)
}
EXPORT_SYMBOL_GPL(pci_bridge_secondary_bus_reset);
+static int pci_root_bus_reset(struct pci_dev *dev, bool probe)
+{
+ struct pci_host_bridge *host = pci_find_host_bridge(dev->bus);
+ int rc;
+
+ /*
+ * Bridges, e.g., Root Ports, are not eligible. Check the header type
+ * because dev->subordinate is not set up yet when the reset methods
+ * are probed during enumeration.
+ */
+ if (pci_is_bridge(dev) || !host->reset_root_port)
+ return -ENOTTY;
+
+ if (probe)
+ return 0;
+
+ rc = host->reset_root_port(host, dev);
+ if (rc)
+ return rc;
+
+ return pci_dev_wait(dev, "bus reset", PCIE_RESET_READY_POLL_MS);
+}
+
static int pci_parent_bus_reset(struct pci_dev *dev, bool probe)
{
struct pci_dev *pdev;
- if (pci_is_root_bus(dev->bus) || dev->subordinate ||
- !dev->bus->self || dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET)
+ if (dev->subordinate || dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET)
return -ENOTTY;
list_for_each_entry(pdev, &dev->bus->devices, bus_list)
if (pdev != dev)
return -ENOTTY;
+ if (pci_is_root_bus(dev->bus))
+ return pci_root_bus_reset(dev, probe);
+
+ if (!dev->bus->self)
+ return -ENOTTY;
+
if (probe)
return 0;
--
2.56.0
next reply other threads:[~2026-10-17 0:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 23:59 Hamza Mahfooz [this message]
2026-10-16 23:59 ` [PATCH 2/2] PCI: hv: add vPCI device reset support Hamza Mahfooz
2026-10-17 0:12 ` sashiko-bot
2026-10-17 0:07 ` [PATCH 1/2] PCI: use reset_root_port() for bus reset of devices on a root bus sashiko-bot
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=20261016235940.942090-1-hamzamahfooz@linux.microsoft.com \
--to=hamzamahfooz@linux.microsoft.com \
--cc=bhelgaas@google.com \
--cc=corbet@lwn.net \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=kwilczynski@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=rdunlap@infradead.org \
--cc=robh@kernel.org \
--cc=wei.liu@kernel.org \
/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