[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <0926a261-520e-4c40-f926-ddd40bb8ce44@deltatee.com>
Date: Fri, 9 Aug 2019 09:46:49 -0600
From: Logan Gunthorpe <logang@...tatee.com>
To: Greentime Hu <green.hu@...il.com>
Cc: greentime.hu@...ive.com, paul.walmsley@...ive.com,
Rob Herring <robh@...nel.org>,
Albert Ou <aou@...s.berkeley.edu>,
Andrew Waterman <andrew@...ive.com>,
Palmer Dabbelt <palmer@...ive.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Stephen Bates <sbates@...thlin.com>,
Zong Li <zong@...estech.com>, Olof Johansson <olof@...om.net>,
linux-riscv@...ts.infradead.org,
Michael Clark <michaeljclark@....com>,
Christoph Hellwig <hch@....de>
Subject: Re: [PATCH v4 2/2] RISC-V: Implement sparsemem
On 2019-08-08 10:23 p.m., Greentime Hu wrote:
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 3f12b069af1d..208b3e14ccd8 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -116,7 +116,8 @@ config PGTABLE_LEVELS
> default 2
>
> config HAVE_ARCH_PFN_VALID
> - def_bool y
> + bool
> + default !SPARSEMEM_VMEMMAP
>
> menu "Platform type"
>
> diff --git a/arch/riscv/include/asm/page.h b/arch/riscv/include/asm/page.h
> index 8ddb6c7fedac..6991f7a5a4a7 100644
> --- a/arch/riscv/include/asm/page.h
> +++ b/arch/riscv/include/asm/page.h
> @@ -93,16 +93,20 @@ extern unsigned long min_low_pfn;
> #define virt_to_pfn(vaddr) (phys_to_pfn(__pa(vaddr)))
> #define pfn_to_virt(pfn) (__va(pfn_to_phys(pfn)))
>
> +#if !defined(CONFIG_SPARSEMEM_VMEMMAP)
> +#define pfn_valid(pfn) \
> + (((pfn) >= pfn_base) && (((pfn)-pfn_base) < max_mapnr))
> #define virt_to_page(vaddr) (pfn_to_page(virt_to_pfn(vaddr)))
> #define page_to_virt(page) (pfn_to_virt(page_to_pfn(page)))
> +#else
> +#define virt_to_page(vaddr) ((struct page *)((((u64)vaddr -
> va_pa_offset) / PAGE_SIZE) * sizeof(struct page) + VMEMMAP_START))
> +#define page_to_virt(pg) ((void *)(((((u64)pg - VMEMMAP_START) /
> sizeof(struct page)) * PAGE_SIZE) + va_pa_offset))
> +#endif
This doesn't make sense to me at all. It should always use pfn_to_page()
for virt_to_page() and the generic pfn_to_page()/page_to_pfn()
implementations essentially already do what you are doing in a cleaner
way. So I'd be really surprised if this does anything at all.
Logan
Powered by blists - more mailing lists