mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] loongarch/pgtable.h: move {dmw,tlb}_virt_to_page() to page.h
@ 2024-03-08  7:46 Max Kellermann
  2024-03-10  1:14 ` Huacai Chen
  0 siblings, 1 reply; 4+ messages in thread
From: Max Kellermann @ 2024-03-08  7:46 UTC (permalink / raw)
  To: chenhuacai, kernel, lienze, yangtiezhu, tglx, arnd, loongarch,
	linux-kernel
  Cc: Max Kellermann

These functions are implemented in pgtable.c, and they are needed only
by the virt_to_pfn() macro in page.h.  Having the prototypes in
pgtable.h causes a circular dependency between page.h and pgtable.h,
because page.h's virt_to_pfn() needs pgtable.h for these two
functions, and pgtable.h needs various definitions from page.h
(e.g. pte_t and pgt_t).

I suggest avoiding this circular dependency by moving the function
prototypes to page.h, even though that is slightly incorrect, because
they are not implemented in page.c but pgtable.c, but it's the
simplest possible solution to this problem and the functions not used
anywhere else.

Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
 arch/loongarch/include/asm/page.h    | 3 +++
 arch/loongarch/include/asm/pgtable.h | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/loongarch/include/asm/page.h b/arch/loongarch/include/asm/page.h
index afb6fa16b826..44027060c54a 100644
--- a/arch/loongarch/include/asm/page.h
+++ b/arch/loongarch/include/asm/page.h
@@ -75,6 +75,9 @@ typedef struct { unsigned long pgprot; } pgprot_t;
 #define pfn_to_kaddr(pfn)	__va((pfn) << PAGE_SHIFT)
 #define sym_to_pfn(x)		__phys_to_pfn(__pa_symbol(x))
 
+struct page *dmw_virt_to_page(unsigned long kaddr);
+struct page *tlb_virt_to_page(unsigned long kaddr);
+
 #define virt_to_pfn(kaddr)	PFN_DOWN(PHYSADDR(kaddr))
 
 #define virt_to_page(kaddr)								\
diff --git a/arch/loongarch/include/asm/pgtable.h b/arch/loongarch/include/asm/pgtable.h
index 8b5df1bbf9e9..af3acdf3481a 100644
--- a/arch/loongarch/include/asm/pgtable.h
+++ b/arch/loongarch/include/asm/pgtable.h
@@ -363,9 +363,6 @@ static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *pt
 extern pgd_t swapper_pg_dir[];
 extern pgd_t invalid_pg_dir[];
 
-struct page *dmw_virt_to_page(unsigned long kaddr);
-struct page *tlb_virt_to_page(unsigned long kaddr);
-
 /*
  * The following only work if pte_present() is true.
  * Undefined behaviour if not..
-- 
2.39.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-03-10 14:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-08  7:46 [PATCH] loongarch/pgtable.h: move {dmw,tlb}_virt_to_page() to page.h Max Kellermann
2024-03-10  1:14 ` Huacai Chen
2024-03-10 10:22   ` Max Kellermann
2024-03-10 14:03     ` Huacai Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®