From 5502b3c7eee2c90a898b65bc6e6ead6fe13e17d2 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Sat, 26 Oct 2024 11:33:12 -0400 Subject: [PATCH] Fixes for 5.4 Signed-off-by: Sasha Levin --- ...b-avoid-division-by-zero-in-apply_co.patch | 49 +++++++++++ ...altek-update-default-depop-procedure.patch | 88 +++++++++++++++++++ queue-5.4/series | 2 + 3 files changed, 139 insertions(+) create mode 100644 queue-5.4/alsa-firewire-lib-avoid-division-by-zero-in-apply_co.patch create mode 100644 queue-5.4/alsa-hda-realtek-update-default-depop-procedure.patch diff --git a/queue-5.4/alsa-firewire-lib-avoid-division-by-zero-in-apply_co.patch b/queue-5.4/alsa-firewire-lib-avoid-division-by-zero-in-apply_co.patch new file mode 100644 index 00000000000..85cde0d6efc --- /dev/null +++ b/queue-5.4/alsa-firewire-lib-avoid-division-by-zero-in-apply_co.patch @@ -0,0 +1,49 @@ +From b30ed5d5b5933cf9b37aa4e216e754d5e46f8ee5 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 07e58dcad4afc..14a4905a777e1 100644 +--- a/sound/firewire/amdtp-stream.c ++++ b/sound/firewire/amdtp-stream.c +@@ -164,6 +164,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.4/alsa-hda-realtek-update-default-depop-procedure.patch b/queue-5.4/alsa-hda-realtek-update-default-depop-procedure.patch new file mode 100644 index 00000000000..db1e7f80e0d --- /dev/null +++ b/queue-5.4/alsa-hda-realtek-update-default-depop-procedure.patch @@ -0,0 +1,88 @@ +From 51832e5580b0481e5a07e99c5c445bbfdceaa420 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 f32c3c3752417..4ed7483087ee6 100644 +--- a/sound/pci/hda/patch_realtek.c ++++ b/sound/pci/hda/patch_realtek.c +@@ -3730,20 +3730,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) +@@ -3759,22 +3757,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.4/series b/queue-5.4/series index 81ea99df322..c6c38d90716 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -412,3 +412,5 @@ net-usb-usbnet-fix-name-regression.patch 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 +alsa-firewire-lib-avoid-division-by-zero-in-apply_co.patch +alsa-hda-realtek-update-default-depop-procedure.patch -- 2.47.2