Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH] PCI: Don't reset a VF through its hotplug slot
@ 2026-11-27  4:44 Samiullah Khawaja
  2026-11-27  4:54 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Samiullah Khawaja @ 2026-11-27  4:44 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Lukas Wunner, Alex Williamson, linux-pci, linux-kernel,
	Samiullah Khawaja, stable

pci_dev_reset_slot_function() doesn't do a slot reset of a multifunction
device, because the reset would also reset the other functions. A VF is
not marked as multifunction, so this check doesn't catch it.

A VF on the same bus as its PF gets the PF's hotplug slot, so behind a
pciehp port the VF has the "bus" reset method. A slot reset of the VF
also resets the PF and all other VFs, and only the VF's state is
restored afterwards.

Fixes: 10791141a6cf ("PCI: Simplify pci_dev_reset_slot_function()")
Cc: stable@vger.kernel.org
Signed-off-by: Samiullah Khawaja <skhawaja@google.com>
---
Tested in QEMU with an igb PF behind a pciehp root port, bound to
vfio-pci with two VFs. Without this patch the VFs have "flr bus" in
reset_method, and a bus reset of one VF also resets the PF and the other
VF. With it the VFs only have "flr".
---
 drivers/pci/pci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 7c6f2aba8144..16e970d26b51 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4994,7 +4994,8 @@ static int pci_dev_reset_slot_function(struct pci_dev *dev, bool probe)
 {
 	if (dev->subordinate || !dev->slot ||
 	    dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET ||
-	    (dev->multifunction && !dev->slot->per_func_slot))
+	    ((dev->multifunction || dev->is_virtfn) &&
+	     !dev->slot->per_func_slot))
 		return -ENOTTY;
 
 	return pci_reset_hotplug_slot(dev->slot->hotplug, probe);

base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
-- 
2.56.1.839.g22a8290db9-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-27  4:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27  4:44 [PATCH] PCI: Don't reset a VF through its hotplug slot Samiullah Khawaja
2026-11-27  4:54 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox