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 06/10] drm/panthor: remove write_cmd
Date: Tue, 16 Sep 2025 14:08:19 -0700 [thread overview]
Message-ID: <20250916210823.4033529-7-olvaffe@gmail.com> (raw)
In-Reply-To: <20250916210823.4033529-1-olvaffe@gmail.com>
Call mmu_hw_wait_ready explicitly instead.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
---
drivers/gpu/drm/panthor/panthor_mmu.c | 46 +++++++++++++++------------
1 file changed, 25 insertions(+), 21 deletions(-)
diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c
index 7d1645a24129d..373871aeea9f4 100644
--- a/drivers/gpu/drm/panthor/panthor_mmu.c
+++ b/drivers/gpu/drm/panthor/panthor_mmu.c
@@ -533,18 +533,6 @@ static int mmu_hw_wait_ready(struct panthor_device *ptdev, u32 as_nr)
return ret;
}
-static int write_cmd(struct panthor_device *ptdev, u32 as_nr, u32 cmd)
-{
- int status;
-
- /* write AS_COMMAND when MMU is ready to accept another command */
- status = mmu_hw_wait_ready(ptdev, as_nr);
- if (!status)
- gpu_write(ptdev, AS_COMMAND(as_nr), cmd);
-
- return status;
-}
-
/**
* mmu_hw_cmd_update() - Issue an UPDATE command
* @ptdev: Device.
@@ -556,14 +544,14 @@ static int write_cmd(struct panthor_device *ptdev, u32 as_nr, u32 cmd)
* Issue an UPDATE command to invalidate MMU caches and update the translation
* table.
*/
-static int mmu_hw_cmd_update(struct panthor_device *ptdev, u32 as_nr, u64 transtab, u64 transcfg,
- u64 memattr)
+static void mmu_hw_cmd_update(struct panthor_device *ptdev, u32 as_nr, u64 transtab, u64 transcfg,
+ u64 memattr)
{
gpu_write64(ptdev, AS_TRANSTAB(as_nr), transtab);
gpu_write64(ptdev, AS_MEMATTR(as_nr), memattr);
gpu_write64(ptdev, AS_TRANSCFG(as_nr), transcfg);
- return write_cmd(ptdev, as_nr, AS_COMMAND_UPDATE);
+ gpu_write(ptdev, AS_COMMAND(as_nr), AS_COMMAND_UPDATE);
}
/**
@@ -606,7 +594,7 @@ static void mmu_hw_cmd_lock(struct panthor_device *ptdev, u32 as_nr, u64 region_
/* Lock the region that needs to be updated */
gpu_write64(ptdev, AS_LOCKADDR(as_nr), region);
- write_cmd(ptdev, as_nr, AS_COMMAND_LOCK);
+ gpu_write(ptdev, AS_COMMAND(as_nr), AS_COMMAND_LOCK);
}
/**
@@ -619,7 +607,7 @@ static void mmu_hw_cmd_lock(struct panthor_device *ptdev, u32 as_nr, u64 region_
*/
static void mmu_hw_cmd_unlock(struct panthor_device *ptdev, u32 as_nr)
{
- write_cmd(ptdev, as_nr, AS_COMMAND_UNLOCK);
+ gpu_write(ptdev, AS_COMMAND(as_nr), AS_COMMAND_UNLOCK);
}
/**
@@ -664,7 +652,9 @@ static int mmu_hw_flush_caches(struct panthor_device *ptdev, int as_nr, u64 iova
* power it up
*/
- mmu_hw_cmd_lock(ptdev, as_nr, iova, size);
+ ret = mmu_hw_wait_ready(ptdev, as_nr);
+ if (!ret)
+ mmu_hw_cmd_lock(ptdev, as_nr, iova, size);
ret = mmu_hw_wait_ready(ptdev, as_nr);
if (ret)
@@ -679,7 +669,9 @@ static int mmu_hw_flush_caches(struct panthor_device *ptdev, int as_nr, u64 iova
* at the end of the GPU_CONTROL cache flush command, unlike
* AS_COMMAND_FLUSH_MEM or AS_COMMAND_FLUSH_PT.
*/
- mmu_hw_cmd_unlock(ptdev, as_nr);
+ ret = mmu_hw_wait_ready(ptdev, as_nr);
+ if (!ret)
+ mmu_hw_cmd_unlock(ptdev, as_nr);
/* Wait for the unlock command to complete */
return mmu_hw_wait_ready(ptdev, as_nr);
@@ -707,7 +699,13 @@ static int panthor_mmu_as_enable(struct panthor_device *ptdev, u32 as_nr,
if (ret)
return ret;
- return mmu_hw_cmd_update(ptdev, as_nr, transtab, transcfg, memattr);
+ ret = mmu_hw_wait_ready(ptdev, as_nr);
+ if (ret)
+ return ret;
+
+ mmu_hw_cmd_update(ptdev, as_nr, transtab, transcfg, memattr);
+
+ return 0;
}
static int panthor_mmu_as_disable(struct panthor_device *ptdev, u32 as_nr)
@@ -718,7 +716,13 @@ static int panthor_mmu_as_disable(struct panthor_device *ptdev, u32 as_nr)
if (ret)
return ret;
- return mmu_hw_cmd_update(ptdev, as_nr, 0, AS_TRANSCFG_ADRMODE_UNMAPPED, 0);
+ ret = mmu_hw_wait_ready(ptdev, as_nr);
+ if (ret)
+ return ret;
+
+ mmu_hw_cmd_update(ptdev, as_nr, 0, AS_TRANSCFG_ADRMODE_UNMAPPED, 0);
+
+ return 0;
}
static u32 panthor_mmu_fault_mask(struct panthor_device *ptdev, u32 value)
--
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 ` Chia-I Wu [this message]
2025-10-02 10:41 ` [PATCH 06/10] drm/panthor: remove write_cmd 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=20250916210823.4033529-7-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