Subject: Re: [PATCH V1 vfio 03/11] vfio: Introduce DMA logging uAPIs

From: Jason Gunthorpe <[email-masked]>
Date: Wed, 6 Jul 2022 21:30:43 -0300

On Wed, Jul 06, 2022 at 05:11:37PM -0600, Alex Williamson wrote:
> > +struct vfio_device_feature_dma_logging_control {
> > +	__aligned_u64 page_size;
> > +	__u32 num_ranges;
> > +	__u32 __reserved;
> > +	__aligned_u64 ranges;
> > +};
> 
> num_ranges probably has a limit below 2^32-1, is it device specific?
> How does the user learn the limit?

The driver is expected to groom the provided ranges to meet whatever
limitations the device happens to have. eg expand to fix misalignment,
cluster to fit in the available tracking, increase page size, etc.

The next patch has a small algorithm that works with mlx5's limits.

This way we avoid trying to explain to userspace every possible device
quirk.

eg if the device support one range it should take the lowest and
highest address, fix the alignment, and use that. If that doesn't work
then tracking isn't supported in the configuration.

> Presumably new ranges cannot be added while logging is already enabled,
> should we build this limitation into the uAPI or might some devices
> have the ability to dynamically add and remove logging ranges?  Thanks,

If we see a device that can do dynamic then we'd add a new ioctl for
'add/remove' ranges along with a feature bit for the capability. mlx5
doesn't support that so we aren't adding uapi that isn't implemented..

Jason