regcache: Warn if regcache_sync() is called in cache_only mode
Subsystems (2)
PATCH v2 1/2 regcache: Warn if regcache_sync() is called in cache_only mode
From: bui duc phuc <[email protected]>
Calling regcache_sync() while cache_only is enabled is invalid API usage, since writes are intentionally kept in the cache and cannot be synchronized to hardware.
Document that callers must disable cache_only before calling regcache_sync(), and reject incorrect usage with a WARN_ON() and -EINVAL.
---
Changes in v2 :
- Check cache_only under the lock.
- Update the function comment.
drivers/base/regmap/regcache.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/base/regmap/regcache.c +10 -0
@@ -397,6 +397,10 @@ static int rbtree_all(const void *key, const struct rb_node *node)* volatile. In general drivers can choose not to use the provided * syncing functionality if they so require. * +* This pushes cached changes made while cache_only (e.g. suspend) down +* to hardware. The caller must disable cache_only before calling this +* function. +* * Return a negative value on failure, 0 on success. */ int regcache_sync (struct regmap *map)
@@ -414,6 +418,12 @@ int regcache_sync(struct regmap *map)BUG_ON (!map->cache_ops); map->lock (map->lock_arg); + +if (WARN_ON (map->cache_only)) { + map->unlock (map->lock_arg); +return -EINVAL ; + } +/* Remember the initial bypass state */ bypass = map->cache_bypass; dev_dbg(map->dev, "Syncing %s cache\n",
Signature · 1 line
2.43.0
PATCH v2 2/2 regcache: Validate cache_only state in regcache_sync_region()
From: bui duc phuc <[email protected]>
Add a WARN_ON() check to ensure regcache_sync_region() is not called while cache_only is enabled.
--- drivers/base/regmap/regcache.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/base/regmap/regcache.c +4 -0
@@ -518,6 +518,10 @@ int regcache_sync_region(struct regmap *map, unsigned int min, map->lock (map->lock_arg); +if (WARN_ON (map->cache_only)) { + map->unlock (map->lock_arg); +return -EINVAL ; + }/* Remember the initial bypass state */ bypass = map->cache_bypass;
Signature · 1 line
2.43.0
Mark Brown
maintainerQuoted 1 line · On Mon, 20 Jul 2026 10:32:37 +0700, [email protected] wrote:
regcache: Warn if
regcache_sync()is called incache_onlymode
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-7.3
Thanks!
[1/2] regcache: Warn if regcache_sync() is called in cache_only mode
https://git.kernel.org/broonie/regmap/c/86fc3483a4d6 [2/2] regcache: Validate cache_only state in regcache_sync_region() https://git.kernel.org/broonie/regmap/c/afc8e3ee8307
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark