Re: [PATCH v2 1/1] PCI: Fix BAR resizing when VF BARs are assigned

From: Alex Williamson
Date: Tue Mar 18 2025 - 11:08:46 EST


On Tue, 18 Mar 2025 13:42:57 +0200 (EET)
Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx> wrote:

> + Jakub
> + Alexander
>
> On Mon, 17 Mar 2025, Alex Williamson wrote:
> > On Mon, 17 Mar 2025 19:18:03 +0100
> > Michał Winiarski <michal.winiarski@xxxxxxxxx> wrote:
> > > On Fri, Mar 14, 2025 at 08:56:49AM -0600, Alex Williamson wrote:
> > > > On Fri, 7 Mar 2025 16:03:49 +0200
> > > > Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx> wrote:
> > > >
> > > > > __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.
> > > > >
> > > > > 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.
> > > >
> > > > Is this true? pci-pf-stub doesn't teardown SR-IOV on release, which I
> > > > understand is done intentionally. Thanks,
>
> Thanks for reviewing. I'm sorry I just took Michał's word on this for
> granted so I didn't check it myself.
>
> I could amend __resource_resize_store() to return -EBUSY if SR-IOV is
> there despite no driver being present

I probably never really considered resizing BARs for an SR-IOV capable
device when adding this support originally, but it seems valid to me
that if we extend releasing resources to the SR-IOV BARs that we simply
need to assert that SR-IOV is disabled and fail otherwise. Thanks,

Alex