[PATCH v2 0/3] PCI/IOV: Restore initial VF BAR sizing after VF ReBAR

From: Marcin Bernatowicz

Date: Mon Aug 03 2026 - 06:38:29 EST


PF drivers can resize a VF BAR using VF Resizable BAR (ReBAR) support via
pci_iov_vf_bar_set_size(). The new size persists in the SR-IOV capability
config space. A later reprobe / unplug-rescan / next pci_enable_sriov()
then sees the inflated VF BAR registers, and the PCI core reserves MMIO
based on that size multiplied by TotalVFs.

On platforms with tight apertures, this can make subsequent SR-IOV enable
fail due to lack of address space.

This series records the initial per-VF BAR sizes during SR-IOV init and
restores those sizes when SR-IOV is disabled, when SR-IOV enable fails,
or when the PF driver is detached.

Note on user-visible behavior: drivers that rely on a resized VF BAR
persisting across an enable/disable cycle must now call
pci_iov_vf_bar_set_size() again before each pci_enable_sriov().

v1 -> v2:
- Addressed sashiko-bot feedback.
- Restore VF BAR sizes on early sriov_enable() validation failures too.
- Move the detach-time restore from sriov_release() to pci_iov_remove().

Marcin Bernatowicz (3):
PCI/IOV: Remember initial VF BAR sizes
PCI/IOV: Restore initial VF ReBAR sizes on SR-IOV disable/failure
PCI/IOV: Restore initial VF ReBAR sizes on PF driver remove

drivers/pci/iov.c | 86 ++++++++++++++++++++++++++++++++++++++++-------
drivers/pci/pci.h | 3 +-
2 files changed, 76 insertions(+), 13 deletions(-)

--
2.43.0