Commit 276e4116 authored by Boris Brezillon's avatar Boris Brezillon Committed by Liviu Dudau
Browse files

drm/panthor: Unlock the locked region before disabling an AS



An AS can be disabled in the middle of a VM operation (VM being
evicted from an AS slot, for instance). In that case, we need the
locked section to be unlocked before releasing the slot.

v2:
- Add an lockdep_assert_held() in panthor_mmu_as_disable()
- Collect R-bs

v3:
- Don't reset the locked_region range in the as_disable() path

Fixes: 6e2d3b3e ("drm/panthor: Add support for atomic page table updates")
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: default avatarLiviu Dudau <liviu.dudau@arm.com>
Reviewed-by: default avatarChia-I Wu <olvaffe@gmail.com>
Signed-off-by: default avatarLiviu Dudau <liviu.dudau@arm.com>
Link: https://patch.msgid.link/20251203121750.404340-4-boris.brezillon@collabora.com
parent 32e593d7
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -588,14 +588,24 @@ static int panthor_mmu_as_enable(struct panthor_device *ptdev, u32 as_nr,
static int panthor_mmu_as_disable(struct panthor_device *ptdev, u32 as_nr,
				  bool recycle_slot)
{
	struct panthor_vm *vm = ptdev->mmu->as.slots[as_nr].vm;
	int ret;

	lockdep_assert_held(&ptdev->mmu->as.slots_lock);

	/* Flush+invalidate RW caches, invalidate RO ones. */
	ret = panthor_gpu_flush_caches(ptdev, CACHE_CLEAN | CACHE_INV,
				       CACHE_CLEAN | CACHE_INV, CACHE_INV);
	if (ret)
		return ret;

	if (vm && vm->locked_region.size) {
		/* Unlock the region if there's a lock pending. */
		ret = as_send_cmd_and_wait(ptdev, vm->as.id, AS_COMMAND_UNLOCK);
		if (ret)
			return ret;
	}

	/* If the slot is going to be used immediately, don't bother changing
	 * the config.
	 */