aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-10-09 15:03:49 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-10-09 15:03:49 -0400
commit80213c03c4151d900cf293ef0fc51f8d88495e14 (patch)
treeaf2422fa255aed96c23cef894e0adbf817f30c45 /drivers/pci/hotplug
parentea584595fc85e65796335033dfca25ed655cd0ed (diff)
parentf92d9ee3ab39841d1f29f2d1aa96ff7c74b36ee1 (diff)
Merge tag 'pci-v3.18-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci
Pull PCI updates from Bjorn Helgaas: "The interesting things here are: - Turn on Config Request Retry Status Software Visibility. This caused hangs last time, but we included a fix this time. - Rework PCI device configuration to use _HPP/_HPX more aggressively - Allow PCI devices to be put into D3cold during system suspend - Add arm64 PCI support - Add APM X-Gene host bridge driver - Add TI Keystone host bridge driver - Add Xilinx AXI host bridge driver More detailed summary: Enumeration - Check Vendor ID only for Config Request Retry Status (Rajat Jain) - Enable Config Request Retry Status when supported (Rajat Jain) - Add generic domain handling (Catalin Marinas) - Generate uppercase hex for modalias interface class (Ricardo Ribalda Delgado) Resource management - Add missing MEM_64 mask in pci_assign_unassigned_bridge_resources() (Yinghai Lu) - Increase IBM ipr SAS Crocodile BARs to at least system page size (Douglas Lehr) PCI device hotplug - Prevent NULL dereference during pciehp probe (Andreas Noever) - Move _HPP & _HPX handling into core (Bjorn Helgaas) - Apply _HPP to PCIe devices as well as PCI (Bjorn Helgaas) - Apply _HPP/_HPX to display devices (Bjorn Helgaas) - Preserve SERR & PARITY settings when applying _HPP/_HPX (Bjorn Helgaas) - Preserve MPS and MRRS settings when applying _HPP/_HPX (Bjorn Helgaas) - Apply _HPP/_HPX to all devices, not just hot-added ones (Bjorn Helgaas) - Fix wait time in pciehp timeout message (Yinghai Lu) - Add more pciehp Slot Control debug output (Yinghai Lu) - Stop disabling pciehp notifications during init (Yinghai Lu) MSI - Remove arch_msi_check_device() (Alexander Gordeev) - Rename pci_msi_check_device() to pci_msi_supported() (Alexander Gordeev) - Move D0 check into pci_msi_check_device() (Alexander Gordeev) - Remove unused kobject from struct msi_desc (Yijing Wang) - Remove "pos" from the struct msi_desc msi_attrib (Yijing Wang) - Add "msi_bus" sysfs MSI/MSI-X control for endpoints (Yijing Wang) - Use __get_cached_msi_msg() instead of get_cached_msi_msg() (Yijing Wang) - Use __read_msi_msg() instead of read_msi_msg() (Yijing Wang) - Use __write_msi_msg() instead of write_msi_msg() (Yijing Wang) Power management - Drop unused runtime PM support code for PCIe ports (Rafael J. Wysocki) - Allow PCI devices to be put into D3cold during system suspend (Rafael J. Wysocki) AER - Add additional AER error strings (Gong Chen) - Make <linux/aer.h> standalone includable (Thierry Reding) Virtualization - Add ACS quirk for Solarflare SFC9120 & SFC9140 (Alex Williamson) - Add ACS quirk for Intel 10G NICs (Alex Williamson) - Add ACS quirk for AMD A88X southbridge (Marti Raudsepp) - Remove unused pci_find_upstream_pcie_bridge(), pci_get_dma_source() (Alex Williamson) - Add device flag helpers (Ethan Zhao) - Assume all Mellanox devices have broken INTx masking (Gavin Shan) Generic host bridge driver - Fix ioport_map() for !CONFIG_GENERIC_IOMAP (Liviu Dudau) - Add pci_register_io_range() and pci_pio_to_address() (Liviu Dudau) - Define PCI_IOBASE as the base of virtual PCI IO space (Liviu Dudau) - Fix the conversion of IO ranges into IO resources (Liviu Dudau) - Add pci_get_new_domain_nr() and of_get_pci_domain_nr() (Liviu Dudau) - Add support for parsing PCI host bridge resources from DT (Liviu Dudau) - Add pci_remap_iospace() to map bus I/O resources (Liviu Dudau) - Add arm64 architectural support for PCI (Liviu Dudau) APM X-Gene - Add APM X-Gene PCIe driver (Tanmay Inamdar) - Add arm64 DT APM X-Gene PCIe device tree nodes (Tanmay Inamdar) Freescale i.MX6 - Probe in module_init(), not fs_initcall() (Lucas Stach) - Delay enabling reference clock for SS until it stabilizes (Tim Harvey) Marvell MVEBU - Fix uninitialized variable in mvebu_get_tgt_attr() (Thomas Petazzoni) NVIDIA Tegra - Make sure the PCIe PLL is really reset (Eric Yuen) - Add error path tegra_msi_teardown_irq() cleanup (Jisheng Zhang) - Fix extended configuration space mapping (Peter Daifuku) - Implement resource hierarchy (Thierry Reding) - Clear CLKREQ# enable on port disable (Thierry Reding) - Add Tegra124 support (Thierry Reding) ST Microelectronics SPEAr13xx - Pass config resource through reg property (Pratyush Anand) Synopsys DesignWare - Use NULL instead of false (Fabio Estevam) - Parse bus-range property from devicetree (Lucas Stach) - Use pci_create_root_bus() instead of pci_scan_root_bus() (Lucas Stach) - Remove pci_assign_unassigned_resources() (Lucas Stach) - Check private_data validity in single place (Lucas Stach) - Setup and clear exactly one MSI at a time (Lucas Stach) - Remove open-coded bitmap operations (Lucas Stach) - Fix configuration base address when using 'reg' (Minghuan Lian) - Fix IO resource end address calculation (Minghuan Lian) - Rename get_msi_data() to get_msi_addr() (Minghuan Lian) - Add get_msi_data() to pcie_host_ops (Minghuan Lian) - Add support for v3.65 hardware (Murali Karicheri) - Fold struct pcie_port_info into struct pcie_port (Pratyush Anand) TI Keystone - Add TI Keystone PCIe driver (Murali Karicheri) - Limit MRSS for all downstream devices (Murali Karicheri) - Assume controller is already in RC mode (Murali Karicheri) - Set device ID based on SoC to support multiple ports (Murali Karicheri) Xilinx AXI - Add Xilinx AXI PCIe driver (Srikanth Thokala) - Fix xilinx_pcie_assign_msi() return value test (Dan Carpenter) Miscellaneous - Clean up whitespace (Quentin Lambert) - Remove assignments from "if" conditions (Quentin Lambert) - Move PCI_VENDOR_ID_VMWARE to pci_ids.h (Francesco Ruggeri) - x86: Mark DMI tables as initialization data (Mathias Krause) - x86: Move __init annotation to the correct place (Mathias Krause) - x86: Mark constants of pci_mmcfg_nvidia_mcp55() as __initconst (Mathias Krause) - x86: Constify pci_mmcfg_probes[] array (Mathias Krause) - x86: Mark PCI BIOS initialization code as such (Mathias Krause) - Parenthesize PCI_DEVID and PCI_VPD_LRDT_ID parameters (Megan Kamiya) - Remove unnecessary variable in pci_add_dynid() (Tobias Klauser)" * tag 'pci-v3.18-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (109 commits) arm64: dts: Add APM X-Gene PCIe device tree nodes PCI: Add ACS quirk for AMD A88X southbridge devices PCI: xgene: Add APM X-Gene PCIe driver PCI: designware: Remove open-coded bitmap operations PCI/MSI: Remove unnecessary temporary variable PCI/MSI: Use __write_msi_msg() instead of write_msi_msg() MSI/powerpc: Use __read_msi_msg() instead of read_msi_msg() PCI/MSI: Use __get_cached_msi_msg() instead of get_cached_msi_msg() PCI/MSI: Add "msi_bus" sysfs MSI/MSI-X control for endpoints PCI/MSI: Remove "pos" from the struct msi_desc msi_attrib PCI/MSI: Remove unused kobject from struct msi_desc PCI/MSI: Rename pci_msi_check_device() to pci_msi_supported() PCI/MSI: Move D0 check into pci_msi_check_device() PCI/MSI: Remove arch_msi_check_device() irqchip: armada-370-xp: Remove arch_msi_check_device() PCI/MSI/PPC: Remove arch_msi_check_device() arm64: Add architectural support for PCI PCI: Add pci_remap_iospace() to map bus I/O resources of/pci: Add support for parsing PCI host bridge resources from DT of/pci: Add pci_get_new_domain_nr() and of_get_pci_domain_nr() ... Conflicts: arch/arm64/boot/dts/apm-storm.dtsi
Diffstat (limited to 'drivers/pci/hotplug')
-rw-r--r--drivers/pci/hotplug/Makefile2
-rw-r--r--drivers/pci/hotplug/acpi_pcihp.c254
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c11
-rw-r--r--drivers/pci/hotplug/acpiphp_ibm.c2
-rw-r--r--drivers/pci/hotplug/cpci_hotplug_core.c13
-rw-r--r--drivers/pci/hotplug/cpcihp_generic.c28
-rw-r--r--drivers/pci/hotplug/cpcihp_zt5550.c44
-rw-r--r--drivers/pci/hotplug/cpqphp.h2
-rw-r--r--drivers/pci/hotplug/cpqphp_core.c3
-rw-r--r--drivers/pci/hotplug/cpqphp_ctrl.c19
-rw-r--r--drivers/pci/hotplug/cpqphp_nvram.c13
-rw-r--r--drivers/pci/hotplug/ibmphp_core.c19
-rw-r--r--drivers/pci/hotplug/ibmphp_ebda.c3
-rw-r--r--drivers/pci/hotplug/ibmphp_hpc.c3
-rw-r--r--drivers/pci/hotplug/ibmphp_pci.c6
-rw-r--r--drivers/pci/hotplug/ibmphp_res.c45
-rw-r--r--drivers/pci/hotplug/pciehp.h2
-rw-r--r--drivers/pci/hotplug/pciehp_core.c7
-rw-r--r--drivers/pci/hotplug/pciehp_hpc.c17
-rw-r--r--drivers/pci/hotplug/pciehp_pci.c9
-rw-r--r--drivers/pci/hotplug/pcihp_slot.c176
-rw-r--r--drivers/pci/hotplug/shpchp_ctrl.c14
-rw-r--r--drivers/pci/hotplug/shpchp_hpc.c5
-rw-r--r--drivers/pci/hotplug/shpchp_pci.c8
24 files changed, 144 insertions, 561 deletions
diff --git a/drivers/pci/hotplug/Makefile b/drivers/pci/hotplug/Makefile
index 3e6532b945c1..4a9aa08b08f1 100644
--- a/drivers/pci/hotplug/Makefile
+++ b/drivers/pci/hotplug/Makefile
@@ -24,7 +24,7 @@ obj-$(CONFIG_HOTPLUG_PCI_S390) += s390_pci_hpc.o
24 24
25obj-$(CONFIG_HOTPLUG_PCI_ACPI_IBM) += acpiphp_ibm.o 25obj-$(CONFIG_HOTPLUG_PCI_ACPI_IBM) += acpiphp_ibm.o
26 26
27pci_hotplug-objs := pci_hotplug_core.o pcihp_slot.o 27pci_hotplug-objs := pci_hotplug_core.o
28 28
29ifdef CONFIG_HOTPLUG_PCI_CPCI 29ifdef CONFIG_HOTPLUG_PCI_CPCI
30pci_hotplug-objs += cpci_hotplug_core.o \ 30pci_hotplug-objs += cpci_hotplug_core.o \
diff --git a/drivers/pci/hotplug/acpi_pcihp.c b/drivers/pci/hotplug/acpi_pcihp.c
index a94d850ae228..876ccc620440 100644
--- a/drivers/pci/hotplug/acpi_pcihp.c
+++ b/drivers/pci/hotplug/acpi_pcihp.c
@@ -46,215 +46,6 @@
46 46
47static bool debug_acpi; 47static bool debug_acpi;
48 48
49static acpi_status
50decode_type0_hpx_record(union acpi_object *record, struct hotplug_params *hpx)
51{
52 int i;
53 union acpi_object *fields = record->package.elements;
54 u32 revision = fields[1].integer.value;
55
56 switch (revision) {
57 case 1:
58 if (record->package.count != 6)
59 return AE_ERROR;
60 for (i = 2; i < 6; i++)
61 if (fields[i].type != ACPI_TYPE_INTEGER)
62 return AE_ERROR;
63 hpx->t0 = &hpx->type0_data;
64 hpx->t0->revision = revision;
65 hpx->t0->cache_line_size = fields[2].integer.value;
66 hpx->t0->latency_timer = fields[3].integer.value;
67 hpx->t0->enable_serr = fields[4].integer.value;
68 hpx->t0->enable_perr = fields[5].integer.value;
69 break;
70 default:
71 printk(KERN_WARNING
72 "%s: Type 0 Revision %d record not supported\n",
73 __func__, revision);
74 return AE_ERROR;
75 }
76 return AE_OK;
77}
78
79static acpi_status
80decode_type1_hpx_record(union acpi_object *record, struct hotplug_params *hpx)
81{
82 int i;
83 union acpi_object *fields = record->package.elements;
84 u32 revision = fields[1].integer.value;
85
86 switch (revision) {
87 case 1:
88 if (record->package.count != 5)
89 return AE_ERROR;
90 for (i = 2; i < 5; i++)
91 if (fields[i].type != ACPI_TYPE_INTEGER)
92 return AE_ERROR;
93 hpx->t1 = &hpx->type1_data;
94 hpx->t1->revision = revision;
95 hpx->t1->max_mem_read = fields[2].integer.value;
96 hpx->t1->avg_max_split = fields[3].integer.value;
97 hpx->t1->tot_max_split = fields[4].integer.value;
98 break;
99 default:
100 printk(KERN_WARNING
101 "%s: Type 1 Revision %d record not supported\n",
102 __func__, revision);
103 return AE_ERROR;
104 }
105 return AE_OK;
106}
107
108static acpi_status
109decode_type2_hpx_record(union acpi_object *record, struct hotplug_params *hpx)
110{
111 int i;
112 union acpi_object *fields = record->package.elements;
113 u32 revision = fields[1].integer.value;
114
115 switch (revision) {
116 case 1:
117 if (record->package.count != 18)
118 return AE_ERROR;
119 for (i = 2; i < 18; i++)
120 if (fields[i].type != ACPI_TYPE_INTEGER)
121 return AE_ERROR;
122 hpx->t2 = &hpx->type2_data;
123 hpx->t2->revision = revision;
124 hpx->t2->unc_err_mask_and = fields[2].integer.value;
125 hpx->t2->unc_err_mask_or = fields[3].integer.value;
126 hpx->t2->unc_err_sever_and = fields[4].integer.value;
127 hpx->t2->unc_err_sever_or = fields[5].integer.value;
128 hpx->t2->cor_err_mask_and = fields[6].integer.value;
129 hpx->t2->cor_err_mask_or = fields[7].integer.value;
130 hpx->t2->adv_err_cap_and = fields[8].integer.value;
131 hpx->t2->adv_err_cap_or = fields[9].integer.value;
132 hpx->t2->pci_exp_devctl_and = fields[10].integer.value;
133 hpx->t2->pci_exp_devctl_or = fields[11].integer.value;
134 hpx->t2->pci_exp_lnkctl_and = fields[12].integer.value;
135 hpx->t2->pci_exp_lnkctl_or = fields[13].integer.value;
136 hpx->t2->sec_unc_err_sever_and = fields[14].integer.value;
137 hpx->t2->sec_unc_err_sever_or = fields[15].integer.value;
138 hpx->t2->sec_unc_err_mask_and = fields[16].integer.value;
139 hpx->t2->sec_unc_err_mask_or = fields[17].integer.value;
140 break;
141 default:
142 printk(KERN_WARNING
143 "%s: Type 2 Revision %d record not supported\n",
144 __func__, revision);
145 return AE_ERROR;
146 }
147 return AE_OK;
148}
149
150static acpi_status
151acpi_run_hpx(acpi_handle handle, struct hotplug_params *hpx)
152{
153 acpi_status status;
154 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
155 union acpi_object *package, *record, *fields;
156 u32 type;
157 int i;
158
159 /* Clear the return buffer with zeros */
160 memset(hpx, 0, sizeof(struct hotplug_params));
161
162 status = acpi_evaluate_object(handle, "_HPX", NULL, &buffer);
163 if (ACPI_FAILURE(status))
164 return status;
165
166 package = (union acpi_object *)buffer.pointer;
167 if (package->type != ACPI_TYPE_PACKAGE) {
168 status = AE_ERROR;
169 goto exit;
170 }
171
172 for (i = 0; i < package->package.count; i++) {
173 record = &package->package.elements[i];
174 if (record->type != ACPI_TYPE_PACKAGE) {
175 status = AE_ERROR;
176 goto exit;
177 }
178
179 fields = record->package.elements;
180 if (fields[0].type != ACPI_TYPE_INTEGER ||
181 fields[1].type != ACPI_TYPE_INTEGER) {
182 status = AE_ERROR;
183 goto exit;
184 }
185
186 type = fields[0].integer.value;
187 switch (type) {
188 case 0:
189 status = decode_type0_hpx_record(record, hpx);
190 if (ACPI_FAILURE(status))
191 goto exit;
192 break;
193 case 1:
194 status = decode_type1_hpx_record(record, hpx);
195 if (ACPI_FAILURE(status))
196 goto exit;
197 break;
198 case 2:
199 status = decode_type2_hpx_record(record, hpx);
200 if (ACPI_FAILURE(status))
201 goto exit;
202 break;
203 default:
204 printk(KERN_ERR "%s: Type %d record not supported\n",
205 __func__, type);
206 status = AE_ERROR;
207 goto exit;
208 }
209 }
210 exit:
211 kfree(buffer.pointer);
212 return status;
213}
214
215static acpi_status
216acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp)
217{
218 acpi_status status;
219 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
220 union acpi_object *package, *fields;
221 int i;
222
223 memset(hpp, 0, sizeof(struct hotplug_params));
224
225 status = acpi_evaluate_object(handle, "_HPP", NULL, &buffer);
226 if (ACPI_FAILURE(status))
227 return status;
228
229 package = (union acpi_object *) buffer.pointer;
230 if (package->type != ACPI_TYPE_PACKAGE ||
231 package->package.count != 4) {
232 status = AE_ERROR;
233 goto exit;
234 }
235
236 fields = package->package.elements;
237 for (i = 0; i < 4; i++) {
238 if (fields[i].type != ACPI_TYPE_INTEGER) {
239 status = AE_ERROR;
240 goto exit;
241 }
242 }
243
244 hpp->t0 = &hpp->type0_data;
245 hpp->t0->revision = 1;
246 hpp->t0->cache_line_size = fields[0].integer.value;
247 hpp->t0->latency_timer = fields[1].integer.value;
248 hpp->t0->enable_serr = fields[2].integer.value;
249 hpp->t0->enable_perr = fields[3].integer.value;
250
251exit:
252 kfree(buffer.pointer);
253 return status;
254}
255
256
257
258/* acpi_run_oshp - get control of hotplug from the firmware 49/* acpi_run_oshp - get control of hotplug from the firmware
259 * 50 *
260 * @handle - the handle of the hotplug controller. 51 * @handle - the handle of the hotplug controller.
@@ -283,48 +74,6 @@ static acpi_status acpi_run_oshp(acpi_handle handle)
283 return status; 74 return status;
284} 75}
285 76
286/* pci_get_hp_params
287 *
288 * @dev - the pci_dev for which we want parameters
289 * @hpp - allocated by the caller
290 */
291int pci_get_hp_params(struct pci_dev *dev, struct hotplug_params *hpp)
292{
293 acpi_status status;
294 acpi_handle handle, phandle;
295 struct pci_bus *pbus;
296
297 handle = NULL;
298 for (pbus = dev->bus; pbus; pbus = pbus->parent) {
299 handle = acpi_pci_get_bridge_handle(pbus);
300 if (handle)
301 break;
302 }
303
304 /*
305 * _HPP settings apply to all child buses, until another _HPP is
306 * encountered. If we don't find an _HPP for the input pci dev,
307 * look for it in the parent device scope since that would apply to
308 * this pci dev.
309 */
310 while (handle) {
311 status = acpi_run_hpx(handle, hpp);
312 if (ACPI_SUCCESS(status))
313 return 0;
314 status = acpi_run_hpp(handle, hpp);
315 if (ACPI_SUCCESS(status))
316 return 0;
317 if (acpi_is_root_bridge(handle))
318 break;
319 status = acpi_get_parent(handle, &phandle);
320 if (ACPI_FAILURE(status))
321 break;
322 handle = phandle;
323 }
324 return -ENODEV;
325}
326EXPORT_SYMBOL_GPL(pci_get_hp_params);
327
328/** 77/**
329 * acpi_get_hp_hw_control_from_firmware 78 * acpi_get_hp_hw_control_from_firmware
330 * @dev: the pci_dev of the bridge that has a hotplug controller 79 * @dev: the pci_dev of the bridge that has a hotplug controller
@@ -433,7 +182,8 @@ int acpi_pci_check_ejectable(struct pci_bus *pbus, acpi_handle handle)
433{ 182{
434 acpi_handle bridge_handle, parent_handle; 183 acpi_handle bridge_handle, parent_handle;
435 184
436 if (!(bridge_handle = acpi_pci_get_bridge_handle(pbus))) 185 bridge_handle = acpi_pci_get_bridge_handle(pbus);
186 if (!bridge_handle)
437 return 0; 187 return 0;
438 if ((ACPI_FAILURE(acpi_get_parent(handle, &parent_handle)))) 188 if ((ACPI_FAILURE(acpi_get_parent(handle, &parent_handle))))
439 return 0; 189 return 0;
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 6cd5160fc057..bcb90e4888dd 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -61,7 +61,6 @@ static DEFINE_MUTEX(bridge_mutex);
61static int acpiphp_hotplug_notify(struct acpi_device *adev, u32 type); 61static int acpiphp_hotplug_notify(struct acpi_device *adev, u32 type);
62static void acpiphp_post_dock_fixup(struct acpi_device *adev); 62static void acpiphp_post_dock_fixup(struct acpi_device *adev);
63static void acpiphp_sanitize_bus(struct pci_bus *bus); 63static void acpiphp_sanitize_bus(struct pci_bus *bus);
64static void acpiphp_set_hpp_values(struct pci_bus *bus);
65static void hotplug_event(u32 type, struct acpiphp_context *context); 64static void hotplug_event(u32 type, struct acpiphp_context *context);
66static void free_bridge(struct kref *kref); 65static void free_bridge(struct kref *kref);
67 66
@@ -510,7 +509,7 @@ static void enable_slot(struct acpiphp_slot *slot)
510 __pci_bus_assign_resources(bus, &add_list, NULL); 509 __pci_bus_assign_resources(bus, &add_list, NULL);
511 510
512 acpiphp_sanitize_bus(bus); 511 acpiphp_sanitize_bus(bus);
513 acpiphp_set_hpp_values(bus); 512 pcie_bus_configure_settings(bus);
514 acpiphp_set_acpi_region(slot); 513 acpiphp_set_acpi_region(slot);
515 514
516 list_for_each_entry(dev, &bus->devices, bus_list) { 515 list_for_each_entry(dev, &bus->devices, bus_list) {
@@ -698,14 +697,6 @@ static void acpiphp_check_bridge(struct acpiphp_bridge *bridge)
698 } 697 }
699} 698}
700 699
701static void acpiphp_set_hpp_values(struct pci_bus *bus)
702{
703 struct pci_dev *dev;
704
705 list_for_each_entry(dev, &bus->devices, bus_list)
706 pci_configure_slot(dev);
707}
708
709/* 700/*
710 * Remove devices for which we could not assign resources, call 701 * Remove devices for which we could not assign resources, call
711 * arch specific code to fix-up the bus 702 * arch specific code to fix-up the bus
diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
index 8dcccffd6e21..6ca23998ee8f 100644
--- a/drivers/pci/hotplug/acpiphp_ibm.c
+++ b/drivers/pci/hotplug/acpiphp_ibm.c
@@ -302,7 +302,7 @@ static int ibm_get_table_from_acpi(char **bufp)
302 goto read_table_done; 302 goto read_table_done;
303 } 303 }
304 304
305 for(size = 0, i = 0; i < package->package.count; i++) { 305 for (size = 0, i = 0; i < package->package.count; i++) {
306 if (package->package.elements[i].type != ACPI_TYPE_BUFFER) { 306 if (package->package.elements[i].type != ACPI_TYPE_BUFFER) {
307 pr_err("%s: Invalid APCI element %d\n", __func__, i); 307 pr_err("%s: Invalid APCI element %d\n", __func__, i);
308 goto read_table_done; 308 goto read_table_done;
diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c
index e09cf7827d68..a5a7fd8332ac 100644
--- a/drivers/pci/hotplug/cpci_hotplug_core.c
+++ b/drivers/pci/hotplug/cpci_hotplug_core.c
@@ -125,7 +125,8 @@ disable_slot(struct hotplug_slot *hotplug_slot)
125 125
126 /* Unconfigure device */ 126 /* Unconfigure device */
127 dbg("%s - unconfiguring slot %s", __func__, slot_name(slot)); 127 dbg("%s - unconfiguring slot %s", __func__, slot_name(slot));
128 if ((retval = cpci_unconfigure_slot(slot))) { 128 retval = cpci_unconfigure_slot(slot);
129 if (retval) {
129 err("%s - could not unconfigure slot %s", 130 err("%s - could not unconfigure slot %s",
130 __func__, slot_name(slot)); 131 __func__, slot_name(slot));
131 goto disable_error; 132 goto disable_error;
@@ -141,9 +142,11 @@ disable_slot(struct hotplug_slot *hotplug_slot)
141 } 142 }
142 cpci_led_on(slot); 143 cpci_led_on(slot);
143 144
144 if (controller->ops->set_power) 145 if (controller->ops->set_power) {
145 if ((retval = controller->ops->set_power(slot, 0))) 146 retval = controller->ops->set_power(slot, 0);
147 if (retval)
146 goto disable_error; 148 goto disable_error;
149 }
147 150
148 if (update_adapter_status(slot->hotplug_slot, 0)) 151 if (update_adapter_status(slot->hotplug_slot, 0))
149 warn("failure to update adapter file"); 152 warn("failure to update adapter file");
@@ -467,9 +470,9 @@ check_slots(void)
467 __func__, slot_name(slot), hs_csr); 470 __func__, slot_name(slot), hs_csr);
468 471
469 if (!slot->extracting) { 472 if (!slot->extracting) {
470 if (update_latch_status(slot->hotplug_slot, 0)) { 473 if (update_latch_status(slot->hotplug_slot, 0))
471 warn("failure to update latch file"); 474 warn("failure to update latch file");
472 } 475
473 slot->extracting = 1; 476 slot->extracting = 1;
474 atomic_inc(&extracting); 477 atomic_inc(&extracting);
475 } 478 }
diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
index 04fcd7811400..66b7bbebe493 100644
--- a/drivers/pci/hotplug/cpcihp_generic.c
+++ b/drivers/pci/hotplug/cpcihp_generic.c
@@ -56,7 +56,7 @@
56 if (debug) \ 56 if (debug) \
57 printk (KERN_DEBUG "%s: " format "\n", \ 57 printk (KERN_DEBUG "%s: " format "\n", \
58 MY_NAME , ## arg); \ 58 MY_NAME , ## arg); \
59 } while(0) 59 } while (0)
60#define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg) 60#define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg)
61#define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg) 61#define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg)
62#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) 62#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg)
@@ -82,28 +82,28 @@ static int __init validate_parameters(void)
82 char *p; 82 char *p;
83 unsigned long tmp; 83 unsigned long tmp;
84 84
85 if(!bridge) { 85 if (!bridge) {
86 info("not configured, disabling."); 86 info("not configured, disabling.");
87 return -EINVAL; 87 return -EINVAL;
88 } 88 }
89 str = bridge; 89 str = bridge;
90 if(!*str) 90 if (!*str)
91 return -EINVAL; 91 return -EINVAL;
92 92
93 tmp = simple_strtoul(str, &p, 16); 93 tmp = simple_strtoul(str, &p, 16);
94 if(p == str || tmp > 0xff) { 94 if (p == str || tmp > 0xff) {
95 err("Invalid hotplug bus bridge device bus number"); 95 err("Invalid hotplug bus bridge device bus number");
96 return -EINVAL; 96 return -EINVAL;
97 } 97 }
98 bridge_busnr = (u8) tmp; 98 bridge_busnr = (u8) tmp;
99 dbg("bridge_busnr = 0x%02x", bridge_busnr); 99 dbg("bridge_busnr = 0x%02x", bridge_busnr);
100 if(*p != ':') { 100 if (*p != ':') {
101 err("Invalid hotplug bus bridge device"); 101 err("Invalid hotplug bus bridge device");
102 return -EINVAL; 102 return -EINVAL;
103 } 103 }
104 str = p + 1; 104 str = p + 1;
105 tmp = simple_strtoul(str, &p, 16); 105 tmp = simple_strtoul(str, &p, 16);
106 if(p == str || tmp > 0x1f) { 106 if (p == str || tmp > 0x1f) {
107 err("Invalid hotplug bus bridge device slot number"); 107 err("Invalid hotplug bus bridge device slot number");
108 return -EINVAL; 108 return -EINVAL;
109 } 109 }
@@ -112,18 +112,18 @@ static int __init validate_parameters(void)
112 112
113 dbg("first_slot = 0x%02x", first_slot); 113 dbg("first_slot = 0x%02x", first_slot);
114 dbg("last_slot = 0x%02x", last_slot); 114 dbg("last_slot = 0x%02x", last_slot);
115 if(!(first_slot && last_slot)) { 115 if (!(first_slot && last_slot)) {
116 err("Need to specify first_slot and last_slot"); 116 err("Need to specify first_slot and last_slot");
117 return -EINVAL; 117 return -EINVAL;
118 } 118 }
119 if(last_slot < first_slot) { 119 if (last_slot < first_slot) {
120 err("first_slot must be less than last_slot"); 120 err("first_slot must be less than last_slot");
121 return -EINVAL; 121 return -EINVAL;
122 } 122 }
123 123
124 dbg("port = 0x%04x", port); 124 dbg("port = 0x%04x", port);
125 dbg("enum_bit = 0x%02x", enum_bit); 125 dbg("enum_bit = 0x%02x", enum_bit);
126 if(enum_bit > 7) { 126 if (enum_bit > 7) {
127 err("Invalid #ENUM bit"); 127 err("Invalid #ENUM bit");
128 return -EINVAL; 128 return -EINVAL;
129 } 129 }
@@ -151,12 +151,12 @@ static int __init cpcihp_generic_init(void)
151 return status; 151 return status;
152 152
153 r = request_region(port, 1, "#ENUM hotswap signal register"); 153 r = request_region(port, 1, "#ENUM hotswap signal register");
154 if(!r) 154 if (!r)
155 return -EBUSY; 155 return -EBUSY;
156 156
157 dev = pci_get_domain_bus_and_slot(0, bridge_busnr, 157 dev = pci_get_domain_bus_and_slot(0, bridge_busnr,
158 PCI_DEVFN(bridge_slot, 0)); 158 PCI_DEVFN(bridge_slot, 0));
159 if(!dev || dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) { 159 if (!dev || dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) {
160 err("Invalid bridge device %s", bridge); 160 err("Invalid bridge device %s", bridge);
161 pci_dev_put(dev); 161 pci_dev_put(dev);
162 return -EINVAL; 162 return -EINVAL;
@@ -169,21 +169,21 @@ static int __init cpcihp_generic_init(void)
169 generic_hpc.ops = &generic_hpc_ops; 169 generic_hpc.ops = &generic_hpc_ops;
170 170
171 status = cpci_hp_register_controller(&generic_hpc); 171 status = cpci_hp_register_controller(&generic_hpc);
172 if(status != 0) { 172 if (status != 0) {
173 err("Could not register cPCI hotplug controller"); 173 err("Could not register cPCI hotplug controller");
174 return -ENODEV; 174 return -ENODEV;
175 } 175 }
176 dbg("registered controller"); 176 dbg("registered controller");
177 177
178 status = cpci_hp_register_bus(bus, first_slot, last_slot); 178 status = cpci_hp_register_bus(bus, first_slot, last_slot);
179 if(status != 0) { 179 if (status != 0) {
180 err("Could not register cPCI hotplug bus"); 180 err("Could not register cPCI hotplug bus");
181 goto init_bus_register_error; 181 goto init_bus_register_error;
182 } 182 }
183 dbg("registered bus"); 183 dbg("registered bus");
184 184
185 status = cpci_hp_start(); 185 status = cpci_hp_start();
186 if(status != 0) { 186 if (status != 0) {
187 err("Could not started cPCI hotplug system"); 187 err("Could not started cPCI hotplug system");
188 goto init_start_error; 188 goto init_start_error;
189 } 189 }
diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
index 6757b3ef7e10..7ecf34e76a61 100644
--- a/drivers/pci/hotplug/cpcihp_zt5550.c
+++ b/drivers/pci/hotplug/cpcihp_zt5550.c
@@ -51,7 +51,7 @@
51 if (debug) \ 51 if (debug) \
52 printk (KERN_DEBUG "%s: " format "\n", \ 52 printk (KERN_DEBUG "%s: " format "\n", \
53 MY_NAME , ## arg); \ 53 MY_NAME , ## arg); \
54 } while(0) 54 } while (0)
55#define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg) 55#define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg)
56#define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg) 56#define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg)
57#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) 57#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg)
@@ -82,13 +82,13 @@ static int zt5550_hc_config(struct pci_dev *pdev)
82 int ret; 82 int ret;
83 83
84 /* Since we know that no boards exist with two HC chips, treat it as an error */ 84 /* Since we know that no boards exist with two HC chips, treat it as an error */
85 if(hc_dev) { 85 if (hc_dev) {
86 err("too many host controller devices?"); 86 err("too many host controller devices?");
87 return -EBUSY; 87 return -EBUSY;
88 } 88 }
89 89
90 ret = pci_enable_device(pdev); 90 ret = pci_enable_device(pdev);
91 if(ret) { 91 if (ret) {
92 err("cannot enable %s\n", pci_name(pdev)); 92 err("cannot enable %s\n", pci_name(pdev));
93 return ret; 93 return ret;
94 } 94 }
@@ -98,7 +98,7 @@ static int zt5550_hc_config(struct pci_dev *pdev)
98 dbg("pci resource start %llx", (unsigned long long)pci_resource_start(hc_dev, 1)); 98 dbg("pci resource start %llx", (unsigned long long)pci_resource_start(hc_dev, 1));
99 dbg("pci resource len %llx", (unsigned long long)pci_resource_len(hc_dev, 1)); 99 dbg("pci resource len %llx", (unsigned long long)pci_resource_len(hc_dev, 1));
100 100
101 if(!request_mem_region(pci_resource_start(hc_dev, 1), 101 if (!request_mem_region(pci_resource_start(hc_dev, 1),
102 pci_resource_len(hc_dev, 1), MY_NAME)) { 102 pci_resource_len(hc_dev, 1), MY_NAME)) {
103 err("cannot reserve MMIO region"); 103 err("cannot reserve MMIO region");
104 ret = -ENOMEM; 104 ret = -ENOMEM;
@@ -107,7 +107,7 @@ static int zt5550_hc_config(struct pci_dev *pdev)
107 107
108 hc_registers = 108 hc_registers =
109 ioremap(pci_resource_start(hc_dev, 1), pci_resource_len(hc_dev, 1)); 109 ioremap(pci_resource_start(hc_dev, 1), pci_resource_len(hc_dev, 1));
110 if(!hc_registers) { 110 if (!hc_registers) {
111 err("cannot remap MMIO region %llx @ %llx", 111 err("cannot remap MMIO region %llx @ %llx",
112 (unsigned long long)pci_resource_len(hc_dev, 1), 112 (unsigned long long)pci_resource_len(hc_dev, 1),
113 (unsigned long long)pci_resource_start(hc_dev, 1)); 113 (unsigned long long)pci_resource_start(hc_dev, 1));
@@ -146,7 +146,7 @@ exit_disable_device:
146 146
147static int zt5550_hc_cleanup(void) 147static int zt5550_hc_cleanup(void)
148{ 148{
149 if(!hc_dev) 149 if (!hc_dev)
150 return -ENODEV; 150 return -ENODEV;
151 151
152 iounmap(hc_registers); 152 iounmap(hc_registers);
@@ -170,9 +170,9 @@ static int zt5550_hc_check_irq(void *dev_id)
170 u8 reg; 170 u8 reg;
171 171
172 ret = 0; 172 ret = 0;
173 if(dev_id == zt5550_hpc.dev_id) { 173 if (dev_id == zt5550_hpc.dev_id) {
174 reg = readb(csr_int_status); 174 reg = readb(csr_int_status);
175 if(reg) 175 if (reg)
176 ret = 1; 176 ret = 1;
177 } 177 }
178 return ret; 178 return ret;
@@ -182,9 +182,9 @@ static int zt5550_hc_enable_irq(void)
182{ 182{
183 u8 reg; 183 u8 reg;
184 184
185 if(hc_dev == NULL) { 185 if (hc_dev == NULL)
186 return -ENODEV; 186 return -ENODEV;
187 } 187
188 reg = readb(csr_int_mask); 188 reg = readb(csr_int_mask);
189 reg = reg & ~ENUM_INT_MASK; 189 reg = reg & ~ENUM_INT_MASK;
190 writeb(reg, csr_int_mask); 190 writeb(reg, csr_int_mask);
@@ -195,9 +195,8 @@ static int zt5550_hc_disable_irq(void)
195{ 195{
196 u8 reg; 196 u8 reg;
197 197
198 if(hc_dev == NULL) { 198 if (hc_dev == NULL)
199 return -ENODEV; 199 return -ENODEV;
200 }
201 200
202 reg = readb(csr_int_mask); 201 reg = readb(csr_int_mask);
203 reg = reg | ENUM_INT_MASK; 202 reg = reg | ENUM_INT_MASK;
@@ -210,15 +209,15 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
210 int status; 209 int status;
211 210
212 status = zt5550_hc_config(pdev); 211 status = zt5550_hc_config(pdev);
213 if(status != 0) { 212 if (status != 0)
214 return status; 213 return status;
215 } 214
216 dbg("returned from zt5550_hc_config"); 215 dbg("returned from zt5550_hc_config");
217 216
218 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller)); 217 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
219 zt5550_hpc_ops.query_enum = zt5550_hc_query_enum; 218 zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
220 zt5550_hpc.ops = &zt5550_hpc_ops; 219 zt5550_hpc.ops = &zt5550_hpc_ops;
221 if(!poll) { 220 if (!poll) {
222 zt5550_hpc.irq = hc_dev->irq; 221 zt5550_hpc.irq = hc_dev->irq;
223 zt5550_hpc.irq_flags = IRQF_SHARED; 222 zt5550_hpc.irq_flags = IRQF_SHARED;
224 zt5550_hpc.dev_id = hc_dev; 223 zt5550_hpc.dev_id = hc_dev;
@@ -231,15 +230,16 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
231 } 230 }
232 231
233 status = cpci_hp_register_controller(&zt5550_hpc); 232 status = cpci_hp_register_controller(&zt5550_hpc);
234 if(status != 0) { 233 if (status != 0) {
235 err("could not register cPCI hotplug controller"); 234 err("could not register cPCI hotplug controller");
236 goto init_hc_error; 235 goto init_hc_error;
237 } 236 }
238 dbg("registered controller"); 237 dbg("registered controller");
239 238
240 /* Look for first device matching cPCI bus's bridge vendor and device IDs */ 239 /* Look for first device matching cPCI bus's bridge vendor and device IDs */
241 if(!(bus0_dev = pci_get_device(PCI_VENDOR_ID_DEC, 240 bus0_dev = pci_get_device(PCI_VENDOR_ID_DEC,
242 PCI_DEVICE_ID_DEC_21154, NULL))) { 241 PCI_DEVICE_ID_DEC_21154, NULL);
242 if (!bus0_dev) {
243 status = -ENODEV; 243 status = -ENODEV;
244 goto init_register_error; 244 goto init_register_error;
245 } 245 }
@@ -247,14 +247,14 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
247 pci_dev_put(bus0_dev); 247 pci_dev_put(bus0_dev);
248 248
249 status = cpci_hp_register_bus(bus0, 0x0a, 0x0f); 249 status = cpci_hp_register_bus(bus0, 0x0a, 0x0f);
250 if(status != 0) { 250 if (status != 0) {
251 err("could not register cPCI hotplug bus"); 251 err("could not register cPCI hotplug bus");
252 goto init_register_error; 252 goto init_register_error;
253 } 253 }
254 dbg("registered bus"); 254 dbg("registered bus");
255 255
256 status = cpci_hp_start(); 256 status = cpci_hp_start();
257 if(status != 0) { 257 if (status != 0) {
258 err("could not started cPCI hotplug system"); 258 err("could not started cPCI hotplug system");
259 cpci_hp_unregister_bus(bus0); 259 cpci_hp_unregister_bus(bus0);
260 goto init_register_error; 260 goto init_register_error;
@@ -300,11 +300,11 @@ static int __init zt5550_init(void)
300 300
301 info(DRIVER_DESC " version: " DRIVER_VERSION); 301 info(DRIVER_DESC " version: " DRIVER_VERSION);
302 r = request_region(ENUM_PORT, 1, "#ENUM hotswap signal register"); 302 r = request_region(ENUM_PORT, 1, "#ENUM hotswap signal register");
303 if(!r) 303 if (!r)
304 return -EBUSY; 304 return -EBUSY;
305 305
306 rc = pci_register_driver(&zt5550_hc_driver); 306 rc = pci_register_driver(&zt5550_hc_driver);
307 if(rc < 0) 307 if (rc < 0)
308 release_region(ENUM_PORT, 1); 308 release_region(ENUM_PORT, 1);
309 return rc; 309 return rc;
310} 310}
diff --git a/drivers/pci/hotplug/cpqphp.h b/drivers/pci/hotplug/cpqphp.h
index 0450f405807d..b28b2d2184cd 100644
--- a/drivers/pci/hotplug/cpqphp.h
+++ b/drivers/pci/hotplug/cpqphp.h
@@ -690,7 +690,7 @@ static inline int cpq_get_latch_status(struct controller *ctrl,
690 690
691 status = (readl(ctrl->hpc_reg + INT_INPUT_CLEAR) & (0x01L << hp_slot)); 691 status = (readl(ctrl->hpc_reg + INT_INPUT_CLEAR) & (0x01L << hp_slot));
692 692
693 return(status == 0) ? 1 : 0; 693 return (status == 0) ? 1 : 0;
694} 694}
695 695
696 696
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c
index 4aaee746df88..a53084ddc118 100644
--- a/drivers/pci/hotplug/cpqphp_core.c
+++ b/drivers/pci/hotplug/cpqphp_core.c
@@ -1096,9 +1096,8 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1096 1096
1097 /* initialize our threads if they haven't already been started up */ 1097 /* initialize our threads if they haven't already been started up */
1098 rc = one_time_init(); 1098 rc = one_time_init();
1099 if (rc) { 1099 if (rc)
1100 goto err_free_bus; 1100 goto err_free_bus;
1101 }
1102 1101
1103 dbg("pdev = %p\n", pdev); 1102 dbg("pdev = %p\n", pdev);
1104 dbg("pci resource start %llx\n", (unsigned long long)pci_resource_start(pdev, 0)); 1103 dbg("pci resource start %llx\n", (unsigned long long)pci_resource_start(pdev, 0));
diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c
index bde47fce3248..c5cbefee5236 100644
--- a/drivers/pci/hotplug/cpqphp_ctrl.c
+++ b/drivers/pci/hotplug/cpqphp_ctrl.c
@@ -705,9 +705,8 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz
705 if (temp == max) { 705 if (temp == max) {
706 *head = max->next; 706 *head = max->next;
707 } else { 707 } else {
708 while (temp && temp->next != max) { 708 while (temp && temp->next != max)
709 temp = temp->next; 709 temp = temp->next;
710 }
711 710
712 if (temp) 711 if (temp)
713 temp->next = max->next; 712 temp->next = max->next;
@@ -903,9 +902,8 @@ irqreturn_t cpqhp_ctrl_intr(int IRQ, void *data)
903 /* 902 /*
904 * Check to see if it was our interrupt 903 * Check to see if it was our interrupt
905 */ 904 */
906 if (!(misc & 0x000C)) { 905 if (!(misc & 0x000C))
907 return IRQ_NONE; 906 return IRQ_NONE;
908 }
909 907
910 if (misc & 0x0004) { 908 if (misc & 0x0004) {
911 /* 909 /*
@@ -1143,7 +1141,7 @@ static u8 set_controller_speed(struct controller *ctrl, u8 adapter_speed, u8 hp_
1143 /* We don't allow freq/mode changes if we find another adapter running 1141 /* We don't allow freq/mode changes if we find another adapter running
1144 * in another slot on this controller 1142 * in another slot on this controller
1145 */ 1143 */
1146 for(slot = ctrl->slot; slot; slot = slot->next) { 1144 for (slot = ctrl->slot; slot; slot = slot->next) {
1147 if (slot->device == (hp_slot + ctrl->slot_device_offset)) 1145 if (slot->device == (hp_slot + ctrl->slot_device_offset))
1148 continue; 1146 continue;
1149 if (!slot->hotplug_slot || !slot->hotplug_slot->info) 1147 if (!slot->hotplug_slot || !slot->hotplug_slot->info)
@@ -1193,7 +1191,7 @@ static u8 set_controller_speed(struct controller *ctrl, u8 adapter_speed, u8 hp_
1193 1191
1194 reg16 = readw(ctrl->hpc_reg + NEXT_CURR_FREQ); 1192 reg16 = readw(ctrl->hpc_reg + NEXT_CURR_FREQ);
1195 reg16 &= ~0x000F; 1193 reg16 &= ~0x000F;
1196 switch(adapter_speed) { 1194 switch (adapter_speed) {
1197 case(PCI_SPEED_133MHz_PCIX): 1195 case(PCI_SPEED_133MHz_PCIX):
1198 reg = 0x75; 1196 reg = 0x75;
1199 reg16 |= 0xB; 1197 reg16 |= 0xB;
@@ -2006,9 +2004,8 @@ int cpqhp_process_SI(struct controller *ctrl, struct pci_func *func)
2006 /* Check to see if the interlock is closed */ 2004 /* Check to see if the interlock is closed */
2007 tempdword = readl(ctrl->hpc_reg + INT_INPUT_CLEAR); 2005 tempdword = readl(ctrl->hpc_reg + INT_INPUT_CLEAR);
2008 2006
2009 if (tempdword & (0x01 << hp_slot)) { 2007 if (tempdword & (0x01 << hp_slot))
2010 return 1; 2008 return 1;
2011 }
2012 2009
2013 if (func->is_a_board) { 2010 if (func->is_a_board) {
2014 rc = board_replaced(func, ctrl); 2011 rc = board_replaced(func, ctrl);
@@ -2070,9 +2067,8 @@ int cpqhp_process_SI(struct controller *ctrl, struct pci_func *func)
2070 } 2067 }
2071 } 2068 }
2072 2069
2073 if (rc) { 2070 if (rc)
2074 dbg("%s: rc = %d\n", __func__, rc); 2071 dbg("%s: rc = %d\n", __func__, rc);
2075 }
2076 2072
2077 if (p_slot) 2073 if (p_slot)
2078 update_slot_info(ctrl, p_slot); 2074 update_slot_info(ctrl, p_slot);
@@ -2095,9 +2091,8 @@ int cpqhp_process_SS(struct controller *ctrl, struct pci_func *func)
2095 device = func->device; 2091 device = func->device;
2096 func = cpqhp_slot_find(ctrl->bus, device, index++); 2092 func = cpqhp_slot_find(ctrl->bus, device, index++);
2097 p_slot = cpqhp_find_slot(ctrl, device); 2093 p_slot = cpqhp_find_slot(ctrl, device);
2098 if (p_slot) { 2094 if (p_slot)
2099 physical_slot = p_slot->number; 2095 physical_slot = p_slot->number;
2100 }
2101 2096
2102 /* Make sure there are no video controllers here */ 2097 /* Make sure there are no video controllers here */
2103 while (func && !rc) { 2098 while (func && !rc) {
diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
index 0968a9bcb345..1e08ff8c229c 100644
--- a/drivers/pci/hotplug/cpqphp_nvram.c
+++ b/drivers/pci/hotplug/cpqphp_nvram.c
@@ -204,9 +204,8 @@ static int load_HRT (void __iomem *rom_start)
204 u8 temp_byte = 0xFF; 204 u8 temp_byte = 0xFF;
205 u32 rc; 205 u32 rc;
206 206
207 if (!check_for_compaq_ROM(rom_start)) { 207 if (!check_for_compaq_ROM(rom_start))
208 return -ENODEV; 208 return -ENODEV;
209 }
210 209
211 available = 1024; 210 available = 1024;
212 211
@@ -250,9 +249,8 @@ static u32 store_HRT (void __iomem *rom_start)
250 249
251 available = 1024; 250 available = 1024;
252 251
253 if (!check_for_compaq_ROM(rom_start)) { 252 if (!check_for_compaq_ROM(rom_start))
254 return(1); 253 return(1);
255 }
256 254
257 buffer = (u32*) evbuffer; 255 buffer = (u32*) evbuffer;
258 256
@@ -427,9 +425,9 @@ static u32 store_HRT (void __iomem *rom_start)
427 425
428void compaq_nvram_init (void __iomem *rom_start) 426void compaq_nvram_init (void __iomem *rom_start)
429{ 427{
430 if (rom_start) { 428 if (rom_start)
431 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR); 429 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
432 } 430
433 dbg("int15 entry = %p\n", compaq_int15_entry_point); 431 dbg("int15 entry = %p\n", compaq_int15_entry_point);
434 432
435 /* initialize our int15 lock */ 433 /* initialize our int15 lock */
@@ -661,9 +659,8 @@ int compaq_nvram_store (void __iomem *rom_start)
661 659
662 if (evbuffer_init) { 660 if (evbuffer_init) {
663 rc = store_HRT(rom_start); 661 rc = store_HRT(rom_start);
664 if (rc) { 662 if (rc)
665 err(msg_unable_to_save); 663 err(msg_unable_to_save);
666 }
667 } 664 }
668 return rc; 665 return rc;
669} 666}
diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c
index f7b8684a7739..3efaf4c38528 100644
--- a/drivers/pci/hotplug/ibmphp_core.c
+++ b/drivers/pci/hotplug/ibmphp_core.c
@@ -1023,7 +1023,8 @@ static int enable_slot(struct hotplug_slot *hs)
1023 debug("ENABLING SLOT........\n"); 1023 debug("ENABLING SLOT........\n");
1024 slot_cur = hs->private; 1024 slot_cur = hs->private;
1025 1025
1026 if ((rc = validate(slot_cur, ENABLE))) { 1026 rc = validate(slot_cur, ENABLE);
1027 if (rc) {
1027 err("validate function failed\n"); 1028 err("validate function failed\n");
1028 goto error_nopower; 1029 goto error_nopower;
1029 } 1030 }
@@ -1199,9 +1200,8 @@ int ibmphp_do_disable_slot(struct slot *slot_cur)
1199 1200
1200 debug("DISABLING SLOT...\n"); 1201 debug("DISABLING SLOT...\n");
1201 1202
1202 if ((slot_cur == NULL) || (slot_cur->ctrl == NULL)) { 1203 if ((slot_cur == NULL) || (slot_cur->ctrl == NULL))
1203 return -ENODEV; 1204 return -ENODEV;
1204 }
1205 1205
1206 flag = slot_cur->flag; 1206 flag = slot_cur->flag;
1207 slot_cur->flag = 1; 1207 slot_cur->flag = 1;
@@ -1336,17 +1336,20 @@ static int __init ibmphp_init(void)
1336 for (i = 0; i < 16; i++) 1336 for (i = 0; i < 16; i++)
1337 irqs[i] = 0; 1337 irqs[i] = 0;
1338 1338
1339 if ((rc = ibmphp_access_ebda())) 1339 rc = ibmphp_access_ebda();
1340 if (rc)
1340 goto error; 1341 goto error;
1341 debug("after ibmphp_access_ebda()\n"); 1342 debug("after ibmphp_access_ebda()\n");
1342 1343
1343 if ((rc = ibmphp_rsrc_init())) 1344 rc = ibmphp_rsrc_init();
1345 if (rc)
1344 goto error; 1346 goto error;
1345 debug("AFTER Resource & EBDA INITIALIZATIONS\n"); 1347 debug("AFTER Resource & EBDA INITIALIZATIONS\n");
1346 1348
1347 max_slots = get_max_slots(); 1349 max_slots = get_max_slots();
1348 1350
1349 if ((rc = ibmphp_register_pci())) 1351 rc = ibmphp_register_pci();
1352 if (rc)
1350 goto error; 1353 goto error;
1351 1354
1352 if (init_ops()) { 1355 if (init_ops()) {
@@ -1355,9 +1358,9 @@ static int __init ibmphp_init(void)
1355 } 1358 }
1356 1359
1357 ibmphp_print_test(); 1360 ibmphp_print_test();
1358 if ((rc = ibmphp_hpc_start_poll_thread())) { 1361 rc = ibmphp_hpc_start_poll_thread();
1362 if (rc)
1359 goto error; 1363 goto error;
1360 }
1361 1364
1362exit: 1365exit:
1363 return rc; 1366 return rc;
diff --git a/drivers/pci/hotplug/ibmphp_ebda.c b/drivers/pci/hotplug/ibmphp_ebda.c
index 0f65ac555434..d9b197d5c6b4 100644
--- a/drivers/pci/hotplug/ibmphp_ebda.c
+++ b/drivers/pci/hotplug/ibmphp_ebda.c
@@ -215,9 +215,8 @@ static void __init print_ebda_hpc (void)
215 debug ("%s - cap of the slot: %x\n", __func__, hpc_ptr->slots[index].slot_cap); 215 debug ("%s - cap of the slot: %x\n", __func__, hpc_ptr->slots[index].slot_cap);
216 } 216 }
217 217
218 for (index = 0; index < hpc_ptr->bus_count; index++) { 218 for (index = 0; index < hpc_ptr->bus_count; index++)
219 debug ("%s - bus# of each bus controlled by this ctlr: %x\n", __func__, hpc_ptr->buses[index].bus_num); 219 debug ("%s - bus# of each bus controlled by this ctlr: %x\n", __func__, hpc_ptr->buses[index].bus_num);
220 }
221 220
222 debug ("%s - type of hpc: %x\n", __func__, hpc_ptr->ctlr_type); 221 debug ("%s - type of hpc: %x\n", __func__, hpc_ptr->ctlr_type);
223 switch (hpc_ptr->ctlr_type) { 222 switch (hpc_ptr->ctlr_type) {
diff --git a/drivers/pci/hotplug/ibmphp_hpc.c b/drivers/pci/hotplug/ibmphp_hpc.c
index a936022956e6..220876715a08 100644
--- a/drivers/pci/hotplug/ibmphp_hpc.c
+++ b/drivers/pci/hotplug/ibmphp_hpc.c
@@ -997,9 +997,8 @@ static int process_changeinstatus (struct slot *pslot, struct slot *poldslot)
997 rc = ibmphp_do_disable_slot (pslot); 997 rc = ibmphp_do_disable_slot (pslot);
998 } 998 }
999 999
1000 if (update || disable) { 1000 if (update || disable)
1001 ibmphp_update_slot_info (pslot); 1001 ibmphp_update_slot_info (pslot);
1002 }
1003 1002
1004 debug ("%s - Exit rc[%d] disable[%x] update[%x]\n", __func__, rc, disable, update); 1003 debug ("%s - Exit rc[%d] disable[%x] update[%x]\n", __func__, rc, disable, update);
1005 1004
diff --git a/drivers/pci/hotplug/ibmphp_pci.c b/drivers/pci/hotplug/ibmphp_pci.c
index 2fd296706ce7..814cea22a9fa 100644
--- a/drivers/pci/hotplug/ibmphp_pci.c
+++ b/drivers/pci/hotplug/ibmphp_pci.c
@@ -145,7 +145,8 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
145 case PCI_HEADER_TYPE_NORMAL: 145 case PCI_HEADER_TYPE_NORMAL:
146 debug ("single device case.... vendor id = %x, hdr_type = %x, class = %x\n", vendor_id, hdr_type, class); 146 debug ("single device case.... vendor id = %x, hdr_type = %x, class = %x\n", vendor_id, hdr_type, class);
147 assign_alt_irq (cur_func, class_code); 147 assign_alt_irq (cur_func, class_code);
148 if ((rc = configure_device (cur_func)) < 0) { 148 rc = configure_device(cur_func);
149 if (rc < 0) {
149 /* We need to do this in case some other BARs were properly inserted */ 150 /* We need to do this in case some other BARs were properly inserted */
150 err ("was not able to configure devfunc %x on bus %x.\n", 151 err ("was not able to configure devfunc %x on bus %x.\n",
151 cur_func->device, cur_func->busno); 152 cur_func->device, cur_func->busno);
@@ -157,7 +158,8 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
157 break; 158 break;
158 case PCI_HEADER_TYPE_MULTIDEVICE: 159 case PCI_HEADER_TYPE_MULTIDEVICE:
159 assign_alt_irq (cur_func, class_code); 160 assign_alt_irq (cur_func, class_code);
160 if ((rc = configure_device (cur_func)) < 0) { 161 rc = configure_device(cur_func);
162 if (rc < 0) {
161 /* We need to do this in case some other BARs were properly inserted */ 163 /* We need to do this in case some other BARs were properly inserted */
162 err ("was not able to configure devfunc %x on bus %x...bailing out\n", 164 err ("was not able to configure devfunc %x on bus %x...bailing out\n",
163 cur_func->device, cur_func->busno); 165 cur_func->device, cur_func->busno);
diff --git a/drivers/pci/hotplug/ibmphp_res.c b/drivers/pci/hotplug/ibmphp_res.c
index f34745abd5b6..219ba8090a37 100644
--- a/drivers/pci/hotplug/ibmphp_res.c
+++ b/drivers/pci/hotplug/ibmphp_res.c
@@ -224,7 +224,8 @@ int __init ibmphp_rsrc_init (void)
224 if ((curr->rsrc_type & RESTYPE) == MMASK) { 224 if ((curr->rsrc_type & RESTYPE) == MMASK) {
225 /* no bus structure exists in place yet */ 225 /* no bus structure exists in place yet */
226 if (list_empty (&gbuses)) { 226 if (list_empty (&gbuses)) {
227 if ((rc = alloc_bus_range (&newbus, &newrange, curr, MEM, 1))) 227 rc = alloc_bus_range(&newbus, &newrange, curr, MEM, 1);
228 if (rc)
228 return rc; 229 return rc;
229 list_add_tail (&newbus->bus_list, &gbuses); 230 list_add_tail (&newbus->bus_list, &gbuses);
230 debug ("gbuses = NULL, Memory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); 231 debug ("gbuses = NULL, Memory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
@@ -237,7 +238,8 @@ int __init ibmphp_rsrc_init (void)
237 return rc; 238 return rc;
238 } else { 239 } else {
239 /* went through all the buses and didn't find ours, need to create a new bus node */ 240 /* went through all the buses and didn't find ours, need to create a new bus node */
240 if ((rc = alloc_bus_range (&newbus, &newrange, curr, MEM, 1))) 241 rc = alloc_bus_range(&newbus, &newrange, curr, MEM, 1);
242 if (rc)
241 return rc; 243 return rc;
242 244
243 list_add_tail (&newbus->bus_list, &gbuses); 245 list_add_tail (&newbus->bus_list, &gbuses);
@@ -248,7 +250,8 @@ int __init ibmphp_rsrc_init (void)
248 /* prefetchable memory */ 250 /* prefetchable memory */
249 if (list_empty (&gbuses)) { 251 if (list_empty (&gbuses)) {
250 /* no bus structure exists in place yet */ 252 /* no bus structure exists in place yet */
251 if ((rc = alloc_bus_range (&newbus, &newrange, curr, PFMEM, 1))) 253 rc = alloc_bus_range(&newbus, &newrange, curr, PFMEM, 1);
254 if (rc)
252 return rc; 255 return rc;
253 list_add_tail (&newbus->bus_list, &gbuses); 256 list_add_tail (&newbus->bus_list, &gbuses);
254 debug ("gbuses = NULL, PFMemory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); 257 debug ("gbuses = NULL, PFMemory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
@@ -261,7 +264,8 @@ int __init ibmphp_rsrc_init (void)
261 return rc; 264 return rc;
262 } else { 265 } else {
263 /* went through all the buses and didn't find ours, need to create a new bus node */ 266 /* went through all the buses and didn't find ours, need to create a new bus node */
264 if ((rc = alloc_bus_range (&newbus, &newrange, curr, PFMEM, 1))) 267 rc = alloc_bus_range(&newbus, &newrange, curr, PFMEM, 1);
268 if (rc)
265 return rc; 269 return rc;
266 list_add_tail (&newbus->bus_list, &gbuses); 270 list_add_tail (&newbus->bus_list, &gbuses);
267 debug ("1st Bus, PFMemory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); 271 debug ("1st Bus, PFMemory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
@@ -271,7 +275,8 @@ int __init ibmphp_rsrc_init (void)
271 /* IO */ 275 /* IO */
272 if (list_empty (&gbuses)) { 276 if (list_empty (&gbuses)) {
273 /* no bus structure exists in place yet */ 277 /* no bus structure exists in place yet */
274 if ((rc = alloc_bus_range (&newbus, &newrange, curr, IO, 1))) 278 rc = alloc_bus_range(&newbus, &newrange, curr, IO, 1);
279 if (rc)
275 return rc; 280 return rc;
276 list_add_tail (&newbus->bus_list, &gbuses); 281 list_add_tail (&newbus->bus_list, &gbuses);
277 debug ("gbuses = NULL, IO Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); 282 debug ("gbuses = NULL, IO Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
@@ -283,7 +288,8 @@ int __init ibmphp_rsrc_init (void)
283 return rc; 288 return rc;
284 } else { 289 } else {
285 /* went through all the buses and didn't find ours, need to create a new bus node */ 290 /* went through all the buses and didn't find ours, need to create a new bus node */
286 if ((rc = alloc_bus_range (&newbus, &newrange, curr, IO, 1))) 291 rc = alloc_bus_range(&newbus, &newrange, curr, IO, 1);
292 if (rc)
287 return rc; 293 return rc;
288 list_add_tail (&newbus->bus_list, &gbuses); 294 list_add_tail (&newbus->bus_list, &gbuses);
289 debug ("1st Bus, IO Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); 295 debug ("1st Bus, IO Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
@@ -1038,7 +1044,9 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
1038 /* found our range */ 1044 /* found our range */
1039 if (!res_prev) { 1045 if (!res_prev) {
1040 /* first time in the loop */ 1046 /* first time in the loop */
1041 if ((res_cur->start != range->start) && ((len_tmp = res_cur->start - 1 - range->start) >= res->len)) { 1047 len_tmp = res_cur->start - 1 - range->start;
1048
1049 if ((res_cur->start != range->start) && (len_tmp >= res->len)) {
1042 debug ("len_tmp = %x\n", len_tmp); 1050 debug ("len_tmp = %x\n", len_tmp);
1043 1051
1044 if ((len_tmp < len_cur) || (len_cur == 0)) { 1052 if ((len_tmp < len_cur) || (len_cur == 0)) {
@@ -1078,7 +1086,9 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
1078 } 1086 }
1079 if (!res_cur->next) { 1087 if (!res_cur->next) {
1080 /* last device on the range */ 1088 /* last device on the range */
1081 if ((range->end != res_cur->end) && ((len_tmp = range->end - (res_cur->end + 1)) >= res->len)) { 1089 len_tmp = range->end - (res_cur->end + 1);
1090
1091 if ((range->end != res_cur->end) && (len_tmp >= res->len)) {
1082 debug ("len_tmp = %x\n", len_tmp); 1092 debug ("len_tmp = %x\n", len_tmp);
1083 if ((len_tmp < len_cur) || (len_cur == 0)) { 1093 if ((len_tmp < len_cur) || (len_cur == 0)) {
1084 1094
@@ -1117,8 +1127,9 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
1117 if (res_prev) { 1127 if (res_prev) {
1118 if (res_prev->rangeno != res_cur->rangeno) { 1128 if (res_prev->rangeno != res_cur->rangeno) {
1119 /* 1st device on this range */ 1129 /* 1st device on this range */
1120 if ((res_cur->start != range->start) && 1130 len_tmp = res_cur->start - 1 - range->start;
1121 ((len_tmp = res_cur->start - 1 - range->start) >= res->len)) { 1131
1132 if ((res_cur->start != range->start) && (len_tmp >= res->len)) {
1122 if ((len_tmp < len_cur) || (len_cur == 0)) { 1133 if ((len_tmp < len_cur) || (len_cur == 0)) {
1123 if ((range->start % tmp_divide) == 0) { 1134 if ((range->start % tmp_divide) == 0) {
1124 /* just perfect, starting address is divisible by length */ 1135 /* just perfect, starting address is divisible by length */
@@ -1153,7 +1164,9 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
1153 } 1164 }
1154 } else { 1165 } else {
1155 /* in the same range */ 1166 /* in the same range */
1156 if ((len_tmp = res_cur->start - 1 - res_prev->end - 1) >= res->len) { 1167 len_tmp = res_cur->start - 1 - res_prev->end - 1;
1168
1169 if (len_tmp >= res->len) {
1157 if ((len_tmp < len_cur) || (len_cur == 0)) { 1170 if ((len_tmp < len_cur) || (len_cur == 0)) {
1158 if (((res_prev->end + 1) % tmp_divide) == 0) { 1171 if (((res_prev->end + 1) % tmp_divide) == 0) {
1159 /* just perfect, starting address's divisible by length */ 1172 /* just perfect, starting address's divisible by length */
@@ -1212,7 +1225,9 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
1212 break; 1225 break;
1213 } 1226 }
1214 while (range) { 1227 while (range) {
1215 if ((len_tmp = range->end - range->start) >= res->len) { 1228 len_tmp = range->end - range->start;
1229
1230 if (len_tmp >= res->len) {
1216 if ((len_tmp < len_cur) || (len_cur == 0)) { 1231 if ((len_tmp < len_cur) || (len_cur == 0)) {
1217 if ((range->start % tmp_divide) == 0) { 1232 if ((range->start % tmp_divide) == 0) {
1218 /* just perfect, starting address's divisible by length */ 1233 /* just perfect, starting address's divisible by length */
@@ -1276,7 +1291,9 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
1276 break; 1291 break;
1277 } 1292 }
1278 while (range) { 1293 while (range) {
1279 if ((len_tmp = range->end - range->start) >= res->len) { 1294 len_tmp = range->end - range->start;
1295
1296 if (len_tmp >= res->len) {
1280 if ((len_tmp < len_cur) || (len_cur == 0)) { 1297 if ((len_tmp < len_cur) || (len_cur == 0)) {
1281 if ((range->start % tmp_divide) == 0) { 1298 if ((range->start % tmp_divide) == 0) {
1282 /* just perfect, starting address's divisible by length */ 1299 /* just perfect, starting address's divisible by length */
@@ -1335,7 +1352,7 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
1335 return -EINVAL; 1352 return -EINVAL;
1336 } 1353 }
1337 } 1354 }
1338 } /* end if(!res_cur) */ 1355 } /* end if (!res_cur) */
1339 return -EINVAL; 1356 return -EINVAL;
1340} 1357}
1341 1358
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index 9e5a9fbb93d7..b11521953485 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -92,7 +92,7 @@ struct controller {
92 struct slot *slot; 92 struct slot *slot;
93 wait_queue_head_t queue; /* sleep & wake process */ 93 wait_queue_head_t queue; /* sleep & wake process */
94 u32 slot_cap; 94 u32 slot_cap;
95 u32 slot_ctrl; 95 u16 slot_ctrl;
96 struct timer_list poll_timer; 96 struct timer_list poll_timer;
97 unsigned long cmd_started; /* jiffies */ 97 unsigned long cmd_started; /* jiffies */
98 unsigned int cmd_busy:1; 98 unsigned int cmd_busy:1;
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index 07aa722bb12c..3a5e7e28b874 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -262,6 +262,13 @@ static int pciehp_probe(struct pcie_device *dev)
262 goto err_out_none; 262 goto err_out_none;
263 } 263 }
264 264
265 if (!dev->port->subordinate) {
266 /* Can happen if we run out of bus numbers during probe */
267 dev_err(&dev->device,
268 "Hotplug bridge without secondary bus, ignoring\n");
269 goto err_out_none;
270 }
271
265 ctrl = pcie_init(dev); 272 ctrl = pcie_init(dev);
266 if (!ctrl) { 273 if (!ctrl) {
267 dev_err(&dev->device, "Controller initialization failed\n"); 274 dev_err(&dev->device, "Controller initialization failed\n");
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index 2a412fa3b338..0ebf754fc177 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -171,9 +171,9 @@ static void pcie_wait_cmd(struct controller *ctrl)
171 * interrupts. 171 * interrupts.
172 */ 172 */
173 if (!rc) 173 if (!rc)
174 ctrl_info(ctrl, "Timeout on hotplug command %#010x (issued %u msec ago)\n", 174 ctrl_info(ctrl, "Timeout on hotplug command %#06x (issued %u msec ago)\n",
175 ctrl->slot_ctrl, 175 ctrl->slot_ctrl,
176 jiffies_to_msecs(now - ctrl->cmd_started)); 176 jiffies_to_msecs(jiffies - ctrl->cmd_started));
177} 177}
178 178
179/** 179/**
@@ -422,9 +422,9 @@ void pciehp_set_attention_status(struct slot *slot, u8 value)
422 default: 422 default:
423 return; 423 return;
424 } 424 }
425 pcie_write_cmd(ctrl, slot_cmd, PCI_EXP_SLTCTL_AIC);
425 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__, 426 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
426 pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, slot_cmd); 427 pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, slot_cmd);
427 pcie_write_cmd(ctrl, slot_cmd, PCI_EXP_SLTCTL_AIC);
428} 428}
429 429
430void pciehp_green_led_on(struct slot *slot) 430void pciehp_green_led_on(struct slot *slot)
@@ -614,6 +614,8 @@ void pcie_enable_notification(struct controller *ctrl)
614 PCI_EXP_SLTCTL_DLLSCE); 614 PCI_EXP_SLTCTL_DLLSCE);
615 615
616 pcie_write_cmd(ctrl, cmd, mask); 616 pcie_write_cmd(ctrl, cmd, mask);
617 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
618 pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, cmd);
617} 619}
618 620
619static void pcie_disable_notification(struct controller *ctrl) 621static void pcie_disable_notification(struct controller *ctrl)
@@ -625,6 +627,8 @@ static void pcie_disable_notification(struct controller *ctrl)
625 PCI_EXP_SLTCTL_HPIE | PCI_EXP_SLTCTL_CCIE | 627 PCI_EXP_SLTCTL_HPIE | PCI_EXP_SLTCTL_CCIE |
626 PCI_EXP_SLTCTL_DLLSCE); 628 PCI_EXP_SLTCTL_DLLSCE);
627 pcie_write_cmd(ctrl, 0, mask); 629 pcie_write_cmd(ctrl, 0, mask);
630 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
631 pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, 0);
628} 632}
629 633
630/* 634/*
@@ -652,6 +656,8 @@ int pciehp_reset_slot(struct slot *slot, int probe)
652 stat_mask |= PCI_EXP_SLTSTA_DLLSC; 656 stat_mask |= PCI_EXP_SLTSTA_DLLSC;
653 657
654 pcie_write_cmd(ctrl, 0, ctrl_mask); 658 pcie_write_cmd(ctrl, 0, ctrl_mask);
659 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
660 pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, 0);
655 if (pciehp_poll_mode) 661 if (pciehp_poll_mode)
656 del_timer_sync(&ctrl->poll_timer); 662 del_timer_sync(&ctrl->poll_timer);
657 663
@@ -659,6 +665,8 @@ int pciehp_reset_slot(struct slot *slot, int probe)
659 665
660 pcie_capability_write_word(pdev, PCI_EXP_SLTSTA, stat_mask); 666 pcie_capability_write_word(pdev, PCI_EXP_SLTSTA, stat_mask);
661 pcie_write_cmd(ctrl, ctrl_mask, ctrl_mask); 667 pcie_write_cmd(ctrl, ctrl_mask, ctrl_mask);
668 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
669 pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, ctrl_mask);
662 if (pciehp_poll_mode) 670 if (pciehp_poll_mode)
663 int_poll_timeout(ctrl->poll_timer.data); 671 int_poll_timeout(ctrl->poll_timer.data);
664 672
@@ -797,9 +805,6 @@ struct controller *pcie_init(struct pcie_device *dev)
797 PCI_EXP_SLTSTA_MRLSC | PCI_EXP_SLTSTA_PDC | 805 PCI_EXP_SLTSTA_MRLSC | PCI_EXP_SLTSTA_PDC |
798 PCI_EXP_SLTSTA_CC | PCI_EXP_SLTSTA_DLLSC); 806 PCI_EXP_SLTSTA_CC | PCI_EXP_SLTSTA_DLLSC);
799 807
800 /* Disable software notification */
801 pcie_disable_notification(ctrl);
802
803 ctrl_info(ctrl, "Slot #%d AttnBtn%c AttnInd%c PwrInd%c PwrCtrl%c MRL%c Interlock%c NoCompl%c LLActRep%c\n", 808 ctrl_info(ctrl, "Slot #%d AttnBtn%c AttnInd%c PwrInd%c PwrCtrl%c MRL%c Interlock%c NoCompl%c LLActRep%c\n",
804 (slot_cap & PCI_EXP_SLTCAP_PSN) >> 19, 809 (slot_cap & PCI_EXP_SLTCAP_PSN) >> 19,
805 FLAG(slot_cap, PCI_EXP_SLTCAP_ABP), 810 FLAG(slot_cap, PCI_EXP_SLTCAP_ABP),
diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c
index 5f871f4c4af1..9e69403be632 100644
--- a/drivers/pci/hotplug/pciehp_pci.c
+++ b/drivers/pci/hotplug/pciehp_pci.c
@@ -65,14 +65,7 @@ int pciehp_configure_device(struct slot *p_slot)
65 pci_hp_add_bridge(dev); 65 pci_hp_add_bridge(dev);
66 66
67 pci_assign_unassigned_bridge_resources(bridge); 67 pci_assign_unassigned_bridge_resources(bridge);
68 68 pcie_bus_configure_settings(parent);
69 list_for_each_entry(dev, &parent->devices, bus_list) {
70 if ((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY)
71 continue;
72
73 pci_configure_slot(dev);
74 }
75
76 pci_bus_add_devices(parent); 69 pci_bus_add_devices(parent);
77 70
78 out: 71 out:
diff --git a/drivers/pci/hotplug/pcihp_slot.c b/drivers/pci/hotplug/pcihp_slot.c
deleted file mode 100644
index 3e36ec8d708a..000000000000
--- a/drivers/pci/hotplug/pcihp_slot.c
+++ /dev/null
@@ -1,176 +0,0 @@
1/*
2 * Copyright (C) 1995,2001 Compaq Computer Corporation
3 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
4 * Copyright (C) 2001 IBM Corp.
5 * Copyright (C) 2003-2004 Intel Corporation
6 * (c) Copyright 2009 Hewlett-Packard Development Company, L.P.
7 *
8 * All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or (at
13 * your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
18 * NON INFRINGEMENT. See the GNU General Public License for more
19 * details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */
25
26#include <linux/pci.h>
27#include <linux/export.h>
28#include <linux/pci_hotplug.h>
29
30static struct hpp_type0 pci_default_type0 = {
31 .revision = 1,
32 .cache_line_size = 8,
33 .latency_timer = 0x40,
34 .enable_serr = 0,
35 .enable_perr = 0,
36};
37
38static void program_hpp_type0(struct pci_dev *dev, struct hpp_type0 *hpp)
39{
40 u16 pci_cmd, pci_bctl;
41
42 if (!hpp) {
43 /*
44 * Perhaps we *should* use default settings for PCIe, but
45 * pciehp didn't, so we won't either.
46 */
47 if (pci_is_pcie(dev))
48 return;
49 hpp = &pci_default_type0;
50 }
51
52 if (hpp->revision > 1) {
53 dev_warn(&dev->dev,
54 "PCI settings rev %d not supported; using defaults\n",
55 hpp->revision);
56 hpp = &pci_default_type0;
57 }
58
59 pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, hpp->cache_line_size);
60 pci_write_config_byte(dev, PCI_LATENCY_TIMER, hpp->latency_timer);
61 pci_read_config_word(dev, PCI_COMMAND, &pci_cmd);
62 if (hpp->enable_serr)
63 pci_cmd |= PCI_COMMAND_SERR;
64 else
65 pci_cmd &= ~PCI_COMMAND_SERR;
66 if (hpp->enable_perr)
67 pci_cmd |= PCI_COMMAND_PARITY;
68 else
69 pci_cmd &= ~PCI_COMMAND_PARITY;
70 pci_write_config_word(dev, PCI_COMMAND, pci_cmd);
71
72 /* Program bridge control value */
73 if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
74 pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER,
75 hpp->latency_timer);
76 pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &pci_bctl);
77 if (hpp->enable_serr)
78 pci_bctl |= PCI_BRIDGE_CTL_SERR;
79 else
80 pci_bctl &= ~PCI_BRIDGE_CTL_SERR;
81 if (hpp->enable_perr)
82 pci_bctl |= PCI_BRIDGE_CTL_PARITY;
83 else
84 pci_bctl &= ~PCI_BRIDGE_CTL_PARITY;
85 pci_write_config_word(dev, PCI_BRIDGE_CONTROL, pci_bctl);
86 }
87}
88
89static void program_hpp_type1(struct pci_dev *dev, struct hpp_type1 *hpp)
90{
91 if (hpp)
92 dev_warn(&dev->dev, "PCI-X settings not supported\n");
93}
94
95static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp)
96{
97 int pos;
98 u32 reg32;
99
100 if (!hpp)
101 return;
102
103 if (hpp->revision > 1) {
104 dev_warn(&dev->dev, "PCIe settings rev %d not supported\n",
105 hpp->revision);
106 return;
107 }
108
109 /* Initialize Device Control Register */
110 pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL,
111 ~hpp->pci_exp_devctl_and, hpp->pci_exp_devctl_or);
112
113 /* Initialize Link Control Register */
114 if (dev->subordinate)
115 pcie_capability_clear_and_set_word(dev, PCI_EXP_LNKCTL,
116 ~hpp->pci_exp_lnkctl_and, hpp->pci_exp_lnkctl_or);
117
118 /* Find Advanced Error Reporting Enhanced Capability */
119 pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
120 if (!pos)
121 return;
122
123 /* Initialize Uncorrectable Error Mask Register */
124 pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, &reg32);
125 reg32 = (reg32 & hpp->unc_err_mask_and) | hpp->unc_err_mask_or;
126 pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, reg32);
127
128 /* Initialize Uncorrectable Error Severity Register */
129 pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_SEVER, &reg32);
130 reg32 = (reg32 & hpp->unc_err_sever_and) | hpp->unc_err_sever_or;
131 pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_SEVER, reg32);
132
133 /* Initialize Correctable Error Mask Register */
134 pci_read_config_dword(dev, pos + PCI_ERR_COR_MASK, &reg32);
135 reg32 = (reg32 & hpp->cor_err_mask_and) | hpp->cor_err_mask_or;
136 pci_write_config_dword(dev, pos + PCI_ERR_COR_MASK, reg32);
137
138 /* Initialize Advanced Error Capabilities and Control Register */
139 pci_read_config_dword(dev, pos + PCI_ERR_CAP, &reg32);
140 reg32 = (reg32 & hpp->adv_err_cap_and) | hpp->adv_err_cap_or;
141 pci_write_config_dword(dev, pos + PCI_ERR_CAP, reg32);
142
143 /*
144 * FIXME: The following two registers are not supported yet.
145 *
146 * o Secondary Uncorrectable Error Severity Register
147 * o Secondary Uncorrectable Error Mask Register
148 */
149}
150
151void pci_configure_slot(struct pci_dev *dev)
152{
153 struct pci_dev *cdev;
154 struct hotplug_params hpp;
155
156 if (!(dev->hdr_type == PCI_HEADER_TYPE_NORMAL ||
157 (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE &&
158 (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI)))
159 return;
160
161 pcie_bus_configure_settings(dev->bus);
162
163 memset(&hpp, 0, sizeof(hpp));
164 pci_get_hp_params(dev, &hpp);
165
166 program_hpp_type2(dev, hpp.t2);
167 program_hpp_type1(dev, hpp.t1);
168 program_hpp_type0(dev, hpp.t0);
169
170 if (dev->subordinate) {
171 list_for_each_entry(cdev, &dev->subordinate->devices,
172 bus_list)
173 pci_configure_slot(cdev);
174 }
175}
176EXPORT_SYMBOL_GPL(pci_configure_slot);
diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
index a81fb67ea9a1..10c7927599b3 100644
--- a/drivers/pci/hotplug/shpchp_ctrl.c
+++ b/drivers/pci/hotplug/shpchp_ctrl.c
@@ -195,7 +195,8 @@ static int change_bus_speed(struct controller *ctrl, struct slot *p_slot,
195 int rc = 0; 195 int rc = 0;
196 196
197 ctrl_dbg(ctrl, "Change speed to %d\n", speed); 197 ctrl_dbg(ctrl, "Change speed to %d\n", speed);
198 if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, speed))) { 198 rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, speed);
199 if (rc) {
199 ctrl_err(ctrl, "%s: Issue of set bus speed mode command failed\n", 200 ctrl_err(ctrl, "%s: Issue of set bus speed mode command failed\n",
200 __func__); 201 __func__);
201 return WRONG_BUS_FREQUENCY; 202 return WRONG_BUS_FREQUENCY;
@@ -261,14 +262,16 @@ static int board_added(struct slot *p_slot)
261 } 262 }
262 263
263 if ((ctrl->pci_dev->vendor == 0x8086) && (ctrl->pci_dev->device == 0x0332)) { 264 if ((ctrl->pci_dev->vendor == 0x8086) && (ctrl->pci_dev->device == 0x0332)) {
264 if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, PCI_SPEED_33MHz))) { 265 rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, PCI_SPEED_33MHz);
266 if (rc) {
265 ctrl_err(ctrl, "%s: Issue of set bus speed mode command failed\n", 267 ctrl_err(ctrl, "%s: Issue of set bus speed mode command failed\n",
266 __func__); 268 __func__);
267 return WRONG_BUS_FREQUENCY; 269 return WRONG_BUS_FREQUENCY;
268 } 270 }
269 271
270 /* turn on board, blink green LED, turn off Amber LED */ 272 /* turn on board, blink green LED, turn off Amber LED */
271 if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) { 273 rc = p_slot->hpc_ops->slot_enable(p_slot);
274 if (rc) {
272 ctrl_err(ctrl, "Issue of Slot Enable command failed\n"); 275 ctrl_err(ctrl, "Issue of Slot Enable command failed\n");
273 return rc; 276 return rc;
274 } 277 }
@@ -296,7 +299,8 @@ static int board_added(struct slot *p_slot)
296 return rc; 299 return rc;
297 300
298 /* turn on board, blink green LED, turn off Amber LED */ 301 /* turn on board, blink green LED, turn off Amber LED */
299 if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) { 302 rc = p_slot->hpc_ops->slot_enable(p_slot);
303 if (rc) {
300 ctrl_err(ctrl, "Issue of Slot Enable command failed\n"); 304 ctrl_err(ctrl, "Issue of Slot Enable command failed\n");
301 return rc; 305 return rc;
302 } 306 }
@@ -595,7 +599,7 @@ static int shpchp_enable_slot (struct slot *p_slot)
595 ctrl_dbg(ctrl, "%s: p_slot->pwr_save %x\n", __func__, p_slot->pwr_save); 599 ctrl_dbg(ctrl, "%s: p_slot->pwr_save %x\n", __func__, p_slot->pwr_save);
596 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 600 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
597 601
598 if(((p_slot->ctrl->pci_dev->vendor == PCI_VENDOR_ID_AMD) || 602 if (((p_slot->ctrl->pci_dev->vendor == PCI_VENDOR_ID_AMD) ||
599 (p_slot->ctrl->pci_dev->device == PCI_DEVICE_ID_AMD_POGO_7458)) 603 (p_slot->ctrl->pci_dev->device == PCI_DEVICE_ID_AMD_POGO_7458))
600 && p_slot->ctrl->num_slots == 1) { 604 && p_slot->ctrl->num_slots == 1) {
601 /* handle amd pogo errata; this must be done before enable */ 605 /* handle amd pogo errata; this must be done before enable */
diff --git a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c
index 29e22352822c..7d223e9080ef 100644
--- a/drivers/pci/hotplug/shpchp_hpc.c
+++ b/drivers/pci/hotplug/shpchp_hpc.c
@@ -466,7 +466,8 @@ static int hpc_get_adapter_speed(struct slot *slot, enum pci_bus_speed *value)
466 u8 m66_cap = !!(slot_reg & MHZ66_CAP); 466 u8 m66_cap = !!(slot_reg & MHZ66_CAP);
467 u8 pi, pcix_cap; 467 u8 pi, pcix_cap;
468 468
469 if ((retval = hpc_get_prog_int(slot, &pi))) 469 retval = hpc_get_prog_int(slot, &pi);
470 if (retval)
470 return retval; 471 return retval;
471 472
472 switch (pi) { 473 switch (pi) {
@@ -798,7 +799,7 @@ static irqreturn_t shpc_isr(int irq, void *dev_id)
798 799
799 ctrl_dbg(ctrl, "%s: intr_loc = %x\n", __func__, intr_loc); 800 ctrl_dbg(ctrl, "%s: intr_loc = %x\n", __func__, intr_loc);
800 801
801 if(!shpchp_poll_mode) { 802 if (!shpchp_poll_mode) {
802 /* 803 /*
803 * Mask Global Interrupt Mask - see implementation 804 * Mask Global Interrupt Mask - see implementation
804 * note on p. 139 of SHPC spec rev 1.0 805 * note on p. 139 of SHPC spec rev 1.0
diff --git a/drivers/pci/hotplug/shpchp_pci.c b/drivers/pci/hotplug/shpchp_pci.c
index 469454e0cc48..f8cd3a27e351 100644
--- a/drivers/pci/hotplug/shpchp_pci.c
+++ b/drivers/pci/hotplug/shpchp_pci.c
@@ -69,13 +69,7 @@ int shpchp_configure_device(struct slot *p_slot)
69 } 69 }
70 70
71 pci_assign_unassigned_bridge_resources(bridge); 71 pci_assign_unassigned_bridge_resources(bridge);
72 72 pcie_bus_configure_settings(parent);
73 list_for_each_entry(dev, &parent->devices, bus_list) {
74 if (PCI_SLOT(dev->devfn) != p_slot->device)
75 continue;
76 pci_configure_slot(dev);
77 }
78
79 pci_bus_add_devices(parent); 73 pci_bus_add_devices(parent);
80 74
81 out: 75 out: