]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/msm: Mark VM as unusable on GPU hangs
authorRob Clark <robdclark@chromium.org>
Sun, 29 Jun 2025 20:13:06 +0000 (13:13 -0700)
committerRob Clark <robin.clark@oss.qualcomm.com>
Sat, 5 Jul 2025 00:48:36 +0000 (17:48 -0700)
If userspace has opted-in to VM_BIND, then GPU hangs and VM_BIND errors
will mark the VM as unusable.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com>
Tested-by: Antonino Maniscalco <antomani103@gmail.com>
Reviewed-by: Antonino Maniscalco <antomani103@gmail.com>
Patchwork: https://patchwork.freedesktop.org/patch/661499/

drivers/gpu/drm/msm/msm_gem.h
drivers/gpu/drm/msm/msm_gem_submit.c
drivers/gpu/drm/msm/msm_gpu.c

index b5bf21f62f9d44911d04c89818db5cb3738410c9..f2631a8c62b95716744b4e821c4b8f723e8e8a26 100644 (file)
@@ -76,6 +76,23 @@ struct msm_gem_vm {
 
        /** @managed: is this a kernel managed VM? */
        bool managed;
+
+       /**
+        * @unusable: True if the VM has turned unusable because something
+        * bad happened during an asynchronous request.
+        *
+        * We don't try to recover from such failures, because this implies
+        * informing userspace about the specific operation that failed, and
+        * hoping the userspace driver can replay things from there. This all
+        * sounds very complicated for little gain.
+        *
+        * Instead, we should just flag the VM as unusable, and fail any
+        * further request targeting this VM.
+        *
+        * As an analogy, this would be mapped to a VK_ERROR_DEVICE_LOST
+        * situation, where the logical device needs to be re-created.
+        */
+       bool unusable;
 };
 #define to_msm_vm(x) container_of(x, struct msm_gem_vm, base)
 
index daf05c380e8400d26905a38aac9541ca92f9b0c9..50fafcacf035db082789bd8c0f2e13fef93e0b49 100644 (file)
@@ -681,6 +681,9 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
        if (args->pad)
                return -EINVAL;
 
+       if (to_msm_vm(ctx->vm)->unusable)
+               return UERR(EPIPE, dev, "context is unusable");
+
        /* for now, we just have 3d pipe.. eventually this would need to
         * be more clever to dispatch to appropriate gpu module:
         */
index c08c942d85a0729d239bb1753d1aedc5a57a00c7..0846f6c5169f7862b583151b3724a9d495d2547d 100644 (file)
@@ -389,8 +389,20 @@ static void recover_worker(struct kthread_work *work)
 
        /* Increment the fault counts */
        submit->queue->faults++;
-       if (submit->vm)
-               to_msm_vm(submit->vm)->faults++;
+       if (submit->vm) {
+               struct msm_gem_vm *vm = to_msm_vm(submit->vm);
+
+               vm->faults++;
+
+               /*
+                * If userspace has opted-in to VM_BIND (and therefore userspace
+                * management of the VM), faults mark the VM as unusuable.  This
+                * matches vulkan expectations (vulkan is the main target for
+                * VM_BIND)
+                */
+               if (!vm->managed)
+                       vm->unusable = true;
+       }
 
        get_comm_cmdline(submit, &comm, &cmd);