Re: [RFC PATCH 05/10] vfio: Create a vfio_device from vma lookup

2021-03-04 Thread Jason Gunthorpe
On Thu, Mar 04, 2021 at 05:07:31PM -0700, Alex Williamson wrote: > On Thu, 4 Mar 2021 19:16:33 -0400 > Jason Gunthorpe wrote: > > > On Thu, Mar 04, 2021 at 02:37:57PM -0700, Alex Williamson wrote: > > > > > Therefore unless a bus driver opts-out by replacing vm_private_data, we > > > can

Re: [RFC PATCH 05/10] vfio: Create a vfio_device from vma lookup

2021-03-04 Thread Alex Williamson
On Thu, 4 Mar 2021 19:16:33 -0400 Jason Gunthorpe wrote: > On Thu, Mar 04, 2021 at 02:37:57PM -0700, Alex Williamson wrote: > > > Therefore unless a bus driver opts-out by replacing vm_private_data, we > > can identify participating vmas by the vm_ops and have flags indicating > > if the vma

Re: [RFC PATCH 05/10] vfio: Create a vfio_device from vma lookup

2021-03-04 Thread Jason Gunthorpe
On Thu, Mar 04, 2021 at 02:37:57PM -0700, Alex Williamson wrote: > Therefore unless a bus driver opts-out by replacing vm_private_data, we > can identify participating vmas by the vm_ops and have flags indicating > if the vma maps device memory such that vfio_get_device_from_vma() > should

Re: [RFC PATCH 05/10] vfio: Create a vfio_device from vma lookup

2021-03-04 Thread Alex Williamson
On Thu, 25 Feb 2021 19:49:49 -0400 Jason Gunthorpe wrote: > On Thu, Feb 25, 2021 at 03:21:13PM -0700, Alex Williamson wrote: > > > This is where it gets tricky. The vm_pgoff we get from > > file_operations.mmap is already essentially describing an offset from > > the base of a specific

Re: [RFC PATCH 05/10] vfio: Create a vfio_device from vma lookup

2021-02-25 Thread Jason Gunthorpe
On Thu, Feb 25, 2021 at 03:21:13PM -0700, Alex Williamson wrote: > This is where it gets tricky. The vm_pgoff we get from > file_operations.mmap is already essentially describing an offset from > the base of a specific resource. We could convert that from an absolute > offset to a pfn offset,

Re: [RFC PATCH 05/10] vfio: Create a vfio_device from vma lookup

2021-02-25 Thread Alex Williamson
On Wed, 24 Feb 2021 20:06:10 -0400 Jason Gunthorpe wrote: > On Wed, Feb 24, 2021 at 02:55:06PM -0700, Alex Williamson wrote: > > > > The only use of the special ops would be if there are multiple types > > > of mmap's going on, but for this narrow use case those would be safely > > >

Re: [RFC PATCH 05/10] vfio: Create a vfio_device from vma lookup

2021-02-24 Thread Jason Gunthorpe
On Wed, Feb 24, 2021 at 02:55:06PM -0700, Alex Williamson wrote: > > The only use of the special ops would be if there are multiple types > > of mmap's going on, but for this narrow use case those would be safely > > distinguished by the vm_pgoff instead > > We potentially do have device

Re: [RFC PATCH 05/10] vfio: Create a vfio_device from vma lookup

2021-02-24 Thread Alex Williamson
On Mon, 22 Feb 2021 13:29:13 -0400 Jason Gunthorpe wrote: > On Mon, Feb 22, 2021 at 09:51:25AM -0700, Alex Williamson wrote: > > > diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c > > index da212425ab30..399c42b77fbb 100644 > > +++ b/drivers/vfio/vfio.c > > @@ -572,6 +572,15 @@ void

Re: [RFC PATCH 05/10] vfio: Create a vfio_device from vma lookup

2021-02-22 Thread Jason Gunthorpe
On Mon, Feb 22, 2021 at 09:51:25AM -0700, Alex Williamson wrote: > diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c > index da212425ab30..399c42b77fbb 100644 > +++ b/drivers/vfio/vfio.c > @@ -572,6 +572,15 @@ void vfio_device_unmap_mapping_range(struct vfio_device > *device, > } >

[RFC PATCH 05/10] vfio: Create a vfio_device from vma lookup

2021-02-22 Thread Alex Williamson
Introduce a vfio bus driver policy where using the exported vfio_device_vma_open() as the vm_ops.open for a vma indicates vm_private_data is the struct vfio_device pointer associated to the vma. This allows a direct vma to device lookup. Operating on an active, open vma to the device, we should