Skip to contentSkip to conversation

sparc32: replace bootmem with memblock

WIP Sam Ravnborg 2 participants 9 messages Jan 3, 2012 – Jan 13, 2012 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore
#0 lore raw

sparc32 uses a combination of a local memory handling and bootmem to handle memory in the early stage of the boot.

Some time ago I started to look at what was required to replace the local memory handling (sp_banks) with memblock - which I understood was the generic way to handle memory in the early phases of the boot.

Tejun have posted a nice series of patches that clean up memblock so it should be possible to replace bootmem too.

Now that this patchset is most likely hitting mainline in next merge window I decided to take a fresh look at introducing memblock for sparc32.

The following is a WIP patch.
It is posted to allow you to take a look and give early feedback.

As time permit I plan to divide the patch in a few smaller preparational pacthes - and one big patch that do the actual replacement.
I hope to have something working that I can post in good time before the 3.3 merge window - I will need testers before it can be applied to mainline.

The patch is maybe 90% finished - and the diffstat looks promising.

 11 files changed, 133 insertions(+), 391 deletions(-)

What is even better is that much of the added code is simpler than the code it replaces.

Some notes to the patch:

- The setup of memblock and much of the other memory stuff is moved to paging_init().
We no longer setup memory before calling start_kernel()

- The setup of initrd follows the same scheme as sparc64. I have deleted a check that I could not understand - and I could see sparc64 deleted the same check some time ago. It is:

- if (initrd_start) {
- if (initrd_start >= (start_pfn << PAGE_SHIFT) &&
- initrd_start < (start_pfn << PAGE_SHIFT) + 2 * PAGE_SIZE)
- bootmap_pfn = PAGE_ALIGN (initrd_end) >> PAGE_SHIFT;
- }

- Handling og highmen is like wrong.
I have not found any good source how to deal with highmen. What I did was to:
1) Locate all highmem added to memblock
(address > (phys_base + SRMMU_MAXMEM))
2) Map the highmem
3) reserve all the highmem in memblock - so it is not passed over to the page allocator.
this all takes place in paging_init()

- kern_addr_valid is (temporary) disabled
I could not grock the code allocating sparc_valid_addr_bitmap and I noticed most archs do not implement this check

- There is some code dealing with zholes_size[] that I know is buggy but need to understnad it first.

- Printing number of reserved pages are dropped as it was not trivial to implment in the same way.

- ARCH_PFN_OFFSET is dropped. It is unused
- pfn_valid is made as a simple range check
- virt_addr_valid is redefined to use pfn_valid - much simpler

My TODO items:
- split up in smaller patches, as feasible
- fix the zholes_size stuff
- add more comments
- address comments from this WIP posting
- get it working on my sparc32 box

Any comments are welcome!

Sam

 arch/sparc/Kconfig                  |    3 +-
 arch/sparc/include/asm/mmu_32.h     |    3 +
 arch/sparc/include/asm/oplib_32.h   |    1 +
 arch/sparc/include/asm/page_32.h    |   22 +--
 arch/sparc/include/asm/pgtable_32.h |    6 +-
 arch/sparc/kernel/setup_32.c        |   17 --
 arch/sparc/mm/fault_32.c            |   12 --
 arch/sparc/mm/init_32.c             |  336 ++++++++++-------------------------
 arch/sparc/mm/srmmu.c               |   60 ++-----
 arch/sparc/mm/sun4c.c               |    9 +-
 arch/sparc/prom/memory.c            |   55 ++-----
 11 files changed, 133 insertions(+), 391 deletions(-)
arch/sparc/Kconfig +2 -1
index 7cb8adf..6faf337 100644
@@ -26,12 +26,14 @@ config SPARC
 	select HAVE_DMA_API_DEBUG
 	select HAVE_ARCH_JUMP_LABEL
 	select HAVE_GENERIC_HARDIRQS
+	select HAVE_MEMBLOCK
 	select GENERIC_IRQ_SHOW
 	select USE_GENERIC_SMP_HELPERS if SMP
 
 config SPARC32
 	def_bool !64BIT
 	select GENERIC_ATOMIC64
+	select NO_BOOTMEM
 
 config SPARC64
 	def_bool 64BIT
@@ -43,7 +45,6 @@ config SPARC64
 	select HAVE_KRETPROBES
 	select HAVE_KPROBES
 	select HAVE_RCU_TABLE_FREE if SMP
-	select HAVE_MEMBLOCK
 	select HAVE_SYSCALL_WRAPPERS
 	select HAVE_DYNAMIC_FTRACE
 	select HAVE_FTRACE_MCOUNT_RECORD
arch/sparc/include/asm/mmu_32.h +3 -0
index 6f056e5..2d9ade2 100644
@@ -7,4 +7,7 @@ typedef unsigned long mm_context_t;
 /* mm/srmmu.c */
 extern ctxd_t *srmmu_ctx_table_phys;
 
+/* mm/init_32.c */
+void __init find_ramdisk(unsigned long phys_base);
+
 #endif
arch/sparc/include/asm/oplib_32.h +1 -0
index 71e5e9a..e80104f 100644
@@ -115,6 +115,7 @@ extern void prom_putsegment(int context, unsigned long virt_addr,
 
 /* Initialize the memory lists based upon the prom version. */
 void prom_meminit(void);
+void prom_memblock_add_mem(void);
 
 /* PROM device tree traversal functions... */
 
arch/sparc/include/asm/page_32.h +3 -19
index bb5c2ac..522af2f 100644
@@ -29,22 +29,6 @@
 		sparc_flush_page_to_ram(page);	\
 	} while (0)
 
-/* The following structure is used to hold the physical
- * memory configuration of the machine.  This is filled in
- * prom_meminit() and is later used by mem_init() to set up
- * mem_map[].  We statically allocate SPARC_PHYS_BANKS+1 of
- * these structs, this is arbitrary.  The entry after the
- * last valid one has num_bytes=0.
- */
-struct sparc_phys_banks {
-  unsigned long base_addr;
-  unsigned long num_bytes;
-};
-
-#define SPARC_PHYS_BANKS 32
-
-extern struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS+1];
-
 /* Cache alias structure.  Entry is valid if context != -1. */
 struct cache_palias {
 	unsigned long vaddr;
@@ -131,6 +115,7 @@ BTFIXUPDEF_SETHI(sparc_unmapped_base)
 #ifndef __ASSEMBLY__
 extern unsigned long phys_base;
 extern unsigned long pfn_base;
+extern unsigned long last_valid_pfn;
 #endif
 #define __pa(x)			((unsigned long)(x) - PAGE_OFFSET + phys_base)
 #define __va(x)			((void *)((unsigned long) (x) - phys_base + PAGE_OFFSET))
@@ -138,11 +123,10 @@ extern unsigned long pfn_base;
 #define virt_to_phys		__pa
 #define phys_to_virt		__va
 
-#define ARCH_PFN_OFFSET		(pfn_base)
 #define virt_to_page(kaddr)	pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
 
-#define pfn_valid(pfn)		(((pfn) >= (pfn_base)) && (((pfn)-(pfn_base)) < max_mapnr))
-#define virt_addr_valid(kaddr)	((((unsigned long)(kaddr)-PAGE_OFFSET)>>PAGE_SHIFT) < max_mapnr)
+#define pfn_valid(pfn)		((pfn) >= pfn_base && (pfn) <= last_valid_pfn)
+#define virt_addr_valid(kaddr)	pfn_valid(PFN_DOWN(__pa(kaddr)))
 
 #define VM_DATA_DEFAULT_FLAGS	(VM_READ | VM_WRITE | VM_EXEC | \
 				 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
arch/sparc/include/asm/pgtable_32.h +2 -4
index a790cc6..04234d5 100644
@@ -425,11 +425,9 @@ __get_iospace (unsigned long addr)
 	}
 }
 
-extern unsigned long *sparc_valid_addr_bitmap;
-
+// extern unsigned long *sparc_valid_addr_bitmap;
 /* Needs to be defined here and not in linux/mm.h, as it is arch dependent */
-#define kern_addr_valid(addr) \
-	(test_bit(__pa((unsigned long)(addr))>>20, sparc_valid_addr_bitmap))
+#define kern_addr_valid(addr) (1)
 
 /*
  * For sparc32&64, the pfn in io_remap_pfn_range() carries <iospace> in
arch/sparc/kernel/setup_32.c +0 -17
index fe1e3fc..06d7d6c 100644
@@ -209,9 +209,6 @@ struct pt_regs fake_swapper_regs;
 
 void __init setup_arch(char **cmdline_p)
 {
-	int i;
-	unsigned long highest_paddr;
-
 	sparc_ttable = (struct tt_entry *) &trapbase;
 
 	/* Initialize PROM console and command line. */
@@ -279,20 +276,6 @@ void __init setup_arch(char **cmdline_p)
 		sun4c_probe_vac();
 	load_mmu();
 
-	phys_base = 0xffffffffUL;
-	highest_paddr = 0UL;
-	for (i = 0; sp_banks[i].num_bytes != 0; i++) {
-		unsigned long top;
-
-		if (sp_banks[i].base_addr < phys_base)
-			phys_base = sp_banks[i].base_addr;
-		top = sp_banks[i].base_addr +
-			sp_banks[i].num_bytes;
-		if (highest_paddr < top)
-			highest_paddr = top;
-	}
-	pfn_base = phys_base >> PAGE_SHIFT;
-
 	if (!root_flags)
 		root_mountflags &= ~MS_RDONLY;
 	ROOT_DEV = old_decode_dev(root_dev);
arch/sparc/mm/fault_32.c +0 -12
index 8023fd7..0a4f5dc 100644
@@ -49,18 +49,6 @@ int vac_size, vac_linesize, vac_do_hw_vac_flushes;
 int vac_entries_per_context, vac_entries_per_segment;
 int vac_entries_per_page;
 
-/* Return how much physical memory we have.  */
-unsigned long probe_memory(void)
-{
-	unsigned long total = 0;
-	int i;
-
-	for (i = 0; sp_banks[i].num_bytes; i++)
-		total += sp_banks[i].num_bytes;
-
-	return total;
-}
-
 extern void sun4c_complete_all_stores(void);
 
 /* Whee, a level 15 NMI interrupt memory error.  Let's have fun... */
arch/sparc/mm/init_32.c +93 -243

417 lines not on this page · raw message

arch/sparc/mm/srmmu.c +2 -5
index cbef74e..128d9e8 100644
@@ -8,6 +8,7 @@
  * Copyright (C) 1999,2000 Anton Blanchard ([email protected])
  */
 
+#include <linux/memblock.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/vmalloc.h>
@@ -57,8 +58,6 @@ int vac_line_size;
 
 extern struct resource sparc_iomap;
 
-extern unsigned long last_valid_pfn;
-
 extern unsigned long page_kernel;
 
 static pgd_t *srmmu_swapper_pg_dir;
@@ -373,15 +372,13 @@ static void srmmu_free_nocache(unsigned long vaddr, int size)
 static void srmmu_early_allocate_ptable_skeleton(unsigned long start,
 						 unsigned long end);
 
-extern unsigned long probe_memory(void);	/* in fault.c */
-
 /*
  * Reserve nocache dynamically proportionally to the amount of
  * system RAM. -- Tomas Szepe <[email protected]>, June 2002
  */
 static void srmmu_nocache_calcsize(void)
 {
-	unsigned long sysmemavail = probe_memory() / 1024;
+	unsigned long sysmemavail = memblock_phys_mem_size() / 1024;
 	int srmmu_nocache_npages;
 
 	srmmu_nocache_npages @@ -1208,46 +1205,25 @@ static void __init do_large_mapping(unsigned long vaddr, unsigned long phys_base

*(pgd_t *)__nocache_fix(pgdp) = __pgd(big_pte);
}

-/* Map sp_bank entry SP_ENTRY, starting at virtual address VBASE. */ -static unsigned long __init map_spbank(unsigned long vbase, int sp_entry) -{
- unsigned long pstart = (sp_banks[sp_entry].base_addr & SRMMU_PGDIR_MASK);
- unsigned long vstart = (vbase & SRMMU_PGDIR_MASK);
- unsigned long vend = SRMMU_PGDIR_ALIGN(vbase + sp_banks[sp_entry].num_bytes);
- /* Map "low" memory only */
- const unsigned long min_vaddr = PAGE_OFFSET;
- const unsigned long max_vaddr = PAGE_OFFSET + SRMMU_MAXMEM;
-
- if (vstart < min_vaddr || vstart >= max_vaddr)
- return vstart;
-
- if (vend > max_vaddr || vend < min_vaddr)
- vend = max_vaddr;
-
- while(vstart < vend) {
- do_large_mapping(vstart, pstart);
- vstart += SRMMU_PGDIR_SIZE; pstart += SRMMU_PGDIR_SIZE;
- }
- return vstart;
-}
-
-static inline void memprobe_error(char *msg)
-{
- prom_printf(msg);
- prom_printf("Halting now...\n");
- prom_halt();
-}
-
static inline void map_kernel(void)
{
- int i;
+ struct memblock_region *reg;

if (phys_base > 0) {
do_large_mapping(PAGE_OFFSET, phys_base);
}

- for (i = 0; sp_banks[i].num_bytes != 0; i++) {
- map_spbank((unsigned long)__va(sp_banks[i].base_addr), i);
+ for_each_memblock(memory, reg) {
+ unsigned long vbase = (unsigned long)__va(reg->base);
+ unsigned long pstart = reg->base & SRMMU_PGDIR_MASK;
+ unsigned long vstart = vbase & SRMMU_PGDIR_MASK;
+ unsigned long vend = SRMMU_PGDIR_ALIGN(vbase + reg->size);
+
+ while (vstart < vend) {
+ do_large_mapping(vstart, pstart);
+ vstart += SRMMU_PGDIR_SIZE;
+ pstart += SRMMU_PGDIR_SIZE;
+ }
}

BTFIXUPSET_SIMM13(user_ptrs_per_pgd, PAGE_OFFSET / SRMMU_PGDIR_SIZE);
@@ -1258,8 +1234,6 @@ extern void sparc_context_init(int);

void (*poke_srmmu)(void) __cpuinitdata = NULL;

-extern unsigned long bootmem_init(unsigned long *pages_avail); -
void __init srmmu_paging_init(void)
{
int i;
@@ -1268,7 +1242,6 @@ void __init srmmu_paging_init(void)
pgd_t *pgd;
pmd_t *pmd;
pte_t *pte;
- unsigned long pages_avail;

sparc_iomap.start = SUN4M_IOBASE_VADDR; /* 16MB of IOSPACE on all sun4m's. */

@@ -1293,8 +1266,7 @@ void __init srmmu_paging_init(void)
prom_halt();
}

- pages_avail = 0;
- last_valid_pfn = bootmem_init(&pages_avail);
+ find_ramdisk(phys_base);

srmmu_nocache_calcsize(); srmmu_nocache_init();
@@ -1349,7 +1321,7 @@ void __init srmmu_paging_init(void)
npages = max_low_pfn - pfn_base;

zones_size[ZONE_DMA] = npages;
- zholes_size[ZONE_DMA] = npages - pages_avail;
+ zholes_size[ZONE_DMA] = npages - 0; // TODO pages_avail;

npages = highend_pfn - max_low_pfn; zones_size[ZONE_HIGHMEM] = npages;

arch/sparc/mm/sun4c.c +2 -7
index 1cf4f19..3b423d6 100644
@@ -1944,22 +1944,17 @@ void sun4c_update_mmu_cache(struct vm_area_struct *vma, unsigned long address, p
 }
 
 extern void sparc_context_init(int);
-extern unsigned long bootmem_init(unsigned long *pages_avail);
-extern unsigned long last_valid_pfn;
 
 void __init sun4c_paging_init(void)
 {
 	int i, cnt;
 	unsigned long kernel_end, vaddr;
 	extern struct resource sparc_iomap;
-	unsigned long end_pfn, pages_avail;
 
 	kernel_end = (unsigned long) &_end;
 	kernel_end = SUN4C_REAL_PGDIR_ALIGN(kernel_end);
 
-	pages_avail = 0;
-	last_valid_pfn = bootmem_init(&pages_avail);
-	end_pfn = last_valid_pfn;
+	find_ramdisk(phy_base);
 
 	sun4c_probe_mmu();
 	invalid_segment = (num_segmaps - 1);
@@ -2004,7 +1999,7 @@ void __init sun4c_paging_init(void)
 		npages = max_low_pfn - pfn_base;
 
 		zones_size[ZONE_DMA] = npages;
-		zholes_size[ZONE_DMA] = npages - pages_avail;
+		zholes_size[ZONE_DMA] = npages - 0; // TODO pages_avail;
 
 		npages = highend_pfn - max_low_pfn;
 		zones_size[ZONE_HIGHMEM] = npages;
arch/sparc/prom/memory.c +11 -44

91 lines not on this page · raw message

maintainer
#1 lore raw

From: Sam Ravnborg <[email protected]>
Date: Tue, 3 Jan 2012 21:45:16 +0100

Quoted 3 lines

- kern_addr_valid is (temporary) disabled
I could not grock the code allocating sparc_valid_addr_bitmap and I noticed most archs do not implement this check

Is it hard to grok where the memory is allocated from or the calculation of the bitmap memory's size? :-)

To be honest, leaving this defined to "0" is no real crime. It just means that /proc/kcore isn't going to be supported as that is the only place this test is really used.

On sparc64 we allocate the bitmap statically in the kernel image because we use it in the TLB miss handler to validate addresses when handling misses in the PAGE_OFFSET linear translation area.

On sparc64 the memory error (or hypervisor error, since when we load TLB entries via the hypervisor it checks the address too) is harder to recover from than just noticing the problem earlier in the TLB miss handler. So that's why we do it this way.

And since we have the table we use it to implement kern_addr_valid() too since that's essentially free.

If the platform would properly fault on any bogus kernel address access, kern_addr_valid() can seemingly just be defined to the constant "1".

maintainer
#2 lore raw
In reply to Sam Ravnborg

From: Sam Ravnborg <[email protected]>
Date: Tue, 3 Jan 2012 21:45:16 +0100

Quoted 10 lines

sparc32 uses a combination of a local memory handling and bootmem to handle memory in the early stage of the boot.

Some time ago I started to look at what was required to replace the local memory handling (sp_banks) with memblock - which I understood was the generic way to handle memory in the early phases of the boot.

Tejun have posted a nice series of patches that clean up memblock so it should be possible to replace bootmem too.

You are extremely brave to be messing around with this area of the sparc32 port, I must say :-) Getting sparc64 sane took a lot of concentrated effort and it lacks much of the baggage that sparc32 still has lying around.

Thanks for doing this work and I'll continue looking over the patch and try to help with the unresolved areas as well.

#3 lore raw
In reply to Sam Ravnborg
Quoted 9 lines · David Miller

From: Sam Ravnborg <[email protected]>
Date: Tue, 3 Jan 2012 21:45:16 +0100

Quoted 3 lines

- kern_addr_valid is (temporary) disabled
I could not grock the code allocating sparc_valid_addr_bitmap and I noticed most archs do not implement this check

Is it hard to grok where the memory is allocated from or the calculation of the bitmap memory's size? :-)

        i = last_valid_pfn >> ((20 - PAGE_SHIFT) + 5);
        i += 1;
        sparc_valid_addr_bitmap = (unsigned long *)
                __alloc_bootmem(i << 2, SMP_CACHE_BYTES, 0UL);

I failed to find out how we calculate the amount
of memory to allocate.

last_valid_pfn is the last page of the available memory. So last_valid_pfn >> (20 - PAGE_SHIFT) is the amount of memory expressed in MB.

But then we shifted an additional "+ 5".
This looks like we go for 32 MB.
+ 1 is just to make sure we cover the last page I think. And when we allocate we do " i << 2 " so we are down to 8 MB.

When we use it we do:

#define kern_addr_valid(addr) \
        (test_bit(__pa((unsigned long)(addr))>>20, sparc_valid_addr_bitmap))

so here it looks like we have one bit for each MB.

I also looked at:
static void __init taint_real_pages(void)

{
        int i;

        for (i = 0; sp_banks[i].num_bytes; i++) {
                unsigned long start, end;

                start = sp_banks[i].base_addr;
                end = start + sp_banks[i].num_bytes;

                while (start < end) {
                        set_bit(start >> 20, sparc_valid_addr_bitmap);
                        start += PAGE_SIZE;
                }
        }
}

Here I could see that we set a bit for each MB
in sparc_valid_addr_bitmap and it is not limited
to the kernel address range.

In the end I got confused and dropped it because I could see that lots of other archs did not implment this check either.

I will capture all this info in the commit which drop this for later reference.

Sam

#4 lore raw
In reply to Sam Ravnborg
Quoted 11 lines · David Miller

From: Sam Ravnborg <[email protected]>
Date: Tue, 3 Jan 2012 21:45:16 +0100

Quoted 8 lines

sparc32 uses a combination of a local memory handling and bootmem to handle memory in the early stage of the boot.

Some time ago I started to look at what was required to replace the local memory handling (sp_banks) with memblock - which I understood was the generic way to handle memory in the early phases of the boot.

Quoted 5 lines
Quoted 2 lines

Tejun have posted a nice series of patches that clean up memblock so it should be possible to replace bootmem too.

You are extremely brave to be messing around with this area of the sparc32 port, I must say :-) Getting sparc64 sane took a

s/brave/stupid/g

Quoted 2 lines

lot of concentrated effort and it lacks much of the baggage that sparc32 still has lying around.

But then sparc32 looks much simpler than sparc64 - especially after I start to get the bigger picture.

Quoted 3 lines

Thanks for doing this work and I'll continue looking over the patch and try to help with the unresolved areas as well.

Thanks!
I plan to post a more readable serie of patches soon after the merge window has closed.

Sam

maintainer
#5 lore raw
In reply to Sam Ravnborg

From: Sam Ravnborg <[email protected]>
Date: Wed, 4 Jan 2012 22:56:18 +0100

Quoted 11 lines · David Miller
Quoted 9 lines

From: Sam Ravnborg <[email protected]>
Date: Tue, 3 Jan 2012 21:45:16 +0100

Quoted 3 lines

- kern_addr_valid is (temporary) disabled
I could not grock the code allocating sparc_valid_addr_bitmap and I noticed most archs do not implement this check

Is it hard to grok where the memory is allocated from or the calculation of the bitmap memory's size? :-)

Quoted 7 lines
        i = last_valid_pfn >> ((20 - PAGE_SHIFT) + 5);
        i += 1;
        sparc_valid_addr_bitmap = (unsigned long *)
                __alloc_bootmem(i << 2, SMP_CACHE_BYTES, 0UL);

I failed to find out how we calculate the amount of memory to allocate.

It could just simply be buggy. Be wary of code that has been in the tree more than 10 years :-)

The formula here has changed several times, at one point the code looked like:

	sparc_valid_addr_bitmap = (unsigned long *)start_mem;
	i = max_mapnr >> (8 + 5);
	i += 1;
	memset(sparc_valid_addr_bitmap, 0, i << 2);
	start_mem += i << 2;

Then it looked something like:

	i = last_valid_pfn >> (8 + 5);
	i += 1;
	sparc_valid_addr_bitmap = (unsigned long *)
		__alloc_bootmem(i << 2, SMP_CACHE_BYTES, 0UL);

and finally the "8" was replaced with 20 - PAGE_SHIFT.

Quoted 10 lines

last_valid_pfn is the last page of the available memory. So last_valid_pfn >> (20 - PAGE_SHIFT) is the amount of memory expressed in MB.

But then we shifted an additional "+ 5".
This looks like we go for 32 MB.
+ 1 is just to make sure we cover the last page I think. And when we allocate we do " i << 2 " so we are down to 8 MB.

Quoted 5 lines

When we use it we do:

#define kern_addr_valid(addr) \
        (test_bit(__pa((unsigned long)(addr))>>20, sparc_valid_addr_bitmap))

so here it looks like we have one bit for each MB.

Indeed, it looks like we mis-size this allocation.

Quoted 2 lines

I also looked at:
static void __init taint_real_pages(void)

...

Quoted 3 lines

Here I could see that we set a bit for each MB in sparc_valid_addr_bitmap and it is not limited to the kernel address range.

It is indeed marking every MB present in the physical memory tables.

maintainer
#6 lore raw
In reply to Sam Ravnborg

From: Sam Ravnborg <[email protected]>
Date: Tue, 3 Jan 2012 21:45:16 +0100

arch/sparc/mm/init_32.c void __init sparc_context_init(int numctx) · line 119

Quoted 3 lines
arch/sparc/mm/init_32.c +2 -0
+/* Reserve memory for initrd (if present) */
+void __init find_ramdisk(unsigned long phys_base)
 {

I would suggest duplicating the comment from sparc64's find_ramdisk() which explains the KERNBASE/phys_base adjustments and that they are an artifact of how the bootloader calculates the ramdisk address it passes to the kernel.

maintainer
#7 lore raw
In reply to Sam Ravnborg

From: Sam Ravnborg <[email protected]>
Date: Tue, 3 Jan 2012 21:45:16 +0100

arch/sparc/mm/init_32.c EXPORT_SYMBOL(PAGE_SHARED); · line 243

Quoted 2 lines
arch/sparc/mm/init_32.c +2 -0
+	/* Reserve all highmem in memblock - this may be nothing */
+	memblock_reserve(highstart, memblock_end_of_DRAM() - highstart);

Actually this calculation is going to be negative most of the time when there is no highmem. And if it is in fact zero, memblock_reserve() has a BUG check on that.

I therefore think you'll need to guard this with a:

if (memblock_end_of_DRAM() - highstart)

test.

Otherwise this patch so far looks great.

#8 lore raw
In reply to Sam Ravnborg
Quoted 10 lines · David Miller

From: Sam Ravnborg <[email protected]>
Date: Tue, 3 Jan 2012 21:45:16 +0100

arch/sparc/mm/init_32.c EXPORT_SYMBOL(PAGE_SHARED); · line 243

Quoted 2 lines
arch/sparc/mm/init_32.c +2 -0
+	/* Reserve all highmem in memblock - this may be nothing */
+	memblock_reserve(highstart, memblock_end_of_DRAM() - highstart);

Actually this calculation is going to be negative most of the time when there is no highmem. And if it is in fact zero, memblock_reserve() has a BUG check on that.

Quoted 5 lines

I therefore think you'll need to guard this with a:

if (memblock_end_of_DRAM() - highstart)

test.

Good catch - I had not seen this.

Quoted 2 lines

Otherwise this patch so far looks great.

Thanks!

I will look at it further the coming weekend addressing your comments. Obviously I will adapt it to the now merged work of Tejun on memblock.

My aim is to have my own box booting before I post next update.

Sam