Skip to content

Commit 49355c8

Browse files
bbrezillonSasha Levin
authored andcommitted
drm/panthor: Always wait after sending a command to an AS
[ Upstream commit d2c6fde ] There's currently no situation where we want to issue a command to an AS and not wait for this command to complete. The wait is either explicitly done (LOCK, UNLOCK) or it's missing (UPDATE). So let's turn write_cmd() into as_send_cmd_and_wait() that has the wait after a command is sent. v2: - New patch v3: - Collect R-b v4: - No changes Reviewed-by: Steven Price <steven.price@arm.com> Link: https://patch.msgid.link/20251128084841.3804658-2-boris.brezillon@collabora.com Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 4d2ccde commit 49355c8

1 file changed

Lines changed: 12 additions & 15 deletions

File tree

drivers/gpu/drm/panthor/panthor_mmu.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -523,27 +523,29 @@ static int wait_ready(struct panthor_device *ptdev, u32 as_nr)
523523
return ret;
524524
}
525525

526-
static int write_cmd(struct panthor_device *ptdev, u32 as_nr, u32 cmd)
526+
static int as_send_cmd_and_wait(struct panthor_device *ptdev, u32 as_nr, u32 cmd)
527527
{
528528
int status;
529529

530530
/* write AS_COMMAND when MMU is ready to accept another command */
531531
status = wait_ready(ptdev, as_nr);
532-
if (!status)
532+
if (!status) {
533533
gpu_write(ptdev, AS_COMMAND(as_nr), cmd);
534+
status = wait_ready(ptdev, as_nr);
535+
}
534536

535537
return status;
536538
}
537539

538-
static void lock_region(struct panthor_device *ptdev, u32 as_nr,
539-
u64 region_start, u64 size)
540+
static int lock_region(struct panthor_device *ptdev, u32 as_nr,
541+
u64 region_start, u64 size)
540542
{
541543
u8 region_width;
542544
u64 region;
543545
u64 region_end = region_start + size;
544546

545547
if (!size)
546-
return;
548+
return 0;
547549

548550
/*
549551
* The locked region is a naturally aligned power of 2 block encoded as
@@ -566,7 +568,7 @@ static void lock_region(struct panthor_device *ptdev, u32 as_nr,
566568

567569
/* Lock the region that needs to be updated */
568570
gpu_write64(ptdev, AS_LOCKADDR(as_nr), region);
569-
write_cmd(ptdev, as_nr, AS_COMMAND_LOCK);
571+
return as_send_cmd_and_wait(ptdev, as_nr, AS_COMMAND_LOCK);
570572
}
571573

572574
static int mmu_hw_do_operation_locked(struct panthor_device *ptdev, int as_nr,
@@ -599,9 +601,7 @@ static int mmu_hw_do_operation_locked(struct panthor_device *ptdev, int as_nr,
599601
* power it up
600602
*/
601603

602-
lock_region(ptdev, as_nr, iova, size);
603-
604-
ret = wait_ready(ptdev, as_nr);
604+
ret = lock_region(ptdev, as_nr, iova, size);
605605
if (ret)
606606
return ret;
607607

@@ -614,10 +614,7 @@ static int mmu_hw_do_operation_locked(struct panthor_device *ptdev, int as_nr,
614614
* at the end of the GPU_CONTROL cache flush command, unlike
615615
* AS_COMMAND_FLUSH_MEM or AS_COMMAND_FLUSH_PT.
616616
*/
617-
write_cmd(ptdev, as_nr, AS_COMMAND_UNLOCK);
618-
619-
/* Wait for the unlock command to complete */
620-
return wait_ready(ptdev, as_nr);
617+
return as_send_cmd_and_wait(ptdev, as_nr, AS_COMMAND_UNLOCK);
621618
}
622619

623620
static int mmu_hw_do_operation(struct panthor_vm *vm,
@@ -646,7 +643,7 @@ static int panthor_mmu_as_enable(struct panthor_device *ptdev, u32 as_nr,
646643
gpu_write64(ptdev, AS_MEMATTR(as_nr), memattr);
647644
gpu_write64(ptdev, AS_TRANSCFG(as_nr), transcfg);
648645

649-
return write_cmd(ptdev, as_nr, AS_COMMAND_UPDATE);
646+
return as_send_cmd_and_wait(ptdev, as_nr, AS_COMMAND_UPDATE);
650647
}
651648

652649
static int panthor_mmu_as_disable(struct panthor_device *ptdev, u32 as_nr)
@@ -661,7 +658,7 @@ static int panthor_mmu_as_disable(struct panthor_device *ptdev, u32 as_nr)
661658
gpu_write64(ptdev, AS_MEMATTR(as_nr), 0);
662659
gpu_write64(ptdev, AS_TRANSCFG(as_nr), AS_TRANSCFG_ADRMODE_UNMAPPED);
663660

664-
return write_cmd(ptdev, as_nr, AS_COMMAND_UPDATE);
661+
return as_send_cmd_and_wait(ptdev, as_nr, AS_COMMAND_UPDATE);
665662
}
666663

667664
static u32 panthor_mmu_fault_mask(struct panthor_device *ptdev, u32 value)

0 commit comments

Comments
 (0)