[PATCH] PCI: Don't reset a VF through its hotplug slot

From: Samiullah Khawaja

Date: Thu Nov 26 2026 - 23:45:08 EST


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@xxxxxxxxxxxxxxx
Signed-off-by: Samiullah Khawaja <skhawaja@xxxxxxxxxx>
---
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