From: Conor Dooley <conor@kernel.org>
To: Bence Csokas <bence.csokas@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Jonathan Cameron <jic23@kernel.org>,
Yicong Yang <yangyicong@hisilicon.com>,
linux-kernel@vger.kernel.org,
Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Subject: Re: [PATCH] cache: Make cpu_cache_invalidate_memregion() error out if there are no handlers
Date: Fri, 2 Oct 2026 18:27:03 +0100 [thread overview]
Message-ID: <20261002-copier-storm-8b3548555546@spud> (raw)
In-Reply-To: <20261001-cci_enxio-v1-1-3c9e16024abd@arm.com>
[-- Attachment #1: Type: text/plain, Size: 2817 bytes --]
On Thu, Oct 01, 2026 at 01:00:07PM +0200, Bence Csokas wrote:
> Currently, if there are no registered handlers,
> cpu_cache_invalidate_memregion() returns 0. Callers are expected to check
> cpu_cache_has_invalidate_memregion() and return -ENXIO themselves, instead
> of calling this function. If a caller forgets to do this, they may
> erroneously think the operation succeeded. This is in contrast to x86,
> where cpu_cache_invalidate_memregion() itself checks if the operation is
> supported, and returns -ENXIO if it is not.
>
> Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
> Signed-off-by: Bence Csokas <bence.csokas@arm.com>
> ---
> I noticed cpu_cache_invalidate_memregion() returns 0 if there are no
> registered `cache_coherency_ops_inst`s, which I find counter-intuitive.
>
> >From what I've seen, there are no in-tree users who do not check
> cpu_cache_has_invalidate_memregion(). However, IMO the better solution
> would be if the function would perform this check, and not the callee.
>
> Furthermore, arch/x86/mm/pat/set_memory.c also implements this function,
> but actually does the feature check, and WARNs and returns -ENXIO if it
> fails that check.
>
> This patch that provides a low-overhead fix.
Hmm, I almost lost this. Guess my patchwork lei query needs an update.
Just happened to remember seeing this fly by!
> ---
> Changes in v1:
> - Rebased to master
> - Collected tags
> - Link to RFC: https://patch.msgid.link/20260922-cci_enxio-v1-0-00bade212729@arm.com
>
> To: Conor Dooley <conor@kernel.org>
> To: Jonathan Cameron <jic23@kernel.org>
> To: Andrew Morton <akpm@linux-foundation.org>
> Cc: linux-kernel@vger.kernel.org
> ---
> lib/cache_maint.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/cache_maint.c b/lib/cache_maint.c
> index 9256a9ffc34c..132d2816d6b1 100644
> --- a/lib/cache_maint.c
> +++ b/lib/cache_maint.c
> @@ -59,12 +59,12 @@ static int cache_inval_done_one(struct cache_coherency_ops_inst *cci)
>
> static int cache_invalidate_memregion(phys_addr_t addr, size_t size)
> {
> - int ret;
> struct cache_coherency_ops_inst *cci;
> struct cc_inval_params params = {
> .addr = addr,
> .size = size,
> };
> + int ret = -ENXIO;
>
> guard(rwsem_read)(&cache_ops_instance_list_lock);
> list_for_each_entry(cci, &cache_ops_instance_list, node) {
> @@ -78,7 +78,7 @@ static int cache_invalidate_memregion(phys_addr_t addr, size_t size)
> return ret;
> }
>
> - return 0;
> + return ret;
> }
>
> struct cache_coherency_ops_inst *
>
> ---
> base-commit: 551c722f40809618230001baccf219193e22fc5a
> change-id: 20260921-cci_enxio-f3d31d9acec7
>
> Best regards,
> --
> Bence Csokas <bence.csokas@arm.com>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
prev parent reply other threads:[~2026-10-02 17:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-01 11:00 Bence Csokas
2026-10-02 17:27 ` Conor Dooley [this message]
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=20261002-copier-storm-8b3548555546@spud \
--to=conor@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=bence.csokas@arm.com \
--cc=jic23@kernel.org \
--cc=jonathan.cameron@oss.qualcomm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=yangyicong@hisilicon.com \
/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®