From: Jonathan Cameron <jic23@kernel.org>
To: Bence Csokas <bence.csokas@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Conor Dooley <conor@kernel.org>,
Yicong Yang <yangyicong@hisilicon.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC] cache: Make cpu_cache_invalidate_memregion() error out if there are no handlers
Date: Wed, 23 Sep 2026 02:48:32 +0100 [thread overview]
Message-ID: <20260923024832.53b104c7@jic23-hlaptop> (raw)
In-Reply-To: <20260922-cci_enxio-v1-1-00bade212729@arm.com>
On Tue, 22 Sep 2026 09:29:31 +0200
Bence Csokas <bence.csokas@arm.com> 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.
>
> Signed-off-by: Bence Csokas <bence.csokas@arm.com>
As you noted short of a race we should never hit this in practice as
all callers must check for support first. Still good to close
that race.
Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Jonathan
> ---
> 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 *
>
next prev parent reply other threads:[~2026-09-23 1:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 7:29 [PATCH RFC] Why does cpu_cache_invalidate_memregion() return 0 if there are no handlers? Bence Csokas
2026-09-22 7:29 ` [PATCH RFC] cache: Make cpu_cache_invalidate_memregion() error out if there are no handlers Bence Csokas
2026-09-23 1:48 ` Jonathan Cameron [this message]
2026-09-23 2:18 ` Andrew Morton
2026-09-23 8:21 ` Bence Csókás
2026-09-23 17:31 ` 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=20260923024832.53b104c7@jic23-hlaptop \
--to=jic23@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=bence.csokas@arm.com \
--cc=conor@kernel.org \
--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®