Subject: Re: [PATCH v2 07/11] vfio: selftests: Allow drivers to specify required region size

From: Jason Gunthorpe <[email-masked]>
Date: Fri, 29 May 2026 14:37:53 -0300

On Thu, May 28, 2026 at 06:59:38PM +0000, David Matlack wrote:
> diff --git a/tools/testing/selftests/vfio/lib/vfio_pci_driver.c b/tools/testing/selftests/vfio/lib/vfio_pci_driver.c
> index 6827f4a6febe..c70c22b1a86c 100644
> --- a/tools/testing/selftests/vfio/lib/vfio_pci_driver.c
> +++ b/tools/testing/selftests/vfio/lib/vfio_pci_driver.c
> @@ -28,6 +28,9 @@ void vfio_pci_driver_probe(struct vfio_pci_device *device)
>                         continue;
> 
>                 device->driver.ops = ops;
> +
> +               VFIO_ASSERT_NE(ops->region_size, 0);
> +               device->driver.region.size = roundup(ops->region_size, getpagesize());

Almost, the iova allocator insists on power of 2 :

/home/jgg/oss/wip/mlx5st/tools/testing/selftests/vfio/lib/iova_allocator.c:54: Assertion Failure

  Expression: size & (size - 1) == 0
  Observed: 0x200c000 == 0
  [errno: 0 - Success]
  Invalid size arg, non-power-of-2

So I left it with the max

		VFIO_ASSERT_NE(ops->region_size, 0);
		device->driver.region.size =
			max_t(u64, roundup_pow_of_two(ops->region_size),
			      getpagesize());

Thanks,
Jason