From: Greg Kroah-Hartman Date: Mon, 28 Sep 2020 13:33:51 +0000 (+0200) Subject: 4.19-stable patches X-Git-Tag: v4.4.238~33 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=319f0ad124b522980a7342e41e08ebb6f7028ae5;p=thirdparty%2Fkernel%2Fstable-queue.git 4.19-stable patches added patches: alsa-hda-realtek-couldn-t-detect-mic-if-booting-with-headset-plugged.patch alsa-hda-realtek-enable-front-panel-headset-led-on-lenovo-thinkstation-p520.patch alsa-usb-audio-add-delay-quirk-for-h570e-usb-headsets.patch arch-x86-lib-usercopy_64.c-fix-__copy_user_flushcache-cache-writeback.patch lib-string.c-implement-stpcpy.patch x86-ioapic-unbreak-check_timer.patch --- diff --git a/queue-4.19/alsa-hda-realtek-couldn-t-detect-mic-if-booting-with-headset-plugged.patch b/queue-4.19/alsa-hda-realtek-couldn-t-detect-mic-if-booting-with-headset-plugged.patch new file mode 100644 index 00000000000..17a17995b2b --- /dev/null +++ b/queue-4.19/alsa-hda-realtek-couldn-t-detect-mic-if-booting-with-headset-plugged.patch @@ -0,0 +1,48 @@ +From 3f74249057827c5f6676c41c18f6be12ce1469ce Mon Sep 17 00:00:00 2001 +From: Hui Wang +Date: Mon, 14 Sep 2020 14:51:18 +0800 +Subject: ALSA: hda/realtek - Couldn't detect Mic if booting with headset plugged + +From: Hui Wang + +commit 3f74249057827c5f6676c41c18f6be12ce1469ce upstream. + +We found a Mic detection issue on many Lenovo laptops, those laptops +belong to differnt models and they have different audio design like +internal mic connects to the codec or PCH, they all have this problem, +the problem is if plugging a headset before powerup/reboot the +machine, after booting up, the headphone could be detected but Mic +couldn't. If we plug out and plug in the headset, both headphone and +Mic could be detected then. + +Through debugging we found the codec on those laptops are same, it is +alc257, and if we don't disable the 3k pulldown in alc256_shutup(), +the issue will be fixed. So far there is no pop noise or power +consumption regression on those laptops after this change. + +Cc: Kailang Yang +Cc: +Signed-off-by: Hui Wang +Link: https://lore.kernel.org/r/20200914065118.19238-1-hui.wang@canonical.com +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman + +--- + sound/pci/hda/patch_realtek.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +--- a/sound/pci/hda/patch_realtek.c ++++ b/sound/pci/hda/patch_realtek.c +@@ -3290,7 +3290,11 @@ static void alc256_shutup(struct hda_cod + + /* 3k pull low control for Headset jack. */ + /* NOTE: call this before clearing the pin, otherwise codec stalls */ +- alc_update_coef_idx(codec, 0x46, 0, 3 << 12); ++ /* If disable 3k pulldown control for alc257, the Mic detection will not work correctly ++ * when booting with headset plugged. So skip setting it for the codec alc257 ++ */ ++ if (codec->core.vendor_id != 0x10ec0257) ++ alc_update_coef_idx(codec, 0x46, 0, 3 << 12); + + if (!spec->no_shutup_pins) + snd_hda_codec_write(codec, hp_pin, 0, diff --git a/queue-4.19/alsa-hda-realtek-enable-front-panel-headset-led-on-lenovo-thinkstation-p520.patch b/queue-4.19/alsa-hda-realtek-enable-front-panel-headset-led-on-lenovo-thinkstation-p520.patch new file mode 100644 index 00000000000..f330ea61085 --- /dev/null +++ b/queue-4.19/alsa-hda-realtek-enable-front-panel-headset-led-on-lenovo-thinkstation-p520.patch @@ -0,0 +1,55 @@ +From f73bbf639b32acb6b409e188fdde5644b301978f Mon Sep 17 00:00:00 2001 +From: Kai-Heng Feng +Date: Mon, 14 Sep 2020 15:02:29 +0800 +Subject: ALSA: hda/realtek: Enable front panel headset LED on Lenovo ThinkStation P520 + +From: Kai-Heng Feng + +commit f73bbf639b32acb6b409e188fdde5644b301978f upstream. + +On Lenovo P520, the front panel headset LED isn't lit up right now. + +Realtek states that the LED needs to be enabled by ALC233's GPIO2, so +let's do it accordingly to light the LED up. + +Signed-off-by: Kai-Heng Feng +Acked-by: Hui Wang +Cc: +Link: https://lore.kernel.org/r/20200914070231.13192-1-kai.heng.feng@canonical.com +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman + +--- + sound/pci/hda/patch_realtek.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +--- a/sound/pci/hda/patch_realtek.c ++++ b/sound/pci/hda/patch_realtek.c +@@ -5616,6 +5616,7 @@ static void alc_fixup_thinkpad_acpi(stru + #include "hp_x360_helper.c" + + enum { ++ ALC269_FIXUP_GPIO2, + ALC269_FIXUP_SONY_VAIO, + ALC275_FIXUP_SONY_VAIO_GPIO2, + ALC269_FIXUP_DELL_M101Z, +@@ -5768,6 +5769,10 @@ enum { + }; + + static const struct hda_fixup alc269_fixups[] = { ++ [ALC269_FIXUP_GPIO2] = { ++ .type = HDA_FIXUP_FUNC, ++ .v.func = alc_fixup_gpio2, ++ }, + [ALC269_FIXUP_SONY_VAIO] = { + .type = HDA_FIXUP_PINCTLS, + .v.pins = (const struct hda_pintbl[]) { +@@ -6563,6 +6568,8 @@ static const struct hda_fixup alc269_fix + [ALC233_FIXUP_LENOVO_MULTI_CODECS] = { + .type = HDA_FIXUP_FUNC, + .v.func = alc233_alc662_fixup_lenovo_dual_codecs, ++ .chained = true, ++ .chain_id = ALC269_FIXUP_GPIO2 + }, + [ALC233_FIXUP_ACER_HEADSET_MIC] = { + .type = HDA_FIXUP_VERBS, diff --git a/queue-4.19/alsa-usb-audio-add-delay-quirk-for-h570e-usb-headsets.patch b/queue-4.19/alsa-usb-audio-add-delay-quirk-for-h570e-usb-headsets.patch new file mode 100644 index 00000000000..aee87e23ac2 --- /dev/null +++ b/queue-4.19/alsa-usb-audio-add-delay-quirk-for-h570e-usb-headsets.patch @@ -0,0 +1,40 @@ +From 315c7ad7a701baba28c628c4c5426b3d9617ceed Mon Sep 17 00:00:00 2001 +From: Joakim Tjernlund +Date: Thu, 10 Sep 2020 10:53:28 +0200 +Subject: ALSA: usb-audio: Add delay quirk for H570e USB headsets + +From: Joakim Tjernlund + +commit 315c7ad7a701baba28c628c4c5426b3d9617ceed upstream. + +Needs the same delay as H650e + +Signed-off-by: Joakim Tjernlund +Cc: stable@vger.kernel.org +Link: https://lore.kernel.org/r/20200910085328.19188-1-joakim.tjernlund@infinera.com +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman + +--- + sound/usb/quirks.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +--- a/sound/usb/quirks.c ++++ b/sound/usb/quirks.c +@@ -1338,12 +1338,13 @@ void snd_usb_ctl_msg_quirk(struct usb_de + && (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS) + msleep(20); + +- /* Zoom R16/24, Logitech H650e, Jabra 550a, Kingston HyperX needs a tiny +- * delay here, otherwise requests like get/set frequency return as +- * failed despite actually succeeding. ++ /* Zoom R16/24, Logitech H650e/H570e, Jabra 550a, Kingston HyperX ++ * needs a tiny delay here, otherwise requests like get/set ++ * frequency return as failed despite actually succeeding. + */ + if ((chip->usb_id == USB_ID(0x1686, 0x00dd) || + chip->usb_id == USB_ID(0x046d, 0x0a46) || ++ chip->usb_id == USB_ID(0x046d, 0x0a56) || + chip->usb_id == USB_ID(0x0b0e, 0x0349) || + chip->usb_id == USB_ID(0x0951, 0x16ad)) && + (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS) diff --git a/queue-4.19/arch-x86-lib-usercopy_64.c-fix-__copy_user_flushcache-cache-writeback.patch b/queue-4.19/arch-x86-lib-usercopy_64.c-fix-__copy_user_flushcache-cache-writeback.patch new file mode 100644 index 00000000000..26ac7d338b3 --- /dev/null +++ b/queue-4.19/arch-x86-lib-usercopy_64.c-fix-__copy_user_flushcache-cache-writeback.patch @@ -0,0 +1,49 @@ +From a1cd6c2ae47ee10ff21e62475685d5b399e2ed4a Mon Sep 17 00:00:00 2001 +From: Mikulas Patocka +Date: Fri, 25 Sep 2020 21:19:24 -0700 +Subject: arch/x86/lib/usercopy_64.c: fix __copy_user_flushcache() cache writeback + +From: Mikulas Patocka + +commit a1cd6c2ae47ee10ff21e62475685d5b399e2ed4a upstream. + +If we copy less than 8 bytes and if the destination crosses a cache +line, __copy_user_flushcache would invalidate only the first cache line. + +This patch makes it invalidate the second cache line as well. + +Fixes: 0aed55af88345b ("x86, uaccess: introduce copy_from_iter_flushcache for pmem / cache-bypass operations") +Signed-off-by: Mikulas Patocka +Signed-off-by: Andrew Morton +Reviewed-by: Dan Williams +Cc: Jan Kara +Cc: Jeff Moyer +Cc: Ingo Molnar +Cc: Christoph Hellwig +Cc: Toshi Kani +Cc: "H. Peter Anvin" +Cc: Al Viro +Cc: Thomas Gleixner +Cc: Matthew Wilcox +Cc: Ross Zwisler +Cc: Ingo Molnar +Cc: +Link: https://lkml.kernel.org/r/alpine.LRH.2.02.2009161451140.21915@file01.intranet.prod.int.rdu2.redhat.com +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + arch/x86/lib/usercopy_64.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/arch/x86/lib/usercopy_64.c ++++ b/arch/x86/lib/usercopy_64.c +@@ -139,7 +139,7 @@ long __copy_user_flushcache(void *dst, c + */ + if (size < 8) { + if (!IS_ALIGNED(dest, 4) || size != 4) +- clean_cache_range(dst, 1); ++ clean_cache_range(dst, size); + } else { + if (!IS_ALIGNED(dest, 8)) { + dest = ALIGN(dest, boot_cpu_data.x86_clflush_size); diff --git a/queue-4.19/lib-string.c-implement-stpcpy.patch b/queue-4.19/lib-string.c-implement-stpcpy.patch new file mode 100644 index 00000000000..cb9a61a5c0c --- /dev/null +++ b/queue-4.19/lib-string.c-implement-stpcpy.patch @@ -0,0 +1,123 @@ +From 1e1b6d63d6340764e00356873e5794225a2a03ea Mon Sep 17 00:00:00 2001 +From: Nick Desaulniers +Date: Fri, 25 Sep 2020 21:19:18 -0700 +Subject: lib/string.c: implement stpcpy + +From: Nick Desaulniers + +commit 1e1b6d63d6340764e00356873e5794225a2a03ea upstream. + +LLVM implemented a recent "libcall optimization" that lowers calls to +`sprintf(dest, "%s", str)` where the return value is used to +`stpcpy(dest, str) - dest`. + +This generally avoids the machinery involved in parsing format strings. +`stpcpy` is just like `strcpy` except it returns the pointer to the new +tail of `dest`. This optimization was introduced into clang-12. + +Implement this so that we don't observe linkage failures due to missing +symbol definitions for `stpcpy`. + +Similar to last year's fire drill with: commit 5f074f3e192f +("lib/string.c: implement a basic bcmp") + +The kernel is somewhere between a "freestanding" environment (no full +libc) and "hosted" environment (many symbols from libc exist with the +same type, function signature, and semantics). + +As Peter Anvin notes, there's not really a great way to inform the +compiler that you're targeting a freestanding environment but would like +to opt-in to some libcall optimizations (see pr/47280 below), rather +than opt-out. + +Arvind notes, -fno-builtin-* behaves slightly differently between GCC +and Clang, and Clang is missing many __builtin_* definitions, which I +consider a bug in Clang and am working on fixing. + +Masahiro summarizes the subtle distinction between compilers justly: + To prevent transformation from foo() into bar(), there are two ways in + Clang to do that; -fno-builtin-foo, and -fno-builtin-bar. There is + only one in GCC; -fno-buitin-foo. + +(Any difference in that behavior in Clang is likely a bug from a missing +__builtin_* definition.) + +Masahiro also notes: + We want to disable optimization from foo() to bar(), + but we may still benefit from the optimization from + foo() into something else. If GCC implements the same transform, we + would run into a problem because it is not -fno-builtin-bar, but + -fno-builtin-foo that disables that optimization. + + In this regard, -fno-builtin-foo would be more future-proof than + -fno-built-bar, but -fno-builtin-foo is still potentially overkill. We + may want to prevent calls from foo() being optimized into calls to + bar(), but we still may want other optimization on calls to foo(). + +It seems that compilers today don't quite provide the fine grain control +over which libcall optimizations pseudo-freestanding environments would +prefer. + +Finally, Kees notes that this interface is unsafe, so we should not +encourage its use. As such, I've removed the declaration from any +header, but it still needs to be exported to avoid linkage errors in +modules. + +Reported-by: Sami Tolvanen +Suggested-by: Andy Lavr +Suggested-by: Arvind Sankar +Suggested-by: Joe Perches +Suggested-by: Kees Cook +Suggested-by: Masahiro Yamada +Suggested-by: Rasmus Villemoes +Signed-off-by: Nick Desaulniers +Signed-off-by: Andrew Morton +Tested-by: Nathan Chancellor +Cc: +Link: https://lkml.kernel.org/r/20200914161643.938408-1-ndesaulniers@google.com +Link: https://bugs.llvm.org/show_bug.cgi?id=47162 +Link: https://bugs.llvm.org/show_bug.cgi?id=47280 +Link: https://github.com/ClangBuiltLinux/linux/issues/1126 +Link: https://man7.org/linux/man-pages/man3/stpcpy.3.html +Link: https://pubs.opengroup.org/onlinepubs/9699919799/functions/stpcpy.html +Link: https://reviews.llvm.org/D85963 +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + lib/string.c | 24 ++++++++++++++++++++++++ + 1 file changed, 24 insertions(+) + +--- a/lib/string.c ++++ b/lib/string.c +@@ -236,6 +236,30 @@ ssize_t strscpy(char *dest, const char * + EXPORT_SYMBOL(strscpy); + #endif + ++/** ++ * stpcpy - copy a string from src to dest returning a pointer to the new end ++ * of dest, including src's %NUL-terminator. May overrun dest. ++ * @dest: pointer to end of string being copied into. Must be large enough ++ * to receive copy. ++ * @src: pointer to the beginning of string being copied from. Must not overlap ++ * dest. ++ * ++ * stpcpy differs from strcpy in a key way: the return value is a pointer ++ * to the new %NUL-terminating character in @dest. (For strcpy, the return ++ * value is a pointer to the start of @dest). This interface is considered ++ * unsafe as it doesn't perform bounds checking of the inputs. As such it's ++ * not recommended for usage. Instead, its definition is provided in case ++ * the compiler lowers other libcalls to stpcpy. ++ */ ++char *stpcpy(char *__restrict__ dest, const char *__restrict__ src); ++char *stpcpy(char *__restrict__ dest, const char *__restrict__ src) ++{ ++ while ((*dest++ = *src++) != '\0') ++ /* nothing */; ++ return --dest; ++} ++EXPORT_SYMBOL(stpcpy); ++ + #ifndef __HAVE_ARCH_STRCAT + /** + * strcat - Append one %NUL-terminated string to another diff --git a/queue-4.19/series b/queue-4.19/series index da7a5bb3cfc..8fdfc47f844 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -9,6 +9,12 @@ m68k-q40-fix-info-leak-in-rtc_ioctl.patch gma-gma500-fix-a-memory-disclosure-bug-due-to-uninit.patch asoc-kirkwood-fix-irq-error-handling.patch media-smiapp-fix-error-handling-at-nvm-reading.patch +arch-x86-lib-usercopy_64.c-fix-__copy_user_flushcache-cache-writeback.patch +x86-ioapic-unbreak-check_timer.patch +alsa-usb-audio-add-delay-quirk-for-h570e-usb-headsets.patch +alsa-hda-realtek-couldn-t-detect-mic-if-booting-with-headset-plugged.patch +alsa-hda-realtek-enable-front-panel-headset-led-on-lenovo-thinkstation-p520.patch +lib-string.c-implement-stpcpy.patch leds-mlxreg-fix-possible-buffer-overflow.patch pm-devfreq-tegra30-fix-integer-overflow-on-cpu-s-fre.patch scsi-fnic-fix-use-after-free.patch diff --git a/queue-4.19/x86-ioapic-unbreak-check_timer.patch b/queue-4.19/x86-ioapic-unbreak-check_timer.patch new file mode 100644 index 00000000000..b7b04ee0df6 --- /dev/null +++ b/queue-4.19/x86-ioapic-unbreak-check_timer.patch @@ -0,0 +1,72 @@ +From 86a82ae0b5095ea24c55898a3f025791e7958b21 Mon Sep 17 00:00:00 2001 +From: Thomas Gleixner +Date: Wed, 23 Sep 2020 17:46:20 +0200 +Subject: x86/ioapic: Unbreak check_timer() + +From: Thomas Gleixner + +commit 86a82ae0b5095ea24c55898a3f025791e7958b21 upstream. + +Several people reported in the kernel bugzilla that between v4.12 and v4.13 +the magic which works around broken hardware and BIOSes to find the proper +timer interrupt delivery mode stopped working for some older affected +platforms which need to fall back to ExtINT delivery mode. + +The reason is that the core code changed to keep track of the masked and +disabled state of an interrupt line more accurately to avoid the expensive +hardware operations. + +That broke an assumption in i8259_make_irq() which invokes + + disable_irq_nosync(); + irq_set_chip_and_handler(); + enable_irq(); + +Up to v4.12 this worked because enable_irq() unconditionally unmasked the +interrupt line, but after the state tracking improvements this is not +longer the case because the IO/APIC uses lazy disabling. So the line state +is unmasked which means that enable_irq() does not call into the new irq +chip to unmask it. + +In principle this is a shortcoming of the core code, but it's more than +unclear whether the core code should try to reset state. At least this +cannot be done unconditionally as that would break other existing use cases +where the chip type is changed, e.g. when changing the trigger type, but +the callers expect the state to be preserved. + +As the way how check_timer() is switching the delivery modes is truly +unique, the obvious fix is to simply unmask the i8259 manually after +changing the mode to ExtINT delivery and switching the irq chip to the +legacy PIC. + +Note, that the fixes tag is not really precise, but identifies the commit +which broke the assumptions in the IO/APIC and i8259 code and that's the +kernel version to which this needs to be backported. + +Fixes: bf22ff45bed6 ("genirq: Avoid unnecessary low level irq function calls") +Reported-by: p_c_chan@hotmail.com +Reported-by: ecm4@mail.com +Reported-by: perdigao1@yahoo.com +Reported-by: matzes@users.sourceforge.net +Reported-by: rvelascog@gmail.com +Signed-off-by: Thomas Gleixner +Tested-by: p_c_chan@hotmail.com +Tested-by: matzes@users.sourceforge.net +Cc: stable@vger.kernel.org +Link: https://bugzilla.kernel.org/show_bug.cgi?id=197769 +Signed-off-by: Greg Kroah-Hartman + +--- + arch/x86/kernel/apic/io_apic.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/arch/x86/kernel/apic/io_apic.c ++++ b/arch/x86/kernel/apic/io_apic.c +@@ -2250,6 +2250,7 @@ static inline void __init check_timer(vo + legacy_pic->init(0); + legacy_pic->make_irq(0); + apic_write(APIC_LVT0, APIC_DM_EXTINT); ++ legacy_pic->unmask(0); + + unlock_ExtINT_logic(); +