All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@collabora.com>
To: Steven Price <steven.price@arm.com>
Cc: "Liviu Dudau" <liviu.dudau@arm.com>,
	"Adrián Larumbe" <adrian.larumbe@collabora.com>,
	dri-devel@lists.freedesktop.org,
	"Akash Goel" <akash.goel@arm.com>,
	"Karunika Choo" <karunika.choo@arm.com>,
	kernel@collabora.com
Subject: Re: [PATCH v2 2/6] drm/panthor: Kill lock_region()
Date: Mon, 17 Nov 2025 16:46:39 +0100	[thread overview]
Message-ID: <20251117164639.5018b9ca@fedora> (raw)
In-Reply-To: <bf18504d-5ff6-47f2-9936-3c798a337816@arm.com>

On Mon, 17 Nov 2025 12:44:58 +0000
Steven Price <steven.price@arm.com> wrote:

> On 13/11/2025 10:39, Boris Brezillon wrote:
> > The meat in lock_region() is about packing a region range into a
> > single u64. The rest is just a regular reg write plus a
> > as_send_cmd_and_wait() call that can easily be inlined in
> > mmu_hw_do_operation_locked().
> > 
> > v2:
> > - New patch
> > 
> > Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> > ---
> >  drivers/gpu/drm/panthor/panthor_mmu.c | 14 +++++---------
> >  1 file changed, 5 insertions(+), 9 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c
> > index 186048fc2c25..f109c1588186 100644
> > --- a/drivers/gpu/drm/panthor/panthor_mmu.c
> > +++ b/drivers/gpu/drm/panthor/panthor_mmu.c
> > @@ -538,11 +538,9 @@ static int as_send_cmd_and_wait(struct panthor_device *ptdev, u32 as_nr, u32 cmd
> >  	return status;
> >  }
> >  
> > -static int lock_region(struct panthor_device *ptdev, u32 as_nr,
> > -		       u64 region_start, u64 size)
> > +static u64 pack_region_range(u64 region_start, u64 size)
> >  {
> >  	u8 region_width;
> > -	u64 region;
> >  	u64 region_end = region_start + size;
> >  
> >  	if (!size)  
> Extra context:
> >		return 0;  
> Rather than skipping the lock for size==0 you are now performing a lock
> with LOCKADDR=0. The best documentation I can find for that says (for
> LOCKADDR_SIZE in the Midgard architecture): "Values in the range 0 to 10
> are undefined and should not be used".
> 
> I think later versions upped the minimum to 14 (log2(1<<15)-1) for
> reasons due to supporting larger page sizes.
> 
> While I suspect this might work (since we don't actually need a lock
> region when size==0) I don't think we should be relying on undefined
> behaviour.
> 
> I think the simple solution is to move the size==0 check up into the caller.

Right. I addressed that in patch 4 (which basically removes
mmu_hw_do_operation_locked()), but I can do it here too.

> 
> Thanks,
> Steve
> 
> > @@ -565,11 +563,7 @@ static int lock_region(struct panthor_device *ptdev, u32 as_nr,
> >  	 */
> >  	region_start &= GENMASK_ULL(63, region_width);
> >  
> > -	region = region_width | region_start;
> > -
> > -	/* Lock the region that needs to be updated */
> > -	gpu_write64(ptdev, AS_LOCKADDR(as_nr), region);
> > -	return as_send_cmd_and_wait(ptdev, as_nr, AS_COMMAND_LOCK);
> > +	return region_width | region_start;
> >  }
> >  
> >  static int mmu_hw_do_operation_locked(struct panthor_device *ptdev, int as_nr,
> > @@ -602,7 +596,9 @@ static int mmu_hw_do_operation_locked(struct panthor_device *ptdev, int as_nr,
> >  	 * power it up
> >  	 */
> >  
> > -	ret = lock_region(ptdev, as_nr, iova, size);
> > +	/* Lock the region that needs to be updated */
> > +	gpu_write64(ptdev, AS_LOCKADDR(as_nr), pack_region_range(iova, size));
> > +	ret = as_send_cmd_and_wait(ptdev, as_nr, AS_COMMAND_LOCK);
> >  	if (ret)
> >  		return ret;
> >    
> 


  reply	other threads:[~2025-11-17 15:46 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-13 10:39 [PATCH v2 0/6] drm/panthor: Misc fixes Boris Brezillon
2025-11-13 10:39 ` [PATCH v2 1/6] drm/panthor: Always wait after sending a command to an AS Boris Brezillon
2025-11-17 12:29   ` Steven Price
2025-11-13 10:39 ` [PATCH v2 2/6] drm/panthor: Kill lock_region() Boris Brezillon
2025-11-17 12:44   ` Steven Price
2025-11-17 15:46     ` Boris Brezillon [this message]
2025-11-13 10:39 ` [PATCH v2 3/6] drm/panthor: Recover from panthor_gpu_flush_caches() failures Boris Brezillon
2025-11-17 14:02   ` Steven Price
2025-11-17 15:44     ` Boris Brezillon
2025-11-17 16:10       ` Steven Price
2025-11-13 10:39 ` [PATCH v2 4/6] drm/panthor: Add support for atomic page table updates Boris Brezillon
2025-11-17 14:26   ` Steven Price
2025-11-13 10:39 ` [PATCH v2 5/6] drm/panthor: Make panthor_vm_[un]map_pages() more robust Boris Brezillon
2025-11-17 15:07   ` Steven Price
2025-11-13 10:39 ` [PATCH v2 6/6] drm/panthor: Relax a check in panthor_sched_pre_reset() Boris Brezillon
2025-11-17 15:12   ` Steven Price

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=20251117164639.5018b9ca@fedora \
    --to=boris.brezillon@collabora.com \
    --cc=adrian.larumbe@collabora.com \
    --cc=akash.goel@arm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=karunika.choo@arm.com \
    --cc=kernel@collabora.com \
    --cc=liviu.dudau@arm.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.