Skip to content

Commit 9ec19bf

Browse files
ij-intelbjorn-helgaas
authored andcommitted
PCI: Fix BAR resizing when VF BARs are assigned
__resource_resize_store() attempts to release all resources of the device before attempting the resize. The loop, however, only covers standard BARs (< PCI_STD_NUM_BARS). If a device has VF BARs that are assigned, pci_reassign_bridge_resources() finds the bridge window still has some assigned child resources and returns -NOENT which makes pci_resize_resource() to detect an error and abort the resize. Change the release loop to cover all resources up to VF BARs which allows the resize operation to release the bridge windows and attempt to assigned them again with the different size. If SR-IOV is enabled, disallow resize as it requires releasing also IOV resources. Link: https://lore.kernel.org/r/20250320142837.8027-1-ilpo.jarvinen@linux.intel.com Fixes: 91fa127 ("PCI: Expose PCIe Resizable BAR support via sysfs") Reported-by: Michał Winiarski <michal.winiarski@intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Alex Williamson <alex.williamson@redhat.com>
1 parent e4cb293 commit 9ec19bf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/pci/pci-sysfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,7 @@ static ssize_t __resource_resize_store(struct device *dev, int n,
15561556
return -EINVAL;
15571557

15581558
device_lock(dev);
1559-
if (dev->driver) {
1559+
if (dev->driver || pci_num_vf(pdev)) {
15601560
ret = -EBUSY;
15611561
goto unlock;
15621562
}
@@ -1578,7 +1578,7 @@ static ssize_t __resource_resize_store(struct device *dev, int n,
15781578

15791579
pci_remove_resource_files(pdev);
15801580

1581-
for (i = 0; i < PCI_STD_NUM_BARS; i++) {
1581+
for (i = 0; i < PCI_BRIDGE_RESOURCES; i++) {
15821582
if (pci_resource_len(pdev, i) &&
15831583
pci_resource_flags(pdev, i) == flags)
15841584
pci_release_resource(pdev, i);

0 commit comments

Comments
 (0)