On Wed, Jul 30, 2025 at 06:43:38PM +0100, Karunika Choo wrote:
> 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.
> 
> Signed-off-by: Karunika Choo <karunika.c...@arm.com>
> Co-developed-by: Dennis Tsiang <dennis.tsi...@arm.com>

Reviewed-by: Liviu Dudau <liviu.du...@arm.com>

Best regards,
Liviu

> ---
>  drivers/gpu/drm/panthor/panthor_gpu.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/gpu/drm/panthor/panthor_gpu.c 
> b/drivers/gpu/drm/panthor/panthor_gpu.c
> index cb7a335e07d7..030409371037 100644
> --- a/drivers/gpu/drm/panthor/panthor_gpu.c
> +++ b/drivers/gpu/drm/panthor/panthor_gpu.c
> @@ -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)) {
> -- 
> 2.49.0
> 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯

Reply via email to