Re: [PATCH v2] vfio/pci: Use a private flag to prevent power state change with VFs

From: Alex Williamson

Date: Fri May 22 2026 - 18:40:12 EST


On Thu, 14 May 2026 17:34:49 +0000
Raghavendra Rao Ananta <rananta@xxxxxxxxxx> wrote:

> The current implementation uses pci_num_vf() while holding the
> memory_lock to prevent changing the power state of a PF when
> VFs are enabled. This creates a lockdep circular dependency
> warning because memory_lock is held during device probing.
>
...
>
> Introduce a private flag 'sriov_active' in the vfio_pci_core_device
> struct. This allows the driver to track the SR-IOV power state requirement
> without relying on pci_num_vf() while holding the memory_lock. The lock is
> now only held to set the flag and ensure the device is in D0, after which
> pci_enable_sriov() can be called without the lock.
>
> Fixes: f4162eb1e2fc ("vfio/pci: Change the PF power state to D0 before enabling VFs")
> Cc: stable@xxxxxxxxxxxxxxx
> Suggested-by: Jason Gunthorpe <jgg@xxxxxxxx>
> Suggested-by: Alex Williamson <alex@xxxxxxxxxxx>
> Signed-off-by: Raghavendra Rao Ananta <rananta@xxxxxxxxxx>
> ---
> drivers/vfio/pci/vfio_pci_core.c | 17 ++++++++++++++---
> include/linux/vfio_pci_core.h | 1 +
> 2 files changed, 15 insertions(+), 3 deletions(-)

Applied to vfio next branch for v7.2, with the noted bitfield
conversion. Thanks,

Alex