From 7a3c2b69386102de9e78fa9ea679898f5502f77d Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Wed, 10 Jul 2019 08:00:59 +0530 Subject: ALSA: lx6464es: Remove unneeded variable err This patch fixes below issue reported by coccicheck sound/pci/lx6464es/lx6464es.c:256:5-8: Unneeded variable: "err". Return "0" on line 258 Signed-off-by: Hariprasad Kelam Signed-off-by: Takashi Iwai --- sound/pci/lx6464es/lx6464es.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c index 1771a6dcbe18..583ca7384d83 100644 --- a/sound/pci/lx6464es/lx6464es.c +++ b/sound/pci/lx6464es/lx6464es.c @@ -253,9 +253,8 @@ exit: static int lx_pcm_close(struct snd_pcm_substream *substream) { - int err = 0; dev_dbg(substream->pcm->card->dev, "->lx_pcm_close\n"); - return err; + return 0; } static snd_pcm_uframes_t lx_pcm_stream_pointer(struct snd_pcm_substream -- cgit v1.2.3-59-g8ed1b From 73948ca0571325aafd925497c1c37f6b09ed1724 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Wed, 10 Jul 2019 08:09:46 +0530 Subject: ALSA: ps3: Remove Unneeded variable: "ret" This patch fixes below issue reported by coccicheck sound/ppc/snd_ps3.c:631:5-8: Unneeded variable: "ret". Return "0" on line 668 Signed-off-by: Hariprasad Kelam Signed-off-by: Takashi Iwai --- sound/ppc/snd_ps3.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/ppc/snd_ps3.c b/sound/ppc/snd_ps3.c index 71b7fd344c58..c213eb7ca23c 100644 --- a/sound/ppc/snd_ps3.c +++ b/sound/ppc/snd_ps3.c @@ -628,7 +628,6 @@ static int snd_ps3_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { struct snd_ps3_card_info *card = snd_pcm_substream_chip(substream); - int ret = 0; switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -665,7 +664,7 @@ static int snd_ps3_pcm_trigger(struct snd_pcm_substream *substream, } - return ret; + return 0; }; /* -- cgit v1.2.3-59-g8ed1b From fbc571290d9f7bfe089c50f4ac4028dd98ebfe98 Mon Sep 17 00:00:00 2001 From: Kailang Yang Date: Mon, 15 Jul 2019 10:41:50 +0800 Subject: ALSA: hda/realtek - Fixed Headphone Mic can't record on Dell platform It assigned to wrong model. So, The headphone Mic can't work. Fixes: 3f640970a414 ("ALSA: hda - Fix headset mic detection problem for several Dell laptops") Signed-off-by: Kailang Yang Cc: Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index f24a757f8239..1c84c12b39b3 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -7657,9 +7657,12 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = { {0x12, 0x90a60130}, {0x17, 0x90170110}, {0x21, 0x03211020}), - SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, + SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE, {0x14, 0x90170110}, {0x21, 0x04211020}), + SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE, + {0x14, 0x90170110}, + {0x21, 0x04211030}), SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, ALC295_STANDARD_PINS, {0x17, 0x21014020}, -- cgit v1.2.3-59-g8ed1b From 5e19cad550a0b01b778fbfde23e036c9759c4f53 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Thu, 11 Jul 2019 22:43:02 +0530 Subject: ALSA: au88x0: Remove unneeded variable: "changed" Fix below issues reported by coccicheck sound/pci/au88x0/au88x0_a3d.c:821:8-15: Unneeded variable: "changed". Return "1" on line 834 sound/pci/au88x0/au88x0_a3d.c:768:5-12: Unneeded variable: "changed". Return "1" on line 777 sound/pci/au88x0/au88x0_a3d.c:804:5-12: Unneeded variable: "changed". Return "1" on line 813 sound/pci/au88x0/au88x0_a3d.c:786:8-15: Unneeded variable: "changed". Return "1" on line 796 Signed-off-by: Hariprasad Kelam Signed-off-by: Takashi Iwai --- sound/pci/au88x0/au88x0_a3d.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'sound') diff --git a/sound/pci/au88x0/au88x0_a3d.c b/sound/pci/au88x0/au88x0_a3d.c index 73471037d59f..2db183f8826a 100644 --- a/sound/pci/au88x0/au88x0_a3d.c +++ b/sound/pci/au88x0/au88x0_a3d.c @@ -765,7 +765,7 @@ snd_vortex_a3d_hrtf_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { a3dsrc_t *a = kcontrol->private_data; - int changed = 1, i; + int i; int coord[6]; for (i = 0; i < 6; i++) coord[i] = ucontrol->value.integer.value[i]; @@ -774,7 +774,7 @@ snd_vortex_a3d_hrtf_put(struct snd_kcontrol *kcontrol, vortex_a3d_coord2hrtf(a->hrtf[1], coord); a3dsrc_SetHrtfTarget(a, a->hrtf[0], a->hrtf[1]); a3dsrc_SetHrtfCurrent(a, a->hrtf[0], a->hrtf[1]); - return changed; + return 1; } static int @@ -783,7 +783,7 @@ snd_vortex_a3d_itd_put(struct snd_kcontrol *kcontrol, { a3dsrc_t *a = kcontrol->private_data; int coord[6]; - int i, changed = 1; + int i; for (i = 0; i < 6; i++) coord[i] = ucontrol->value.integer.value[i]; /* Translate orientation coordinates to a3d params. */ @@ -793,7 +793,7 @@ snd_vortex_a3d_itd_put(struct snd_kcontrol *kcontrol, a3dsrc_SetItdTarget(a, a->itd[0], a->itd[1]); a3dsrc_SetItdCurrent(a, a->itd[0], a->itd[1]); a3dsrc_SetItdDline(a, a->dline); - return changed; + return 1; } static int @@ -801,7 +801,6 @@ snd_vortex_a3d_ild_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { a3dsrc_t *a = kcontrol->private_data; - int changed = 1; int l, r; /* There may be some scale tranlation needed here. */ l = ucontrol->value.integer.value[0]; @@ -810,7 +809,7 @@ snd_vortex_a3d_ild_put(struct snd_kcontrol *kcontrol, /* Left Right panning. */ a3dsrc_SetGainTarget(a, l, r); a3dsrc_SetGainCurrent(a, l, r); - return changed; + return 1; } static int @@ -818,7 +817,7 @@ snd_vortex_a3d_filter_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { a3dsrc_t *a = kcontrol->private_data; - int i, changed = 1; + int i; int params[6]; for (i = 0; i < 6; i++) params[i] = ucontrol->value.integer.value[i]; @@ -831,7 +830,7 @@ snd_vortex_a3d_filter_put(struct snd_kcontrol *kcontrol, a3dsrc_SetAtmosCurrent(a, a->filter[0], a->filter[1], a->filter[2], a->filter[3], a->filter[4]); - return changed; + return 1; } static const struct snd_kcontrol_new vortex_a3d_kcontrol = { -- cgit v1.2.3-59-g8ed1b From b7cad26d150b05955b5e35b30a82c3eb66761cdc Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Thu, 11 Jul 2019 22:47:26 +0530 Subject: ALSA: emu10k1: Remove unneeded variable "change" fix below issue reported by coccicheck sound/pci/emu10k1/emu10k1x.c:1077:5-11: Unneeded variable: "change". Return "0" on line 1092 Signed-off-by: Hariprasad Kelam Signed-off-by: Takashi Iwai --- sound/pci/emu10k1/emu10k1x.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index 67d6473ab0cd..9cf81832259c 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c @@ -1074,7 +1074,6 @@ static int snd_emu10k1x_shared_spdif_put(struct snd_kcontrol *kcontrol, { struct emu10k1x *emu = snd_kcontrol_chip(kcontrol); unsigned int val; - int change = 0; val = ucontrol->value.integer.value[0] ; @@ -1089,7 +1088,7 @@ static int snd_emu10k1x_shared_spdif_put(struct snd_kcontrol *kcontrol, snd_emu10k1x_ptr_write(emu, ROUTING, 0, 0x1003F); snd_emu10k1x_gpio_write(emu, 0x1080); } - return change; + return 0; } static const struct snd_kcontrol_new snd_emu10k1x_shared_spdif = -- cgit v1.2.3-59-g8ed1b From 2f235d92ac225361a9c653cb76c7ca8ef99621de Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Thu, 11 Jul 2019 22:51:07 +0530 Subject: ALSA: rme9652: Unneeded variable: "result". This patch fixes below issue reported by coccicheck sound/pci/rme9652/rme9652.c:2161:5-11: Unneeded variable: "result". Return "0" on line 2167 Signed-off-by: Hariprasad Kelam Signed-off-by: Takashi Iwai --- sound/pci/rme9652/rme9652.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c index cb9818af5b41..4c851f8dcaf8 100644 --- a/sound/pci/rme9652/rme9652.c +++ b/sound/pci/rme9652/rme9652.c @@ -2158,13 +2158,12 @@ static int snd_rme9652_prepare(struct snd_pcm_substream *substream) { struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream); unsigned long flags; - int result = 0; spin_lock_irqsave(&rme9652->lock, flags); if (!rme9652->running) rme9652_reset_hw_pointer(rme9652); spin_unlock_irqrestore(&rme9652->lock, flags); - return result; + return 0; } static const struct snd_pcm_hardware snd_rme9652_playback_subinfo = -- cgit v1.2.3-59-g8ed1b From 4b4e0e32e4b09274dbc9d173016c1a026f44608c Mon Sep 17 00:00:00 2001 From: Hui Wang Date: Tue, 16 Jul 2019 15:21:34 +0800 Subject: ALSA: hda/realtek: apply ALC891 headset fixup to one Dell machine Without this patch, the headset-mic and headphone-mic don't work. Cc: Signed-off-by: Hui Wang Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 1c84c12b39b3..de224cbea7a0 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -8803,6 +8803,11 @@ static const struct snd_hda_pin_quirk alc662_pin_fixup_tbl[] = { {0x18, 0x01a19030}, {0x1a, 0x01813040}, {0x21, 0x01014020}), + SND_HDA_PIN_QUIRK(0x10ec0867, 0x1028, "Dell", ALC891_FIXUP_DELL_MIC_NO_PRESENCE, + {0x16, 0x01813030}, + {0x17, 0x02211010}, + {0x18, 0x01a19040}, + {0x21, 0x01014020}), SND_HDA_PIN_QUIRK(0x10ec0662, 0x1028, "Dell", ALC662_FIXUP_DELL_MIC_NO_PRESENCE, {0x14, 0x01014010}, {0x18, 0x01a19020}, -- cgit v1.2.3-59-g8ed1b From ede34f397ddb063b145b9e7d79c6026f819ded13 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 15 Jul 2019 22:50:27 +0200 Subject: ALSA: seq: Break too long mutex context in the write loop The fix for the racy writes and ioctls to sequencer widened the application of client->ioctl_mutex to the whole write loop. Although it does unlock/relock for the lengthy operation like the event dup, the loop keeps the ioctl_mutex for the whole time in other situations. This may take quite long time if the user-space would give a huge buffer, and this is a likely cause of some weird behavior spotted by syzcaller fuzzer. This patch puts a simple workaround, just adding a mutex break in the loop when a large number of events have been processed. This shouldn't hit any performance drop because the threshold is set high enough for usual operations. Fixes: 7bd800915677 ("ALSA: seq: More protection for concurrent write and ioctl races") Reported-by: syzbot+97aae04ce27e39cbfca9@syzkaller.appspotmail.com Reported-by: syzbot+4c595632b98bb8ffcc66@syzkaller.appspotmail.com Cc: Signed-off-by: Takashi Iwai --- sound/core/seq/seq_clientmgr.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index a60e7a17f0b8..7737b2670064 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -1021,7 +1021,7 @@ static ssize_t snd_seq_write(struct file *file, const char __user *buf, { struct snd_seq_client *client = file->private_data; int written = 0, len; - int err; + int err, handled; struct snd_seq_event event; if (!(snd_seq_file_flags(file) & SNDRV_SEQ_LFLG_OUTPUT)) @@ -1034,6 +1034,8 @@ static ssize_t snd_seq_write(struct file *file, const char __user *buf, if (!client->accept_output || client->pool == NULL) return -ENXIO; + repeat: + handled = 0; /* allocate the pool now if the pool is not allocated yet */ mutex_lock(&client->ioctl_mutex); if (client->pool->size > 0 && !snd_seq_write_pool_allocated(client)) { @@ -1093,12 +1095,19 @@ static ssize_t snd_seq_write(struct file *file, const char __user *buf, 0, 0, &client->ioctl_mutex); if (err < 0) break; + handled++; __skip_event: /* Update pointers and counts */ count -= len; buf += len; written += len; + + /* let's have a coffee break if too many events are queued */ + if (++handled >= 200) { + mutex_unlock(&client->ioctl_mutex); + goto repeat; + } } out: -- cgit v1.2.3-59-g8ed1b From eb4177116bf568a413c544eca3f4446cb4064be9 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 15 Jul 2019 23:12:13 +0200 Subject: ALSA: hda/hdmi - Remove duplicated define INTEL_GET_VENDOR_VERB is defined twice identically. Let's remove a superfluous line. Fixes: b0d8bc50b9f2 ("ALSA: hda: hdmi - add Icelake support") Cc: Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_hdmi.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index 40323d91f9e4..1e6c489bca15 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -2416,7 +2416,6 @@ static void intel_haswell_fixup_connect_list(struct hda_codec *codec, snd_hda_override_conn_list(codec, nid, spec->num_cvts, spec->cvt_nids); } -#define INTEL_GET_VENDOR_VERB 0xf81 #define INTEL_GET_VENDOR_VERB 0xf81 #define INTEL_SET_VENDOR_VERB 0x781 #define INTEL_EN_DP12 0x02 /* enable DP 1.2 features */ -- cgit v1.2.3-59-g8ed1b From 3140aafb22edeab0cc41f15f53b12a118c0ac215 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 15 Jul 2019 23:14:53 +0200 Subject: ALSA: hda/hdmi - Fix i915 reverse port/pin mapping The recent fix for Icelake HDMI codec introduced the mapping from pin NID to the i915 gfx port number. However, it forgot the reverse mapping from the port number to the pin NID that is used in the ELD notifier callback. As a result, it's processed to a wrong widget and gives a warning like snd_hda_codec_hdmi hdaudioC0D2: HDMI: pin nid 5 not registered This patch corrects it with a proper reverse mapping function. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=204133 Fixes: b0d8bc50b9f2 ("ALSA: hda: hdmi - add Icelake support") Reviewed-by: Kai Vehmanen Cc: Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_hdmi.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index 1e6c489bca15..0b2a26e2c5f1 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -2524,18 +2524,32 @@ static int intel_pin2port(void *audio_ptr, int pin_nid) return -1; } +static int intel_port2pin(struct hda_codec *codec, int port) +{ + struct hdmi_spec *spec = codec->spec; + + if (!spec->port_num) { + /* we assume only from port-B to port-D */ + if (port < 1 || port > 3) + return 0; + /* intel port is 1-based */ + return port + intel_base_nid(codec) - 1; + } + + if (port < 1 || port > spec->port_num) + return 0; + return spec->port_map[port - 1]; +} + static void intel_pin_eld_notify(void *audio_ptr, int port, int pipe) { struct hda_codec *codec = audio_ptr; int pin_nid; int dev_id = pipe; - /* we assume only from port-B to port-D */ - if (port < 1 || port > 3) + pin_nid = intel_port2pin(codec, port); + if (!pin_nid) return; - - pin_nid = port + intel_base_nid(codec) - 1; /* intel port is 1-based */ - /* skip notification during system suspend (but not in runtime PM); * the state will be updated at resume */ -- cgit v1.2.3-59-g8ed1b From 4914da2fb0c89205790503f20dfdde854f3afdd8 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 16 Jul 2019 08:56:51 +0200 Subject: ALSA: hda - Don't resume forcibly i915 HDMI/DP codec We apply the codec resume forcibly at system resume callback for updating and syncing the jack detection state that may have changed during sleeping. This is, however, superfluous for the codec like Intel HDMI/DP, where the jack detection is managed via the audio component notification; i.e. the jack state change shall be reported sooner or later from the graphics side at mode change. This patch changes the codec resume callback to avoid the forcible resume conditionally with a new flag, codec->relaxed_resume, for reducing the resume time. The flag is set in the codec probe. Although this doesn't fix the entire bug mentioned in the bugzilla entry below, it's still a good optimization and some improvements are seen. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=201901 Cc: Signed-off-by: Takashi Iwai --- include/sound/hda_codec.h | 2 ++ sound/pci/hda/hda_codec.c | 8 ++++++-- sound/pci/hda/patch_hdmi.c | 6 +++++- 3 files changed, 13 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/include/sound/hda_codec.h b/include/sound/hda_codec.h index 8f46ff3449d5..871993696c5f 100644 --- a/include/sound/hda_codec.h +++ b/include/sound/hda_codec.h @@ -252,6 +252,8 @@ struct hda_codec { unsigned int auto_runtime_pm:1; /* enable automatic codec runtime pm */ unsigned int force_pin_prefix:1; /* Add location prefix */ unsigned int link_down_at_suspend:1; /* link down at runtime suspend */ + unsigned int relaxed_resume:1; /* don't resume forcibly for jack */ + #ifdef CONFIG_PM unsigned long power_on_acct; unsigned long power_off_acct; diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 5346631df1ec..e30e86ca6b72 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -2941,15 +2941,19 @@ static int hda_codec_runtime_resume(struct device *dev) #ifdef CONFIG_PM_SLEEP static int hda_codec_force_resume(struct device *dev) { + struct hda_codec *codec = dev_to_hda_codec(dev); + bool forced_resume = !codec->relaxed_resume; int ret; /* The get/put pair below enforces the runtime resume even if the * device hasn't been used at suspend time. This trick is needed to * update the jack state change during the sleep. */ - pm_runtime_get_noresume(dev); + if (forced_resume) + pm_runtime_get_noresume(dev); ret = pm_runtime_force_resume(dev); - pm_runtime_put(dev); + if (forced_resume) + pm_runtime_put(dev); return ret; } diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index 0b2a26e2c5f1..bea7b0961080 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -2292,8 +2292,10 @@ static void generic_hdmi_free(struct hda_codec *codec) struct hdmi_spec *spec = codec->spec; int pin_idx, pcm_idx; - if (codec_has_acomp(codec)) + if (codec_has_acomp(codec)) { snd_hdac_acomp_register_notifier(&codec->bus->core, NULL); + codec->relaxed_resume = 0; + } for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); @@ -2579,6 +2581,8 @@ static void register_i915_notifier(struct hda_codec *codec) spec->drm_audio_ops.pin_eld_notify = intel_pin_eld_notify; snd_hdac_acomp_register_notifier(&codec->bus->core, &spec->drm_audio_ops); + /* no need for forcible resume for jack check thanks to notifier */ + codec->relaxed_resume = 1; } /* setup_stream ops override for HSW+ */ -- cgit v1.2.3-59-g8ed1b