diff mbox series

[v4,04/16] powerpc/mm/32s: use generic mmu_mapin_ram() for all blocks.

Message ID 790cf44815f8c56b3c600560bad9139f63be9f68.1550692943.git.christophe.leroy@c-s.fr (mailing list archive)
State Superseded
Headers show
Series powerpc/32: Use BATs/LTLBs for STRICT_KERNEL_RWX | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success next/apply_patch Successfully applied
snowpatch_ozlabs/checkpatch success total: 0 errors, 0 warnings, 0 checks, 35 lines checked

Commit Message

Christophe Leroy Feb. 21, 2019, 8:04 a.m. UTC
Now that mmu_mapin_ram() is able to handle other blocks
than the one starting at 0, the WII can use it for all
its blocks.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/mm/pgtable_32.c | 27 +++++++++------------------
 1 file changed, 9 insertions(+), 18 deletions(-)

Comments

Michael Ellerman Feb. 21, 2019, 1:51 p.m. UTC | #1
Christophe Leroy <christophe.leroy@c-s.fr> writes:

> Now that mmu_mapin_ram() is able to handle other blocks
> than the one starting at 0, the WII can use it for all
> its blocks.
>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> ---
>  arch/powerpc/mm/pgtable_32.c | 27 +++++++++------------------
>  1 file changed, 9 insertions(+), 18 deletions(-)
>
> diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
> index b4858818523f..2bf9bf8867d4 100644
> --- a/arch/powerpc/mm/pgtable_32.c
> +++ b/arch/powerpc/mm/pgtable_32.c
> @@ -254,26 +254,17 @@ static void __init __mapin_ram_chunk(unsigned long offset, unsigned long top)
>  
>  void __init mapin_ram(void)
>  {
> -	unsigned long s, top;
> -
> -#ifndef CONFIG_WII
> -	top = total_lowmem;
> -	s = mmu_mapin_ram(0, top);
> -	__mapin_ram_chunk(s, top);
> -#else
> -	if (!wii_hole_size) {
> -		s = mmu_mapin_ram(0, total_lowmem);
> -		__mapin_ram_chunk(s, total_lowmem);
> -	} else {
> -		top = wii_hole_start;
> -		s = mmu_mapin_ram(0, top);
> -		__mapin_ram_chunk(s, top);
> +	struct memblock_region *reg;
> +
> +	for_each_memblock(memory, reg) {
> +		unsigned long base = reg->base;
> +		unsigned long top = min(base + reg->size, (unsigned long)total_lowmem);

This gives me:

In file included from ../arch/powerpc/mm/pgtable_32.c:22:
../arch/powerpc/mm/pgtable_32.c: In function ‘mapin_ram’:
../include/linux/kernel.h:846:29: error: comparison of distinct pointer types lacks a cast [-Werror]
   (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
                             ^~
../include/linux/kernel.h:860:4: note: in expansion of macro ‘__typecheck’
   (__typecheck(x, y) && __no_side_effects(x, y))
    ^~~~~~~~~~~
../include/linux/kernel.h:870:24: note: in expansion of macro ‘__safe_cmp’
  __builtin_choose_expr(__safe_cmp(x, y), \
                        ^~~~~~~~~~
../include/linux/kernel.h:879:19: note: in expansion of macro ‘__careful_cmp’
 #define min(x, y) __careful_cmp(x, y, <)
                   ^~~~~~~~~~~~~
../arch/powerpc/mm/pgtable_32.c:261:23: note: in expansion of macro ‘min’
   unsigned long top = min(base + reg->size, (unsigned long)total_lowmem);
                       ^~~
cc1: all warnings being treated as errors
../scripts/Makefile.build:276: recipe for target 'arch/powerpc/mm/pgtable_32.o' failed


For 44x/bamboo_defconfig.

cheers
Christophe Leroy Feb. 21, 2019, 2:38 p.m. UTC | #2
Le 21/02/2019 à 14:51, Michael Ellerman a écrit :
> Christophe Leroy <christophe.leroy@c-s.fr> writes:
> 
>> Now that mmu_mapin_ram() is able to handle other blocks
>> than the one starting at 0, the WII can use it for all
>> its blocks.
>>
>> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
>> ---
>>   arch/powerpc/mm/pgtable_32.c | 27 +++++++++------------------
>>   1 file changed, 9 insertions(+), 18 deletions(-)
>>
>> diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
>> index b4858818523f..2bf9bf8867d4 100644
>> --- a/arch/powerpc/mm/pgtable_32.c
>> +++ b/arch/powerpc/mm/pgtable_32.c
>> @@ -254,26 +254,17 @@ static void __init __mapin_ram_chunk(unsigned long offset, unsigned long top)
>>   
>>   void __init mapin_ram(void)
>>   {
>> -	unsigned long s, top;
>> -
>> -#ifndef CONFIG_WII
>> -	top = total_lowmem;
>> -	s = mmu_mapin_ram(0, top);
>> -	__mapin_ram_chunk(s, top);
>> -#else
>> -	if (!wii_hole_size) {
>> -		s = mmu_mapin_ram(0, total_lowmem);
>> -		__mapin_ram_chunk(s, total_lowmem);
>> -	} else {
>> -		top = wii_hole_start;
>> -		s = mmu_mapin_ram(0, top);
>> -		__mapin_ram_chunk(s, top);
>> +	struct memblock_region *reg;
>> +
>> +	for_each_memblock(memory, reg) {
>> +		unsigned long base = reg->base;
>> +		unsigned long top = min(base + reg->size, (unsigned long)total_lowmem);
> 
> This gives me:
> 
> In file included from ../arch/powerpc/mm/pgtable_32.c:22:
> ../arch/powerpc/mm/pgtable_32.c: In function ‘mapin_ram’:
> ../include/linux/kernel.h:846:29: error: comparison of distinct pointer types lacks a cast [-Werror]
>     (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
>                               ^~
> ../include/linux/kernel.h:860:4: note: in expansion of macro ‘__typecheck’
>     (__typecheck(x, y) && __no_side_effects(x, y))
>      ^~~~~~~~~~~
> ../include/linux/kernel.h:870:24: note: in expansion of macro ‘__safe_cmp’
>    __builtin_choose_expr(__safe_cmp(x, y), \
>                          ^~~~~~~~~~
> ../include/linux/kernel.h:879:19: note: in expansion of macro ‘__careful_cmp’
>   #define min(x, y) __careful_cmp(x, y, <)
>                     ^~~~~~~~~~~~~
> ../arch/powerpc/mm/pgtable_32.c:261:23: note: in expansion of macro ‘min’
>     unsigned long top = min(base + reg->size, (unsigned long)total_lowmem);
>                         ^~~
> cc1: all warnings being treated as errors
> ../scripts/Makefile.build:276: recipe for target 'arch/powerpc/mm/pgtable_32.o' failed
> 
> 
> For 44x/bamboo_defconfig.
> 


Argh ! I had the same kind of warning this morning with 
pmac32_defconfig, that's the reason why I added the cast to unsigned long.

Christophe
Christophe Leroy Feb. 21, 2019, 7:02 p.m. UTC | #3
On 02/21/2019 01:51 PM, Michael Ellerman wrote:
> Christophe Leroy <christophe.leroy@c-s.fr> writes:
> 
>> Now that mmu_mapin_ram() is able to handle other blocks
>> than the one starting at 0, the WII can use it for all
>> its blocks.
>>
>> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
>> ---
>>   arch/powerpc/mm/pgtable_32.c | 27 +++++++++------------------
>>   1 file changed, 9 insertions(+), 18 deletions(-)
>>
>> diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
>> index b4858818523f..2bf9bf8867d4 100644
>> --- a/arch/powerpc/mm/pgtable_32.c
>> +++ b/arch/powerpc/mm/pgtable_32.c
>> @@ -254,26 +254,17 @@ static void __init __mapin_ram_chunk(unsigned long offset, unsigned long top)
>>   
>>   void __init mapin_ram(void)
>>   {
>> -	unsigned long s, top;
>> -
>> -#ifndef CONFIG_WII
>> -	top = total_lowmem;
>> -	s = mmu_mapin_ram(0, top);
>> -	__mapin_ram_chunk(s, top);
>> -#else
>> -	if (!wii_hole_size) {
>> -		s = mmu_mapin_ram(0, total_lowmem);
>> -		__mapin_ram_chunk(s, total_lowmem);
>> -	} else {
>> -		top = wii_hole_start;
>> -		s = mmu_mapin_ram(0, top);
>> -		__mapin_ram_chunk(s, top);
>> +	struct memblock_region *reg;
>> +
>> +	for_each_memblock(memory, reg) {
>> +		unsigned long base = reg->base;
>> +		unsigned long top = min(base + reg->size, (unsigned long)total_lowmem);
> 
> This gives me:
> 
> In file included from ../arch/powerpc/mm/pgtable_32.c:22:
> ../arch/powerpc/mm/pgtable_32.c: In function ‘mapin_ram’:
> ../include/linux/kernel.h:846:29: error: comparison of distinct pointer types lacks a cast [-Werror]
>     (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
>                               ^~
> ../include/linux/kernel.h:860:4: note: in expansion of macro ‘__typecheck’
>     (__typecheck(x, y) && __no_side_effects(x, y))
>      ^~~~~~~~~~~
> ../include/linux/kernel.h:870:24: note: in expansion of macro ‘__safe_cmp’
>    __builtin_choose_expr(__safe_cmp(x, y), \
>                          ^~~~~~~~~~
> ../include/linux/kernel.h:879:19: note: in expansion of macro ‘__careful_cmp’
>   #define min(x, y) __careful_cmp(x, y, <)
>                     ^~~~~~~~~~~~~
> ../arch/powerpc/mm/pgtable_32.c:261:23: note: in expansion of macro ‘min’
>     unsigned long top = min(base + reg->size, (unsigned long)total_lowmem);
>                         ^~~
> cc1: all warnings being treated as errors
> ../scripts/Makefile.build:276: recipe for target 'arch/powerpc/mm/pgtable_32.o' failed
> 
> 
> For 44x/bamboo_defconfig.
> 

The patch below should make it. Tested it on half a dozen of config.

diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
index 2bf9bf8867d4..c4b0eb51f6d8 100644
--- a/arch/powerpc/mm/pgtable_32.c
+++ b/arch/powerpc/mm/pgtable_32.c
@@ -257,8 +257,8 @@ void __init mapin_ram(void)
  	struct memblock_region *reg;

  	for_each_memblock(memory, reg) {
-		unsigned long base = reg->base;
-		unsigned long top = min(base + reg->size, (unsigned long)total_lowmem);
+		phys_addr_t base = reg->base;
+		phys_addr_t top = min(base + reg->size, total_lowmem);

  		if (base >= top)
  			continue;

I'll send out v5, hope it'll be the last one :(

Christophe
diff mbox series

Patch

diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
index b4858818523f..2bf9bf8867d4 100644
--- a/arch/powerpc/mm/pgtable_32.c
+++ b/arch/powerpc/mm/pgtable_32.c
@@ -254,26 +254,17 @@  static void __init __mapin_ram_chunk(unsigned long offset, unsigned long top)
 
 void __init mapin_ram(void)
 {
-	unsigned long s, top;
-
-#ifndef CONFIG_WII
-	top = total_lowmem;
-	s = mmu_mapin_ram(0, top);
-	__mapin_ram_chunk(s, top);
-#else
-	if (!wii_hole_size) {
-		s = mmu_mapin_ram(0, total_lowmem);
-		__mapin_ram_chunk(s, total_lowmem);
-	} else {
-		top = wii_hole_start;
-		s = mmu_mapin_ram(0, top);
-		__mapin_ram_chunk(s, top);
+	struct memblock_region *reg;
+
+	for_each_memblock(memory, reg) {
+		unsigned long base = reg->base;
+		unsigned long top = min(base + reg->size, (unsigned long)total_lowmem);
 
-		top = memblock_end_of_DRAM();
-		s = wii_mmu_mapin_mem2(top);
-		__mapin_ram_chunk(s, top);
+		if (base >= top)
+			continue;
+		base = mmu_mapin_ram(base, top);
+		__mapin_ram_chunk(base, top);
 	}
-#endif
 }
 
 /* Scan the real Linux page tables and return a PTE pointer for