Skip to content

Commit 6a4d287

Browse files
robclarkRob Clark
authored andcommitted
drm/msm: Mark VM as unusable on GPU hangs
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 <[email protected]> Signed-off-by: Rob Clark <[email protected]> Tested-by: Antonino Maniscalco <[email protected]> Reviewed-by: Antonino Maniscalco <[email protected]> Patchwork: https://patchwork.freedesktop.org/patch/661499/
1 parent feb8ef4 commit 6a4d287

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

drivers/gpu/drm/msm/msm_gem.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,23 @@ struct msm_gem_vm {
7676

7777
/** @managed: is this a kernel managed VM? */
7878
bool managed;
79+
80+
/**
81+
* @unusable: True if the VM has turned unusable because something
82+
* bad happened during an asynchronous request.
83+
*
84+
* We don't try to recover from such failures, because this implies
85+
* informing userspace about the specific operation that failed, and
86+
* hoping the userspace driver can replay things from there. This all
87+
* sounds very complicated for little gain.
88+
*
89+
* Instead, we should just flag the VM as unusable, and fail any
90+
* further request targeting this VM.
91+
*
92+
* As an analogy, this would be mapped to a VK_ERROR_DEVICE_LOST
93+
* situation, where the logical device needs to be re-created.
94+
*/
95+
bool unusable;
7996
};
8097
#define to_msm_vm(x) container_of(x, struct msm_gem_vm, base)
8198

drivers/gpu/drm/msm/msm_gem_submit.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,9 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
681681
if (args->pad)
682682
return -EINVAL;
683683

684+
if (to_msm_vm(ctx->vm)->unusable)
685+
return UERR(EPIPE, dev, "context is unusable");
686+
684687
/* for now, we just have 3d pipe.. eventually this would need to
685688
* be more clever to dispatch to appropriate gpu module:
686689
*/

drivers/gpu/drm/msm/msm_gpu.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,20 @@ static void recover_worker(struct kthread_work *work)
389389

390390
/* Increment the fault counts */
391391
submit->queue->faults++;
392-
if (submit->vm)
393-
to_msm_vm(submit->vm)->faults++;
392+
if (submit->vm) {
393+
struct msm_gem_vm *vm = to_msm_vm(submit->vm);
394+
395+
vm->faults++;
396+
397+
/*
398+
* If userspace has opted-in to VM_BIND (and therefore userspace
399+
* management of the VM), faults mark the VM as unusuable. This
400+
* matches vulkan expectations (vulkan is the main target for
401+
* VM_BIND)
402+
*/
403+
if (!vm->managed)
404+
vm->unusable = true;
405+
}
394406

395407
get_comm_cmdline(submit, &comm, &cmd);
396408

0 commit comments

Comments
 (0)