aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/pci/mmconfig_64.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/pci/mmconfig_64.c')
-rw-r--r--arch/x86/pci/mmconfig_64.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/arch/x86/pci/mmconfig_64.c b/arch/x86/pci/mmconfig_64.c
index 9207fd49233c..a1994163c99d 100644
--- a/arch/x86/pci/mmconfig_64.c
+++ b/arch/x86/pci/mmconfig_64.c
@@ -127,7 +127,7 @@ static void __iomem * __init mcfg_ioremap(struct acpi_mcfg_allocation *cfg)
127int __init pci_mmcfg_arch_init(void) 127int __init pci_mmcfg_arch_init(void)
128{ 128{
129 int i; 129 int i;
130 pci_mmcfg_virt = kmalloc(sizeof(*pci_mmcfg_virt) * 130 pci_mmcfg_virt = kzalloc(sizeof(*pci_mmcfg_virt) *
131 pci_mmcfg_config_num, GFP_KERNEL); 131 pci_mmcfg_config_num, GFP_KERNEL);
132 if (pci_mmcfg_virt == NULL) { 132 if (pci_mmcfg_virt == NULL) {
133 printk(KERN_ERR "PCI: Can not allocate memory for mmconfig structures\n"); 133 printk(KERN_ERR "PCI: Can not allocate memory for mmconfig structures\n");
@@ -141,9 +141,29 @@ int __init pci_mmcfg_arch_init(void)
141 printk(KERN_ERR "PCI: Cannot map mmconfig aperture for " 141 printk(KERN_ERR "PCI: Cannot map mmconfig aperture for "
142 "segment %d\n", 142 "segment %d\n",
143 pci_mmcfg_config[i].pci_segment); 143 pci_mmcfg_config[i].pci_segment);
144 pci_mmcfg_arch_free();
144 return 0; 145 return 0;
145 } 146 }
146 } 147 }
147 raw_pci_ext_ops = &pci_mmcfg; 148 raw_pci_ext_ops = &pci_mmcfg;
148 return 1; 149 return 1;
149} 150}
151
152void __init pci_mmcfg_arch_free(void)
153{
154 int i;
155
156 if (pci_mmcfg_virt == NULL)
157 return;
158
159 for (i = 0; i < pci_mmcfg_config_num; ++i) {
160 if (pci_mmcfg_virt[i].virt) {
161 iounmap(pci_mmcfg_virt[i].virt);
162 pci_mmcfg_virt[i].virt = NULL;
163 pci_mmcfg_virt[i].cfg = NULL;
164 }
165 }
166
167 kfree(pci_mmcfg_virt);
168 pci_mmcfg_virt = NULL;
169}