]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
gpu: host1x: Don't rely on dma_fence_wait_timeout return value
authorMikko Perttunen <mperttunen@nvidia.com>
Wed, 1 Mar 2023 13:51:06 +0000 (15:51 +0200)
committerThierry Reding <treding@nvidia.com>
Tue, 4 Apr 2023 12:24:24 +0000 (14:24 +0200)
dma_fence_wait_timeout (along with a host of other jiffies-based
timeouting functions) returns zero both in case of timeout and when
the wait completes during the last jiffy before timeout. As such,
we can't rely on it to distinguish between success and timeout.

To prevent confusing callers by returning -EAGAIN before the timeout
period has elapsed, check if the fence got signaled again after
the wait.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
drivers/gpu/host1x/syncpt.c

index 2d2007760eac92201854a16cf8e5aa828a804490..f63d14a57a1d950daa1a5864613d7f2fe4d04aa9 100644 (file)
@@ -248,7 +248,13 @@ int host1x_syncpt_wait(struct host1x_syncpt *sp, u32 thresh, long timeout,
        if (value)
                *value = host1x_syncpt_load(sp);
 
-       if (wait_err == 0)
+       /*
+        * Don't rely on dma_fence_wait_timeout return value,
+        * since it returns zero both on timeout and if the
+        * wait completed with 0 jiffies left.
+        */
+       host1x_hw_syncpt_load(sp->host, sp);
+       if (wait_err == 0 && !host1x_syncpt_is_expired(sp, thresh))
                return -EAGAIN;
        else if (wait_err < 0)
                return wait_err;