aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/hotplug')
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c64
-rw-r--r--drivers/pci/hotplug/cpci_hotplug_pci.c35
-rw-r--r--drivers/pci/hotplug/cpqphp_pci.c8
-rw-r--r--drivers/pci/hotplug/ibmphp_core.c8
-rw-r--r--drivers/pci/hotplug/pciehp_pci.c28
-rw-r--r--drivers/pci/hotplug/sgi_hotplug.c12
-rw-r--r--drivers/pci/hotplug/shpchp_ctrl.c3
-rw-r--r--drivers/pci/hotplug/shpchp_pci.c45
-rw-r--r--drivers/pci/hotplug/shpchp_sysfs.c6
9 files changed, 85 insertions, 124 deletions
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 806c44fa645a..395c67d3d296 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -100,11 +100,11 @@ static int post_dock_fixups(struct notifier_block *nb, unsigned long val,
100 PCI_PRIMARY_BUS, 100 PCI_PRIMARY_BUS,
101 &buses); 101 &buses);
102 102
103 if (((buses >> 8) & 0xff) != bus->secondary) { 103 if (((buses >> 8) & 0xff) != bus->busn_res.start) {
104 buses = (buses & 0xff000000) 104 buses = (buses & 0xff000000)
105 | ((unsigned int)(bus->primary) << 0) 105 | ((unsigned int)(bus->primary) << 0)
106 | ((unsigned int)(bus->secondary) << 8) 106 | ((unsigned int)(bus->busn_res.start) << 8)
107 | ((unsigned int)(bus->subordinate) << 16); 107 | ((unsigned int)(bus->busn_res.end) << 16);
108 pci_write_config_dword(bus->self, PCI_PRIMARY_BUS, buses); 108 pci_write_config_dword(bus->self, PCI_PRIMARY_BUS, buses);
109 } 109 }
110 return NOTIFY_OK; 110 return NOTIFY_OK;
@@ -132,6 +132,15 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
132 if (!acpi_pci_check_ejectable(pbus, handle) && !is_dock_device(handle)) 132 if (!acpi_pci_check_ejectable(pbus, handle) && !is_dock_device(handle))
133 return AE_OK; 133 return AE_OK;
134 134
135 status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr);
136 if (ACPI_FAILURE(status)) {
137 warn("can't evaluate _ADR (%#x)\n", status);
138 return AE_OK;
139 }
140
141 device = (adr >> 16) & 0xffff;
142 function = adr & 0xffff;
143
135 pdev = pbus->self; 144 pdev = pbus->self;
136 if (pdev && pci_is_pcie(pdev)) { 145 if (pdev && pci_is_pcie(pdev)) {
137 tmp = acpi_find_root_bridge_handle(pdev); 146 tmp = acpi_find_root_bridge_handle(pdev);
@@ -144,10 +153,6 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
144 } 153 }
145 } 154 }
146 155
147 acpi_evaluate_integer(handle, "_ADR", NULL, &adr);
148 device = (adr >> 16) & 0xffff;
149 function = adr & 0xffff;
150
151 newfunc = kzalloc(sizeof(struct acpiphp_func), GFP_KERNEL); 156 newfunc = kzalloc(sizeof(struct acpiphp_func), GFP_KERNEL);
152 if (!newfunc) 157 if (!newfunc)
153 return AE_NO_MEMORY; 158 return AE_NO_MEMORY;
@@ -692,7 +697,7 @@ static unsigned char acpiphp_max_busnr(struct pci_bus *bus)
692 * bus->subordinate value because it could have 697 * bus->subordinate value because it could have
693 * padding in it. 698 * padding in it.
694 */ 699 */
695 max = bus->secondary; 700 max = bus->busn_res.start;
696 701
697 list_for_each(tmp, &bus->children) { 702 list_for_each(tmp, &bus->children) {
698 n = pci_bus_max_busnr(pci_bus_b(tmp)); 703 n = pci_bus_max_busnr(pci_bus_b(tmp));
@@ -878,6 +883,24 @@ static void disable_bridges(struct pci_bus *bus)
878 } 883 }
879} 884}
880 885
886/* return first device in slot, acquiring a reference on it */
887static struct pci_dev *dev_in_slot(struct acpiphp_slot *slot)
888{
889 struct pci_bus *bus = slot->bridge->pci_bus;
890 struct pci_dev *dev;
891 struct pci_dev *ret = NULL;
892
893 down_read(&pci_bus_sem);
894 list_for_each_entry(dev, &bus->devices, bus_list)
895 if (PCI_SLOT(dev->devfn) == slot->device) {
896 ret = pci_dev_get(dev);
897 break;
898 }
899 up_read(&pci_bus_sem);
900
901 return ret;
902}
903
881/** 904/**
882 * disable_device - disable a slot 905 * disable_device - disable a slot
883 * @slot: ACPI PHP slot 906 * @slot: ACPI PHP slot
@@ -893,6 +916,7 @@ static int disable_device(struct acpiphp_slot *slot)
893 pdev = pci_get_slot(bus, PCI_DEVFN(slot->device, 0)); 916 pdev = pci_get_slot(bus, PCI_DEVFN(slot->device, 0));
894 if (!pdev) 917 if (!pdev)
895 goto err_exit; 918 goto err_exit;
919 pci_dev_put(pdev);
896 920
897 list_for_each_entry(func, &slot->funcs, sibling) { 921 list_for_each_entry(func, &slot->funcs, sibling) {
898 if (func->bridge) { 922 if (func->bridge) {
@@ -901,18 +925,22 @@ static int disable_device(struct acpiphp_slot *slot)
901 (u32)1, NULL, NULL); 925 (u32)1, NULL, NULL);
902 func->bridge = NULL; 926 func->bridge = NULL;
903 } 927 }
928 }
904 929
905 pdev = pci_get_slot(slot->bridge->pci_bus, 930 /*
906 PCI_DEVFN(slot->device, func->function)); 931 * enable_device() enumerates all functions in this device via
907 if (pdev) { 932 * pci_scan_slot(), whether they have associated ACPI hotplug
908 pci_stop_bus_device(pdev); 933 * methods (_EJ0, etc.) or not. Therefore, we remove all functions
909 if (pdev->subordinate) { 934 * here.
910 disable_bridges(pdev->subordinate); 935 */
911 pci_disable_device(pdev); 936 while ((pdev = dev_in_slot(slot))) {
912 } 937 pci_stop_bus_device(pdev);
913 __pci_remove_bus_device(pdev); 938 if (pdev->subordinate) {
914 pci_dev_put(pdev); 939 disable_bridges(pdev->subordinate);
940 pci_disable_device(pdev);
915 } 941 }
942 __pci_remove_bus_device(pdev);
943 pci_dev_put(pdev);
916 } 944 }
917 945
918 list_for_each_entry(func, &slot->funcs, sibling) { 946 list_for_each_entry(func, &slot->funcs, sibling) {
diff --git a/drivers/pci/hotplug/cpci_hotplug_pci.c b/drivers/pci/hotplug/cpci_hotplug_pci.c
index ae853ccd0cd5..dcc75c785443 100644
--- a/drivers/pci/hotplug/cpci_hotplug_pci.c
+++ b/drivers/pci/hotplug/cpci_hotplug_pci.c
@@ -285,42 +285,19 @@ int __ref cpci_configure_slot(struct slot *slot)
285 for (fn = 0; fn < 8; fn++) { 285 for (fn = 0; fn < 8; fn++) {
286 struct pci_dev *dev; 286 struct pci_dev *dev;
287 287
288 dev = pci_get_slot(parent, PCI_DEVFN(PCI_SLOT(slot->devfn), fn)); 288 dev = pci_get_slot(parent,
289 PCI_DEVFN(PCI_SLOT(slot->devfn), fn));
289 if (!dev) 290 if (!dev)
290 continue; 291 continue;
291 if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) || 292 if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) ||
292 (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)) { 293 (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS))
293 /* Find an unused bus number for the new bridge */ 294 pci_hp_add_bridge(dev);
294 struct pci_bus *child;
295 unsigned char busnr, start = parent->secondary;
296 unsigned char end = parent->subordinate;
297
298 for (busnr = start; busnr <= end; busnr++) {
299 if (!pci_find_bus(pci_domain_nr(parent),
300 busnr))
301 break;
302 }
303 if (busnr >= end) {
304 err("No free bus for hot-added bridge\n");
305 pci_dev_put(dev);
306 continue;
307 }
308 child = pci_add_new_bus(parent, dev, busnr);
309 if (!child) {
310 err("Cannot add new bus for %s\n",
311 pci_name(dev));
312 pci_dev_put(dev);
313 continue;
314 }
315 child->subordinate = pci_do_scan_bus(child);
316 pci_bus_size_bridges(child);
317 }
318 pci_dev_put(dev); 295 pci_dev_put(dev);
319 } 296 }
320 297
321 pci_bus_assign_resources(parent); 298 pci_assign_unassigned_bridge_resources(parent->self);
299
322 pci_bus_add_devices(parent); 300 pci_bus_add_devices(parent);
323 pci_enable_bridges(parent);
324 301
325 dbg("%s - exit", __func__); 302 dbg("%s - exit", __func__);
326 return 0; 303 return 0;
diff --git a/drivers/pci/hotplug/cpqphp_pci.c b/drivers/pci/hotplug/cpqphp_pci.c
index 1c8494021a42..09801c6945ce 100644
--- a/drivers/pci/hotplug/cpqphp_pci.c
+++ b/drivers/pci/hotplug/cpqphp_pci.c
@@ -83,7 +83,6 @@ static void __iomem *detect_HRT_floating_pointer(void __iomem *begin, void __iom
83 83
84int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func) 84int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func)
85{ 85{
86 unsigned char bus;
87 struct pci_bus *child; 86 struct pci_bus *child;
88 int num; 87 int num;
89 88
@@ -106,9 +105,10 @@ int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func)
106 } 105 }
107 106
108 if (func->pci_dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { 107 if (func->pci_dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
109 pci_read_config_byte(func->pci_dev, PCI_SECONDARY_BUS, &bus); 108 pci_hp_add_bridge(func->pci_dev);
110 child = (struct pci_bus*) pci_add_new_bus(func->pci_dev->bus, (func->pci_dev), bus); 109 child = func->pci_dev->subordinate;
111 pci_do_scan_bus(child); 110 if (child)
111 pci_bus_add_devices(child);
112 } 112 }
113 113
114 pci_dev_put(func->pci_dev); 114 pci_dev_put(func->pci_dev);
diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c
index 4fda7e6a86a7..7dccad5fc891 100644
--- a/drivers/pci/hotplug/ibmphp_core.c
+++ b/drivers/pci/hotplug/ibmphp_core.c
@@ -775,7 +775,6 @@ static u8 bus_structure_fixup(u8 busno)
775 775
776static int ibm_configure_device(struct pci_func *func) 776static int ibm_configure_device(struct pci_func *func)
777{ 777{
778 unsigned char bus;
779 struct pci_bus *child; 778 struct pci_bus *child;
780 int num; 779 int num;
781 int flag = 0; /* this is to make sure we don't double scan the bus, 780 int flag = 0; /* this is to make sure we don't double scan the bus,
@@ -805,9 +804,10 @@ static int ibm_configure_device(struct pci_func *func)
805 } 804 }
806 } 805 }
807 if (!(flag) && (func->dev->hdr_type == PCI_HEADER_TYPE_BRIDGE)) { 806 if (!(flag) && (func->dev->hdr_type == PCI_HEADER_TYPE_BRIDGE)) {
808 pci_read_config_byte(func->dev, PCI_SECONDARY_BUS, &bus); 807 pci_hp_add_bridge(func->dev);
809 child = pci_add_new_bus(func->dev->bus, func->dev, bus); 808 child = func->dev->subordinate;
810 pci_do_scan_bus(child); 809 if (child)
810 pci_bus_add_devices(child);
811 } 811 }
812 812
813 return 0; 813 return 0;
diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c
index 47d9dc06b109..09cecaf450c5 100644
--- a/drivers/pci/hotplug/pciehp_pci.c
+++ b/drivers/pci/hotplug/pciehp_pci.c
@@ -34,29 +34,6 @@
34#include "../pci.h" 34#include "../pci.h"
35#include "pciehp.h" 35#include "pciehp.h"
36 36
37static int __ref pciehp_add_bridge(struct pci_dev *dev)
38{
39 struct pci_bus *parent = dev->bus;
40 int pass, busnr, start = parent->secondary;
41 int end = parent->subordinate;
42
43 for (busnr = start; busnr <= end; busnr++) {
44 if (!pci_find_bus(pci_domain_nr(parent), busnr))
45 break;
46 }
47 if (busnr-- > end) {
48 err("No bus number available for hot-added bridge %s\n",
49 pci_name(dev));
50 return -1;
51 }
52 for (pass = 0; pass < 2; pass++)
53 busnr = pci_scan_bridge(parent, dev, busnr, pass);
54 if (!dev->subordinate)
55 return -1;
56
57 return 0;
58}
59
60int pciehp_configure_device(struct slot *p_slot) 37int pciehp_configure_device(struct slot *p_slot)
61{ 38{
62 struct pci_dev *dev; 39 struct pci_dev *dev;
@@ -85,9 +62,8 @@ int pciehp_configure_device(struct slot *p_slot)
85 if (!dev) 62 if (!dev)
86 continue; 63 continue;
87 if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) || 64 if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) ||
88 (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)) { 65 (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS))
89 pciehp_add_bridge(dev); 66 pci_hp_add_bridge(dev);
90 }
91 pci_dev_put(dev); 67 pci_dev_put(dev);
92 } 68 }
93 69
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c
index de573113c102..f64ca92253da 100644
--- a/drivers/pci/hotplug/sgi_hotplug.c
+++ b/drivers/pci/hotplug/sgi_hotplug.c
@@ -397,13 +397,11 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
397 else 397 else
398 sn_io_slot_fixup(dev); 398 sn_io_slot_fixup(dev);
399 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { 399 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
400 unsigned char sec_bus; 400 pci_hp_add_bridge(dev);
401 pci_read_config_byte(dev, PCI_SECONDARY_BUS, 401 if (dev->subordinate) {
402 &sec_bus); 402 new_bus = dev->subordinate;
403 new_bus = pci_add_new_bus(dev->bus, dev, 403 new_ppb = 1;
404 sec_bus); 404 }
405 pci_scan_child_bus(new_bus);
406 new_ppb = 1;
407 } 405 }
408 pci_dev_put(dev); 406 pci_dev_put(dev);
409 } 407 }
diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
index b00b09bdd38a..f9b5a52e4115 100644
--- a/drivers/pci/hotplug/shpchp_ctrl.c
+++ b/drivers/pci/hotplug/shpchp_ctrl.c
@@ -262,9 +262,6 @@ static int board_added(struct slot *p_slot)
262 } 262 }
263 263
264 if ((ctrl->pci_dev->vendor == 0x8086) && (ctrl->pci_dev->device == 0x0332)) { 264 if ((ctrl->pci_dev->vendor == 0x8086) && (ctrl->pci_dev->device == 0x0332)) {
265 if (slots_not_empty)
266 return WRONG_BUS_FREQUENCY;
267
268 if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, PCI_SPEED_33MHz))) { 265 if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, PCI_SPEED_33MHz))) {
269 ctrl_err(ctrl, "%s: Issue of set bus speed mode command" 266 ctrl_err(ctrl, "%s: Issue of set bus speed mode command"
270 " failed\n", __func__); 267 " failed\n", __func__);
diff --git a/drivers/pci/hotplug/shpchp_pci.c b/drivers/pci/hotplug/shpchp_pci.c
index df7e4bfadae3..c627ed9957d1 100644
--- a/drivers/pci/hotplug/shpchp_pci.c
+++ b/drivers/pci/hotplug/shpchp_pci.c
@@ -37,9 +37,10 @@
37int __ref shpchp_configure_device(struct slot *p_slot) 37int __ref shpchp_configure_device(struct slot *p_slot)
38{ 38{
39 struct pci_dev *dev; 39 struct pci_dev *dev;
40 struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate;
41 int num, fn;
42 struct controller *ctrl = p_slot->ctrl; 40 struct controller *ctrl = p_slot->ctrl;
41 struct pci_dev *bridge = ctrl->pci_dev;
42 struct pci_bus *parent = bridge->subordinate;
43 int num, fn;
43 44
44 dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0)); 45 dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0));
45 if (dev) { 46 if (dev) {
@@ -61,39 +62,23 @@ int __ref shpchp_configure_device(struct slot *p_slot)
61 if (!dev) 62 if (!dev)
62 continue; 63 continue;
63 if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) || 64 if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) ||
64 (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)) { 65 (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS))
65 /* Find an unused bus number for the new bridge */ 66 pci_hp_add_bridge(dev);
66 struct pci_bus *child; 67 pci_dev_put(dev);
67 unsigned char busnr, start = parent->secondary; 68 }
68 unsigned char end = parent->subordinate; 69
69 for (busnr = start; busnr <= end; busnr++) { 70 pci_assign_unassigned_bridge_resources(bridge);
70 if (!pci_find_bus(pci_domain_nr(parent), 71
71 busnr)) 72 for (fn = 0; fn < 8; fn++) {
72 break; 73 dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, fn));
73 } 74 if (!dev)
74 if (busnr > end) { 75 continue;
75 ctrl_err(ctrl,
76 "No free bus for hot-added bridge\n");
77 pci_dev_put(dev);
78 continue;
79 }
80 child = pci_add_new_bus(parent, dev, busnr);
81 if (!child) {
82 ctrl_err(ctrl, "Cannot add new bus for %s\n",
83 pci_name(dev));
84 pci_dev_put(dev);
85 continue;
86 }
87 child->subordinate = pci_do_scan_bus(child);
88 pci_bus_size_bridges(child);
89 }
90 pci_configure_slot(dev); 76 pci_configure_slot(dev);
91 pci_dev_put(dev); 77 pci_dev_put(dev);
92 } 78 }
93 79
94 pci_bus_assign_resources(parent);
95 pci_bus_add_devices(parent); 80 pci_bus_add_devices(parent);
96 pci_enable_bridges(parent); 81
97 return 0; 82 return 0;
98} 83}
99 84
diff --git a/drivers/pci/hotplug/shpchp_sysfs.c b/drivers/pci/hotplug/shpchp_sysfs.c
index efa30da1ae8f..eeb23ceae4a8 100644
--- a/drivers/pci/hotplug/shpchp_sysfs.c
+++ b/drivers/pci/hotplug/shpchp_sysfs.c
@@ -73,13 +73,13 @@ static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, cha
73 } 73 }
74 } 74 }
75 out += sprintf(out, "Free resources: bus numbers\n"); 75 out += sprintf(out, "Free resources: bus numbers\n");
76 for (busnr = bus->secondary; busnr <= bus->subordinate; busnr++) { 76 for (busnr = bus->busn_res.start; busnr <= bus->busn_res.end; busnr++) {
77 if (!pci_find_bus(pci_domain_nr(bus), busnr)) 77 if (!pci_find_bus(pci_domain_nr(bus), busnr))
78 break; 78 break;
79 } 79 }
80 if (busnr < bus->subordinate) 80 if (busnr < bus->busn_res.end)
81 out += sprintf(out, "start = %8.8x, length = %8.8x\n", 81 out += sprintf(out, "start = %8.8x, length = %8.8x\n",
82 busnr, (bus->subordinate - busnr)); 82 busnr, (int)(bus->busn_res.end - busnr));
83 83
84 return out - buf; 84 return out - buf;
85} 85}