[PATCH v2 1/3] PCI/IOV: Remember initial VF BAR sizes
Marcin Bernatowicz <[email protected]> Mon, 3 Aug 2026 12:30:05 +0200
| Newsgroups | org.freedesktop.lists.intel-xe,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pci |
|---|---|
| Message-ID | <[email protected]> |
SR-IOV initialization records the per-VF BAR sizes derived from the VF BAR registers in the SR-IOV capability. PF drivers may later change VF BAR sizes using VF Resizable BAR support (pci_iov_vf_bar_set_size()). Save the initial per-VF BAR sizes so later code can restore them when SR-IOV is disabled, when SR-IOV enable fails, or when the PF driver is unbound while VF BARs are still resized. The initial size is captured before the resource is multiplied by TotalVFs, so it represents one VF's BAR size as advertised by hardware. No functional change on its own. Signed-off-by: Marcin Bernatowicz <[email protected]> --- drivers/pci/iov.c | 1 + drivers/pci/pci.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index b0d24839c084..ae9309fc6dd7 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -869,6 +869,7 @@ static int sriov_init(struct pci_dev *dev, int pos) goto failed; } iov->barsz[i] = resource_size(res); + iov->barsz_orig[i] = iov->barsz[i]; resource_set_size(res, resource_size(res) * total); pci_info(dev, "%s %pR: contains BAR %d for %d VFs\n", res_name, res, i, total); diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 68b5fb675d1c..71c0d9fe5524 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -713,7 +713,8 @@ struct pci_sriov { u8 hdr_type; /* VF header type */ u16 subsystem_vendor; /* VF subsystem vendor */ u16 subsystem_device; /* VF subsystem device */ - resource_size_t barsz[PCI_SRIOV_NUM_BARS]; /* VF BAR size */ + resource_size_t barsz[PCI_SRIOV_NUM_BARS]; /* Current VF BAR size */ + resource_size_t barsz_orig[PCI_SRIOV_NUM_BARS]; /* Initial VF BAR size at probe */ u16 vf_rebar_cap; /* VF Resizable BAR capability offset */ bool drivers_autoprobe; /* Auto probing of VFs by driver */ }; -- 2.43.0