]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/panthor: Serialize GPU cache flush operations
authorKarunika Choo <karunika.choo@arm.com>
Thu, 7 Aug 2025 16:26:31 +0000 (17:26 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:37:02 +0000 (15:37 -0500)
[ Upstream commit e322a4844811b54477b7072eb40dc9e402a1725d ]

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
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/panthor/panthor_gpu.c

index cb7a335e07d7c3b6457150c8a3225a9c49286677..030409371037b39f11d97b7e46d38a1f7d60a40f 100644 (file)
@@ -35,6 +35,9 @@ struct panthor_gpu {
 
        /** @reqs_acked: GPU request wait queue. */
        wait_queue_head_t reqs_acked;
+
+       /** @cache_flush_lock: Lock to serialize cache flushes */
+       struct mutex cache_flush_lock;
 };
 
 /**
@@ -204,6 +207,7 @@ int panthor_gpu_init(struct panthor_device *ptdev)
 
        spin_lock_init(&gpu->reqs_lock);
        init_waitqueue_head(&gpu->reqs_acked);
+       mutex_init(&gpu->cache_flush_lock);
        ptdev->gpu = gpu;
        panthor_gpu_init_info(ptdev);
 
@@ -353,6 +357,9 @@ int panthor_gpu_flush_caches(struct panthor_device *ptdev,
        bool timedout = false;
        unsigned long flags;
 
+       /* Serialize cache flush operations. */
+       guard(mutex)(&ptdev->gpu->cache_flush_lock);
+
        spin_lock_irqsave(&ptdev->gpu->reqs_lock, flags);
        if (!drm_WARN_ON(&ptdev->base,
                         ptdev->gpu->pending_reqs & GPU_IRQ_CLEAN_CACHES_COMPLETED)) {