aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/pci_root.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-11-14 00:02:00 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-11-14 00:02:00 -0500
commit2f466d33f5f60542d3d82c0477de5863b22c94b9 (patch)
tree839972958941d55852a9af270b04af09e3147116 /drivers/acpi/pci_root.c
parentf9300eaaac1ca300083ad41937923a90cc3a2394 (diff)
parenteaaeb1cb33310dea6c3fa45d8bfc63e5a1d0a846 (diff)
Merge tag 'pci-v3.13-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci
Pull PCI changes from Bjorn Helgaas: "Resource management - Fix host bridge window coalescing (Alexey Neyman) - Pass type, width, and prefetchability for window alignment (Wei Yang) PCI device hotplug - Convert acpiphp, acpiphp_ibm to dynamic debug (Lan Tianyu) Power management - Remove pci_pm_complete() (Liu Chuansheng) MSI - Fail initialization if device is not in PCI_D0 (Yijing Wang) MPS (Max Payload Size) - Use pcie_get_mps() and pcie_set_mps() to simplify code (Yijing Wang) - Use pcie_set_readrq() to simplify code (Yijing Wang) - Use cached pci_dev->pcie_mpss to simplify code (Yijing Wang) SR-IOV - Enable upstream bridges even for VFs on virtual buses (Bjorn Helgaas) - Use pci_is_root_bus() to avoid catching virtual buses (Wei Yang) Virtualization - Add x86 MSI masking ops (Konrad Rzeszutek Wilk) Freescale i.MX6 - Support i.MX6 PCIe controller (Sean Cross) - Increase link startup timeout (Marek Vasut) - Probe PCIe in fs_initcall() (Marek Vasut) - Fix imprecise abort handler (Tim Harvey) - Remove redundant of_match_ptr (Sachin Kamat) Renesas R-Car - Support Gen2 internal PCIe controller (Valentine Barshak) Samsung Exynos - Add MSI support (Jingoo Han) - Turn off power when link fails (Jingoo Han) - Add Jingoo Han as maintainer (Jingoo Han) - Add clk_disable_unprepare() on error path (Wei Yongjun) - Remove redundant of_match_ptr (Sachin Kamat) Synopsys DesignWare - Add irq_create_mapping() (Pratyush Anand) - Add header guards (Seungwon Jeon) Miscellaneous - Enable native PCIe services by default on non-ACPI (Andrew Murray) - Cleanup _OSC usage and messages (Bjorn Helgaas) - Remove pcibios_last_bus boot option on non-x86 (Bjorn Helgaas) - Convert bus code to use bus_, drv_, and dev_groups (Greg Kroah-Hartman) - Remove unused pci_mem_start (Myron Stowe) - Make sysfs functions static (Sachin Kamat) - Warn on invalid return from driver probe (Stephen M. Cameron) - Remove Intel Haswell D3 delays (Todd E Brandt) - Call pci_set_master() in core if driver doesn't do it (Yinghai Lu) - Use pci_is_pcie() to simplify code (Yijing Wang) - Use PCIe capability accessors to simplify code (Yijing Wang) - Use cached pci_dev->pcie_cap to simplify code (Yijing Wang) - Removed unused "is_pcie" from struct pci_dev (Yijing Wang) - Simplify sysfs CPU affinity implementation (Yijing Wang)" * tag 'pci-v3.13-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (79 commits) PCI: Enable upstream bridges even for VFs on virtual buses PCI: Add pci_upstream_bridge() PCI: Add x86_msi.msi_mask_irq() and msix_mask_irq() PCI: Warn on driver probe return value greater than zero PCI: Drop warning about drivers that don't use pci_set_master() PCI: Workaround missing pci_set_master in pci drivers powerpc/pci: Use pci_is_pcie() to simplify code [fix] PCI: Update pcie_ports 'auto' behavior for non-ACPI platforms PCI: imx6: Probe the PCIe in fs_initcall() PCI: Add R-Car Gen2 internal PCI support PCI: imx6: Remove redundant of_match_ptr PCI: Report pci_pme_active() kmalloc failure mn10300/PCI: Remove useless pcibios_last_bus frv/PCI: Remove pcibios_last_bus PCI: imx6: Increase link startup timeout PCI: exynos: Remove redundant of_match_ptr PCI: imx6: Fix imprecise abort handler PCI: Fail MSI/MSI-X initialization if device is not in PCI_D0 PCI: imx6: Remove redundant dev_err() in imx6_pcie_probe() x86/PCI: Coalesce multiple overlapping host bridge windows ...
Diffstat (limited to 'drivers/acpi/pci_root.c')
-rw-r--r--drivers/acpi/pci_root.c246
1 files changed, 148 insertions, 98 deletions
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 417876bce854..56f05869b08d 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -51,10 +51,10 @@ static int acpi_pci_root_add(struct acpi_device *device,
51 const struct acpi_device_id *not_used); 51 const struct acpi_device_id *not_used);
52static void acpi_pci_root_remove(struct acpi_device *device); 52static void acpi_pci_root_remove(struct acpi_device *device);
53 53
54#define ACPI_PCIE_REQ_SUPPORT (OSC_EXT_PCI_CONFIG_SUPPORT \ 54#define ACPI_PCIE_REQ_SUPPORT (OSC_PCI_EXT_CONFIG_SUPPORT \
55 | OSC_ACTIVE_STATE_PWR_SUPPORT \ 55 | OSC_PCI_ASPM_SUPPORT \
56 | OSC_CLOCK_PWR_CAPABILITY_SUPPORT \ 56 | OSC_PCI_CLOCK_PM_SUPPORT \
57 | OSC_MSI_SUPPORT) 57 | OSC_PCI_MSI_SUPPORT)
58 58
59static const struct acpi_device_id root_device_ids[] = { 59static const struct acpi_device_id root_device_ids[] = {
60 {"PNP0A03", 0}, 60 {"PNP0A03", 0},
@@ -129,6 +129,55 @@ static acpi_status try_get_root_bridge_busnr(acpi_handle handle,
129 return AE_OK; 129 return AE_OK;
130} 130}
131 131
132struct pci_osc_bit_struct {
133 u32 bit;
134 char *desc;
135};
136
137static struct pci_osc_bit_struct pci_osc_support_bit[] = {
138 { OSC_PCI_EXT_CONFIG_SUPPORT, "ExtendedConfig" },
139 { OSC_PCI_ASPM_SUPPORT, "ASPM" },
140 { OSC_PCI_CLOCK_PM_SUPPORT, "ClockPM" },
141 { OSC_PCI_SEGMENT_GROUPS_SUPPORT, "Segments" },
142 { OSC_PCI_MSI_SUPPORT, "MSI" },
143};
144
145static struct pci_osc_bit_struct pci_osc_control_bit[] = {
146 { OSC_PCI_EXPRESS_NATIVE_HP_CONTROL, "PCIeHotplug" },
147 { OSC_PCI_SHPC_NATIVE_HP_CONTROL, "SHPCHotplug" },
148 { OSC_PCI_EXPRESS_PME_CONTROL, "PME" },
149 { OSC_PCI_EXPRESS_AER_CONTROL, "AER" },
150 { OSC_PCI_EXPRESS_CAPABILITY_CONTROL, "PCIeCapability" },
151};
152
153static void decode_osc_bits(struct acpi_pci_root *root, char *msg, u32 word,
154 struct pci_osc_bit_struct *table, int size)
155{
156 char buf[80];
157 int i, len = 0;
158 struct pci_osc_bit_struct *entry;
159
160 buf[0] = '\0';
161 for (i = 0, entry = table; i < size; i++, entry++)
162 if (word & entry->bit)
163 len += snprintf(buf + len, sizeof(buf) - len, "%s%s",
164 len ? " " : "", entry->desc);
165
166 dev_info(&root->device->dev, "_OSC: %s [%s]\n", msg, buf);
167}
168
169static void decode_osc_support(struct acpi_pci_root *root, char *msg, u32 word)
170{
171 decode_osc_bits(root, msg, word, pci_osc_support_bit,
172 ARRAY_SIZE(pci_osc_support_bit));
173}
174
175static void decode_osc_control(struct acpi_pci_root *root, char *msg, u32 word)
176{
177 decode_osc_bits(root, msg, word, pci_osc_control_bit,
178 ARRAY_SIZE(pci_osc_control_bit));
179}
180
132static u8 pci_osc_uuid_str[] = "33DB4D5B-1FF7-401C-9657-7441C03DD766"; 181static u8 pci_osc_uuid_str[] = "33DB4D5B-1FF7-401C-9657-7441C03DD766";
133 182
134static acpi_status acpi_pci_run_osc(acpi_handle handle, 183static acpi_status acpi_pci_run_osc(acpi_handle handle,
@@ -160,14 +209,14 @@ static acpi_status acpi_pci_query_osc(struct acpi_pci_root *root,
160 support &= OSC_PCI_SUPPORT_MASKS; 209 support &= OSC_PCI_SUPPORT_MASKS;
161 support |= root->osc_support_set; 210 support |= root->osc_support_set;
162 211
163 capbuf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE; 212 capbuf[OSC_QUERY_DWORD] = OSC_QUERY_ENABLE;
164 capbuf[OSC_SUPPORT_TYPE] = support; 213 capbuf[OSC_SUPPORT_DWORD] = support;
165 if (control) { 214 if (control) {
166 *control &= OSC_PCI_CONTROL_MASKS; 215 *control &= OSC_PCI_CONTROL_MASKS;
167 capbuf[OSC_CONTROL_TYPE] = *control | root->osc_control_set; 216 capbuf[OSC_CONTROL_DWORD] = *control | root->osc_control_set;
168 } else { 217 } else {
169 /* Run _OSC query only with existing controls. */ 218 /* Run _OSC query only with existing controls. */
170 capbuf[OSC_CONTROL_TYPE] = root->osc_control_set; 219 capbuf[OSC_CONTROL_DWORD] = root->osc_control_set;
171 } 220 }
172 221
173 status = acpi_pci_run_osc(root->device->handle, capbuf, &result); 222 status = acpi_pci_run_osc(root->device->handle, capbuf, &result);
@@ -182,11 +231,7 @@ static acpi_status acpi_pci_query_osc(struct acpi_pci_root *root,
182static acpi_status acpi_pci_osc_support(struct acpi_pci_root *root, u32 flags) 231static acpi_status acpi_pci_osc_support(struct acpi_pci_root *root, u32 flags)
183{ 232{
184 acpi_status status; 233 acpi_status status;
185 acpi_handle tmp;
186 234
187 status = acpi_get_handle(root->device->handle, "_OSC", &tmp);
188 if (ACPI_FAILURE(status))
189 return status;
190 mutex_lock(&osc_lock); 235 mutex_lock(&osc_lock);
191 status = acpi_pci_query_osc(root, flags, NULL); 236 status = acpi_pci_query_osc(root, flags, NULL);
192 mutex_unlock(&osc_lock); 237 mutex_unlock(&osc_lock);
@@ -318,9 +363,8 @@ EXPORT_SYMBOL_GPL(acpi_get_pci_dev);
318acpi_status acpi_pci_osc_control_set(acpi_handle handle, u32 *mask, u32 req) 363acpi_status acpi_pci_osc_control_set(acpi_handle handle, u32 *mask, u32 req)
319{ 364{
320 struct acpi_pci_root *root; 365 struct acpi_pci_root *root;
321 acpi_status status; 366 acpi_status status = AE_OK;
322 u32 ctrl, capbuf[3]; 367 u32 ctrl, capbuf[3];
323 acpi_handle tmp;
324 368
325 if (!mask) 369 if (!mask)
326 return AE_BAD_PARAMETER; 370 return AE_BAD_PARAMETER;
@@ -333,10 +377,6 @@ acpi_status acpi_pci_osc_control_set(acpi_handle handle, u32 *mask, u32 req)
333 if (!root) 377 if (!root)
334 return AE_NOT_EXIST; 378 return AE_NOT_EXIST;
335 379
336 status = acpi_get_handle(handle, "_OSC", &tmp);
337 if (ACPI_FAILURE(status))
338 return status;
339
340 mutex_lock(&osc_lock); 380 mutex_lock(&osc_lock);
341 381
342 *mask = ctrl | root->osc_control_set; 382 *mask = ctrl | root->osc_control_set;
@@ -351,17 +391,21 @@ acpi_status acpi_pci_osc_control_set(acpi_handle handle, u32 *mask, u32 req)
351 goto out; 391 goto out;
352 if (ctrl == *mask) 392 if (ctrl == *mask)
353 break; 393 break;
394 decode_osc_control(root, "platform does not support",
395 ctrl & ~(*mask));
354 ctrl = *mask; 396 ctrl = *mask;
355 } 397 }
356 398
357 if ((ctrl & req) != req) { 399 if ((ctrl & req) != req) {
400 decode_osc_control(root, "not requesting control; platform does not support",
401 req & ~(ctrl));
358 status = AE_SUPPORT; 402 status = AE_SUPPORT;
359 goto out; 403 goto out;
360 } 404 }
361 405
362 capbuf[OSC_QUERY_TYPE] = 0; 406 capbuf[OSC_QUERY_DWORD] = 0;
363 capbuf[OSC_SUPPORT_TYPE] = root->osc_support_set; 407 capbuf[OSC_SUPPORT_DWORD] = root->osc_support_set;
364 capbuf[OSC_CONTROL_TYPE] = ctrl; 408 capbuf[OSC_CONTROL_DWORD] = ctrl;
365 status = acpi_pci_run_osc(handle, capbuf, mask); 409 status = acpi_pci_run_osc(handle, capbuf, mask);
366 if (ACPI_SUCCESS(status)) 410 if (ACPI_SUCCESS(status))
367 root->osc_control_set = *mask; 411 root->osc_control_set = *mask;
@@ -371,6 +415,87 @@ out:
371} 415}
372EXPORT_SYMBOL(acpi_pci_osc_control_set); 416EXPORT_SYMBOL(acpi_pci_osc_control_set);
373 417
418static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm,
419 int *clear_aspm)
420{
421 u32 support, control, requested;
422 acpi_status status;
423 struct acpi_device *device = root->device;
424 acpi_handle handle = device->handle;
425
426 /*
427 * All supported architectures that use ACPI have support for
428 * PCI domains, so we indicate this in _OSC support capabilities.
429 */
430 support = OSC_PCI_SEGMENT_GROUPS_SUPPORT;
431 if (pci_ext_cfg_avail())
432 support |= OSC_PCI_EXT_CONFIG_SUPPORT;
433 if (pcie_aspm_support_enabled())
434 support |= OSC_PCI_ASPM_SUPPORT | OSC_PCI_CLOCK_PM_SUPPORT;
435 if (pci_msi_enabled())
436 support |= OSC_PCI_MSI_SUPPORT;
437
438 decode_osc_support(root, "OS supports", support);
439 status = acpi_pci_osc_support(root, support);
440 if (ACPI_FAILURE(status)) {
441 dev_info(&device->dev, "_OSC failed (%s); disabling ASPM\n",
442 acpi_format_exception(status));
443 *no_aspm = 1;
444 return;
445 }
446
447 if (pcie_ports_disabled) {
448 dev_info(&device->dev, "PCIe port services disabled; not requesting _OSC control\n");
449 return;
450 }
451
452 if ((support & ACPI_PCIE_REQ_SUPPORT) != ACPI_PCIE_REQ_SUPPORT) {
453 decode_osc_support(root, "not requesting OS control; OS requires",
454 ACPI_PCIE_REQ_SUPPORT);
455 return;
456 }
457
458 control = OSC_PCI_EXPRESS_CAPABILITY_CONTROL
459 | OSC_PCI_EXPRESS_NATIVE_HP_CONTROL
460 | OSC_PCI_EXPRESS_PME_CONTROL;
461
462 if (pci_aer_available()) {
463 if (aer_acpi_firmware_first())
464 dev_info(&device->dev,
465 "PCIe AER handled by firmware\n");
466 else
467 control |= OSC_PCI_EXPRESS_AER_CONTROL;
468 }
469
470 requested = control;
471 status = acpi_pci_osc_control_set(handle, &control,
472 OSC_PCI_EXPRESS_CAPABILITY_CONTROL);
473 if (ACPI_SUCCESS(status)) {
474 decode_osc_control(root, "OS now controls", control);
475 if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) {
476 /*
477 * We have ASPM control, but the FADT indicates
478 * that it's unsupported. Clear it.
479 */
480 *clear_aspm = 1;
481 }
482 } else {
483 decode_osc_control(root, "OS requested", requested);
484 decode_osc_control(root, "platform willing to grant", control);
485 dev_info(&device->dev, "_OSC failed (%s); disabling ASPM\n",
486 acpi_format_exception(status));
487
488 /*
489 * We want to disable ASPM here, but aspm_disabled
490 * needs to remain in its state from boot so that we
491 * properly handle PCIe 1.1 devices. So we set this
492 * flag here, to defer the action until after the ACPI
493 * root scan.
494 */
495 *no_aspm = 1;
496 }
497}
498
374static int acpi_pci_root_add(struct acpi_device *device, 499static int acpi_pci_root_add(struct acpi_device *device,
375 const struct acpi_device_id *not_used) 500 const struct acpi_device_id *not_used)
376{ 501{
@@ -378,9 +503,8 @@ static int acpi_pci_root_add(struct acpi_device *device,
378 acpi_status status; 503 acpi_status status;
379 int result; 504 int result;
380 struct acpi_pci_root *root; 505 struct acpi_pci_root *root;
381 u32 flags, base_flags;
382 acpi_handle handle = device->handle; 506 acpi_handle handle = device->handle;
383 bool no_aspm = false, clear_aspm = false; 507 int no_aspm = 0, clear_aspm = 0;
384 508
385 root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); 509 root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
386 if (!root) 510 if (!root)
@@ -433,81 +557,7 @@ static int acpi_pci_root_add(struct acpi_device *device,
433 557
434 root->mcfg_addr = acpi_pci_root_get_mcfg_addr(handle); 558 root->mcfg_addr = acpi_pci_root_get_mcfg_addr(handle);
435 559
436 /* 560 negotiate_os_control(root, &no_aspm, &clear_aspm);
437 * All supported architectures that use ACPI have support for
438 * PCI domains, so we indicate this in _OSC support capabilities.
439 */
440 flags = base_flags = OSC_PCI_SEGMENT_GROUPS_SUPPORT;
441 acpi_pci_osc_support(root, flags);
442
443 if (pci_ext_cfg_avail())
444 flags |= OSC_EXT_PCI_CONFIG_SUPPORT;
445 if (pcie_aspm_support_enabled()) {
446 flags |= OSC_ACTIVE_STATE_PWR_SUPPORT |
447 OSC_CLOCK_PWR_CAPABILITY_SUPPORT;
448 }
449 if (pci_msi_enabled())
450 flags |= OSC_MSI_SUPPORT;
451 if (flags != base_flags) {
452 status = acpi_pci_osc_support(root, flags);
453 if (ACPI_FAILURE(status)) {
454 dev_info(&device->dev, "ACPI _OSC support "
455 "notification failed, disabling PCIe ASPM\n");
456 no_aspm = true;
457 flags = base_flags;
458 }
459 }
460
461 if (!pcie_ports_disabled
462 && (flags & ACPI_PCIE_REQ_SUPPORT) == ACPI_PCIE_REQ_SUPPORT) {
463 flags = OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL
464 | OSC_PCI_EXPRESS_NATIVE_HP_CONTROL
465 | OSC_PCI_EXPRESS_PME_CONTROL;
466
467 if (pci_aer_available()) {
468 if (aer_acpi_firmware_first())
469 dev_dbg(&device->dev,
470 "PCIe errors handled by BIOS.\n");
471 else
472 flags |= OSC_PCI_EXPRESS_AER_CONTROL;
473 }
474
475 dev_info(&device->dev,
476 "Requesting ACPI _OSC control (0x%02x)\n", flags);
477
478 status = acpi_pci_osc_control_set(handle, &flags,
479 OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
480 if (ACPI_SUCCESS(status)) {
481 dev_info(&device->dev,
482 "ACPI _OSC control (0x%02x) granted\n", flags);
483 if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) {
484 /*
485 * We have ASPM control, but the FADT indicates
486 * that it's unsupported. Clear it.
487 */
488 clear_aspm = true;
489 }
490 } else {
491 dev_info(&device->dev,
492 "ACPI _OSC request failed (%s), "
493 "returned control mask: 0x%02x\n",
494 acpi_format_exception(status), flags);
495 dev_info(&device->dev,
496 "ACPI _OSC control for PCIe not granted, disabling ASPM\n");
497 /*
498 * We want to disable ASPM here, but aspm_disabled
499 * needs to remain in its state from boot so that we
500 * properly handle PCIe 1.1 devices. So we set this
501 * flag here, to defer the action until after the ACPI
502 * root scan.
503 */
504 no_aspm = true;
505 }
506 } else {
507 dev_info(&device->dev,
508 "Unable to request _OSC control "
509 "(_OSC support mask: 0x%02x)\n", flags);
510 }
511 561
512 /* 562 /*
513 * TBD: Need PCI interface for enumeration/configuration of roots. 563 * TBD: Need PCI interface for enumeration/configuration of roots.