Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 358398
b: refs/heads/master
c: b0cc602
h: refs/heads/master
v: v3
  • Loading branch information
Yijing Wang authored and Bjorn Helgaas committed Jan 24, 2013
1 parent 8b45f5c commit fea2f35
Show file tree
Hide file tree
Showing 35 changed files with 643 additions and 425 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 708b59bfe1d1727451ca41f5dc4c17cf99dfaf51
refs/heads/master: b0cc6020e1cc62f1253215f189611b34be4a83c7
1 change: 1 addition & 0 deletions trunk/arch/frv/mb93090-mb00/pci-frv.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ void pcibios_resource_survey(void);
/* pci-vdk.c */

extern int __nongpreldata pcibios_last_bus;
extern struct pci_bus *__nongpreldata pci_root_bus;
extern struct pci_ops *__nongpreldata pci_root_ops;

/* pci-irq.c */
Expand Down
4 changes: 3 additions & 1 deletion trunk/arch/frv/mb93090-mb00/pci-vdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
unsigned int __nongpreldata pci_probe = 1;

int __nongpreldata pcibios_last_bus = -1;
struct pci_bus *__nongpreldata pci_root_bus;
struct pci_ops *__nongpreldata pci_root_ops;

/*
Expand Down Expand Up @@ -415,7 +416,8 @@ int __init pcibios_init(void)
printk("PCI: Probing PCI hardware\n");
pci_add_resource(&resources, &pci_ioport_resource);
pci_add_resource(&resources, &pci_iomem_resource);
pci_scan_root_bus(NULL, 0, pci_root_ops, NULL, &resources);
pci_root_bus = pci_scan_root_bus(NULL, 0, pci_root_ops, NULL,
&resources);

pcibios_irq_init();
pcibios_fixup_peer_bridges();
Expand Down
8 changes: 0 additions & 8 deletions trunk/arch/ia64/pci/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,14 +396,6 @@ pci_acpi_scan_root(struct acpi_pci_root *root)
return NULL;
}

int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
{
struct pci_controller *controller = bridge->bus->sysdata;

ACPI_HANDLE_SET(&bridge->dev, controller->acpi_handle);
return 0;
}

static int __devinit is_valid_resource(struct pci_dev *dev, int idx)
{
unsigned int i, type_mask = IORESOURCE_IO | IORESOURCE_MEM;
Expand Down
1 change: 1 addition & 0 deletions trunk/arch/mn10300/unit-asb2305/pci-asb2305.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ extern void pcibios_resource_survey(void);
/* pci.c */

extern int pcibios_last_bus;
extern struct pci_bus *pci_root_bus;
extern struct pci_ops *pci_root_ops;

extern struct irq_routing_table *pcibios_get_irq_routing_table(void);
Expand Down
4 changes: 3 additions & 1 deletion trunk/arch/mn10300/unit-asb2305/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
unsigned int pci_probe = 1;

int pcibios_last_bus = -1;
struct pci_bus *pci_root_bus;
struct pci_ops *pci_root_ops;

/*
Expand Down Expand Up @@ -376,7 +377,8 @@ static int __init pcibios_init(void)

pci_add_resource_offset(&resources, &pci_ioport_resource, io_offset);
pci_add_resource_offset(&resources, &pci_iomem_resource, mem_offset);
pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL, &resources);
pci_root_bus = pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL,
&resources);

pcibios_irq_init();
pcibios_fixup_irqs();
Expand Down
3 changes: 0 additions & 3 deletions trunk/arch/x86/include/asm/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
struct pci_sysdata {
int domain; /* PCI domain */
int node; /* NUMA node */
#ifdef CONFIG_ACPI
void *acpi; /* ACPI-specific data */
#endif
#ifdef CONFIG_X86_64
void *iommu; /* IOMMU private data */
#endif
Expand Down
1 change: 1 addition & 0 deletions trunk/arch/x86/include/asm/pci_x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ void pcibios_set_cache_line_size(void);
/* pci-pc.c */

extern int pcibios_last_bus;
extern struct pci_bus *pci_root_bus;
extern struct pci_ops pci_root_ops;

void pcibios_scan_specific_bus(int busn);
Expand Down
9 changes: 0 additions & 9 deletions trunk/arch/x86/pci/acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,6 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
sd = &info->sd;
sd->domain = domain;
sd->node = node;
sd->acpi = device->handle;
/*
* Maybe the desired pci bus has been already scanned. In such case
* it is unnecessary to scan the pci bus with the given domain,busnum.
Expand Down Expand Up @@ -594,14 +593,6 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
return bus;
}

int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
{
struct pci_sysdata *sd = bridge->bus->sysdata;

ACPI_HANDLE_SET(&bridge->dev, sd->acpi);
return 0;
}

int __init pci_acpi_init(void)
{
struct pci_dev *dev = NULL;
Expand Down
1 change: 1 addition & 0 deletions trunk/arch/x86/pci/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ int noioapicreroute = 1;
#endif
int pcibios_last_bus = -1;
unsigned long pirq_table_addr;
struct pci_bus *pci_root_bus;
const struct pci_raw_ops *__read_mostly raw_pci_ops;
const struct pci_raw_ops *__read_mostly raw_pci_ext_ops;

Expand Down
185 changes: 64 additions & 121 deletions trunk/arch/x86/pci/i386.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ struct pcibios_fwaddrmap {

static LIST_HEAD(pcibios_fwaddrmappings);
static DEFINE_SPINLOCK(pcibios_fwaddrmap_lock);
static bool pcibios_fw_addr_done;

/* Must be called with 'pcibios_fwaddrmap_lock' lock held. */
static struct pcibios_fwaddrmap *pcibios_fwaddrmap_lookup(struct pci_dev *dev)
Expand All @@ -73,9 +72,6 @@ pcibios_save_fw_addr(struct pci_dev *dev, int idx, resource_size_t fw_addr)
unsigned long flags;
struct pcibios_fwaddrmap *map;

if (pcibios_fw_addr_done)
return;

spin_lock_irqsave(&pcibios_fwaddrmap_lock, flags);
map = pcibios_fwaddrmap_lookup(dev);
if (!map) {
Expand All @@ -101,9 +97,6 @@ resource_size_t pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx)
struct pcibios_fwaddrmap *map;
resource_size_t fw_addr = 0;

if (pcibios_fw_addr_done)
return 0;

spin_lock_irqsave(&pcibios_fwaddrmap_lock, flags);
map = pcibios_fwaddrmap_lookup(dev);
if (map)
Expand All @@ -113,7 +106,7 @@ resource_size_t pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx)
return fw_addr;
}

static void __init pcibios_fw_addr_list_del(void)
static void pcibios_fw_addr_list_del(void)
{
unsigned long flags;
struct pcibios_fwaddrmap *entry, *next;
Expand All @@ -125,7 +118,6 @@ static void __init pcibios_fw_addr_list_del(void)
kfree(entry);
}
spin_unlock_irqrestore(&pcibios_fwaddrmap_lock, flags);
pcibios_fw_addr_done = true;
}

static int
Expand Down Expand Up @@ -201,46 +193,46 @@ EXPORT_SYMBOL(pcibios_align_resource);
* as well.
*/

static void pcibios_allocate_bridge_resources(struct pci_dev *dev)
static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
{
struct pci_bus *bus;
struct pci_dev *dev;
int idx;
struct resource *r;

for (idx = PCI_BRIDGE_RESOURCES; idx < PCI_NUM_RESOURCES; idx++) {
r = &dev->resource[idx];
if (!r->flags)
continue;
if (!r->start || pci_claim_resource(dev, idx) < 0) {
/*
* Something is wrong with the region.
* Invalidate the resource to prevent
* child resource allocations in this
* range.
*/
r->start = r->end = 0;
r->flags = 0;
/* Depth-First Search on bus tree */
list_for_each_entry(bus, bus_list, node) {
if ((dev = bus->self)) {
for (idx = PCI_BRIDGE_RESOURCES;
idx < PCI_NUM_RESOURCES; idx++) {
r = &dev->resource[idx];
if (!r->flags)
continue;
if (!r->start ||
pci_claim_resource(dev, idx) < 0) {
/*
* Something is wrong with the region.
* Invalidate the resource to prevent
* child resource allocations in this
* range.
*/
r->start = r->end = 0;
r->flags = 0;
}
}
}
pcibios_allocate_bus_resources(&bus->children);
}
}

static void pcibios_allocate_bus_resources(struct pci_bus *bus)
{
struct pci_bus *child;

/* Depth-First Search on bus tree */
if (bus->self)
pcibios_allocate_bridge_resources(bus->self);
list_for_each_entry(child, &bus->children, node)
pcibios_allocate_bus_resources(child);
}

struct pci_check_idx_range {
int start;
int end;
};

static void pcibios_allocate_dev_resources(struct pci_dev *dev, int pass)
static void __init pcibios_allocate_resources(int pass)
{
struct pci_dev *dev = NULL;
int idx, disabled, i;
u16 command;
struct resource *r;
Expand All @@ -252,13 +244,14 @@ static void pcibios_allocate_dev_resources(struct pci_dev *dev, int pass)
#endif
};

pci_read_config_word(dev, PCI_COMMAND, &command);
for (i = 0; i < ARRAY_SIZE(idx_range); i++)
for_each_pci_dev(dev) {
pci_read_config_word(dev, PCI_COMMAND, &command);
for (i = 0; i < ARRAY_SIZE(idx_range); i++)
for (idx = idx_range[i].start; idx <= idx_range[i].end; idx++) {
r = &dev->resource[idx];
if (r->parent) /* Already allocated */
if (r->parent) /* Already allocated */
continue;
if (!r->start) /* Address not assigned at all */
if (!r->start) /* Address not assigned at all */
continue;
if (r->flags & IORESOURCE_IO)
disabled = !(command & PCI_COMMAND_IO);
Expand All @@ -277,107 +270,57 @@ static void pcibios_allocate_dev_resources(struct pci_dev *dev, int pass)
}
}
}
if (!pass) {
r = &dev->resource[PCI_ROM_RESOURCE];
if (r->flags & IORESOURCE_ROM_ENABLE) {
/* Turn the ROM off, leave the resource region,
* but keep it unregistered. */
u32 reg;
dev_dbg(&dev->dev, "disabling ROM %pR\n", r);
r->flags &= ~IORESOURCE_ROM_ENABLE;
pci_read_config_dword(dev, dev->rom_base_reg, &reg);
pci_write_config_dword(dev, dev->rom_base_reg,
if (!pass) {
r = &dev->resource[PCI_ROM_RESOURCE];
if (r->flags & IORESOURCE_ROM_ENABLE) {
/* Turn the ROM off, leave the resource region,
* but keep it unregistered. */
u32 reg;
dev_dbg(&dev->dev, "disabling ROM %pR\n", r);
r->flags &= ~IORESOURCE_ROM_ENABLE;
pci_read_config_dword(dev,
dev->rom_base_reg, &reg);
pci_write_config_dword(dev, dev->rom_base_reg,
reg & ~PCI_ROM_ADDRESS_ENABLE);
}
}
}
}

static void pcibios_allocate_resources(struct pci_bus *bus, int pass)
{
struct pci_dev *dev;
struct pci_bus *child;

list_for_each_entry(dev, &bus->devices, bus_list) {
pcibios_allocate_dev_resources(dev, pass);

child = dev->subordinate;
if (child)
pcibios_allocate_resources(child, pass);
}
}

static void pcibios_allocate_dev_rom_resource(struct pci_dev *dev)
static int __init pcibios_assign_resources(void)
{
struct pci_dev *dev = NULL;
struct resource *r;

/*
* Try to use BIOS settings for ROMs, otherwise let
* pci_assign_unassigned_resources() allocate the new
* addresses.
*/
r = &dev->resource[PCI_ROM_RESOURCE];
if (!r->flags || !r->start)
return;

if (pci_claim_resource(dev, PCI_ROM_RESOURCE) < 0) {
r->end -= r->start;
r->start = 0;
}
}
static void pcibios_allocate_rom_resources(struct pci_bus *bus)
{
struct pci_dev *dev;
struct pci_bus *child;

list_for_each_entry(dev, &bus->devices, bus_list) {
pcibios_allocate_dev_rom_resource(dev);

child = dev->subordinate;
if (child)
pcibios_allocate_rom_resources(child);
if (!(pci_probe & PCI_ASSIGN_ROMS)) {
/*
* Try to use BIOS settings for ROMs, otherwise let
* pci_assign_unassigned_resources() allocate the new
* addresses.
*/
for_each_pci_dev(dev) {
r = &dev->resource[PCI_ROM_RESOURCE];
if (!r->flags || !r->start)
continue;
if (pci_claim_resource(dev, PCI_ROM_RESOURCE) < 0) {
r->end -= r->start;
r->start = 0;
}
}
}
}

static int __init pcibios_assign_resources(void)
{
struct pci_bus *bus;

if (!(pci_probe & PCI_ASSIGN_ROMS))
list_for_each_entry(bus, &pci_root_buses, node)
pcibios_allocate_rom_resources(bus);

pci_assign_unassigned_resources();
pcibios_fw_addr_list_del();

return 0;
}

void pcibios_resource_survey_bus(struct pci_bus *bus)
{
dev_printk(KERN_DEBUG, &bus->dev, "Allocating resources\n");

pcibios_allocate_bus_resources(bus);

pcibios_allocate_resources(bus, 0);
pcibios_allocate_resources(bus, 1);

if (!(pci_probe & PCI_ASSIGN_ROMS))
pcibios_allocate_rom_resources(bus);
}

void __init pcibios_resource_survey(void)
{
struct pci_bus *bus;

DBG("PCI: Allocating resources\n");

list_for_each_entry(bus, &pci_root_buses, node)
pcibios_allocate_bus_resources(bus);

list_for_each_entry(bus, &pci_root_buses, node)
pcibios_allocate_resources(bus, 0);
list_for_each_entry(bus, &pci_root_buses, node)
pcibios_allocate_resources(bus, 1);
pcibios_allocate_bus_resources(&pci_root_buses);
pcibios_allocate_resources(0);
pcibios_allocate_resources(1);

e820_reserve_resources_late();
/*
Expand Down
Loading

0 comments on commit fea2f35

Please sign in to comment.