From: Mike Looijmans <mike.looijmans@topic.nl>
To: bigunclemax@gmail.com
Cc: Linus Walleij <linus.walleij@linaro.org>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] pinctrl: mcp23s08: delete regmap reg_defaults to avoid cache sync issues
Date: Fri, 24 Oct 2025 08:54:02 +0200 [thread overview]
Message-ID: <aaa1208a-f11a-4537-94a8-afed77c7fe84@topic.nl> (raw)
In-Reply-To: <20251009132651.649099-2-bigunclemax@gmail.com>
On 10/9/25 15:26, 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.
Did some testing on actual hardware with this patch "as is". As Sander
mentioned, the REGCACHE_FLAT caching mode assumes all registers are "0"
initially, which causes similar issues as what we're trying to solve.
I've verified that by setting a bit to "1" in the OLAT register (using
i2cset) for an unused GPIO line. After a reboot, the kernel resets it to
"0" because of the caching issue.
I then changed the cache_type to REGCACHE_MAPLE as indicated below, and
then the kernel doesn't touch that bit any longer (as it should).
So once you've amended the patch with REGCACHE_MAPLE, you have my:
Tested-by: Mike Looijmans <mike.looijmans@topic.nl>
> ...
> static const struct regmap_range mcp23x08_volatile_range = {
> .range_min = MCP_INTF,
> .range_max = MCP_GPIO,
> @@ -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,
Must be REGCACHE_MAPLE
> .max_register = MCP_OLAT,
> .disable_locking = true, /* mcp->lock protects the regmap */
> };
> EXPORT_SYMBOL_GPL(mcp23x08_regmap);
>
> -static const struct reg_default mcp23x17_defaults[] = {
> - {.reg = MCP_IODIR << 1, .def = 0xffff},
> - {.reg = MCP_IPOL << 1, .def = 0x0000},
> - {.reg = MCP_GPINTEN << 1, .def = 0x0000},
> - {.reg = MCP_DEFVAL << 1, .def = 0x0000},
> - {.reg = MCP_INTCON << 1, .def = 0x0000},
> - {.reg = MCP_IOCON << 1, .def = 0x0000},
> - {.reg = MCP_GPPU << 1, .def = 0x0000},
> - {.reg = MCP_OLAT << 1, .def = 0x0000},
> -};
> -
> static const struct regmap_range mcp23x17_volatile_range = {
> .range_min = MCP_INTF << 1,
> .range_max = MCP_GPIO << 1,
> @@ -129,8 +105,6 @@ const struct regmap_config mcp23x17_regmap = {
> .max_register = MCP_OLAT << 1,
> .volatile_table = &mcp23x17_volatile_table,
> .precious_table = &mcp23x17_precious_table,
> - .reg_defaults = mcp23x17_defaults,
> - .num_reg_defaults = ARRAY_SIZE(mcp23x17_defaults),
> .cache_type = REGCACHE_FLAT,
Must be REGCACHE_MAPLE
> .val_format_endian = REGMAP_ENDIAN_LITTLE,
> .disable_locking = true, /* mcp->lock protects the regmap */
> @@ -614,14 +588,6 @@ int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,
> ...
--
Mike Looijmans
System Expert
TOPIC Embedded Products B.V.
Materiaalweg 4, 5681 RJ Best
The Netherlands
T: +31 (0) 499 33 69 69
E: mike.looijmans@topic.nl
W: www.topic.nl
next prev parent reply other threads:[~2025-10-24 6:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-09 13:26 [PATCH v2] pinctrl: mcp23s08: delete regmap reg_defaults to avoid cache sync issues bigunclemax
2025-10-13 13:22 ` Linus Walleij
2025-10-20 19:40 ` Sander Vanheule
2025-10-22 14:45 ` Mike Looijmans
2025-10-24 6:54 ` Mike Looijmans [this message]
-- strict thread matches above, loose matches on Subject: below --
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=aaa1208a-f11a-4537-94a8-afed77c7fe84@topic.nl \
--to=mike.looijmans@topic.nl \
--cc=bigunclemax@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).