From: Konrad Dybcio <konradybcio@kernel.org>
To: Mark Brown <broonie@kernel.org>, lkml <linux-kernel@vger.kernel.org>
Cc: Bjorn Andersson <andersson@kernel.org>
Subject: Re: [PATCH] regmap: Check for register readability before checking cache during read
Date: Thu, 15 Jun 2023 22:45:53 +0200 [thread overview]
Message-ID: <ea63420a-a08d-3610-b01f-61dabe56d2df@kernel.org> (raw)
In-Reply-To: <20230613-b4-regmap-check-readability-before-cache-v1-1-b144c0b01ed9@kernel.org>
On 13.06.2023 22:07, Mark Brown wrote:
> Ensure that we don't return a spurious cache hit for unreadable registers
> (eg, with the flat cache which doesn't understand sparseness) by checking
> for readability before we do a cache lookup.
>
> Signed-off-by: Mark Brown <broonie@kernel.org>
> ---
(+CC Bjorn)
Hi Mark,
this patch breaks using regmap_field_force_write() on fields that are
parts of registers marked as write-only (e.g. by regmap_access_table.no_ranges)
Is that intended?
What's the recommended fix?
FWIW this breaks soc/qcom/icc-bwmon.c, causing an interrupt storm at boot due
to the "clear the counters" register not being taken care of, so it'd be
appreciated if we can sort this out quickly.
Konrad
> drivers/base/regmap/regmap.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
> index fa2d3fba6ac9..3efbe59ca1a7 100644
> --- a/drivers/base/regmap/regmap.c
> +++ b/drivers/base/regmap/regmap.c
> @@ -2897,6 +2897,9 @@ static int _regmap_read(struct regmap *map, unsigned int reg,
> int ret;
> void *context = _regmap_map_get_context(map);
>
> + if (!regmap_readable(map, reg))
> + return -EIO;
> +
> if (!map->cache_bypass) {
> ret = regcache_read(map, reg, val);
> if (ret == 0)
> @@ -2906,9 +2909,6 @@ static int _regmap_read(struct regmap *map, unsigned int reg,
> if (map->cache_only)
> return -EBUSY;
>
> - if (!regmap_readable(map, reg))
> - return -EIO;
> -
> ret = map->reg_read(context, reg, val);
> if (ret == 0) {
> if (regmap_should_log(map))
>
> ---
> base-commit: 858fd168a95c5b9669aac8db6c14a9aeab446375
> change-id: 20230613-b4-regmap-check-readability-before-cache-9f658338a5c1
>
> Best regards,
next prev parent reply other threads:[~2023-06-15 20:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-13 20:07 [PATCH] regmap: Check for register readability before checking cache during read Mark Brown
2023-06-14 13:47 ` Mark Brown
2023-06-15 20:45 ` Konrad Dybcio [this message]
2023-06-15 20:55 ` Mark Brown
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=ea63420a-a08d-3610-b01f-61dabe56d2df@kernel.org \
--to=konradybcio@kernel.org \
--cc=andersson@kernel.org \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.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