On Tue, 12 Nov 2024, Christian König wrote: > Am 12.11.24 um 14:42 schrieb Ilpo Järvinen: > > __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. > > > Looks good in general, but a couple of comments. > > Similarly, an assigned Expansion ROM resource prevents the resize. > > > Expansion ROMs were intentionally left untouched by the initial patch since those are > usually 32bit resources and the resize was implemented only for 64bit BARs. > > Change the release loop to cover both the VF BARs and Expansion ROM > which allows the resize operation to release the bridge windows and > attempt to assigned them again with the different size. > > > I'm not sure if Expansion ROMs should be touched here. Those are 32bit resources > usually and notoriously broken in the ACPI tables. > > What I've seen multiple times that after releasing them you can't move nor assign > them again to their original position. > > Background is that some ACPI table denotes the location of the ROM as reserved and we > only accept the Expansion ROM at that location because of a quirk (which is of course > not applied when you resize). > > On the other hand do we have use cases for resizing 32bit BARs? So far we resized > those only by accident. Thanks for taking a look! This is not about resizing 32bit BARs. Is that somehow enforced so they cannot end up into the same bridge window? Because we can only resize a bridge window if we release all its child resources. > As __resource_resize_store() checks first that no driver is bound to > the PCI device before resizing is allowed, SR-IOV cannot be enabled > during resize so it is safe to release also the IOV resources. > > Fixes: 8bb705e3e79d ("PCI: Add pci_resize_resource() for resizing BARs") > > > The code in question was added by 91fa127794ac ("PCI: Expose PCIe Resizable BAR > support via sysfs"). Oh right. I don't know why I ended up picking that other commit (sure, I was also looking that other diff but maybe it was just a copy-paste error). -- i. > Regards, > Christian. > > Reported-by: Michał Winiarski <michal.winiarski@xxxxxxxxx> > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx> > --- > drivers/pci/pci-sysfs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c > index 5d0f4db1cab7..80b01087d3ef 100644 > --- a/drivers/pci/pci-sysfs.c > +++ b/drivers/pci/pci-sysfs.c > @@ -1440,7 +1440,7 @@ static ssize_t __resource_resize_store(struct device *dev, int > n, > > pci_remove_resource_files(pdev); > > - for (i = 0; i < PCI_STD_NUM_BARS; i++) { > + for (i = 0; i < PCI_BRIDGE_RESOURCES; i++) { > if (pci_resource_len(pdev, i) && > pci_resource_flags(pdev, i) == flags) > pci_release_resource(pdev, i); > > > >