All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regmap: rbtree: Fix wrong register marked as in-cache when creating new node
@ 2023-09-22 15:37 Richard Fitzgerald
  2023-09-22 19:28 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Fitzgerald @ 2023-09-22 15:37 UTC (permalink / raw)
  To: broonie; +Cc: linux-kernel, patches, Richard Fitzgerald

When regcache_rbtree_write() creates a new rbtree_node it was passing the
wrong bit number to regcache_rbtree_set_register(). The bit number is the
offset __in number of registers__, but in the case of creating a new block
regcache_rbtree_write() was not dividing by the address stride to get the
number of registers.

Fix this by dividing by map->reg_stride.
Compare with regcache_rbtree_read() where the bit is checked.

This bug meant that the wrong register was marked as present. The register
that was written to the cache could not be read from the cache because it
was not marked as cached. But a nearby register could be marked as having
a cached value even if it was never written to the cache.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: 3f4ff561bc88 ("regmap: rbtree: Make cache_present bitmap per node")
---
 drivers/base/regmap/regcache-rbtree.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/base/regmap/regcache-rbtree.c b/drivers/base/regmap/regcache-rbtree.c
index db716ffd083e..3db88bbcae0f 100644
--- a/drivers/base/regmap/regcache-rbtree.c
+++ b/drivers/base/regmap/regcache-rbtree.c
@@ -453,7 +453,8 @@ static int regcache_rbtree_write(struct regmap *map, unsigned int reg,
 		if (!rbnode)
 			return -ENOMEM;
 		regcache_rbtree_set_register(map, rbnode,
-					     reg - rbnode->base_reg, value);
+					     (reg - rbnode->base_reg) / map->reg_stride,
+					     value);
 		regcache_rbtree_insert(map, &rbtree_ctx->root, rbnode);
 		rbtree_ctx->cached_rbnode = rbnode;
 	}
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] regmap: rbtree: Fix wrong register marked as in-cache when creating new node
  2023-09-22 15:37 [PATCH] regmap: rbtree: Fix wrong register marked as in-cache when creating new node Richard Fitzgerald
@ 2023-09-22 19:28 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2023-09-22 19:28 UTC (permalink / raw)
  To: Richard Fitzgerald; +Cc: linux-kernel, patches

On Fri, 22 Sep 2023 16:37:11 +0100, Richard Fitzgerald wrote:
> When regcache_rbtree_write() creates a new rbtree_node it was passing the
> wrong bit number to regcache_rbtree_set_register(). The bit number is the
> offset __in number of registers__, but in the case of creating a new block
> regcache_rbtree_write() was not dividing by the address stride to get the
> number of registers.
> 
> Fix this by dividing by map->reg_stride.
> Compare with regcache_rbtree_read() where the bit is checked.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next

Thanks!

[1/1] regmap: rbtree: Fix wrong register marked as in-cache when creating new node
      commit: 7a795ac8d49e2433e1b97caf5e99129daf8e1b08

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] 2+ messages in thread

end of thread, other threads:[~2023-09-22 19:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-22 15:37 [PATCH] regmap: rbtree: Fix wrong register marked as in-cache when creating new node Richard Fitzgerald
2023-09-22 19:28 ` 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.