lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c477be44febb94b8c81f522c4d86971417740e6d.camel@svanheule.net>
Date: Mon, 12 Jan 2026 20:09:33 +0100
From: Sander Vanheule <sander@...nheule.net>
To: "Sheetal ." <sheetal@...dia.com>, Mark Brown <broonie@...nel.org>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>, "Rafael J . Wysocki"	
 <rafael@...nel.org>, Danilo Krummrich <dakr@...nel.org>, Liam Girdwood	
 <lgirdwood@...il.com>, Jaroslav Kysela <perex@...ex.cz>, Takashi Iwai	
 <tiwai@...e.com>, Thierry Reding <thierry.reding@...il.com>, Jonathan
 Hunter	 <jonathanh@...dia.com>, Mohan kumar <mkumard@...dia.com>, 
	linux-kernel@...r.kernel.org, linux-sound@...r.kernel.org, 
	linux-tegra@...r.kernel.org
Subject: Re: [RFC PATCH v2 1/3] regmap: Add flat_cache_default_is_zero flag
 for flat cache

Hi,

On Mon, 2026-01-12 at 09:58 +0530, Sheetal . wrote:
> From: Sheetal <sheetal@...dia.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ