Compare
b26edc925c1cfa0184cd270ed81d4833db045ce0..834035934cef9e60169de682f4dc9feafd49e51a
regmap: Remove debugfs before cache teardown
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 <michael.reeves077@gmail.com> Reviewed-by: Peng Fan <peng.fan@nxp.com> Link: https://patch.msgid.link/20261006-regcache-lifecycle-submit-v3-1-37bdd82fd47c@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
Michael Reeves <michael.reeves077@gmail.com> · 2026-10-06 07:03 UTC · committed by Mark Brown
5 files changed,
+13
−9
- drivers/base/regmap/regmap-debugfs.c
- drivers/base/regmap/regmap.c
- sound/soc/codecs/cs42l52.c
- sound/soc/codecs/cs42l56.c
- sound/soc/codecs/pcm3168a.c
modified drivers/base/regmap/regmap-debugfs.c
| @@ -664,6 +664,7 @@ void regmap_debugfs_exit(struct regmap *map) | |||
| 664 | 664 | { | |
| 665 | 665 | if (map->debugfs) { | |
| 666 | 666 | debugfs_remove_recursive(map->debugfs); | |
| 667 | + | map->debugfs = NULL; | |
| 667 | 668 | mutex_lock(&map->cache_lock); | |
| 668 | 669 | regmap_debugfs_free_dump_cache(map); | |
| 669 | 670 | mutex_unlock(&map->cache_lock); | |
modified drivers/base/regmap/regmap.c
| @@ -1422,8 +1422,8 @@ int regmap_reinit_cache(struct regmap *map, const struct regmap_config *config) | |||
| 1422 | 1422 | { | |
| 1423 | 1423 | int ret; | |
| 1424 | 1424 | ||
| 1425 | - | regcache_exit(map); | |
| 1426 | 1425 | regmap_debugfs_exit(map); | |
| 1426 | + | regcache_exit(map); | |
| 1427 | 1427 | ||
| 1428 | 1428 | map->max_register = config->max_register; | |
| 1429 | 1429 | map->max_register_is_set = map->max_register ?: config->max_register_is_0; | |
| @@ -1440,12 +1440,16 @@ int regmap_reinit_cache(struct regmap *map, const struct regmap_config *config) | |||
| 1440 | 1440 | if (ret) | |
| 1441 | 1441 | return ret; | |
| 1442 | 1442 | ||
| 1443 | - | regmap_debugfs_init(map); | |
| 1444 | - | ||
| 1445 | 1443 | map->cache_bypass = false; | |
| 1446 | 1444 | map->cache_only = false; | |
| 1447 | 1445 | ||
| 1448 | - | return regcache_init(map, config); | |
| 1446 | + | ret = regcache_init(map, config); | |
| 1447 | + | if (ret) | |
| 1448 | + | return ret; | |
| 1449 | + | ||
| 1450 | + | regmap_debugfs_init(map); | |
| 1451 | + | ||
| 1452 | + | return 0; | |
| 1449 | 1453 | } | |
| 1450 | 1454 | EXPORT_SYMBOL_GPL(regmap_reinit_cache); | |
| 1451 | 1455 | ||
| @@ -1459,9 +1463,8 @@ void regmap_exit(struct regmap *map) | |||
| 1459 | 1463 | struct regmap_async *async; | |
| 1460 | 1464 | ||
| 1461 | 1465 | regmap_detach_dev(map->dev, map); | |
| 1462 | - | regcache_exit(map); | |
| 1463 | - | ||
| 1464 | 1466 | regmap_debugfs_exit(map); | |
| 1467 | + | regcache_exit(map); | |
| 1465 | 1468 | regmap_range_exit(map); | |
| 1466 | 1469 | if (map->bus && map->bus->free_context) | |
| 1467 | 1470 | map->bus->free_context(map->bus_context); | |
modified sound/soc/codecs/cs42l52.c
| @@ -290,7 +290,7 @@ static const char * const cs42l52_ng_type_text[] = { | |||
| 290 | 290 | }; | |
| 291 | 291 | ||
| 292 | 292 | static SOC_ENUM_SINGLE_DECL(ng_type_enum, | |
| 293 | - | CS42L52_NOISE_GATE_CTL, 7, | |
| 293 | + | CS42L52_NOISE_GATE_CTL, 6, | |
| 294 | 294 | cs42l52_ng_type_text); | |
| 295 | 295 | ||
| 296 | 296 | static const char * const left_swap_text[] = { | |
modified sound/soc/codecs/cs42l56.c
| @@ -481,7 +481,7 @@ static const struct snd_kcontrol_new cs42l56_snd_controls[] = { | |||
| 481 | 481 | 0, 0x3f, 0, 0), | |
| 482 | 482 | SOC_SINGLE_TLV("Limiter MAX", CS42L56_LIM_THRESHOLD_CTL, | |
| 483 | 483 | 5, 0x07, 1, alc_tlv), | |
| 484 | - | SOC_SINGLE_TLV("Limiter Cushion", CS42L56_LIM_THRESHOLD_CTL, | |
| 484 | + | SOC_SINGLE_TLV("Limiter Cushion", CS42L56_ALC_THRESHOLD, | |
| 485 | 485 | 2, 0x07, 1, alc_tlv), | |
| 486 | 486 | ||
| 487 | 487 | SOC_SINGLE("NG Switch", CS42L56_NOISE_GATE_CTL, 6, 1, 1), | |
modified sound/soc/codecs/pcm3168a.c
| @@ -103,7 +103,7 @@ static SOC_ENUM_SINGLE_DECL(pcm3168a_dac_zf_func, PCM3168A_DAC_ATT_DEMP_ZF, | |||
| 103 | 103 | static const char *const pcm3168a_pol[] = { "Active High", "Active Low" }; | |
| 104 | 104 | ||
| 105 | 105 | static SOC_ENUM_SINGLE_DECL(pcm3168a_dac_zf_pol, PCM3168A_DAC_ATT_DEMP_ZF, | |
| 106 | - | PCM3168A_DAC_ZREV_SHIFT, pcm3168a_pol); | |
| 106 | + | PCM3168A_DAC_ATSPDA_SHIFT, pcm3168a_pol); | |
| 107 | 107 | ||
| 108 | 108 | static const char *const pcm3168a_con[] = { "Differential", "Single-Ended" }; | |
| 109 | 109 | ||