From 70556c57f050298491b29447a9a0af477bab68d2 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Sat, 26 Oct 2024 11:33:10 -0400 Subject: [PATCH] Fixes for 5.15 Signed-off-by: Sasha Levin --- ...b-avoid-division-by-zero-in-apply_co.patch | 49 +++++++++++ ...altek-update-default-depop-procedure.patch | 88 +++++++++++++++++++ queue-5.15/series | 2 + 3 files changed, 139 insertions(+) create mode 100644 queue-5.15/alsa-firewire-lib-avoid-division-by-zero-in-apply_co.patch create mode 100644 queue-5.15/alsa-hda-realtek-update-default-depop-procedure.patch diff --git a/queue-5.15/alsa-firewire-lib-avoid-division-by-zero-in-apply_co.patch b/queue-5.15/alsa-firewire-lib-avoid-division-by-zero-in-apply_co.patch new file mode 100644 index 00000000000..ef9067edbf8 --- /dev/null +++ b/queue-5.15/alsa-firewire-lib-avoid-division-by-zero-in-apply_co.patch @@ -0,0 +1,49 @@ +From 5dd4b30236306d1e958d939fbecba8ea7e9638ec Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 18 Oct 2024 09:00:18 +0300 +Subject: ALSA: firewire-lib: Avoid division by zero in + apply_constraint_to_size() + +From: Andrey Shumilin + +[ Upstream commit 72cafe63b35d06b5cfbaf807e90ae657907858da ] + +The step variable is initialized to zero. It is changed in the loop, +but if it's not changed it will remain zero. Add a variable check +before the division. + +The observed behavior was introduced by commit 826b5de90c0b +("ALSA: firewire-lib: fix insufficient PCM rule for period/buffer size"), +and it is difficult to show that any of the interval parameters will +satisfy the snd_interval_test() condition with data from the +amdtp_rate_table[] table. + +Found by Linux Verification Center (linuxtesting.org) with SVACE. + +Fixes: 826b5de90c0b ("ALSA: firewire-lib: fix insufficient PCM rule for period/buffer size") +Signed-off-by: Andrey Shumilin +Reviewed-by: Takashi Sakamoto +Link: https://patch.msgid.link/20241018060018.1189537-1-shum.sdl@nppct.ru +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/firewire/amdtp-stream.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c +index 842fe127c5378..b5b3b4d177aaf 100644 +--- a/sound/firewire/amdtp-stream.c ++++ b/sound/firewire/amdtp-stream.c +@@ -172,6 +172,9 @@ static int apply_constraint_to_size(struct snd_pcm_hw_params *params, + step = max(step, amdtp_syt_intervals[i]); + } + ++ if (step == 0) ++ return -EINVAL; ++ + t.min = roundup(s->min, step); + t.max = rounddown(s->max, step); + t.integer = 1; +-- +2.43.0 + diff --git a/queue-5.15/alsa-hda-realtek-update-default-depop-procedure.patch b/queue-5.15/alsa-hda-realtek-update-default-depop-procedure.patch new file mode 100644 index 00000000000..9b0e32086eb --- /dev/null +++ b/queue-5.15/alsa-hda-realtek-update-default-depop-procedure.patch @@ -0,0 +1,88 @@ +From 5d9da6fdb6c7d9f9baa1fac1b8c05c4038e19cd0 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 23 Oct 2024 16:13:10 +0800 +Subject: ALSA: hda/realtek: Update default depop procedure + +From: Kailang Yang + +[ Upstream commit e3ea2757c312e51bbf62ebc434a6f7df1e3a201f ] + +Old procedure has a chance to meet Headphone no output. + +Fixes: c2d6af53a43f ("ALSA: hda/realtek - Add default procedure for suspend and resume state") +Signed-off-by: Kailang Yang +Link: https://lore.kernel.org/17b717a0a0b04a77aea4a8ec820cba13@realtek.com +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/pci/hda/patch_realtek.c | 38 ++++++++++++++++------------------- + 1 file changed, 17 insertions(+), 21 deletions(-) + +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c +index d76e0a2618afc..4ce2f042c04e7 100644 +--- a/sound/pci/hda/patch_realtek.c ++++ b/sound/pci/hda/patch_realtek.c +@@ -3848,20 +3848,18 @@ static void alc_default_init(struct hda_codec *codec) + + hp_pin_sense = snd_hda_jack_detect(codec, hp_pin); + +- if (hp_pin_sense) ++ if (hp_pin_sense) { + msleep(2); + +- snd_hda_codec_write(codec, hp_pin, 0, +- AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); +- +- if (hp_pin_sense) +- msleep(85); ++ snd_hda_codec_write(codec, hp_pin, 0, ++ AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); + +- snd_hda_codec_write(codec, hp_pin, 0, +- AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); ++ msleep(75); + +- if (hp_pin_sense) +- msleep(100); ++ snd_hda_codec_write(codec, hp_pin, 0, ++ AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); ++ msleep(75); ++ } + } + + static void alc_default_shutup(struct hda_codec *codec) +@@ -3877,22 +3875,20 @@ static void alc_default_shutup(struct hda_codec *codec) + + hp_pin_sense = snd_hda_jack_detect(codec, hp_pin); + +- if (hp_pin_sense) ++ if (hp_pin_sense) { + msleep(2); + +- snd_hda_codec_write(codec, hp_pin, 0, +- AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); +- +- if (hp_pin_sense) +- msleep(85); +- +- if (!spec->no_shutup_pins) + snd_hda_codec_write(codec, hp_pin, 0, +- AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0); ++ AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); + +- if (hp_pin_sense) +- msleep(100); ++ msleep(75); + ++ if (!spec->no_shutup_pins) ++ snd_hda_codec_write(codec, hp_pin, 0, ++ AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0); ++ ++ msleep(75); ++ } + alc_auto_setup_eapd(codec, false); + alc_shutup_pins(codec); + } +-- +2.43.0 + diff --git a/queue-5.15/series b/queue-5.15/series index 07e493aee75..903f8064422 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -61,3 +61,5 @@ net-sched-fix-use-after-free-in-taprio_change.patch r8169-avoid-unsolicited-interrupts.patch posix-clock-posix-clock-fix-unbalanced-locking-in-pc.patch bpf-perf-fix-perf_event_detach_bpf_prog-error-handli.patch +alsa-firewire-lib-avoid-division-by-zero-in-apply_co.patch +alsa-hda-realtek-update-default-depop-procedure.patch -- 2.47.2