hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/pci/hotplug/pciehp_pci.c
....@@ -13,20 +13,28 @@
1313 *
1414 */
1515
16
-#include <linux/module.h>
16
+#define dev_fmt(fmt) "pciehp: " fmt
17
+
1718 #include <linux/kernel.h>
1819 #include <linux/types.h>
1920 #include <linux/pci.h>
2021 #include "../pci.h"
2122 #include "pciehp.h"
2223
23
-int pciehp_configure_device(struct slot *p_slot)
24
+/**
25
+ * pciehp_configure_device() - enumerate PCI devices below a hotplug bridge
26
+ * @ctrl: PCIe hotplug controller
27
+ *
28
+ * Enumerate PCI devices below a hotplug bridge and add them to the system.
29
+ * Return 0 on success, %-EEXIST if the devices are already enumerated or
30
+ * %-ENODEV if enumeration failed.
31
+ */
32
+int pciehp_configure_device(struct controller *ctrl)
2433 {
2534 struct pci_dev *dev;
26
- struct pci_dev *bridge = p_slot->ctrl->pcie->port;
35
+ struct pci_dev *bridge = ctrl->pcie->port;
2736 struct pci_bus *parent = bridge->subordinate;
2837 int num, ret = 0;
29
- struct controller *ctrl = p_slot->ctrl;
3038
3139 pci_lock_rescan_remove();
3240
....@@ -62,17 +70,28 @@
6270 return ret;
6371 }
6472
65
-void pciehp_unconfigure_device(struct slot *p_slot)
73
+/**
74
+ * pciehp_unconfigure_device() - remove PCI devices below a hotplug bridge
75
+ * @ctrl: PCIe hotplug controller
76
+ * @presence: whether the card is still present in the slot;
77
+ * true for safe removal via sysfs or an Attention Button press,
78
+ * false for surprise removal
79
+ *
80
+ * Unbind PCI devices below a hotplug bridge from their drivers and remove
81
+ * them from the system. Safely removed devices are quiesced. Surprise
82
+ * removed devices are marked as such to prevent further accesses.
83
+ */
84
+void pciehp_unconfigure_device(struct controller *ctrl, bool presence)
6685 {
67
- u8 presence = 0;
6886 struct pci_dev *dev, *temp;
69
- struct pci_bus *parent = p_slot->ctrl->pcie->port->subordinate;
87
+ struct pci_bus *parent = ctrl->pcie->port->subordinate;
7088 u16 command;
71
- struct controller *ctrl = p_slot->ctrl;
7289
7390 ctrl_dbg(ctrl, "%s: domain:bus:dev = %04x:%02x:00\n",
7491 __func__, pci_domain_nr(parent), parent->number);
75
- pciehp_get_adapter_status(p_slot, &presence);
92
+
93
+ if (!presence)
94
+ pci_walk_bus(parent, pci_dev_set_disconnected, NULL);
7695
7796 pci_lock_rescan_remove();
7897
....@@ -85,12 +104,6 @@
85104 list_for_each_entry_safe_reverse(dev, temp, &parent->devices,
86105 bus_list) {
87106 pci_dev_get(dev);
88
- if (!presence) {
89
- pci_dev_set_disconnected(dev, NULL);
90
- if (pci_has_subordinate(dev))
91
- pci_walk_bus(dev->subordinate,
92
- pci_dev_set_disconnected, NULL);
93
- }
94107 pci_stop_and_remove_bus_device(dev);
95108 /*
96109 * Ensure that no new Requests will be generated from