From 17b91bb54efa72833a25a265a4b36c0cf14130b8 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 15 Jul 2018 12:10:38 +0200 Subject: [PATCH] 4.9-stable patches added patches: alsa-hda-handle-pm-failure-during-hotplug.patch fs-elf-make-sure-to-page-align-bss-in-load_elf_library.patch i2c-tegra-fix-nack-error-handling.patch iw_cxgb4-correctly-enforce-the-max-reg_mr-depth.patch tools-build-fix-escaping-in-.cmd-files-for-future-make.patch --- ...hda-handle-pm-failure-during-hotplug.patch | 103 ++++++++++++++++++ ...o-page-align-bss-in-load_elf_library.patch | 48 ++++++++ .../i2c-tegra-fix-nack-error-handling.patch | 72 ++++++++++++ ...rrectly-enforce-the-max-reg_mr-depth.patch | 35 ++++++ queue-4.9/series | 5 + ...caping-in-.cmd-files-for-future-make.patch | 60 ++++++++++ 6 files changed, 323 insertions(+) create mode 100644 queue-4.9/alsa-hda-handle-pm-failure-during-hotplug.patch create mode 100644 queue-4.9/fs-elf-make-sure-to-page-align-bss-in-load_elf_library.patch create mode 100644 queue-4.9/i2c-tegra-fix-nack-error-handling.patch create mode 100644 queue-4.9/iw_cxgb4-correctly-enforce-the-max-reg_mr-depth.patch create mode 100644 queue-4.9/tools-build-fix-escaping-in-.cmd-files-for-future-make.patch diff --git a/queue-4.9/alsa-hda-handle-pm-failure-during-hotplug.patch b/queue-4.9/alsa-hda-handle-pm-failure-during-hotplug.patch new file mode 100644 index 00000000000..77f30a1b873 --- /dev/null +++ b/queue-4.9/alsa-hda-handle-pm-failure-during-hotplug.patch @@ -0,0 +1,103 @@ +From aaa23f86001bdb82d2f937c5c7bce0a1e11a6c5b Mon Sep 17 00:00:00 2001 +From: Chris Wilson +Date: Wed, 27 Jun 2018 07:25:32 +0100 +Subject: ALSA: hda - Handle pm failure during hotplug + +From: Chris Wilson + +commit aaa23f86001bdb82d2f937c5c7bce0a1e11a6c5b upstream. + +Obtaining the runtime pm wakeref can fail, especially in a hotplug +scenario where i915.ko has been unloaded. If we do not catch the +failure, we end up with an unbalanced pm. + +v2 additions by tiwai: +hdmi_present_sense() checks the return value and handle only a +negative error case and bails out only if it's really still suspended. +Also, snd_hda_power_down() is called at the error path so that the +refcount is balanced. + +Along with it, the spec->pcm_lock is taken outside +hdmi_present_sense() in the caller side, so that it won't cause +deadlock at reentrace via runtime resume. + +v3 fix by tiwai: +Missing linux/pm_runtime.h is included. + +References: 222bde03881c ("ALSA: hda - Fix mutex deadlock at HDMI/DP hotplug") +Signed-off-by: Chris Wilson +Cc: +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman + +--- + sound/pci/hda/patch_hdmi.c | 19 ++++++++++++++----- + 1 file changed, 14 insertions(+), 5 deletions(-) + +--- a/sound/pci/hda/patch_hdmi.c ++++ b/sound/pci/hda/patch_hdmi.c +@@ -33,6 +33,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -731,8 +732,10 @@ static void check_presence_and_report(st + + if (pin_idx < 0) + return; ++ mutex_lock(&spec->pcm_lock); + if (hdmi_present_sense(get_pin(spec, pin_idx), 1)) + snd_hda_jack_report_sync(codec); ++ mutex_unlock(&spec->pcm_lock); + } + + static void jack_callback(struct hda_codec *codec, +@@ -1521,21 +1524,23 @@ static void sync_eld_via_acomp(struct hd + static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll) + { + struct hda_codec *codec = per_pin->codec; +- struct hdmi_spec *spec = codec->spec; + int ret; + + /* no temporary power up/down needed for component notifier */ +- if (!codec_has_acomp(codec)) +- snd_hda_power_up_pm(codec); ++ if (!codec_has_acomp(codec)) { ++ ret = snd_hda_power_up_pm(codec); ++ if (ret < 0 && pm_runtime_suspended(hda_codec_dev(codec))) { ++ snd_hda_power_down_pm(codec); ++ return false; ++ } ++ } + +- mutex_lock(&spec->pcm_lock); + if (codec_has_acomp(codec)) { + sync_eld_via_acomp(codec, per_pin); + ret = false; /* don't call snd_hda_jack_report_sync() */ + } else { + ret = hdmi_present_sense_via_verbs(per_pin, repoll); + } +- mutex_unlock(&spec->pcm_lock); + + if (!codec_has_acomp(codec)) + snd_hda_power_down_pm(codec); +@@ -1547,12 +1552,16 @@ static void hdmi_repoll_eld(struct work_ + { + struct hdmi_spec_per_pin *per_pin = + container_of(to_delayed_work(work), struct hdmi_spec_per_pin, work); ++ struct hda_codec *codec = per_pin->codec; ++ struct hdmi_spec *spec = codec->spec; + + if (per_pin->repoll_count++ > 6) + per_pin->repoll_count = 0; + ++ mutex_lock(&spec->pcm_lock); + if (hdmi_present_sense(per_pin, per_pin->repoll_count)) + snd_hda_jack_report_sync(per_pin->codec); ++ mutex_unlock(&spec->pcm_lock); + } + + static void intel_haswell_fixup_connect_list(struct hda_codec *codec, diff --git a/queue-4.9/fs-elf-make-sure-to-page-align-bss-in-load_elf_library.patch b/queue-4.9/fs-elf-make-sure-to-page-align-bss-in-load_elf_library.patch new file mode 100644 index 00000000000..fc3e96942df --- /dev/null +++ b/queue-4.9/fs-elf-make-sure-to-page-align-bss-in-load_elf_library.patch @@ -0,0 +1,48 @@ +From 24962af7e1041b7e50c1bc71d8d10dc678c556b5 Mon Sep 17 00:00:00 2001 +From: Oscar Salvador +Date: Fri, 13 Jul 2018 16:59:13 -0700 +Subject: fs, elf: make sure to page align bss in load_elf_library + +From: Oscar Salvador + +commit 24962af7e1041b7e50c1bc71d8d10dc678c556b5 upstream. + +The current code does not make sure to page align bss before calling +vm_brk(), and this can lead to a VM_BUG_ON() in __mm_populate() due to +the requested lenght not being correctly aligned. + +Let us make sure to align it properly. + +Kees: only applicable to CONFIG_USELIB kernels: 32-bit and configured +for libc5. + +Link: http://lkml.kernel.org/r/20180705145539.9627-1-osalvador@techadventures.net +Signed-off-by: Oscar Salvador +Reported-by: syzbot+5dcb560fe12aa5091c06@syzkaller.appspotmail.com +Tested-by: Tetsuo Handa +Acked-by: Kees Cook +Cc: Michal Hocko +Cc: Nicolas Pitre +Cc: +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + fs/binfmt_elf.c | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +--- a/fs/binfmt_elf.c ++++ b/fs/binfmt_elf.c +@@ -1217,9 +1217,8 @@ static int load_elf_library(struct file + goto out_free_ph; + } + +- len = ELF_PAGESTART(eppnt->p_filesz + eppnt->p_vaddr + +- ELF_MIN_ALIGN - 1); +- bss = eppnt->p_memsz + eppnt->p_vaddr; ++ len = ELF_PAGEALIGN(eppnt->p_filesz + eppnt->p_vaddr); ++ bss = ELF_PAGEALIGN(eppnt->p_memsz + eppnt->p_vaddr); + if (bss > len) { + error = vm_brk(len, bss - len); + if (error) diff --git a/queue-4.9/i2c-tegra-fix-nack-error-handling.patch b/queue-4.9/i2c-tegra-fix-nack-error-handling.patch new file mode 100644 index 00000000000..75c598e0a04 --- /dev/null +++ b/queue-4.9/i2c-tegra-fix-nack-error-handling.patch @@ -0,0 +1,72 @@ +From 54836e2d03e76d80aec3399368ffaf5b7caadd1b Mon Sep 17 00:00:00 2001 +From: Jon Hunter +Date: Tue, 3 Jul 2018 09:55:43 +0100 +Subject: i2c: tegra: Fix NACK error handling + +From: Jon Hunter + +commit 54836e2d03e76d80aec3399368ffaf5b7caadd1b upstream. + +On Tegra30 Cardhu the PCA9546 I2C mux is not ACK'ing I2C commands on +resume from suspend (which is caused by the reset signal for the I2C +mux not being configured correctl). However, this NACK is causing the +Tegra30 to hang on resuming from suspend which is not expected as we +detect NACKs and handle them. The hang observed appears to occur when +resetting the I2C controller to recover from the NACK. + +Commit 77821b4678f9 ("i2c: tegra: proper handling of error cases") added +additional error handling for some error cases including NACK, however, +it appears that this change conflicts with an early fix by commit +f70893d08338 ("i2c: tegra: Add delay before resetting the controller +after NACK"). After commit 77821b4678f9 was made we now disable 'packet +mode' before the delay from commit f70893d08338 happens. Testing shows +that moving the delay to before disabling 'packet mode' fixes the hang +observed on Tegra30. The delay was added to give the I2C controller +chance to send a stop condition and so it makes sense to move this to +before we disable packet mode. Please note that packet mode is always +enabled for Tegra. + +Fixes: 77821b4678f9 ("i2c: tegra: proper handling of error cases") +Signed-off-by: Jon Hunter +Acked-by: Thierry Reding +Signed-off-by: Wolfram Sang +Cc: stable@vger.kernel.org +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/i2c/busses/i2c-tegra.c | 17 ++++++++--------- + 1 file changed, 8 insertions(+), 9 deletions(-) + +--- a/drivers/i2c/busses/i2c-tegra.c ++++ b/drivers/i2c/busses/i2c-tegra.c +@@ -547,6 +547,14 @@ static int tegra_i2c_disable_packet_mode + { + u32 cnfg; + ++ /* ++ * NACK interrupt is generated before the I2C controller generates ++ * the STOP condition on the bus. So wait for 2 clock periods ++ * before disabling the controller so that the STOP condition has ++ * been delivered properly. ++ */ ++ udelay(DIV_ROUND_UP(2 * 1000000, i2c_dev->bus_clk_rate)); ++ + cnfg = i2c_readl(i2c_dev, I2C_CNFG); + if (cnfg & I2C_CNFG_PACKET_MODE_EN) + i2c_writel(i2c_dev, cnfg & ~I2C_CNFG_PACKET_MODE_EN, I2C_CNFG); +@@ -708,15 +716,6 @@ static int tegra_i2c_xfer_msg(struct teg + if (likely(i2c_dev->msg_err == I2C_ERR_NONE)) + return 0; + +- /* +- * NACK interrupt is generated before the I2C controller generates +- * the STOP condition on the bus. So wait for 2 clock periods +- * before resetting the controller so that the STOP condition has +- * been delivered properly. +- */ +- if (i2c_dev->msg_err == I2C_ERR_NO_ACK) +- udelay(DIV_ROUND_UP(2 * 1000000, i2c_dev->bus_clk_rate)); +- + tegra_i2c_init(i2c_dev); + if (i2c_dev->msg_err == I2C_ERR_NO_ACK) { + if (msg->flags & I2C_M_IGNORE_NAK) diff --git a/queue-4.9/iw_cxgb4-correctly-enforce-the-max-reg_mr-depth.patch b/queue-4.9/iw_cxgb4-correctly-enforce-the-max-reg_mr-depth.patch new file mode 100644 index 00000000000..b1795b9319b --- /dev/null +++ b/queue-4.9/iw_cxgb4-correctly-enforce-the-max-reg_mr-depth.patch @@ -0,0 +1,35 @@ +From 7b72717a20bba8bdd01b14c0460be7d15061cd6b Mon Sep 17 00:00:00 2001 +From: Steve Wise +Date: Thu, 21 Jun 2018 07:43:21 -0700 +Subject: iw_cxgb4: correctly enforce the max reg_mr depth + +From: Steve Wise + +commit 7b72717a20bba8bdd01b14c0460be7d15061cd6b upstream. + +The code was mistakenly using the length of the page array memory instead +of the depth of the page array. + +This would cause MR creation to fail in some cases. + +Fixes: 8376b86de7d3 ("iw_cxgb4: Support the new memory registration API") +Cc: stable@vger.kernel.org +Signed-off-by: Steve Wise +Signed-off-by: Jason Gunthorpe +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/infiniband/hw/cxgb4/mem.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/infiniband/hw/cxgb4/mem.c ++++ b/drivers/infiniband/hw/cxgb4/mem.c +@@ -724,7 +724,7 @@ static int c4iw_set_page(struct ib_mr *i + { + struct c4iw_mr *mhp = to_c4iw_mr(ibmr); + +- if (unlikely(mhp->mpl_len == mhp->max_mpl_len)) ++ if (unlikely(mhp->mpl_len == mhp->attr.pbl_size)) + return -ENOMEM; + + mhp->mpl[mhp->mpl_len++] = addr; diff --git a/queue-4.9/series b/queue-4.9/series index 414ce0e4efb..f9e1ebb0a6c 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -17,3 +17,8 @@ usb-quirks-add-delay-quirks-for-corsair-strafe.patch xhci-xhci-mem-off-by-one-in-xhci_stream_id_to_ring.patch hid-usbhid-add-quirk-for-innomedia-innex-genesis-atari-adapter.patch fix-up-non-directory-creation-in-sgid-directories.patch +alsa-hda-handle-pm-failure-during-hotplug.patch +fs-elf-make-sure-to-page-align-bss-in-load_elf_library.patch +tools-build-fix-escaping-in-.cmd-files-for-future-make.patch +i2c-tegra-fix-nack-error-handling.patch +iw_cxgb4-correctly-enforce-the-max-reg_mr-depth.patch diff --git a/queue-4.9/tools-build-fix-escaping-in-.cmd-files-for-future-make.patch b/queue-4.9/tools-build-fix-escaping-in-.cmd-files-for-future-make.patch new file mode 100644 index 00000000000..74c15d1e87a --- /dev/null +++ b/queue-4.9/tools-build-fix-escaping-in-.cmd-files-for-future-make.patch @@ -0,0 +1,60 @@ +From 9feeb638cde083c737e295c0547f1b4f28e99583 Mon Sep 17 00:00:00 2001 +From: Paul Menzel +Date: Tue, 5 Jun 2018 19:00:22 +0200 +Subject: tools build: fix # escaping in .cmd files for future Make + +From: Paul Menzel + +commit 9feeb638cde083c737e295c0547f1b4f28e99583 upstream. + +In 2016 GNU Make made a backwards incompatible change to the way '#' +characters were handled in Makefiles when used inside functions or +macros: + +http://git.savannah.gnu.org/cgit/make.git/commit/?id=c6966b323811c37acedff05b57 + +Due to this change, when attempting to run `make prepare' I get a +spurious make syntax error: + + /home/earnest/linux/tools/objtool/.fixdep.o.cmd:1: *** missing separator. Stop. + +When inspecting `.fixdep.o.cmd' it includes two lines which use +unescaped comment characters at the top: + + \# cannot find fixdep (/home/earnest/linux/tools/objtool//fixdep) + \# using basic dep data + +This is because `tools/build/Build.include' prints these '\#' +characters: + + printf '\# cannot find fixdep (%s)\n' $(fixdep) > $(dot-target).cmd; \ + printf '\# using basic dep data\n\n' >> $(dot-target).cmd; \ + +This completes commit 9564a8cf422d ("Kbuild: fix # escaping in .cmd files +for future Make"). + +Link: https://bugzilla.kernel.org/show_bug.cgi?id=197847 +Cc: Randy Dunlap +Cc: Rasmus Villemoes +Cc: stable@vger.kernel.org +Signed-off-by: Paul Menzel +Signed-off-by: Masahiro Yamada +Signed-off-by: Greg Kroah-Hartman + +--- + tools/build/Build.include | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/tools/build/Build.include ++++ b/tools/build/Build.include +@@ -63,8 +63,8 @@ dep-cmd = $(if $(wildcard $(fixdep)), + $(fixdep) $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp; \ + rm -f $(depfile); \ + mv -f $(dot-target).tmp $(dot-target).cmd, \ +- printf '\# cannot find fixdep (%s)\n' $(fixdep) > $(dot-target).cmd; \ +- printf '\# using basic dep data\n\n' >> $(dot-target).cmd; \ ++ printf '$(pound) cannot find fixdep (%s)\n' $(fixdep) > $(dot-target).cmd; \ ++ printf '$(pound) using basic dep data\n\n' >> $(dot-target).cmd; \ + cat $(depfile) >> $(dot-target).cmd; \ + printf '%s\n' 'cmd_$@ := $(make-cmd)' >> $(dot-target).cmd) + -- 2.47.3