From: "Dan Williams (nvidia)" <djbw@kernel.org>
To: Srirangan Madhavan <smadhavan@nvidia.com>,
catalin.marinas@arm.com, will@kernel.org,
mark.rutland@arm.com, lpieralisi@kernel.org,
sudeep.holla@arm.com
Cc: conor@kernel.org, jic23@kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, vsethi@nvidia.com,
jevans@nvidia.com, raghupathyk@nvidia.com, srikars@nvidia.com,
nbenech@nvidia.com, alwilliamson@nvidia.com,
Dan Williams <danwilliams@nvidia.com>,
Srirangan Madhavan <smadhavan@nvidia.com>
Subject: Re: [RFC PATCH 2/2] arm64: mm: add SMCCC-backed cache invalidate provider
Date: Thu, 21 May 2026 13:10:20 -0700 [thread overview]
Message-ID: <6a0f66ac6d7e_1bb00e100c0@djbw-dev.notmuch> (raw)
In-Reply-To: <20260521073047.320614-3-smadhavan@nvidia.com>
Srirangan Madhavan wrote:
> Add an arm64 cache maintenance backend that discovers SMCCC cache
> clean+invalidate support, queries attributes, handles transient BUSY and
> RATE_LIMITED responses with bounded retries, and registers with the generic
> cache coherency framework.
>
> Signed-off-by: Srirangan Madhavan <smadhavan@nvidia.com>
> ---
> MAINTAINERS | 1 +
> arch/arm64/mm/Makefile | 1 +
> arch/arm64/mm/cache_maint.c | 180 ++++++++++++++++++++++++++++++++++++
> 3 files changed, 182 insertions(+)
> create mode 100644 arch/arm64/mm/cache_maint.c
[..]
> +static int arm64_smccc_cache_wbinv(struct cache_coherency_ops_inst *cci,
> + struct cc_inval_params *invp)
> +{
> + struct arm64_smccc_cache *cache =
> + container_of(cci, struct arm64_smccc_cache, cci);
> + struct arm_smccc_res res = {};
> + int delay_us = smccc_cache_delay_us(cache);
> + u64 gen = 0;
> + s32 status;
> + int ret;
> + int i;
> +
> + if (!invp->size)
> + return -EINVAL;
> +
> + if (cache->global_op)
> + gen = READ_ONCE(cache->global_flush_gen);
> +
> + guard(mutex)(&cache->lock);
> +
> + /*
> + * If firmware reports a global operation type, a successful operation
> + * covers every request that was already waiting behind it. Skip if the
> + * generation advanced while this request was waiting to enter the
> + * serialized firmware call path.
> + */
> + if (cache->global_op && gen != READ_ONCE(cache->global_flush_gen))
> + return 0;
Hmm, this looks like it could under flush which is worse than over
flushing. The ordering is:
CPU0 CPU1
<dirty>
flush_gen==0
lock
flush_gen==0
flush <dirty>
flush_gen++ flush_gen==0
lock
flush_gen==1
skip
I.e. if CPU1 is racing dirtying while CPU0 is still flushing, then there
is a window for CPU1 to read the updated flush_gen and skip when it
needs to follow on with a new flush cycle. So this either needs a more
sophisticated queue / batch system to track which requests might get
satisfied while waiting for a turn, or just drop the optimization until
it is clear it causes a problem in practice.
I think dropping the optimization is practical for now.
> +
> + for (i = 0; i < SMCCC_CACHE_MAX_RETRIES; i++) {
> + /* Long firmware operations can trigger watchdog checks. */
> + touch_nmi_watchdog();
> +
> + arm_smccc_1_1_invoke(ARM_SMCCC_ARCH_CLEAN_INV_MEMREGION,
> + invp->addr, invp->size, 0UL, &res);
> + status = (s32)res.a0;
> + ret = smccc_cache_status_to_errno(status);
> + if (!ret) {
> + if (cache->global_op) {
> + WRITE_ONCE(cache->global_flush_gen,
> + cache->global_flush_gen + 1);
> + }
> + return 0;
> + }
> +
> + if (ret != -EBUSY && ret != -EAGAIN)
> + return ret;
I notice that cxl_region_invalidate_memregion() only expects failures to
find a flush capability, not failures to execute a flush.
Just a note to circle back to this concern.
next prev parent reply other threads:[~2026-05-21 20:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 7:30 [RFC PATCH 0/2] arm64: add SMCCC cache invalidation backend for memregion users Srirangan Madhavan
2026-05-21 7:30 ` [RFC PATCH 1/2] arm64: smccc: add cache clean/invalidate IDs and return codes Srirangan Madhavan
2026-05-21 7:30 ` [RFC PATCH 2/2] arm64: mm: add SMCCC-backed cache invalidate provider Srirangan Madhavan
2026-05-21 11:18 ` Jonathan Cameron
2026-05-21 14:12 ` Conor Dooley
2026-05-21 16:35 ` Catalin Marinas
2026-05-21 20:10 ` Dan Williams (nvidia) [this message]
2026-05-21 11:28 ` [RFC PATCH 0/2] arm64: add SMCCC cache invalidation backend for memregion users Jonathan Cameron
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=6a0f66ac6d7e_1bb00e100c0@djbw-dev.notmuch \
--to=djbw@kernel.org \
--cc=alwilliamson@nvidia.com \
--cc=catalin.marinas@arm.com \
--cc=conor@kernel.org \
--cc=danwilliams@nvidia.com \
--cc=jevans@nvidia.com \
--cc=jic23@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mark.rutland@arm.com \
--cc=nbenech@nvidia.com \
--cc=raghupathyk@nvidia.com \
--cc=smadhavan@nvidia.com \
--cc=srikars@nvidia.com \
--cc=sudeep.holla@arm.com \
--cc=vsethi@nvidia.com \
--cc=will@kernel.org \
/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