On Thu, 3 Apr 2025 11:44:42 -0400
Stefan Hajnoczi <stefa...@redhat.com> wrote:

> On Thu, Apr 03, 2025 at 09:47:26AM +0200, Niklas Schnelle wrote:
> > On Wed, 2025-04-02 at 11:51 -0400, Stefan Hajnoczi wrote:  
> > > On Tue, Apr 01, 2025 at 10:22:43AM -0700, Farhan Ali wrote:  
> > > > Hi,
> > > > 
> > > > Recently on s390x we have enabled mmap support for vfio-pci devices 
> > > > [1].  
> > > 
> > > Hi Alex,
> > > I wanted to bring this to your attention. Feel free to merge it through
> > > the VFIO tree, otherwise I will merge it once you have taken a look.
> > > 
> > > Thanks,
> > > Stefan
> > >   
> > > > This allows us to take advantage and use userspace drivers on s390x. 
> > > > However,
> > > > on s390x we have special instructions for MMIO access. Starting with 
> > > > z15 
> > > > (and newer platforms) we have new PCI Memory I/O (MIO) instructions 
> > > > which 
> > > > operate on virtually mapped PCI memory spaces, and can be used from 
> > > > userspace.
> > > > On older platforms we would fallback to using existing system calls for 
> > > > MMIO access.
> > > > 
> > > > This patch series introduces support the PCI MIO instructions, and 
> > > > enables s390x
> > > > support for the userspace NVMe driver on s390x. I would appreciate any 
> > > > review/feedback
> > > > on the patches.
> > > > 
> > > > Thanks
> > > > Farhan  
> > 
> > Hi Stefan,
> > 
> > the kernel patch actually made it into Linus' tree for v6.15 already as
> > commit aa9f168d55dc ("s390/pci: Support mmap() of PCI resources except
> > for ISM devices") plus prerequisites. This went via the PCI tree
> > because they included a change to struct pci_dev and also enabled
> > mmap() on PCI resource files. Alex reviewed an earlier version and was
> > the one who suggested to also enable mmap() on PCI resources.  
> 
> The introduction of a new QEMU API for accessing MMIO BARs in this
> series is something Alex might be interested in as QEMU VFIO maintainer.
> That wouldn't have been part of the kernel patch review.
> 
> If he's aware of the new API he can encourage other VFIO users to use it
> in the future so that you won't need to convert them to work on s390x
> again.

I don't claim any jurisdiction over the vfio-nvme driver.  In general
vfio users should be using either vfio_region_ops, ram_device_mem_ops,
or directly mapping MMIO into the VM address space.  The first uses
pread/write through the region offset, irrespective of the type of
memory, the second provides the type of access used here where we're
dereferencing into an mmap, and the last if of course the preferred
mechanism where available.

It is curious that the proposal here doesn't include any changes to
ram_device_mem_ops for more generically enabling MMIO access on s390x.
Thanks,

Alex


Reply via email to