Skip to content

Commit dd11c7d

Browse files
Karunika Choostevenprice-arm
authored andcommitted
drm/panthor: Make MMU cache maintenance use FLUSH_CACHES command
As the FLUSH_MEM and FLUSH_PT MMU_AS commands are deprecated in GPUs from Mali-Gx20 onwards, this patch adds support for performing cache maintenance via the FLUSH_CACHES command in GPU_COMMAND in place of FLUSH_MEM and FLUSH_PT commands. Mali-Gx10 and Mali-Gx15 GPUs also has support for the FLUSH_CACHES command and will also use this by default going forward. Reviewed-by: Steven Price <steven.price@arm.com> Reviewed-by: Chia-I Wu <olvaffe@gmail.com> Reviewed-by: Liviu Dudau <liviu.dudau@arm.com> Signed-off-by: Karunika Choo <karunika.choo@arm.com> Signed-off-by: Steven Price <steven.price@arm.com> Link: https://lore.kernel.org/r/20250807162633.3666310-7-karunika.choo@arm.com
1 parent e322a48 commit dd11c7d

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

drivers/gpu/drm/panthor/panthor_mmu.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
#include "panthor_device.h"
3131
#include "panthor_gem.h"
32+
#include "panthor_gpu.h"
3233
#include "panthor_heap.h"
3334
#include "panthor_mmu.h"
3435
#include "panthor_regs.h"
@@ -568,6 +569,35 @@ static void lock_region(struct panthor_device *ptdev, u32 as_nr,
568569
write_cmd(ptdev, as_nr, AS_COMMAND_LOCK);
569570
}
570571

572+
static int mmu_hw_do_flush_on_gpu_ctrl(struct panthor_device *ptdev, int as_nr,
573+
u32 op)
574+
{
575+
const u32 l2_flush_op = CACHE_CLEAN | CACHE_INV;
576+
u32 lsc_flush_op = 0;
577+
int ret;
578+
579+
if (op == AS_COMMAND_FLUSH_MEM)
580+
lsc_flush_op = CACHE_CLEAN | CACHE_INV;
581+
582+
ret = wait_ready(ptdev, as_nr);
583+
if (ret)
584+
return ret;
585+
586+
ret = panthor_gpu_flush_caches(ptdev, l2_flush_op, lsc_flush_op, 0);
587+
if (ret)
588+
return ret;
589+
590+
/*
591+
* Explicitly unlock the region as the AS is not unlocked automatically
592+
* at the end of the GPU_CONTROL cache flush command, unlike
593+
* AS_COMMAND_FLUSH_MEM or AS_COMMAND_FLUSH_PT.
594+
*/
595+
write_cmd(ptdev, as_nr, AS_COMMAND_UNLOCK);
596+
597+
/* Wait for the unlock command to complete */
598+
return wait_ready(ptdev, as_nr);
599+
}
600+
571601
static int mmu_hw_do_operation_locked(struct panthor_device *ptdev, int as_nr,
572602
u64 iova, u64 size, u32 op)
573603
{
@@ -585,6 +615,9 @@ static int mmu_hw_do_operation_locked(struct panthor_device *ptdev, int as_nr,
585615
if (op != AS_COMMAND_UNLOCK)
586616
lock_region(ptdev, as_nr, iova, size);
587617

618+
if (op == AS_COMMAND_FLUSH_MEM || op == AS_COMMAND_FLUSH_PT)
619+
return mmu_hw_do_flush_on_gpu_ctrl(ptdev, as_nr, op);
620+
588621
/* Run the MMU operation */
589622
write_cmd(ptdev, as_nr, op);
590623

0 commit comments

Comments
 (0)