<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jul 11, 2017 at 12:22 AM, Daniel Vetter <span dir="ltr"><<a href="mailto:daniel@ffwll.ch" target="_blank">daniel@ffwll.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Mon, Jul 10, 2017 at 02:09:42PM -0700, Jason Ekstrand wrote:<br>
> On Mon, Jul 10, 2017 at 9:15 AM, Christian König <<a href="mailto:deathsimple@vodafone.de">deathsimple@vodafone.de</a>><br>
> wrote:<br>
><br>
> > Am 10.07.2017 um 17:52 schrieb Jason Ekstrand:<br>
> ><br>
> > On Mon, Jul 10, 2017 at 8:45 AM, Christian König <<a href="mailto:deathsimple@vodafone.de">deathsimple@vodafone.de</a>><br>
> > wrote:<br>
> ><br>
> >> Am 10.07.2017 um 17:28 schrieb Jason Ekstrand:<br>
> >><br>
> >> On Wed, Jul 5, 2017 at 6:04 PM, Dave Airlie <<a href="mailto:airlied@gmail.com">airlied@gmail.com</a>> wrote:<br>
> >> [SNIP]<br>
> >> So, reading some CTS tests again, and I think we have a problem here.<br>
> >> The Vulkan spec allows you to wait on a fence that is in the unsignaled<br>
> >> state.<br>
> >><br>
> >><br>
> >> At least on the closed source driver that would be illegal as far as I<br>
> >> know.<br>
> >><br>
> ><br>
> > Then they are doing workarounds in userspace.  There are definitely CTS<br>
> > tests for this:<br>
> ><br>
> > <a href="https://github.com/KhronosGroup/VK-GL-CTS/blob/master/external/vulkancts/" rel="noreferrer" target="_blank">https://github.com/<wbr>KhronosGroup/VK-GL-CTS/blob/<wbr>master/external/vulkancts/</a><br>
> > modules/vulkan/<wbr>synchronization/<wbr>vktSynchronizationBasicFenceTe<wbr>sts.cpp#L74<br>
> ><br>
> ><br>
> >> You can't wait on a semaphore before the signal operation is send down to<br>
> >> the kerel.<br>
> >><br>
> ><br>
> > We (Intel) deal with this today by tracking whether or not the fence has<br>
> > been submitted and using a condition variable in userspace to sort it all<br>
> > out.<br>
> ><br>
> ><br>
> > Which sounds exactly like what AMD is doing in it's drivers as well.<br>
> ><br>
><br>
> Which doesn't work cross-process so...<br>
><br>
> > If we ever want to share fences across processes (which we do), then this<br>
> > needs to be sorted in the kernel.<br>
> ><br>
> ><br>
> > That would clearly get a NAK from my side, even Microsoft forbids wait<br>
> > before signal because you can easily end up in deadlock situations.<br>
> ><br>
><br>
> Please don't NAK things that are required by the API specification and CTS<br>
> tests.  That makes it very hard for people like me to get their jobs done.<br>
> :-)<br>
><br>
> Now, as for whether or not it's a good idea.  First off, we do have<br>
> timeouts an a status querying mechanism so an application can just set a<br>
> timeout of 1s and do something if it times out.  Second, if the application<br>
> is a compositor or something else that doesn't trust its client, it<br>
> shouldn't be using the OPAQUE_FD mechanism of Vulkan semaphore/fence<br>
> sharing anyway.  For those scenarios, they can require the untrusted client<br>
> to use FENCE_FD (sync file) and they have all of the usual guarantees about<br>
> when the work got submitted, etc.<br>
><br>
> Also, I'm more than happy to put this all behind a flag so it's not the<br>
> default behavior.<br>
<br>
</div></div>Android had a similar requirement to have a fence fd before the fence<br>
existed in hwc1, before they fixed that in hwc2. But it's probably still<br>
useful for deeply pipelined renderes with littel memory, aka tiled<br>
renderers on phones.<br>
<br>
The idea we've tossed around is to create a so-called future fence. In the<br>
kernel if you try to deref a future fence, the usual thing that happens is<br>
you'll block (interruptibly, which we can because fence lookup might<br>
fail), _until_ a real fence shows up and can be returned. That implements<br>
the uapi expectations without risking deadlocks in the kernel, albeit with<br>
a bit much blocking. Still better than doing the same in userspace (since<br>
in userspace you probably need to do that when importing the fence, not at<br>
execbuf time).<span class="HOEnZb"><font color="#888888"><br>
</font></span></blockquote></div><br></div><div class="gmail_extra">Yes, I'm aware of the future fence idea.  However, that's not really all that related.  We're not talking about blocking GPU work here.  We're talking about the CPU wait API having support for "wait for submit and signal" behavior instead of just "wait for signal".<br></div></div>