[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7f46ef3c80734f478501d21cef0182c5@AcuMS.aculab.com>
Date: Sun, 6 Mar 2022 08:30:14 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Jarkko Sakkinen' <jarkko@...nel.org>,
"linux-mm@...ck.org" <linux-mm@...ck.org>
CC: Dave Hansen <dave.hansen@...ux.intel.com>,
Nathaniel McCallum <nathaniel@...fian.com>,
Reinette Chatre <reinette.chatre@...el.com>,
"Andrew Morton" <akpm@...ux-foundation.org>,
"linux-sgx@...r.kernel.org" <linux-sgx@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Florian Fainelli <f.fainelli@...il.com>,
Thomas Bogendoerfer <tsbogend@...ha.franken.de>,
Matthew Auld <matthew.auld@...el.com>,
Thomas Hellström
<thomas.hellstrom@...ux.intel.com>,
Daniel Vetter <daniel.vetter@...ll.ch>,
Jason Ekstrand <jason@...kstrand.net>,
Chris Wilson <chris@...is-wilson.co.uk>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Tvrtko Ursulin <tvrtko.ursulin@...el.com>,
Vasily Averin <vvs@...tuozzo.com>,
Shakeel Butt <shakeelb@...gle.com>,
"Michal Hocko" <mhocko@...e.com>,
zhangyiru <zhangyiru3@...wei.com>,
Alexey Gladkov <legion@...nel.org>,
Alexander Mikhalitsyn <alexander.mikhalitsyn@...tuozzo.com>,
"linux-mips@...r.kernel.org" <linux-mips@...r.kernel.org>,
"intel-gfx@...ts.freedesktop.org" <intel-gfx@...ts.freedesktop.org>,
"dri-devel@...ts.freedesktop.org" <dri-devel@...ts.freedesktop.org>,
"codalist@...a.cs.cmu.edu" <codalist@...a.cs.cmu.edu>,
"linux-unionfs@...r.kernel.org" <linux-unionfs@...r.kernel.org>,
"linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>
Subject: RE: [PATCH RFC 0/3] MAP_POPULATE for device memory
From: Jarkko Sakkinen
> Sent: 06 March 2022 05:32
>
> For device memory (aka VM_IO | VM_PFNMAP) MAP_POPULATE does nothing. Allow
> to use that for initializing the device memory by providing a new callback
> f_ops->populate() for the purpose.
>
> SGX patches are provided to show the callback in context.
>
> An obvious alternative is a ioctl but it is less elegant and requires
> two syscalls (mmap + ioctl) per memory range, instead of just one
> (mmap).
Is this all about trying to stop the vm_operations_struct.fault()
function being called?
It is pretty easy to ensure the mappings are setup in the driver's
mmap() function.
Then the fault() function can just return -VM_FAULT_SIGBUS;
If it is actually device memory you just need to call vm_iomap_memory()
That quite nicely mmap()s PCIe memory space into a user process.
Mapping driver memory is slightly more difficult.
For buffers allocated with dma_alloc_coherent() you can
probably use dma_mmap_coherent().
But I have a loop calling remap_pfn_range() because the
buffer area is made of multiple 16kB kernel buffers that
need to be mapped to contiguous user pages.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists