<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/drivers/base/regmap, branch master</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>regmap: irq: fix incorrect index calculation for read_sub_irq_data()</title>
<updated>2026-10-21T16:53:15+00:00</updated>
<author>
<name>Qinguang Xu</name>
<email>guang.cy2023@gmail.com</email>
</author>
<published>2026-10-20T13:39:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=1ea2927c1bc3c66d2ff69f131268e6be4d38a87c'/>
<id>1ea2927c1bc3c66d2ff69f131268e6be4d38a87c</id>
<content type='text'>
While working on a PMIC driver that utilizes num_main_regs &gt; 1, this
issue was noticed. Currently, no in-tree driver sets `num_main_regs &gt;
1`, so this bug has not been triggered in practice.

Pass the global index calculated with `i` instead of the local bit
offset `b` to read_sub_irq_data().

Fix an off-by-one error in the index bounds check.

This patch has been compile-tested only.

Signed-off-by: Qinguang Xu &lt;guang.cy2023@gmail.com&gt;
Link: https://patch.msgid.link/20261020-debug-v1-1-44e0491ede30@gmail.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
While working on a PMIC driver that utilizes num_main_regs &gt; 1, this
issue was noticed. Currently, no in-tree driver sets `num_main_regs &gt;
1`, so this bug has not been triggered in practice.

Pass the global index calculated with `i` instead of the local bit
offset `b` to read_sub_irq_data().

Fix an off-by-one error in the index bounds check.

This patch has been compile-tested only.

Signed-off-by: Qinguang Xu &lt;guang.cy2023@gmail.com&gt;
Link: https://patch.msgid.link/20261020-debug-v1-1-44e0491ede30@gmail.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>regmap: Merge up fixes</title>
<updated>2026-10-19T18:23:44+00:00</updated>
<author>
<name>Mark Brown</name>
<email>broonie@kernel.org</email>
</author>
<published>2026-10-19T18:23:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=2dee91ee94eec85d09c13c7ca83e3005906d3732'/>
<id>2dee91ee94eec85d09c13c7ca83e3005906d3732</id>
<content type='text'>
The main thing here is a fix for lockdep warnings with MMIO regmaps that
use a raw spinlock and a cache, some other lockdep fixes we'd done for
the benefit of the maple tree on sleeping buses meant that we were doing
allocations for those MMIO regmaps under a raw spinlock.  While fixing
that Michael Reeves also noticed that the debugfs files were briefly
available without the cache structures backing them.

There's also a fix for interrupt freeing on error in regmap-irq which
had been hanging around because it's not super urgent.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The main thing here is a fix for lockdep warnings with MMIO regmaps that
use a raw spinlock and a cache, some other lockdep fixes we'd done for
the benefit of the maple tree on sleeping buses meant that we were doing
allocations for those MMIO regmaps under a raw spinlock.  While fixing
that Michael Reeves also noticed that the debugfs files were briefly
available without the cache structures backing them.

There's also a fix for interrupt freeing on error in regmap-irq which
had been hanging around because it's not super urgent.
</pre>
</div>
</content>
</entry>
<entry>
<title>regmap: Fix cache lifecycle locking and teardown</title>
<updated>2026-10-12T23:11:44+00:00</updated>
<author>
<name>Mark Brown</name>
<email>broonie@kernel.org</email>
</author>
<published>2026-10-12T23:11:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=d5a821f66047c2effd06147b84775f9b2ce0f4aa'/>
<id>d5a821f66047c2effd06147b84775f9b2ce0f4aa</id>
<content type='text'>
Michael Reeves &lt;michael.reeves077@gmail.com&gt; says:

Fix an "Invalid wait context" lockdep warning during Apple GPIO probe and
correct debugfs ordering during cache teardown.

Tested on Apple M3 MacBook Air (T8122):

- All 4 GPIO controllers probe successfully with lockdep enabled.
- The "Invalid wait context" warning no longer occurs.
- The regmap KUnit suite passes and lockdep remains enabled.

Link: https://patch.msgid.link/20261006-regcache-lifecycle-submit-v3-0-37bdd82fd47c@gmail.com
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Michael Reeves &lt;michael.reeves077@gmail.com&gt; says:

Fix an "Invalid wait context" lockdep warning during Apple GPIO probe and
correct debugfs ordering during cache teardown.

Tested on Apple M3 MacBook Air (T8122):

- All 4 GPIO controllers probe successfully with lockdep enabled.
- The "Invalid wait context" warning no longer occurs.
- The regmap KUnit suite passes and lockdep remains enabled.

Link: https://patch.msgid.link/20261006-regcache-lifecycle-submit-v3-0-37bdd82fd47c@gmail.com
</pre>
</div>
</content>
</entry>
<entry>
<title>regmap: Drop map lock during cache init and exit</title>
<updated>2026-10-12T23:11:44+00:00</updated>
<author>
<name>Michael Reeves</name>
<email>michael.reeves077@gmail.com</email>
</author>
<published>2026-10-06T07:03:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=abff0a48b110fe52d43999b4cb7c793a510a6bf1'/>
<id>abff0a48b110fe52d43999b4cb7c793a510a6bf1</id>
<content type='text'>
On systems with CONFIG_PROVE_RAW_LOCK_NESTING enabled, Apple GPIO probe
triggers an "Invalid wait context" lockdep warning.

The driver uses a regmap with a raw spinlock and REGCACHE_FLAT. During
regcache_init(), regcache_flat_init() allocates memory while holding the
raw spinlock. The memory allocator can acquire a non-raw spinlock, which
causes an invalid raw-to-non-raw lock nesting error. The abbreviated call
chain is:

  apple_gpio_pinctrl_probe
    regcache_init
      regcache_flat_init
        __kmalloc_noprof
          __pcs_replace_empty_main
            refill_objects
              _raw_spin_lock_irqsave

Cache allocation occurs before the regmap is published, cache destruction
occurs after users have stopped accessing it, and regmap_reinit_cache()
requires callers to prevent concurrent access. Remove the outer map lock
from cache initialization and destruction. Keep it for cache population
and normal register access.

The Maple cache still uses its internal spinlock during teardown. That
lock can also be acquired from hard IRQ context during register access.
Add Maple-state irqsave helpers and use them during teardown to preserve
the lock's IRQ-safe lockdep state.

Fixes: fd4ebc07b4df ("regmap: Hold the regmap lock when allocating and freeing the cache")
Suggested-by: Mark Brown &lt;broonie@kernel.org&gt;
Suggested-by: Liam R. Howlett &lt;liam@infradead.org&gt;
Signed-off-by: Michael Reeves &lt;michael.reeves077@gmail.com&gt;
Reviewed-by: Peng Fan &lt;peng.fan@nxp.com&gt;
Link: https://patch.msgid.link/20261006-regcache-lifecycle-submit-v3-2-37bdd82fd47c@gmail.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
On systems with CONFIG_PROVE_RAW_LOCK_NESTING enabled, Apple GPIO probe
triggers an "Invalid wait context" lockdep warning.

The driver uses a regmap with a raw spinlock and REGCACHE_FLAT. During
regcache_init(), regcache_flat_init() allocates memory while holding the
raw spinlock. The memory allocator can acquire a non-raw spinlock, which
causes an invalid raw-to-non-raw lock nesting error. The abbreviated call
chain is:

  apple_gpio_pinctrl_probe
    regcache_init
      regcache_flat_init
        __kmalloc_noprof
          __pcs_replace_empty_main
            refill_objects
              _raw_spin_lock_irqsave

Cache allocation occurs before the regmap is published, cache destruction
occurs after users have stopped accessing it, and regmap_reinit_cache()
requires callers to prevent concurrent access. Remove the outer map lock
from cache initialization and destruction. Keep it for cache population
and normal register access.

The Maple cache still uses its internal spinlock during teardown. That
lock can also be acquired from hard IRQ context during register access.
Add Maple-state irqsave helpers and use them during teardown to preserve
the lock's IRQ-safe lockdep state.

Fixes: fd4ebc07b4df ("regmap: Hold the regmap lock when allocating and freeing the cache")
Suggested-by: Mark Brown &lt;broonie@kernel.org&gt;
Suggested-by: Liam R. Howlett &lt;liam@infradead.org&gt;
Signed-off-by: Michael Reeves &lt;michael.reeves077@gmail.com&gt;
Reviewed-by: Peng Fan &lt;peng.fan@nxp.com&gt;
Link: https://patch.msgid.link/20261006-regcache-lifecycle-submit-v3-2-37bdd82fd47c@gmail.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>regmap: Remove debugfs before cache teardown</title>
<updated>2026-10-12T23:11:43+00:00</updated>
<author>
<name>Michael Reeves</name>
<email>michael.reeves077@gmail.com</email>
</author>
<published>2026-10-06T07:03:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=834035934cef9e60169de682f4dc9feafd49e51a'/>
<id>834035934cef9e60169de682f4dc9feafd49e51a</id>
<content type='text'>
regmap_exit() and regmap_reinit_cache() destroy the register cache before
removing debugfs. A concurrent debugfs cache operation can therefore
access cache state after the backend exit callback starts freeing it.

Remove debugfs before cache teardown, and clear the debugfs pointer after
removal. During cache reinitialization, recreate debugfs only after the
new cache initializes successfully.

Signed-off-by: Michael Reeves &lt;michael.reeves077@gmail.com&gt;
Reviewed-by: Peng Fan &lt;peng.fan@nxp.com&gt;
Link: https://patch.msgid.link/20261006-regcache-lifecycle-submit-v3-1-37bdd82fd47c@gmail.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
regmap_exit() and regmap_reinit_cache() destroy the register cache before
removing debugfs. A concurrent debugfs cache operation can therefore
access cache state after the backend exit callback starts freeing it.

Remove debugfs before cache teardown, and clear the debugfs pointer after
removal. During cache reinitialization, recreate debugfs only after the
new cache initializes successfully.

Signed-off-by: Michael Reeves &lt;michael.reeves077@gmail.com&gt;
Reviewed-by: Peng Fan &lt;peng.fan@nxp.com&gt;
Link: https://patch.msgid.link/20261006-regcache-lifecycle-submit-v3-1-37bdd82fd47c@gmail.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>regmap: debugfs: Use __free(kfree) for regmap_reg_ranges_read_file</title>
<updated>2026-10-08T07:46:00+00:00</updated>
<author>
<name>Peng Fan</name>
<email>peng.fan@nxp.com</email>
</author>
<published>2026-10-08T00:49:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=f52260f49b107fddbcf7c75f9cf2347a5031f0f7'/>
<id>f52260f49b107fddbcf7c75f9cf2347a5031f0f7</id>
<content type='text'>
Convert buf and entry in regmap_reg_ranges_read_file() from manual
kfree() to __free(kfree) scope-based cleanup. This eliminates the
goto error path and the manual kfree(buf) on entry allocation failure,
simplifying the function to use straight-line returns.

Signed-off-by: Peng Fan &lt;peng.fan@nxp.com&gt;
Link: https://patch.msgid.link/20261008-regmap-debugfs-fix-v1-1-3df2f25c01b6@nxp.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Convert buf and entry in regmap_reg_ranges_read_file() from manual
kfree() to __free(kfree) scope-based cleanup. This eliminates the
goto error path and the manual kfree(buf) on entry allocation failure,
simplifying the function to use straight-line returns.

Signed-off-by: Peng Fan &lt;peng.fan@nxp.com&gt;
Link: https://patch.msgid.link/20261008-regmap-debugfs-fix-v1-1-3df2f25c01b6@nxp.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>regmap: debugfs: Use guard to simplify code</title>
<updated>2026-10-06T16:08:00+00:00</updated>
<author>
<name>Peng Fan</name>
<email>peng.fan@nxp.com</email>
</author>
<published>2026-10-02T13:11:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=a93de1d65c6b5e4d493640be7f1429faad47a584'/>
<id>a93de1d65c6b5e4d493640be7f1429faad47a584</id>
<content type='text'>
Replace open-coded mutex_lock()/unlock() pairs with guard() and
scoped_guard() across the debugfs code.

 - regmap_debugfs_get_dump_start(): guard(mutex) replaces three
   unlock sites (kzalloc failure, cache hit, end-of-function).

 - regmap_next_readable_reg(): early return for the common case
   and scoped_guard for the cache fallback path.

 - regmap_reg_ranges_read_file(): scoped_guard wraps the cache
   iteration loop.

 - regmap_debugfs_init(): scoped_guard for single list_add.

 - regmap_debugfs_exit(): flatten if/else into early return and
   scoped_guard for the early-list cleanup.

 - regmap_debugfs_initcall(): guard(mutex) held to function end.

No functional change.

Signed-off-by: Peng Fan &lt;peng.fan@nxp.com&gt;
Link: https://patch.msgid.link/20261002-regmap-lock-2nd-v2-7-e172b0501c52@nxp.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Replace open-coded mutex_lock()/unlock() pairs with guard() and
scoped_guard() across the debugfs code.

 - regmap_debugfs_get_dump_start(): guard(mutex) replaces three
   unlock sites (kzalloc failure, cache hit, end-of-function).

 - regmap_next_readable_reg(): early return for the common case
   and scoped_guard for the cache fallback path.

 - regmap_reg_ranges_read_file(): scoped_guard wraps the cache
   iteration loop.

 - regmap_debugfs_init(): scoped_guard for single list_add.

 - regmap_debugfs_exit(): flatten if/else into early return and
   scoped_guard for the early-list cleanup.

 - regmap_debugfs_initcall(): guard(mutex) held to function end.

No functional change.

Signed-off-by: Peng Fan &lt;peng.fan@nxp.com&gt;
Link: https://patch.msgid.link/20261002-regmap-lock-2nd-v2-7-e172b0501c52@nxp.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>regmap: debugfs: Use __free(kfree) in regmap_name_read_file()</title>
<updated>2026-10-06T16:08:00+00:00</updated>
<author>
<name>Peng Fan</name>
<email>peng.fan@nxp.com</email>
</author>
<published>2026-10-02T13:11:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=d64967dee82b117f3fcc4da71ccf5b9258670869'/>
<id>d64967dee82b117f3fcc4da71ccf5b9258670869</id>
<content type='text'>
Use the __free(kfree) cleanup helper for the temporary buffer allocated
by regmap_name_read_file().

Remove the explicit kfree() calls from the error and success paths.

No functional change.

Signed-off-by: Peng Fan &lt;peng.fan@nxp.com&gt;
Link: https://patch.msgid.link/20261002-regmap-lock-2nd-v2-6-e172b0501c52@nxp.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use the __free(kfree) cleanup helper for the temporary buffer allocated
by regmap_name_read_file().

Remove the explicit kfree() calls from the error and success paths.

No functional change.

Signed-off-by: Peng Fan &lt;peng.fan@nxp.com&gt;
Link: https://patch.msgid.link/20261002-regmap-lock-2nd-v2-6-e172b0501c52@nxp.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>regmap: fix potential double-free of map-&gt;reg_defaults on cache reinit</title>
<updated>2026-10-06T16:08:00+00:00</updated>
<author>
<name>Peng Fan</name>
<email>peng.fan@nxp.com</email>
</author>
<published>2026-10-02T13:11:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=ca685a42b0fda83037a92e3fd58763aa033c124b'/>
<id>ca685a42b0fda83037a92e3fd58763aa033c124b</id>
<content type='text'>
regcache_exit() frees map-&gt;reg_defaults but does not NULL the pointer.
If regmap_reinit_cache() is later called with a config that has neither
reg_defaults nor num_reg_defaults_raw, regcache_init() skips both
allocation branches and leaves the stale pointer in place.  Should
cache_ops-&gt;init then fail, the err_free_reg_defaults error path calls
kfree(map-&gt;reg_defaults) a second time.

NULL the pointer after freeing so the error-path kfree() is a harmless
no-op.

Assisted-by: LLM
Signed-off-by: Peng Fan &lt;peng.fan@nxp.com&gt;
Link: https://patch.msgid.link/20261002-regmap-lock-2nd-v2-5-e172b0501c52@nxp.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
regcache_exit() frees map-&gt;reg_defaults but does not NULL the pointer.
If regmap_reinit_cache() is later called with a config that has neither
reg_defaults nor num_reg_defaults_raw, regcache_init() skips both
allocation branches and leaves the stale pointer in place.  Should
cache_ops-&gt;init then fail, the err_free_reg_defaults error path calls
kfree(map-&gt;reg_defaults) a second time.

NULL the pointer after freeing so the error-path kfree() is a harmless
no-op.

Assisted-by: LLM
Signed-off-by: Peng Fan &lt;peng.fan@nxp.com&gt;
Link: https://patch.msgid.link/20261002-regmap-lock-2nd-v2-5-e172b0501c52@nxp.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>regmap: use krealloc_array() in regmap_register_patch()</title>
<updated>2026-10-06T16:08:00+00:00</updated>
<author>
<name>Peng Fan</name>
<email>peng.fan@nxp.com</email>
</author>
<published>2026-10-02T13:11:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=8a889c83e478074f90335791f7d2c8e2dc5b0552'/>
<id>8a889c83e478074f90335791f7d2c8e2dc5b0552</id>
<content type='text'>
Replace krealloc() with krealloc_array() in regmap_register_patch() to
gain the built-in overflow check on the element-count * element-size
multiplication, and switch to the early-return error style to reduce
nesting.

Assisted-by: LLM
Signed-off-by: Peng Fan &lt;peng.fan@nxp.com&gt;
Link: https://patch.msgid.link/20261002-regmap-lock-2nd-v2-4-e172b0501c52@nxp.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Replace krealloc() with krealloc_array() in regmap_register_patch() to
gain the built-in overflow check on the element-count * element-size
multiplication, and switch to the early-return error style to reduce
nesting.

Assisted-by: LLM
Signed-off-by: Peng Fan &lt;peng.fan@nxp.com&gt;
Link: https://patch.msgid.link/20261002-regmap-lock-2nd-v2-4-e172b0501c52@nxp.com
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
</pre>
</div>
</content>
</entry>
</feed>
