aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/pci
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2009-11-13 19:34:39 -0500
committerJesse Barnes <jbarnes@virtuousgeek.org>2009-11-24 18:30:01 -0500
commit3f0f5503926f7447615f083c2d57545a83b6357c (patch)
tree9ab3d2378eea794c34baac952eb753b31afd673d /arch/x86/pci
parent2f2a8b9c90279e75f87aaf322a948bdced27e89f (diff)
x86/PCI: MMCONFIG: add virtual address to struct pci_mmcfg_region
The virtual address is only used for x86_64, but it's so much simpler to manage it as part of the pci_mmcfg_region that I think it's worth wasting a pointer per MMCONFIG region on x86_32. 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_64.c45
1 files changed, 14 insertions, 31 deletions
diff --git a/arch/x86/pci/mmconfig_64.c b/arch/x86/pci/mmconfig_64.c
index fdf08f97131b..78fa05c6c04d 100644
--- a/arch/x86/pci/mmconfig_64.c
+++ b/arch/x86/pci/mmconfig_64.c
@@ -12,24 +12,17 @@
12#include <asm/e820.h> 12#include <asm/e820.h>
13#include <asm/pci_x86.h> 13#include <asm/pci_x86.h>
14 14
15/* Static virtual mapping of the MMCONFIG aperture */
16struct mmcfg_virt {
17 struct pci_mmcfg_region *cfg;
18 char __iomem *virt;
19};
20static struct mmcfg_virt *pci_mmcfg_virt;
21
22static char __iomem *get_virt(unsigned int seg, unsigned bus) 15static char __iomem *get_virt(unsigned int seg, unsigned bus)
23{ 16{
17 int i;
24 struct pci_mmcfg_region *cfg; 18 struct pci_mmcfg_region *cfg;
25 int cfg_num;
26 19
27 for (cfg_num = 0; cfg_num < pci_mmcfg_config_num; cfg_num++) { 20 for (i = 0; i < pci_mmcfg_config_num; ++i) {
28 cfg = pci_mmcfg_virt[cfg_num].cfg; 21 cfg = &pci_mmcfg_config[i];
29 if (cfg->segment == seg && 22 if (cfg->segment == seg &&
30 (cfg->start_bus <= bus) && 23 (cfg->start_bus <= bus) &&
31 (cfg->end_bus >= bus)) 24 (cfg->end_bus >= bus))
32 return pci_mmcfg_virt[cfg_num].virt; 25 return cfg->virt;
33 } 26 }
34 27
35 /* Fall back to type 0 */ 28 /* Fall back to type 0 */
@@ -130,20 +123,15 @@ static void __iomem * __init mcfg_ioremap(struct pci_mmcfg_region *cfg)
130int __init pci_mmcfg_arch_init(void) 123int __init pci_mmcfg_arch_init(void)
131{ 124{
132 int i; 125 int i;
133 pci_mmcfg_virt = kzalloc(sizeof(*pci_mmcfg_virt) * 126 struct pci_mmcfg_region *cfg;
134 pci_mmcfg_config_num, GFP_KERNEL);
135 if (pci_mmcfg_virt == NULL) {
136 printk(KERN_ERR "PCI: Can not allocate memory for mmconfig structures\n");
137 return 0;
138 }
139 127
140 for (i = 0; i < pci_mmcfg_config_num; ++i) { 128 for (i = 0; i < pci_mmcfg_config_num; ++i) {
141 pci_mmcfg_virt[i].cfg = &pci_mmcfg_config[i]; 129 cfg = &pci_mmcfg_config[i];
142 pci_mmcfg_virt[i].virt = mcfg_ioremap(&pci_mmcfg_config[i]); 130 cfg->virt = mcfg_ioremap(cfg);
143 if (!pci_mmcfg_virt[i].virt) { 131 if (!cfg->virt) {
144 printk(KERN_ERR "PCI: Cannot map mmconfig aperture for " 132 printk(KERN_ERR "PCI: Cannot map mmconfig aperture for "
145 "segment %d\n", 133 "segment %d\n",
146 pci_mmcfg_config[i].segment); 134 cfg->segment);
147 pci_mmcfg_arch_free(); 135 pci_mmcfg_arch_free();
148 return 0; 136 return 0;
149 } 137 }
@@ -155,18 +143,13 @@ int __init pci_mmcfg_arch_init(void)
155void __init pci_mmcfg_arch_free(void) 143void __init pci_mmcfg_arch_free(void)
156{ 144{
157 int i; 145 int i;
158 146 struct pci_mmcfg_region *cfg;
159 if (pci_mmcfg_virt == NULL)
160 return;
161 147
162 for (i = 0; i < pci_mmcfg_config_num; ++i) { 148 for (i = 0; i < pci_mmcfg_config_num; ++i) {
163 if (pci_mmcfg_virt[i].virt) { 149 cfg = &pci_mmcfg_config[i];
164 iounmap(pci_mmcfg_virt[i].virt + PCI_MMCFG_BUS_OFFSET(pci_mmcfg_virt[i].cfg->start_bus)); 150 if (cfg->virt) {
165 pci_mmcfg_virt[i].virt = NULL; 151 iounmap(cfg->virt + PCI_MMCFG_BUS_OFFSET(cfg->start_bus));
166 pci_mmcfg_virt[i].cfg = NULL; 152 cfg->virt = NULL;
167 } 153 }
168 } 154 }
169
170 kfree(pci_mmcfg_virt);
171 pci_mmcfg_virt = NULL;
172} 155}