Skip to content

Commit d56557a

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6: PCI: bus speed strings should be const PCI hotplug: Fix build with CONFIG_ACPI unset PCI: PCIe: Remove the port driver module exit routine PCI: PCIe: Move PCIe PME code to the pcie directory PCI: PCIe: Disable PCIe port services during port initialization PCI: PCIe: Ask BIOS for control of all native services at once ACPI/PCI: Negotiate _OSC control bits before requesting them ACPI/PCI: Do not preserve _OSC control bits returned by a query ACPI/PCI: Make acpi_pci_query_osc() return control bits ACPI/PCI: Reorder checks in acpi_pci_osc_control_set() PCI: PCIe: Introduce commad line switch for disabling port services PCI: PCIe AER: Introduce pci_aer_available() x86/PCI: only define pci_domain_nr if PCI and PCI_DOMAINS are set PCI: provide stub pci_domain_nr function for !CONFIG_PCI configs
2 parents fa2925c + 17134d9 commit d56557a

File tree

24 files changed

+281
-291
lines changed

24 files changed

+281
-291
lines changed

Documentation/kernel-parameters.txt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,15 +1974,18 @@ and is between 256 and 4096 characters. It is defined in the file
19741974
force Enable ASPM even on devices that claim not to support it.
19751975
WARNING: Forcing ASPM on may cause system lockups.
19761976

1977+
pcie_ports= [PCIE] PCIe ports handling:
1978+
auto Ask the BIOS whether or not to use native PCIe services
1979+
associated with PCIe ports (PME, hot-plug, AER). Use
1980+
them only if that is allowed by the BIOS.
1981+
native Use native PCIe services associated with PCIe ports
1982+
unconditionally.
1983+
compat Treat PCIe ports as PCI-to-PCI bridges, disable the PCIe
1984+
ports driver.
1985+
19771986
pcie_pme= [PCIE,PM] Native PCIe PME signaling options:
1978-
Format: {auto|force}[,nomsi]
1979-
auto Use native PCIe PME signaling if the BIOS allows the
1980-
kernel to control PCIe config registers of root ports.
1981-
force Use native PCIe PME signaling even if the BIOS refuses
1982-
to allow the kernel to control the relevant PCIe config
1983-
registers.
19841987
nomsi Do not use MSI for native PCIe PME signaling (this makes
1985-
all PCIe root ports use INTx for everything).
1988+
all PCIe root ports use INTx for all services).
19861989

19871990
pcmv= [HW,PCMCIA] BadgePAD 4
19881991

arch/x86/include/asm/pci.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ extern struct pci_bus *pci_scan_bus_on_node(int busno, struct pci_ops *ops,
2727
int node);
2828
extern struct pci_bus *pci_scan_bus_with_sysdata(int busno);
2929

30+
#ifdef CONFIG_PCI
31+
32+
#ifdef CONFIG_PCI_DOMAINS
3033
static inline int pci_domain_nr(struct pci_bus *bus)
3134
{
3235
struct pci_sysdata *sd = bus->sysdata;
@@ -37,13 +40,12 @@ static inline int pci_proc_domain(struct pci_bus *bus)
3740
{
3841
return pci_domain_nr(bus);
3942
}
40-
43+
#endif
4144

4245
/* Can be used to override the logic in pci_scan_bus for skipping
4346
already-configured bus numbers - to be used for buggy BIOSes
4447
or architectures with incomplete PCI setup by the loader */
4548

46-
#ifdef CONFIG_PCI
4749
extern unsigned int pcibios_assign_all_busses(void);
4850
extern int pci_legacy_init(void);
4951
# ifdef CONFIG_ACPI

drivers/acpi/pci_root.c

Lines changed: 56 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include <linux/pm_runtime.h>
3434
#include <linux/pci.h>
3535
#include <linux/pci-acpi.h>
36-
#include <linux/pci-aspm.h>
3736
#include <linux/acpi.h>
3837
#include <linux/slab.h>
3938
#include <acpi/acpi_bus.h>
@@ -226,22 +225,31 @@ static acpi_status acpi_pci_run_osc(acpi_handle handle,
226225
return status;
227226
}
228227

229-
static acpi_status acpi_pci_query_osc(struct acpi_pci_root *root, u32 flags)
228+
static acpi_status acpi_pci_query_osc(struct acpi_pci_root *root,
229+
u32 support,
230+
u32 *control)
230231
{
231232
acpi_status status;
232-
u32 support_set, result, capbuf[3];
233+
u32 result, capbuf[3];
234+
235+
support &= OSC_PCI_SUPPORT_MASKS;
236+
support |= root->osc_support_set;
233237

234-
/* do _OSC query for all possible controls */
235-
support_set = root->osc_support_set | (flags & OSC_PCI_SUPPORT_MASKS);
236238
capbuf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE;
237-
capbuf[OSC_SUPPORT_TYPE] = support_set;
238-
capbuf[OSC_CONTROL_TYPE] = OSC_PCI_CONTROL_MASKS;
239+
capbuf[OSC_SUPPORT_TYPE] = support;
240+
if (control) {
241+
*control &= OSC_PCI_CONTROL_MASKS;
242+
capbuf[OSC_CONTROL_TYPE] = *control | root->osc_control_set;
243+
} else {
244+
/* Run _OSC query for all possible controls. */
245+
capbuf[OSC_CONTROL_TYPE] = OSC_PCI_CONTROL_MASKS;
246+
}
239247

240248
status = acpi_pci_run_osc(root->device->handle, capbuf, &result);
241249
if (ACPI_SUCCESS(status)) {
242-
root->osc_support_set = support_set;
243-
root->osc_control_qry = result;
244-
root->osc_queried = 1;
250+
root->osc_support_set = support;
251+
if (control)
252+
*control = result;
245253
}
246254
return status;
247255
}
@@ -255,7 +263,7 @@ static acpi_status acpi_pci_osc_support(struct acpi_pci_root *root, u32 flags)
255263
if (ACPI_FAILURE(status))
256264
return status;
257265
mutex_lock(&osc_lock);
258-
status = acpi_pci_query_osc(root, flags);
266+
status = acpi_pci_query_osc(root, flags, NULL);
259267
mutex_unlock(&osc_lock);
260268
return status;
261269
}
@@ -365,55 +373,70 @@ struct pci_dev *acpi_get_pci_dev(acpi_handle handle)
365373
EXPORT_SYMBOL_GPL(acpi_get_pci_dev);
366374

367375
/**
368-
* acpi_pci_osc_control_set - commit requested control to Firmware
369-
* @handle: acpi_handle for the target ACPI object
370-
* @flags: driver's requested control bits
376+
* acpi_pci_osc_control_set - Request control of PCI root _OSC features.
377+
* @handle: ACPI handle of a PCI root bridge (or PCIe Root Complex).
378+
* @mask: Mask of _OSC bits to request control of, place to store control mask.
379+
* @req: Mask of _OSC bits the control of is essential to the caller.
380+
*
381+
* Run _OSC query for @mask and if that is successful, compare the returned
382+
* mask of control bits with @req. If all of the @req bits are set in the
383+
* returned mask, run _OSC request for it.
371384
*
372-
* Attempt to take control from Firmware on requested control bits.
385+
* The variable at the @mask address may be modified regardless of whether or
386+
* not the function returns success. On success it will contain the mask of
387+
* _OSC bits the BIOS has granted control of, but its contents are meaningless
388+
* on failure.
373389
**/
374-
acpi_status acpi_pci_osc_control_set(acpi_handle handle, u32 flags)
390+
acpi_status acpi_pci_osc_control_set(acpi_handle handle, u32 *mask, u32 req)
375391
{
392+
struct acpi_pci_root *root;
376393
acpi_status status;
377-
u32 control_req, result, capbuf[3];
394+
u32 ctrl, capbuf[3];
378395
acpi_handle tmp;
379-
struct acpi_pci_root *root;
380396

381-
status = acpi_get_handle(handle, "_OSC", &tmp);
382-
if (ACPI_FAILURE(status))
383-
return status;
397+
if (!mask)
398+
return AE_BAD_PARAMETER;
384399

385-
control_req = (flags & OSC_PCI_CONTROL_MASKS);
386-
if (!control_req)
400+
ctrl = *mask & OSC_PCI_CONTROL_MASKS;
401+
if ((ctrl & req) != req)
387402
return AE_TYPE;
388403

389404
root = acpi_pci_find_root(handle);
390405
if (!root)
391406
return AE_NOT_EXIST;
392407

408+
status = acpi_get_handle(handle, "_OSC", &tmp);
409+
if (ACPI_FAILURE(status))
410+
return status;
411+
393412
mutex_lock(&osc_lock);
413+
414+
*mask = ctrl | root->osc_control_set;
394415
/* No need to evaluate _OSC if the control was already granted. */
395-
if ((root->osc_control_set & control_req) == control_req)
416+
if ((root->osc_control_set & ctrl) == ctrl)
396417
goto out;
397418

398-
/* Need to query controls first before requesting them */
399-
if (!root->osc_queried) {
400-
status = acpi_pci_query_osc(root, root->osc_support_set);
419+
/* Need to check the available controls bits before requesting them. */
420+
while (*mask) {
421+
status = acpi_pci_query_osc(root, root->osc_support_set, mask);
401422
if (ACPI_FAILURE(status))
402423
goto out;
424+
if (ctrl == *mask)
425+
break;
426+
ctrl = *mask;
403427
}
404-
if ((root->osc_control_qry & control_req) != control_req) {
405-
printk(KERN_DEBUG
406-
"Firmware did not grant requested _OSC control\n");
428+
429+
if ((ctrl & req) != req) {
407430
status = AE_SUPPORT;
408431
goto out;
409432
}
410433

411434
capbuf[OSC_QUERY_TYPE] = 0;
412435
capbuf[OSC_SUPPORT_TYPE] = root->osc_support_set;
413-
capbuf[OSC_CONTROL_TYPE] = root->osc_control_set | control_req;
414-
status = acpi_pci_run_osc(handle, capbuf, &result);
436+
capbuf[OSC_CONTROL_TYPE] = ctrl;
437+
status = acpi_pci_run_osc(handle, capbuf, mask);
415438
if (ACPI_SUCCESS(status))
416-
root->osc_control_set = result;
439+
root->osc_control_set = *mask;
417440
out:
418441
mutex_unlock(&osc_lock);
419442
return status;
@@ -544,14 +567,6 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
544567
if (flags != base_flags)
545568
acpi_pci_osc_support(root, flags);
546569

547-
status = acpi_pci_osc_control_set(root->device->handle,
548-
OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
549-
550-
if (ACPI_FAILURE(status)) {
551-
printk(KERN_INFO "Unable to assume PCIe control: Disabling ASPM\n");
552-
pcie_no_aspm();
553-
}
554-
555570
pci_acpi_add_bus_pm_notifier(device, root->bus);
556571
if (device->wakeup.flags.run_wake)
557572
device_set_run_wake(root->bus->bridge, true);

drivers/pci/hotplug/acpi_pcihp.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,7 @@ int acpi_get_hp_hw_control_from_firmware(struct pci_dev *pdev, u32 flags)
338338
acpi_handle chandle, handle;
339339
struct acpi_buffer string = { ACPI_ALLOCATE_BUFFER, NULL };
340340

341-
flags &= (OSC_PCI_EXPRESS_NATIVE_HP_CONTROL |
342-
OSC_SHPC_NATIVE_HP_CONTROL |
343-
OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
341+
flags &= OSC_SHPC_NATIVE_HP_CONTROL;
344342
if (!flags) {
345343
err("Invalid flags %u specified!\n", flags);
346344
return -EINVAL;
@@ -360,7 +358,7 @@ int acpi_get_hp_hw_control_from_firmware(struct pci_dev *pdev, u32 flags)
360358
acpi_get_name(handle, ACPI_FULL_PATHNAME, &string);
361359
dbg("Trying to get hotplug control for %s\n",
362360
(char *)string.pointer);
363-
status = acpi_pci_osc_control_set(handle, flags);
361+
status = acpi_pci_osc_control_set(handle, &flags, flags);
364362
if (ACPI_SUCCESS(status))
365363
goto got_one;
366364
if (status == AE_SUPPORT)

drivers/pci/hotplug/pciehp.h

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -176,19 +176,11 @@ static inline void pciehp_firmware_init(void)
176176
{
177177
pciehp_acpi_slot_detection_init();
178178
}
179-
180-
static inline int pciehp_get_hp_hw_control_from_firmware(struct pci_dev *dev)
181-
{
182-
int retval;
183-
u32 flags = (OSC_PCI_EXPRESS_NATIVE_HP_CONTROL |
184-
OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
185-
retval = acpi_get_hp_hw_control_from_firmware(dev, flags);
186-
if (retval)
187-
return retval;
188-
return pciehp_acpi_slot_detection_check(dev);
189-
}
190179
#else
191180
#define pciehp_firmware_init() do {} while (0)
192-
#define pciehp_get_hp_hw_control_from_firmware(dev) 0
181+
static inline int pciehp_acpi_slot_detection_check(struct pci_dev *dev)
182+
{
183+
return 0;
184+
}
193185
#endif /* CONFIG_ACPI */
194186
#endif /* _PCIEHP_H */

drivers/pci/hotplug/pciehp_acpi.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ static int __init dummy_probe(struct pcie_device *dev)
8585
acpi_handle handle;
8686
struct dummy_slot *slot, *tmp;
8787
struct pci_dev *pdev = dev->port;
88-
/* Note: pciehp_detect_mode != PCIEHP_DETECT_ACPI here */
89-
if (pciehp_get_hp_hw_control_from_firmware(pdev))
90-
return -ENODEV;
88+
9189
pos = pci_pcie_cap(pdev);
9290
if (!pos)
9391
return -ENODEV;

drivers/pci/hotplug/pciehp_core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module_param(pciehp_force, bool, 0644);
5959
MODULE_PARM_DESC(pciehp_debug, "Debugging mode enabled or not");
6060
MODULE_PARM_DESC(pciehp_poll_mode, "Using polling mechanism for hot-plug events or not");
6161
MODULE_PARM_DESC(pciehp_poll_time, "Polling mechanism frequency, in seconds");
62-
MODULE_PARM_DESC(pciehp_force, "Force pciehp, even if _OSC and OSHP are missing");
62+
MODULE_PARM_DESC(pciehp_force, "Force pciehp, even if OSHP is missing");
6363

6464
#define PCIE_MODULE_NAME "pciehp"
6565

@@ -235,7 +235,7 @@ static int pciehp_probe(struct pcie_device *dev)
235235
dev_info(&dev->device,
236236
"Bypassing BIOS check for pciehp use on %s\n",
237237
pci_name(dev->port));
238-
else if (pciehp_get_hp_hw_control_from_firmware(dev->port))
238+
else if (pciehp_acpi_slot_detection_check(dev->port))
239239
goto err_out_none;
240240

241241
ctrl = pcie_init(dev);

drivers/pci/pci.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,10 @@ static inline void pci_msi_init_pci_dev(struct pci_dev *dev) { }
140140

141141
#ifdef CONFIG_PCIEAER
142142
void pci_no_aer(void);
143+
bool pci_aer_available(void);
143144
#else
144145
static inline void pci_no_aer(void) { }
146+
static inline bool pci_aer_available(void) { return false; }
145147
#endif
146148

147149
static inline int pci_no_d1d2(struct pci_dev *dev)

drivers/pci/pcie/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
obj-$(CONFIG_PCIEASPM) += aspm.o
77

88
pcieportdrv-y := portdrv_core.o portdrv_pci.o portdrv_bus.o
9+
pcieportdrv-$(CONFIG_ACPI) += portdrv_acpi.o
910

1011
obj-$(CONFIG_PCIEPORTBUS) += pcieportdrv.o
1112

1213
# Build PCI Express AER if needed
1314
obj-$(CONFIG_PCIEAER) += aer/
1415

15-
obj-$(CONFIG_PCIE_PME) += pme/
16+
obj-$(CONFIG_PCIE_PME) += pme.o

drivers/pci/pcie/aer/aerdrv.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ void pci_no_aer(void)
7272
pcie_aer_disable = 1; /* has priority over 'forceload' */
7373
}
7474

75+
bool pci_aer_available(void)
76+
{
77+
return !pcie_aer_disable && pci_msi_enabled();
78+
}
79+
7580
static int set_device_error_reporting(struct pci_dev *dev, void *data)
7681
{
7782
bool enable = *((bool *)data);
@@ -411,9 +416,7 @@ static void aer_error_resume(struct pci_dev *dev)
411416
*/
412417
static int __init aer_service_init(void)
413418
{
414-
if (pcie_aer_disable)
415-
return -ENXIO;
416-
if (!pci_msi_enabled())
419+
if (!pci_aer_available())
417420
return -ENXIO;
418421
return pcie_port_service_register(&aerdriver);
419422
}

drivers/pci/pcie/aer/aerdrv_acpi.c

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,42 +19,6 @@
1919
#include <acpi/apei.h>
2020
#include "aerdrv.h"
2121

22-
/**
23-
* aer_osc_setup - run ACPI _OSC method
24-
* @pciedev: pcie_device which AER is being enabled on
25-
*
26-
* @return: Zero on success. Nonzero otherwise.
27-
*
28-
* Invoked when PCIe bus loads AER service driver. To avoid conflict with
29-
* BIOS AER support requires BIOS to yield AER control to OS native driver.
30-
**/
31-
int aer_osc_setup(struct pcie_device *pciedev)
32-
{
33-
acpi_status status = AE_NOT_FOUND;
34-
struct pci_dev *pdev = pciedev->port;
35-
acpi_handle handle = NULL;
36-
37-
if (acpi_pci_disabled)
38-
return -1;
39-
40-
handle = acpi_find_root_bridge_handle(pdev);
41-
if (handle) {
42-
status = acpi_pci_osc_control_set(handle,
43-
OSC_PCI_EXPRESS_AER_CONTROL |
44-
OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
45-
}
46-
47-
if (ACPI_FAILURE(status)) {
48-
dev_printk(KERN_DEBUG, &pciedev->device, "AER service couldn't "
49-
"init device: %s\n",
50-
(status == AE_SUPPORT || status == AE_NOT_FOUND) ?
51-
"no _OSC support" : "_OSC failed");
52-
return -1;
53-
}
54-
55-
return 0;
56-
}
57-
5822
#ifdef CONFIG_ACPI_APEI
5923
static inline int hest_match_pci(struct acpi_hest_aer_common *p,
6024
struct pci_dev *pci)

0 commit comments

Comments
 (0)