[PATCH] vfio/pds: Fix missing detach_ioas op

Brett Creeley posted 1 patch 3 months, 1 week ago
drivers/vfio/pci/pds/vfio_dev.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] vfio/pds: Fix missing detach_ioas op
Posted by Brett Creeley 3 months, 1 week ago
When CONFIG_IOMMUFD is enabled and a device is bound to the pds_vfio_pci
driver, the following WARN_ON() trace is seen and probe fails:

WARNING: CPU: 0 PID: 5040 at drivers/vfio/vfio_main.c:317 __vfio_register_dev+0x130/0x140 [vfio]
<...>
pds_vfio_pci 0000:08:00.1: probe with driver pds_vfio_pci failed with error -22

This is because the driver's vfio_device_ops.detach_ioas isn't set.

Fix this by using the generic vfio_iommufd_physical_detach_ioas
function.

Fixes: 38fe3975b4c2 ("vfio/pds: Initial support for pds VFIO driver")
Signed-off-by: Brett Creeley <brett.creeley@amd.com>
---
 drivers/vfio/pci/pds/vfio_dev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/vfio/pci/pds/vfio_dev.c b/drivers/vfio/pci/pds/vfio_dev.c
index 76a80ae7087b..f6e0253a8a14 100644
--- a/drivers/vfio/pci/pds/vfio_dev.c
+++ b/drivers/vfio/pci/pds/vfio_dev.c
@@ -204,6 +204,7 @@ static const struct vfio_device_ops pds_vfio_ops = {
 	.bind_iommufd = vfio_iommufd_physical_bind,
 	.unbind_iommufd = vfio_iommufd_physical_unbind,
 	.attach_ioas = vfio_iommufd_physical_attach_ioas,
+	.detach_ioas = vfio_iommufd_physical_detach_ioas,
 };
 
 const struct vfio_device_ops *pds_vfio_ops_info(void)
-- 
2.17.1
Re: [PATCH] vfio/pds: Fix missing detach_ioas op
Posted by Alex Williamson 2 months, 4 weeks ago
On Wed, 2 Jul 2025 09:37:44 -0700
Brett Creeley <brett.creeley@amd.com> wrote:

> When CONFIG_IOMMUFD is enabled and a device is bound to the pds_vfio_pci
> driver, the following WARN_ON() trace is seen and probe fails:
> 
> WARNING: CPU: 0 PID: 5040 at drivers/vfio/vfio_main.c:317 __vfio_register_dev+0x130/0x140 [vfio]
> <...>
> pds_vfio_pci 0000:08:00.1: probe with driver pds_vfio_pci failed with error -22
> 
> This is because the driver's vfio_device_ops.detach_ioas isn't set.
> 
> Fix this by using the generic vfio_iommufd_physical_detach_ioas
> function.
> 
> Fixes: 38fe3975b4c2 ("vfio/pds: Initial support for pds VFIO driver")
> Signed-off-by: Brett Creeley <brett.creeley@amd.com>
> ---
>  drivers/vfio/pci/pds/vfio_dev.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/vfio/pci/pds/vfio_dev.c b/drivers/vfio/pci/pds/vfio_dev.c
> index 76a80ae7087b..f6e0253a8a14 100644
> --- a/drivers/vfio/pci/pds/vfio_dev.c
> +++ b/drivers/vfio/pci/pds/vfio_dev.c
> @@ -204,6 +204,7 @@ static const struct vfio_device_ops pds_vfio_ops = {
>  	.bind_iommufd = vfio_iommufd_physical_bind,
>  	.unbind_iommufd = vfio_iommufd_physical_unbind,
>  	.attach_ioas = vfio_iommufd_physical_attach_ioas,
> +	.detach_ioas = vfio_iommufd_physical_detach_ioas,
>  };
>  
>  const struct vfio_device_ops *pds_vfio_ops_info(void)

Applied to vfio next branch for v6.17.  Thanks,

Alex
RE: [PATCH] vfio/pds: Fix missing detach_ioas op
Posted by Tian, Kevin 3 months ago
> From: Brett Creeley <brett.creeley@amd.com>
> Sent: Thursday, July 3, 2025 12:38 AM
> 
> When CONFIG_IOMMUFD is enabled and a device is bound to the
> pds_vfio_pci
> driver, the following WARN_ON() trace is seen and probe fails:
> 
> WARNING: CPU: 0 PID: 5040 at drivers/vfio/vfio_main.c:317
> __vfio_register_dev+0x130/0x140 [vfio]
> <...>
> pds_vfio_pci 0000:08:00.1: probe with driver pds_vfio_pci failed with error -
> 22
> 
> This is because the driver's vfio_device_ops.detach_ioas isn't set.
> 
> Fix this by using the generic vfio_iommufd_physical_detach_ioas
> function.
> 
> Fixes: 38fe3975b4c2 ("vfio/pds: Initial support for pds VFIO driver")
> Signed-off-by: Brett Creeley <brett.creeley@amd.com>

It's a surprise to see it caught so late...

Reviewed-by: Kevin Tian <kevin.tian@intel.com>