From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DD2BAD116F6 for ; Tue, 2 Dec 2025 14:22:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 243C510E67D; Tue, 2 Dec 2025 14:22:01 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by gabe.freedesktop.org (Postfix) with ESMTP id DC2B710E674 for ; Tue, 2 Dec 2025 14:21:59 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 347E2153B for ; Tue, 2 Dec 2025 06:21:52 -0800 (PST) Received: from [10.2.10.34] (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 58A293F73B for ; Tue, 2 Dec 2025 06:21:59 -0800 (PST) Date: Tue, 2 Dec 2025 14:21:40 +0000 From: Liviu Dudau To: Boris Brezillon Cc: Steven Price , =?utf-8?Q?Adri=C3=A1n?= Larumbe , dri-devel@lists.freedesktop.org, Akash Goel , kernel@collabora.com Subject: Re: [PATCH v1 2/3] drm/panthor: Make sure caches are flushed/invalidated when an AS is recycled Message-ID: References: <20251202133538.83078-1-boris.brezillon@collabora.com> <20251202133538.83078-3-boris.brezillon@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20251202133538.83078-3-boris.brezillon@collabora.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Tue, Dec 02, 2025 at 02:35:37PM +0100, Boris Brezillon wrote: > When we re-assign a slot to a different VM, we need to make sure the > old VM caches are flushed before doing the switch. Specialize > panthor_mmu_as_disable() so we can skip the slot programmation while > still getting the cache flushing, and call this helper from > panthor_vm_active() when an idle slot is recycled. > > Fixes: 6e2d3b3e8589 ("drm/panthor: Add support for atomic page table updates") > Signed-off-by: Boris Brezillon Reviewed-by: Liviu Dudau Best regards, Liviu > --- > drivers/gpu/drm/panthor/panthor_mmu.c | 26 ++++++++++++++++++++------ > 1 file changed, 20 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c > index 8ba5259e3d28..3644af1a8e56 100644 > --- a/drivers/gpu/drm/panthor/panthor_mmu.c > +++ b/drivers/gpu/drm/panthor/panthor_mmu.c > @@ -585,7 +585,8 @@ static int panthor_mmu_as_enable(struct panthor_device *ptdev, u32 as_nr, > return as_send_cmd_and_wait(ptdev, as_nr, AS_COMMAND_UPDATE); > } > > -static int panthor_mmu_as_disable(struct panthor_device *ptdev, u32 as_nr) > +static int panthor_mmu_as_disable(struct panthor_device *ptdev, u32 as_nr, > + bool recycle_slot) > { > int ret; > > @@ -595,6 +596,12 @@ static int panthor_mmu_as_disable(struct panthor_device *ptdev, u32 as_nr) > if (ret) > return ret; > > + /* If the slot is going to be used immediately, don't bother changing > + * the config. > + */ > + if (recycle_slot) > + return 0; > + > gpu_write64(ptdev, AS_TRANSTAB(as_nr), 0); > gpu_write64(ptdev, AS_MEMATTR(as_nr), 0); > gpu_write64(ptdev, AS_TRANSCFG(as_nr), AS_TRANSCFG_ADRMODE_UNMAPPED); > @@ -714,6 +721,11 @@ int panthor_vm_active(struct panthor_vm *vm) > > drm_WARN_ON(&ptdev->base, refcount_read(&lru_vm->as.active_cnt)); > as = lru_vm->as.id; > + > + ret = panthor_mmu_as_disable(ptdev, as, true); > + if (ret) > + goto out_unlock; > + > panthor_vm_release_as_locked(lru_vm); > } > > @@ -853,7 +865,7 @@ static void panthor_vm_declare_unusable(struct panthor_vm *vm) > vm->unusable = true; > mutex_lock(&ptdev->mmu->as.slots_lock); > if (vm->as.id >= 0 && drm_dev_enter(&ptdev->base, &cookie)) { > - panthor_mmu_as_disable(ptdev, vm->as.id); > + panthor_mmu_as_disable(ptdev, vm->as.id, false); > drm_dev_exit(cookie); > } > mutex_unlock(&ptdev->mmu->as.slots_lock); > @@ -1780,7 +1792,7 @@ static void panthor_mmu_irq_handler(struct panthor_device *ptdev, u32 status) > ptdev->mmu->as.slots[as].vm->unhandled_fault = true; > > /* Disable the MMU to kill jobs on this AS. */ > - panthor_mmu_as_disable(ptdev, as); > + panthor_mmu_as_disable(ptdev, as, false); > mutex_unlock(&ptdev->mmu->as.slots_lock); > > status &= ~mask; > @@ -1809,7 +1821,8 @@ void panthor_mmu_suspend(struct panthor_device *ptdev) > struct panthor_vm *vm = ptdev->mmu->as.slots[i].vm; > > if (vm) { > - drm_WARN_ON(&ptdev->base, panthor_mmu_as_disable(ptdev, i)); > + drm_WARN_ON(&ptdev->base, > + panthor_mmu_as_disable(ptdev, i, false)); > panthor_vm_release_as_locked(vm); > } > } > @@ -1930,7 +1943,7 @@ static void panthor_vm_free(struct drm_gpuvm *gpuvm) > int cookie; > > if (drm_dev_enter(&ptdev->base, &cookie)) { > - panthor_mmu_as_disable(ptdev, vm->as.id); > + panthor_mmu_as_disable(ptdev, vm->as.id, false); > drm_dev_exit(cookie); > } > > @@ -2790,7 +2803,8 @@ void panthor_mmu_unplug(struct panthor_device *ptdev) > struct panthor_vm *vm = ptdev->mmu->as.slots[i].vm; > > if (vm) { > - drm_WARN_ON(&ptdev->base, panthor_mmu_as_disable(ptdev, i)); > + drm_WARN_ON(&ptdev->base, > + panthor_mmu_as_disable(ptdev, i, false)); > panthor_vm_release_as_locked(vm); > } > } > -- > 2.51.1 >