Skip to content

Commit e322a48

Browse files
Karunika Choostevenprice-arm
authored andcommitted
drm/panthor: Serialize GPU cache flush operations
In certain scenarios, it is possible for multiple cache flushes to be requested before the previous one completes. This patch introduces the cache_flush_lock mutex to serialize these operations and ensure that any requested cache flushes are completed instead of dropped. Reviewed-by: Liviu Dudau <liviu.dudau@arm.com> Co-developed-by: Dennis Tsiang <dennis.tsiang@arm.com> Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com> Signed-off-by: Karunika Choo <karunika.choo@arm.com> Reviewed-by: Steven Price <steven.price@arm.com> Signed-off-by: Steven Price <steven.price@arm.com> Link: https://lore.kernel.org/r/20250807162633.3666310-6-karunika.choo@arm.com
1 parent 3b1dc21 commit e322a48

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

drivers/gpu/drm/panthor/panthor_gpu.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ struct panthor_gpu {
3535

3636
/** @reqs_acked: GPU request wait queue. */
3737
wait_queue_head_t reqs_acked;
38+
39+
/** @cache_flush_lock: Lock to serialize cache flushes */
40+
struct mutex cache_flush_lock;
3841
};
3942

4043
#define GPU_INTERRUPTS_MASK \
@@ -110,6 +113,7 @@ int panthor_gpu_init(struct panthor_device *ptdev)
110113

111114
spin_lock_init(&gpu->reqs_lock);
112115
init_waitqueue_head(&gpu->reqs_acked);
116+
mutex_init(&gpu->cache_flush_lock);
113117
ptdev->gpu = gpu;
114118

115119
dma_set_max_seg_size(ptdev->base.dev, UINT_MAX);
@@ -258,6 +262,9 @@ int panthor_gpu_flush_caches(struct panthor_device *ptdev,
258262
bool timedout = false;
259263
unsigned long flags;
260264

265+
/* Serialize cache flush operations. */
266+
guard(mutex)(&ptdev->gpu->cache_flush_lock);
267+
261268
spin_lock_irqsave(&ptdev->gpu->reqs_lock, flags);
262269
if (!drm_WARN_ON(&ptdev->base,
263270
ptdev->gpu->pending_reqs & GPU_IRQ_CLEAN_CACHES_COMPLETED)) {

0 commit comments

Comments
 (0)