提交 0b64ad71 编写于 作者: Y Yinghai Lu 提交者: Ingo Molnar

x86: clear pci_mmcfg_virt when mmcfg get rejected

For x86_64, need to free pci_mmcfg_virt, and iounmap some pointers
when MMCONF is not reserved in E820 or acpi _CRS and get rejected.
Signed-off-by: NYinghai Lu <yinghai.lu@sun.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Greg KH <greg@kroah.com>
Cc: Greg KH <greg@kroah.com>
Cc: Andi Kleen <ak@suse.de>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
上级 7752d5cf
...@@ -300,6 +300,7 @@ static void __init pci_mmcfg_reject_broken(void) ...@@ -300,6 +300,7 @@ static void __init pci_mmcfg_reject_broken(void)
reject: reject:
printk(KERN_ERR "PCI: Not using MMCONFIG.\n"); printk(KERN_ERR "PCI: Not using MMCONFIG.\n");
pci_mmcfg_arch_free();
kfree(pci_mmcfg_config); kfree(pci_mmcfg_config);
pci_mmcfg_config = NULL; pci_mmcfg_config = NULL;
pci_mmcfg_config_num = 0; pci_mmcfg_config_num = 0;
......
...@@ -136,3 +136,7 @@ int __init pci_mmcfg_arch_init(void) ...@@ -136,3 +136,7 @@ int __init pci_mmcfg_arch_init(void)
raw_pci_ext_ops = &pci_mmcfg; raw_pci_ext_ops = &pci_mmcfg;
return 1; return 1;
} }
void __init pci_mmcfg_arch_free(void)
{
}
...@@ -127,7 +127,7 @@ static void __iomem * __init mcfg_ioremap(struct acpi_mcfg_allocation *cfg) ...@@ -127,7 +127,7 @@ static void __iomem * __init mcfg_ioremap(struct acpi_mcfg_allocation *cfg)
int __init pci_mmcfg_arch_init(void) int __init pci_mmcfg_arch_init(void)
{ {
int i; int i;
pci_mmcfg_virt = kmalloc(sizeof(*pci_mmcfg_virt) * pci_mmcfg_virt = kzalloc(sizeof(*pci_mmcfg_virt) *
pci_mmcfg_config_num, GFP_KERNEL); pci_mmcfg_config_num, GFP_KERNEL);
if (pci_mmcfg_virt == NULL) { if (pci_mmcfg_virt == NULL) {
printk(KERN_ERR "PCI: Can not allocate memory for mmconfig structures\n"); printk(KERN_ERR "PCI: Can not allocate memory for mmconfig structures\n");
...@@ -141,9 +141,29 @@ int __init pci_mmcfg_arch_init(void) ...@@ -141,9 +141,29 @@ int __init pci_mmcfg_arch_init(void)
printk(KERN_ERR "PCI: Cannot map mmconfig aperture for " printk(KERN_ERR "PCI: Cannot map mmconfig aperture for "
"segment %d\n", "segment %d\n",
pci_mmcfg_config[i].pci_segment); pci_mmcfg_config[i].pci_segment);
pci_mmcfg_arch_free();
return 0; return 0;
} }
} }
raw_pci_ext_ops = &pci_mmcfg; raw_pci_ext_ops = &pci_mmcfg;
return 1; return 1;
} }
void __init pci_mmcfg_arch_free(void)
{
int i;
if (pci_mmcfg_virt == NULL)
return;
for (i = 0; i < pci_mmcfg_config_num; ++i) {
if (pci_mmcfg_virt[i].virt) {
iounmap(pci_mmcfg_virt[i].virt);
pci_mmcfg_virt[i].virt = NULL;
pci_mmcfg_virt[i].cfg = NULL;
}
}
kfree(pci_mmcfg_virt);
pci_mmcfg_virt = NULL;
}
...@@ -101,6 +101,7 @@ extern void pci_pcbios_init(void); ...@@ -101,6 +101,7 @@ extern void pci_pcbios_init(void);
/* pci-mmconfig.c */ /* pci-mmconfig.c */
extern int __init pci_mmcfg_arch_init(void); extern int __init pci_mmcfg_arch_init(void);
extern void __init pci_mmcfg_arch_free(void);
/* /*
* AMD Fam10h CPUs are buggy, and cannot access MMIO config space * AMD Fam10h CPUs are buggy, and cannot access MMIO config space
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册