Skip to contentSkip to conversation

riscv: mm: fix build errors caused by mk_pmd()

PATCH Superseded Nanyong Sun 2 participants 4 messages May 24, 2021 – Jun 1, 2021 RISC-V

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv: mm: fix build errors caused by mk_pmd()

With "riscv: mm: add THP support on 64-bit", mk_pmd() function
introduce build errors,
1.build with CONFIG_ARCH_RV32I=y:
arch/riscv/include/asm/pgtable.h: In function 'mk_pmd':
arch/riscv/include/asm/pgtable.h:513:9: error: implicit declaration of function 'pfn_pmd';
did you mean 'pfn_pgd'? [-Werror=implicit-function-declaration]

2.build with CONFIG_SPARSEMEM=y && CONFIG_SPARSEMEM_VMEMMAP=n arch/riscv/include/asm/pgtable.h: In function 'mk_pmd':
include/asm-generic/memory_model.h:64:14: error: implicit declaration of function 'page_to_section';
did you mean 'present_section'? [-Werror=implicit-function-declaration]

Use macro definition instead of inline function for mk_pmd to fix the above problems.It is similar to the mk_pte macro.

---
 arch/riscv/include/asm/pgtable.h | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
arch/riscv/include/asm/pgtable.h +1 -4
index 4b708ae08910..f35d9c90d4cb 100644
@@ -508,10 +508,7 @@ static inline unsigned long pmd_pfn(pmd_t pmd)
 	return ((__pmd_to_phys(pmd) & PMD_MASK) >> PAGE_SHIFT);
 }
 
-static inline pmd_t mk_pmd(struct page *page, pgprot_t prot)
-{
-	return pfn_pmd(page_to_pfn(page), prot);
-}
+#define mk_pmd(page, prot)    pfn_pmd(page_to_pfn(page), prot)
 
 static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
 {
Signature · 1 line
2.18.0.huawei.25
maintainer
#1 lore raw
Quoted 27 lines · On Mon, 24 May 2021 00:02:20 PDT (-0700), [email protected] wrote:

With "riscv: mm: add THP support on 64-bit", mk_pmd() function
introduce build errors,
1.build with CONFIG_ARCH_RV32I=y:
arch/riscv/include/asm/pgtable.h: In function 'mk_pmd':
arch/riscv/include/asm/pgtable.h:513:9: error: implicit declaration of function 'pfn_pmd';
did you mean 'pfn_pgd'? [-Werror=implicit-function-declaration]

2.build with CONFIG_SPARSEMEM=y && CONFIG_SPARSEMEM_VMEMMAP=n arch/riscv/include/asm/pgtable.h: In function 'mk_pmd':
include/asm-generic/memory_model.h:64:14: error: implicit declaration of function 'page_to_section';
did you mean 'present_section'? [-Werror=implicit-function-declaration]

Use macro definition instead of inline function for mk_pmd to fix the above problems.It is similar to the mk_pte macro.

---
 arch/riscv/include/asm/pgtable.h | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
arch/riscv/include/asm/pgtable.h +0 -0
index 4b708ae08910..f35d9c90d4cb 100644
@@ -508,10 +508,7 @@ static inline unsigned long pmd_pfn(pmd_t pmd)
 	return ((__pmd_to_phys(pmd) & PMD_MASK) >> PAGE_SHIFT);

arch/riscv/include/asm/pgtable.h static inline unsigned long pmd_pfn(pmd_t pmd) · line 514

Quoted 10 lines
arch/riscv/include/asm/pgtable.h +1 -4
 }
 
-static inline pmd_t mk_pmd(struct page *page, pgprot_t prot)
-{
-	return pfn_pmd(page_to_pfn(page), prot);
-}
+#define mk_pmd(page, prot)    pfn_pmd(page_to_pfn(page), prot)
 
 static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
 {

Thanks, this is on for-next.

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

maintainer
#2 lore raw
Quoted 36 lines · Palmer Dabbelt
Quoted 35 lines · On Mon, 24 May 2021 00:02:20 PDT (-0700), [email protected] wrote:

With "riscv: mm: add THP support on 64-bit", mk_pmd() function
introduce build errors,
1.build with CONFIG_ARCH_RV32I=y:
arch/riscv/include/asm/pgtable.h: In function 'mk_pmd':
arch/riscv/include/asm/pgtable.h:513:9: error: implicit declaration of function 'pfn_pmd';
did you mean 'pfn_pgd'? [-Werror=implicit-function-declaration]

2.build with CONFIG_SPARSEMEM=y && CONFIG_SPARSEMEM_VMEMMAP=n arch/riscv/include/asm/pgtable.h: In function 'mk_pmd':
include/asm-generic/memory_model.h:64:14: error: implicit declaration of function 'page_to_section';
did you mean 'present_section'? [-Werror=implicit-function-declaration]

Use macro definition instead of inline function for mk_pmd to fix the above problems.It is similar to the mk_pte macro.

---
 arch/riscv/include/asm/pgtable.h | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
arch/riscv/include/asm/pgtable.h +1 -4
index 4b708ae08910..f35d9c90d4cb 100644
@@ -508,10 +508,7 @@ static inline unsigned long pmd_pfn(pmd_t pmd)
 	return ((__pmd_to_phys(pmd) & PMD_MASK) >> PAGE_SHIFT);
 }
 
-static inline pmd_t mk_pmd(struct page *page, pgprot_t prot)
-{
-	return pfn_pmd(page_to_pfn(page), prot);
-}
+#define mk_pmd(page, prot)    pfn_pmd(page_to_pfn(page), prot)
 
Quoted 4 lines

arch/riscv/include/asm/pgtable.h static inline unsigned long pmd_pfn(pmd_t pmd) · line 514

Quoted 2 lines
arch/riscv/include/asm/pgtable.h +0 -0
 static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
 {

Thanks, this is on for-next.

Sorry, I wasn't looking closely enough. I think the actual problem here is that mk_pmd() should be in pgtable-64.h.

#3 lore raw
Quoted 37 lines · Palmer Dabbelt
Quoted 36 lines · Palmer Dabbelt
Quoted 35 lines · On Mon, 24 May 2021 00:02:20 PDT (-0700), [email protected] wrote:

With "riscv: mm: add THP support on 64-bit", mk_pmd() function
introduce build errors,
1.build with CONFIG_ARCH_RV32I=y:
arch/riscv/include/asm/pgtable.h: In function 'mk_pmd':
arch/riscv/include/asm/pgtable.h:513:9: error: implicit declaration of function 'pfn_pmd'; did you mean 'pfn_pgd'? [-Werror=implicit-function-declaration]

2.build with CONFIG_SPARSEMEM=y && CONFIG_SPARSEMEM_VMEMMAP=n arch/riscv/include/asm/pgtable.h: In function 'mk_pmd':
include/asm-generic/memory_model.h:64:14: error: implicit declaration of function 'page_to_section'; did you mean 'present_section'? [-Werror=implicit-function-declaration]

Use macro definition instead of inline function for mk_pmd to fix the above problems.It is similar to the mk_pte macro.

---
 arch/riscv/include/asm/pgtable.h | 5 +----

 1 file changed, 1 insertion(+), 4 deletions(-)
arch/riscv/include/asm/pgtable.h +1 -4
index 4b708ae08910..f35d9c90d4cb 100644
@@ -508,10 +508,7 @@ static inline unsigned long pmd_pfn(pmd_t pmd)
      return ((__pmd_to_phys(pmd) & PMD_MASK) >> PAGE_SHIFT);
  }
 
-static inline pmd_t mk_pmd(struct page *page, pgprot_t prot)
-{
-    return pfn_pmd(page_to_pfn(page), prot);
-}
+#define mk_pmd(page, prot)    pfn_pmd(page_to_pfn(page), prot)
 
Quoted 7 lines
Quoted 4 lines

arch/riscv/include/asm/pgtable.h static inline unsigned long pmd_pfn(pmd_t pmd) · line 514

Quoted 2 lines
arch/riscv/include/asm/pgtable.h +0 -0
  static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
  {

Thanks, this is on for-next.

Sorry, I wasn't looking closely enough.  I think the actual problem here is that mk_pmd() should be in pgtable-64.h. .

Moving mk_pmd() to pgtable-64.h can only solve the first problem, but not the second.

The second one need mk_pmd() defined as a macro, like this previous solution:

https://patchwork.kernel.org/project/linux-riscv/patch/[email protected]/

Or do i need to move the '#define mk_pmd(page, prot) ...' to pgtable-64.h ?