RFC vfio/pci: Disable sriov on PF device close
Get series with b4
b4 am [email protected]Versions newest first
- v1 RFC Latest1 patch 10 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/1 | vfio/pci: Disable sriov on PF device closedrivers/ | +7 | 10 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [RFC PATCH 0/1] vfio/pci: Disable sriov on PF device close
When userspace closes a VFIO device file descriptor, the vfio driver performs a hardware reset on the PCIe device to ensure it is returned to a clean state. However, if the closed device is an SR-IOV Physical Function (PF), it may have instantiated Virtual Functions (VFs) that are actively bound to host kernel drivers (or other vfio instances).
When the PF is hardware-reset via VFIO, it implicitly disrupts SR-IOV operations at the device level. Because this reset happens without notifying the core PCI driver model, the kernel drivers bound to the VFs remain loaded and operate under the assumption that the VF hardware is still functional.
This creates a state mismatch between the kernel's view of the hardware and the actual device state. Subsequent attempts by the host OS or bound drivers to interact with the VFs will fail, leading to unexpected errors.
Disabling SRIOV before resetting the device avoids this issue by tearing down the VFs and removing the VF devices.
The fix in this patch only disables SRIOV on PF reset for devices bound to vfio-pci drivers. But this probably needs a fix for kernel drivers also, maybe return -EBUSY when SRIOV is enabled?
Looking forward to your feedback on this.
---
Samiullah Khawaja (1):
vfio/pci: Disable sriov on PF device close
drivers/vfio/pci/vfio_pci_core.c | 7 +++++++ 1 file changed, 7 insertions(+)
base-commit: 0f6da28aab51b16762ed82e8fdeaa5042da45b08
Signature · 1 line
2.55.0.629.g250fe7f194-goog