X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=drivers%2Fpci%2Fprobe.c;h=3706ce7972dddc0c389f828a3ec0c4635d1d8efe;hb=6592e02ae4bd7b277230aa0c5821588a13b9d8e3;hp=387fbbb97431eef05d3920db995690ce2f201240;hpb=70308923d317f2ad4973c30d90bb48ae38761317;p=safe%2Fjmp%2Flinux-2.6 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 387fbbb..3706ce7 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "pci.h" #define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */ @@ -20,8 +21,6 @@ LIST_HEAD(pci_root_buses); EXPORT_SYMBOL(pci_root_buses); -LIST_HEAD(pci_devices); - static int find_anything(struct device *dev, void *data) { @@ -93,6 +92,7 @@ void pci_remove_legacy_files(struct pci_bus *bus) { return; } * PCI Bus Class Devices */ static ssize_t pci_bus_show_cpuaffinity(struct device *dev, + int type, struct device_attribute *attr, char *buf) { @@ -100,12 +100,30 @@ static ssize_t pci_bus_show_cpuaffinity(struct device *dev, cpumask_t cpumask; cpumask = pcibus_to_cpumask(to_pci_bus(dev)); - ret = cpumask_scnprintf(buf, PAGE_SIZE, cpumask); - if (ret < PAGE_SIZE) - buf[ret++] = '\n'; + ret = type? + cpulist_scnprintf(buf, PAGE_SIZE-2, cpumask): + cpumask_scnprintf(buf, PAGE_SIZE-2, cpumask); + buf[ret++] = '\n'; + buf[ret] = '\0'; return ret; } -DEVICE_ATTR(cpuaffinity, S_IRUGO, pci_bus_show_cpuaffinity, NULL); + +static ssize_t inline pci_bus_show_cpumaskaffinity(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + return pci_bus_show_cpuaffinity(dev, 0, attr, buf); +} + +static ssize_t inline pci_bus_show_cpulistaffinity(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + return pci_bus_show_cpuaffinity(dev, 1, attr, buf); +} + +DEVICE_ATTR(cpuaffinity, S_IRUGO, pci_bus_show_cpumaskaffinity, NULL); +DEVICE_ATTR(cpulistaffinity, S_IRUGO, pci_bus_show_cpulistaffinity, NULL); /* * PCI Bus Class @@ -236,7 +254,7 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom) res->flags |= l & ~PCI_BASE_ADDRESS_IO_MASK; } res->end = res->start + (unsigned long) sz; - res->flags |= pci_calc_resource_flags(l); + res->flags |= pci_calc_resource_flags(l) | IORESOURCE_SIZEALIGN; if (is_64bit_memory(l)) { u32 szhi, lhi; @@ -289,7 +307,8 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom) if (sz) { res->flags = (l & IORESOURCE_ROM_ENABLE) | IORESOURCE_MEM | IORESOURCE_PREFETCH | - IORESOURCE_READONLY | IORESOURCE_CACHEABLE; + IORESOURCE_READONLY | IORESOURCE_CACHEABLE | + IORESOURCE_SIZEALIGN; res->start = l & PCI_ROM_ADDRESS_MASK; res->end = res->start + (unsigned long) sz; } @@ -399,8 +418,8 @@ static struct pci_bus * pci_alloc_bus(void) return b; } -static struct pci_bus * __devinit -pci_alloc_child_bus(struct pci_bus *parent, struct pci_dev *bridge, int busnr) +static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent, + struct pci_dev *bridge, int busnr) { struct pci_bus *child; int i; @@ -633,7 +652,9 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, pci_write_config_byte(dev, PCI_SUBORDINATE_BUS, max); } - sprintf(child->name, (is_cardbus ? "PCI CardBus #%02x" : "PCI Bus #%02x"), child->number); + sprintf(child->name, + (is_cardbus ? "PCI CardBus %04x:%02x" : "PCI Bus %04x:%02x"), + pci_domain_nr(bus), child->number); /* Has only triggered on CardBus, fixup is in yenta_socket */ while (bus->parent) { @@ -793,6 +814,7 @@ static void pci_release_dev(struct device *dev) struct pci_dev *pci_dev; pci_dev = to_pci_dev(dev); + pci_vpd_release(pci_dev); kfree(pci_dev); } @@ -820,6 +842,21 @@ static void set_pcie_port_type(struct pci_dev *pdev) * reading the dword at 0x100 which must either be 0 or a valid extended * capability header. */ +int pci_cfg_space_size_ext(struct pci_dev *dev) +{ + u32 status; + + if (pci_read_config_dword(dev, 256, &status) != PCIBIOS_SUCCESSFUL) + goto fail; + if (status == 0xffffffff) + goto fail; + + return PCI_CFG_SPACE_EXP_SIZE; + + fail: + return PCI_CFG_SPACE_SIZE; +} + int pci_cfg_space_size(struct pci_dev *dev) { int pos; @@ -836,12 +873,7 @@ int pci_cfg_space_size(struct pci_dev *dev) goto fail; } - if (pci_read_config_dword(dev, 256, &status) != PCIBIOS_SUCCESSFUL) - goto fail; - if (status == 0xffffffff) - goto fail; - - return PCI_CFG_SPACE_EXP_SIZE; + return pci_cfg_space_size_ext(dev); fail: return PCI_CFG_SPACE_SIZE; @@ -860,7 +892,6 @@ struct pci_dev *alloc_pci_dev(void) if (!dev) return NULL; - INIT_LIST_HEAD(&dev->global_list); INIT_LIST_HEAD(&dev->bus_list); pci_msi_init_pci_dev(dev); @@ -873,8 +904,7 @@ EXPORT_SYMBOL(alloc_pci_dev); * Read the config data for a PCI device, sanity-check it * and fill in the dev structure... */ -static struct pci_dev * __devinit -pci_scan_device(struct pci_bus *bus, int devfn) +static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn) { struct pci_dev *dev; u32 l; @@ -933,6 +963,8 @@ pci_scan_device(struct pci_bus *bus, int devfn) return NULL; } + pci_vpd_pci22_init(dev); + return dev; } @@ -942,7 +974,6 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) dev->dev.release = pci_release_dev; pci_dev_get(dev); - set_dev_node(&dev->dev, pcibus_to_node(bus)); dev->dev.dma_mask = &dev->dma_mask; dev->dev.dma_parms = &dev->dma_parms; dev->dev.coherent_dma_mask = 0xffffffffull; @@ -957,7 +988,6 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) * Add the device to our list of discovered devices * and the bus list for fixup functions, etc. */ - INIT_LIST_HEAD(&dev->global_list); down_write(&pci_bus_sem); list_add_tail(&dev->bus_list, &bus->devices); up_write(&pci_bus_sem); @@ -984,7 +1014,7 @@ EXPORT_SYMBOL(pci_scan_single_device); * * Scan a PCI slot on the specified PCI bus for devices, adding * discovered devices to the @bus->devices list. New devices - * will have an empty dev->global_list head. + * will not have is_added set. */ int pci_scan_slot(struct pci_bus *bus, int devfn) { @@ -1016,6 +1046,10 @@ int pci_scan_slot(struct pci_bus *bus, int devfn) break; } } + + if (bus->self) + pcie_aspm_init_link_state(bus->self); + return nr; } @@ -1055,6 +1089,10 @@ unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus) return max; } +void __attribute__((weak)) set_pci_bus_resources_arch_default(struct pci_bus *b) +{ +} + struct pci_bus * pci_create_bus(struct device *parent, int bus, struct pci_ops *ops, void *sysdata) { @@ -1094,6 +1132,9 @@ struct pci_bus * pci_create_bus(struct device *parent, goto dev_reg_err; b->bridge = get_device(dev); + if (!parent) + set_dev_node(b->bridge, pcibus_to_node(b)); + b->dev.class = &pcibus_class; b->dev.parent = b->bridge; sprintf(b->dev.bus_id, "%04x:%02x", pci_domain_nr(b), bus); @@ -1111,6 +1152,8 @@ struct pci_bus * pci_create_bus(struct device *parent, b->resource[0] = &ioport_resource; b->resource[1] = &iomem_resource; + set_pci_bus_resources_arch_default(b); + return b; dev_create_file_err: @@ -1186,7 +1229,7 @@ static void __init pci_insertion_sort_klist(struct pci_dev *a, struct list_head list_move_tail(&a->dev.knode_bus.n_node, list); } -static void __init pci_sort_breadthfirst_klist(void) +void __init pci_sort_breadthfirst(void) { LIST_HEAD(sorted_devices); struct list_head *pos, *tmp; @@ -1207,36 +1250,3 @@ static void __init pci_sort_breadthfirst_klist(void) list_splice(&sorted_devices, &device_klist->k_list); spin_unlock(&device_klist->k_lock); } - -static void __init pci_insertion_sort_devices(struct pci_dev *a, struct list_head *list) -{ - struct pci_dev *b; - - list_for_each_entry(b, list, global_list) { - if (pci_sort_bf_cmp(a, b) <= 0) { - list_move_tail(&a->global_list, &b->global_list); - return; - } - } - list_move_tail(&a->global_list, list); -} - -static void __init pci_sort_breadthfirst_devices(void) -{ - LIST_HEAD(sorted_devices); - struct pci_dev *dev, *tmp; - - down_write(&pci_bus_sem); - list_for_each_entry_safe(dev, tmp, &pci_devices, global_list) { - pci_insertion_sort_devices(dev, &sorted_devices); - } - list_splice(&sorted_devices, &pci_devices); - up_write(&pci_bus_sem); -} - -void __init pci_sort_breadthfirst(void) -{ - pci_sort_breadthfirst_devices(); - pci_sort_breadthfirst_klist(); -} -