summaryrefslogtreecommitdiff
path: root/arch/x86/pci
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2009-11-13 17:34:39 -0700
committerJesse Barnes <jbarnes@virtuousgeek.org>2009-11-24 15:30:01 -0800
commit3f0f5503926f7447615f083c2d57545a83b6357c (patch)
tree9ab3d2378eea794c34baac952eb753b31afd673d /arch/x86/pci
parent2f2a8b9c90279e75f87aaf322a948bdced27e89f (diff)
downloadlinux-3.10-3f0f5503926f7447615f083c2d57545a83b6357c.tar.gz
linux-3.10-3f0f5503926f7447615f083c2d57545a83b6357c.tar.bz2
linux-3.10-3f0f5503926f7447615f083c2d57545a83b6357c.zip
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 fdf08f97131..78fa05c6c04 100644
--- a/arch/x86/pci/mmconfig_64.c
+++ b/arch/x86/pci/mmconfig_64.c
@@ -12,24 +12,17 @@
#include <asm/e820.h>
#include <asm/pci_x86.h>
-/* Static virtual mapping of the MMCONFIG aperture */
-struct mmcfg_virt {
- struct pci_mmcfg_region *cfg;
- char __iomem *virt;
-};
-static struct mmcfg_virt *pci_mmcfg_virt;
-
static char __iomem *get_virt(unsigned int seg, unsigned bus)
{
+ int i;
struct pci_mmcfg_region *cfg;
- int cfg_num;
- for (cfg_num = 0; cfg_num < pci_mmcfg_config_num; cfg_num++) {
- cfg = pci_mmcfg_virt[cfg_num].cfg;
+ for (i = 0; i < pci_mmcfg_config_num; ++i) {
+ cfg = &pci_mmcfg_config[i];
if (cfg->segment == seg &&
(cfg->start_bus <= bus) &&
(cfg->end_bus >= bus))
- return pci_mmcfg_virt[cfg_num].virt;
+ return cfg->virt;
}
/* Fall back to type 0 */
@@ -130,20 +123,15 @@ static void __iomem * __init mcfg_ioremap(struct pci_mmcfg_region *cfg)
int __init pci_mmcfg_arch_init(void)
{
int i;
- pci_mmcfg_virt = kzalloc(sizeof(*pci_mmcfg_virt) *
- pci_mmcfg_config_num, GFP_KERNEL);
- if (pci_mmcfg_virt == NULL) {
- printk(KERN_ERR "PCI: Can not allocate memory for mmconfig structures\n");
- return 0;
- }
+ struct pci_mmcfg_region *cfg;
for (i = 0; i < pci_mmcfg_config_num; ++i) {
- pci_mmcfg_virt[i].cfg = &pci_mmcfg_config[i];
- pci_mmcfg_virt[i].virt = mcfg_ioremap(&pci_mmcfg_config[i]);
- if (!pci_mmcfg_virt[i].virt) {
+ cfg = &pci_mmcfg_config[i];
+ cfg->virt = mcfg_ioremap(cfg);
+ if (!cfg->virt) {
printk(KERN_ERR "PCI: Cannot map mmconfig aperture for "
"segment %d\n",
- pci_mmcfg_config[i].segment);
+ cfg->segment);
pci_mmcfg_arch_free();
return 0;
}
@@ -155,18 +143,13 @@ int __init pci_mmcfg_arch_init(void)
void __init pci_mmcfg_arch_free(void)
{
int i;
-
- if (pci_mmcfg_virt == NULL)
- return;
+ struct pci_mmcfg_region *cfg;
for (i = 0; i < pci_mmcfg_config_num; ++i) {
- if (pci_mmcfg_virt[i].virt) {
- iounmap(pci_mmcfg_virt[i].virt + PCI_MMCFG_BUS_OFFSET(pci_mmcfg_virt[i].cfg->start_bus));
- pci_mmcfg_virt[i].virt = NULL;
- pci_mmcfg_virt[i].cfg = NULL;
+ cfg = &pci_mmcfg_config[i];
+ if (cfg->virt) {
+ iounmap(cfg->virt + PCI_MMCFG_BUS_OFFSET(cfg->start_bus));
+ cfg->virt = NULL;
}
}
-
- kfree(pci_mmcfg_virt);
- pci_mmcfg_virt = NULL;
}