All of lore.kernel.org
 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>,
	"Adrián Larumbe" <adrian.larumbe@collabora.com>,
	dri-devel@lists.freedesktop.org,
	"Akash Goel" <akash.goel@arm.com>,
	kernel@collabora.com
Subject: Re: [PATCH v1 2/3] drm/panthor: Make sure caches are flushed/invalidated when an AS is recycled
Date: Tue, 2 Dec 2025 14:21:40 +0000	[thread overview]
Message-ID: <aS719IXbHLkD2gsj@e142607> (raw)
In-Reply-To: <20251202133538.83078-3-boris.brezillon@collabora.com>

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 <boris.brezillon@collabora.com>

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

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
> 

  reply	other threads:[~2025-12-02 14:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-02 13:35 [PATCH v1 0/3] drm/panthor: Fix regressions introduced recently Boris Brezillon
2025-12-02 13:35 ` [PATCH v1 1/3] drm/panthor: Drop a WARN_ON() in group_free_queue() Boris Brezillon
2025-12-02 14:20   ` Liviu Dudau
2025-12-02 13:35 ` [PATCH v1 2/3] drm/panthor: Make sure caches are flushed/invalidated when an AS is recycled Boris Brezillon
2025-12-02 14:21   ` Liviu Dudau [this message]
2025-12-02 13:35 ` [PATCH v1 3/3] drm/panthor: Unlock the locked region before disabling an AS Boris Brezillon
2025-12-02 14:28   ` Liviu Dudau
2025-12-02 15:09   ` Akash Goel
2025-12-02 16:21     ` Boris Brezillon
2025-12-02 23:30 ` [PATCH v1 0/3] drm/panthor: Fix regressions introduced recently Chia-I Wu

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=aS719IXbHLkD2gsj@e142607 \
    --to=liviu.dudau@arm.com \
    --cc=adrian.larumbe@collabora.com \
    --cc=akash.goel@arm.com \
    --cc=boris.brezillon@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel@collabora.com \
    --cc=steven.price@arm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.