Re: [PATCH v2 5/5] vfio/pci: Latch all module parameters per device
From: fengchengwen
Date: Fri Jun 12 2026 - 04:43:17 EST
On 6/12/2026 5:35 AM, Alex Williamson wrote:
> The vfio-pci module parameters of disable_idle_d3, nointxmask, and
> disable_vga latch vfio-pci policy into vfio-pci-core globals each time
> the vfio-pci module is initialized. The disable_idle_d3 parameter has
> already migrated to a per-device flag in order to provide consistency
> for refcounted PM operations for the lifetime of the device
> registration.
>
> Pull the remaining vfio-pci module-parameter policy out of vfio-pci-core
> into per-device flags set at device initialization.
>
> This also restores the mutable aspect of the disable_idle_d3 and
> nointxmask module parameters for vfio-pci, with the caveat that the
> parameters are latched into the device at probe.
>
> A notable change for variant drivers is that their devices are no longer
> affected by vfio-pci module parameters and those drivers may need to
> adopt similar module parameters if any devices have a hidden dependency
> on vfio-pci setting non-default policy.
>
> Assisted-by: Claude:claude-opus-4-8
> Signed-off-by: Alex Williamson <alex.williamson@xxxxxxxxxx>
> ---
> drivers/vfio/pci/vfio_pci.c | 30 ++++++++++++++++++++++--------
> drivers/vfio/pci/vfio_pci_core.c | 26 ++++++--------------------
> include/linux/vfio_pci_core.h | 4 ++--
> 3 files changed, 30 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
> index 0c771064c0b8..830369ff878d 100644
> --- a/drivers/vfio/pci/vfio_pci.c
> +++ b/drivers/vfio/pci/vfio_pci.c
> @@ -125,9 +125,30 @@ static int vfio_pci_open_device(struct vfio_device *core_vdev)
> return 0;
> }
>
> +static int vfio_pci_init_dev(struct vfio_device *core_vdev)
> +{
> + struct vfio_pci_core_device *vdev =
> + container_of(core_vdev, struct vfio_pci_core_device, vdev);
> +
> + /*
> + * These behaviors originated in vfio-pci and moved into
> + * vfio-pci-core when the driver was split; vfio-pci remains the
> + * only driver that toggles them. Latch our module parameters per
> + * device at init time so that later parameter changes do not
> + * affect already-initialized devices.
> + */
> + vdev->nointxmask = nointxmask;
> + vdev->disable_idle_d3 = disable_idle_d3;
> +#ifdef CONFIG_VFIO_PCI_VGA
> + vdev->disable_vga = disable_vga;
Since nointxmask and disable_idle_d3 already have S_IWUSR and share the same
"latch per device at init" behavior, it would be better to also add S_IWUSR
to disable_vga for permission and behavior consistency.
Runtime writes will only affect future devices, existing devices keep their
latched value, so no extra risk.
...