From: Chia-I Wu <olvaffe@gmail.com>
To: Boris Brezillon <boris.brezillon@collabora.com>,
Steven Price <steven.price@arm.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: [PATCH 10/10] drm/panthor: simplify mmu_hw_flush_caches
Date: Tue, 16 Sep 2025 14:08:23 -0700 [thread overview]
Message-ID: <20250916210823.4033529-11-olvaffe@gmail.com> (raw)
In-Reply-To: <20250916210823.4033529-1-olvaffe@gmail.com>
Simplify flush op to a bool to control whether LSC is
flushed/invalidated. Remove mmu_hw_do_operation helper.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
---
drivers/gpu/drm/panthor/panthor_mmu.c | 42 ++++++---------------------
1 file changed, 9 insertions(+), 33 deletions(-)
diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c
index 743e9342eece7..5418f079444ce 100644
--- a/drivers/gpu/drm/panthor/panthor_mmu.c
+++ b/drivers/gpu/drm/panthor/panthor_mmu.c
@@ -613,33 +613,20 @@ static void mmu_hw_cmd_unlock(struct panthor_device *ptdev, u32 as_nr)
* @as_nr: AS to issue command to.
* @iova: Start of the region.
* @size: Size of the region.
- * @op: AS_COMMAND_FLUSH_*
+ * @flush_lsc: True if LSC should be flushed/invalidated.
*
* Issue LOCK/GPU_FLUSH_CACHES/UNLOCK commands in order to flush and
* invalidate L2/MMU/LSC caches for a region.
*
* Return: 0 on success, a negative error code otherwise.
*/
-static int mmu_hw_flush_caches(struct panthor_device *ptdev, int as_nr, u64 iova, u64 size, u32 op)
+static int mmu_hw_flush_caches(struct panthor_device *ptdev, int as_nr, u64 iova, u64 size,
+ bool flush_lsc)
{
const u32 l2_flush_op = CACHE_CLEAN | CACHE_INV;
- u32 lsc_flush_op;
+ const u32 lsc_flush_op = flush_lsc ? l2_flush_op : 0;
int ret;
- lockdep_assert_held(&ptdev->mmu->as.slots_lock);
-
- switch (op) {
- case AS_COMMAND_FLUSH_MEM:
- lsc_flush_op = CACHE_CLEAN | CACHE_INV;
- break;
- case AS_COMMAND_FLUSH_PT:
- lsc_flush_op = 0;
- break;
- default:
- drm_WARN(&ptdev->base, 1, "Unexpected AS_COMMAND: %d", op);
- return -EINVAL;
- }
-
if (as_nr < 0 || !size)
return 0;
@@ -671,25 +658,12 @@ static int mmu_hw_flush_caches(struct panthor_device *ptdev, int as_nr, u64 iova
return ret;
}
-static int mmu_hw_do_operation(struct panthor_vm *vm,
- u64 iova, u64 size, u32 op)
-{
- struct panthor_device *ptdev = vm->ptdev;
- int ret;
-
- mutex_lock(&ptdev->mmu->as.slots_lock);
- ret = mmu_hw_flush_caches(ptdev, vm->as.id, iova, size, op);
- mutex_unlock(&ptdev->mmu->as.slots_lock);
-
- return ret;
-}
-
static int panthor_mmu_as_enable(struct panthor_device *ptdev, u32 as_nr,
u64 transtab, u64 transcfg, u64 memattr)
{
int ret;
- ret = mmu_hw_flush_caches(ptdev, as_nr, 0, ~0ULL, AS_COMMAND_FLUSH_MEM);
+ ret = mmu_hw_flush_caches(ptdev, as_nr, 0, ~0ULL, true);
if (ret)
return ret;
@@ -706,7 +680,7 @@ static int panthor_mmu_as_disable(struct panthor_device *ptdev, u32 as_nr)
{
int ret;
- ret = mmu_hw_flush_caches(ptdev, as_nr, 0, ~0ULL, AS_COMMAND_FLUSH_MEM);
+ ret = mmu_hw_flush_caches(ptdev, as_nr, 0, ~0ULL, true);
if (ret)
return ret;
@@ -962,7 +936,9 @@ static int panthor_vm_flush_range(struct panthor_vm *vm, u64 iova, u64 size)
if (!drm_dev_enter(&ptdev->base, &cookie))
return 0;
- ret = mmu_hw_do_operation(vm, iova, size, AS_COMMAND_FLUSH_PT);
+ mutex_lock(&ptdev->mmu->as.slots_lock);
+ ret = mmu_hw_flush_caches(ptdev, vm->as.id, iova, size, false);
+ mutex_unlock(&ptdev->mmu->as.slots_lock);
drm_dev_exit(cookie);
return ret;
--
2.51.0.384.g4c02a37b29-goog
next prev parent reply other threads:[~2025-09-16 21:08 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
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 ` Chia-I Wu [this message]
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=20250916210823.4033529-11-olvaffe@gmail.com \
--to=olvaffe@gmail.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=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