aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2010-12-17 19:58:40 -0500
committerH. Peter Anvin <hpa@linux.intel.com>2010-12-29 17:46:54 -0500
commit32e3f2b00c529477d26895c5428ed95bba537443 (patch)
tree234eb05abd0060d6fc343583de99e248e27d9d68
parent4b239f458c229de044d6905c2b0f9fe16ed9e01e (diff)
x86-64, gart: Fix allocation with memblock
When trying to change alloc_bootmem with memblock to go with real top-down Found one old system: [ 0.000000] Node 0: aperture @ ac000000 size 64 MB [ 0.000000] Aperture pointing to e820 RAM. Ignoring. [ 0.000000] Your BIOS doesn't leave a aperture memory hole [ 0.000000] Please enable the IOMMU option in the BIOS setup [ 0.000000] This costs you 64 MB of RAM [ 0.000000] memblock_x86_reserve_range: [0x2020000000-0x2023ffffff] aperture64 [ 0.000000] Cannot allocate aperture memory hole (ffff882020000000,65536K) [ 0.000000] memblock_x86_free_range: [0x2020000000-0x2023ffffff] [ 0.000000] Kernel panic - not syncing: Not enough memory for aperture [ 0.000000] Pid: 0, comm: swapper Not tainted 2.6.37-rc5-tip-yh-06229-gb792dc2-dirty #331 [ 0.000000] Call Trace: [ 0.000000] [<ffffffff81cf50fe>] ? panic+0x91/0x1a3 [ 0.000000] [<ffffffff827c66b2>] ? gart_iommu_hole_init+0x3d7/0x4a3 [ 0.000000] [<ffffffff81d026a9>] ? _etext+0x0/0x3 [ 0.000000] [<ffffffff827ba940>] ? pci_iommu_alloc+0x47/0x71 [ 0.000000] [<ffffffff827c820b>] ? mem_init+0x19/0xec [ 0.000000] [<ffffffff827b3c40>] ? start_kernel+0x20a/0x3e8 [ 0.000000] [<ffffffff827b32cc>] ? x86_64_start_reservations+0x9c/0xa0 [ 0.000000] [<ffffffff827b33e4>] ? x86_64_start_kernel+0x114/0x11b it means __alloc_bootmem_nopanic() get too high for that aperture. Use memblock_find_in_range() with limit directly. Signed-off-by: Yinghai Lu <yinghai@kernel.org> LKML-Reference: <4D0C0740.90104@kernel.org> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--arch/x86/kernel/aperture_64.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/arch/x86/kernel/aperture_64.c b/arch/x86/kernel/aperture_64.c
index dcd7c83e1659..85f66b4f4fee 100644
--- a/arch/x86/kernel/aperture_64.c
+++ b/arch/x86/kernel/aperture_64.c
@@ -13,7 +13,7 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/types.h> 14#include <linux/types.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/bootmem.h> 16#include <linux/memblock.h>
17#include <linux/mmzone.h> 17#include <linux/mmzone.h>
18#include <linux/pci_ids.h> 18#include <linux/pci_ids.h>
19#include <linux/pci.h> 19#include <linux/pci.h>
@@ -69,7 +69,7 @@ static void __init insert_aperture_resource(u32 aper_base, u32 aper_size)
69static u32 __init allocate_aperture(void) 69static u32 __init allocate_aperture(void)
70{ 70{
71 u32 aper_size; 71 u32 aper_size;
72 void *p; 72 unsigned long addr;
73 73
74 /* aper_size should <= 1G */ 74 /* aper_size should <= 1G */
75 if (fallback_aper_order > 5) 75 if (fallback_aper_order > 5)
@@ -95,27 +95,26 @@ static u32 __init allocate_aperture(void)
95 * so don't use 512M below as gart iommu, leave the space for kernel 95 * so don't use 512M below as gart iommu, leave the space for kernel
96 * code for safe 96 * code for safe
97 */ 97 */
98 p = __alloc_bootmem_nopanic(aper_size, aper_size, 512ULL<<20); 98 addr = memblock_find_in_range(0, 1ULL<<32, aper_size, 512ULL<<20);
99 if (addr == MEMBLOCK_ERROR || addr + aper_size > 0xffffffff) {
100 printk(KERN_ERR
101 "Cannot allocate aperture memory hole (%lx,%uK)\n",
102 addr, aper_size>>10);
103 return 0;
104 }
105 memblock_x86_reserve_range(addr, addr + aper_size, "aperture64");
99 /* 106 /*
100 * Kmemleak should not scan this block as it may not be mapped via the 107 * Kmemleak should not scan this block as it may not be mapped via the
101 * kernel direct mapping. 108 * kernel direct mapping.
102 */ 109 */
103 kmemleak_ignore(p); 110 kmemleak_ignore(phys_to_virt(addr));
104 if (!p || __pa(p)+aper_size > 0xffffffff) {
105 printk(KERN_ERR
106 "Cannot allocate aperture memory hole (%p,%uK)\n",
107 p, aper_size>>10);
108 if (p)
109 free_bootmem(__pa(p), aper_size);
110 return 0;
111 }
112 printk(KERN_INFO "Mapping aperture over %d KB of RAM @ %lx\n", 111 printk(KERN_INFO "Mapping aperture over %d KB of RAM @ %lx\n",
113 aper_size >> 10, __pa(p)); 112 aper_size >> 10, addr);
114 insert_aperture_resource((u32)__pa(p), aper_size); 113 insert_aperture_resource((u32)addr, aper_size);
115 register_nosave_region((u32)__pa(p) >> PAGE_SHIFT, 114 register_nosave_region(addr >> PAGE_SHIFT,
116 (u32)__pa(p+aper_size) >> PAGE_SHIFT); 115 (addr+aper_size) >> PAGE_SHIFT);
117 116
118 return (u32)__pa(p); 117 return (u32)addr;
119} 118}
120 119
121 120