.. | .. |
---|
13 | 13 | * |
---|
14 | 14 | */ |
---|
15 | 15 | |
---|
16 | | -#include <linux/module.h> |
---|
| 16 | +#define dev_fmt(fmt) "pciehp: " fmt |
---|
| 17 | + |
---|
17 | 18 | #include <linux/kernel.h> |
---|
18 | 19 | #include <linux/types.h> |
---|
19 | 20 | #include <linux/pci.h> |
---|
20 | 21 | #include "../pci.h" |
---|
21 | 22 | #include "pciehp.h" |
---|
22 | 23 | |
---|
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) |
---|
24 | 33 | { |
---|
25 | 34 | struct pci_dev *dev; |
---|
26 | | - struct pci_dev *bridge = p_slot->ctrl->pcie->port; |
---|
| 35 | + struct pci_dev *bridge = ctrl->pcie->port; |
---|
27 | 36 | struct pci_bus *parent = bridge->subordinate; |
---|
28 | 37 | int num, ret = 0; |
---|
29 | | - struct controller *ctrl = p_slot->ctrl; |
---|
30 | 38 | |
---|
31 | 39 | pci_lock_rescan_remove(); |
---|
32 | 40 | |
---|
.. | .. |
---|
62 | 70 | return ret; |
---|
63 | 71 | } |
---|
64 | 72 | |
---|
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) |
---|
66 | 85 | { |
---|
67 | | - u8 presence = 0; |
---|
68 | 86 | 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; |
---|
70 | 88 | u16 command; |
---|
71 | | - struct controller *ctrl = p_slot->ctrl; |
---|
72 | 89 | |
---|
73 | 90 | ctrl_dbg(ctrl, "%s: domain:bus:dev = %04x:%02x:00\n", |
---|
74 | 91 | __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); |
---|
76 | 95 | |
---|
77 | 96 | pci_lock_rescan_remove(); |
---|
78 | 97 | |
---|
.. | .. |
---|
85 | 104 | list_for_each_entry_safe_reverse(dev, temp, &parent->devices, |
---|
86 | 105 | bus_list) { |
---|
87 | 106 | 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 | | - } |
---|
94 | 107 | pci_stop_and_remove_bus_device(dev); |
---|
95 | 108 | /* |
---|
96 | 109 | * Ensure that no new Requests will be generated from |
---|