diff options
| -rw-r--r-- | arch/x86/kernel/aperture_64.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/arch/x86/kernel/aperture_64.c b/arch/x86/kernel/aperture_64.c index dcd7c83e165..85f66b4f4fe 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) | |||
| 69 | static u32 __init allocate_aperture(void) | 69 | static 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 | ||
