diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-08-14 06:19:59 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-08-14 06:19:59 -0400 |
commit | 8d7ccaa545490cdffdfaff0842436a8dd85cf47b (patch) | |
tree | 8129b5907161bc6ae26deb3645ce1e280c5e1f51 /drivers/pci | |
parent | b2139aa0eec330c711c5a279db361e5ef1178e78 (diff) | |
parent | 30a2f3c60a84092c8084dfe788b710f8d0768cd4 (diff) |
Merge commit 'v2.6.27-rc3' into x86/prototypes
Conflicts:
include/asm-x86/dma-mapping.h
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'drivers/pci')
-rw-r--r-- | drivers/pci/dmar.c | 4 | ||||
-rw-r--r-- | drivers/pci/hotplug/acpiphp.h | 4 | ||||
-rw-r--r-- | drivers/pci/hotplug/pciehp_hpc.c | 2 | ||||
-rw-r--r-- | drivers/pci/msi.c | 20 | ||||
-rw-r--r-- | drivers/pci/pci-acpi.c | 7 | ||||
-rw-r--r-- | drivers/pci/pci.c | 45 | ||||
-rw-r--r-- | drivers/pci/pcie/aspm.c | 32 | ||||
-rw-r--r-- | drivers/pci/probe.c | 299 | ||||
-rw-r--r-- | drivers/pci/proc.c | 18 | ||||
-rw-r--r-- | drivers/pci/quirks.c | 20 |
10 files changed, 280 insertions, 171 deletions
diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c index f941f609dbf3..8bf86ae2333f 100644 --- a/drivers/pci/dmar.c +++ b/drivers/pci/dmar.c | |||
@@ -317,10 +317,8 @@ int __init dmar_table_init(void) | |||
317 | return -ENODEV; | 317 | return -ENODEV; |
318 | } | 318 | } |
319 | 319 | ||
320 | if (list_empty(&dmar_rmrr_units)) { | 320 | if (list_empty(&dmar_rmrr_units)) |
321 | printk(KERN_INFO PREFIX "No RMRR found\n"); | 321 | printk(KERN_INFO PREFIX "No RMRR found\n"); |
322 | return -ENODEV; | ||
323 | } | ||
324 | 322 | ||
325 | return 0; | 323 | return 0; |
326 | } | 324 | } |
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h index eecf7cbf4139..5a58b075dd8d 100644 --- a/drivers/pci/hotplug/acpiphp.h +++ b/drivers/pci/hotplug/acpiphp.h | |||
@@ -36,7 +36,7 @@ | |||
36 | #define _ACPIPHP_H | 36 | #define _ACPIPHP_H |
37 | 37 | ||
38 | #include <linux/acpi.h> | 38 | #include <linux/acpi.h> |
39 | #include <linux/kobject.h> /* for KOBJ_NAME_LEN */ | 39 | #include <linux/kobject.h> |
40 | #include <linux/mutex.h> | 40 | #include <linux/mutex.h> |
41 | #include <linux/pci_hotplug.h> | 41 | #include <linux/pci_hotplug.h> |
42 | 42 | ||
@@ -51,7 +51,7 @@ | |||
51 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) | 51 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) |
52 | 52 | ||
53 | /* name size which is used for entries in pcihpfs */ | 53 | /* name size which is used for entries in pcihpfs */ |
54 | #define SLOT_NAME_SIZE KOBJ_NAME_LEN /* {_SUN} */ | 54 | #define SLOT_NAME_SIZE 20 /* {_SUN} */ |
55 | 55 | ||
56 | struct acpiphp_bridge; | 56 | struct acpiphp_bridge; |
57 | struct acpiphp_slot; | 57 | struct acpiphp_slot; |
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 1323a43285d7..ad27e9e225a6 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c | |||
@@ -1103,7 +1103,7 @@ static inline void dbg_ctrl(struct controller *ctrl) | |||
1103 | dbg(" Power Indicator : %3s\n", PWR_LED(ctrl) ? "yes" : "no"); | 1103 | dbg(" Power Indicator : %3s\n", PWR_LED(ctrl) ? "yes" : "no"); |
1104 | dbg(" Hot-Plug Surprise : %3s\n", HP_SUPR_RM(ctrl) ? "yes" : "no"); | 1104 | dbg(" Hot-Plug Surprise : %3s\n", HP_SUPR_RM(ctrl) ? "yes" : "no"); |
1105 | dbg(" EMI Present : %3s\n", EMI(ctrl) ? "yes" : "no"); | 1105 | dbg(" EMI Present : %3s\n", EMI(ctrl) ? "yes" : "no"); |
1106 | dbg(" Comamnd Completed : %3s\n", NO_CMD_CMPL(ctrl)? "no" : "yes"); | 1106 | dbg(" Command Completed : %3s\n", NO_CMD_CMPL(ctrl)? "no" : "yes"); |
1107 | pciehp_readw(ctrl, SLOTSTATUS, ®16); | 1107 | pciehp_readw(ctrl, SLOTSTATUS, ®16); |
1108 | dbg("Slot Status : 0x%04x\n", reg16); | 1108 | dbg("Slot Status : 0x%04x\n", reg16); |
1109 | pciehp_readw(ctrl, SLOTCTRL, ®16); | 1109 | pciehp_readw(ctrl, SLOTCTRL, ®16); |
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 15af618d36e2..4a10b5624f72 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c | |||
@@ -126,7 +126,16 @@ static void msix_flush_writes(unsigned int irq) | |||
126 | } | 126 | } |
127 | } | 127 | } |
128 | 128 | ||
129 | static void msi_set_mask_bits(unsigned int irq, u32 mask, u32 flag) | 129 | /* |
130 | * PCI 2.3 does not specify mask bits for each MSI interrupt. Attempting to | ||
131 | * mask all MSI interrupts by clearing the MSI enable bit does not work | ||
132 | * reliably as devices without an INTx disable bit will then generate a | ||
133 | * level IRQ which will never be cleared. | ||
134 | * | ||
135 | * Returns 1 if it succeeded in masking the interrupt and 0 if the device | ||
136 | * doesn't support MSI masking. | ||
137 | */ | ||
138 | static int msi_set_mask_bits(unsigned int irq, u32 mask, u32 flag) | ||
130 | { | 139 | { |
131 | struct msi_desc *entry; | 140 | struct msi_desc *entry; |
132 | 141 | ||
@@ -144,8 +153,7 @@ static void msi_set_mask_bits(unsigned int irq, u32 mask, u32 flag) | |||
144 | mask_bits |= flag & mask; | 153 | mask_bits |= flag & mask; |
145 | pci_write_config_dword(entry->dev, pos, mask_bits); | 154 | pci_write_config_dword(entry->dev, pos, mask_bits); |
146 | } else { | 155 | } else { |
147 | __msi_set_enable(entry->dev, entry->msi_attrib.pos, | 156 | return 0; |
148 | !flag); | ||
149 | } | 157 | } |
150 | break; | 158 | break; |
151 | case PCI_CAP_ID_MSIX: | 159 | case PCI_CAP_ID_MSIX: |
@@ -161,6 +169,7 @@ static void msi_set_mask_bits(unsigned int irq, u32 mask, u32 flag) | |||
161 | break; | 169 | break; |
162 | } | 170 | } |
163 | entry->msi_attrib.masked = !!flag; | 171 | entry->msi_attrib.masked = !!flag; |
172 | return 1; | ||
164 | } | 173 | } |
165 | 174 | ||
166 | void read_msi_msg(unsigned int irq, struct msi_msg *msg) | 175 | void read_msi_msg(unsigned int irq, struct msi_msg *msg) |
@@ -299,9 +308,8 @@ static void __pci_restore_msi_state(struct pci_dev *dev) | |||
299 | entry->msi_attrib.masked); | 308 | entry->msi_attrib.masked); |
300 | 309 | ||
301 | pci_read_config_word(dev, pos + PCI_MSI_FLAGS, &control); | 310 | pci_read_config_word(dev, pos + PCI_MSI_FLAGS, &control); |
302 | control &= ~(PCI_MSI_FLAGS_QSIZE | PCI_MSI_FLAGS_ENABLE); | 311 | control &= ~PCI_MSI_FLAGS_QSIZE; |
303 | if (entry->msi_attrib.maskbit || !entry->msi_attrib.masked) | 312 | control |= PCI_MSI_FLAGS_ENABLE; |
304 | control |= PCI_MSI_FLAGS_ENABLE; | ||
305 | pci_write_config_word(dev, pos + PCI_MSI_FLAGS, control); | 313 | pci_write_config_word(dev, pos + PCI_MSI_FLAGS, control); |
306 | } | 314 | } |
307 | 315 | ||
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index 7764768b6a0e..89a2f0fa10f9 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/init.h> | 11 | #include <linux/init.h> |
12 | #include <linux/pci.h> | 12 | #include <linux/pci.h> |
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/pci-aspm.h> | ||
14 | #include <acpi/acpi.h> | 15 | #include <acpi/acpi.h> |
15 | #include <acpi/acnamesp.h> | 16 | #include <acpi/acnamesp.h> |
16 | #include <acpi/acresrc.h> | 17 | #include <acpi/acresrc.h> |
@@ -372,6 +373,12 @@ static int __init acpi_pci_init(void) | |||
372 | printk(KERN_INFO"ACPI FADT declares the system doesn't support MSI, so disable it\n"); | 373 | printk(KERN_INFO"ACPI FADT declares the system doesn't support MSI, so disable it\n"); |
373 | pci_no_msi(); | 374 | pci_no_msi(); |
374 | } | 375 | } |
376 | |||
377 | if (acpi_gbl_FADT.boot_flags & BAF_PCIE_ASPM_CONTROL) { | ||
378 | printk(KERN_INFO"ACPI FADT declares the system doesn't support PCIe ASPM, so disable it\n"); | ||
379 | pcie_no_aspm(); | ||
380 | } | ||
381 | |||
375 | ret = register_acpi_bus_type(&acpi_pci_bus); | 382 | ret = register_acpi_bus_type(&acpi_pci_bus); |
376 | if (ret) | 383 | if (ret) |
377 | return 0; | 384 | return 0; |
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index d00f0e0d8453..c9884bba22de 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -572,6 +572,10 @@ int pci_set_power_state(struct pci_dev *dev, pci_power_t state) | |||
572 | if (!ret) | 572 | if (!ret) |
573 | pci_update_current_state(dev); | 573 | pci_update_current_state(dev); |
574 | } | 574 | } |
575 | /* This device is quirked not to be put into D3, so | ||
576 | don't put it in D3 */ | ||
577 | if (state == PCI_D3hot && (dev->dev_flags & PCI_DEV_FLAGS_NO_D3)) | ||
578 | return 0; | ||
575 | 579 | ||
576 | error = pci_raw_set_power_state(dev, state); | 580 | error = pci_raw_set_power_state(dev, state); |
577 | 581 | ||
@@ -1040,7 +1044,7 @@ int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state) | |||
1040 | * @dev: PCI device to handle. | 1044 | * @dev: PCI device to handle. |
1041 | * @state: PCI state from which device will issue PME#. | 1045 | * @state: PCI state from which device will issue PME#. |
1042 | */ | 1046 | */ |
1043 | static bool pci_pme_capable(struct pci_dev *dev, pci_power_t state) | 1047 | bool pci_pme_capable(struct pci_dev *dev, pci_power_t state) |
1044 | { | 1048 | { |
1045 | if (!dev->pm_cap) | 1049 | if (!dev->pm_cap) |
1046 | return false; | 1050 | return false; |
@@ -1056,7 +1060,7 @@ static bool pci_pme_capable(struct pci_dev *dev, pci_power_t state) | |||
1056 | * The caller must verify that the device is capable of generating PME# before | 1060 | * The caller must verify that the device is capable of generating PME# before |
1057 | * calling this function with @enable equal to 'true'. | 1061 | * calling this function with @enable equal to 'true'. |
1058 | */ | 1062 | */ |
1059 | static void pci_pme_active(struct pci_dev *dev, bool enable) | 1063 | void pci_pme_active(struct pci_dev *dev, bool enable) |
1060 | { | 1064 | { |
1061 | u16 pmcsr; | 1065 | u16 pmcsr; |
1062 | 1066 | ||
@@ -1123,17 +1127,16 @@ int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable) | |||
1123 | } | 1127 | } |
1124 | 1128 | ||
1125 | /** | 1129 | /** |
1126 | * pci_prepare_to_sleep - prepare PCI device for system-wide transition into a sleep state | 1130 | * pci_target_state - find an appropriate low power state for a given PCI dev |
1127 | * @dev: Device to handle. | 1131 | * @dev: PCI device |
1128 | * | 1132 | * |
1129 | * Choose the power state appropriate for the device depending on whether | 1133 | * Use underlying platform code to find a supported low power state for @dev. |
1130 | * it can wake up the system and/or is power manageable by the platform | 1134 | * If the platform can't manage @dev, return the deepest state from which it |
1131 | * (PCI_D3hot is the default) and put the device into that state. | 1135 | * can generate wake events, based on any available PME info. |
1132 | */ | 1136 | */ |
1133 | int pci_prepare_to_sleep(struct pci_dev *dev) | 1137 | pci_power_t pci_target_state(struct pci_dev *dev) |
1134 | { | 1138 | { |
1135 | pci_power_t target_state = PCI_D3hot; | 1139 | pci_power_t target_state = PCI_D3hot; |
1136 | int error; | ||
1137 | 1140 | ||
1138 | if (platform_pci_power_manageable(dev)) { | 1141 | if (platform_pci_power_manageable(dev)) { |
1139 | /* | 1142 | /* |
@@ -1160,7 +1163,7 @@ int pci_prepare_to_sleep(struct pci_dev *dev) | |||
1160 | * to generate PME#. | 1163 | * to generate PME#. |
1161 | */ | 1164 | */ |
1162 | if (!dev->pm_cap) | 1165 | if (!dev->pm_cap) |
1163 | return -EIO; | 1166 | return PCI_POWER_ERROR; |
1164 | 1167 | ||
1165 | if (dev->pme_support) { | 1168 | if (dev->pme_support) { |
1166 | while (target_state | 1169 | while (target_state |
@@ -1169,6 +1172,25 @@ int pci_prepare_to_sleep(struct pci_dev *dev) | |||
1169 | } | 1172 | } |
1170 | } | 1173 | } |
1171 | 1174 | ||
1175 | return target_state; | ||
1176 | } | ||
1177 | |||
1178 | /** | ||
1179 | * pci_prepare_to_sleep - prepare PCI device for system-wide transition into a sleep state | ||
1180 | * @dev: Device to handle. | ||
1181 | * | ||
1182 | * Choose the power state appropriate for the device depending on whether | ||
1183 | * it can wake up the system and/or is power manageable by the platform | ||
1184 | * (PCI_D3hot is the default) and put the device into that state. | ||
1185 | */ | ||
1186 | int pci_prepare_to_sleep(struct pci_dev *dev) | ||
1187 | { | ||
1188 | pci_power_t target_state = pci_target_state(dev); | ||
1189 | int error; | ||
1190 | |||
1191 | if (target_state == PCI_POWER_ERROR) | ||
1192 | return -EIO; | ||
1193 | |||
1172 | pci_enable_wake(dev, target_state, true); | 1194 | pci_enable_wake(dev, target_state, true); |
1173 | 1195 | ||
1174 | error = pci_set_power_state(dev, target_state); | 1196 | error = pci_set_power_state(dev, target_state); |
@@ -1918,7 +1940,10 @@ EXPORT_SYMBOL(pci_select_bars); | |||
1918 | EXPORT_SYMBOL(pci_set_power_state); | 1940 | EXPORT_SYMBOL(pci_set_power_state); |
1919 | EXPORT_SYMBOL(pci_save_state); | 1941 | EXPORT_SYMBOL(pci_save_state); |
1920 | EXPORT_SYMBOL(pci_restore_state); | 1942 | EXPORT_SYMBOL(pci_restore_state); |
1943 | EXPORT_SYMBOL(pci_pme_capable); | ||
1944 | EXPORT_SYMBOL(pci_pme_active); | ||
1921 | EXPORT_SYMBOL(pci_enable_wake); | 1945 | EXPORT_SYMBOL(pci_enable_wake); |
1946 | EXPORT_SYMBOL(pci_target_state); | ||
1922 | EXPORT_SYMBOL(pci_prepare_to_sleep); | 1947 | EXPORT_SYMBOL(pci_prepare_to_sleep); |
1923 | EXPORT_SYMBOL(pci_back_from_sleep); | 1948 | EXPORT_SYMBOL(pci_back_from_sleep); |
1924 | EXPORT_SYMBOL_GPL(pci_set_pcie_reset_state); | 1949 | EXPORT_SYMBOL_GPL(pci_set_pcie_reset_state); |
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index f82495583e63..9a7c9e1408a4 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c | |||
@@ -55,7 +55,7 @@ struct pcie_link_state { | |||
55 | struct endpoint_state endpoints[8]; | 55 | struct endpoint_state endpoints[8]; |
56 | }; | 56 | }; |
57 | 57 | ||
58 | static int aspm_disabled; | 58 | static int aspm_disabled, aspm_force; |
59 | static DEFINE_MUTEX(aspm_lock); | 59 | static DEFINE_MUTEX(aspm_lock); |
60 | static LIST_HEAD(link_list); | 60 | static LIST_HEAD(link_list); |
61 | 61 | ||
@@ -510,6 +510,7 @@ static int pcie_aspm_sanity_check(struct pci_dev *pdev) | |||
510 | { | 510 | { |
511 | struct pci_dev *child_dev; | 511 | struct pci_dev *child_dev; |
512 | int child_pos; | 512 | int child_pos; |
513 | u32 reg32; | ||
513 | 514 | ||
514 | /* | 515 | /* |
515 | * Some functions in a slot might not all be PCIE functions, very | 516 | * Some functions in a slot might not all be PCIE functions, very |
@@ -519,6 +520,19 @@ static int pcie_aspm_sanity_check(struct pci_dev *pdev) | |||
519 | child_pos = pci_find_capability(child_dev, PCI_CAP_ID_EXP); | 520 | child_pos = pci_find_capability(child_dev, PCI_CAP_ID_EXP); |
520 | if (!child_pos) | 521 | if (!child_pos) |
521 | return -EINVAL; | 522 | return -EINVAL; |
523 | |||
524 | /* | ||
525 | * Disable ASPM for pre-1.1 PCIe device, we follow MS to use | ||
526 | * RBER bit to determine if a function is 1.1 version device | ||
527 | */ | ||
528 | pci_read_config_dword(child_dev, child_pos + PCI_EXP_DEVCAP, | ||
529 | ®32); | ||
530 | if (!(reg32 & PCI_EXP_DEVCAP_RBER && !aspm_force)) { | ||
531 | printk("Pre-1.1 PCIe device detected, " | ||
532 | "disable ASPM for %s. It can be enabled forcedly" | ||
533 | " with 'pcie_aspm=force'\n", pci_name(pdev)); | ||
534 | return -EINVAL; | ||
535 | } | ||
522 | } | 536 | } |
523 | return 0; | 537 | return 0; |
524 | } | 538 | } |
@@ -802,11 +816,23 @@ void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev) | |||
802 | 816 | ||
803 | static int __init pcie_aspm_disable(char *str) | 817 | static int __init pcie_aspm_disable(char *str) |
804 | { | 818 | { |
805 | aspm_disabled = 1; | 819 | if (!strcmp(str, "off")) { |
820 | aspm_disabled = 1; | ||
821 | printk(KERN_INFO "PCIe ASPM is disabled\n"); | ||
822 | } else if (!strcmp(str, "force")) { | ||
823 | aspm_force = 1; | ||
824 | printk(KERN_INFO "PCIe ASPM is forcedly enabled\n"); | ||
825 | } | ||
806 | return 1; | 826 | return 1; |
807 | } | 827 | } |
808 | 828 | ||
809 | __setup("pcie_noaspm", pcie_aspm_disable); | 829 | __setup("pcie_aspm=", pcie_aspm_disable); |
830 | |||
831 | void pcie_no_aspm(void) | ||
832 | { | ||
833 | if (!aspm_force) | ||
834 | aspm_disabled = 1; | ||
835 | } | ||
810 | 836 | ||
811 | #ifdef CONFIG_ACPI | 837 | #ifdef CONFIG_ACPI |
812 | #include <acpi/acpi_bus.h> | 838 | #include <acpi/acpi_bus.h> |
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index b1724cf31b66..a04498d390c8 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
@@ -52,27 +52,49 @@ EXPORT_SYMBOL(no_pci_devices); | |||
52 | * Some platforms allow access to legacy I/O port and ISA memory space on | 52 | * Some platforms allow access to legacy I/O port and ISA memory space on |
53 | * a per-bus basis. This routine creates the files and ties them into | 53 | * a per-bus basis. This routine creates the files and ties them into |
54 | * their associated read, write and mmap files from pci-sysfs.c | 54 | * their associated read, write and mmap files from pci-sysfs.c |
55 | * | ||
56 | * On error unwind, but don't propogate the error to the caller | ||
57 | * as it is ok to set up the PCI bus without these files. | ||
55 | */ | 58 | */ |
56 | static void pci_create_legacy_files(struct pci_bus *b) | 59 | static void pci_create_legacy_files(struct pci_bus *b) |
57 | { | 60 | { |
61 | int error; | ||
62 | |||
58 | b->legacy_io = kzalloc(sizeof(struct bin_attribute) * 2, | 63 | b->legacy_io = kzalloc(sizeof(struct bin_attribute) * 2, |
59 | GFP_ATOMIC); | 64 | GFP_ATOMIC); |
60 | if (b->legacy_io) { | 65 | if (!b->legacy_io) |
61 | b->legacy_io->attr.name = "legacy_io"; | 66 | goto kzalloc_err; |
62 | b->legacy_io->size = 0xffff; | 67 | |
63 | b->legacy_io->attr.mode = S_IRUSR | S_IWUSR; | 68 | b->legacy_io->attr.name = "legacy_io"; |
64 | b->legacy_io->read = pci_read_legacy_io; | 69 | b->legacy_io->size = 0xffff; |
65 | b->legacy_io->write = pci_write_legacy_io; | 70 | b->legacy_io->attr.mode = S_IRUSR | S_IWUSR; |
66 | device_create_bin_file(&b->dev, b->legacy_io); | 71 | b->legacy_io->read = pci_read_legacy_io; |
67 | 72 | b->legacy_io->write = pci_write_legacy_io; | |
68 | /* Allocated above after the legacy_io struct */ | 73 | error = device_create_bin_file(&b->dev, b->legacy_io); |
69 | b->legacy_mem = b->legacy_io + 1; | 74 | if (error) |
70 | b->legacy_mem->attr.name = "legacy_mem"; | 75 | goto legacy_io_err; |
71 | b->legacy_mem->size = 1024*1024; | 76 | |
72 | b->legacy_mem->attr.mode = S_IRUSR | S_IWUSR; | 77 | /* Allocated above after the legacy_io struct */ |
73 | b->legacy_mem->mmap = pci_mmap_legacy_mem; | 78 | b->legacy_mem = b->legacy_io + 1; |
74 | device_create_bin_file(&b->dev, b->legacy_mem); | 79 | b->legacy_mem->attr.name = "legacy_mem"; |
75 | } | 80 | b->legacy_mem->size = 1024*1024; |
81 | b->legacy_mem->attr.mode = S_IRUSR | S_IWUSR; | ||
82 | b->legacy_mem->mmap = pci_mmap_legacy_mem; | ||
83 | error = device_create_bin_file(&b->dev, b->legacy_mem); | ||
84 | if (error) | ||
85 | goto legacy_mem_err; | ||
86 | |||
87 | return; | ||
88 | |||
89 | legacy_mem_err: | ||
90 | device_remove_bin_file(&b->dev, b->legacy_io); | ||
91 | legacy_io_err: | ||
92 | kfree(b->legacy_io); | ||
93 | b->legacy_io = NULL; | ||
94 | kzalloc_err: | ||
95 | printk(KERN_WARNING "pci: warning: could not create legacy I/O port " | ||
96 | "and ISA memory resources to sysfs\n"); | ||
97 | return; | ||
76 | } | 98 | } |
77 | 99 | ||
78 | void pci_remove_legacy_files(struct pci_bus *b) | 100 | void pci_remove_legacy_files(struct pci_bus *b) |
@@ -163,12 +185,9 @@ static inline unsigned int pci_calc_resource_flags(unsigned int flags) | |||
163 | return IORESOURCE_MEM; | 185 | return IORESOURCE_MEM; |
164 | } | 186 | } |
165 | 187 | ||
166 | /* | 188 | static u64 pci_size(u64 base, u64 maxbase, u64 mask) |
167 | * Find the extent of a PCI decode.. | ||
168 | */ | ||
169 | static u32 pci_size(u32 base, u32 maxbase, u32 mask) | ||
170 | { | 189 | { |
171 | u32 size = mask & maxbase; /* Find the significant bits */ | 190 | u64 size = mask & maxbase; /* Find the significant bits */ |
172 | if (!size) | 191 | if (!size) |
173 | return 0; | 192 | return 0; |
174 | 193 | ||
@@ -184,135 +203,142 @@ static u32 pci_size(u32 base, u32 maxbase, u32 mask) | |||
184 | return size; | 203 | return size; |
185 | } | 204 | } |
186 | 205 | ||
187 | static u64 pci_size64(u64 base, u64 maxbase, u64 mask) | 206 | enum pci_bar_type { |
207 | pci_bar_unknown, /* Standard PCI BAR probe */ | ||
208 | pci_bar_io, /* An io port BAR */ | ||
209 | pci_bar_mem32, /* A 32-bit memory BAR */ | ||
210 | pci_bar_mem64, /* A 64-bit memory BAR */ | ||
211 | }; | ||
212 | |||
213 | static inline enum pci_bar_type decode_bar(struct resource *res, u32 bar) | ||
188 | { | 214 | { |
189 | u64 size = mask & maxbase; /* Find the significant bits */ | 215 | if ((bar & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_IO) { |
190 | if (!size) | 216 | res->flags = bar & ~PCI_BASE_ADDRESS_IO_MASK; |
191 | return 0; | 217 | return pci_bar_io; |
218 | } | ||
192 | 219 | ||
193 | /* Get the lowest of them to find the decode size, and | 220 | res->flags = bar & ~PCI_BASE_ADDRESS_MEM_MASK; |
194 | from that the extent. */ | ||
195 | size = (size & ~(size-1)) - 1; | ||
196 | 221 | ||
197 | /* base == maxbase can be valid only if the BAR has | 222 | if (res->flags == PCI_BASE_ADDRESS_MEM_TYPE_64) |
198 | already been programmed with all 1s. */ | 223 | return pci_bar_mem64; |
199 | if (base == maxbase && ((base | size) & mask) != mask) | 224 | return pci_bar_mem32; |
200 | return 0; | ||
201 | |||
202 | return size; | ||
203 | } | 225 | } |
204 | 226 | ||
205 | static inline int is_64bit_memory(u32 mask) | 227 | /* |
228 | * If the type is not unknown, we assume that the lowest bit is 'enable'. | ||
229 | * Returns 1 if the BAR was 64-bit and 0 if it was 32-bit. | ||
230 | */ | ||
231 | static int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, | ||
232 | struct resource *res, unsigned int pos) | ||
206 | { | 233 | { |
207 | if ((mask & (PCI_BASE_ADDRESS_SPACE|PCI_BASE_ADDRESS_MEM_TYPE_MASK)) == | 234 | u32 l, sz, mask; |
208 | (PCI_BASE_ADDRESS_SPACE_MEMORY|PCI_BASE_ADDRESS_MEM_TYPE_64)) | ||
209 | return 1; | ||
210 | return 0; | ||
211 | } | ||
212 | 235 | ||
213 | static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom) | 236 | mask = type ? ~PCI_ROM_ADDRESS_ENABLE : ~0; |
214 | { | ||
215 | unsigned int pos, reg, next; | ||
216 | u32 l, sz; | ||
217 | struct resource *res; | ||
218 | 237 | ||
219 | for(pos=0; pos<howmany; pos = next) { | 238 | res->name = pci_name(dev); |
220 | u64 l64; | ||
221 | u64 sz64; | ||
222 | u32 raw_sz; | ||
223 | 239 | ||
224 | next = pos+1; | 240 | pci_read_config_dword(dev, pos, &l); |
225 | res = &dev->resource[pos]; | 241 | pci_write_config_dword(dev, pos, mask); |
226 | res->name = pci_name(dev); | 242 | pci_read_config_dword(dev, pos, &sz); |
227 | reg = PCI_BASE_ADDRESS_0 + (pos << 2); | 243 | pci_write_config_dword(dev, pos, l); |
228 | pci_read_config_dword(dev, reg, &l); | 244 | |
229 | pci_write_config_dword(dev, reg, ~0); | 245 | /* |
230 | pci_read_config_dword(dev, reg, &sz); | 246 | * All bits set in sz means the device isn't working properly. |
231 | pci_write_config_dword(dev, reg, l); | 247 | * If the BAR isn't implemented, all bits must be 0. If it's a |
232 | if (!sz || sz == 0xffffffff) | 248 | * memory BAR or a ROM, bit 0 must be clear; if it's an io BAR, bit |
233 | continue; | 249 | * 1 must be clear. |
234 | if (l == 0xffffffff) | 250 | */ |
235 | l = 0; | 251 | if (!sz || sz == 0xffffffff) |
236 | raw_sz = sz; | 252 | goto fail; |
237 | if ((l & PCI_BASE_ADDRESS_SPACE) == | 253 | |
238 | PCI_BASE_ADDRESS_SPACE_MEMORY) { | 254 | /* |
239 | sz = pci_size(l, sz, (u32)PCI_BASE_ADDRESS_MEM_MASK); | 255 | * I don't know how l can have all bits set. Copied from old code. |
240 | /* | 256 | * Maybe it fixes a bug on some ancient platform. |
241 | * For 64bit prefetchable memory sz could be 0, if the | 257 | */ |
242 | * real size is bigger than 4G, so we need to check | 258 | if (l == 0xffffffff) |
243 | * szhi for that. | 259 | l = 0; |
244 | */ | 260 | |
245 | if (!is_64bit_memory(l) && !sz) | 261 | if (type == pci_bar_unknown) { |
246 | continue; | 262 | type = decode_bar(res, l); |
247 | res->start = l & PCI_BASE_ADDRESS_MEM_MASK; | 263 | res->flags |= pci_calc_resource_flags(l) | IORESOURCE_SIZEALIGN; |
248 | res->flags |= l & ~PCI_BASE_ADDRESS_MEM_MASK; | 264 | if (type == pci_bar_io) { |
265 | l &= PCI_BASE_ADDRESS_IO_MASK; | ||
266 | mask = PCI_BASE_ADDRESS_IO_MASK & 0xffff; | ||
249 | } else { | 267 | } else { |
250 | sz = pci_size(l, sz, PCI_BASE_ADDRESS_IO_MASK & 0xffff); | 268 | l &= PCI_BASE_ADDRESS_MEM_MASK; |
251 | if (!sz) | 269 | mask = (u32)PCI_BASE_ADDRESS_MEM_MASK; |
252 | continue; | ||
253 | res->start = l & PCI_BASE_ADDRESS_IO_MASK; | ||
254 | res->flags |= l & ~PCI_BASE_ADDRESS_IO_MASK; | ||
255 | } | 270 | } |
256 | res->end = res->start + (unsigned long) sz; | 271 | } else { |
257 | res->flags |= pci_calc_resource_flags(l) | IORESOURCE_SIZEALIGN; | 272 | res->flags |= (l & IORESOURCE_ROM_ENABLE); |
258 | if (is_64bit_memory(l)) { | 273 | l &= PCI_ROM_ADDRESS_MASK; |
259 | u32 szhi, lhi; | 274 | mask = (u32)PCI_ROM_ADDRESS_MASK; |
260 | 275 | } | |
261 | pci_read_config_dword(dev, reg+4, &lhi); | 276 | |
262 | pci_write_config_dword(dev, reg+4, ~0); | 277 | if (type == pci_bar_mem64) { |
263 | pci_read_config_dword(dev, reg+4, &szhi); | 278 | u64 l64 = l; |
264 | pci_write_config_dword(dev, reg+4, lhi); | 279 | u64 sz64 = sz; |
265 | sz64 = ((u64)szhi << 32) | raw_sz; | 280 | u64 mask64 = mask | (u64)~0 << 32; |
266 | l64 = ((u64)lhi << 32) | l; | 281 | |
267 | sz64 = pci_size64(l64, sz64, PCI_BASE_ADDRESS_MEM_MASK); | 282 | pci_read_config_dword(dev, pos + 4, &l); |
268 | next++; | 283 | pci_write_config_dword(dev, pos + 4, ~0); |
269 | #if BITS_PER_LONG == 64 | 284 | pci_read_config_dword(dev, pos + 4, &sz); |
270 | if (!sz64) { | 285 | pci_write_config_dword(dev, pos + 4, l); |
271 | res->start = 0; | 286 | |
272 | res->end = 0; | 287 | l64 |= ((u64)l << 32); |
273 | res->flags = 0; | 288 | sz64 |= ((u64)sz << 32); |
274 | continue; | 289 | |
275 | } | 290 | sz64 = pci_size(l64, sz64, mask64); |
276 | res->start = l64 & PCI_BASE_ADDRESS_MEM_MASK; | 291 | |
277 | res->end = res->start + sz64; | 292 | if (!sz64) |
278 | #else | 293 | goto fail; |
279 | if (sz64 > 0x100000000ULL) { | 294 | |
280 | dev_err(&dev->dev, "BAR %d: can't handle 64-bit" | 295 | if ((sizeof(resource_size_t) < 8) && (sz64 > 0x100000000ULL)) { |
281 | " BAR\n", pos); | 296 | dev_err(&dev->dev, "can't handle 64-bit BAR\n"); |
282 | res->start = 0; | 297 | goto fail; |
283 | res->flags = 0; | 298 | } else if ((sizeof(resource_size_t) < 8) && l) { |
284 | } else if (lhi) { | 299 | /* Address above 32-bit boundary; disable the BAR */ |
285 | /* 64-bit wide address, treat as disabled */ | 300 | pci_write_config_dword(dev, pos, 0); |
286 | pci_write_config_dword(dev, reg, | 301 | pci_write_config_dword(dev, pos + 4, 0); |
287 | l & ~(u32)PCI_BASE_ADDRESS_MEM_MASK); | 302 | res->start = 0; |
288 | pci_write_config_dword(dev, reg+4, 0); | 303 | res->end = sz64; |
289 | res->start = 0; | 304 | } else { |
290 | res->end = sz; | 305 | res->start = l64; |
291 | } | 306 | res->end = l64 + sz64; |
292 | #endif | ||
293 | } | 307 | } |
308 | } else { | ||
309 | sz = pci_size(l, sz, mask); | ||
310 | |||
311 | if (!sz) | ||
312 | goto fail; | ||
313 | |||
314 | res->start = l; | ||
315 | res->end = l + sz; | ||
294 | } | 316 | } |
317 | |||
318 | out: | ||
319 | return (type == pci_bar_mem64) ? 1 : 0; | ||
320 | fail: | ||
321 | res->flags = 0; | ||
322 | goto out; | ||
323 | } | ||
324 | |||
325 | static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom) | ||
326 | { | ||
327 | unsigned int pos, reg; | ||
328 | |||
329 | for (pos = 0; pos < howmany; pos++) { | ||
330 | struct resource *res = &dev->resource[pos]; | ||
331 | reg = PCI_BASE_ADDRESS_0 + (pos << 2); | ||
332 | pos += __pci_read_base(dev, pci_bar_unknown, res, reg); | ||
333 | } | ||
334 | |||
295 | if (rom) { | 335 | if (rom) { |
336 | struct resource *res = &dev->resource[PCI_ROM_RESOURCE]; | ||
296 | dev->rom_base_reg = rom; | 337 | dev->rom_base_reg = rom; |
297 | res = &dev->resource[PCI_ROM_RESOURCE]; | 338 | res->flags = IORESOURCE_MEM | IORESOURCE_PREFETCH | |
298 | res->name = pci_name(dev); | 339 | IORESOURCE_READONLY | IORESOURCE_CACHEABLE | |
299 | pci_read_config_dword(dev, rom, &l); | 340 | IORESOURCE_SIZEALIGN; |
300 | pci_write_config_dword(dev, rom, ~PCI_ROM_ADDRESS_ENABLE); | 341 | __pci_read_base(dev, pci_bar_mem32, res, rom); |
301 | pci_read_config_dword(dev, rom, &sz); | ||
302 | pci_write_config_dword(dev, rom, l); | ||
303 | if (l == 0xffffffff) | ||
304 | l = 0; | ||
305 | if (sz && sz != 0xffffffff) { | ||
306 | sz = pci_size(l, sz, (u32)PCI_ROM_ADDRESS_MASK); | ||
307 | if (sz) { | ||
308 | res->flags = (l & IORESOURCE_ROM_ENABLE) | | ||
309 | IORESOURCE_MEM | IORESOURCE_PREFETCH | | ||
310 | IORESOURCE_READONLY | IORESOURCE_CACHEABLE | | ||
311 | IORESOURCE_SIZEALIGN; | ||
312 | res->start = l & PCI_ROM_ADDRESS_MASK; | ||
313 | res->end = res->start + (unsigned long) sz; | ||
314 | } | ||
315 | } | ||
316 | } | 342 | } |
317 | } | 343 | } |
318 | 344 | ||
@@ -1053,7 +1079,8 @@ int pci_scan_slot(struct pci_bus *bus, int devfn) | |||
1053 | } | 1079 | } |
1054 | } | 1080 | } |
1055 | 1081 | ||
1056 | if (bus->self) | 1082 | /* only one slot has pcie device */ |
1083 | if (bus->self && nr) | ||
1057 | pcie_aspm_init_link_state(bus->self); | 1084 | pcie_aspm_init_link_state(bus->self); |
1058 | 1085 | ||
1059 | return nr; | 1086 | return nr; |
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c index 4400dffbd93a..e1098c302c45 100644 --- a/drivers/pci/proc.c +++ b/drivers/pci/proc.c | |||
@@ -88,7 +88,7 @@ proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *pp | |||
88 | if ((pos & 3) && cnt > 2) { | 88 | if ((pos & 3) && cnt > 2) { |
89 | unsigned short val; | 89 | unsigned short val; |
90 | pci_user_read_config_word(dev, pos, &val); | 90 | pci_user_read_config_word(dev, pos, &val); |
91 | __put_user(cpu_to_le16(val), (unsigned short __user *) buf); | 91 | __put_user(cpu_to_le16(val), (__le16 __user *) buf); |
92 | buf += 2; | 92 | buf += 2; |
93 | pos += 2; | 93 | pos += 2; |
94 | cnt -= 2; | 94 | cnt -= 2; |
@@ -97,7 +97,7 @@ proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *pp | |||
97 | while (cnt >= 4) { | 97 | while (cnt >= 4) { |
98 | unsigned int val; | 98 | unsigned int val; |
99 | pci_user_read_config_dword(dev, pos, &val); | 99 | pci_user_read_config_dword(dev, pos, &val); |
100 | __put_user(cpu_to_le32(val), (unsigned int __user *) buf); | 100 | __put_user(cpu_to_le32(val), (__le32 __user *) buf); |
101 | buf += 4; | 101 | buf += 4; |
102 | pos += 4; | 102 | pos += 4; |
103 | cnt -= 4; | 103 | cnt -= 4; |
@@ -106,7 +106,7 @@ proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *pp | |||
106 | if (cnt >= 2) { | 106 | if (cnt >= 2) { |
107 | unsigned short val; | 107 | unsigned short val; |
108 | pci_user_read_config_word(dev, pos, &val); | 108 | pci_user_read_config_word(dev, pos, &val); |
109 | __put_user(cpu_to_le16(val), (unsigned short __user *) buf); | 109 | __put_user(cpu_to_le16(val), (__le16 __user *) buf); |
110 | buf += 2; | 110 | buf += 2; |
111 | pos += 2; | 111 | pos += 2; |
112 | cnt -= 2; | 112 | cnt -= 2; |
@@ -156,8 +156,8 @@ proc_bus_pci_write(struct file *file, const char __user *buf, size_t nbytes, lof | |||
156 | } | 156 | } |
157 | 157 | ||
158 | if ((pos & 3) && cnt > 2) { | 158 | if ((pos & 3) && cnt > 2) { |
159 | unsigned short val; | 159 | __le16 val; |
160 | __get_user(val, (unsigned short __user *) buf); | 160 | __get_user(val, (__le16 __user *) buf); |
161 | pci_user_write_config_word(dev, pos, le16_to_cpu(val)); | 161 | pci_user_write_config_word(dev, pos, le16_to_cpu(val)); |
162 | buf += 2; | 162 | buf += 2; |
163 | pos += 2; | 163 | pos += 2; |
@@ -165,8 +165,8 @@ proc_bus_pci_write(struct file *file, const char __user *buf, size_t nbytes, lof | |||
165 | } | 165 | } |
166 | 166 | ||
167 | while (cnt >= 4) { | 167 | while (cnt >= 4) { |
168 | unsigned int val; | 168 | __le32 val; |
169 | __get_user(val, (unsigned int __user *) buf); | 169 | __get_user(val, (__le32 __user *) buf); |
170 | pci_user_write_config_dword(dev, pos, le32_to_cpu(val)); | 170 | pci_user_write_config_dword(dev, pos, le32_to_cpu(val)); |
171 | buf += 4; | 171 | buf += 4; |
172 | pos += 4; | 172 | pos += 4; |
@@ -174,8 +174,8 @@ proc_bus_pci_write(struct file *file, const char __user *buf, size_t nbytes, lof | |||
174 | } | 174 | } |
175 | 175 | ||
176 | if (cnt >= 2) { | 176 | if (cnt >= 2) { |
177 | unsigned short val; | 177 | __le16 val; |
178 | __get_user(val, (unsigned short __user *) buf); | 178 | __get_user(val, (__le16 __user *) buf); |
179 | pci_user_write_config_word(dev, pos, le16_to_cpu(val)); | 179 | pci_user_write_config_word(dev, pos, le16_to_cpu(val)); |
180 | buf += 2; | 180 | buf += 2; |
181 | pos += 2; | 181 | pos += 2; |
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 12d489395fad..9236e7f869c8 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
@@ -923,6 +923,19 @@ static void __init quirk_ide_samemode(struct pci_dev *pdev) | |||
923 | } | 923 | } |
924 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_10, quirk_ide_samemode); | 924 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_10, quirk_ide_samemode); |
925 | 925 | ||
926 | /* | ||
927 | * Some ATA devices break if put into D3 | ||
928 | */ | ||
929 | |||
930 | static void __devinit quirk_no_ata_d3(struct pci_dev *pdev) | ||
931 | { | ||
932 | /* Quirk the legacy ATA devices only. The AHCI ones are ok */ | ||
933 | if ((pdev->class >> 8) == PCI_CLASS_STORAGE_IDE) | ||
934 | pdev->dev_flags |= PCI_DEV_FLAGS_NO_D3; | ||
935 | } | ||
936 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, PCI_ANY_ID, quirk_no_ata_d3); | ||
937 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_ATI, PCI_ANY_ID, quirk_no_ata_d3); | ||
938 | |||
926 | /* This was originally an Alpha specific thing, but it really fits here. | 939 | /* This was originally an Alpha specific thing, but it really fits here. |
927 | * The i82375 PCI/EISA bridge appears as non-classified. Fix that. | 940 | * The i82375 PCI/EISA bridge appears as non-classified. Fix that. |
928 | */ | 941 | */ |
@@ -1743,9 +1756,14 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_VIA, 0x324e, quirk_via_cx700_pci_parking_c | |||
1743 | */ | 1756 | */ |
1744 | static void __devinit quirk_brcm_570x_limit_vpd(struct pci_dev *dev) | 1757 | static void __devinit quirk_brcm_570x_limit_vpd(struct pci_dev *dev) |
1745 | { | 1758 | { |
1746 | /* Only disable the VPD capability for 5706, 5708, and 5709 rev. A */ | 1759 | /* |
1760 | * Only disable the VPD capability for 5706, 5706S, 5708, | ||
1761 | * 5708S and 5709 rev. A | ||
1762 | */ | ||
1747 | if ((dev->device == PCI_DEVICE_ID_NX2_5706) || | 1763 | if ((dev->device == PCI_DEVICE_ID_NX2_5706) || |
1764 | (dev->device == PCI_DEVICE_ID_NX2_5706S) || | ||
1748 | (dev->device == PCI_DEVICE_ID_NX2_5708) || | 1765 | (dev->device == PCI_DEVICE_ID_NX2_5708) || |
1766 | (dev->device == PCI_DEVICE_ID_NX2_5708S) || | ||
1749 | ((dev->device == PCI_DEVICE_ID_NX2_5709) && | 1767 | ((dev->device == PCI_DEVICE_ID_NX2_5709) && |
1750 | (dev->revision & 0xf0) == 0x0)) { | 1768 | (dev->revision & 0xf0) == 0x0)) { |
1751 | if (dev->vpd) | 1769 | if (dev->vpd) |