Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp2007168pxu; Fri, 9 Oct 2020 05:46:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztFwGGBohCK3WBhOW1gG944hsTTq8iSTwRKIekKyLSzWL+DrUPSxK/S9G6O5R62hQPqtxJ X-Received: by 2002:aa7:cb92:: with SMTP id r18mr14838750edt.13.1602247571977; Fri, 09 Oct 2020 05:46:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602247571; cv=none; d=google.com; s=arc-20160816; b=kbKwsTP/+2YSW3tJLZOAkolHD+yVaHveQPE93RH1kAGon5qCxVZ1PKdua2+8chFSXi CAiHtnYyX/aGZ/G0lX9sPETT+k6QmxTC63p+/8yZ2LQUnuQpzT30YLdf8p/xb1OaaLlQ p7LeuLAG1b/v5bGM31pDqQabZrBBVwuwZKegzLTechwKP4wsUSDSbcdNuFP3OkAeMmjh i6u0kwDhPoa58h89B++8j1umbEpv8Ak3FjWTFOlWmXxMAof6T1vqpCEfZ8fNCQ6HHUuD wp/T7IwAVcucQWXnyg4wZwG0tVH220qsYswsX1r66LCIDjLgymwMWVm008yhJfMI3SKc RM6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=j2v0JGDVyp8sPdUvC0TywQB3/suT1yW3MxzSfR37Wl8=; b=k+iaJbXA6YO/ayn2OoBm8cILSQPvtTev8mHQr3IuIoqqzq9f5imFEcRsGn3RtA4o2j nVAZeEtppiuY5GOCk5KE3tqTi3effLUtRunIQTWXRHpEPrUhbVLCNlJzIpx1Z/VdAxLn gwHilejTmwecxzsJQigbj5TUhTbmuzuAwoIha01eB8rERb05aeymmx6s0iBgC1zQkrjE YYo/riTGxZlFaY4imYCru0zmlwtkG6AtGPBz4bt09Pn6DmlM/mxfzI3KCGNLUCG4GfI7 ykIUEx/5mPchhdMti2Qeu6skIbXg6UQh7Zl5bzK6LLYn209UW/J+iYZz0Py1kA3S2Cax EI2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l31si6141605edl.524.2020.10.09.05.45.47; Fri, 09 Oct 2020 05:46:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732430AbgJIK5i (ORCPT + 99 others); Fri, 9 Oct 2020 06:57:38 -0400 Received: from mail.loongson.cn ([114.242.206.163]:38282 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732391AbgJIK5h (ORCPT ); Fri, 9 Oct 2020 06:57:37 -0400 Received: from linux.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dx2MUaQoBf2pcbAA--.2238S4; Fri, 09 Oct 2020 18:57:32 +0800 (CST) From: Tiezhu Yang To: Thomas Bogendoerfer , Huacai Chen , Jiaxun Yang Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Xuefeng Li Subject: [PATCH 2/3] MIPS: Loongson64: Clean up numa.c Date: Fri, 9 Oct 2020 18:57:29 +0800 Message-Id: <1602241050-24051-3-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1602241050-24051-1-git-send-email-yangtiezhu@loongson.cn> References: <1602241050-24051-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf9Dx2MUaQoBf2pcbAA--.2238S4 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xZFpf9x0JU0hF3UUUUU= X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (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 --- 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 #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); } -- 2.1.0