From: Sander Vanheule <sander@svanheule.net>
To: bigunclemax@gmail.com
Cc: Mike Looijmans <mike.looijmans@topic.nl>,
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: Mon, 20 Oct 2025 21:40:04 +0200 [thread overview]
Message-ID: <c046ace3d4569405e167db9cc6ede90048dc0450.camel@svanheule.net> (raw)
In-Reply-To: <20251009132651.649099-2-bigunclemax@gmail.com>
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.
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
next prev parent reply other threads:[~2025-10-20 19:40 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 [this message]
2025-10-22 14:45 ` Mike Looijmans
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=c046ace3d4569405e167db9cc6ede90048dc0450.camel@svanheule.net \
--to=sander@svanheule.net \
--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=mike.looijmans@topic.nl \
/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®