Skip to contentSkip to conversation

MIPS: add declaration for function `memory_region_available`

PATCH Superseded Mathieu Malaterre 3 participants 9 messages Dec 26, 2017 – Feb 14, 2018 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 MIPS: add declaration for function `memory_region_available`

Fix non-fatal warning:

arch/mips/kernel/setup.c:158:13: warning: no previous prototype for ‘memory_region_available’ [-Wmissing-prototypes]
bool __init memory_region_available(phys_addr_t start, phys_addr_t size)

             ^~~~~~~~~~~~~~~~~~~~~~~
---
 arch/mips/include/asm/bootinfo.h | 1 +
 1 file changed, 1 insertion(+)
arch/mips/include/asm/bootinfo.h +1 -0
index e26a093bb17a..32e3c9a2c5a0 100644
@@ -108,6 +108,7 @@ extern struct boot_mem_map boot_mem_map;
 
 extern void add_memory_region(phys_addr_t start, phys_addr_t size, long type);
 extern void detect_memory_region(phys_addr_t start, phys_addr_t sz_min,  phys_addr_t sz_max);
+extern bool memory_region_available(phys_addr_t start, phys_addr_t size);
 
 extern void prom_init(void);
 extern void prom_free_prom_memory(void);
Signature · 1 line
2.11.0
#1 lore raw

PATCH 2/2 MIPS: Remove a warning when PHYS_OFFSET is 0x0

Rewrite the comparison in else if statement, case where min_low_pfn > ARCH_PFN_OFFSET has already been checked in the first if statement:

  if (min_low_pfn > ARCH_PFN_OFFSET) {

Fix non-fatal warning:

arch/mips/kernel/setup.c: In function ‘bootmem_init’:
arch/mips/kernel/setup.c:461:25: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]

  } else if (min_low_pfn < ARCH_PFN_OFFSET) {
                         ^
---
 arch/mips/kernel/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/setup.c +1 -1
index f19d61224c71..073695ccc1aa 100644
@@ -458,7 +458,7 @@ static void __init bootmem_init(void)
 		pr_info("Wasting %lu bytes for tracking %lu unused pages\n",
 			(min_low_pfn - ARCH_PFN_OFFSET) * sizeof(struct page),
 			min_low_pfn - ARCH_PFN_OFFSET);
-	} else if (min_low_pfn < ARCH_PFN_OFFSET) {
+	} else if (ARCH_PFN_OFFSET - min_low_pfn > 0UL) {
 		pr_info("%lu free pages won't be used\n",
 			ARCH_PFN_OFFSET - min_low_pfn);
 	}
Signature · 1 line
2.11.0
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] MIPS: Remove a warning when PHYS_OFFSET is 0x0

Quoted 11 lines · Mathieu Malaterre

Rewrite the comparison in else if statement, case where min_low_pfn > ARCH_PFN_OFFSET has already been checked in the first if statement:

  if (min_low_pfn > ARCH_PFN_OFFSET) {

Fix non-fatal warning:

arch/mips/kernel/setup.c: In function ‘bootmem_init’:
arch/mips/kernel/setup.c:461:25: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]

  } else if (min_low_pfn < ARCH_PFN_OFFSET) {
                         ^

What compiler version is that with out of interest? It isn't exactly new code.

Quoted 2 lines

Cheers
James

Quoted 20 lines
---
 arch/mips/kernel/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/setup.c +1 -1
index f19d61224c71..073695ccc1aa 100644
@@ -458,7 +458,7 @@ static void __init bootmem_init(void)
 		pr_info("Wasting %lu bytes for tracking %lu unused pages\n",
 			(min_low_pfn - ARCH_PFN_OFFSET) * sizeof(struct page),
 			min_low_pfn - ARCH_PFN_OFFSET);
-	} else if (min_low_pfn < ARCH_PFN_OFFSET) {
+	} else if (ARCH_PFN_OFFSET - min_low_pfn > 0UL) {
 		pr_info("%lu free pages won't be used\n",
 			ARCH_PFN_OFFSET - min_low_pfn);
 	}
Signature · 1 line
2.11.0
#3 lore raw

Re: [PATCH 2/2] MIPS: Remove a warning when PHYS_OFFSET is 0x0

Hi James,

Quoted 8 lines · James Hogan
Quoted 7 lines · Mathieu Malaterre

Rewrite the comparison in else if statement, case where min_low_pfn > ARCH_PFN_OFFSET has already been checked in the first if statement:

  if (min_low_pfn > ARCH_PFN_OFFSET) {

Fix non-fatal warning:

Quoted 7 lines
Quoted 4 lines

arch/mips/kernel/setup.c: In function ‘bootmem_init’:
arch/mips/kernel/setup.c:461:25: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]

  } else if (min_low_pfn < ARCH_PFN_OFFSET) {
                         ^

What compiler version is that with out of interest? It isn't exactly new code.

I've clarified in v2, that this happen during compilation using W=1

For reference:

$ mipsel-linux-gnu-gcc -dumpversion
6.3.0
Quoted 4 lines
Quoted 2 lines

Thanks !

#4 lore raw

Re: [PATCH 2/2] MIPS: Remove a warning when PHYS_OFFSET is 0x0

Quoted 28 lines · Mathieu Malaterre

Hi James,

Quoted 8 lines · James Hogan
Quoted 7 lines · Mathieu Malaterre

Rewrite the comparison in else if statement, case where min_low_pfn > ARCH_PFN_OFFSET has already been checked in the first if statement:

  if (min_low_pfn > ARCH_PFN_OFFSET) {

Fix non-fatal warning:

Quoted 7 lines
Quoted 4 lines

arch/mips/kernel/setup.c: In function ‘bootmem_init’:
arch/mips/kernel/setup.c:461:25: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]

  } else if (min_low_pfn < ARCH_PFN_OFFSET) {
                         ^

What compiler version is that with out of interest? It isn't exactly new code.

I've clarified in v2, that this happen during compilation using W=1

For reference:

$ mipsel-linux-gnu-gcc -dumpversion
6.3.0
Quoted 1 line
Quoted 1 line
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Thanks !

ping ?

https://patchwork.linux-mips.org/project/linux-mips/list/?series=623

#5 lore raw

Re: [PATCH 2/2] MIPS: Remove a warning when PHYS_OFFSET is 0x0

Quoted 31 lines · Mathieu Malaterre
Quoted 30 lines · Mathieu Malaterre

Hi James,

Quoted 8 lines · James Hogan
Quoted 7 lines · Mathieu Malaterre

Rewrite the comparison in else if statement, case where min_low_pfn > ARCH_PFN_OFFSET has already been checked in the first if statement:

  if (min_low_pfn > ARCH_PFN_OFFSET) {

Fix non-fatal warning:

Quoted 7 lines
Quoted 4 lines

arch/mips/kernel/setup.c: In function ‘bootmem_init’:
arch/mips/kernel/setup.c:461:25: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]

  } else if (min_low_pfn < ARCH_PFN_OFFSET) {
                         ^

What compiler version is that with out of interest? It isn't exactly new code.

I've clarified in v2, that this happen during compilation using W=1

For reference:

$ mipsel-linux-gnu-gcc -dumpversion
6.3.0
Quoted 3 lines
Quoted 2 lines
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Thanks !

ping ?

https://patchwork.linux-mips.org/project/linux-mips/list/?series=623

Yep, both applied for 4.17.

Thanks
James

#6 lore raw

PATCH v2 2/2 MIPS: Remove a warning when PHYS_OFFSET is 0x0

In reply to Mathieu Malaterre

Rewrite the comparison in else if statement, case where min_low_pfn > ARCH_PFN_OFFSET has already been checked in the first if statement:

  if (min_low_pfn > ARCH_PFN_OFFSET) {

Fix non-fatal warning during compilation using W=1:

arch/mips/kernel/setup.c: In function ‘bootmem_init’:
arch/mips/kernel/setup.c:461:25: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]

  } else if (min_low_pfn < ARCH_PFN_OFFSET) {
                         ^

---
v2: clarify W=1 in commit message

 arch/mips/kernel/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/setup.c +1 -1
index 68db4bdd3255..791dc78b132b 100644
@@ -459,7 +459,7 @@ static void __init bootmem_init(void)
 		pr_info("Wasting %lu bytes for tracking %lu unused pages\n",
 			(min_low_pfn - ARCH_PFN_OFFSET) * sizeof(struct page),
 			min_low_pfn - ARCH_PFN_OFFSET);
-	} else if (min_low_pfn < ARCH_PFN_OFFSET) {
+	} else if (ARCH_PFN_OFFSET - min_low_pfn > 0UL) {
 		pr_info("%lu free pages won't be used\n",
 			ARCH_PFN_OFFSET - min_low_pfn);
 	}
Signature · 1 line
2.11.0
#7 lore raw
In reply to Mathieu Malaterre
Quoted 5 lines · Mathieu Malaterre

Fix non-fatal warning:

arch/mips/kernel/setup.c:158:13: warning: no previous prototype for ‘memory_region_available’ [-Wmissing-prototypes]
bool __init memory_region_available(phys_addr_t start, phys_addr_t size)

             ^~~~~~~~~~~~~~~~~~~~~~~

It only seems to be referenced from that one file, so making it static and __maybe_unused to handle the configs it isn't used would probably be better.

Thanks
James

Quoted 22 lines
---
 arch/mips/include/asm/bootinfo.h | 1 +
 1 file changed, 1 insertion(+)
arch/mips/include/asm/bootinfo.h +1 -0
index e26a093bb17a..32e3c9a2c5a0 100644
@@ -108,6 +108,7 @@ extern struct boot_mem_map boot_mem_map;
 
 extern void add_memory_region(phys_addr_t start, phys_addr_t size, long type);
 extern void detect_memory_region(phys_addr_t start, phys_addr_t sz_min,  phys_addr_t sz_max);
+extern bool memory_region_available(phys_addr_t start, phys_addr_t size);
 
 extern void prom_init(void);
 extern void prom_free_prom_memory(void);
Signature · 1 line
2.11.0
#8 lore raw

PATCH v2 1/2 MIPS: Make declaration for function `memory_region_available` static

In reply to Mathieu Malaterre

Fix non-fatal warning during compilation using W=1:

arch/mips/kernel/setup.c:158:13: warning: no previous prototype for ‘memory_region_available’ [-Wmissing-prototypes]
bool __init memory_region_available(phys_addr_t start, phys_addr_t size)

             ^~~~~~~~~~~~~~~~~~~~~~~

---
v2: Prefer static declaration, clarify W=1 in commit message

 arch/mips/kernel/setup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/mips/kernel/setup.c +2 -1
index f19d61224c71..68db4bdd3255 100644
@@ -155,7 +155,8 @@ void __init detect_memory_region(phys_addr_t start, phys_addr_t sz_min, phys_add
 	add_memory_region(start, size, BOOT_MEM_RAM);
 }
 
-bool __init memory_region_available(phys_addr_t start, phys_addr_t size)
+static bool __init __maybe_unused memory_region_available(phys_addr_t start,
+	phys_addr_t size)
 {
 	int i;
 	bool in_ram = false, free = true;
Signature · 1 line
2.11.0