[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <c046ace3d4569405e167db9cc6ede90048dc0450.camel@svanheule.net>
Date: Mon, 20 Oct 2025 21:40:04 +0200
From: Sander Vanheule <sander@...nheule.net>
To: bigunclemax@...il.com
Cc: Mike Looijmans <mike.looijmans@...ic.nl>, Linus Walleij
<linus.walleij@...aro.org>, linux-gpio@...r.kernel.org,
linux-kernel@...r.kernel.org, Andy Shevchenko
<andriy.shevchenko@...ux.intel.com>
Subject: Re: [PATCH v2] pinctrl: mcp23s08: delete regmap reg_defaults to
avoid cache sync issues
Hi,
On Thu, 2025-10-09 at 16:26 +0300, bigunclemax@...il.com wrote:
> From: Maksim Kiselev <bigunclemax@...il.com>
>
> The probe function does not guarantee that chip registers are in their
> default state. Thus using reg_defaults for regmap is incorrect.
>
> ---
>
> @@ -82,25 +71,12 @@ const struct regmap_config mcp23x08_regmap = {
> .reg_stride = 1,
> .volatile_table = &mcp23x08_volatile_table,
> .precious_table = &mcp23x08_precious_table,
> - .reg_defaults = mcp23x08_defaults,
> - .num_reg_defaults = ARRAY_SIZE(mcp23x08_defaults),
> .cache_type = REGCACHE_FLAT,
> .max_register = MCP_OLAT,
> .disable_locking = true, /* mcp->lock protects the regmap */
As Andy mentioned, the problem you will now have to deal with is that your cache
is not initialized at all. Unlike the other cache types, REGCACHE_FLAT will
zero-initialize its cache, perhaps making your cache sync issues worse.
You have two options to initialize the cache properly:
* Provide .num_reg_defaults_raw (= MCP_OLAT + 1). This will give you a warning
on probe about the cache defaults being initialized from hardware.
* Switch to another cache type (REGCACHE_MAPLE), which is aware of (in)valid
cache entries. regmap will then init the cache on the first access to a
register.
You could also combine the two, like the Cypress driver Andy referred to
(pinctrl-cy8c95x0.c). In that case you get cache loading at init, instead of at
first use, but without the risk of missing something.
Best,
Sander
Powered by blists - more mailing lists