<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Aug 9, 2017 at 2:31 PM, Chris Wilson <span dir="ltr"><<a href="mailto:chris@chris-wilson.co.uk" target="_blank">chris@chris-wilson.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Quoting Jason Ekstrand (2017-08-09 18:00:54)<br>
</span><div><div class="h5">> +static signed long drm_syncobj_array_wait_<wbr>timeout(struct drm_syncobj **syncobjs,<br>
> +                                                 uint32_t count,<br>
> +                                                 uint32_t flags,<br>
> +                                                 signed long timeout,<br>
> +                                                 uint32_t *idx)<br>
> +{<br>
> +       struct syncobj_wait_entry *entries;<br>
> +       struct dma_fence *fence;<br>
> +       signed long ret;<br>
> +       uint32_t signaled_count, i;<br>
> +<br>
> +       if (timeout == 0) {<br>
> +               signaled_count = 0;<br>
> +               for (i = 0; i < count; ++i) {<br>
> +                       ret = drm_syncobj_signaled(syncobjs[<wbr>i], flags);<br>
> +                       if (ret < 0)<br>
> +                               return ret;<br>
> +                       if (ret == 0)<br>
> +                               continue;<br>
> +                       if (signaled_count == 0 && idx)<br>
> +                               *idx = i;<br>
> +                       signaled_count++;<br>
> +               }<br>
> +<br>
> +               if (flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_<wbr>ALL)<br>
> +                       return signaled_count == count ? 1 : 0;<br>
> +               else<br>
> +                       return signaled_count > 0 ? 1 : 0;<br>
<br>
</div></div>There's a very annoying laxness in the dma_fence API here, in that<br>
backends are not required to automatically report when a fence is<br>
signaled prior to fence->ops->enable_signaling() being called.<br>
So here if we fail to match signaled_count, we need to fallthough and<br>
try a 0 timeout wait!<br></blockquote><div><br></div><div>That is very annoying!  I'll see how bad the fall-through is...<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Christian, dma_fence_wait_any_timeout() has this same bug you told me off<br>
for, e.g. commit 698c0f7ff216 ("dma-buf/fence: revert "don't wait when<br>
specified timeout is zero" (v2)")!<br>
<span class="HOEnZb"><font color="#888888">-Chris<br>
</font></span></blockquote></div><br></div></div>