Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpu: host1x: Don't rely on dma_fence_wait_timeout return value

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>

authored by

Mikko Perttunen and committed by
Thierry Reding
c1aaee94 1d83d1a2

+7 -1
+7 -1
drivers/gpu/host1x/syncpt.c
··· 248 248 if (value) 249 249 *value = host1x_syncpt_load(sp); 250 250 251 - if (wait_err == 0) 251 + /* 252 + * Don't rely on dma_fence_wait_timeout return value, 253 + * since it returns zero both on timeout and if the 254 + * wait completed with 0 jiffies left. 255 + */ 256 + host1x_hw_syncpt_load(sp->host, sp); 257 + if (wait_err == 0 && !host1x_syncpt_is_expired(sp, thresh)) 252 258 return -EAGAIN; 253 259 else if (wait_err < 0) 254 260 return wait_err;