]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
regmap: Ensure range selector registers are updated after cache sync
authorMark Brown <broonie@kernel.org>
Thu, 26 Oct 2023 15:49:19 +0000 (16:49 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 28 Nov 2023 16:56:32 +0000 (16:56 +0000)
commit63e09cdfe948a97d88266d32569220b4b2094623
tree89116a707d07ff926151989839563995e4d109ee
parent0c49e74e95bfb51589d2b3e9554b40da02f66798
regmap: Ensure range selector registers are updated after cache sync

[ Upstream commit 0ec7731655de196bc1e4af99e495b38778109d22 ]

When we sync the register cache we do so with the cache bypassed in order
to avoid overhead from writing the synced values back into the cache. If
the regmap has ranges and the selector register for those ranges is in a
register which is cached this has the unfortunate side effect of meaning
that the physical and cached copies of the selector register can be out of
sync after a cache sync. The cache will have whatever the selector was when
the sync started and the hardware will have the selector for the register
that was synced last.

Fix this by rewriting all cached selector registers after every sync,
ensuring that the hardware and cache have the same content. This will
result in extra writes that wouldn't otherwise be needed but is simple
so hopefully robust. We don't read from the hardware since not all
devices have physical read support.

Given that nobody noticed this until now it is likely that we are rarely if
ever hitting this case.

Reported-by: Hector Martin <marcan@marcan.st>
Cc: stable@vger.kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20231026-regmap-fix-selector-sync-v1-1-633ded82770d@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/base/regmap/regcache.c