From: Steven Price <steven.price@arm.com>
To: Chia-I Wu <olvaffe@gmail.com>
Cc: Boris Brezillon <boris.brezillon@collabora.com>,
Liviu Dudau <liviu.dudau@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>,
Grant Likely <grant.likely@linaro.org>,
Heiko Stuebner <heiko@sntech.de>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 02/10] drm/panthor: rename and document lock_region
Date: Fri, 3 Oct 2025 15:13:05 +0100 [thread overview]
Message-ID: <2404993b-a96c-4a99-bfba-3f9e3031c90b@arm.com> (raw)
In-Reply-To: <CAPaKu7TT_Uph+ccNQ4q2+y9Pbmm-nLnPOgsLwEuZGnON26EStg@mail.gmail.com>
On 03/10/2025 01:46, Chia-I Wu wrote:
> On Thu, Oct 2, 2025 at 3:41 AM Steven Price <steven.price@arm.com> wrote:
>>
>> On 16/09/2025 22:08, Chia-I Wu wrote:
>>> Rename lock_region to mmu_hw_cmd_lock.
>>>
>>> Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
>>> ---
>>> drivers/gpu/drm/panthor/panthor_mmu.c | 15 ++++++++++++---
>>> 1 file changed, 12 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c
>>> index d3af4f79012b4..8600d98842345 100644
>>> --- a/drivers/gpu/drm/panthor/panthor_mmu.c
>>> +++ b/drivers/gpu/drm/panthor/panthor_mmu.c
>>> @@ -545,8 +545,17 @@ static int write_cmd(struct panthor_device *ptdev, u32 as_nr, u32 cmd)
>>> return status;
>>> }
>>>
>>> -static void lock_region(struct panthor_device *ptdev, u32 as_nr,
>>> - u64 region_start, u64 size)
>>> +/**
>>> + * mmu_hw_cmd_lock() - Issue a LOCK command
>>> + * @ptdev: Device.
>>> + * @as_nr: AS to issue command to.
>>> + * @region_start: Start of the region.
>>> + * @size: Size of the region.
>>> + *
>>> + * Issue a LOCK command to invalidate MMU caches and block future transactions
>>> + * for a region.
>>
>> The LOCK command doesn't invalidate the caches - that's the UNLOCK
>> command. LOCK just blocks any memory accesses that target the region.
>>
>> [I guess the hardware implementation might flush TLBs to achieve the
>> block, but that's an implementation detail and shouldn't be relied upon].
> Hm, for LOCK, the doc I have says "MMU caches are invalidated." And
> for UNLOCK, there is actually no invalidation when the region is
> LOCK'ed.
Hmm, interesting. You are correct - I knew that it is possible to do an
UNLOCK without a LOCK and in that case it is the UNLOCK which performs
the invalidation. But looking back through the architecture
documentation it does actually state that the LOCK invalidates MMU
caches. So it appears I'm wrong - sorry about that.
>> I'm also not entirely clear what the benefit of this rename is? It's a
>> static function in a xxx_mmu.c file so it's fairly obvious this going to
>> MMU HW related. I also feel "_region" in the name makes it obvious that
>> there is a memory range that is affected by the lock.
> A big part of this file is for in-memory page tables. "mmu_hw_" prefix
> is used by some functions that write the regs. This (and following)
> renames prefix other such functions by "mmu_hw_" for consistency.
Well before this series there are a total of two functions currently
which have the mmu_hw_ prefix:
* mmu_hw_do_operation_locked
* mmu_hw_do_operation
Which I think needed something more than "do_operation", possibly
"do_mmu_operation" or "do_mmu_hw_operation" might have been better, but
I don't think there's a great difference. Generally we don't include a
prefix on static functions because they are local to the file.
> Then there are "mmu_hw_cmd_FOO" for each hw cmd FOO. That's why the
> "_region' part gets dropped.
It's interesting that the documentation says:
> LOCK (2)
>
> Issues a lock region command to the MMU
So while I can't deny that the command is called "LOCK", informally we
do call it "lock region" more commonly because it describes the purpose
better.
Thanks,
Steve
>>
>> Thanks,
>> Steve
>>
>>> + */
>>> +static void mmu_hw_cmd_lock(struct panthor_device *ptdev, u32 as_nr, u64 region_start, u64 size)
>>> {
>>> u8 region_width;
>>> u64 region;
>>> @@ -609,7 +618,7 @@ static int mmu_hw_do_operation_locked(struct panthor_device *ptdev, int as_nr,
>>> * power it up
>>> */
>>>
>>> - lock_region(ptdev, as_nr, iova, size);
>>> + mmu_hw_cmd_lock(ptdev, as_nr, iova, size);
>>>
>>> ret = mmu_hw_wait_ready(ptdev, as_nr);
>>> if (ret)
>>
next prev parent reply other threads:[~2025-10-03 14:13 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-16 21:08 [PATCH 00/10] drm/panthor: minor AS_CONTROL clean up Chia-I Wu
2025-09-16 21:08 ` [PATCH 01/10] drm/panthor: rename and document wait_ready Chia-I Wu
2025-09-16 21:08 ` [PATCH 02/10] drm/panthor: rename and document lock_region Chia-I Wu
2025-10-02 10:41 ` Steven Price
2025-10-03 0:46 ` Chia-I Wu
2025-10-03 14:13 ` Steven Price [this message]
2025-09-16 21:08 ` [PATCH 03/10] drm/panthor: add mmu_hw_cmd_unlock Chia-I Wu
2025-09-16 21:08 ` [PATCH 04/10] drm/panthor: add mmu_hw_cmd_update Chia-I Wu
2025-10-02 10:41 ` Steven Price
2025-09-16 21:08 ` [PATCH 05/10] drm/panthor: rename and document mmu_hw_do_operation_locked Chia-I Wu
2025-10-02 10:41 ` Steven Price
2025-10-03 0:31 ` Chia-I Wu
2025-10-03 14:13 ` Steven Price
2025-10-03 16:35 ` Chia-I Wu
2025-09-16 21:08 ` [PATCH 06/10] drm/panthor: remove write_cmd Chia-I Wu
2025-10-02 10:41 ` Steven Price
2025-09-16 21:08 ` [PATCH 07/10] drm/panthor: remove unnecessary mmu_hw_wait_ready calls Chia-I Wu
2025-10-02 10:41 ` Steven Price
2025-10-03 0:23 ` Chia-I Wu
2025-10-03 14:13 ` Steven Price
2025-10-03 16:46 ` Chia-I Wu
2025-09-16 21:08 ` [PATCH 08/10] drm/panthor: improve error handling for mmu_hw_flush_caches Chia-I Wu
2025-09-16 21:08 ` [PATCH 09/10] drm/panthor: move size check to mmu_hw_flush_caches Chia-I Wu
2025-09-16 21:08 ` [PATCH 10/10] drm/panthor: simplify mmu_hw_flush_caches Chia-I Wu
2025-10-02 10:48 ` [PATCH 00/10] drm/panthor: minor AS_CONTROL clean up 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=2404993b-a96c-4a99-bfba-3f9e3031c90b@arm.com \
--to=steven.price@arm.com \
--cc=airlied@gmail.com \
--cc=boris.brezillon@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=grant.likely@linaro.org \
--cc=heiko@sntech.de \
--cc=linux-kernel@vger.kernel.org \
--cc=liviu.dudau@arm.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=olvaffe@gmail.com \
--cc=simona@ffwll.ch \
--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®