Skip to content

Commit

Permalink
drm/panthor: flush FW AS caches in slow reset path
Browse files Browse the repository at this point in the history
In the off-chance that waiting for the firmware to signal its booted status
timed out in the fast reset path, one must flush the cache lines for the
entire FW VM address space before reloading the regions, otherwise stale
values eventually lead to a scheduler job timeout.

Fixes: 647810e ("drm/panthor: Add the MMU/VM logical block")
Cc: stable@vger.kernel.org
Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>
Acked-by: Liviu Dudau <liviu.dudau@arm.com>
Reviewed-by: Steven Price <steven.price@arm.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240902130237.3440720-1-adrian.larumbe@collabora.com
  • Loading branch information
Adrián Larumbe authored and Boris Brezillon committed Sep 5, 2024
1 parent 76dce2a commit 7de295d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
8 changes: 7 additions & 1 deletion drivers/gpu/drm/panthor/panthor_fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,12 @@ int panthor_fw_post_reset(struct panthor_device *ptdev)
panthor_fw_stop(ptdev);
ptdev->fw->fast_reset = false;
drm_err(&ptdev->base, "FW fast reset failed, trying a slow reset");

ret = panthor_vm_flush_all(ptdev->fw->vm);
if (ret) {
drm_err(&ptdev->base, "FW slow reset failed (couldn't flush FW's AS l2cache)");
return ret;
}
}

/* Reload all sections, including RO ones. We're not supposed
Expand All @@ -1099,7 +1105,7 @@ int panthor_fw_post_reset(struct panthor_device *ptdev)

ret = panthor_fw_start(ptdev);
if (ret) {
drm_err(&ptdev->base, "FW slow reset failed");
drm_err(&ptdev->base, "FW slow reset failed (couldn't start the FW )");
return ret;
}

Expand Down
21 changes: 18 additions & 3 deletions drivers/gpu/drm/panthor/panthor_mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,12 @@ static int mmu_hw_do_operation_locked(struct panthor_device *ptdev, int as_nr,
if (as_nr < 0)
return 0;

/*
* If the AS number is greater than zero, then we can be sure
* the device is up and running, so we don't need to explicitly
* power it up
*/

if (op != AS_COMMAND_UNLOCK)
lock_region(ptdev, as_nr, iova, size);

Expand Down Expand Up @@ -874,14 +880,23 @@ static int panthor_vm_flush_range(struct panthor_vm *vm, u64 iova, u64 size)
if (!drm_dev_enter(&ptdev->base, &cookie))
return 0;

/* Flush the PTs only if we're already awake */
if (pm_runtime_active(ptdev->base.dev))
ret = mmu_hw_do_operation(vm, iova, size, AS_COMMAND_FLUSH_PT);
ret = mmu_hw_do_operation(vm, iova, size, AS_COMMAND_FLUSH_PT);

drm_dev_exit(cookie);
return ret;
}

/**
* panthor_vm_flush_all() - Flush L2 caches for the entirety of a VM's AS
* @vm: VM whose cache to flush
*
* Return: 0 on success, a negative error code if flush failed.
*/
int panthor_vm_flush_all(struct panthor_vm *vm)
{
return panthor_vm_flush_range(vm, vm->base.mm_start, vm->base.mm_range);
}

static int panthor_vm_unmap_pages(struct panthor_vm *vm, u64 iova, u64 size)
{
struct panthor_device *ptdev = vm->ptdev;
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/panthor/panthor_mmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ panthor_vm_get_bo_for_va(struct panthor_vm *vm, u64 va, u64 *bo_offset);
int panthor_vm_active(struct panthor_vm *vm);
void panthor_vm_idle(struct panthor_vm *vm);
int panthor_vm_as(struct panthor_vm *vm);
int panthor_vm_flush_all(struct panthor_vm *vm);

struct panthor_heap_pool *
panthor_vm_get_heap_pool(struct panthor_vm *vm, bool create);
Expand Down

0 comments on commit 7de295d

Please sign in to comment.