|
@@ -13,7 +13,7 @@
|
|
|
#include <linux/kernel.h>
|
|
|
#include <linux/types.h>
|
|
|
#include <linux/init.h>
|
|
|
-#include <linux/bootmem.h>
|
|
|
+#include <linux/memblock.h>
|
|
|
#include <linux/mmzone.h>
|
|
|
#include <linux/pci_ids.h>
|
|
|
#include <linux/pci.h>
|
|
@@ -69,7 +69,7 @@ static void __init insert_aperture_resource(u32 aper_base, u32 aper_size)
|
|
|
static u32 __init allocate_aperture(void)
|
|
|
{
|
|
|
u32 aper_size;
|
|
|
- void *p;
|
|
|
+ unsigned long addr;
|
|
|
|
|
|
/* aper_size should <= 1G */
|
|
|
if (fallback_aper_order > 5)
|
|
@@ -95,27 +95,26 @@ static u32 __init allocate_aperture(void)
|
|
|
* so don't use 512M below as gart iommu, leave the space for kernel
|
|
|
* code for safe
|
|
|
*/
|
|
|
- p = __alloc_bootmem_nopanic(aper_size, aper_size, 512ULL<<20);
|
|
|
+ addr = memblock_find_in_range(0, 1ULL<<32, aper_size, 512ULL<<20);
|
|
|
+ if (addr == MEMBLOCK_ERROR || addr + aper_size > 0xffffffff) {
|
|
|
+ printk(KERN_ERR
|
|
|
+ "Cannot allocate aperture memory hole (%lx,%uK)\n",
|
|
|
+ addr, aper_size>>10);
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ memblock_x86_reserve_range(addr, addr + aper_size, "aperture64");
|
|
|
/*
|
|
|
* Kmemleak should not scan this block as it may not be mapped via the
|
|
|
* kernel direct mapping.
|
|
|
*/
|
|
|
- kmemleak_ignore(p);
|
|
|
- if (!p || __pa(p)+aper_size > 0xffffffff) {
|
|
|
- printk(KERN_ERR
|
|
|
- "Cannot allocate aperture memory hole (%p,%uK)\n",
|
|
|
- p, aper_size>>10);
|
|
|
- if (p)
|
|
|
- free_bootmem(__pa(p), aper_size);
|
|
|
- return 0;
|
|
|
- }
|
|
|
+ kmemleak_ignore(phys_to_virt(addr));
|
|
|
printk(KERN_INFO "Mapping aperture over %d KB of RAM @ %lx\n",
|
|
|
- aper_size >> 10, __pa(p));
|
|
|
- insert_aperture_resource((u32)__pa(p), aper_size);
|
|
|
- register_nosave_region((u32)__pa(p) >> PAGE_SHIFT,
|
|
|
- (u32)__pa(p+aper_size) >> PAGE_SHIFT);
|
|
|
+ aper_size >> 10, addr);
|
|
|
+ insert_aperture_resource((u32)addr, aper_size);
|
|
|
+ register_nosave_region(addr >> PAGE_SHIFT,
|
|
|
+ (addr+aper_size) >> PAGE_SHIFT);
|
|
|
|
|
|
- return (u32)__pa(p);
|
|
|
+ return (u32)addr;
|
|
|
}
|
|
|
|
|
|
|