From a17d609e3e216c406f7c0cec2a94086a4401ac06 Mon Sep 17 00:00:00 2001
From: Steven Price <steven.price@arm.com>
Date: Thu, 29 Oct 2020 17:00:47 +0000
Subject: drm/panfrost: Don't corrupt the queue mutex on open/close
Git-commit: a17d609e3e216c406f7c0cec2a94086a4401ac06
Patch-mainline: v5.11-rc1
References: bsc#1152472
The mutex within the panfrost_queue_state should have the lifetime of
the queue, however it was erroneously initialised/destroyed during
panfrost_job_{open,close} which is called every time a client
opens/closes the drm node.
Move the initialisation/destruction to panfrost_job_{init,fini} where it
belongs.
Fixes: 1a11a88cfd9a ("drm/panfrost: Fix job timeout handling")
Signed-off-by: Steven Price <steven.price@arm.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201029170047.30564-1-steven.price@arm.com
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/gpu/drm/panfrost/panfrost_job.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
--- a/drivers/gpu/drm/panfrost/panfrost_job.c
+++ b/drivers/gpu/drm/panfrost/panfrost_job.c
@@ -531,6 +531,8 @@ int panfrost_job_init(struct panfrost_de
}
for (j = 0; j < NUM_JOB_SLOTS; j++) {
+ mutex_init(&js->queue[j].lock);
+
js->queue[j].fence_context = dma_fence_context_alloc(1);
ret = drm_sched_init(&js->queue[j].sched,
@@ -561,8 +563,10 @@ void panfrost_job_fini(struct panfrost_d
job_write(pfdev, JOB_INT_MASK, 0);
- for (j = 0; j < NUM_JOB_SLOTS; j++)
+ for (j = 0; j < NUM_JOB_SLOTS; j++) {
drm_sched_fini(&js->queue[j].sched);
+ mutex_destroy(&js->queue[j].lock);
+ }
}
@@ -574,7 +578,6 @@ int panfrost_job_open(struct panfrost_fi
int ret, i;
for (i = 0; i < NUM_JOB_SLOTS; i++) {
- mutex_init(&js->queue[i].lock);
rq = &js->queue[i].sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL];
ret = drm_sched_entity_init(&panfrost_priv->sched_entity[i], &rq, 1, NULL);
if (WARN_ON(ret))
@@ -589,10 +592,8 @@ void panfrost_job_close(struct panfrost_
struct panfrost_job_slot *js = pfdev->js;
int i;
- for (i = 0; i < NUM_JOB_SLOTS; i++) {
+ for (i = 0; i < NUM_JOB_SLOTS; i++)
drm_sched_entity_destroy(&panfrost_priv->sched_entity[i]);
- mutex_destroy(&js->queue[i].lock);
- }
}
int panfrost_job_is_idle(struct panfrost_device *pfdev)