From: Mike Looijmans <mike.looijmans@topic.nl>
To: Sander Vanheule <sander@svanheule.net>, bigunclemax@gmail.com
Cc: Linus Walleij <linus.walleij@linaro.org>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: Re: [PATCH v2] pinctrl: mcp23s08: delete regmap reg_defaults to avoid cache sync issues
Date: Wed, 22 Oct 2025 16:45:48 +0200 [thread overview]
Message-ID: <e461ca08-ad28-44fe-85f1-afe332c1d43d@topic.nl> (raw)
In-Reply-To: <c046ace3d4569405e167db9cc6ede90048dc0450.camel@svanheule.net>
On 10/20/25 21:40, Sander Vanheule wrote:
> Hi,
>
> On Thu, 2025-10-09 at 16:26 +0300, bigunclemax@gmail.com wrote:
>> From: Maksim Kiselev <bigunclemax@gmail.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.
Ouch...
I have access to hardware this week (boards with 2 and 3 of the I2C
chips), I'll be able to do some hands-on testing, and report back.
> 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.
Using REGCACHE_MAPLE sounds like the obvious solution to me. That's what most other drivers use.
> 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.
--
Mike Looijmans
next prev parent reply other threads:[~2025-10-22 14:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-09 13:26 bigunclemax
2025-10-13 13:22 ` Linus Walleij
2025-10-20 19:40 ` Sander Vanheule
2025-10-22 14:45 ` Mike Looijmans [this message]
2025-10-24 6:54 ` Mike Looijmans
2025-10-18 19:31 Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e461ca08-ad28-44fe-85f1-afe332c1d43d@topic.nl \
--to=mike.looijmans@topic.nl \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bigunclemax@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sander@svanheule.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®