On Fri, 29 Jun 2018 15:09:34 -0500, Bjorn Helgaas wrote: > On Mon, Jun 18, 2018 at 03:01:42PM -0700, Jakub Kicinski wrote: > > Bjorn points out that currently core and most of the drivers don't > > clean up dev->sriov->driver_max_VFs settings on .remove(). This > > means that if a different driver is bound afterwards it will > > inherit the old setting: > > > > - load PF driver 1 > > - driver 1 calls pci_sriov_set_totalvfs() to reduce driver_max_VFs > > - unload PF driver 1 > > - load PF driver 2 > > # driver 2 does not know to call pci_sriov_set_totalvfs() > > > > Some drivers (e.g. nfp) used to do the clean up by calling > > pci_sriov_set_totalvfs(dev, 0), since 0 was equivalent to no driver > > limit set. After commit 8d85a7a4f2c9 ("PCI/IOV: Allow PF drivers > > to limit total_VFs to 0") 0 no longer has this special meaning. > > > > The need to reset driver_max_VFs comes from the fact that old FW > > builds may not expose its VF limits to the drivers, and depend on > > the ability to reject the configuration change when driver notifies > > the FW as part of struct pci_driver->sriov_configure() callback. > > Therefore if there is no information on VF count limits we should > > use the PCI capability max, and not the last value set by > > pci_sriov_set_totalvfs(). > > > > Reset driver_max_VFs back to total_VFs after device remove. If > > drivers want to reload FW/reconfigure the device while driver is > > bound we may add an explicit pci_sriov_reset_totalvfs(), but for > > now no driver is doing that. > > > > Fixes: 8d85a7a4f2c9 ("PCI/IOV: Allow PF drivers to limit total_VFs to 0") > > Signed-off-by: Jakub Kicinski <jakub.kicinski@xxxxxxxxxxxxx> > > Applied to for-linus for v4.18, thanks! Awesome, thanks a lot!