diff mbox series

[08/11] mfd: wm5110: Update to use maple tree register cache

Message ID 20230713-mfd-cirrus-maple-v1-8-16dacae402a8@kernel.org (mailing list archive)
State New, archived
Headers show
Series mfd:: Update Cirrus Logic drivers to use maple tree register caches | expand

Commit Message

Mark Brown July 13, 2023, 12:49 a.m. UTC
The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache. In
v6.5 it has also acquired the ability to generate multi-register writes in
sync operations, bringing performance up to parity with the rbtree cache
there.

Update the wm5110 driver to use the more modern data structure.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/mfd/wm5110-tables.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Charles Keepax July 18, 2023, 3:42 p.m. UTC | #1
On Thu, Jul 13, 2023 at 01:49:26AM +0100, Mark Brown wrote:
> The maple tree register cache is based on a much more modern data structure
> than the rbtree cache and makes optimisation choices which are probably
> more appropriate for modern systems than those made by the rbtree cache. In
> v6.5 it has also acquired the ability to generate multi-register writes in
> sync operations, bringing performance up to parity with the rbtree cache
> there.
> 
> Update the wm5110 driver to use the more modern data structure.
> 
> Signed-off-by: Mark Brown <broonie@kernel.org>
> ---
>  drivers/mfd/wm5110-tables.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mfd/wm5110-tables.c b/drivers/mfd/wm5110-tables.c
> index 65b9b1d6daec..eba324875afd 100644
> --- a/drivers/mfd/wm5110-tables.c
> +++ b/drivers/mfd/wm5110-tables.c
> @@ -3218,7 +3218,7 @@ const struct regmap_config wm5110_i2c_regmap = {
>  	.readable_reg = wm5110_readable_register,
>  	.volatile_reg = wm5110_volatile_register,
>  
> -	.cache_type = REGCACHE_RBTREE,
> +	.cache_type = REGCACHE_MAPLE,
>  	.reg_defaults = wm5110_reg_default,
>  	.num_reg_defaults = ARRAY_SIZE(wm5110_reg_default),
>  };
> 
> -- 
> 2.39.2
> 

This one appears to cause me some issues, seems to get the IRQs
into a weird state when doing compressed stream stuff. The
issue seems to also require commit bfa0b38c1483 ("regmap:
maple: Implement block sync for the maple tree cache") to be
present. So it definitely seems to relate to the cache sync,
but not sure if it is something todo with the device itself,
or the maple tree stuff yet.

Thanks,
Charles
Charles Keepax July 18, 2023, 5 p.m. UTC | #2
On Tue, Jul 18, 2023 at 03:42:00PM +0000, Charles Keepax wrote:
> On Thu, Jul 13, 2023 at 01:49:26AM +0100, Mark Brown wrote:
> > The maple tree register cache is based on a much more modern data structure
> > than the rbtree cache and makes optimisation choices which are probably
> > more appropriate for modern systems than those made by the rbtree cache. In
> > v6.5 it has also acquired the ability to generate multi-register writes in
> > sync operations, bringing performance up to parity with the rbtree cache
> > there.
> > 
> > Update the wm5110 driver to use the more modern data structure.
> > 
> > Signed-off-by: Mark Brown <broonie@kernel.org>
> > ---
> >  drivers/mfd/wm5110-tables.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/mfd/wm5110-tables.c b/drivers/mfd/wm5110-tables.c
> > index 65b9b1d6daec..eba324875afd 100644
> > --- a/drivers/mfd/wm5110-tables.c
> > +++ b/drivers/mfd/wm5110-tables.c
> > @@ -3218,7 +3218,7 @@ const struct regmap_config wm5110_i2c_regmap = {
> >  	.readable_reg = wm5110_readable_register,
> >  	.volatile_reg = wm5110_volatile_register,
> >  
> > -	.cache_type = REGCACHE_RBTREE,
> > +	.cache_type = REGCACHE_MAPLE,
> >  	.reg_defaults = wm5110_reg_default,
> >  	.num_reg_defaults = ARRAY_SIZE(wm5110_reg_default),
> >  };
> > 
> > -- 
> > 2.39.2
> > 
> 
> This one appears to cause me some issues, seems to get the IRQs
> into a weird state when doing compressed stream stuff. The
> issue seems to also require commit bfa0b38c1483 ("regmap:
> maple: Implement block sync for the maple tree cache") to be
> present. So it definitely seems to relate to the cache sync,
> but not sure if it is something todo with the device itself,
> or the maple tree stuff yet.
> 

Ah... I think I see the regcache_sync sets async=true, but then
the maple tree code immediately deletes the buffer after calling
_regmap_raw_write. So its a racy use after free.

How would we feel about having the maple tree code, clear async
again?

Thanks,
Charles
Mark Brown July 18, 2023, 5:16 p.m. UTC | #3
On Tue, Jul 18, 2023 at 05:00:35PM +0000, Charles Keepax wrote:
> On Tue, Jul 18, 2023 at 03:42:00PM +0000, Charles Keepax wrote:

> > This one appears to cause me some issues, seems to get the IRQs
> > into a weird state when doing compressed stream stuff. The
> > issue seems to also require commit bfa0b38c1483 ("regmap:
> > maple: Implement block sync for the maple tree cache") to be
> > present. So it definitely seems to relate to the cache sync,
> > but not sure if it is something todo with the device itself,
> > or the maple tree stuff yet.

> Ah... I think I see the regcache_sync sets async=true, but then
> the maple tree code immediately deletes the buffer after calling
> _regmap_raw_write. So its a racy use after free.

> How would we feel about having the maple tree code, clear async
> again?

I was going to say, it must be a maple tree issue.  I think we should
push that async down into the rbtree code, that's probably also broken
for other cache types if used in conjunction with slow buses...
diff mbox series

Patch

diff --git a/drivers/mfd/wm5110-tables.c b/drivers/mfd/wm5110-tables.c
index 65b9b1d6daec..eba324875afd 100644
--- a/drivers/mfd/wm5110-tables.c
+++ b/drivers/mfd/wm5110-tables.c
@@ -3218,7 +3218,7 @@  const struct regmap_config wm5110_i2c_regmap = {
 	.readable_reg = wm5110_readable_register,
 	.volatile_reg = wm5110_volatile_register,
 
-	.cache_type = REGCACHE_RBTREE,
+	.cache_type = REGCACHE_MAPLE,
 	.reg_defaults = wm5110_reg_default,
 	.num_reg_defaults = ARRAY_SIZE(wm5110_reg_default),
 };