Skip to content

Commit 08df0d9

Browse files
Tzung-Bi Shihbroonie
authored andcommitted
ASoC: max98090: revert "ASoC: max98090: fix lockdep warning"
Commit 2dc98af ("ASoC: max98090: fix lockdep warning") introduced a helpful-less small lock: shdn_lock. Reverts the commit. Reasons: 1. Lockdep should not be happy by either the original or current code. From lockdep's point of view, there is a lock inversion anyway. Let d = dapm_mutex, c = controls_rwsem, s = shdn_lock, From the reported calling stack: lock acquisition order of snd_soc_register_card() is: d -> c. > snd_ctl_add_replace+0x3c/0x84 > dapm_create_or_share_kcontrol+0x24c/0x2e0 > snd_soc_dapm_new_widgets+0x308/0x594 > snd_soc_bind_card+0x80c/0xad4 > devm_snd_soc_register_card+0x34/0x6c If calling snd_soc_dapm_put_enum_double() in kcontrol's put (e.g. SOC_DAPM_ENUM_EXT), lock acquisition order is: c -> d. Note that, snd_soc_dapm_put_enum_double() acquires d. The possible lock inversion is always there if registering sound card and putting mixer control happen at the same time. In fact, it never happens because the control device don't show up to the userspace until the sound card build success. Commit 2dc98af ("ASoC: max98090: fix lockdep warning") changes the order to: c -> s -> d. The lock inversion is still there. 2. Commit 62d5ae4 ("ASoC: max98090: save and restore SHDN when changing sensitive registers SHDN bit") designed to use dapm_mutex to protect SHDN bit. Use a separate lock breaks the protection. DAPM changes SHDN bit automatically when it finds the path. Thus, any code wants to change the SHDN bit, need to acquire the dapm_mutex first. > SND_SOC_DAPM_SUPPLY("SHDN", M98090_REG_DEVICE_SHUTDOWN, > M98090_SHDNN_SHIFT, 0, NULL, 0), Fixes: 2dc98af ("ASoC: max98090: fix lockdep warning") Signed-off-by: Tzung-Bi Shih <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 250a15c commit 08df0d9

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

sound/soc/codecs/max98090.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ static void max98090_shdn_restore_locked(struct max98090_priv *max98090)
5252

5353
static void max98090_shdn_save(struct max98090_priv *max98090)
5454
{
55-
mutex_lock(&max98090->shdn_lock);
55+
mutex_lock(&max98090->component->card->dapm_mutex);
5656
max98090_shdn_save_locked(max98090);
5757
}
5858

5959
static void max98090_shdn_restore(struct max98090_priv *max98090)
6060
{
6161
max98090_shdn_restore_locked(max98090);
62-
mutex_unlock(&max98090->shdn_lock);
62+
mutex_unlock(&max98090->component->card->dapm_mutex);
6363
}
6464

6565
static int max98090_put_volsw(struct snd_kcontrol *kcontrol,
@@ -2313,12 +2313,12 @@ static void max98090_pll_work(struct max98090_priv *max98090)
23132313
*/
23142314

23152315
/* Toggle shutdown OFF then ON */
2316-
mutex_lock(&max98090->shdn_lock);
2316+
mutex_lock(&component->card->dapm_mutex);
23172317
snd_soc_component_update_bits(component, M98090_REG_DEVICE_SHUTDOWN,
23182318
M98090_SHDNN_MASK, 0);
23192319
snd_soc_component_update_bits(component, M98090_REG_DEVICE_SHUTDOWN,
23202320
M98090_SHDNN_MASK, M98090_SHDNN_MASK);
2321-
mutex_unlock(&max98090->shdn_lock);
2321+
mutex_unlock(&component->card->dapm_mutex);
23222322

23232323
for (i = 0; i < 10; ++i) {
23242324
/* Give PLL time to lock */
@@ -2731,8 +2731,6 @@ static int max98090_i2c_probe(struct i2c_client *i2c,
27312731
if (max98090 == NULL)
27322732
return -ENOMEM;
27332733

2734-
mutex_init(&max98090->shdn_lock);
2735-
27362734
if (ACPI_HANDLE(&i2c->dev)) {
27372735
acpi_id = acpi_match_device(i2c->dev.driver->acpi_match_table,
27382736
&i2c->dev);

sound/soc/codecs/max98090.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1539,7 +1539,6 @@ struct max98090_priv {
15391539
unsigned int pa2en;
15401540
unsigned int sidetone;
15411541
bool master;
1542-
struct mutex shdn_lock;
15431542
int saved_count;
15441543
int saved_shdn;
15451544
};

0 commit comments

Comments
 (0)