aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/probe.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-04-21 18:58:35 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-21 18:58:35 -0400
commitbda0c0afa7a694bb1459fd023515aca681e4d79a (patch)
treecd8b9d9811463de2065cbe79d59689082d6c53cf /drivers/pci/probe.c
parent904e0ab54b7591b9cb01cfc0dbbedcc8bc0d949b (diff)
parentaf40b485ea2d957ae2f237ab0e33539ae8f29562 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/pci-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/pci-2.6: (42 commits) PCI: Change PCI subsystem MAINTAINER PCI: pci-iommu-iotlb-flushing-speedup PCI: pci_setup_bridge() mustn't be __devinit PCI: pci_bus_size_cardbus() mustn't be __devinit PCI: pci_scan_device() mustn't be __devinit PCI: pci_alloc_child_bus() mustn't be __devinit PCI: replace remaining __FUNCTION__ occurrences PCI: Hotplug: fakephp: Return success, not ENODEV, when bus rescan is triggered PCI: Hotplug: Fix leaks in IBM Hot Plug Controller Driver - ibmphp_init_devno() PCI: clean up resource alignment management PCI: aerdrv_acpi.c: remove unneeded NULL check PCI: Update VIA CX700 quirk PCI: Expose PCI VPD through sysfs PCI: iommu: iotlb flushing PCI: simplify quirk debug output PCI: iova RB tree setup tweak PCI: parisc: use generic pci_enable_resources() PCI: ppc: use generic pci_enable_resources() PCI: powerpc: use generic pci_enable_resources() PCI: ia64: use generic pci_enable_resources() ...
Diffstat (limited to 'drivers/pci/probe.c')
-rw-r--r--drivers/pci/probe.c80
1 files changed, 32 insertions, 48 deletions
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 4b3011a23eff..f991359f0c36 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -9,6 +9,7 @@
9#include <linux/slab.h> 9#include <linux/slab.h>
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/cpumask.h> 11#include <linux/cpumask.h>
12#include <linux/pci-aspm.h>
12#include "pci.h" 13#include "pci.h"
13 14
14#define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */ 15#define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */
@@ -20,18 +21,27 @@
20LIST_HEAD(pci_root_buses); 21LIST_HEAD(pci_root_buses);
21EXPORT_SYMBOL(pci_root_buses); 22EXPORT_SYMBOL(pci_root_buses);
22 23
23LIST_HEAD(pci_devices); 24
25static int find_anything(struct device *dev, void *data)
26{
27 return 1;
28}
24 29
25/* 30/*
26 * Some device drivers need know if pci is initiated. 31 * Some device drivers need know if pci is initiated.
27 * Basically, we think pci is not initiated when there 32 * Basically, we think pci is not initiated when there
28 * is no device in list of pci_devices. 33 * is no device to be found on the pci_bus_type.
29 */ 34 */
30int no_pci_devices(void) 35int no_pci_devices(void)
31{ 36{
32 return list_empty(&pci_devices); 37 struct device *dev;
33} 38 int no_devices;
34 39
40 dev = bus_find_device(&pci_bus_type, NULL, NULL, find_anything);
41 no_devices = (dev == NULL);
42 put_device(dev);
43 return no_devices;
44}
35EXPORT_SYMBOL(no_pci_devices); 45EXPORT_SYMBOL(no_pci_devices);
36 46
37#ifdef HAVE_PCI_LEGACY 47#ifdef HAVE_PCI_LEGACY
@@ -244,7 +254,7 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
244 res->flags |= l & ~PCI_BASE_ADDRESS_IO_MASK; 254 res->flags |= l & ~PCI_BASE_ADDRESS_IO_MASK;
245 } 255 }
246 res->end = res->start + (unsigned long) sz; 256 res->end = res->start + (unsigned long) sz;
247 res->flags |= pci_calc_resource_flags(l); 257 res->flags |= pci_calc_resource_flags(l) | IORESOURCE_SIZEALIGN;
248 if (is_64bit_memory(l)) { 258 if (is_64bit_memory(l)) {
249 u32 szhi, lhi; 259 u32 szhi, lhi;
250 260
@@ -297,7 +307,8 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
297 if (sz) { 307 if (sz) {
298 res->flags = (l & IORESOURCE_ROM_ENABLE) | 308 res->flags = (l & IORESOURCE_ROM_ENABLE) |
299 IORESOURCE_MEM | IORESOURCE_PREFETCH | 309 IORESOURCE_MEM | IORESOURCE_PREFETCH |
300 IORESOURCE_READONLY | IORESOURCE_CACHEABLE; 310 IORESOURCE_READONLY | IORESOURCE_CACHEABLE |
311 IORESOURCE_SIZEALIGN;
301 res->start = l & PCI_ROM_ADDRESS_MASK; 312 res->start = l & PCI_ROM_ADDRESS_MASK;
302 res->end = res->start + (unsigned long) sz; 313 res->end = res->start + (unsigned long) sz;
303 } 314 }
@@ -407,8 +418,8 @@ static struct pci_bus * pci_alloc_bus(void)
407 return b; 418 return b;
408} 419}
409 420
410static struct pci_bus * __devinit 421static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
411pci_alloc_child_bus(struct pci_bus *parent, struct pci_dev *bridge, int busnr) 422 struct pci_dev *bridge, int busnr)
412{ 423{
413 struct pci_bus *child; 424 struct pci_bus *child;
414 int i; 425 int i;
@@ -641,7 +652,9 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
641 pci_write_config_byte(dev, PCI_SUBORDINATE_BUS, max); 652 pci_write_config_byte(dev, PCI_SUBORDINATE_BUS, max);
642 } 653 }
643 654
644 sprintf(child->name, (is_cardbus ? "PCI CardBus #%02x" : "PCI Bus #%02x"), child->number); 655 sprintf(child->name,
656 (is_cardbus ? "PCI CardBus %04x:%02x" : "PCI Bus %04x:%02x"),
657 pci_domain_nr(bus), child->number);
645 658
646 /* Has only triggered on CardBus, fixup is in yenta_socket */ 659 /* Has only triggered on CardBus, fixup is in yenta_socket */
647 while (bus->parent) { 660 while (bus->parent) {
@@ -801,6 +814,7 @@ static void pci_release_dev(struct device *dev)
801 struct pci_dev *pci_dev; 814 struct pci_dev *pci_dev;
802 815
803 pci_dev = to_pci_dev(dev); 816 pci_dev = to_pci_dev(dev);
817 pci_vpd_release(pci_dev);
804 kfree(pci_dev); 818 kfree(pci_dev);
805} 819}
806 820
@@ -868,7 +882,6 @@ struct pci_dev *alloc_pci_dev(void)
868 if (!dev) 882 if (!dev)
869 return NULL; 883 return NULL;
870 884
871 INIT_LIST_HEAD(&dev->global_list);
872 INIT_LIST_HEAD(&dev->bus_list); 885 INIT_LIST_HEAD(&dev->bus_list);
873 886
874 pci_msi_init_pci_dev(dev); 887 pci_msi_init_pci_dev(dev);
@@ -881,8 +894,7 @@ EXPORT_SYMBOL(alloc_pci_dev);
881 * Read the config data for a PCI device, sanity-check it 894 * Read the config data for a PCI device, sanity-check it
882 * and fill in the dev structure... 895 * and fill in the dev structure...
883 */ 896 */
884static struct pci_dev * __devinit 897static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
885pci_scan_device(struct pci_bus *bus, int devfn)
886{ 898{
887 struct pci_dev *dev; 899 struct pci_dev *dev;
888 u32 l; 900 u32 l;
@@ -941,6 +953,8 @@ pci_scan_device(struct pci_bus *bus, int devfn)
941 return NULL; 953 return NULL;
942 } 954 }
943 955
956 pci_vpd_pci22_init(dev);
957
944 return dev; 958 return dev;
945} 959}
946 960
@@ -965,7 +979,6 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
965 * Add the device to our list of discovered devices 979 * Add the device to our list of discovered devices
966 * and the bus list for fixup functions, etc. 980 * and the bus list for fixup functions, etc.
967 */ 981 */
968 INIT_LIST_HEAD(&dev->global_list);
969 down_write(&pci_bus_sem); 982 down_write(&pci_bus_sem);
970 list_add_tail(&dev->bus_list, &bus->devices); 983 list_add_tail(&dev->bus_list, &bus->devices);
971 up_write(&pci_bus_sem); 984 up_write(&pci_bus_sem);
@@ -992,7 +1005,7 @@ EXPORT_SYMBOL(pci_scan_single_device);
992 * 1005 *
993 * Scan a PCI slot on the specified PCI bus for devices, adding 1006 * Scan a PCI slot on the specified PCI bus for devices, adding
994 * discovered devices to the @bus->devices list. New devices 1007 * discovered devices to the @bus->devices list. New devices
995 * will have an empty dev->global_list head. 1008 * will not have is_added set.
996 */ 1009 */
997int pci_scan_slot(struct pci_bus *bus, int devfn) 1010int pci_scan_slot(struct pci_bus *bus, int devfn)
998{ 1011{
@@ -1024,6 +1037,10 @@ int pci_scan_slot(struct pci_bus *bus, int devfn)
1024 break; 1037 break;
1025 } 1038 }
1026 } 1039 }
1040
1041 if (bus->self)
1042 pcie_aspm_init_link_state(bus->self);
1043
1027 return nr; 1044 return nr;
1028} 1045}
1029 1046
@@ -1194,7 +1211,7 @@ static void __init pci_insertion_sort_klist(struct pci_dev *a, struct list_head
1194 list_move_tail(&a->dev.knode_bus.n_node, list); 1211 list_move_tail(&a->dev.knode_bus.n_node, list);
1195} 1212}
1196 1213
1197static void __init pci_sort_breadthfirst_klist(void) 1214void __init pci_sort_breadthfirst(void)
1198{ 1215{
1199 LIST_HEAD(sorted_devices); 1216 LIST_HEAD(sorted_devices);
1200 struct list_head *pos, *tmp; 1217 struct list_head *pos, *tmp;
@@ -1215,36 +1232,3 @@ static void __init pci_sort_breadthfirst_klist(void)
1215 list_splice(&sorted_devices, &device_klist->k_list); 1232 list_splice(&sorted_devices, &device_klist->k_list);
1216 spin_unlock(&device_klist->k_lock); 1233 spin_unlock(&device_klist->k_lock);
1217} 1234}
1218
1219static void __init pci_insertion_sort_devices(struct pci_dev *a, struct list_head *list)
1220{
1221 struct pci_dev *b;
1222
1223 list_for_each_entry(b, list, global_list) {
1224 if (pci_sort_bf_cmp(a, b) <= 0) {
1225 list_move_tail(&a->global_list, &b->global_list);
1226 return;
1227 }
1228 }
1229 list_move_tail(&a->global_list, list);
1230}
1231
1232static void __init pci_sort_breadthfirst_devices(void)
1233{
1234 LIST_HEAD(sorted_devices);
1235 struct pci_dev *dev, *tmp;
1236
1237 down_write(&pci_bus_sem);
1238 list_for_each_entry_safe(dev, tmp, &pci_devices, global_list) {
1239 pci_insertion_sort_devices(dev, &sorted_devices);
1240 }
1241 list_splice(&sorted_devices, &pci_devices);
1242 up_write(&pci_bus_sem);
1243}
1244
1245void __init pci_sort_breadthfirst(void)
1246{
1247 pci_sort_breadthfirst_devices();
1248 pci_sort_breadthfirst_klist();
1249}
1250