Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2019-05-17 06:38:43 +0200
committerJiri Slaby <jslaby@suse.cz>2019-05-17 06:38:53 +0200
commit9d7b3e84ec255355e43c5f914b4fae7cf7e672cd (patch)
tree6e015ce85d077f32229a94522cd265ca78ef5a58
parentce4e2d0a22c6da2f4342ffa39fd51280a85e94a8 (diff)
PCI: hv: Add hv_pci_remove_slots() when we unload the driver
-rw-r--r--patches.kernel.org/5.1.3-041-PCI-hv-Add-hv_pci_remove_slots-when-we-unload-t.patch83
-rw-r--r--series.conf1
2 files changed, 84 insertions, 0 deletions
diff --git a/patches.kernel.org/5.1.3-041-PCI-hv-Add-hv_pci_remove_slots-when-we-unload-t.patch b/patches.kernel.org/5.1.3-041-PCI-hv-Add-hv_pci_remove_slots-when-we-unload-t.patch
new file mode 100644
index 0000000000..0aea3ff177
--- /dev/null
+++ b/patches.kernel.org/5.1.3-041-PCI-hv-Add-hv_pci_remove_slots-when-we-unload-t.patch
@@ -0,0 +1,83 @@
+From: Dexuan Cui <decui@microsoft.com>
+Date: Mon, 4 Mar 2019 21:34:48 +0000
+Subject: [PATCH] PCI: hv: Add hv_pci_remove_slots() when we unload the driver
+References: bnc#1012628
+Patch-mainline: 5.1.3
+Git-commit: 15becc2b56c6eda3d9bf5ae993bafd5661c1fad1
+
+commit 15becc2b56c6eda3d9bf5ae993bafd5661c1fad1 upstream.
+
+When we unload the pci-hyperv host controller driver, the host does not
+send us a PCI_EJECT message.
+
+In this case we also need to make sure the sysfs PCI slot directory is
+removed, otherwise a command on a slot file eg:
+
+"cat /sys/bus/pci/slots/2/address"
+
+will trigger a
+
+"BUG: unable to handle kernel paging request"
+
+and, if we unload/reload the driver several times we would end up with
+stale slot entries in PCI slot directories in /sys/bus/pci/slots/
+
+root@localhost:~# ls -rtl /sys/bus/pci/slots/
+total 0
+drwxr-xr-x 2 root root 0 Feb 7 10:49 2
+drwxr-xr-x 2 root root 0 Feb 7 10:49 2-1
+drwxr-xr-x 2 root root 0 Feb 7 10:51 2-2
+
+Add the missing code to remove the PCI slot and fix the current
+behaviour.
+
+Fixes: a15f2c08c708 ("PCI: hv: support reporting serial number as slot information")
+Signed-off-by: Dexuan Cui <decui@microsoft.com>
+[lorenzo.pieralisi@arm.com: reformatted the log]
+Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
+Reviewed-by: Stephen Hemminger <sthemmin@microsoft.com>
+Reviewed-by: Michael Kelley <mikelley@microsoft.com>
+Cc: stable@vger.kernel.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Jiri Slaby <jslaby@suse.cz>
+---
+ drivers/pci/controller/pci-hyperv.c | 16 ++++++++++++++++
+ 1 file changed, 16 insertions(+)
+
+diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c
+index 30f16b882746..b489412e3502 100644
+--- a/drivers/pci/controller/pci-hyperv.c
++++ b/drivers/pci/controller/pci-hyperv.c
+@@ -1486,6 +1486,21 @@ static void hv_pci_assign_slots(struct hv_pcibus_device *hbus)
+ }
+ }
+
++/*
++ * Remove entries in sysfs pci slot directory.
++ */
++static void hv_pci_remove_slots(struct hv_pcibus_device *hbus)
++{
++ struct hv_pci_dev *hpdev;
++
++ list_for_each_entry(hpdev, &hbus->children, list_entry) {
++ if (!hpdev->pci_slot)
++ continue;
++ pci_destroy_slot(hpdev->pci_slot);
++ hpdev->pci_slot = NULL;
++ }
++}
++
+ /**
+ * create_root_hv_pci_bus() - Expose a new root PCI bus
+ * @hbus: Root PCI bus, as understood by this driver
+@@ -2680,6 +2695,7 @@ static int hv_pci_remove(struct hv_device *hdev)
+ pci_lock_rescan_remove();
+ pci_stop_root_bus(hbus->pci_bus);
+ pci_remove_root_bus(hbus->pci_bus);
++ hv_pci_remove_slots(hbus);
+ pci_unlock_rescan_remove();
+ hbus->state = hv_pcibus_removed;
+ }
+--
+2.21.0
+
diff --git a/series.conf b/series.conf
index 251a9391c4..613da8bfee 100644
--- a/series.conf
+++ b/series.conf
@@ -126,6 +126,7 @@
patches.kernel.org/5.1.3-038-powerpc-booke64-set-RI-in-default-MSR.patch
patches.kernel.org/5.1.3-039-virtio_ring-Fix-potential-mem-leak-in-virtqueue.patch
patches.kernel.org/5.1.3-040-PCI-hv-Fix-a-memory-leak-in-hv_eject_device_wor.patch
+ patches.kernel.org/5.1.3-041-PCI-hv-Add-hv_pci_remove_slots-when-we-unload-t.patch
########################################################
# Build fixes that apply to the vanilla kernel too.