A synchronous VM_BIND waits for its job with an interruptible wait and
ignores the result. On a signal the ioctl returns 0 while the job is
still queued. Userspace can then use the new mappings before the page
tables are written, and the channel can take an MMU fault.

Wait uninterruptibly. A synchronous job takes no syncobjs, so only the
jobs queued before it on the same scheduler can delay it.

Fixes: b88baab82871 ("drm/nouveau: implement new VM_BIND uAPI")
Signed-off-by: Mohamed Ahmed <[email protected]>
Tested-by: Thomas Andersen <[email protected]>
---
 drivers/gpu/drm/nouveau/nouveau_sched.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_sched.c 
b/drivers/gpu/drm/nouveau/nouveau_sched.c
index b3f02c490ecb..680ddffefca1 100644
--- a/drivers/gpu/drm/nouveau/nouveau_sched.c
+++ b/drivers/gpu/drm/nouveau/nouveau_sched.c
@@ -328,7 +328,11 @@ nouveau_job_submit(struct nouveau_job *job)
        mutex_unlock(&sched->mutex);
 
        if (done_fence) {
-               dma_fence_wait(done_fence, true);
+               /* The job is queued and its VA space changes are applied. It
+                * can neither be restarted nor reported as failed, so wait
+                * until it has run.
+                */
+               dma_fence_wait(done_fence, false);
                dma_fence_put(done_fence);
        }
 
-- 
2.56.1

Reply via email to