Re: [RFC v2 1/2] vfio: add callback to get tph info for dmabuf

Leon Romanovsky
2026-03-31T08:39:40Z

On Thu, Mar 26, 2026 at 03:55:44PM -0700, Zhiping Zhang wrote:
> On Thu, Mar 26, 2026 at 3:41 PM Keith Busch <kbusch@kernel.org> wrote:
> >
> > >
> > On Wed, Mar 25, 2026 at 10:25:34AM +0200, Leon Romanovsky wrote:
> > > On Tue, Mar 24, 2026 at 04:46:02PM -0700, Zhiping Zhang wrote:
> > > > struct vfio_device_feature_dma_buf {
> > > > __u32 region_index;
> > > > __u32 open_flags;
> > > > - __u32 flags;
> > > > - __u32 nr_ranges;
> > > > + __u32 flags;
> > > > +#define VFIO_DMABUF_FL_TPH (1U << 0) /* TPH info is present */
> > > > +#define VFIO_DMABUF_TPH_PH_SHIFT 1 /* bits 1-2: PH (2-bit) */
> > > > +#define VFIO_DMABUF_TPH_PH_MASK 0x6U
> > > > +#define VFIO_DMABUF_TPH_ST_SHIFT 16 /* bits 16-31: steering tag */
> > > > +#define VFIO_DMABUF_TPH_ST_MASK 0xffff0000U
> > >
> > > This extension of flags is basically kills future extension of this
> > > struct for anything that includes TPH.
> > >
> > > Add new
> > > enum vfio_device_feature_dma_buf_flags {
> > > VFIO_DMABUF_FL_TPH = 1 << 0
> > > }
>
> yes we can do that.
>
> > >
> > > > + __u32 nr_ranges;
> > >
> > > add your "__u16 steering_tag" and "__u8 ph" fields here.
> >
> That is what I did in V1, Leon.

Not really, you did only half of the work. You didn't introduce new flag
and didn't calculate "old dma range" position.

Thanks