lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e461ca08-ad28-44fe-85f1-afe332c1d43d@topic.nl>
Date: Wed, 22 Oct 2025 16:45:48 +0200
From: Mike Looijmans <mike.looijmans@...ic.nl>
To: Sander Vanheule <sander@...nheule.net>, bigunclemax@...il.com
CC: 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

On 10/20/25 21:40, Sander Vanheule wrote:
> 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.

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



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ