On Fri, Jun 18, 2021 at 12:35:58PM +0100, Srinivas Kandagatla wrote:
The issue that I encountered is when doing regmap_update_bits on
a write only register. In regcache path this will not do the right
thing as the register is not readable and driver which is using
regmap_update_bits will never notice that it can not do a update
bits on write only register leading to inconsistent writes and
random hardware behavior.
Why will use of regmap_update_bits() mean that a driver will never
notice a write failure? Shouldn't remgap_update_bits() be fixed to
report any errors it isn't reporting, or the driver fixed to check
error codes? I really don't understand the issue you're trying to
report - what is "the right thing" and what makes you believe that a
driver can't do an _update_bits() on a write only but cached register?
Can you specify in concrete terms what the problem is.
There seems to be missing checks in regcache_read() which is
now added by moving the orignal check in _regmap_read() before
accessing regcache.
Cc: stable@xxxxxxxxxxxxxxx
Fixes: 5d1729e7f02f ("regmap: Incorporate the regcache core into regmap")
Are you *sure* you've identified the actual issue here - nobody has seen
any problems with this in the past decade? Please don't just pick a
random commit for the sake of adding a Fixes tag.
Initially I added check in regcache_read(), later I moved it to _regmap_read. do you think check in regcache_read() is the correct place?
@@ -2677,6 +2677,9 @@ static int _regmap_read(struct regmap *map, unsigned int reg,
int ret;
void *context = _regmap_map_get_context(map);
+ if (!regmap_readable(map, reg))
+ return -EIO;
+
if (!map->cache_bypass) {
ret = regcache_read(map, reg, val);
if (ret == 0)
@@ -2686,9 +2689,6 @@ static int _regmap_read(struct regmap *map, unsigned int reg,
if (map->cache_only)
return -EBUSY;
- if (!regmap_readable(map, reg))
- return -EIO;
-
This puts the readability check before the cache check which will break
all drivers using the cache on write only registers.