]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.7-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 13 Jul 2020 15:37:36 +0000 (17:37 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 13 Jul 2020 15:37:36 +0000 (17:37 +0200)
added patches:
alsa-hda-let-hs_mic-be-picked-ahead-of-hp_mic.patch
alsa-hda-realtek-fix-lenovo-thinkpad-x1-carbon-7th-quirk-subdevice-id.patch
alsa-opl3-fix-infoleak-in-opl3.patch
alsa-usb-audio-add-implicit-feedback-quirk-for-rtx6001.patch
alsa-usb-audio-add-quirk-for-macrosilicon-ms2109.patch
ib-hfi1-do-not-destroy-hfi1_wq-when-the-device-is-shut-down.patch
ib-hfi1-do-not-destroy-link_wq-when-the-device-is-shut-down.patch

queue-5.7/alsa-hda-let-hs_mic-be-picked-ahead-of-hp_mic.patch [new file with mode: 0644]
queue-5.7/alsa-hda-realtek-fix-lenovo-thinkpad-x1-carbon-7th-quirk-subdevice-id.patch [new file with mode: 0644]
queue-5.7/alsa-opl3-fix-infoleak-in-opl3.patch [new file with mode: 0644]
queue-5.7/alsa-usb-audio-add-implicit-feedback-quirk-for-rtx6001.patch [new file with mode: 0644]
queue-5.7/alsa-usb-audio-add-quirk-for-macrosilicon-ms2109.patch [new file with mode: 0644]
queue-5.7/ib-hfi1-do-not-destroy-hfi1_wq-when-the-device-is-shut-down.patch [new file with mode: 0644]
queue-5.7/ib-hfi1-do-not-destroy-link_wq-when-the-device-is-shut-down.patch [new file with mode: 0644]

diff --git a/queue-5.7/alsa-hda-let-hs_mic-be-picked-ahead-of-hp_mic.patch b/queue-5.7/alsa-hda-let-hs_mic-be-picked-ahead-of-hp_mic.patch
new file mode 100644 (file)
index 0000000..07b3a0a
--- /dev/null
@@ -0,0 +1,59 @@
+From 6a6ca7881b1ab1c13fe0d70bae29211a65dd90de Mon Sep 17 00:00:00 2001
+From: Hui Wang <hui.wang@canonical.com>
+Date: Thu, 25 Jun 2020 16:38:33 +0800
+Subject: ALSA: hda - let hs_mic be picked ahead of hp_mic
+
+From: Hui Wang <hui.wang@canonical.com>
+
+commit 6a6ca7881b1ab1c13fe0d70bae29211a65dd90de upstream.
+
+We have a Dell AIO, there is neither internal speaker nor internal
+mic, only a multi-function audio jack on it.
+
+Users reported that after freshly installing the OS and plug
+a headset to the audio jack, the headset can't output sound. I
+reproduced this bug, at that moment, the Input Source is as below:
+Simple mixer control 'Input Source',0
+  Capabilities: cenum
+  Items: 'Headphone Mic' 'Headset Mic'
+  Item0: 'Headphone Mic'
+
+That is because the patch_realtek will set this audio jack as mic_in
+mode if Input Source's value is hp_mic.
+
+If it is not fresh installing, this issue will not happen since the
+systemd will run alsactl restore -f /var/lib/alsa/asound.state, this
+will set the 'Input Source' according to history value.
+
+If there is internal speaker or internal mic, this issue will not
+happen since there is valid sink/source in the pulseaudio, the PA will
+set the 'Input Source' according to active_port.
+
+To fix this issue, change the parser function to let the hs_mic be
+stored ahead of hp_mic.
+
+Cc: stable@vger.kernel.org
+Signed-off-by: Hui Wang <hui.wang@canonical.com>
+Link: https://lore.kernel.org/r/20200625083833.11264-1-hui.wang@canonical.com
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ sound/pci/hda/hda_auto_parser.c |    6 ++++++
+ 1 file changed, 6 insertions(+)
+
+--- a/sound/pci/hda/hda_auto_parser.c
++++ b/sound/pci/hda/hda_auto_parser.c
+@@ -72,6 +72,12 @@ static int compare_input_type(const void
+       if (a->type != b->type)
+               return (int)(a->type - b->type);
++      /* If has both hs_mic and hp_mic, pick the hs_mic ahead of hp_mic. */
++      if (a->is_headset_mic && b->is_headphone_mic)
++              return -1; /* don't swap */
++      else if (a->is_headphone_mic && b->is_headset_mic)
++              return 1; /* swap */
++
+       /* In case one has boost and the other one has not,
+          pick the one with boost first. */
+       return (int)(b->has_boost_on_pin - a->has_boost_on_pin);
diff --git a/queue-5.7/alsa-hda-realtek-fix-lenovo-thinkpad-x1-carbon-7th-quirk-subdevice-id.patch b/queue-5.7/alsa-hda-realtek-fix-lenovo-thinkpad-x1-carbon-7th-quirk-subdevice-id.patch
new file mode 100644 (file)
index 0000000..4fce16d
--- /dev/null
@@ -0,0 +1,58 @@
+From 9774dc218bb628974dcbc76412f970e9258e5f27 Mon Sep 17 00:00:00 2001
+From: Benjamin Poirier <benjamin.poirier@gmail.com>
+Date: Fri, 3 Jul 2020 17:00:04 +0900
+Subject: ALSA: hda/realtek - Fix Lenovo Thinkpad X1 Carbon 7th quirk subdevice id
+
+From: Benjamin Poirier <benjamin.poirier@gmail.com>
+
+commit 9774dc218bb628974dcbc76412f970e9258e5f27 upstream.
+
+1)
+In snd_hda_pick_fixup(), quirks are first matched by PCI SSID and then, if
+there is no match, by codec SSID. The Lenovo "ThinkPad X1 Carbon 7th" has
+an audio chip with PCI SSID 0x2292 and codec SSID 0x2293[1]. Therefore, fix
+the quirk meant for that device to match on .subdevice == 0x2292.
+
+2)
+The "Thinkpad X1 Yoga 7th" does not exist. The companion product to the
+Carbon 7th is the Yoga 4th. That device has an audio chip with PCI SSID
+0x2292 and codec SSID 0x2292[2]. Given the behavior of
+snd_hda_pick_fixup(), it is not possible to have a separate quirk for the
+Yoga based on SSID. Therefore, merge the quirks meant for the Carbon and
+Yoga. This preserves the current behavior for the Yoga.
+
+[1] This is the case on my own machine and can also be checked here
+https://github.com/linuxhw/LsPCI/tree/master/Notebook/Lenovo/ThinkPad
+https://gist.github.com/hamidzr/dd81e429dc86f4327ded7a2030e7d7d9#gistcomment-3225701
+[2]
+https://github.com/linuxhw/LsPCI/tree/master/Convertible/Lenovo/ThinkPad
+https://gist.github.com/hamidzr/dd81e429dc86f4327ded7a2030e7d7d9#gistcomment-3176355
+
+Fixes: d2cd795c4ece ("ALSA: hda - fixup for the bass speaker on Lenovo Carbon X1 7th gen")
+Fixes: 54a6a7dc107d ("ALSA: hda/realtek - Add quirk for the bass speaker on Lenovo Yoga X1 7th gen")
+Cc: Jaroslav Kysela <perex@perex.cz>
+Cc: Kailang Yang <kailang@realtek.com>
+Tested-by: Vincent Bernat <vincent@bernat.ch>
+Tested-by: Even Brenden <evenbrenden@gmail.com>
+Signed-off-by: Benjamin Poirier <benjamin.poirier@gmail.com>
+Cc: <stable@vger.kernel.org>
+Link: https://lore.kernel.org/r/20200703080005.8942-2-benjamin.poirier@gmail.com
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ sound/pci/hda/patch_realtek.c |    3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+--- a/sound/pci/hda/patch_realtek.c
++++ b/sound/pci/hda/patch_realtek.c
+@@ -7536,8 +7536,7 @@ static const struct snd_pci_quirk alc269
+       SND_PCI_QUIRK(0x17aa, 0x224c, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
+       SND_PCI_QUIRK(0x17aa, 0x224d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
+       SND_PCI_QUIRK(0x17aa, 0x225d, "Thinkpad T480", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
+-      SND_PCI_QUIRK(0x17aa, 0x2292, "Thinkpad X1 Yoga 7th", ALC285_FIXUP_THINKPAD_HEADSET_JACK),
+-      SND_PCI_QUIRK(0x17aa, 0x2293, "Thinkpad X1 Carbon 7th", ALC285_FIXUP_THINKPAD_HEADSET_JACK),
++      SND_PCI_QUIRK(0x17aa, 0x2292, "Thinkpad X1 Carbon 7th", ALC285_FIXUP_THINKPAD_HEADSET_JACK),
+       SND_PCI_QUIRK(0x17aa, 0x22be, "Thinkpad X1 Carbon 8th", ALC285_FIXUP_THINKPAD_HEADSET_JACK),
+       SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
+       SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
diff --git a/queue-5.7/alsa-opl3-fix-infoleak-in-opl3.patch b/queue-5.7/alsa-opl3-fix-infoleak-in-opl3.patch
new file mode 100644 (file)
index 0000000..6d65434
--- /dev/null
@@ -0,0 +1,37 @@
+From ad155712bb1ea2151944cf06a0e08c315c70c1e3 Mon Sep 17 00:00:00 2001
+From: xidongwang <wangxidong_97@163.com>
+Date: Sun, 5 Jul 2020 20:27:38 -0700
+Subject: ALSA: opl3: fix infoleak in opl3
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: xidongwang <wangxidong_97@163.com>
+
+commit ad155712bb1ea2151944cf06a0e08c315c70c1e3 upstream.
+
+The stack object “info” in snd_opl3_ioctl() has a leaking problem.
+It has 2 padding bytes which are not initialized and leaked via
+“copy_to_user”.
+
+Signed-off-by: xidongwang <wangxidong_97@163.com>
+Cc: <stable@vger.kernel.org>
+Link: https://lore.kernel.org/r/1594006058-30362-1-git-send-email-wangxidong_97@163.com
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ sound/drivers/opl3/opl3_synth.c |    2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/sound/drivers/opl3/opl3_synth.c
++++ b/sound/drivers/opl3/opl3_synth.c
+@@ -91,6 +91,8 @@ int snd_opl3_ioctl(struct snd_hwdep * hw
+               {
+                       struct snd_dm_fm_info info;
++                      memset(&info, 0, sizeof(info));
++
+                       info.fm_mode = opl3->fm_mode;
+                       info.rhythm = opl3->rhythm;
+                       if (copy_to_user(argp, &info, sizeof(struct snd_dm_fm_info)))
diff --git a/queue-5.7/alsa-usb-audio-add-implicit-feedback-quirk-for-rtx6001.patch b/queue-5.7/alsa-usb-audio-add-implicit-feedback-quirk-for-rtx6001.patch
new file mode 100644 (file)
index 0000000..912f70a
--- /dev/null
@@ -0,0 +1,33 @@
+From b6a1e78b96a5d7f312f08b3a470eb911ab5feec0 Mon Sep 17 00:00:00 2001
+From: Pavel Hofman <pavel.hofman@ivitera.com>
+Date: Fri, 3 Jul 2020 12:04:33 +0200
+Subject: ALSA: usb-audio: Add implicit feedback quirk for RTX6001
+
+From: Pavel Hofman <pavel.hofman@ivitera.com>
+
+commit b6a1e78b96a5d7f312f08b3a470eb911ab5feec0 upstream.
+
+USB Audio analyzer RTX6001 uses the same implicit feedback quirk
+as other XMOS-based devices.
+
+Signed-off-by: Pavel Hofman <pavel.hofman@ivitera.com>
+Tested-by: Pavel Hofman <pavel.hofman@ivitera.com>
+Cc: <stable@vger.kernel.org>
+Link: https://lore.kernel.org/r/822f0f20-1886-6884-a6b2-d11c685cbafa@ivitera.com
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ sound/usb/pcm.c |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/sound/usb/pcm.c
++++ b/sound/usb/pcm.c
+@@ -368,6 +368,7 @@ static int set_sync_ep_implicit_fb_quirk
+               goto add_sync_ep_from_ifnum;
+       case USB_ID(0x07fd, 0x0008): /* MOTU M Series */
+       case USB_ID(0x31e9, 0x0002): /* Solid State Logic SSL2+ */
++      case USB_ID(0x0d9a, 0x00df): /* RTX6001 */
+               ep = 0x81;
+               ifnum = 2;
+               goto add_sync_ep_from_ifnum;
diff --git a/queue-5.7/alsa-usb-audio-add-quirk-for-macrosilicon-ms2109.patch b/queue-5.7/alsa-usb-audio-add-quirk-for-macrosilicon-ms2109.patch
new file mode 100644 (file)
index 0000000..c80c12b
--- /dev/null
@@ -0,0 +1,81 @@
+From e337bf19f6af38d5c3fa6d06cd594e0f890ca1ac Mon Sep 17 00:00:00 2001
+From: Hector Martin <marcan@marcan.st>
+Date: Thu, 2 Jul 2020 16:14:33 +0900
+Subject: ALSA: usb-audio: add quirk for MacroSilicon MS2109
+
+From: Hector Martin <marcan@marcan.st>
+
+commit e337bf19f6af38d5c3fa6d06cd594e0f890ca1ac upstream.
+
+These devices claim to be 96kHz mono, but actually are 48kHz stereo with
+swapped channels and unaligned transfers.
+
+Cc: stable@vger.kernel.org
+Signed-off-by: Hector Martin <marcan@marcan.st>
+Link: https://lore.kernel.org/r/20200702071433.237843-1-marcan@marcan.st
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ sound/usb/quirks-table.h |   52 +++++++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 52 insertions(+)
+
+--- a/sound/usb/quirks-table.h
++++ b/sound/usb/quirks-table.h
+@@ -3611,4 +3611,56 @@ ALC1220_VB_DESKTOP(0x26ce, 0x0a01), /* A
+       }
+ },
++/*
++ * MacroSilicon MS2109 based HDMI capture cards
++ *
++ * These claim 96kHz 1ch in the descriptors, but are actually 48kHz 2ch.
++ * They also need QUIRK_AUDIO_ALIGN_TRANSFER, which makes one wonder if
++ * they pretend to be 96kHz mono as a workaround for stereo being broken
++ * by that...
++ *
++ * They also have swapped L-R channels, but that's for userspace to deal
++ * with.
++ */
++{
++      USB_DEVICE(0x534d, 0x2109),
++      .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
++              .vendor_name = "MacroSilicon",
++              .product_name = "MS2109",
++              .ifnum = QUIRK_ANY_INTERFACE,
++              .type = QUIRK_COMPOSITE,
++              .data = &(const struct snd_usb_audio_quirk[]) {
++                      {
++                              .ifnum = 2,
++                              .type = QUIRK_AUDIO_ALIGN_TRANSFER,
++                      },
++                      {
++                              .ifnum = 2,
++                              .type = QUIRK_AUDIO_STANDARD_MIXER,
++                      },
++                      {
++                              .ifnum = 3,
++                              .type = QUIRK_AUDIO_FIXED_ENDPOINT,
++                              .data = &(const struct audioformat) {
++                                      .formats = SNDRV_PCM_FMTBIT_S16_LE,
++                                      .channels = 2,
++                                      .iface = 3,
++                                      .altsetting = 1,
++                                      .altset_idx = 1,
++                                      .attributes = 0,
++                                      .endpoint = 0x82,
++                                      .ep_attr = USB_ENDPOINT_XFER_ISOC |
++                                              USB_ENDPOINT_SYNC_ASYNC,
++                                      .rates = SNDRV_PCM_RATE_CONTINUOUS,
++                                      .rate_min = 48000,
++                                      .rate_max = 48000,
++                              }
++                      },
++                      {
++                              .ifnum = -1
++                      }
++              }
++      }
++},
++
+ #undef USB_DEVICE_VENDOR_SPEC
diff --git a/queue-5.7/ib-hfi1-do-not-destroy-hfi1_wq-when-the-device-is-shut-down.patch b/queue-5.7/ib-hfi1-do-not-destroy-hfi1_wq-when-the-device-is-shut-down.patch
new file mode 100644 (file)
index 0000000..b13414d
--- /dev/null
@@ -0,0 +1,158 @@
+From 28b70cd9236563e1a88a6094673fef3c08db0d51 Mon Sep 17 00:00:00 2001
+From: Kaike Wan <kaike.wan@intel.com>
+Date: Tue, 23 Jun 2020 16:40:47 -0400
+Subject: IB/hfi1: Do not destroy hfi1_wq when the device is shut down
+
+From: Kaike Wan <kaike.wan@intel.com>
+
+commit 28b70cd9236563e1a88a6094673fef3c08db0d51 upstream.
+
+The workqueue hfi1_wq is destroyed in function shutdown_device(), which is
+called by either shutdown_one() or remove_one(). The function
+shutdown_one() is called when the kernel is rebooted while remove_one() is
+called when the hfi1 driver is unloaded. When the kernel is rebooted,
+hfi1_wq is destroyed while all qps are still active, leading to a kernel
+crash:
+
+  BUG: unable to handle kernel NULL pointer dereference at 0000000000000102
+  IP: [<ffffffff94cb7b02>] __queue_work+0x32/0x3e0
+  PGD 0
+  Oops: 0000 [#1] SMP
+  Modules linked in: dm_round_robin nvme_rdma(OE) nvme_fabrics(OE) nvme_core(OE) ib_isert iscsi_target_mod target_core_mod ib_ucm mlx4_ib iTCO_wdt iTCO_vendor_support mxm_wmi sb_edac intel_powerclamp coretemp intel_rapl iosf_mbi kvm rpcrdma sunrpc irqbypass crc32_pclmul ghash_clmulni_intel rdma_ucm aesni_intel ib_uverbs lrw gf128mul opa_vnic glue_helper ablk_helper ib_iser cryptd ib_umad rdma_cm iw_cm ses enclosure libiscsi scsi_transport_sas pcspkr joydev ib_ipoib(OE) scsi_transport_iscsi ib_cm sg ipmi_ssif mei_me lpc_ich i2c_i801 mei ioatdma ipmi_si dm_multipath ipmi_devintf ipmi_msghandler wmi acpi_pad acpi_power_meter hangcheck_timer ip_tables ext4 mbcache jbd2 mlx4_en sd_mod crc_t10dif crct10dif_generic mgag200 drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ttm hfi1(OE)
+  crct10dif_pclmul crct10dif_common crc32c_intel drm ahci mlx4_core libahci rdmavt(OE) igb megaraid_sas ib_core libata drm_panel_orientation_quirks ptp pps_core devlink dca i2c_algo_bit dm_mirror dm_region_hash dm_log dm_mod
+  CPU: 19 PID: 0 Comm: swapper/19 Kdump: loaded Tainted: G OE ------------ 3.10.0-957.el7.x86_64 #1
+  Hardware name: Phegda X2226A/S2600CW, BIOS SE5C610.86B.01.01.0024.021320181901 02/13/2018
+  task: ffff8a799ba0d140 ti: ffff8a799bad8000 task.ti: ffff8a799bad8000
+  RIP: 0010:[<ffffffff94cb7b02>] [<ffffffff94cb7b02>] __queue_work+0x32/0x3e0
+  RSP: 0018:ffff8a90dde43d80 EFLAGS: 00010046
+  RAX: 0000000000000082 RBX: 0000000000000086 RCX: 0000000000000000
+  RDX: ffff8a90b924fcb8 RSI: 0000000000000000 RDI: 000000000000001b
+  RBP: ffff8a90dde43db8 R08: ffff8a799ba0d6d8 R09: ffff8a90dde53900
+  R10: 0000000000000002 R11: ffff8a90dde43de8 R12: ffff8a90b924fcb8
+  R13: 000000000000001b R14: 0000000000000000 R15: ffff8a90d2890000
+  FS: 0000000000000000(0000) GS:ffff8a90dde40000(0000) knlGS:0000000000000000
+  CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
+  CR2: 0000000000000102 CR3: 0000001a70410000 CR4: 00000000001607e0
+  Call Trace:
+  [<ffffffff94cb8105>] queue_work_on+0x45/0x50
+  [<ffffffffc03f781e>] _hfi1_schedule_send+0x6e/0xc0 [hfi1]
+  [<ffffffffc03f78a2>] hfi1_schedule_send+0x32/0x70 [hfi1]
+  [<ffffffffc02cf2d9>] rvt_rc_timeout+0xe9/0x130 [rdmavt]
+  [<ffffffff94ce563a>] ? trigger_load_balance+0x6a/0x280
+  [<ffffffffc02cf1f0>] ? rvt_free_qpn+0x40/0x40 [rdmavt]
+  [<ffffffff94ca7f58>] call_timer_fn+0x38/0x110
+  [<ffffffffc02cf1f0>] ? rvt_free_qpn+0x40/0x40 [rdmavt]
+  [<ffffffff94caa3bd>] run_timer_softirq+0x24d/0x300
+  [<ffffffff94ca0f05>] __do_softirq+0xf5/0x280
+  [<ffffffff9537832c>] call_softirq+0x1c/0x30
+  [<ffffffff94c2e675>] do_softirq+0x65/0xa0
+  [<ffffffff94ca1285>] irq_exit+0x105/0x110
+  [<ffffffff953796c8>] smp_apic_timer_interrupt+0x48/0x60
+  [<ffffffff95375df2>] apic_timer_interrupt+0x162/0x170
+  <EOI>
+  [<ffffffff951adfb7>] ? cpuidle_enter_state+0x57/0xd0
+  [<ffffffff951ae10e>] cpuidle_idle_call+0xde/0x230
+  [<ffffffff94c366de>] arch_cpu_idle+0xe/0xc0
+  [<ffffffff94cfc3ba>] cpu_startup_entry+0x14a/0x1e0
+  [<ffffffff94c57db7>] start_secondary+0x1f7/0x270
+  [<ffffffff94c000d5>] start_cpu+0x5/0x14
+
+The solution is to destroy the workqueue only when the hfi1 driver is
+unloaded, not when the device is shut down. In addition, when the device
+is shut down, no more work should be scheduled on the workqueues and the
+workqueues are flushed.
+
+Fixes: 8d3e71136a08 ("IB/{hfi1, qib}: Add handling of kernel restart")
+Link: https://lore.kernel.org/r/20200623204047.107638.77646.stgit@awfm-01.aw.intel.com
+Cc: <stable@vger.kernel.org>
+Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
+Signed-off-by: Kaike Wan <kaike.wan@intel.com>
+Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
+Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/infiniband/hw/hfi1/init.c     |   27 +++++++++++++++++++++++----
+ drivers/infiniband/hw/hfi1/qp.c       |    5 ++++-
+ drivers/infiniband/hw/hfi1/tid_rdma.c |    5 ++++-
+ 3 files changed, 31 insertions(+), 6 deletions(-)
+
+--- a/drivers/infiniband/hw/hfi1/init.c
++++ b/drivers/infiniband/hw/hfi1/init.c
+@@ -829,6 +829,25 @@ wq_error:
+ }
+ /**
++ * destroy_workqueues - destroy per port workqueues
++ * @dd: the hfi1_ib device
++ */
++static void destroy_workqueues(struct hfi1_devdata *dd)
++{
++      int pidx;
++      struct hfi1_pportdata *ppd;
++
++      for (pidx = 0; pidx < dd->num_pports; ++pidx) {
++              ppd = dd->pport + pidx;
++
++              if (ppd->hfi1_wq) {
++                      destroy_workqueue(ppd->hfi1_wq);
++                      ppd->hfi1_wq = NULL;
++              }
++      }
++}
++
++/**
+  * enable_general_intr() - Enable the IRQs that will be handled by the
+  * general interrupt handler.
+  * @dd: valid devdata
+@@ -1102,11 +1121,10 @@ static void shutdown_device(struct hfi1_
+                */
+               hfi1_quiet_serdes(ppd);
+-              if (ppd->hfi1_wq) {
+-                      destroy_workqueue(ppd->hfi1_wq);
+-                      ppd->hfi1_wq = NULL;
+-              }
++              if (ppd->hfi1_wq)
++                      flush_workqueue(ppd->hfi1_wq);
+               if (ppd->link_wq) {
++                      flush_workqueue(ppd->link_wq);
+                       destroy_workqueue(ppd->link_wq);
+                       ppd->link_wq = NULL;
+               }
+@@ -1757,6 +1775,7 @@ static void remove_one(struct pci_dev *p
+        * clear dma engines, etc.
+        */
+       shutdown_device(dd);
++      destroy_workqueues(dd);
+       stop_timers(dd);
+--- a/drivers/infiniband/hw/hfi1/qp.c
++++ b/drivers/infiniband/hw/hfi1/qp.c
+@@ -381,7 +381,10 @@ bool _hfi1_schedule_send(struct rvt_qp *
+       struct hfi1_ibport *ibp =
+               to_iport(qp->ibqp.device, qp->port_num);
+       struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
+-      struct hfi1_devdata *dd = dd_from_ibdev(qp->ibqp.device);
++      struct hfi1_devdata *dd = ppd->dd;
++
++      if (dd->flags & HFI1_SHUTDOWN)
++              return true;
+       return iowait_schedule(&priv->s_iowait, ppd->hfi1_wq,
+                              priv->s_sde ?
+--- a/drivers/infiniband/hw/hfi1/tid_rdma.c
++++ b/drivers/infiniband/hw/hfi1/tid_rdma.c
+@@ -5406,7 +5406,10 @@ static bool _hfi1_schedule_tid_send(stru
+       struct hfi1_ibport *ibp =
+               to_iport(qp->ibqp.device, qp->port_num);
+       struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
+-      struct hfi1_devdata *dd = dd_from_ibdev(qp->ibqp.device);
++      struct hfi1_devdata *dd = ppd->dd;
++
++      if ((dd->flags & HFI1_SHUTDOWN))
++              return true;
+       return iowait_tid_schedule(&priv->s_iowait, ppd->hfi1_wq,
+                                  priv->s_sde ?
diff --git a/queue-5.7/ib-hfi1-do-not-destroy-link_wq-when-the-device-is-shut-down.patch b/queue-5.7/ib-hfi1-do-not-destroy-link_wq-when-the-device-is-shut-down.patch
new file mode 100644 (file)
index 0000000..64eea24
--- /dev/null
@@ -0,0 +1,54 @@
+From 2315ec12ee8e8257bb335654c62e0cae71dc278d Mon Sep 17 00:00:00 2001
+From: Kaike Wan <kaike.wan@intel.com>
+Date: Tue, 23 Jun 2020 16:40:53 -0400
+Subject: IB/hfi1: Do not destroy link_wq when the device is shut down
+
+From: Kaike Wan <kaike.wan@intel.com>
+
+commit 2315ec12ee8e8257bb335654c62e0cae71dc278d upstream.
+
+The workqueue link_wq should only be destroyed when the hfi1 driver is
+unloaded, not when the device is shut down.
+
+Fixes: 71d47008ca1b ("IB/hfi1: Create workqueue for link events")
+Link: https://lore.kernel.org/r/20200623204053.107638.70315.stgit@awfm-01.aw.intel.com
+Cc: <stable@vger.kernel.org>
+Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
+Signed-off-by: Kaike Wan <kaike.wan@intel.com>
+Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
+Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/infiniband/hw/hfi1/init.c |   10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+--- a/drivers/infiniband/hw/hfi1/init.c
++++ b/drivers/infiniband/hw/hfi1/init.c
+@@ -844,6 +844,10 @@ static void destroy_workqueues(struct hf
+                       destroy_workqueue(ppd->hfi1_wq);
+                       ppd->hfi1_wq = NULL;
+               }
++              if (ppd->link_wq) {
++                      destroy_workqueue(ppd->link_wq);
++                      ppd->link_wq = NULL;
++              }
+       }
+ }
+@@ -1120,14 +1124,10 @@ static void shutdown_device(struct hfi1_
+                * We can't count on interrupts since we are stopping.
+                */
+               hfi1_quiet_serdes(ppd);
+-
+               if (ppd->hfi1_wq)
+                       flush_workqueue(ppd->hfi1_wq);
+-              if (ppd->link_wq) {
++              if (ppd->link_wq)
+                       flush_workqueue(ppd->link_wq);
+-                      destroy_workqueue(ppd->link_wq);
+-                      ppd->link_wq = NULL;
+-              }
+       }
+       sdma_exit(dd);
+ }