diff mbox series

[2/3] MIPS: Loongson64: Clean up numa.c

Message ID 1602241050-24051-3-git-send-email-yangtiezhu@loongson.cn (mailing list archive)
State Superseded
Headers show
Series Avoid build error, clean up numa.c and add /proc/boardinfo | expand

Commit Message

Tiezhu Yang Oct. 9, 2020, 10:57 a.m. UTC
(1) Replace nid_to_addroffset() with nid_to_addrbase() and then remove the
related useless code.

(2) Since end_pfn = start_pfn + node_psize, use "node_psize" instead of
"end_pfn - start_pfn" to avoid the redundant calculation.

(3) After commit 6fbde6b492df ("MIPS: Loongson64: Move files to the
top-level directory"), CONFIG_ZONE_DMA32 is always set for Loongson64
due to MACH_LOONGSON64 selects ZONE_DMA32, so no need to use ifdef any
more, just remove it.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 arch/mips/include/asm/mach-loongson64/mmzone.h |  6 +-----
 arch/mips/loongson64/numa.c                    | 29 +++-----------------------
 2 files changed, 4 insertions(+), 31 deletions(-)

Comments

Jiaxun Yang Oct. 10, 2020, 8:06 a.m. UTC | #1
在 2020/10/9 下午6:57, Tiezhu Yang 写道:
> (1) Replace nid_to_addroffset() with nid_to_addrbase() and then remove the
> related useless code.
>
> (2) Since end_pfn = start_pfn + node_psize, use "node_psize" instead of
> "end_pfn - start_pfn" to avoid the redundant calculation.
>
> (3) After commit 6fbde6b492df ("MIPS: Loongson64: Move files to the
> top-level directory"), CONFIG_ZONE_DMA32 is always set for Loongson64
> due to MACH_LOONGSON64 selects ZONE_DMA32, so no need to use ifdef any
> more, just remove it.
>
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>

Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>

> ---
>   arch/mips/include/asm/mach-loongson64/mmzone.h |  6 +-----
>   arch/mips/loongson64/numa.c                    | 29 +++-----------------------
>   2 files changed, 4 insertions(+), 31 deletions(-)
>
> diff --git a/arch/mips/include/asm/mach-loongson64/mmzone.h b/arch/mips/include/asm/mach-loongson64/mmzone.h
> index 3a25dbd..c3f0f7a 100644
> --- a/arch/mips/include/asm/mach-loongson64/mmzone.h
> +++ b/arch/mips/include/asm/mach-loongson64/mmzone.h
> @@ -11,13 +11,9 @@
>   
>   #include <boot_param.h>
>   #define NODE_ADDRSPACE_SHIFT 44
> -#define NODE0_ADDRSPACE_OFFSET 0x000000000000UL
> -#define NODE1_ADDRSPACE_OFFSET 0x100000000000UL
> -#define NODE2_ADDRSPACE_OFFSET 0x200000000000UL
> -#define NODE3_ADDRSPACE_OFFSET 0x300000000000UL
>   
>   #define pa_to_nid(addr)  (((addr) & 0xf00000000000) >> NODE_ADDRSPACE_SHIFT)
> -#define nid_to_addrbase(nid) ((nid) << NODE_ADDRSPACE_SHIFT)
> +#define nid_to_addrbase(nid) ((unsigned long)(nid) << NODE_ADDRSPACE_SHIFT)
>   
>   extern struct pglist_data *__node_data[];
>   
> diff --git a/arch/mips/loongson64/numa.c b/arch/mips/loongson64/numa.c
> index ea8bb1b..cf9459f 100644
> --- a/arch/mips/loongson64/numa.c
> +++ b/arch/mips/loongson64/numa.c
> @@ -98,27 +98,6 @@ static void __init init_topology_matrix(void)
>   	}
>   }
>   
> -static unsigned long nid_to_addroffset(unsigned int nid)
> -{
> -	unsigned long result;
> -	switch (nid) {
> -	case 0:
> -	default:
> -		result = NODE0_ADDRSPACE_OFFSET;
> -		break;
> -	case 1:
> -		result = NODE1_ADDRSPACE_OFFSET;
> -		break;
> -	case 2:
> -		result = NODE2_ADDRSPACE_OFFSET;
> -		break;
> -	case 3:
> -		result = NODE3_ADDRSPACE_OFFSET;
> -		break;
> -	}
> -	return result;
> -}
> -
>   static void __init szmem(unsigned int node)
>   {
>   	u32 i, mem_type;
> @@ -146,7 +125,7 @@ static void __init szmem(unsigned int node)
>   			pr_info("       start_pfn:0x%llx, end_pfn:0x%llx, num_physpages:0x%lx\n",
>   				start_pfn, end_pfn, num_physpages);
>   			memblock_add_node(PFN_PHYS(start_pfn),
> -				PFN_PHYS(end_pfn - start_pfn), node);
> +				PFN_PHYS(node_psize), node);
>   			break;
>   		case SYSTEM_RAM_HIGH:
>   			start_pfn = ((node_id << 44) + mem_start) >> PAGE_SHIFT;
> @@ -158,7 +137,7 @@ static void __init szmem(unsigned int node)
>   			pr_info("       start_pfn:0x%llx, end_pfn:0x%llx, num_physpages:0x%lx\n",
>   				start_pfn, end_pfn, num_physpages);
>   			memblock_add_node(PFN_PHYS(start_pfn),
> -				PFN_PHYS(end_pfn - start_pfn), node);
> +				PFN_PHYS(node_psize), node);
>   			break;
>   		case SYSTEM_RAM_RESERVED:
>   			pr_info("Node%d: mem_type:%d, mem_start:0x%llx, mem_size:0x%llx MB\n",
> @@ -175,7 +154,7 @@ static void __init node_mem_init(unsigned int node)
>   	unsigned long node_addrspace_offset;
>   	unsigned long start_pfn, end_pfn;
>   
> -	node_addrspace_offset = nid_to_addroffset(node);
> +	node_addrspace_offset = nid_to_addrbase(node);
>   	pr_info("Node%d's addrspace_offset is 0x%lx\n",
>   			node, node_addrspace_offset);
>   
> @@ -242,9 +221,7 @@ void __init paging_init(void)
>   	unsigned long zones_size[MAX_NR_ZONES] = {0, };
>   
>   	pagetable_init();
> -#ifdef CONFIG_ZONE_DMA32
>   	zones_size[ZONE_DMA32] = MAX_DMA32_PFN;
> -#endif
>   	zones_size[ZONE_NORMAL] = max_low_pfn;
>   	free_area_init(zones_size);
>   }
diff mbox series

Patch

diff --git a/arch/mips/include/asm/mach-loongson64/mmzone.h b/arch/mips/include/asm/mach-loongson64/mmzone.h
index 3a25dbd..c3f0f7a 100644
--- a/arch/mips/include/asm/mach-loongson64/mmzone.h
+++ b/arch/mips/include/asm/mach-loongson64/mmzone.h
@@ -11,13 +11,9 @@ 
 
 #include <boot_param.h>
 #define NODE_ADDRSPACE_SHIFT 44
-#define NODE0_ADDRSPACE_OFFSET 0x000000000000UL
-#define NODE1_ADDRSPACE_OFFSET 0x100000000000UL
-#define NODE2_ADDRSPACE_OFFSET 0x200000000000UL
-#define NODE3_ADDRSPACE_OFFSET 0x300000000000UL
 
 #define pa_to_nid(addr)  (((addr) & 0xf00000000000) >> NODE_ADDRSPACE_SHIFT)
-#define nid_to_addrbase(nid) ((nid) << NODE_ADDRSPACE_SHIFT)
+#define nid_to_addrbase(nid) ((unsigned long)(nid) << NODE_ADDRSPACE_SHIFT)
 
 extern struct pglist_data *__node_data[];
 
diff --git a/arch/mips/loongson64/numa.c b/arch/mips/loongson64/numa.c
index ea8bb1b..cf9459f 100644
--- a/arch/mips/loongson64/numa.c
+++ b/arch/mips/loongson64/numa.c
@@ -98,27 +98,6 @@  static void __init init_topology_matrix(void)
 	}
 }
 
-static unsigned long nid_to_addroffset(unsigned int nid)
-{
-	unsigned long result;
-	switch (nid) {
-	case 0:
-	default:
-		result = NODE0_ADDRSPACE_OFFSET;
-		break;
-	case 1:
-		result = NODE1_ADDRSPACE_OFFSET;
-		break;
-	case 2:
-		result = NODE2_ADDRSPACE_OFFSET;
-		break;
-	case 3:
-		result = NODE3_ADDRSPACE_OFFSET;
-		break;
-	}
-	return result;
-}
-
 static void __init szmem(unsigned int node)
 {
 	u32 i, mem_type;
@@ -146,7 +125,7 @@  static void __init szmem(unsigned int node)
 			pr_info("       start_pfn:0x%llx, end_pfn:0x%llx, num_physpages:0x%lx\n",
 				start_pfn, end_pfn, num_physpages);
 			memblock_add_node(PFN_PHYS(start_pfn),
-				PFN_PHYS(end_pfn - start_pfn), node);
+				PFN_PHYS(node_psize), node);
 			break;
 		case SYSTEM_RAM_HIGH:
 			start_pfn = ((node_id << 44) + mem_start) >> PAGE_SHIFT;
@@ -158,7 +137,7 @@  static void __init szmem(unsigned int node)
 			pr_info("       start_pfn:0x%llx, end_pfn:0x%llx, num_physpages:0x%lx\n",
 				start_pfn, end_pfn, num_physpages);
 			memblock_add_node(PFN_PHYS(start_pfn),
-				PFN_PHYS(end_pfn - start_pfn), node);
+				PFN_PHYS(node_psize), node);
 			break;
 		case SYSTEM_RAM_RESERVED:
 			pr_info("Node%d: mem_type:%d, mem_start:0x%llx, mem_size:0x%llx MB\n",
@@ -175,7 +154,7 @@  static void __init node_mem_init(unsigned int node)
 	unsigned long node_addrspace_offset;
 	unsigned long start_pfn, end_pfn;
 
-	node_addrspace_offset = nid_to_addroffset(node);
+	node_addrspace_offset = nid_to_addrbase(node);
 	pr_info("Node%d's addrspace_offset is 0x%lx\n",
 			node, node_addrspace_offset);
 
@@ -242,9 +221,7 @@  void __init paging_init(void)
 	unsigned long zones_size[MAX_NR_ZONES] = {0, };
 
 	pagetable_init();
-#ifdef CONFIG_ZONE_DMA32
 	zones_size[ZONE_DMA32] = MAX_DMA32_PFN;
-#endif
 	zones_size[ZONE_NORMAL] = max_low_pfn;
 	free_area_init(zones_size);
 }