mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Liviu Dudau <liviu.dudau@arm.com>
To: Boris Brezillon <boris.brezillon@collabora.com>
Cc: Steven Price <steven.price@arm.com>,
	Akash Goel <akash.goel@arm.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Chia-I Wu <olvaffe@gmail.com>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] drm/panthor: Fully disable the AS even if it's going to be re-assigned
Date: Fri, 16 Oct 2026 11:38:54 +0100	[thread overview]
Message-ID: <atH-vsYXtgKOk2D3@e142607> (raw)
In-Reply-To: <20260924-panthor-mmu-fixes-v1-2-e25f9b106466@collabora.com>

On Thu, Sep 24, 2026 at 02:30:44PM +0200, Boris Brezillon wrote:
> We're trying to be smart by skipping the UPDATE(UNMAPPED) step, but
> it remains to be proven it adds any noticeable overhead. Moreover, it's
> breaking the assumption that, once the VM is unbound, no access can
> happen on it.
> 
> For instance, say the panthor_mmu_as_enable() call in panthor_vm_active()
> fails after we've called panthor_vm_release_as_locked(), we're now in a
> state where the HW still points to the old page table, but SW slot points
> to the new VM, which is not truly HW-bound.
> 
> If, after the as_slots lock is released, the evicted VM itself is
> released, the HW might have access to memory that has been returned
> to the system until the reset we scheduled (because of the faulty
> AS_COMMAND) is effective.
> 
> Let's make this bullet-proof by doing a full bound -> unbound -> bound
> cycle on AS slot recycling.
> 
> Fixes: 32e593d74c39 ("drm/panthor: Make sure caches are flushed/invalidated when an AS is recycled")
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>

Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>

Best regards,
Liviu

> ---
>  drivers/gpu/drm/panthor/panthor_mmu.c | 21 +++++++--------------
>  1 file changed, 7 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c
> index 7e98084b9a1e..038a092fd08c 100644
> --- a/drivers/gpu/drm/panthor/panthor_mmu.c
> +++ b/drivers/gpu/drm/panthor/panthor_mmu.c
> @@ -620,8 +620,7 @@ 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,
> -				  bool recycle_slot)
> +static int panthor_mmu_as_disable(struct panthor_device *ptdev, u32 as_nr)
>  {
>  	struct panthor_mmu *mmu = ptdev->mmu;
>  	struct panthor_vm *vm = ptdev->mmu->as.slots[as_nr].vm;
> @@ -645,12 +644,6 @@ static int panthor_mmu_as_disable(struct panthor_device *ptdev, u32 as_nr,
>  			return ret;
>  	}
>  
> -	/* If the slot is going to be used immediately, don't bother changing
> -	 * the config.
> -	 */
> -	if (recycle_slot)
> -		return 0;
> -
>  	gpu_write64(mmu->iomem, AS_TRANSTAB(as_nr), 0);
>  	gpu_write64(mmu->iomem, AS_MEMATTR(as_nr), 0);
>  	gpu_write64(mmu->iomem, AS_TRANSCFG(as_nr), AS_TRANSCFG_ADRMODE_UNMAPPED);
> @@ -777,7 +770,7 @@ 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);
> +		ret = panthor_mmu_as_disable(ptdev, as);
>  		if (ret)
>  			goto out_unlock;
>  
> @@ -919,7 +912,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, false);
> +		panthor_mmu_as_disable(ptdev, vm->as.id);
>  		drm_dev_exit(cookie);
>  	}
>  	mutex_unlock(&ptdev->mmu->as.slots_lock);
> @@ -1911,7 +1904,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, false);
> +		panthor_mmu_as_disable(ptdev, as);
>  		mutex_unlock(&ptdev->mmu->as.slots_lock);
>  
>  		status &= ~mask;
> @@ -1940,7 +1933,7 @@ void panthor_mmu_suspend(struct panthor_device *ptdev)
>  
>  		if (vm) {
>  			drm_WARN_ON(&ptdev->base,
> -				    panthor_mmu_as_disable(ptdev, i, false));
> +				    panthor_mmu_as_disable(ptdev, i));
>  			panthor_vm_release_as_locked(vm);
>  		}
>  	}
> @@ -2065,7 +2058,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, false);
> +			panthor_mmu_as_disable(ptdev, vm->as.id);
>  			drm_dev_exit(cookie);
>  		}
>  
> @@ -3360,7 +3353,7 @@ void panthor_mmu_unplug(struct panthor_device *ptdev)
>  
>  		if (vm) {
>  			drm_WARN_ON(&ptdev->base,
> -				    panthor_mmu_as_disable(ptdev, i, false));
> +				    panthor_mmu_as_disable(ptdev, i));
>  			panthor_vm_release_as_locked(vm);
>  		}
>  	}
> 
> -- 
> 2.55.0
> 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯

  reply	other threads:[~2026-10-16 10:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24 12:30 [PATCH 0/3] drm/panthor: Misc MMU fixes/robustness improvements Boris Brezillon
2026-09-24 12:30 ` [PATCH 1/3] drm/panthor: Don't invalidate OTHER caches Boris Brezillon
2026-10-16 10:37   ` Liviu Dudau
2026-09-24 12:30 ` [PATCH 2/3] drm/panthor: Fully disable the AS even if it's going to be re-assigned Boris Brezillon
2026-10-16 10:38   ` Liviu Dudau [this message]
2026-09-24 12:30 ` [PATCH 3/3] drm/panthor: Move cache-flush after UPDATE(UNMAPPED) Boris Brezillon
2026-10-16 10:41   ` Liviu Dudau
2026-10-16 12:25 ` [PATCH 0/3] drm/panthor: Misc MMU fixes/robustness improvements Liviu Dudau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=atH-vsYXtgKOk2D3@e142607 \
    --to=liviu.dudau@arm.com \
    --cc=airlied@gmail.com \
    --cc=akash.goel@arm.com \
    --cc=boris.brezillon@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=olvaffe@gmail.com \
    --cc=simona@ffwll.ch \
    --cc=steven.price@arm.com \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®