* [PATCH v2 1/2] regcache: Warn if regcache_sync() is called in cache_only mode
@ 2026-07-20 3:32 phucduc.bui
2026-07-20 3:32 ` [PATCH v2 2/2] regcache: Validate cache_only state in regcache_sync_region() phucduc.bui
2026-07-20 17:46 ` [PATCH v2 1/2] regcache: Warn if regcache_sync() is called in cache_only mode Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: phucduc.bui @ 2026-07-20 3:32 UTC (permalink / raw)
To: Mark Brown, Greg Kroah-Hartman, rafael
Cc: Danilo Krummrich, linux-kernel, driver-core, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
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.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
Changes in v2 :
- Check cache_only under the lock.
- Update the function comment.
drivers/base/regmap/regcache.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index 96cdae25b9c4..20e0641d21b2 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -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",
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2 2/2] regcache: Validate cache_only state in regcache_sync_region()
2026-07-20 3:32 [PATCH v2 1/2] regcache: Warn if regcache_sync() is called in cache_only mode phucduc.bui
@ 2026-07-20 3:32 ` phucduc.bui
2026-07-20 17:46 ` [PATCH v2 1/2] regcache: Warn if regcache_sync() is called in cache_only mode Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: phucduc.bui @ 2026-07-20 3:32 UTC (permalink / raw)
To: Mark Brown, Greg Kroah-Hartman, rafael
Cc: Danilo Krummrich, linux-kernel, driver-core, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Add a WARN_ON() check to ensure regcache_sync_region() is not called
while cache_only is enabled.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
drivers/base/regmap/regcache.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index 20e0641d21b2..be167ee6f57c 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -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;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 1/2] regcache: Warn if regcache_sync() is called in cache_only mode
2026-07-20 3:32 [PATCH v2 1/2] regcache: Warn if regcache_sync() is called in cache_only mode phucduc.bui
2026-07-20 3:32 ` [PATCH v2 2/2] regcache: Validate cache_only state in regcache_sync_region() phucduc.bui
@ 2026-07-20 17:46 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2026-07-20 17:46 UTC (permalink / raw)
To: Greg Kroah-Hartman, rafael, phucduc.bui
Cc: Danilo Krummrich, linux-kernel, driver-core
On Mon, 20 Jul 2026 10:32:37 +0700, phucduc.bui@gmail.com wrote:
> regcache: Warn if regcache_sync() is called in cache_only mode
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-21 13:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-20 3:32 [PATCH v2 1/2] regcache: Warn if regcache_sync() is called in cache_only mode phucduc.bui
2026-07-20 3:32 ` [PATCH v2 2/2] regcache: Validate cache_only state in regcache_sync_region() phucduc.bui
2026-07-20 17:46 ` [PATCH v2 1/2] regcache: Warn if regcache_sync() is called in cache_only mode Mark Brown
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.