Commit e81995bb1c0077a312cb621abc406a36f65a986a

Authored by Bjorn Helgaas
Committed by Jesse Barnes
1 parent 11876e52e9

PCI hotplug: acpiphp: use generic pci_configure_slot()

Use the generic pci_configure_slot() rather than the acpiphp-specific
decode_hpp() and program_hpp().

Unlike the previous acpiphp-specific code, pci_configure_slot() programs
PCIe settings when an _HPX method provides them, so acpiphp-managed PCIe
devices can now be configured.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Reviewed-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Acked-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>

Showing 3 changed files with 7 additions and 87 deletions Side-by-side Diff

drivers/pci/hotplug/acpi_pcihp.c
... ... @@ -322,13 +322,12 @@
322 322 return status;
323 323 }
324 324  
325   -/* acpi_get_hp_params_from_firmware
  325 +/* pci_get_hp_params
326 326 *
327 327 * @dev - the pci_dev for which we want parameters
328 328 * @hpp - allocated by the caller
329 329 */
330   -int acpi_get_hp_params_from_firmware(struct pci_dev *dev,
331   - struct hotplug_params *hpp)
  330 +int pci_get_hp_params(struct pci_dev *dev, struct hotplug_params *hpp)
332 331 {
333 332 acpi_status status;
334 333 acpi_handle handle, phandle;
... ... @@ -345,7 +344,7 @@
345 344 * _HPP settings apply to all child buses, until another _HPP is
346 345 * encountered. If we don't find an _HPP for the input pci dev,
347 346 * look for it in the parent device scope since that would apply to
348   - * this pci dev. If we don't find any _HPP, use hardcoded defaults
  347 + * this pci dev.
349 348 */
350 349 while (handle) {
351 350 status = acpi_run_hpx(handle, hpp);
... ... @@ -363,7 +362,7 @@
363 362 }
364 363 return -ENODEV;
365 364 }
366   -EXPORT_SYMBOL_GPL(acpi_get_hp_params_from_firmware);
  365 +EXPORT_SYMBOL_GPL(pci_get_hp_params);
367 366  
368 367 /**
369 368 * acpi_get_hp_hw_control_from_firmware
drivers/pci/hotplug/acpiphp_glue.c
... ... @@ -271,29 +271,6 @@
271 271 return found;
272 272 }
273 273  
274   -
275   -/* decode ACPI 2.0 _HPP hot plug parameters */
276   -static void decode_hpp(struct pci_dev *dev, struct hotplug_params *hpp)
277   -{
278   - int ret;
279   -
280   - ret = acpi_get_hp_params_from_firmware(dev, hpp);
281   - if (ret || !hpp->t0 || (hpp->t0->revision > 1)) {
282   - /* use default numbers */
283   - printk(KERN_WARNING
284   - "%s: Could not get hotplug parameters. Use defaults\n",
285   - __func__);
286   - hpp->t0 = &hpp->type0_data;
287   - hpp->t0->revision = 0;
288   - hpp->t0->cache_line_size = 0x10;
289   - hpp->t0->latency_timer = 0x40;
290   - hpp->t0->enable_serr = 0;
291   - hpp->t0->enable_perr = 0;
292   - }
293   -}
294   -
295   -
296   -
297 274 /* initialize miscellaneous stuff for both root and PCI-to-PCI bridge */
298 275 static void init_bridge_misc(struct acpiphp_bridge *bridge)
299 276 {
300 277  
301 278  
... ... @@ -1247,66 +1224,12 @@
1247 1224 return retval;
1248 1225 }
1249 1226  
1250   -static void program_hpp(struct pci_dev *dev, struct hotplug_params *hpp)
1251   -{
1252   - u16 pci_cmd, pci_bctl;
1253   - struct pci_dev *cdev;
1254   -
1255   - /* Program hpp values for this device */
1256   - if (!(dev->hdr_type == PCI_HEADER_TYPE_NORMAL ||
1257   - (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE &&
1258   - (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI)))
1259   - return;
1260   -
1261   - if ((dev->class >> 8) == PCI_CLASS_BRIDGE_HOST)
1262   - return;
1263   -
1264   - pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE,
1265   - hpp->t0->cache_line_size);
1266   - pci_write_config_byte(dev, PCI_LATENCY_TIMER,
1267   - hpp->t0->latency_timer);
1268   - pci_read_config_word(dev, PCI_COMMAND, &pci_cmd);
1269   - if (hpp->t0->enable_serr)
1270   - pci_cmd |= PCI_COMMAND_SERR;
1271   - else
1272   - pci_cmd &= ~PCI_COMMAND_SERR;
1273   - if (hpp->t0->enable_perr)
1274   - pci_cmd |= PCI_COMMAND_PARITY;
1275   - else
1276   - pci_cmd &= ~PCI_COMMAND_PARITY;
1277   - pci_write_config_word(dev, PCI_COMMAND, pci_cmd);
1278   -
1279   - /* Program bridge control value and child devices */
1280   - if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
1281   - pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER,
1282   - hpp->t0->latency_timer);
1283   - pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &pci_bctl);
1284   - if (hpp->t0->enable_serr)
1285   - pci_bctl |= PCI_BRIDGE_CTL_SERR;
1286   - else
1287   - pci_bctl &= ~PCI_BRIDGE_CTL_SERR;
1288   - if (hpp->t0->enable_perr)
1289   - pci_bctl |= PCI_BRIDGE_CTL_PARITY;
1290   - else
1291   - pci_bctl &= ~PCI_BRIDGE_CTL_PARITY;
1292   - pci_write_config_word(dev, PCI_BRIDGE_CONTROL, pci_bctl);
1293   - if (dev->subordinate) {
1294   - list_for_each_entry(cdev, &dev->subordinate->devices,
1295   - bus_list)
1296   - program_hpp(cdev, hpp);
1297   - }
1298   - }
1299   -}
1300   -
1301 1227 static void acpiphp_set_hpp_values(struct pci_bus *bus)
1302 1228 {
1303 1229 struct pci_dev *dev;
1304   - struct hotplug_params hpp;
1305 1230  
1306   - list_for_each_entry(dev, &bus->devices, bus_list) {
1307   - decode_hpp(dev, &hpp);
1308   - program_hpp(dev, &hpp);
1309   - }
  1231 + list_for_each_entry(dev, &bus->devices, bus_list)
  1232 + pci_configure_slot(dev);
1310 1233 }
1311 1234  
1312 1235 /*
include/linux/pci_hotplug.h
... ... @@ -227,12 +227,10 @@
227 227 #ifdef CONFIG_ACPI
228 228 #include <acpi/acpi.h>
229 229 #include <acpi/acpi_bus.h>
230   -int acpi_get_hp_params_from_firmware(struct pci_dev *dev,
231   - struct hotplug_params *hpp);
  230 +int pci_get_hp_params(struct pci_dev *dev, struct hotplug_params *hpp);
232 231 int acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev, u32 flags);
233 232 int acpi_pci_check_ejectable(struct pci_bus *pbus, acpi_handle handle);
234 233 int acpi_pci_detect_ejectable(acpi_handle handle);
235   -#define pci_get_hp_params(dev, hpp) acpi_get_hp_params_from_firmware(dev, hpp)
236 234 #else
237 235 static inline int pci_get_hp_params(struct pci_dev *dev,
238 236 struct hotplug_params *hpp)