From: Matthew Brost <[email protected]>

aie2_hmm_invalidate() waits for the jobs using a BO before the CPU pages
behind it are released, but does so interruptibly. When the task
triggering the invalidation has a signal pending the wait returns
-ERESTARTSYS immediately, the notifier completes and the pages can be
freed or migrated while the device is still accessing them through the
PASID.

An MMU notifier cannot fail a blockable invalidation, so wait
uninterruptibly. With MAX_SCHEDULE_TIMEOUT an uninterruptible wait
cannot time out either, so drop the now dead error handling.

Fixes: aac243092b70 ("accel/amdxdna: Add command execution")
Co-authored-by: Copilot <[email protected]>
Signed-off-by: Matthew Brost <[email protected]>
Signed-off-by: Lizhi Hou <[email protected]>
---
 drivers/accel/amdxdna/aie2_ctx.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/accel/amdxdna/aie2_ctx.c b/drivers/accel/amdxdna/aie2_ctx.c
index 9c6b7353cbe9..84ab8a55b7ab 100644
--- a/drivers/accel/amdxdna/aie2_ctx.c
+++ b/drivers/accel/amdxdna/aie2_ctx.c
@@ -1286,16 +1286,12 @@ int aie2_cmd_submit(struct amdxdna_hwctx *hwctx, struct 
amdxdna_sched_job *job,
 void aie2_hmm_invalidate(struct amdxdna_gem_obj *abo,
                         unsigned long cur_seq)
 {
-       struct amdxdna_dev *xdna = to_xdna_dev(to_gobj(abo)->dev);
-       struct drm_gem_object *gobj = to_gobj(abo);
-       long ret;
-
-       ret = dma_resv_wait_timeout(gobj->resv, DMA_RESV_USAGE_BOOKKEEP,
-                                   true, MAX_SCHEDULE_TIMEOUT);
-       if (!ret)
-               XDNA_ERR(xdna, "Failed to wait for bo, ret %ld", ret);
-       else if (ret == -ERESTARTSYS)
-               XDNA_DBG(xdna, "Wait for bo interrupted by signal");
+       /*
+        * The pages must not be released while the device may still access
+        * them, so this wait must be neither interruptible nor time limited.
+        */
+       dma_resv_wait_timeout(to_gobj(abo)->resv, DMA_RESV_USAGE_BOOKKEEP,
+                             false, MAX_SCHEDULE_TIMEOUT);
 }
 
 int aie2_hwctx_heap_expand(struct amdxdna_hwctx *hwctx,
-- 
2.34.1

Reply via email to