Skip to content

Commit

Permalink
ASoC: allo-piano-dac-plus: Fix volume limit locking
Browse files Browse the repository at this point in the history
Calling snd_soc_limit_volume from within a kcontrol put handler seems
to cause a deadlock as it attempts to claim a write lock that is already
held. Call snd_soc_limit_volume from the main initialisation code
instead, to avoid the recursive locking.

See: #6527

Signed-off-by: Phil Elwell <[email protected]>
  • Loading branch information
pelwell committed Dec 17, 2024
1 parent a7d8cc1 commit 3f85231
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions sound/soc/bcm/allo-piano-dac-plus.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,14 +452,6 @@ static int pcm512x_set_reg_sub(struct snd_kcontrol *kcontrol,

rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]);

if (digital_gain_0db_limit) {
ret = snd_soc_limit_volume(card, "Subwoofer Playback Volume",
207);
if (ret < 0)
dev_warn(card->dev, "Failed to set volume limit: %d\n",
ret);
}

// When in Dual Mono, Sub vol control should not set anything.
if (glb_ptr->dual_mode != 1) { //Not in Dual Mono mode

Expand Down Expand Up @@ -562,14 +554,6 @@ static int pcm512x_set_reg_master(struct snd_kcontrol *kcontrol,

rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]);

if (digital_gain_0db_limit) {
ret = snd_soc_limit_volume(card, "Master Playback Volume",
207);
if (ret < 0)
dev_warn(card->dev, "Failed to set volume limit: %d\n",
ret);
}

if (glb_ptr->dual_mode == 1) { //in Dual Mono Mode

ret = snd_soc_component_write(snd_soc_rtd_to_codec(rtd, 0)->component,
Expand Down Expand Up @@ -750,15 +734,27 @@ static int snd_allo_piano_dac_init(struct snd_soc_pcm_runtime *rtd)
if (digital_gain_0db_limit) {
int ret;

ret = snd_soc_limit_volume(card, "Master Playback Volume",
207);
if (ret < 0)
dev_warn(card->dev, "Failed to set master volume limit: %d\n",
ret);

ret = snd_soc_limit_volume(card, "Subwoofer Playback Volume",
207);
if (ret < 0)
dev_warn(card->dev, "Failed to set subwoofer volume limit: %d\n",
ret);

//Set volume limit on both dacs
for (i = 0; i < ARRAY_SIZE(codec_ctl_pfx); i++) {
char cname[256];

sprintf(cname, "%s %s", codec_ctl_pfx[i], codec_ctl_name[0]);
ret = snd_soc_limit_volume(card, cname, 207);
if (ret < 0)
dev_warn(card->dev, "Failed to set volume limit: %d\n",
ret);
dev_warn(card->dev, "Failed to set %s volume limit: %d\n",
cname, ret);
}
}

Expand Down

0 comments on commit 3f85231

Please sign in to comment.