Commit 5a9e02e9 authored by Wu Fengguang's avatar Wu Fengguang Committed by Takashi Iwai

ALSA: hda - create hda_codec.control_mutex for kcontrol->private_value

Fix the following lockdep warning by not reusing the hda_codec.spdif_mutex.

    ALSA sound/pci/hda/hda_codec.c:882: hda_codec_cleanup_stream: NID=0x2

    =======================================================
    [ INFO: possible circular locking dependency detected ]
    2.6.28-next-20090102 #33
    -------------------------------------------------------
    mplayer/3151 is trying to acquire lock:
     (&pcm->open_mutex){--..}, at: [<ffffffffa004ced3>] snd_pcm_release+0x43/0xd0 [snd_pcm]

    but task is already holding lock:
     (&mm->mmap_sem){----}, at: [<ffffffff810c0252>] sys_munmap+0x42/0x80

    which lock already depends on the new lock.
Signed-off-by: default avatarWu Fengguang <fengguang.wu@intel.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 57d13927
...@@ -735,6 +735,7 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr ...@@ -735,6 +735,7 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr
codec->bus = bus; codec->bus = bus;
codec->addr = codec_addr; codec->addr = codec_addr;
mutex_init(&codec->spdif_mutex); mutex_init(&codec->spdif_mutex);
mutex_init(&codec->control_mutex);
init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info)); init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info));
init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head)); init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head));
snd_array_init(&codec->mixers, sizeof(struct snd_kcontrol *), 32); snd_array_init(&codec->mixers, sizeof(struct snd_kcontrol *), 32);
...@@ -1418,12 +1419,12 @@ int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol, ...@@ -1418,12 +1419,12 @@ int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol,
unsigned long pval; unsigned long pval;
int err; int err;
mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */ mutex_lock(&codec->control_mutex);
pval = kcontrol->private_value; pval = kcontrol->private_value;
kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */ kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */
err = snd_hda_mixer_amp_switch_get(kcontrol, ucontrol); err = snd_hda_mixer_amp_switch_get(kcontrol, ucontrol);
kcontrol->private_value = pval; kcontrol->private_value = pval;
mutex_unlock(&codec->spdif_mutex); mutex_unlock(&codec->control_mutex);
return err; return err;
} }
EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_switch_get); EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_switch_get);
...@@ -1435,7 +1436,7 @@ int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, ...@@ -1435,7 +1436,7 @@ int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol,
unsigned long pval; unsigned long pval;
int i, indices, err = 0, change = 0; int i, indices, err = 0, change = 0;
mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */ mutex_lock(&codec->control_mutex);
pval = kcontrol->private_value; pval = kcontrol->private_value;
indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT; indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT;
for (i = 0; i < indices; i++) { for (i = 0; i < indices; i++) {
...@@ -1447,7 +1448,7 @@ int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, ...@@ -1447,7 +1448,7 @@ int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol,
change |= err; change |= err;
} }
kcontrol->private_value = pval; kcontrol->private_value = pval;
mutex_unlock(&codec->spdif_mutex); mutex_unlock(&codec->control_mutex);
return err < 0 ? err : change; return err < 0 ? err : change;
} }
EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_switch_put); EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_switch_put);
...@@ -1462,12 +1463,12 @@ int snd_hda_mixer_bind_ctls_info(struct snd_kcontrol *kcontrol, ...@@ -1462,12 +1463,12 @@ int snd_hda_mixer_bind_ctls_info(struct snd_kcontrol *kcontrol,
struct hda_bind_ctls *c; struct hda_bind_ctls *c;
int err; int err;
mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */ mutex_lock(&codec->control_mutex);
c = (struct hda_bind_ctls *)kcontrol->private_value; c = (struct hda_bind_ctls *)kcontrol->private_value;
kcontrol->private_value = *c->values; kcontrol->private_value = *c->values;
err = c->ops->info(kcontrol, uinfo); err = c->ops->info(kcontrol, uinfo);
kcontrol->private_value = (long)c; kcontrol->private_value = (long)c;
mutex_unlock(&codec->spdif_mutex); mutex_unlock(&codec->control_mutex);
return err; return err;
} }
EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_ctls_info); EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_ctls_info);
...@@ -1479,12 +1480,12 @@ int snd_hda_mixer_bind_ctls_get(struct snd_kcontrol *kcontrol, ...@@ -1479,12 +1480,12 @@ int snd_hda_mixer_bind_ctls_get(struct snd_kcontrol *kcontrol,
struct hda_bind_ctls *c; struct hda_bind_ctls *c;
int err; int err;
mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */ mutex_lock(&codec->control_mutex);
c = (struct hda_bind_ctls *)kcontrol->private_value; c = (struct hda_bind_ctls *)kcontrol->private_value;
kcontrol->private_value = *c->values; kcontrol->private_value = *c->values;
err = c->ops->get(kcontrol, ucontrol); err = c->ops->get(kcontrol, ucontrol);
kcontrol->private_value = (long)c; kcontrol->private_value = (long)c;
mutex_unlock(&codec->spdif_mutex); mutex_unlock(&codec->control_mutex);
return err; return err;
} }
EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_ctls_get); EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_ctls_get);
...@@ -1497,7 +1498,7 @@ int snd_hda_mixer_bind_ctls_put(struct snd_kcontrol *kcontrol, ...@@ -1497,7 +1498,7 @@ int snd_hda_mixer_bind_ctls_put(struct snd_kcontrol *kcontrol,
unsigned long *vals; unsigned long *vals;
int err = 0, change = 0; int err = 0, change = 0;
mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */ mutex_lock(&codec->control_mutex);
c = (struct hda_bind_ctls *)kcontrol->private_value; c = (struct hda_bind_ctls *)kcontrol->private_value;
for (vals = c->values; *vals; vals++) { for (vals = c->values; *vals; vals++) {
kcontrol->private_value = *vals; kcontrol->private_value = *vals;
...@@ -1507,7 +1508,7 @@ int snd_hda_mixer_bind_ctls_put(struct snd_kcontrol *kcontrol, ...@@ -1507,7 +1508,7 @@ int snd_hda_mixer_bind_ctls_put(struct snd_kcontrol *kcontrol,
change |= err; change |= err;
} }
kcontrol->private_value = (long)c; kcontrol->private_value = (long)c;
mutex_unlock(&codec->spdif_mutex); mutex_unlock(&codec->control_mutex);
return err < 0 ? err : change; return err < 0 ? err : change;
} }
EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_ctls_put); EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_ctls_put);
...@@ -1519,12 +1520,12 @@ int snd_hda_mixer_bind_tlv(struct snd_kcontrol *kcontrol, int op_flag, ...@@ -1519,12 +1520,12 @@ int snd_hda_mixer_bind_tlv(struct snd_kcontrol *kcontrol, int op_flag,
struct hda_bind_ctls *c; struct hda_bind_ctls *c;
int err; int err;
mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */ mutex_lock(&codec->control_mutex);
c = (struct hda_bind_ctls *)kcontrol->private_value; c = (struct hda_bind_ctls *)kcontrol->private_value;
kcontrol->private_value = *c->values; kcontrol->private_value = *c->values;
err = c->ops->tlv(kcontrol, op_flag, size, tlv); err = c->ops->tlv(kcontrol, op_flag, size, tlv);
kcontrol->private_value = (long)c; kcontrol->private_value = (long)c;
mutex_unlock(&codec->spdif_mutex); mutex_unlock(&codec->control_mutex);
return err; return err;
} }
EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_tlv); EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_tlv);
......
...@@ -771,6 +771,7 @@ struct hda_codec { ...@@ -771,6 +771,7 @@ struct hda_codec {
struct hda_cache_rec cmd_cache; /* cache for other commands */ struct hda_cache_rec cmd_cache; /* cache for other commands */
struct mutex spdif_mutex; struct mutex spdif_mutex;
struct mutex control_mutex;
unsigned int spdif_status; /* IEC958 status bits */ unsigned int spdif_status; /* IEC958 status bits */
unsigned short spdif_ctls; /* SPDIF control bits */ unsigned short spdif_ctls; /* SPDIF control bits */
unsigned int spdif_in_enable; /* SPDIF input enable? */ unsigned int spdif_in_enable; /* SPDIF input enable? */
......
...@@ -1502,11 +1502,11 @@ static int alc_cap_vol_info(struct snd_kcontrol *kcontrol, ...@@ -1502,11 +1502,11 @@ static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
struct alc_spec *spec = codec->spec; struct alc_spec *spec = codec->spec;
int err; int err;
mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */ mutex_lock(&codec->control_mutex);
kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
HDA_INPUT); HDA_INPUT);
err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo); err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */ mutex_unlock(&codec->control_mutex);
return err; return err;
} }
...@@ -1517,11 +1517,11 @@ static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag, ...@@ -1517,11 +1517,11 @@ static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
struct alc_spec *spec = codec->spec; struct alc_spec *spec = codec->spec;
int err; int err;
mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */ mutex_lock(&codec->control_mutex);
kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
HDA_INPUT); HDA_INPUT);
err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv); err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */ mutex_unlock(&codec->control_mutex);
return err; return err;
} }
...@@ -1537,11 +1537,11 @@ static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol, ...@@ -1537,11 +1537,11 @@ static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
int err; int err;
mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */ mutex_lock(&codec->control_mutex);
kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx], kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
3, 0, HDA_INPUT); 3, 0, HDA_INPUT);
err = func(kcontrol, ucontrol); err = func(kcontrol, ucontrol);
mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */ mutex_unlock(&codec->control_mutex);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment