Messages in this thread | | | From | Logan Gunthorpe <> | Date | Wed, 14 Aug 2019 10:56:35 -0600 | Subject | Re: [PATCH v4 2/2] RISC-V: Implement sparsemem |
| |
On 2019-08-14 7:35 a.m., Greentime Hu wrote: > Logan Gunthorpe <logang@deltatee.com> 於 2019年8月14日 週三 上午12:50寫道: >> >> On 2019-08-13 10:39 a.m., Paul Walmsley wrote: >>> On Tue, 13 Aug 2019, Logan Gunthorpe wrote: >>> >>>> On 2019-08-13 12:04 a.m., Greentime Hu wrote: >>>> >>>>> Every architecture with mmu defines their own pfn_valid(). >>>> >>>> Not true. Arm64, for example just uses the generic implementation in >>>> mmzone.h. >>> >>> arm64 seems to define their own: >>> >>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/Kconfig#n899 >> >> Oh, yup. My mistake. >> >>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/mm/init.c#n235 >>> >>> While there are many architectures which have their own pfn_valid(); >>> oddly, almost none of them set HAVE_ARCH_PFN_VALID ? >> >> Yes, much of this is super confusing. Seems HAVE_ARCH_PFN_VALID only >> matters if SPARSEMEM is set. So risc-v probably doesn't need to set it >> and we just need a #ifdef !CONFIG_FLATMEM around the pfn_valid >> definition like other arches. >> > > Maybe this commit explains why it used HAVE_ARCH_PFN_VALID instead of SPARSEMEM. > https://github.com/torvalds/linux/commit/7b7bf499f79de3f6c85a340c8453a78789523f85 > > BTW, I found another issue here. > #define FIXADDR_TOP (VMALLOC_START) > #define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) > #define VMEMMAP_END (VMALLOC_START - 1) > #define VMEMMAP_START (VMALLOC_START - VMEMMAP_SIZE) > These 2 regions are overlapped. > > How about this fix? Not sure if it is good for everyone.
Yes, this looks good to me. I can fold these changes into my patch and send a v5 to the list.
Thanks!
Logan
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig > index 3f12b069af1d..3c4d394679d0 100644 > --- a/arch/riscv/Kconfig > +++ b/arch/riscv/Kconfig > @@ -115,9 +115,6 @@ config PGTABLE_LEVELS > default 3 if 64BIT > default 2 > > -config HAVE_ARCH_PFN_VALID > - def_bool y > - > menu "Platform type" > > choice > diff --git a/arch/riscv/include/asm/fixmap.h b/arch/riscv/include/asm/fixmap.h > index c207f6634b91..72e106b60bc5 100644 > --- a/arch/riscv/include/asm/fixmap.h > +++ b/arch/riscv/include/asm/fixmap.h > @@ -26,7 +26,7 @@ enum fixed_addresses { > }; > > #define FIXADDR_SIZE (__end_of_fixed_addresses * PAGE_SIZE) > -#define FIXADDR_TOP (VMALLOC_START) > +#define FIXADDR_TOP (VMEMMAP_START) > #define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) > > #define FIXMAP_PAGE_IO PAGE_KERNEL > diff --git a/arch/riscv/include/asm/page.h b/arch/riscv/include/asm/page.h > index 8ddb6c7fedac..83830997dce6 100644 > --- a/arch/riscv/include/asm/page.h > +++ b/arch/riscv/include/asm/page.h > @@ -100,8 +100,10 @@ extern unsigned long min_low_pfn; > #define page_to_bus(page) (page_to_phys(page)) > #define phys_to_page(paddr) (pfn_to_page(phys_to_pfn(paddr))) > > +#if defined(CONFIG_FLATMEM) > #define pfn_valid(pfn) \ > (((pfn) >= pfn_base) && (((pfn)-pfn_base) < max_mapnr)) > +#endif > > #define ARCH_PFN_OFFSET (pfn_base)
| |