From: Sander Vanheule <sander@svanheule.net>
To: "Sheetal ." <sheetal@nvidia.com>, Mark Brown <broonie@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J . Wysocki" <rafael@kernel.org>,
Danilo Krummrich <dakr@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Thierry Reding <thierry.reding@gmail.com>,
Jonathan Hunter <jonathanh@nvidia.com>,
Mohan kumar <mkumard@nvidia.com>,
linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org,
linux-tegra@vger.kernel.org
Subject: Re: [RFC PATCH v2 1/3] regmap: Add flat_cache_default_is_zero flag for flat cache
Date: Mon, 12 Jan 2026 20:09:33 +0100 [thread overview]
Message-ID: <c477be44febb94b8c81f522c4d86971417740e6d.camel@svanheule.net> (raw)
In-Reply-To: <20260112042841.51799-2-sheetal@nvidia.com>
Hi,
On Mon, 2026-01-12 at 09:58 +0530, Sheetal . wrote:
> From: Sheetal <sheetal@nvidia.com>
>
> Commit e062bdfdd6ad ("regmap: warn users about uninitialized flat
> cache") added a warning for drivers using REGCACHE_FLAT when reading
> registers not present in reg_defaults.
>
> For hardware where registers have a power-on-reset value of zero
> or drivers that wish to treat zero as a valid cache default, adding
> all such registers to reg_defaults has drawbacks:
>
> 1. Maintenance burden: Drivers must list every readable register
> regardless of its reset value.
If you would extend regmap_config to accept a callback for defaults, this burden
could be reduced to near-zero if it was a simple wrapper for the writeable_regs
and/or readable_regs callbacks. I.e. "return 0x0 if readable or writable".
> 2. No functional benefit: Entries like { REG, 0x0 } only set the
> validity bit; the flat cache value is already zero.
There is a functional benefit: it allows regmap_sync() to do what it is supposed
to do: check if a cached register matches the reset value to omit writing the
cached value to hardware after a reset.
> 3. Code bloat: Large reg_defaults arrays increase driver size.
As I argued before, bloat would be limited if the user could provide tables or
callbacks for defaults.
>
> Add a flat_cache_default_is_zero flag to struct regmap_config. When
> set, the flat cache marks registers as valid on first read instead
> of warning.
>
> The valid bit is set on first read rather than marking all registers
> valid at init time for the following reasons:
> - Avoids writes to register holes or unused addresses during sync.
> - Safer for drivers that don't have writeable_reg callback defined.
These are benefits of using a sparse cache, but on closer inspection don't
actually apply here. You can validate this in your kunit test if you also do the
negative check: assert that registers outside of the written range are left
untouched (written == 0).
Because regcache_read() will never return -ENOENT with this option enabled,
regmap_sync() will see all registers as "written". Since there are no defaults
to check against, this will cause regmap_sync() to write to *all* writable
registers. With this patch, you are just reverting to the old behaviour where
regmap_sync() silently overwrites registers you never accessed with 0.
Best,
Sander
next prev parent reply other threads:[~2026-01-12 19:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-12 4:28 [RFC PATCH v2 0/3] " Sheetal .
2026-01-12 4:28 ` [RFC PATCH v2 1/3] " Sheetal .
2026-01-12 19:09 ` Sander Vanheule [this message]
2026-01-12 21:45 ` Mark Brown
2026-01-12 4:28 ` [RFC PATCH v2 2/3] regmap: Add KUnit test for flat_cache_default_is_zero Sheetal .
2026-01-12 4:28 ` [RFC PATCH v2 3/3] ASoC: tegra: Enable flat_cache_default_is_zero for audio drivers Sheetal .
2026-01-12 12:26 ` Mark Brown
2026-01-12 12:53 ` Sheetal .
2026-01-12 13:32 ` 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=c477be44febb94b8c81f522c4d86971417740e6d.camel@svanheule.net \
--to=sander@svanheule.net \
--cc=broonie@kernel.org \
--cc=dakr@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jonathanh@nvidia.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=mkumard@nvidia.com \
--cc=perex@perex.cz \
--cc=rafael@kernel.org \
--cc=sheetal@nvidia.com \
--cc=thierry.reding@gmail.com \
--cc=tiwai@suse.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®