GEM allocation for para-virtualized DRM driver

Oleksandr Andrushchenko andr2000 at gmail.com
Mon Mar 20 17:18:07 UTC 2017



On 03/18/2017 02:22 PM, Rob Clark wrote:
> On Fri, Mar 17, 2017 at 1:39 PM, Oleksandr Andrushchenko
> <andr2000 at gmail.com> wrote:
>> Hello,
>> I am writing a para-virtualized DRM driver for Xen hypervisor
>> and it now works with DRM CMA helpers, but I would also like
>> to make it work with non-contigous memory: virtual machine
>> that the driver runs in can't guarantee that CMA is actually
>> physically contigous (that is not a problem because of IPMMU
>> and other means, the only constraint I have is that I cannot mmap
>> with pgprot == noncached). So, I am planning to use *drm_gem_get_pages* +
>> *shmem_read_mapping_page_gfp* to allocate memory for GEM objects
>> (scanout buffers + dma-bufs shared with virtual GPU)
>>
>> Do you think this is the right approach to take?
> I guess if you had some case where you needed to "migrate" buffers
> between host and guest memory, then TTM might be useful.  Otherwise
> this sounds like the right approach.
Tried that today (drm_gem_get_pages), the result is interesting:

1. modetest
1.1. Runs, I can see page flips
1.2. vm_operations_struct.fault is called, I can vm_insert_page

2. kmscube (Rob, thanks for that :) + PowerVR SGX 6250
2.1. Cannot initialize EGL
2.2. vm_operations_struct.fault is NOT called

In both cases 2 dumbs are created and successfully mmaped,
in case of kmscube there are also handle_to_fd IOCTLs issued
and no DRM errors observed. No DMA-BUF mmap attempt seen

I re-checked 2) with alloc_pages + remap_pfn_range and it works
(it cannot unmap cleanly, but it could be because I didn't call
split_pages after alloc_pages), thus the setup is still good

Can it be that the buffer allocated with drm_gem_get_pages
doesn't suit PowerVR for some reason?
>
> BR,
> -R
Thank you,
Oleksandr


More information about the dri-devel mailing list