]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.19.35/pci-pciehp-ignore-link-state-changes-after-powering-off-a-slot.patch
Linux 4.19.35
[thirdparty/kernel/stable-queue.git] / releases / 4.19.35 / pci-pciehp-ignore-link-state-changes-after-powering-off-a-slot.patch
CommitLineData
d33cec38
GKH
1From 3943af9d01e94330d0cfac6fccdbc829aad50c92 Mon Sep 17 00:00:00 2001
2From: Sergey Miroshnichenko <s.miroshnichenko@yadro.com>
3Date: Tue, 12 Mar 2019 15:05:48 +0300
4Subject: PCI: pciehp: Ignore Link State Changes after powering off a slot
5
6From: Sergey Miroshnichenko <s.miroshnichenko@yadro.com>
7
8commit 3943af9d01e94330d0cfac6fccdbc829aad50c92 upstream.
9
10During a safe hot remove, the OS powers off the slot, which may cause a
11Data Link Layer State Changed event. The slot has already been set to
12OFF_STATE, so that event results in re-enabling the device, making it
13impossible to safely remove it.
14
15Clear out the Presence Detect Changed and Data Link Layer State Changed
16events when the disabled slot has settled down.
17
18It is still possible to re-enable the device if it remains in the slot
19after pressing the Attention Button by pressing it again.
20
21Fixes the problem that Micah reported below: an NVMe drive power button may
22not actually turn off the drive.
23
24Link: https://bugzilla.kernel.org/show_bug.cgi?id=203237
25Reported-by: Micah Parrish <micah.parrish@hpe.com>
26Tested-by: Micah Parrish <micah.parrish@hpe.com>
27Signed-off-by: Sergey Miroshnichenko <s.miroshnichenko@yadro.com>
28[bhelgaas: changelog, add bugzilla URL]
29Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
30Reviewed-by: Lukas Wunner <lukas@wunner.de>
31Cc: stable@vger.kernel.org # v4.19+
32Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
33
34---
35 drivers/pci/hotplug/pciehp_ctrl.c | 4 ++++
36 1 file changed, 4 insertions(+)
37
38--- a/drivers/pci/hotplug/pciehp_ctrl.c
39+++ b/drivers/pci/hotplug/pciehp_ctrl.c
40@@ -117,6 +117,10 @@ static void remove_board(struct slot *p_
41 * removed from the slot/adapter.
42 */
43 msleep(1000);
44+
45+ /* Ignore link or presence changes caused by power off */
46+ atomic_and(~(PCI_EXP_SLTSTA_DLLSC | PCI_EXP_SLTSTA_PDC),
47+ &ctrl->pending_events);
48 }
49
50 /* turn off Green LED */