Skip to content

Commit 7122b68

Browse files
committed
drm/v3d: Take a lock across GPU scheduler job creation and queuing.
Between creation and queueing of a job, you need to prevent any other job from being created and queued. Otherwise the scheduler's fences may be signaled out of seqno order. v2: move mutex unlock to the error label. Signed-off-by: Eric Anholt <[email protected]> Fixes: 57692c9 ("drm/v3d: Introduce a new DRM driver for Broadcom V3D V3.x+") Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Reviewed-by: Lucas Stach <[email protected]>
1 parent 6aa1340 commit 7122b68

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

drivers/gpu/drm/v3d/v3d_drv.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ struct v3d_dev {
8585
*/
8686
struct mutex reset_lock;
8787

88+
/* Lock taken when creating and pushing the GPU scheduler
89+
* jobs, to keep the sched-fence seqnos in order.
90+
*/
91+
struct mutex sched_lock;
92+
8893
struct {
8994
u32 num_allocated;
9095
u32 pages_allocated;

drivers/gpu/drm/v3d/v3d_gem.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
550550
if (ret)
551551
goto fail;
552552

553+
mutex_lock(&v3d->sched_lock);
553554
if (exec->bin.start != exec->bin.end) {
554555
ret = drm_sched_job_init(&exec->bin.base,
555556
&v3d->queue[V3D_BIN].sched,
@@ -576,6 +577,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
576577
kref_get(&exec->refcount); /* put by scheduler job completion */
577578
drm_sched_entity_push_job(&exec->render.base,
578579
&v3d_priv->sched_entity[V3D_RENDER]);
580+
mutex_unlock(&v3d->sched_lock);
579581

580582
v3d_attach_object_fences(exec);
581583

@@ -594,6 +596,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
594596
return 0;
595597

596598
fail_unreserve:
599+
mutex_unlock(&v3d->sched_lock);
597600
v3d_unlock_bo_reservations(dev, exec, &acquire_ctx);
598601
fail:
599602
v3d_exec_put(exec);
@@ -615,6 +618,7 @@ v3d_gem_init(struct drm_device *dev)
615618
spin_lock_init(&v3d->job_lock);
616619
mutex_init(&v3d->bo_lock);
617620
mutex_init(&v3d->reset_lock);
621+
mutex_init(&v3d->sched_lock);
618622

619623
/* Note: We don't allocate address 0. Various bits of HW
620624
* treat 0 as special, such as the occlusion query counters

0 commit comments

Comments
 (0)