Commit 0b64ad7123eb013c3de26750f2d4c356cd566231
Committed by
Ingo Molnar
1 parent
7752d5cfe3
Exists in
master
and in
4 other branches
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: Yinghai 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: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Showing 4 changed files with 27 additions and 1 deletions Side-by-side Diff
arch/x86/pci/mmconfig-shared.c
arch/x86/pci/mmconfig_32.c
arch/x86/pci/mmconfig_64.c
... | ... | @@ -127,7 +127,7 @@ |
127 | 127 | int __init pci_mmcfg_arch_init(void) |
128 | 128 | { |
129 | 129 | int i; |
130 | - pci_mmcfg_virt = kmalloc(sizeof(*pci_mmcfg_virt) * | |
130 | + pci_mmcfg_virt = kzalloc(sizeof(*pci_mmcfg_virt) * | |
131 | 131 | pci_mmcfg_config_num, GFP_KERNEL); |
132 | 132 | if (pci_mmcfg_virt == NULL) { |
133 | 133 | printk(KERN_ERR "PCI: Can not allocate memory for mmconfig structures\n"); |
134 | 134 | |
... | ... | @@ -141,10 +141,30 @@ |
141 | 141 | printk(KERN_ERR "PCI: Cannot map mmconfig aperture for " |
142 | 142 | "segment %d\n", |
143 | 143 | pci_mmcfg_config[i].pci_segment); |
144 | + pci_mmcfg_arch_free(); | |
144 | 145 | return 0; |
145 | 146 | } |
146 | 147 | } |
147 | 148 | raw_pci_ext_ops = &pci_mmcfg; |
148 | 149 | return 1; |
150 | +} | |
151 | + | |
152 | +void __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; | |
149 | 169 | } |
arch/x86/pci/pci.h