linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [POWERPC] Introduce lowmem_end_addr to distiguish from total_lowmem
@ 2008-03-24 23:33 Kumar Gala
  2008-03-25  3:18 ` [PATCH] [POWERPC] Introduce lowmem_end_addr to distiguish fromtotal_lowmem Zhang Wei
  0 siblings, 1 reply; 3+ messages in thread
From: Kumar Gala @ 2008-03-24 23:33 UTC (permalink / raw)
  To: linuxppc-dev

total_lowmem represents the amount of low memory not the physical address
that low memory ends at.  If the start of memory is at 0 it happends that
total_lowmem can be used as both the size and the address that lowmem
ends at. (technical its one byte beyond the end)

To make the code a bit more clear and deal with the case when the start of
memory isn't at physical 0, we introduce lowmem_end_addr that represents
one byte beyond the last physical address in the lowmem region.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
---
 arch/powerpc/mm/44x_mmu.c |    2 +-
 arch/powerpc/mm/init_32.c |    4 +++-
 arch/powerpc/mm/init_64.c |    2 ++
 arch/powerpc/mm/mem.c     |   16 +++++++++-------
 4 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/arch/powerpc/mm/44x_mmu.c b/arch/powerpc/mm/44x_mmu.c
index 04dc087..953fb91 100644
--- a/arch/powerpc/mm/44x_mmu.c
+++ b/arch/powerpc/mm/44x_mmu.c
@@ -67,7 +67,7 @@ unsigned long __init mmu_mapin_ram(void)

 	/* Pin in enough TLBs to cover any lowmem not covered by the
 	 * initial 256M mapping established in head_44x.S */
-	for (addr = PPC_PIN_SIZE; addr < total_lowmem;
+	for (addr = PPC_PIN_SIZE; addr < lowmem_end_addr;
 	     addr += PPC_PIN_SIZE)
 		ppc44x_pin_tlb(addr + PAGE_OFFSET, addr);

diff --git a/arch/powerpc/mm/init_32.c b/arch/powerpc/mm/init_32.c
index 01a81a0..345a275 100644
--- a/arch/powerpc/mm/init_32.c
+++ b/arch/powerpc/mm/init_32.c
@@ -147,6 +147,7 @@ void __init MMU_init(void)
 	}

 	total_lowmem = total_memory = lmb_end_of_DRAM() - memstart_addr;
+	lowmem_end_addr = memstart_addr + total_lowmem;

 #ifdef CONFIG_FSL_BOOKE
 	/* Freescale Book-E parts expect lowmem to be mapped by fixed TLB
@@ -157,9 +158,10 @@ void __init MMU_init(void)

 	if (total_lowmem > __max_low_memory) {
 		total_lowmem = __max_low_memory;
+		lowmem_end_addr = memstart_addr + total_lowmem;
 #ifndef CONFIG_HIGHMEM
 		total_memory = total_lowmem;
-		lmb_enforce_memory_limit(total_lowmem);
+		lmb_enforce_memory_limit(lowmem_end_addr);
 		lmb_analyze();
 #endif /* CONFIG_HIGHMEM */
 	}
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index abeb0eb..f18b203 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -75,6 +75,8 @@
 /* max amount of RAM to use */
 unsigned long __max_memory;

+phys_addr_t memstart_addr;
+
 void free_initmem(void)
 {
 	unsigned long addr;
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 60c019c..9c10b14 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -217,9 +217,11 @@ void __init do_init_bootmem(void)
 	unsigned long total_pages;
 	int boot_mapsize;

-	max_pfn = total_pages = lmb_end_of_DRAM() >> PAGE_SHIFT;
+	max_pfn = lmb_end_of_DRAM() >> PAGE_SHIFT;
+	total_pages = (lmb_end_of_DRAM() - memstart_addr) >> PAGE_SHIFT;
 #ifdef CONFIG_HIGHMEM
 	total_pages = total_lowmem >> PAGE_SHIFT;
+	max_low_pfn = lowmem_end_addr >> PAGE_SHIFT;
 #endif

 	/*
@@ -245,18 +247,18 @@ void __init do_init_bootmem(void)
 	 * present.
 	 */
 #ifdef CONFIG_HIGHMEM
-	free_bootmem_with_active_regions(0, total_lowmem >> PAGE_SHIFT);
+	free_bootmem_with_active_regions(0, lowmem_end_addr >> PAGE_SHIFT);

 	/* reserve the sections we're already using */
 	for (i = 0; i < lmb.reserved.cnt; i++) {
 		unsigned long addr = lmb.reserved.region[i].base +
 				     lmb_size_bytes(&lmb.reserved, i) - 1;
-		if (addr < total_lowmem)
+		if (addr < lowmem_end_addr)
 			reserve_bootmem(lmb.reserved.region[i].base,
 					lmb_size_bytes(&lmb.reserved, i),
 					BOOTMEM_DEFAULT);
-		else if (lmb.reserved.region[i].base < total_lowmem) {
-			unsigned long adjusted_size = total_lowmem -
+		else if (lmb.reserved.region[i].base < lowmem_end_addr) {
+			unsigned long adjusted_size = lowmem_end_addr -
 				      lmb.reserved.region[i].base;
 			reserve_bootmem(lmb.reserved.region[i].base,
 					adjusted_size, BOOTMEM_DEFAULT);
@@ -326,7 +328,7 @@ void __init paging_init(void)
 	       (top_of_ram - total_ram) >> 20);
 	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
 #ifdef CONFIG_HIGHMEM
-	max_zone_pfns[ZONE_DMA] = total_lowmem >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_DMA] = lowmem_end_addr >> PAGE_SHIFT;
 	max_zone_pfns[ZONE_HIGHMEM] = top_of_ram >> PAGE_SHIFT;
 #else
 	max_zone_pfns[ZONE_DMA] = top_of_ram >> PAGE_SHIFT;
@@ -381,7 +383,7 @@ void __init mem_init(void)
 	{
 		unsigned long pfn, highmem_mapnr;

-		highmem_mapnr = total_lowmem >> PAGE_SHIFT;
+		highmem_mapnr = lowmem_end_addr >> PAGE_SHIFT;
 		for (pfn = highmem_mapnr; pfn < max_mapnr; ++pfn) {
 			struct page *page = pfn_to_page(pfn);
 			if (lmb_is_reserved(pfn << PAGE_SHIFT))
-- 
1.5.4.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH] [POWERPC] Introduce lowmem_end_addr to distiguish fromtotal_lowmem
  2008-03-24 23:33 [PATCH] [POWERPC] Introduce lowmem_end_addr to distiguish from total_lowmem Kumar Gala
@ 2008-03-25  3:18 ` Zhang Wei
  2008-03-25  3:31   ` Kumar Gala
  0 siblings, 1 reply; 3+ messages in thread
From: Zhang Wei @ 2008-03-25  3:18 UTC (permalink / raw)
  To: Kumar Gala, linuxppc-dev; +Cc: Wang Haiying

Hi, Kumar,

> -----Original Message-----
> From: linuxppc-dev-bounces+wei.zhang=3Dfreescale.com@ozlabs.org=20
>=20
> total_lowmem represents the amount of low memory not the=20
> physical address
> that low memory ends at.  If the start of memory is at 0 it=20
> happends that
> total_lowmem can be used as both the size and the address that lowmem
> ends at. (technical its one byte beyond the end)
>=20
> To make the code a bit more clear and deal with the case when=20
> the start of
> memory isn't at physical 0, we introduce lowmem_end_addr that=20
> represents
> one byte beyond the last physical address in the lowmem region.

About the kernel memory offset, if the memory area from phyical 0
 to lowmem start address is reserved for other usage in this kernel,
 no more comments. If it will be used by other kernel (in asmp mode),
 how about to use tlb mapping physical address to virtual address 0
 not move the kernel lowmem address? I consider the tlb mapping
 will be more safe.

Cheers!
Wei.

>=20
> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
> ---
>  arch/powerpc/mm/44x_mmu.c |    2 +-
>  arch/powerpc/mm/init_32.c |    4 +++-
>  arch/powerpc/mm/init_64.c |    2 ++
>  arch/powerpc/mm/mem.c     |   16 +++++++++-------
>  4 files changed, 15 insertions(+), 9 deletions(-)
>=20
> diff --git a/arch/powerpc/mm/44x_mmu.c b/arch/powerpc/mm/44x_mmu.c
> index 04dc087..953fb91 100644
> --- a/arch/powerpc/mm/44x_mmu.c
> +++ b/arch/powerpc/mm/44x_mmu.c
> @@ -67,7 +67,7 @@ unsigned long __init mmu_mapin_ram(void)
>=20
>  	/* Pin in enough TLBs to cover any lowmem not covered by the
>  	 * initial 256M mapping established in head_44x.S */
> -	for (addr =3D PPC_PIN_SIZE; addr < total_lowmem;
> +	for (addr =3D PPC_PIN_SIZE; addr < lowmem_end_addr;
>  	     addr +=3D PPC_PIN_SIZE)
>  		ppc44x_pin_tlb(addr + PAGE_OFFSET, addr);
>=20
> diff --git a/arch/powerpc/mm/init_32.c b/arch/powerpc/mm/init_32.c
> index 01a81a0..345a275 100644
> --- a/arch/powerpc/mm/init_32.c
> +++ b/arch/powerpc/mm/init_32.c
> @@ -147,6 +147,7 @@ void __init MMU_init(void)
>  	}
>=20
>  	total_lowmem =3D total_memory =3D lmb_end_of_DRAM() - memstart_addr;
> +	lowmem_end_addr =3D memstart_addr + total_lowmem;
>=20
>  #ifdef CONFIG_FSL_BOOKE
>  	/* Freescale Book-E parts expect lowmem to be mapped by=20
> fixed TLB
> @@ -157,9 +158,10 @@ void __init MMU_init(void)
>=20
>  	if (total_lowmem > __max_low_memory) {
>  		total_lowmem =3D __max_low_memory;
> +		lowmem_end_addr =3D memstart_addr + total_lowmem;
>  #ifndef CONFIG_HIGHMEM
>  		total_memory =3D total_lowmem;
> -		lmb_enforce_memory_limit(total_lowmem);
> +		lmb_enforce_memory_limit(lowmem_end_addr);
>  		lmb_analyze();
>  #endif /* CONFIG_HIGHMEM */
>  	}
> diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
> index abeb0eb..f18b203 100644
> --- a/arch/powerpc/mm/init_64.c
> +++ b/arch/powerpc/mm/init_64.c
> @@ -75,6 +75,8 @@
>  /* max amount of RAM to use */
>  unsigned long __max_memory;
>=20
> +phys_addr_t memstart_addr;
> +
>  void free_initmem(void)
>  {
>  	unsigned long addr;
> diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
> index 60c019c..9c10b14 100644
> --- a/arch/powerpc/mm/mem.c
> +++ b/arch/powerpc/mm/mem.c
> @@ -217,9 +217,11 @@ void __init do_init_bootmem(void)
>  	unsigned long total_pages;
>  	int boot_mapsize;
>=20
> -	max_pfn =3D total_pages =3D lmb_end_of_DRAM() >> PAGE_SHIFT;
> +	max_pfn =3D lmb_end_of_DRAM() >> PAGE_SHIFT;
> +	total_pages =3D (lmb_end_of_DRAM() - memstart_addr) >> PAGE_SHIFT;
>  #ifdef CONFIG_HIGHMEM
>  	total_pages =3D total_lowmem >> PAGE_SHIFT;
> +	max_low_pfn =3D lowmem_end_addr >> PAGE_SHIFT;
>  #endif
>=20
>  	/*
> @@ -245,18 +247,18 @@ void __init do_init_bootmem(void)
>  	 * present.
>  	 */
>  #ifdef CONFIG_HIGHMEM
> -	free_bootmem_with_active_regions(0, total_lowmem >> PAGE_SHIFT);
> +	free_bootmem_with_active_regions(0, lowmem_end_addr >>=20
> PAGE_SHIFT);
>=20
>  	/* reserve the sections we're already using */
>  	for (i =3D 0; i < lmb.reserved.cnt; i++) {
>  		unsigned long addr =3D lmb.reserved.region[i].base +
>  				    =20
> lmb_size_bytes(&lmb.reserved, i) - 1;
> -		if (addr < total_lowmem)
> +		if (addr < lowmem_end_addr)
>  			reserve_bootmem(lmb.reserved.region[i].base,
>  				=09
> lmb_size_bytes(&lmb.reserved, i),
>  					BOOTMEM_DEFAULT);
> -		else if (lmb.reserved.region[i].base < total_lowmem) {
> -			unsigned long adjusted_size =3D total_lowmem -
> +		else if (lmb.reserved.region[i].base <=20
> lowmem_end_addr) {
> +			unsigned long adjusted_size =3D lowmem_end_addr -
>  				      lmb.reserved.region[i].base;
>  			reserve_bootmem(lmb.reserved.region[i].base,
>  					adjusted_size, BOOTMEM_DEFAULT);
> @@ -326,7 +328,7 @@ void __init paging_init(void)
>  	       (top_of_ram - total_ram) >> 20);
>  	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
>  #ifdef CONFIG_HIGHMEM
> -	max_zone_pfns[ZONE_DMA] =3D total_lowmem >> PAGE_SHIFT;
> +	max_zone_pfns[ZONE_DMA] =3D lowmem_end_addr >> PAGE_SHIFT;
>  	max_zone_pfns[ZONE_HIGHMEM] =3D top_of_ram >> PAGE_SHIFT;
>  #else
>  	max_zone_pfns[ZONE_DMA] =3D top_of_ram >> PAGE_SHIFT;
> @@ -381,7 +383,7 @@ void __init mem_init(void)
>  	{
>  		unsigned long pfn, highmem_mapnr;
>=20
> -		highmem_mapnr =3D total_lowmem >> PAGE_SHIFT;
> +		highmem_mapnr =3D lowmem_end_addr >> PAGE_SHIFT;
>  		for (pfn =3D highmem_mapnr; pfn < max_mapnr; ++pfn) {
>  			struct page *page =3D pfn_to_page(pfn);
>  			if (lmb_is_reserved(pfn << PAGE_SHIFT))
> --=20
> 1.5.4.1
>=20
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
>=20

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [POWERPC] Introduce lowmem_end_addr to distiguish fromtotal_lowmem
  2008-03-25  3:18 ` [PATCH] [POWERPC] Introduce lowmem_end_addr to distiguish fromtotal_lowmem Zhang Wei
@ 2008-03-25  3:31   ` Kumar Gala
  0 siblings, 0 replies; 3+ messages in thread
From: Kumar Gala @ 2008-03-25  3:31 UTC (permalink / raw)
  To: Zhang Wei; +Cc: linuxppc-dev, Wang Haiying


On Mar 24, 2008, at 10:18 PM, Zhang Wei wrote:
> Hi, Kumar,
>
>> -----Original Message-----
>> From: linuxppc-dev-bounces+wei.zhang=freescale.com@ozlabs.org
>>
>> total_lowmem represents the amount of low memory not the
>> physical address
>> that low memory ends at.  If the start of memory is at 0 it
>> happends that
>> total_lowmem can be used as both the size and the address that lowmem
>> ends at. (technical its one byte beyond the end)
>>
>> To make the code a bit more clear and deal with the case when
>> the start of
>> memory isn't at physical 0, we introduce lowmem_end_addr that
>> represents
>> one byte beyond the last physical address in the lowmem region.
>
> About the kernel memory offset, if the memory area from phyical 0
> to lowmem start address is reserved for other usage in this kernel,
> no more comments. If it will be used by other kernel (in asmp mode),
> how about to use tlb mapping physical address to virtual address 0
> not move the kernel lowmem address? I consider the tlb mapping
> will be more safe.

I'm not sure I follow your question.

- k

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-03-25  3:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-24 23:33 [PATCH] [POWERPC] Introduce lowmem_end_addr to distiguish from total_lowmem Kumar Gala
2008-03-25  3:18 ` [PATCH] [POWERPC] Introduce lowmem_end_addr to distiguish fromtotal_lowmem Zhang Wei
2008-03-25  3:31   ` Kumar Gala

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).