[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAhV-H6O02es7ZsDRjWfO=9hz8owa1SWZXkyZ=p3BO28D+ix6A@mail.gmail.com>
Date: Sun, 10 Mar 2024 09:14:24 +0800
From: Huacai Chen <chenhuacai@...nel.org>
To: Max Kellermann <max.kellermann@...os.com>
Cc: kernel@...0n.name, lienze@...inos.cn, yangtiezhu@...ngson.cn,
tglx@...utronix.de, arnd@...db.de, loongarch@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] loongarch/pgtable.h: move {dmw,tlb}_virt_to_page() to page.h
Hi, Max,
Could you please share what kind of configuration will cause a build error?
Huacai
On Fri, Mar 8, 2024 at 3:46 PM Max Kellermann <max.kellermann@...oscom> wrote:
>
> 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@...os.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
>
>
Powered by blists - more mailing lists