diff options
author | Huacai Chen <chenhuacai@loongson.cn> | 2022-05-31 18:04:12 +0800 |
---|---|---|
committer | Huacai Chen <chenhuacai@loongson.cn> | 2022-06-03 20:09:29 +0800 |
commit | d4b6f1562a3c3284adcef81d6e4f183d7d34b8a9 (patch) | |
tree | 365dc4b9e63fe8b038078a8fe6e8b8acb32527b1 /arch/loongarch/mm/init.c | |
parent | 46859ac8af52ae599e1b51992ddef3eb43f295fc (diff) | |
download | linux-stable-d4b6f1562a3c3284adcef81d6e4f183d7d34b8a9.tar.gz linux-stable-d4b6f1562a3c3284adcef81d6e4f183d7d34b8a9.tar.bz2 linux-stable-d4b6f1562a3c3284adcef81d6e4f183d7d34b8a9.zip |
LoongArch: Add Non-Uniform Memory Access (NUMA) support
Add Non-Uniform Memory Access (NUMA) support for LoongArch. LoongArch
has 48-bit physical address, but the HyperTransport I/O bus only support
40-bit address, so we need a custom phys_to_dma() and dma_to_phys() to
extract the 4-bit node id (bit 44~47) from Loongson-3's 48-bit physical
address space and embed it into 40-bit. In the 40-bit dma address, node
id offset can be read from the LS7A_DMA_CFG register.
Reviewed-by: WANG Xuerui <git@xen0n.name>
Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Diffstat (limited to 'arch/loongarch/mm/init.c')
-rw-r--r-- | arch/loongarch/mm/init.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/arch/loongarch/mm/init.c b/arch/loongarch/mm/init.c index afd6634ce171..7094a68c9b83 100644 --- a/arch/loongarch/mm/init.c +++ b/arch/loongarch/mm/init.c @@ -84,6 +84,7 @@ int __ref page_is_ram(unsigned long pfn) return memblock_is_memory(addr) && !memblock_is_reserved(addr); } +#ifndef CONFIG_NUMA void __init paging_init(void) { unsigned long max_zone_pfns[MAX_NR_ZONES]; @@ -107,6 +108,7 @@ void __init mem_init(void) memblock_free_all(); setup_zero_pages(); /* Setup zeroed pages. */ } +#endif /* !CONFIG_NUMA */ void __ref free_initmem(void) { @@ -129,6 +131,17 @@ int arch_add_memory(int nid, u64 start, u64 size, struct mhp_params *params) return ret; } +#ifdef CONFIG_NUMA +int memory_add_physaddr_to_nid(u64 start) +{ + int nid; + + nid = pa_to_nid(start); + return nid; +} +EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid); +#endif + #ifdef CONFIG_MEMORY_HOTREMOVE void arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap) { |