<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 16, 2021 at 7:43 AM Daniel Vetter <<a href="mailto:daniel@ffwll.ch" target="_blank">daniel@ffwll.ch</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Mon, Nov 15, 2021 at 07:26:14PM +0000, Kasireddy, Vivek wrote:<br>
> Hi Daniel, Greg,<br>
> <br>
> If it is the same or a similar crash reported here:<br>
> <a href="https://lists.freedesktop.org/archives/dri-devel/2021-November/330018.html" rel="noreferrer" target="_blank">https://lists.freedesktop.org/archives/dri-devel/2021-November/330018.html</a><br>
> and here: <a href="https://lists.freedesktop.org/archives/dri-devel/2021-November/330212.html" rel="noreferrer" target="_blank">https://lists.freedesktop.org/archives/dri-devel/2021-November/330212.html</a><br>
> then the fix is already merged:<br>
> <a href="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d89c0c8322ecdc9a2ec84b959b6f766be082da76" rel="noreferrer" target="_blank">https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d89c0c8322ecdc9a2ec84b959b6f766be082da76</a></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Yeah but that still leaves the problem of why exaxtly virtgpu is<br>
reinventing drm_poll here?</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Can you please replace it with drm_poll like all other drivers, including<br>
the ones that have private events?<br></blockquote><div><br></div><div>Hi Daniel,</div><div><br></div><div>Allow me to explain the use case a bit. It's for when virtgpu KMS is not used, but a special Wayland compositor does wayland passthrough instead:</div><div><pre style="overflow-x:auto;white-space:pre-wrap;color:rgb(0,0,0)"><a rel="nofollow" href="https://www.youtube.com/watch?v=WwrXqDERFm8" target="_blank">https://www.youtube.com/watch?v=WwrXqDERFm8</a>
<a rel="nofollow" href="https://www.youtube.com/watch?v=EkNBsBx501Q" target="_blank">https://www.youtube.com/watch?v=EkNBsBx501Q</a>
</pre><pre style="overflow-x:auto;white-space:pre-wrap;color:rgb(0,0,0)"><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal">This technique has gained much popularity in the virtualized laptop space, where it offers better performance/user experience than virtgpu KMS. The relevant paravirtualized userspace is "Sommelier":</div><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal"><br></div><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal"><a href="https://chromium.googlesource.com/chromiumos/platform2/+/main/vm_tools/sommelier/" target="_blank">https://chromium.googlesource.com/chromiumos/platform2/+/main/vm_tools/sommelier/</a><br></div><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal"><a href="https://chromium.googlesource.com/chromiumos/platform2/+/main/vm_tools/sommelier/virtualization/virtgpu_channel.cc" target="_blank">https://chromium.googlesource.com/chromiumos/platform2/+/main/vm_tools/sommelier/virtualization/virtgpu_channel.cc</a><br></div><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal"><br></div><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal">Previously, we were using the out-of-tree virtio-wl device and there were many discussions on how we could get this upstream:</div><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal"><br></div><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal"><a href="https://lists.freedesktop.org/archives/dri-devel/2017-December/160309.html" target="_blank">https://lists.freedesktop.org/archives/dri-devel/2017-December/160309.html</a><br></div><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal"><a href="https://lists.oasis-open.org/archives/virtio-dev/202002/msg00005.html" target="_blank">https://lists.oasis-open.org/archives/virtio-dev/202002/msg00005.html</a><br></div><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal"><br></div><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal">Extending virtgpu was deemed the least intrusive option:</div><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal"><br></div><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal"><a href="https://www.spinics.net/lists/kvm/msg159206.html" target="_blank">https://www.spinics.net/lists/kvm/msg159206.html</a><br></div><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal"><br></div><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal">We ultimately settled on the context type abstraction and used <span style="color:rgb(0,0,0);white-space:pre-wrap">virtio_gpu_poll to tell the guest "hey, we have a Wayland event". </span>The host response is actually in a buffer of type BLOB_MEM_GUEST.</div><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal"><br></div><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal">It is possible to use drm_poll(..), but that would have to be accompanied by a drm_read(..). You'll need to define a dummy <span style="color:rgb(0,0,0);white-space:pre-wrap">VIRTGPU_EVENT_FENCE_SIGNALED in the uapi too. </span></div><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal"><span style="color:rgb(0,0,0);white-space:pre-wrap"><br></span></div><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal"><span style="color:rgb(0,0,0);white-space:pre-wrap">That's originally how I did it, but some pointed out that's unnecessary since the host response is in the BLOB_MEM_GUEST buffer and virtgpu event is a dummy event. So we decided just to modify virtio_gpu_poll(..) to have the desired semantics in that case. </span></div><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal"><span style="color:rgb(0,0,0);white-space:pre-wrap"><br></span></div><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal"><span style="color:rgb(0,0,0);white-space:pre-wrap">For the regular virtio-gpu KMS path, things remain unchanged.</span></div><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal"><br></div><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal">There are of course other ways to do it (perhaps polling a dma_fence), but that was the cleanest way we could find.</div><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal"><br></div><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal">It's not rare for virtio to "special things" (see virtio_dma_buf_ops, virtio_dma_ops), since they are in fake devices. </div><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal"><br></div><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal">We're open to other ideas, but hopefully that answers some of your questions. </div></pre></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Thanks, Daniel<br>
<br>
> <br>
> Thanks,<br>
> Vivek<br>
> <br>
> > On Sat, Nov 13, 2021 at 03:51:48PM +0100, Greg KH wrote:<br>
> > > On Tue, Sep 21, 2021 at 04:20:23PM -0700, Gurchetan Singh wrote:<br>
> > > > Similar to DRM_VMW_EVENT_FENCE_SIGNALED. Sends a pollable event<br>
> > > > to the DRM file descriptor when a fence on a specific ring is<br>
> > > > signaled.<br>
> > > ><br>
> > > > One difference is the event is not exposed via the UAPI -- this is<br>
> > > > because host responses are on a shared memory buffer of type<br>
> > > > BLOB_MEM_GUEST [this is the common way to receive responses with<br>
> > > > virtgpu]. As such, there is no context specific read(..)<br>
> > > > implementation either -- just a poll(..) implementation.<br>
> > > ><br>
> > > > Signed-off-by: Gurchetan Singh <<a href="mailto:gurchetansingh@chromium.org" target="_blank">gurchetansingh@chromium.org</a>><br>
> > > > Acked-by: Nicholas Verne <<a href="mailto:nverne@chromium.org" target="_blank">nverne@chromium.org</a>><br>
> > > > ---<br>
> > > > drivers/gpu/drm/virtio/virtgpu_drv.c | 43 +++++++++++++++++++++++++-<br>
> > > > drivers/gpu/drm/virtio/virtgpu_drv.h | 7 +++++<br>
> > > > drivers/gpu/drm/virtio/virtgpu_fence.c | 10 ++++++<br>
> > > > drivers/gpu/drm/virtio/virtgpu_ioctl.c | 34 ++++++++++++++++++++<br>
> > > > 4 files changed, 93 insertions(+), 1 deletion(-)<br>
> > ><br>
> > > This commit seems to cause a crash in a virtual drm gpu driver for<br>
> > > Android. I have reverted this, and the next commit in the series from<br>
> > > Linus's tree and all is good again.<br>
> > ><br>
> > > Any ideas?<br>
> > <br>
> > Well no, but also this patch looks very questionable of hand-rolling<br>
> > drm_poll. Yes you can do driver private events like<br>
> > DRM_VMW_EVENT_FENCE_SIGNALED, that's fine. But you really should not need<br>
> > to hand-roll the poll callback. vmwgfx (which generally is a very old<br>
> > driver which has lots of custom stuff, so not a great example) doesn't do<br>
> > that either.<br>
> > <br>
> > So that part should go no matter what I think.<br>
> > -Daniel<br>
> > --<br>
> > Daniel Vetter<br>
> > Software Engineer, Intel Corporation<br>
> > <a href="http://blog.ffwll.ch" rel="noreferrer" target="_blank">http://blog.ffwll.ch</a><br>
<br>
-- <br>
Daniel Vetter<br>
Software Engineer, Intel Corporation<br>
<a href="http://blog.ffwll.ch" rel="noreferrer" target="_blank">http://blog.ffwll.ch</a><br>
</blockquote></div></div>