Skip to content

Commit df1a1ed

Browse files
brendan-kingMTCoster
authored andcommitted
drm/imagination: avoid deadlock on fence release
Do scheduler queue fence release processing on a workqueue, rather than in the release function itself. Fixes deadlock issues such as the following: [ 607.400437] ============================================ [ 607.405755] WARNING: possible recursive locking detected [ 607.415500] -------------------------------------------- [ 607.420817] weston:zfq0/24149 is trying to acquire lock: [ 607.426131] ffff000017d041a0 (reservation_ww_class_mutex){+.+.}-{3:3}, at: pvr_gem_object_vunmap+0x40/0xc0 [powervr] [ 607.436728] but task is already holding lock: [ 607.442554] ffff000017d105a0 (reservation_ww_class_mutex){+.+.}-{3:3}, at: dma_buf_ioctl+0x250/0x554 [ 607.451727] other info that might help us debug this: [ 607.458245] Possible unsafe locking scenario: [ 607.464155] CPU0 [ 607.466601] ---- [ 607.469044] lock(reservation_ww_class_mutex); [ 607.473584] lock(reservation_ww_class_mutex); [ 607.478114] *** DEADLOCK *** Cc: stable@vger.kernel.org Fixes: eaf01ee ("drm/imagination: Implement job submission and scheduling") Signed-off-by: Brendan King <brendan.king@imgtec.com> Reviewed-by: Matt Coster <matt.coster@imgtec.com> Link: https://patchwork.freedesktop.org/patch/msgid/20250226-fence-release-deadlock-v2-1-6fed2fc1fe88@imgtec.com Signed-off-by: Matt Coster <matt.coster@imgtec.com>
1 parent 6b481ab commit df1a1ed

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

drivers/gpu/drm/imagination/pvr_queue.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,20 @@ pvr_queue_fence_get_driver_name(struct dma_fence *f)
109109
return PVR_DRIVER_NAME;
110110
}
111111

112+
static void pvr_queue_fence_release_work(struct work_struct *w)
113+
{
114+
struct pvr_queue_fence *fence = container_of(w, struct pvr_queue_fence, release_work);
115+
116+
pvr_context_put(fence->queue->ctx);
117+
dma_fence_free(&fence->base);
118+
}
119+
112120
static void pvr_queue_fence_release(struct dma_fence *f)
113121
{
114122
struct pvr_queue_fence *fence = container_of(f, struct pvr_queue_fence, base);
123+
struct pvr_device *pvr_dev = fence->queue->ctx->pvr_dev;
115124

116-
pvr_context_put(fence->queue->ctx);
117-
dma_fence_free(f);
125+
queue_work(pvr_dev->sched_wq, &fence->release_work);
118126
}
119127

120128
static const char *
@@ -268,6 +276,7 @@ pvr_queue_fence_init(struct dma_fence *f,
268276

269277
pvr_context_get(queue->ctx);
270278
fence->queue = queue;
279+
INIT_WORK(&fence->release_work, pvr_queue_fence_release_work);
271280
dma_fence_init(&fence->base, fence_ops,
272281
&fence_ctx->lock, fence_ctx->id,
273282
atomic_inc_return(&fence_ctx->seqno));

drivers/gpu/drm/imagination/pvr_queue.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#define PVR_QUEUE_H
66

77
#include <drm/gpu_scheduler.h>
8+
#include <linux/workqueue.h>
89

910
#include "pvr_cccb.h"
1011
#include "pvr_device.h"
@@ -63,6 +64,9 @@ struct pvr_queue_fence {
6364

6465
/** @queue: Queue that created this fence. */
6566
struct pvr_queue *queue;
67+
68+
/** @release_work: Fence release work structure. */
69+
struct work_struct release_work;
6670
};
6771

6872
/**

0 commit comments

Comments
 (0)