diff options
author | Bjorn Helgaas <bjorn.helgaas@hp.com> | 2009-11-13 19:34:08 -0500 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2009-11-24 18:29:11 -0500 |
commit | df5eb1d67e8074dfbc23cf396c556116728187b3 (patch) | |
tree | 1512457b52c6763ee9921094f62690d0a3b8b1e3 /arch/x86/pci | |
parent | f7ca69848786bb99fdfafb511791b078c298438e (diff) |
x86/PCI: MMCONFIG: add PCI_MMCFG_BUS_OFFSET() to factor common expression
This factors out the common "bus << 20" expression used when computing the
MMCONFIG address.
Reviewed-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'arch/x86/pci')
-rw-r--r-- | arch/x86/pci/mmconfig-shared.c | 16 | ||||
-rw-r--r-- | arch/x86/pci/mmconfig_32.c | 2 | ||||
-rw-r--r-- | arch/x86/pci/mmconfig_64.c | 15 |
3 files changed, 16 insertions, 17 deletions
diff --git a/arch/x86/pci/mmconfig-shared.c b/arch/x86/pci/mmconfig-shared.c index 067a2cfed15c..4820f0e8c594 100644 --- a/arch/x86/pci/mmconfig-shared.c +++ b/arch/x86/pci/mmconfig-shared.c | |||
@@ -355,8 +355,9 @@ static void __init pci_mmcfg_insert_resources(void) | |||
355 | snprintf(names, PCI_MMCFG_RESOURCE_NAME_LEN, | 355 | snprintf(names, PCI_MMCFG_RESOURCE_NAME_LEN, |
356 | "PCI MMCONFIG %u [%02x-%02x]", cfg->pci_segment, | 356 | "PCI MMCONFIG %u [%02x-%02x]", cfg->pci_segment, |
357 | cfg->start_bus_number, cfg->end_bus_number); | 357 | cfg->start_bus_number, cfg->end_bus_number); |
358 | res->start = cfg->address + (cfg->start_bus_number << 20); | 358 | res->start = cfg->address + |
359 | res->end = res->start + (num_buses << 20) - 1; | 359 | PCI_MMCFG_BUS_OFFSET(cfg->start_bus_number); |
360 | res->end = res->start + PCI_MMCFG_BUS_OFFSET(num_buses) - 1; | ||
360 | res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; | 361 | res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; |
361 | insert_resource(&iomem_resource, res); | 362 | insert_resource(&iomem_resource, res); |
362 | names += PCI_MMCFG_RESOURCE_NAME_LEN; | 363 | names += PCI_MMCFG_RESOURCE_NAME_LEN; |
@@ -478,15 +479,14 @@ static void __init pci_mmcfg_reject_broken(int early) | |||
478 | return; | 479 | return; |
479 | 480 | ||
480 | for (i = 0; i < pci_mmcfg_config_num; i++) { | 481 | for (i = 0; i < pci_mmcfg_config_num; i++) { |
481 | int valid = 0; | 482 | int num_buses, valid = 0; |
482 | u64 addr, size; | 483 | u64 addr, size; |
483 | 484 | ||
484 | cfg = &pci_mmcfg_config[i]; | 485 | cfg = &pci_mmcfg_config[i]; |
485 | addr = cfg->start_bus_number; | 486 | addr = cfg->address + |
486 | addr <<= 20; | 487 | PCI_MMCFG_BUS_OFFSET(cfg->start_bus_number); |
487 | addr += cfg->address; | 488 | num_buses = cfg->end_bus_number - cfg->start_bus_number + 1; |
488 | size = cfg->end_bus_number + 1 - cfg->start_bus_number; | 489 | size = PCI_MMCFG_BUS_OFFSET(num_buses); |
489 | size <<= 20; | ||
490 | printk(KERN_NOTICE "PCI: MCFG configuration %d: base %lx " | 490 | printk(KERN_NOTICE "PCI: MCFG configuration %d: base %lx " |
491 | "segment %hu buses %u - %u\n", | 491 | "segment %hu buses %u - %u\n", |
492 | i, (unsigned long)cfg->address, cfg->pci_segment, | 492 | i, (unsigned long)cfg->address, cfg->pci_segment, |
diff --git a/arch/x86/pci/mmconfig_32.c b/arch/x86/pci/mmconfig_32.c index f10a7e94a84c..8c19df89ad75 100644 --- a/arch/x86/pci/mmconfig_32.c +++ b/arch/x86/pci/mmconfig_32.c | |||
@@ -47,7 +47,7 @@ static u32 get_base_addr(unsigned int seg, int bus, unsigned devfn) | |||
47 | */ | 47 | */ |
48 | static void pci_exp_set_dev_base(unsigned int base, int bus, int devfn) | 48 | static void pci_exp_set_dev_base(unsigned int base, int bus, int devfn) |
49 | { | 49 | { |
50 | u32 dev_base = base | (bus << 20) | (devfn << 12); | 50 | u32 dev_base = base | PCI_MMCFG_BUS_OFFSET(bus) | (devfn << 12); |
51 | int cpu = smp_processor_id(); | 51 | int cpu = smp_processor_id(); |
52 | if (dev_base != mmcfg_last_accessed_device || | 52 | if (dev_base != mmcfg_last_accessed_device || |
53 | cpu != mmcfg_last_accessed_cpu) { | 53 | cpu != mmcfg_last_accessed_cpu) { |
diff --git a/arch/x86/pci/mmconfig_64.c b/arch/x86/pci/mmconfig_64.c index 94349f8b2f96..8588711924cc 100644 --- a/arch/x86/pci/mmconfig_64.c +++ b/arch/x86/pci/mmconfig_64.c | |||
@@ -43,7 +43,7 @@ static char __iomem *pci_dev_base(unsigned int seg, unsigned int bus, unsigned i | |||
43 | addr = get_virt(seg, bus); | 43 | addr = get_virt(seg, bus); |
44 | if (!addr) | 44 | if (!addr) |
45 | return NULL; | 45 | return NULL; |
46 | return addr + ((bus << 20) | (devfn << 12)); | 46 | return addr + (PCI_MMCFG_BUS_OFFSET(bus) | (devfn << 12)); |
47 | } | 47 | } |
48 | 48 | ||
49 | static int pci_mmcfg_read(unsigned int seg, unsigned int bus, | 49 | static int pci_mmcfg_read(unsigned int seg, unsigned int bus, |
@@ -113,17 +113,16 @@ static void __iomem * __init mcfg_ioremap(struct acpi_mcfg_allocation *cfg) | |||
113 | { | 113 | { |
114 | void __iomem *addr; | 114 | void __iomem *addr; |
115 | u64 start, size; | 115 | u64 start, size; |
116 | int num_buses; | ||
116 | 117 | ||
117 | start = cfg->start_bus_number; | 118 | start = cfg->address + PCI_MMCFG_BUS_OFFSET(cfg->start_bus_number); |
118 | start <<= 20; | 119 | num_buses = cfg->end_bus_number - cfg->start_bus_number + 1; |
119 | start += cfg->address; | 120 | size = PCI_MMCFG_BUS_OFFSET(num_buses); |
120 | size = cfg->end_bus_number + 1 - cfg->start_bus_number; | ||
121 | size <<= 20; | ||
122 | addr = ioremap_nocache(start, size); | 121 | addr = ioremap_nocache(start, size); |
123 | if (addr) { | 122 | if (addr) { |
124 | printk(KERN_INFO "PCI: Using MMCONFIG at %Lx - %Lx\n", | 123 | printk(KERN_INFO "PCI: Using MMCONFIG at %Lx - %Lx\n", |
125 | start, start + size - 1); | 124 | start, start + size - 1); |
126 | addr -= cfg->start_bus_number << 20; | 125 | addr -= PCI_MMCFG_BUS_OFFSET(cfg->start_bus_number); |
127 | } | 126 | } |
128 | return addr; | 127 | return addr; |
129 | } | 128 | } |
@@ -162,7 +161,7 @@ void __init pci_mmcfg_arch_free(void) | |||
162 | 161 | ||
163 | for (i = 0; i < pci_mmcfg_config_num; ++i) { | 162 | for (i = 0; i < pci_mmcfg_config_num; ++i) { |
164 | if (pci_mmcfg_virt[i].virt) { | 163 | if (pci_mmcfg_virt[i].virt) { |
165 | iounmap(pci_mmcfg_virt[i].virt + (pci_mmcfg_virt[i].cfg->start_bus_number << 20)); | 164 | iounmap(pci_mmcfg_virt[i].virt + PCI_MMCFG_BUS_OFFSET(pci_mmcfg_virt[i].cfg->start_bus_number)); |
166 | pci_mmcfg_virt[i].virt = NULL; | 165 | pci_mmcfg_virt[i].virt = NULL; |
167 | pci_mmcfg_virt[i].cfg = NULL; | 166 | pci_mmcfg_virt[i].cfg = NULL; |
168 | } | 167 | } |