[PATCH 0/2] PCI/IOV: Add missing PCI rescan-remove locking when enabling/disabling SR-IOV

Niklas Schnelle posted 2 patches 1 month, 1 week ago
drivers/pci/iov.c    | 5 +++++
drivers/pci/pci.h    | 2 ++
drivers/pci/probe.c  | 2 +-
drivers/pci/remove.c | 1 +
4 files changed, 9 insertions(+), 1 deletion(-)
[PATCH 0/2] PCI/IOV: Add missing PCI rescan-remove locking when enabling/disabling SR-IOV
Posted by Niklas Schnelle 1 month, 1 week ago
Hi Bjorn, Hi Lukas,

This series fixes missing PCI rescan-remove locking in sriov_disable()
and sriov_enable() the former of which was observed to cause a double
remove / list corruption on s390. The first patch is the fix itself and
gives more details while the second patch is an optional proposal to add
a lockdep assertion to pci_stop_and_remove_bus_device() to catch missing
rescan-remove locking more easily in the future. If applied without the
first patch disabling SR-IOV via "echo 0 > /sys/bus/pci/devices/<dev>
/sriov_numvfs" triggers the lockdep assertion. I haven't found an easy
way to trigger the assertion in the sriov_enable() case but I checked
callers.

Also since the sriov_add_vfs() path is not excercised on s390 due to
pdev->no_vf_scan I did some basic testing on an x86 test system with an
SR-IOV capable ConnectX-6 DX NIC.

Thanks,
Niklas

Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
---
Niklas Schnelle (2):
      PCI/IOV: Add missing PCI rescan-remove locking when enabling/disabling SR-IOV
      PCI: Add lockdep assertion in pci_stop_and_remove_bus_device()

 drivers/pci/iov.c    | 5 +++++
 drivers/pci/pci.h    | 2 ++
 drivers/pci/probe.c  | 2 +-
 drivers/pci/remove.c | 1 +
 4 files changed, 9 insertions(+), 1 deletion(-)
---
base-commit: 1b237f190eb3d36f52dffe07a40b5eb210280e00
change-id: 20250821-pci_fix_sriov_disable-552f29c822dd

Best regards,
-- 
Niklas Schnelle
Re: [PATCH 0/2] PCI/IOV: Add missing PCI rescan-remove locking when enabling/disabling SR-IOV
Posted by Bjorn Helgaas 6 days, 21 hours ago
On Tue, Aug 26, 2025 at 10:52:07AM +0200, Niklas Schnelle wrote:
> Hi Bjorn, Hi Lukas,
> 
> This series fixes missing PCI rescan-remove locking in sriov_disable()
> and sriov_enable() the former of which was observed to cause a double
> remove / list corruption on s390. The first patch is the fix itself and
> gives more details while the second patch is an optional proposal to add
> a lockdep assertion to pci_stop_and_remove_bus_device() to catch missing
> rescan-remove locking more easily in the future. If applied without the
> first patch disabling SR-IOV via "echo 0 > /sys/bus/pci/devices/<dev>
> /sriov_numvfs" triggers the lockdep assertion. I haven't found an easy
> way to trigger the assertion in the sriov_enable() case but I checked
> callers.
> 
> Also since the sriov_add_vfs() path is not excercised on s390 due to
> pdev->no_vf_scan I did some basic testing on an x86 test system with an
> SR-IOV capable ConnectX-6 DX NIC.
> 
> Thanks,
> Niklas
> 
> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
> ---
> Niklas Schnelle (2):
>       PCI/IOV: Add missing PCI rescan-remove locking when enabling/disabling SR-IOV
>       PCI: Add lockdep assertion in pci_stop_and_remove_bus_device()
> 
>  drivers/pci/iov.c    | 5 +++++
>  drivers/pci/pci.h    | 2 ++
>  drivers/pci/probe.c  | 2 +-
>  drivers/pci/remove.c | 1 +
>  4 files changed, 9 insertions(+), 1 deletion(-)

Applied to pci/virtualization, hoping to squeeze into v6.18.