Re: [PATCH v2 13/22] iommufd: Add mmap interface

Jason Gunthorpe
2025-05-07T12:40:17Z

On Tue, May 06, 2025 at 01:54:10PM -0700, Nicolin Chen wrote:

> Now I start to think about the FD situation: either a fault queue or
> an eventq returns an FD and holds a refcount on the event object. So
> the event object can't be destroyed unless the FD is released first.
> Are we doing it incorrectly here?

Not necessarily, and maybe that is a good point that we are already
doing these cross dependencies. But we could fix the FDs with some
work too.

> I see! It just needs to call that function when we remove the mmap
> for a vIOMMU destroy().

It is a little fussy to setup the inode as well, but yes.

The other small advantage is you don't need to setup a special VMA ops
and do VMA tracking to hold the refcount on the vqueue object.

But there is also any annoying race with unmap in setting up the mmap
PFNs which is why vfio is doing it from a fault handler..

So maybe refcount is the simplest option for now. We could fix it
later and it won't prevent close() from working right.

Jason