diff --git a/arch/sparc/include/mm.h b/arch/sparc/include/mm.h index 5508c19b1926c25fe6f8fea5063341e825a0be3c..e5a5f11c31d4887fc1a6f71db5393275726ba1b6 100644 --- a/arch/sparc/include/mm.h +++ b/arch/sparc/include/mm.h @@ -17,7 +17,7 @@ * last valid one has num_bytes==0. */ -struct sparc_physical_banks { +struct sparc_physical_bank { unsigned long base_addr; unsigned long num_bytes; }; @@ -28,7 +28,7 @@ struct sparc_physical_banks { #define SPARC_PHYS_BANKS 0 #endif -extern struct sparc_physical_banks sp_banks[SPARC_PHYS_BANKS + 1]; +extern struct sparc_physical_bank sp_banks[SPARC_PHYS_BANKS + 1]; /* linker symbol marking the the start of the program (image) */ diff --git a/arch/sparc/kernel/bootmem.c b/arch/sparc/kernel/bootmem.c index f554ccf08983967a7bf491d0d17c3a0304e92af4..a5e15cfc0c8ff1b28c5456849e7de323e228e5a9 100644 --- a/arch/sparc/kernel/bootmem.c +++ b/arch/sparc/kernel/bootmem.c @@ -100,14 +100,17 @@ void *bootmem_alloc(size_t size) { void *ptr; + unsigned long flags; + + if (!size) return NULL; - arch_local_irq_disable(); + flags = arch_local_irq_save(); spin_lock_raw(&bootmem_lock); ptr = chunk_alloc(&phys_mem_pool, size); spin_unlock(&bootmem_lock); - arch_local_irq_enable(); + arch_local_irq_restore(flags); if (!ptr) { pr_emerg("BOOTMEM: allocator out of memory\n"); @@ -126,17 +129,41 @@ void *bootmem_alloc(size_t size) void bootmem_free(void *ptr) { -#if 0 - arch_local_irq_disable(); -#endif + unsigned long flags; + + flags = arch_local_irq_save(); spin_lock_raw(&bootmem_lock); chunk_free(&phys_mem_pool, ptr); spin_unlock(&bootmem_lock); -#if 0 - arch_local_irq_enable(); -#endif + arch_local_irq_restore(flags); +} + + +/** + * @brief allocate and add a page map node + */ + +static void bootmem_init_page_map_node(struct page_map_node **pg_node) +{ + struct mm_pool *pool; + + + /* let's assume we always have enough memory, because if we + * don't, there is a serious configuration problem anyways + */ + + (*pg_node) = (struct page_map_node *) bootmem_alloc(sizeof(struct page_map_node)); + + pool = (*pg_node)->pool; + pool = (struct mm_pool *) bootmem_alloc(sizeof(struct mm_pool)); + + bzero(pool, sizeof(struct mm_pool)); + + pool->block_order = (struct list_head *) bootmem_alloc(sizeof(struct list_head) * (MM_BLOCK_ORDER_MAX + 1)); + pool->alloc_order = (unsigned char *) bootmem_alloc(MM_INIT_NUM_BLOCKS); + pool->blk_free = (unsigned long *) bootmem_alloc(MM_INIT_LEN_BITMAP * sizeof(unsigned long)); } @@ -150,6 +177,7 @@ void bootmem_init(void) int ret; + unsigned long base_pfn; unsigned long start_pfn; unsigned long start_img_pfn; @@ -283,7 +311,6 @@ void bootmem_init(void) #else for (i = 0; sp_banks[i].num_bytes != 0; i++) { #endif - BUG_ON(i > SPARC_PHYS_BANKS); /* this one has already been added */ @@ -299,24 +326,11 @@ void bootmem_init(void) break; } - /* let's assume we always have enough memory, because if we - * don't, there is a serious configuration problem anyways - * - * XXX this should be a function... - */ - - (*pg_node) = (struct page_map_node *) bootmem_alloc(sizeof(struct page_map_node)); - (*pg_node)->pool = (struct mm_pool *) bootmem_alloc(sizeof(struct mm_pool)); - - bzero((*pg_node)->pool, sizeof(struct mm_pool)); - - (*pg_node)->pool->block_order = (struct list_head *) bootmem_alloc(sizeof(struct list_head) * (MM_BLOCK_ORDER_MAX + 1)); - (*pg_node)->pool->alloc_order = (unsigned char *) bootmem_alloc(MM_INIT_NUM_BLOCKS); - (*pg_node)->pool->blk_free = (unsigned long *) bootmem_alloc(MM_INIT_LEN_BITMAP * sizeof(unsigned long)); + bootmem_init_page_map_node(pg_node); ret = page_map_add(sp_banks[i].base_addr, - sp_banks[i].base_addr + sp_banks[i].num_bytes, - PAGE_SIZE); + sp_banks[i].base_addr + sp_banks[i].num_bytes, + PAGE_SIZE); if (ret) { pr_emerg("BOOTMEM: cannot add page map node\n"); diff --git a/arch/sparc/kernel/mm.c b/arch/sparc/kernel/mm.c index fc3b53c8b80f9fab6408e9cd365981d773007982..f69447085e6a296f2cece9eefdba7063ccfc5fc2 100644 --- a/arch/sparc/kernel/mm.c +++ b/arch/sparc/kernel/mm.c @@ -19,4 +19,4 @@ unsigned long phys_base; unsigned long pfn_base; -struct sparc_physical_banks sp_banks[SPARC_PHYS_BANKS + 1]; +struct sparc_physical_bank sp_banks[SPARC_PHYS_BANKS + 1];