<div dir="ltr">Sorry for joining this later, is there some way to get it also implemented under OS other than Linux Host?<div><br></div><div>I guess udmabuf is something specified to Linux host? </div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Oct 4, 2018 at 7:34 AM Elie Tournier <<a href="mailto:tournier.elie@gmail.com">tournier.elie@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Thu, Oct 04, 2018 at 10:57:29AM +0200, Gerd Hoffmann wrote:<br>
>   Hi,<br>
> <br>
> > > > Yes, it stands for ARM frame buffer compression and it's widely used<br>
> > > > on that architecture.<br>
> > ><br>
> > > Speaking of compression:  How does buffer size calculation and buffer<br>
> > > allocation work in case compression is used?<br>
> > <br>
> > There's a header + compressed data or an auxiliary buffer.  Here are<br>
> > some examples:<br>
> > <br>
> > <a href="https://chromium.googlesource.com/chromiumos/platform/minigbm/+/master/rockchip.c#33" rel="noreferrer" target="_blank">https://chromium.googlesource.com/chromiumos/platform/minigbm/+/master/rockchip.c#33</a><br>
> <br>
> Hmm, so you need some format-specific knowledge to calculate the buffer<br>
> size.  How does the allocation workflow look like?  Userspace (libgbm)<br>
> calculates the size, then asks the kernel create a bo with that size?<br>
> <br>
> Related: how is the stride calculated?<br>
> <br>
> I'm asking because I want get the workflow right for hostmapped<br>
> resource allocation.  Right now we have no modifiers, so it is<br>
> simple to calculate the size needed for a given resource.  Also given we<br>
> have no shared mapping between host and guest and copy around the data,<br>
> so any stride mismatches can be accounted for when copying.  Both will<br>
> not be true any more when we add hostmap and modifier support ...<br>
> <br>
> So the fundamental question is:  Can the guest calculate the size needed<br>
> in advance?  Or will the guest have to first ask the host create a<br>
> resource, then query how big it is, finally map the thing into the guest<br>
> address space?<br>
> <br>
> Related:  Who should decide which format modifiers should be used?<br>
> guest or host?<br>
> <br>
> > <a href="https://cgit.freedesktop.org/mesa/mesa/tree/src/mesa/drivers/dri/i965/intel_screen.c#n735" rel="noreferrer" target="_blank">https://cgit.freedesktop.org/mesa/mesa/tree/src/mesa/drivers/dri/i965/intel_screen.c#n735</a><br>
> <br>
> What is in the auxiliary buffer?  The compression metadata (i.e. simliar<br>
> to what afbc has in the header)?<br>
> <br>
> How they are passed around?  Is the auxiliary buffer just another bo?<br>
> <br>
> > > How does mesa handle modifiers?  Does it use the drm modifiers directly?<br>
> > > Or has mesa/gallium its own naming scheme?<br>
> > ><br>
> > > Right now the format specification used by virtio is based on gallium<br>
> > > formats ...<br>
> > <br>
> > The modifiers are from DRM, and drm_fourcc.h is considered the source<br>
> > of truth (I guess that's where some of the problems with v4l2<br>
> > integration arise).<br>
> <br>
> Ok.<br>
> <br>
> > Anyways, here are the conclusions that I can discern from this discussion:<br>
> > <br>
> > 1) Host mapped memory should be fine, as long it's optional for the VMM<br>
> <br>
> Yes, we need a virtio feature flag for this.  First, for backward<br>
> compatibilty reasons.  Second, because the VMM might want to make this<br>
> configurable per VM.<br>
<br>
I fully agree with that.<br>
> <br>
> > 2) Texture uploads can be improved.  BTW, what's the benefit of<br>
> > udmabuf over an iov with one element for say a 5-level texture?<br>
> <br>
> Well, udmabuf can be used to get a linear mapping of a scattered<br>
> resource.  Now qemu can map that udmabuf, the pass on the one-elem-iov<br>
> to virglrenderer.  Or qemu can pass the udmabuf handle to virglrenderer.<br>
> <br>
> The later has the advantage that virglrenderer can possibly do more with<br>
> the dmabuf than simply mmap()ing it (specifically let the gpu driver<br>
> import it).  The former has the advantage that it works without<br>
> virglrenderer changes.<br>
<br>
So at Collabora, we are also looking at reducing copies during texture uploads.<br>
We were thinking about the second conclusion: "qemu can pass the udmabuf handle to virglrenderer"<br>
and I'd like to recapitulate what has been discussed here on this regard.<br>
My understanding is that we'd require that the VMM allocates all the memory of the machine in a single memfd region.<br>
Then, when a client in the guest requests a texture upload, Mesa would create a virtio-gpu resource<br>
to wrap the buffer that the client passed with the texture data.<br>
virtio-gpu would pass the physical addresses backing that buffer to the virtio queue message<br>
for creating a buffer or attaching memory to it.<br>
When the VMM processes the message, it would create a dmabuf via udmabuf out of those physical addresses.<br>
That dmabuf can then be mapped and the address can be directly passed to read_transfer_data in virglrenderer.<br>
<br>
Did I get that right? If we agree with a plan, we will be happy to help with the implementation or the code review.<br>
<br>
Elie<br>
> <br>
> > 3) Coherent memory ioctl needed for Vulkan/gl4.5<br>
> <br>
> Yes.<br>
> <br>
> > 4) The new ioctl should take into account format modifiers<br>
> <br>
> Well, it isn't just the ioctl.  We also have to hash out the virtio<br>
> protocol extension (even though it'll probably look simliar to the<br>
> ioctl interface), and the virglrenderer api extension.<br>
> <br>
> > 5) The DRM_VIRTGPU_RESOURCE_INFO needs to be fixed and expanded for<br>
> > (1), (3) and (4)<br>
> <br>
> Not just that one, we need a new/improved resource create ioctl too.<br>
> And while being at it we might want split the thing, into an ioctl to<br>
> create buffers (aka gem objects), and into one (or more) ioctls to<br>
> specifiy what is in there (format, width + height, modifiers, ...).<br>
> <br>
> > 6) There's no clear path forward on how to pipe host display<br>
> > information to the guest, such that the guest can know which modifier<br>
> > is the best.  Hopefully, the wayland proxying Collabora is working on<br>
> > can clear this up..<br>
> <br>
> Ah, so you think the guest should pick the modifier then?<br>
> <br>
> Guess we could use a capset to provide a list (ordered by preference)<br>
> to the guest.<br>
> <br>
> <br>
> cheers,<br>
>   Gerd<br>
> <br>
> _______________________________________________<br>
> virglrenderer-devel mailing list<br>
> <a href="mailto:virglrenderer-devel@lists.freedesktop.org" target="_blank">virglrenderer-devel@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/virglrenderer-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/virglrenderer-devel</a><br>
_______________________________________________<br>
virglrenderer-devel mailing list<br>
<a href="mailto:virglrenderer-devel@lists.freedesktop.org" target="_blank">virglrenderer-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/virglrenderer-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/virglrenderer-devel</a><br>
</blockquote></div>