From: Boris Brezillon <boris.brezillon@collabora.com>
To: Karunika Choo <karunika.choo@arm.com>
Cc: dri-devel@lists.freedesktop.org, nd@arm.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>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 7/9] drm/panthor: Support GPU_CONTROL cache flush based on feature bit
Date: Fri, 21 Mar 2025 09:41:09 +0100 [thread overview]
Message-ID: <20250321094109.116a6915@collabora.com> (raw)
In-Reply-To: <20250320111741.1937892-8-karunika.choo@arm.com>
On Thu, 20 Mar 2025 11:17:39 +0000
Karunika Choo <karunika.choo@arm.com> wrote:
> As the FLUSH_MEM and FLUSH_PT commands are deprecated in GPUs from
> Mali-G720 onwards, this patch adds support for performing cache
> maintenance via the FLUSH_CACHES command in GPU_CONTROL, in place of
> FLUSH_MEM and FLUSH_PT based on PANTHOR_HW_FEATURE_GPU_CTRL_CACHE_FLUSH
> feature bit.
>
> Signed-off-by: Karunika Choo <karunika.choo@arm.com>
> ---
> drivers/gpu/drm/panthor/panthor_hw.h | 6 +++++
> drivers/gpu/drm/panthor/panthor_mmu.c | 35 +++++++++++++++++++++++++++
> 2 files changed, 41 insertions(+)
>
> diff --git a/drivers/gpu/drm/panthor/panthor_hw.h b/drivers/gpu/drm/panthor/panthor_hw.h
> index dfe0f86c5d76..4d67fdfe86f9 100644
> --- a/drivers/gpu/drm/panthor/panthor_hw.h
> +++ b/drivers/gpu/drm/panthor/panthor_hw.h
> @@ -16,6 +16,12 @@ struct panthor_device;
> * New feature flags will be added with support for newer GPU architectures.
> */
> enum panthor_hw_feature {
> + /**
> + * @PANTHOR_HW_FEATURE_GPU_CTRL_CACHE_FLUSH: Perform cache maintenance
> + * via GPU_CONTROL.
> + */
> + PANTHOR_HW_FEATURE_GPU_CTRL_CACHE_FLUSH,
> +
> /** @PANTHOR_HW_FEATURES_END: Must be last. */
> PANTHOR_HW_FEATURES_END
> };
> diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c
> index a0a79f19bdea..4ac8bf36177e 100644
> --- a/drivers/gpu/drm/panthor/panthor_mmu.c
> +++ b/drivers/gpu/drm/panthor/panthor_mmu.c
> @@ -29,7 +29,9 @@
>
> #include "panthor_device.h"
> #include "panthor_gem.h"
> +#include "panthor_gpu.h"
> #include "panthor_heap.h"
> +#include "panthor_hw.h"
> #include "panthor_mmu.h"
> #include "panthor_regs.h"
> #include "panthor_sched.h"
> @@ -568,6 +570,35 @@ static void lock_region(struct panthor_device *ptdev, u32 as_nr,
> write_cmd(ptdev, as_nr, AS_COMMAND_LOCK);
> }
>
> +static int mmu_hw_do_flush_on_gpu_ctrl(struct panthor_device *ptdev, int as_nr,
> + u32 op)
> +{
> + const u32 l2_flush_op = CACHE_CLEAN | CACHE_INV;
> + u32 lsc_flush_op = 0;
> + int ret;
> +
> + if (op == AS_COMMAND_FLUSH_MEM)
> + lsc_flush_op = CACHE_CLEAN | CACHE_INV;
> +
> + ret = wait_ready(ptdev, as_nr);
> + if (ret)
> + return ret;
> +
> + ret = panthor_gpu_flush_caches(ptdev, l2_flush_op, lsc_flush_op, 0);
> + if (ret)
> + return ret;
> +
> + /*
> + * Explicitly unlock the region as the AS is not unlocked automatically
> + * at the end of the GPU_CONTROL cache flush command, unlike
> + * AS_COMMAND_FLUSH_MEM or AS_COMMAND_FLUSH_PT.
> + */
> + write_cmd(ptdev, as_nr, AS_COMMAND_UNLOCK);
> +
> + /* Wait for the unlock command to complete */
> + return wait_ready(ptdev, as_nr);
> +}
> +
> static int mmu_hw_do_operation_locked(struct panthor_device *ptdev, int as_nr,
> u64 iova, u64 size, u32 op)
> {
> @@ -585,6 +616,10 @@ static int mmu_hw_do_operation_locked(struct panthor_device *ptdev, int as_nr,
> if (op != AS_COMMAND_UNLOCK)
> lock_region(ptdev, as_nr, iova, size);
>
> + if (panthor_hw_supports(ptdev,PANTHOR_HW_FEATURE_GPU_CTRL_CACHE_FLUSH))
> + if (op == AS_COMMAND_FLUSH_MEM || op == AS_COMMAND_FLUSH_PT)
> + return mmu_hw_do_flush_on_gpu_ctrl(ptdev, as_nr, op);
Can't we use this sequence on v10 as well? The GPU flush_cache command
exists there, so I'd rather switch all CSF HW to this sequence than
diverge on v11+.
> +
> /* Run the MMU operation */
> write_cmd(ptdev, as_nr, op);
>
next prev parent reply other threads:[~2025-03-21 8:41 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-20 11:17 [PATCH v2 0/9] drm/panthor: Add GPU specific initialization framework to support new Mali GPUs Karunika Choo
2025-03-20 11:17 ` [PATCH v2 1/9] drm/panthor: Add 64-bit and poll register accessors Karunika Choo
2025-03-21 7:48 ` Boris Brezillon
2025-04-09 13:00 ` Karunika Choo
2025-04-10 13:28 ` Boris Brezillon
2025-04-10 16:49 ` Karunika Choo
2025-03-20 11:17 ` [PATCH v2 2/9] drm/panthor: Use " Karunika Choo
2025-03-21 7:53 ` Boris Brezillon
2025-04-09 13:07 ` Karunika Choo
2025-04-10 13:29 ` Boris Brezillon
2025-03-20 11:17 ` [PATCH v2 3/9] drm/panthor: Add GPU specific initialization framework Karunika Choo
2025-03-21 8:28 ` Boris Brezillon
2025-03-20 11:17 ` [PATCH v2 4/9] drm/panthor: Move GPU info initialization into panthor_hw.c Karunika Choo
2025-03-21 8:16 ` Boris Brezillon
2025-03-21 8:43 ` Boris Brezillon
2025-03-20 11:17 ` [PATCH v2 5/9] drm/panthor: Make getting GPU model name simple and extensible Karunika Choo
2025-03-21 8:02 ` Boris Brezillon
2025-04-10 13:20 ` Karunika Choo
2025-04-10 13:37 ` Boris Brezillon
2025-03-20 11:17 ` [PATCH v2 6/9] drm/panthor: Add support for Mali-G715 family of GPUs Karunika Choo
2025-03-21 8:34 ` Boris Brezillon
2025-03-20 11:17 ` [PATCH v2 7/9] drm/panthor: Support GPU_CONTROL cache flush based on feature bit Karunika Choo
2025-03-21 8:41 ` Boris Brezillon [this message]
2025-03-20 11:17 ` [PATCH v2 8/9] drm/panthor: Add support for Mali-G720 and Mali-G725 GPUs Karunika Choo
2025-03-20 11:17 ` [PATCH v2 9/9] drm/panthor: Add support for Mali-G710, Mali-G510, and Mali-G310 Karunika Choo
2025-03-20 19:03 ` Liviu Dudau
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=20250321094109.116a6915@collabora.com \
--to=boris.brezillon@collabora.com \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=karunika.choo@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=liviu.dudau@arm.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=nd@arm.com \
--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