loongarch.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] LoongArch: Use TLB for ioremap()
@ 2022-08-23  3:03 Huacai Chen
  2022-08-23  7:41 ` kernel test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Huacai Chen @ 2022-08-23  3:03 UTC (permalink / raw)
  To: Arnd Bergmann, Huacai Chen
  Cc: loongarch, linux-arch, Xuefeng Li, Guo Ren, Xuerui Wang,
	Jiaxun Yang, linux-kernel, Huacai Chen

We can support more cache attributes (e.g., CC, SUC and WUC) and page
protection when we use TLB for ioremap(). The implementation is based
on GENERIC_IOREMAP.

The existing simple ioremap() implementation has better performance so
we keep it and introduce ARCH_IOREMAP to control the selection.

We move pagetable_init() earlier to make early ioremap() works, and we
modify the PCI ecam mapping because the TLB-based version of ioremap()
will actually take the size into account.

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
V2: Based on GENERIC_IOREMAP.

 arch/loongarch/Kconfig                    |  7 +++
 arch/loongarch/include/asm/fixmap.h       | 15 +++++
 arch/loongarch/include/asm/io.h           | 69 ++++++--------------
 arch/loongarch/include/asm/pgtable-bits.h |  3 +
 arch/loongarch/kernel/setup.c             |  2 +-
 arch/loongarch/mm/init.c                  | 64 +++++++++++++++++++
 arch/loongarch/pci/acpi.c                 | 76 +++++++++++++++++++++--
 7 files changed, 180 insertions(+), 56 deletions(-)

diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig
index 3594f0ba7581..5b89386d6972 100644
--- a/arch/loongarch/Kconfig
+++ b/arch/loongarch/Kconfig
@@ -61,6 +61,7 @@ config LOONGARCH
 	select GENERIC_CPU_AUTOPROBE
 	select GENERIC_ENTRY
 	select GENERIC_GETTIMEOFDAY
+	select GENERIC_IOREMAP if !ARCH_IOREMAP
 	select GENERIC_IRQ_MULTI_HANDLER
 	select GENERIC_IRQ_PROBE
 	select GENERIC_IRQ_SHOW
@@ -168,6 +169,9 @@ config MACH_LOONGSON32
 config MACH_LOONGSON64
 	def_bool 64BIT
 
+config FIX_EARLYCON_MEM
+	def_bool y
+
 config PAGE_SIZE_4KB
 	bool
 
@@ -421,6 +425,9 @@ config SECCOMP
 
 endmenu
 
+config ARCH_IOREMAP
+	bool
+
 config ARCH_SELECT_MEMORY_MODEL
 	def_bool y
 
diff --git a/arch/loongarch/include/asm/fixmap.h b/arch/loongarch/include/asm/fixmap.h
index b3541dfa2013..d2e55ae55bb9 100644
--- a/arch/loongarch/include/asm/fixmap.h
+++ b/arch/loongarch/include/asm/fixmap.h
@@ -10,4 +10,19 @@
 
 #define NR_FIX_BTMAPS 64
 
+enum fixed_addresses {
+	FIX_HOLE,
+	FIX_EARLYCON_MEM_BASE,
+	__end_of_fixed_addresses
+};
+
+#define FIXADDR_SIZE	(__end_of_fixed_addresses << PAGE_SHIFT)
+#define FIXADDR_START	(FIXADDR_TOP - FIXADDR_SIZE)
+#define FIXMAP_PAGE_IO	PAGE_KERNEL_SUC
+
+extern void __set_fixmap(enum fixed_addresses idx,
+			 phys_addr_t phys, pgprot_t flags);
+
+#include <asm-generic/fixmap.h>
+
 #endif
diff --git a/arch/loongarch/include/asm/io.h b/arch/loongarch/include/asm/io.h
index 999944ea1cea..87a88eb792c1 100644
--- a/arch/loongarch/include/asm/io.h
+++ b/arch/loongarch/include/asm/io.h
@@ -27,71 +27,38 @@ extern void __init early_iounmap(void __iomem *addr, unsigned long size);
 #define early_memremap early_ioremap
 #define early_memunmap early_iounmap
 
+#ifdef CONFIG_ARCH_IOREMAP
+
 static inline void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size,
 					 unsigned long prot_val)
 {
-	if (prot_val == _CACHE_CC)
+	if (prot_val & _CACHE_CC)
 		return (void __iomem *)(unsigned long)(CACHE_BASE + offset);
 	else
 		return (void __iomem *)(unsigned long)(UNCACHE_BASE + offset);
 }
 
-/*
- * ioremap -   map bus memory into CPU space
- * @offset:    bus address of the memory
- * @size:      size of the resource to map
- *
- * ioremap performs a platform specific sequence of operations to
- * make bus memory CPU accessible via the readb/readw/readl/writeb/
- * writew/writel functions and the other mmio helpers. The returned
- * address is not guaranteed to be usable directly as a virtual
- * address.
- */
-#define ioremap(offset, size)					\
-	ioremap_prot((offset), (size), _CACHE_SUC)
+#define ioremap(offset, size)		\
+	ioremap_prot((offset), (size), pgprot_val(PAGE_KERNEL_SUC))
 
-/*
- * ioremap_wc - map bus memory into CPU space
- * @offset:     bus address of the memory
- * @size:       size of the resource to map
- *
- * ioremap_wc performs a platform specific sequence of operations to
- * make bus memory CPU accessible via the readb/readw/readl/writeb/
- * writew/writel functions and the other mmio helpers. The returned
- * address is not guaranteed to be usable directly as a virtual
- * address.
- *
- * This version of ioremap ensures that the memory is marked uncachable
- * but accelerated by means of write-combining feature. It is specifically
- * useful for PCIe prefetchable windows, which may vastly improve a
- * communications performance. If it was determined on boot stage, what
- * CPU CCA doesn't support WUC, the method shall fall-back to the
- * _CACHE_SUC option (see cpu_probe() method).
- */
-#define ioremap_wc(offset, size)				\
-	ioremap_prot((offset), (size), _CACHE_WUC)
+#define iounmap(addr) 			do { } while (0)
+
+#endif
 
 /*
- * ioremap_cache -  map bus memory into CPU space
- * @offset:	    bus address of the memory
- * @size:	    size of the resource to map
- *
- * ioremap_cache performs a platform specific sequence of operations to
- * make bus memory CPU accessible via the readb/readw/readl/writeb/
- * writew/writel functions and the other mmio helpers. The returned
- * address is not guaranteed to be usable directly as a virtual
- * address.
+ * On LoongArch, ioremap() has two variants, ioremap_wc() and ioremap_cache().
+ * They map bus memory into CPU space, the mapped memory is marked uncachable
+ * (_CACHE_SUC), uncachable but accelerated by write-combine (_CACHE_WUC) and
+ * cachable (_CACHE_CC) respectively for CPU access.
  *
- * This version of ioremap ensures that the memory is marked cachable by
- * the CPU.  Also enables full write-combining.	 Useful for some
- * memory-like regions on I/O busses.
+ * @offset:    bus address of the memory
+ * @size:      size of the resource to map
  */
-#define ioremap_cache(offset, size)				\
-	ioremap_prot((offset), (size), _CACHE_CC)
+#define ioremap_wc(offset, size)	\
+	ioremap_prot((offset), (size), pgprot_val(PAGE_KERNEL_WUC))
 
-static inline void iounmap(const volatile void __iomem *addr)
-{
-}
+#define ioremap_cache(offset, size)	\
+	ioremap_prot((offset), (size), pgprot_val(PAGE_KERNEL))
 
 #define mmiowb() asm volatile ("dbar 0" ::: "memory")
 
diff --git a/arch/loongarch/include/asm/pgtable-bits.h b/arch/loongarch/include/asm/pgtable-bits.h
index 9ca147a29bab..3d1e0a69975a 100644
--- a/arch/loongarch/include/asm/pgtable-bits.h
+++ b/arch/loongarch/include/asm/pgtable-bits.h
@@ -83,8 +83,11 @@
 				 _PAGE_GLOBAL | _PAGE_KERN |  _CACHE_SUC)
 #define PAGE_KERNEL_WUC __pgprot(_PAGE_PRESENT | __READABLE | __WRITEABLE | \
 				 _PAGE_GLOBAL | _PAGE_KERN |  _CACHE_WUC)
+
 #ifndef __ASSEMBLY__
 
+#define _PAGE_IOREMAP		pgprot_val(PAGE_KERNEL_SUC)
+
 #define pgprot_noncached pgprot_noncached
 
 static inline pgprot_t pgprot_noncached(pgprot_t _prot)
diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c
index 2b4e98170bc1..f938aae3e92c 100644
--- a/arch/loongarch/kernel/setup.c
+++ b/arch/loongarch/kernel/setup.c
@@ -349,10 +349,10 @@ void __init setup_arch(char **cmdline_p)
 
 	init_environ();
 	memblock_init();
+	pagetable_init();
 	parse_early_param();
 
 	platform_init();
-	pagetable_init();
 	arch_mem_init(cmdline_p);
 
 	resource_init();
diff --git a/arch/loongarch/mm/init.c b/arch/loongarch/mm/init.c
index 88c935344034..63e19b7a6644 100644
--- a/arch/loongarch/mm/init.c
+++ b/arch/loongarch/mm/init.c
@@ -201,6 +201,70 @@ void vmemmap_free(unsigned long start, unsigned long end,
 #endif
 #endif
 
+static pte_t *fixmap_pte(unsigned long addr)
+{
+	pgd_t *pgd;
+	p4d_t *p4d;
+	pud_t *pud;
+	pmd_t *pmd;
+
+	pgd = pgd_offset_k(addr);
+	p4d = p4d_offset(pgd, addr);
+
+	if (pgd_none(*pgd)) {
+		pud_t *new;
+
+		new = memblock_alloc_low(PAGE_SIZE, PAGE_SIZE);
+		pgd_populate(&init_mm, pgd, new);
+#ifndef __PAGETABLE_PUD_FOLDED
+		pud_init(new);
+#endif
+	}
+
+	pud = pud_offset(p4d, addr);
+	if (pud_none(*pud)) {
+		pmd_t *new;
+
+		new = memblock_alloc_low(PAGE_SIZE, PAGE_SIZE);
+		pud_populate(&init_mm, pud, new);
+#ifndef __PAGETABLE_PMD_FOLDED
+		pmd_init(new);
+#endif
+	}
+
+	pmd = pmd_offset(pud, addr);
+	if (pmd_none(*pmd)) {
+		pte_t *new;
+
+		new = memblock_alloc_low(PAGE_SIZE, PAGE_SIZE);
+		pmd_populate_kernel(&init_mm, pmd, new);
+	}
+
+	return pte_offset_kernel(pmd, addr);
+}
+
+void __init __set_fixmap(enum fixed_addresses idx,
+			       phys_addr_t phys, pgprot_t flags)
+{
+	unsigned long addr = __fix_to_virt(idx);
+	pte_t *ptep;
+
+	BUG_ON(idx <= FIX_HOLE || idx >= __end_of_fixed_addresses);
+
+	ptep = fixmap_pte(addr);
+	if (!pte_none(*ptep)) {
+		pte_ERROR(*ptep);
+		return;
+	}
+
+	if (pgprot_val(flags))
+		set_pte(ptep, pfn_pte(phys >> PAGE_SHIFT, flags));
+	else {
+		pte_clear(&init_mm, addr, ptep);
+		flush_tlb_kernel_range(addr, addr + PAGE_SIZE);
+	}
+}
+
 /*
  * Align swapper_pg_dir in to 64K, allows its address to be loaded
  * with a single LUI instruction in the TLB handlers.  If we used
diff --git a/arch/loongarch/pci/acpi.c b/arch/loongarch/pci/acpi.c
index bf921487333c..ac18ca7a900a 100644
--- a/arch/loongarch/pci/acpi.c
+++ b/arch/loongarch/pci/acpi.c
@@ -82,6 +82,69 @@ static int acpi_prepare_root_resources(struct acpi_pci_root_info *ci)
 	return 0;
 }
 
+/*
+ * Create a PCI config space window
+ *  - reserve mem region
+ *  - alloc struct pci_config_window with space for all mappings
+ *  - ioremap the config space
+ */
+struct pci_config_window *arch_pci_ecam_create(struct device *dev,
+		struct resource *cfgres, struct resource *busr, const struct pci_ecam_ops *ops)
+{
+	int bsz, bus_range, err;
+	struct resource *conflict;
+	struct pci_config_window *cfg;
+
+	if (busr->start > busr->end)
+		return ERR_PTR(-EINVAL);
+
+	cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
+	if (!cfg)
+		return ERR_PTR(-ENOMEM);
+
+	cfg->parent = dev;
+	cfg->ops = ops;
+	cfg->busr.start = busr->start;
+	cfg->busr.end = busr->end;
+	cfg->busr.flags = IORESOURCE_BUS;
+	bus_range = resource_size(cfgres) >> ops->bus_shift;
+
+	bsz = 1 << ops->bus_shift;
+
+	cfg->res.start = cfgres->start;
+	cfg->res.end = cfgres->end;
+	cfg->res.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+	cfg->res.name = "PCI ECAM";
+
+	conflict = request_resource_conflict(&iomem_resource, &cfg->res);
+	if (conflict) {
+		err = -EBUSY;
+		dev_err(dev, "can't claim ECAM area %pR: address conflict with %s %pR\n",
+			&cfg->res, conflict->name, conflict);
+		goto err_exit;
+	}
+
+	cfg->win = pci_remap_cfgspace(cfgres->start, bus_range * bsz);
+	if (!cfg->win)
+		goto err_exit_iomap;
+
+	if (ops->init) {
+		err = ops->init(cfg);
+		if (err)
+			goto err_exit;
+	}
+	dev_info(dev, "ECAM at %pR for %pR\n", &cfg->res, &cfg->busr);
+
+	return cfg;
+
+err_exit_iomap:
+	err = -ENOMEM;
+	dev_err(dev, "ECAM ioremap failed\n");
+err_exit:
+	pci_ecam_free(cfg);
+	return ERR_PTR(err);
+}
+
 /*
  * Lookup the bus range for the domain in MCFG, and set up config space
  * mapping.
@@ -106,11 +169,16 @@ pci_acpi_setup_ecam_mapping(struct acpi_pci_root *root)
 
 	bus_shift = ecam_ops->bus_shift ? : 20;
 
-	cfgres.start = root->mcfg_addr + (bus_res->start << bus_shift);
-	cfgres.end = cfgres.start + (resource_size(bus_res) << bus_shift) - 1;
-	cfgres.flags = IORESOURCE_MEM;
+	if (bus_shift == 20)
+		cfg = pci_ecam_create(dev, &cfgres, bus_res, ecam_ops);
+	else {
+		cfgres.start = root->mcfg_addr + (bus_res->start << bus_shift);
+		cfgres.end = cfgres.start + (resource_size(bus_res) << bus_shift) - 1;
+		cfgres.end |= BIT(28) + (((PCI_CFG_SPACE_EXP_SIZE - 1) & 0xf00) << 16);
+		cfgres.flags = IORESOURCE_MEM;
+		cfg = arch_pci_ecam_create(dev, &cfgres, bus_res, ecam_ops);
+	}
 
-	cfg = pci_ecam_create(dev, &cfgres, bus_res, ecam_ops);
 	if (IS_ERR(cfg)) {
 		dev_err(dev, "%04x:%pR error %ld mapping ECAM\n", seg, bus_res, PTR_ERR(cfg));
 		return NULL;
-- 
2.31.1


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

* Re: [PATCH V2] LoongArch: Use TLB for ioremap()
  2022-08-23  3:03 [PATCH V2] LoongArch: Use TLB for ioremap() Huacai Chen
@ 2022-08-23  7:41 ` kernel test robot
  2022-08-24  0:13 ` kernel test robot
  2022-08-24  3:07 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2022-08-23  7:41 UTC (permalink / raw)
  To: Huacai Chen, Arnd Bergmann, Huacai Chen
  Cc: kbuild-all, loongarch, linux-arch, Xuefeng Li, Guo Ren,
	Xuerui Wang, Jiaxun Yang, linux-kernel

Hi Huacai,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v6.0-rc2 next-20220822]
[cannot apply to soc/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Huacai-Chen/LoongArch-Use-TLB-for-ioremap/20220823-110829
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 072e51356cd5a4a1c12c1020bc054c99b98333df
config: loongarch-allyesconfig (https://download.01.org/0day-ci/archive/20220823/202208231528.Lgm9hRwt-lkp@intel.com/config)
compiler: loongarch64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/80f55a8feb23743d963d113c803bf54b1287244d
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Huacai-Chen/LoongArch-Use-TLB-for-ioremap/20220823-110829
        git checkout 80f55a8feb23743d963d113c803bf54b1287244d
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=loongarch SHELL=/bin/bash arch/loongarch/ drivers/net/ fs// kernel/ lib// mm//

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from include/linux/pgtable.h:14,
                    from include/asm-generic/io.h:1048,
                    from arch/loongarch/include/asm/io.h:94,
                    from arch/loongarch/include/asm/pgtable.h:62,
                    from arch/loongarch/include/asm/uaccess.h:17,
                    from include/linux/uaccess.h:11,
                    from include/linux/sched/task.h:11,
                    from include/linux/sched/signal.h:9,
                    from include/linux/ptrace.h:7,
                    from arch/loongarch/kernel/cpu-probe.c:9:
   include/asm-generic/pgtable_uffd.h:10:40: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
      10 | static __always_inline int pmd_uffd_wp(pmd_t pmd)
         |                                        ^~~~~
         |                                        pud_t
   include/asm-generic/pgtable_uffd.h:20:24: error: unknown type name 'pmd_t'
      20 | static __always_inline pmd_t pmd_mkuffd_wp(pmd_t pmd)
         |                        ^~~~~
   include/asm-generic/pgtable_uffd.h:20:44: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
      20 | static __always_inline pmd_t pmd_mkuffd_wp(pmd_t pmd)
         |                                            ^~~~~
         |                                            pud_t
   include/asm-generic/pgtable_uffd.h:30:24: error: unknown type name 'pmd_t'
      30 | static __always_inline pmd_t pmd_clear_uffd_wp(pmd_t pmd)
         |                        ^~~~~
   include/asm-generic/pgtable_uffd.h:30:48: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
      30 | static __always_inline pmd_t pmd_clear_uffd_wp(pmd_t pmd)
         |                                                ^~~~~
         |                                                pud_t
   include/asm-generic/pgtable_uffd.h:50:15: error: unknown type name 'pmd_t'
      50 | static inline pmd_t pmd_swp_mkuffd_wp(pmd_t pmd)
         |               ^~~~~
   include/asm-generic/pgtable_uffd.h:50:39: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
      50 | static inline pmd_t pmd_swp_mkuffd_wp(pmd_t pmd)
         |                                       ^~~~~
         |                                       pud_t
   include/asm-generic/pgtable_uffd.h:55:35: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
      55 | static inline int pmd_swp_uffd_wp(pmd_t pmd)
         |                                   ^~~~~
         |                                   pud_t
   include/asm-generic/pgtable_uffd.h:60:15: error: unknown type name 'pmd_t'
      60 | static inline pmd_t pmd_swp_clear_uffd_wp(pmd_t pmd)
         |               ^~~~~
   include/asm-generic/pgtable_uffd.h:60:43: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
      60 | static inline pmd_t pmd_swp_clear_uffd_wp(pmd_t pmd)
         |                                           ^~~~~
         |                                           pud_t
   In file included from include/linux/pgtable.h:15:
   include/linux/page_table_check.h:132:67: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
     132 |                                               unsigned long addr, pmd_t pmd)
         |                                                                   ^~~~~
         |                                                                   pud_t
   include/linux/page_table_check.h:148:65: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
     148 |                                             unsigned long addr, pmd_t *pmdp,
         |                                                                 ^~~~~
         |                                                                 pud_t
   include/linux/page_table_check.h:149:45: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
     149 |                                             pmd_t pmd)
         |                                             ^~~~~
         |                                             pud_t
   include/linux/page_table_check.h:161:53: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
     161 |                                                     pmd_t pmd)
         |                                                     ^~~~~
         |                                                     pud_t
   include/linux/pgtable.h:90:40: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
      90 | static inline pte_t *pte_offset_kernel(pmd_t *pmd, unsigned long address)
         |                                        ^~~~~
         |                                        pud_t
   include/linux/pgtable.h:109:15: error: unknown type name 'pmd_t'
     109 | static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
         |               ^~~~~
   include/linux/pgtable.h: In function 'pmd_offset':
   include/linux/pgtable.h:111:16: error: implicit declaration of function 'pud_pgtable'; did you mean 'pmd_pgtable'? [-Werror=implicit-function-declaration]
     111 |         return pud_pgtable(*pud) + pmd_index(address);
         |                ^~~~~~~~~~~
         |                pmd_pgtable
>> include/linux/pgtable.h:111:34: warning: returning 'long unsigned int' from a function with return type 'int *' makes pointer from integer without a cast [-Wint-conversion]
     111 |         return pud_pgtable(*pud) + pmd_index(address);
         |                ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
   include/linux/pgtable.h: At top level:
   include/linux/pgtable.h:151:15: error: unknown type name 'pmd_t'
     151 | static inline pmd_t *pmd_off(struct mm_struct *mm, unsigned long va)
         |               ^~~~~
   include/linux/pgtable.h:156:15: error: unknown type name 'pmd_t'
     156 | static inline pmd_t *pmd_off_k(unsigned long va)
         |               ^~~~~
   include/linux/pgtable.h: In function 'virt_to_kpte':
   include/linux/pgtable.h:163:9: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
     163 |         pmd_t *pmd = pmd_off_k(vaddr);
         |         ^~~~~
         |         pud_t
   include/linux/pgtable.h:165:16: error: implicit declaration of function 'pmd_none'; did you mean 'p4d_none'? [-Werror=implicit-function-declaration]
     165 |         return pmd_none(*pmd) ? NULL : pte_offset_kernel(pmd, vaddr);
         |                ^~~~~~~~
         |                p4d_none
   include/linux/pgtable.h:94:27: error: implicit declaration of function 'pte_offset_kernel' [-Werror=implicit-function-declaration]
      94 | #define pte_offset_kernel pte_offset_kernel
         |                           ^~~~~~~~~~~~~~~~~
   include/linux/pgtable.h:165:40: note: in expansion of macro 'pte_offset_kernel'
     165 |         return pmd_none(*pmd) ? NULL : pte_offset_kernel(pmd, vaddr);
         |                                        ^~~~~~~~~~~~~~~~~
>> include/linux/pgtable.h:165:38: warning: pointer/integer type mismatch in conditional expression
     165 |         return pmd_none(*pmd) ? NULL : pte_offset_kernel(pmd, vaddr);
         |                                      ^
   include/linux/pgtable.h: At top level:
   include/linux/pgtable.h:177:57: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
     177 |                                  unsigned long address, pmd_t *pmdp,
         |                                                         ^~~~~
         |                                                         pud_t
   include/linux/pgtable.h:178:34: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
     178 |                                  pmd_t entry, int dirty);
         |                                  ^~~~~
         |                                  pud_t
   include/linux/pgtable.h: In function 'ptep_test_and_clear_young':
   include/linux/pgtable.h:207:14: error: implicit declaration of function 'pte_young' [-Werror=implicit-function-declaration]
     207 |         if (!pte_young(pte))
         |              ^~~~~~~~~
   include/linux/pgtable.h:210:17: error: implicit declaration of function 'set_pte_at' [-Werror=implicit-function-declaration]
     210 |                 set_pte_at(vma->vm_mm, address, ptep, pte_mkold(pte));
         |                 ^~~~~~~~~~
   include/linux/pgtable.h:210:55: error: implicit declaration of function 'pte_mkold' [-Werror=implicit-function-declaration]
     210 |                 set_pte_at(vma->vm_mm, address, ptep, pte_mkold(pte));
         |                                                       ^~~~~~~~~
   include/linux/pgtable.h: At top level:
   include/linux/pgtable.h:219:45: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
     219 |                                             pmd_t *pmdp)
         |                                             ^~~~~
         |                                             pud_t
   include/linux/pgtable.h:248:58: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
     248 |                                   unsigned long address, pmd_t *pmdp);
         |                                                          ^~~~~
         |                                                          pud_t
   include/linux/pgtable.h: In function 'ptep_get_and_clear':
   include/linux/pgtable.h:269:9: error: implicit declaration of function 'pte_clear'; did you mean 'p4d_clear'? [-Werror=implicit-function-declaration]
     269 |         pte_clear(mm, address, ptep);
         |         ^~~~~~~~~
         |         p4d_clear
   include/linux/pgtable.h: At top level:
   include/linux/pgtable.h:345:15: error: unknown type name 'pmd_t'
     345 | static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
         |               ^~~~~
   include/linux/pgtable.h:347:45: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
     347 |                                             pmd_t *pmdp)
         |                                             ^~~~~
         |                                             pud_t
   include/linux/pgtable.h: In function 'pudp_huge_get_and_clear':
   include/linux/pgtable.h:364:9: error: implicit declaration of function 'pud_clear'; did you mean 'p4d_clear'? [-Werror=implicit-function-declaration]
     364 |         pud_clear(pudp);
         |         ^~~~~~~~~
         |         p4d_clear
   include/linux/pgtable.h: At top level:
   include/linux/pgtable.h:374:15: error: unknown type name 'pmd_t'
     374 | static inline pmd_t pmdp_huge_get_and_clear_full(struct vm_area_struct *vma,
         |               ^~~~~
   include/linux/pgtable.h:375:68: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
     375 |                                             unsigned long address, pmd_t *pmdp,
         |                                                                    ^~~~~
         |                                                                    pud_t
   include/linux/pgtable.h:442:8: error: unknown type name 'pmd_t'
     442 | extern pmd_t pmdp_huge_clear_flush(struct vm_area_struct *vma,
         |        ^~~~~
   include/linux/pgtable.h:444:31: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
     444 |                               pmd_t *pmdp);
         |                               ^~~~~
         |                               pud_t
   include/linux/pgtable.h: In function 'ptep_set_wrprotect':
   include/linux/pgtable.h:455:39: error: implicit declaration of function 'pte_wrprotect'; did you mean 'ptep_set_wrprotect'? [-Werror=implicit-function-declaration]
     455 |         set_pte_at(mm, address, ptep, pte_wrprotect(old_pte));
         |                                       ^~~~~~~~~~~~~
         |                                       ptep_set_wrprotect
   include/linux/pgtable.h: At top level:
   include/linux/pgtable.h:502:62: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
     502 |                                       unsigned long address, pmd_t *pmdp)
         |                                                              ^~~~~
         |                                                              pud_t
   include/linux/pgtable.h:535:8: error: unknown type name 'pmd_t'
     535 | extern pmd_t pmdp_collapse_flush(struct vm_area_struct *vma,
         |        ^~~~~
   include/linux/pgtable.h:536:57: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
     536 |                                  unsigned long address, pmd_t *pmdp);
         |                                                         ^~~~~
         |                                                         pud_t
   include/linux/pgtable.h:550:62: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
     550 | extern void pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp,
         |                                                              ^~~~~
         |                                                              pud_t
   include/linux/pgtable.h:555:68: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
     555 | extern pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp);
         |                                                                    ^~~~~
         |                                                                    pud_t
   include/linux/pgtable.h:564:15: error: unknown type name 'pmd_t'
     564 | static inline pmd_t generic_pmdp_establish(struct vm_area_struct *vma,
         |               ^~~~~
   include/linux/pgtable.h:565:40: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
     565 |                 unsigned long address, pmd_t *pmdp, pmd_t pmd)
         |                                        ^~~~~
         |                                        pud_t
   include/linux/pgtable.h:565:53: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
     565 |                 unsigned long address, pmd_t *pmdp, pmd_t pmd)
         |                                                     ^~~~~
         |                                                     pud_t
   include/linux/pgtable.h:574:8: error: unknown type name 'pmd_t'
--
         |             p4d_none
   In file included from include/linux/init.h:5,
                    from arch/loongarch/kernel/cpu-probe.c:7:
   include/linux/pgtable.h:866:22: error: implicit declaration of function 'pud_bad'; did you mean 'p4d_bad'? [-Werror=implicit-function-declaration]
     866 |         if (unlikely(pud_bad(*pud))) {
         |                      ^~~~~~~
   include/linux/compiler.h:78:45: note: in definition of macro 'unlikely'
      78 | # define unlikely(x)    __builtin_expect(!!(x), 0)
         |                                             ^
   include/linux/pgtable.h: At top level:
   include/linux/pgtable.h:873:41: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
     873 | static inline int pmd_none_or_clear_bad(pmd_t *pmd)
         |                                         ^~~~~
         |                                         pud_t
   include/linux/pgtable.h:1083:34: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
    1083 | static inline int pmd_soft_dirty(pmd_t pmd)
         |                                  ^~~~~
         |                                  pud_t
   include/linux/pgtable.h:1093:15: error: unknown type name 'pmd_t'
    1093 | static inline pmd_t pmd_mksoft_dirty(pmd_t pmd)
         |               ^~~~~
   include/linux/pgtable.h:1093:38: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
    1093 | static inline pmd_t pmd_mksoft_dirty(pmd_t pmd)
         |                                      ^~~~~
         |                                      pud_t
   include/linux/pgtable.h:1103:15: error: unknown type name 'pmd_t'
    1103 | static inline pmd_t pmd_clear_soft_dirty(pmd_t pmd)
         |               ^~~~~
   include/linux/pgtable.h:1103:42: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
    1103 | static inline pmd_t pmd_clear_soft_dirty(pmd_t pmd)
         |                                          ^~~~~
         |                                          pud_t
   include/linux/pgtable.h:1123:15: error: unknown type name 'pmd_t'
    1123 | static inline pmd_t pmd_swp_mksoft_dirty(pmd_t pmd)
         |               ^~~~~
   include/linux/pgtable.h:1123:42: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
    1123 | static inline pmd_t pmd_swp_mksoft_dirty(pmd_t pmd)
         |                                          ^~~~~
         |                                          pud_t
   include/linux/pgtable.h:1128:38: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
    1128 | static inline int pmd_swp_soft_dirty(pmd_t pmd)
         |                                      ^~~~~
         |                                      pud_t
   include/linux/pgtable.h:1133:15: error: unknown type name 'pmd_t'
    1133 | static inline pmd_t pmd_swp_clear_soft_dirty(pmd_t pmd)
         |               ^~~~~
   include/linux/pgtable.h:1133:46: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
    1133 | static inline pmd_t pmd_swp_clear_soft_dirty(pmd_t pmd)
         |                                              ^~~~~
         |                                              pud_t
   include/linux/pgtable.h:1264:30: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
    1264 | static inline int pmd_devmap(pmd_t pmd)
         |                              ^~~~~
         |                              pud_t
   include/linux/pgtable.h:1313:15: error: unknown type name 'pmd_t'
    1313 | static inline pmd_t pmd_read_atomic(pmd_t *pmdp)
         |               ^~~~~
   include/linux/pgtable.h:1313:37: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
    1313 | static inline pmd_t pmd_read_atomic(pmd_t *pmdp)
         |                                     ^~~~~
         |                                     pud_t
   include/linux/pgtable.h:1348:55: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
    1348 | static inline int pmd_none_or_trans_huge_or_clear_bad(pmd_t *pmd)
         |                                                       ^~~~~
         |                                                       pud_t
   include/linux/pgtable.h:1405:38: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
    1405 | static inline int pmd_trans_unstable(pmd_t *pmd)
         |                                      ^~~~~
         |                                      pud_t
   include/linux/pgtable.h:1420:45: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
    1420 | static inline int pmd_devmap_trans_unstable(pmd_t *pmd)
         |                                             ^~~~~
         |                                             pud_t
   include/linux/pgtable.h:1476:32: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
    1476 | static inline int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot)
         |                                ^~~~~
         |                                pud_t
   include/linux/pgtable.h:1485:34: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
    1485 | static inline int pmd_clear_huge(pmd_t *pmd)
         |                                  ^~~~~
         |                                  pud_t
   include/linux/pgtable.h:1497:37: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
    1497 | static inline int pmd_free_pte_page(pmd_t *pmd, unsigned long addr)
         |                                     ^~~~~
         |                                     pud_t
   arch/loongarch/include/asm/pgtable.h:164:19: error: static declaration of 'pud_none' follows non-static declaration
     164 | static inline int pud_none(pud_t pud)
         |                   ^~~~~~~~
   include/linux/pgtable.h:864:13: note: previous implicit declaration of 'pud_none' with type 'int()'
     864 |         if (pud_none(*pud))
         |             ^~~~~~~~
   arch/loongarch/include/asm/pgtable.h:169:19: error: static declaration of 'pud_bad' follows non-static declaration
     169 | static inline int pud_bad(pud_t pud)
         |                   ^~~~~~~
   include/linux/pgtable.h:866:22: note: previous implicit declaration of 'pud_bad' with type 'int()'
     866 |         if (unlikely(pud_bad(*pud))) {
         |                      ^~~~~~~
   include/linux/compiler.h:78:45: note: in definition of macro 'unlikely'
      78 | # define unlikely(x)    __builtin_expect(!!(x), 0)
         |                                             ^
>> arch/loongarch/include/asm/pgtable.h:179:20: warning: conflicting types for 'pud_clear'; have 'void(pud_t *)'
     179 | static inline void pud_clear(pud_t *pudp)
         |                    ^~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:179:20: error: static declaration of 'pud_clear' follows non-static declaration
   include/linux/pgtable.h:364:9: note: previous implicit declaration of 'pud_clear' with type 'void(pud_t *)'
     364 |         pud_clear(pudp);
         |         ^~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:184:22: error: conflicting types for 'pud_pgtable'; have 'pmd_t *(pud_t)'
     184 | static inline pmd_t *pud_pgtable(pud_t pud)
         |                      ^~~~~~~~~~~
   include/linux/pgtable.h:111:16: note: previous implicit declaration of 'pud_pgtable' with type 'int()'
     111 |         return pud_pgtable(*pud) + pmd_index(address);
         |                ^~~~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:199:19: error: static declaration of 'pmd_none' follows non-static declaration
     199 | static inline int pmd_none(pmd_t pmd)
         |                   ^~~~~~~~
   include/linux/pgtable.h:165:16: note: previous implicit declaration of 'pmd_none' with type 'int()'
     165 |         return pmd_none(*pmd) ? NULL : pte_offset_kernel(pmd, vaddr);
         |                ^~~~~~~~
>> arch/loongarch/include/asm/pgtable.h:303:20: warning: conflicting types for 'set_pte_at'; have 'void(struct mm_struct *, long unsigned int,  pte_t *, pte_t)'
     303 | static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
         |                    ^~~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:303:20: error: static declaration of 'set_pte_at' follows non-static declaration
   include/linux/pgtable.h:210:17: note: previous implicit declaration of 'set_pte_at' with type 'void(struct mm_struct *, long unsigned int,  pte_t *, pte_t)'
     210 |                 set_pte_at(vma->vm_mm, address, ptep, pte_mkold(pte));
         |                 ^~~~~~~~~~
>> arch/loongarch/include/asm/pgtable.h:309:20: warning: conflicting types for 'pte_clear'; have 'void(struct mm_struct *, long unsigned int,  pte_t *)'
     309 | static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
         |                    ^~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:309:20: error: static declaration of 'pte_clear' follows non-static declaration
   include/linux/pgtable.h:269:9: note: previous implicit declaration of 'pte_clear' with type 'void(struct mm_struct *, long unsigned int,  pte_t *)'
     269 |         pte_clear(mm, address, ptep);
         |         ^~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:330:19: error: static declaration of 'pte_young' follows non-static declaration
     330 | static inline int pte_young(pte_t pte)  { return pte_val(pte) & _PAGE_ACCESSED; }
         |                   ^~~~~~~~~
   include/linux/pgtable.h:207:14: note: previous implicit declaration of 'pte_young' with type 'int()'
     207 |         if (!pte_young(pte))
         |              ^~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:333:21: error: conflicting types for 'pte_mkold'; have 'pte_t(pte_t)'
     333 | static inline pte_t pte_mkold(pte_t pte)
         |                     ^~~~~~~~~
   include/linux/pgtable.h:210:55: note: previous implicit declaration of 'pte_mkold' with type 'int()'
     210 |                 set_pte_at(vma->vm_mm, address, ptep, pte_mkold(pte));
         |                                                       ^~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:363:21: error: conflicting types for 'pte_wrprotect'; have 'pte_t(pte_t)'
     363 | static inline pte_t pte_wrprotect(pte_t pte)
         |                     ^~~~~~~~~~~~~
   include/linux/pgtable.h:455:39: note: previous implicit declaration of 'pte_wrprotect' with type 'int()'
     455 |         set_pte_at(mm, address, ptep, pte_wrprotect(old_pte));
         |                                       ^~~~~~~~~~~~~
>> arch/loongarch/include/asm/pgtable.h:382: warning: "pte_accessible" redefined
     382 | #define pte_accessible pte_accessible
         | 
   include/linux/pgtable.h:780: note: this is the location of the previous definition
     780 | # define pte_accessible(mm, pte)        ((void)(pte), 1)
         | 
   In file included from include/linux/mm.h:703,
                    from include/linux/pid_namespace.h:7,
                    from include/linux/ptrace.h:10:
   include/linux/huge_mm.h: In function 'pmd_trans_huge_lock':
   include/linux/huge_mm.h:236:58: error: implicit declaration of function 'pmd_devmap'; did you mean 'pgd_devmap'? [-Werror=implicit-function-declaration]
     236 |         if (is_swap_pmd(*pmd) || pmd_trans_huge(*pmd) || pmd_devmap(*pmd))
         |                                                          ^~~~~~~~~~
         |                                                          pgd_devmap
   include/linux/mm.h: In function 'pmd_alloc':
   include/linux/mm.h:2205:21: error: returning 'int *' from a function with incompatible return type 'pmd_t *' [-Werror=incompatible-pointer-types]
    2204 |         return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
         |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    2205 |                 NULL: pmd_offset(pud, address);
         |                 ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors
..


vim +179 arch/loongarch/include/asm/pgtable.h

09cfefb7fa70c3 Huacai Chen 2022-05-31  168  
09cfefb7fa70c3 Huacai Chen 2022-05-31 @169  static inline int pud_bad(pud_t pud)
09cfefb7fa70c3 Huacai Chen 2022-05-31  170  {
09cfefb7fa70c3 Huacai Chen 2022-05-31  171  	return pud_val(pud) & ~PAGE_MASK;
09cfefb7fa70c3 Huacai Chen 2022-05-31  172  }
09cfefb7fa70c3 Huacai Chen 2022-05-31  173  
09cfefb7fa70c3 Huacai Chen 2022-05-31  174  static inline int pud_present(pud_t pud)
09cfefb7fa70c3 Huacai Chen 2022-05-31  175  {
09cfefb7fa70c3 Huacai Chen 2022-05-31  176  	return pud_val(pud) != (unsigned long)invalid_pmd_table;
09cfefb7fa70c3 Huacai Chen 2022-05-31  177  }
09cfefb7fa70c3 Huacai Chen 2022-05-31  178  
09cfefb7fa70c3 Huacai Chen 2022-05-31 @179  static inline void pud_clear(pud_t *pudp)
09cfefb7fa70c3 Huacai Chen 2022-05-31  180  {
09cfefb7fa70c3 Huacai Chen 2022-05-31  181  	pud_val(*pudp) = ((unsigned long)invalid_pmd_table);
09cfefb7fa70c3 Huacai Chen 2022-05-31  182  }
09cfefb7fa70c3 Huacai Chen 2022-05-31  183  
09cfefb7fa70c3 Huacai Chen 2022-05-31  184  static inline pmd_t *pud_pgtable(pud_t pud)
09cfefb7fa70c3 Huacai Chen 2022-05-31  185  {
09cfefb7fa70c3 Huacai Chen 2022-05-31  186  	return (pmd_t *)pud_val(pud);
09cfefb7fa70c3 Huacai Chen 2022-05-31  187  }
09cfefb7fa70c3 Huacai Chen 2022-05-31  188  
09cfefb7fa70c3 Huacai Chen 2022-05-31  189  #define set_pud(pudptr, pudval) do { *(pudptr) = (pudval); } while (0)
09cfefb7fa70c3 Huacai Chen 2022-05-31  190  
09cfefb7fa70c3 Huacai Chen 2022-05-31  191  #define pud_phys(pud)		virt_to_phys((void *)pud_val(pud))
09cfefb7fa70c3 Huacai Chen 2022-05-31  192  #define pud_page(pud)		(pfn_to_page(pud_phys(pud) >> PAGE_SHIFT))
09cfefb7fa70c3 Huacai Chen 2022-05-31  193  
09cfefb7fa70c3 Huacai Chen 2022-05-31  194  #endif
09cfefb7fa70c3 Huacai Chen 2022-05-31  195  
09cfefb7fa70c3 Huacai Chen 2022-05-31  196  /*
09cfefb7fa70c3 Huacai Chen 2022-05-31  197   * Empty pmd entries point to the invalid_pte_table.
09cfefb7fa70c3 Huacai Chen 2022-05-31  198   */
09cfefb7fa70c3 Huacai Chen 2022-05-31 @199  static inline int pmd_none(pmd_t pmd)
09cfefb7fa70c3 Huacai Chen 2022-05-31  200  {
09cfefb7fa70c3 Huacai Chen 2022-05-31  201  	return pmd_val(pmd) == (unsigned long)invalid_pte_table;
09cfefb7fa70c3 Huacai Chen 2022-05-31  202  }
09cfefb7fa70c3 Huacai Chen 2022-05-31  203  
09cfefb7fa70c3 Huacai Chen 2022-05-31  204  static inline int pmd_bad(pmd_t pmd)
09cfefb7fa70c3 Huacai Chen 2022-05-31  205  {
09cfefb7fa70c3 Huacai Chen 2022-05-31  206  	return (pmd_val(pmd) & ~PAGE_MASK);
09cfefb7fa70c3 Huacai Chen 2022-05-31  207  }
09cfefb7fa70c3 Huacai Chen 2022-05-31  208  
09cfefb7fa70c3 Huacai Chen 2022-05-31  209  static inline int pmd_present(pmd_t pmd)
09cfefb7fa70c3 Huacai Chen 2022-05-31  210  {
09cfefb7fa70c3 Huacai Chen 2022-05-31  211  	if (unlikely(pmd_val(pmd) & _PAGE_HUGE))
09cfefb7fa70c3 Huacai Chen 2022-05-31  212  		return !!(pmd_val(pmd) & (_PAGE_PRESENT | _PAGE_PROTNONE));
09cfefb7fa70c3 Huacai Chen 2022-05-31  213  
09cfefb7fa70c3 Huacai Chen 2022-05-31  214  	return pmd_val(pmd) != (unsigned long)invalid_pte_table;
09cfefb7fa70c3 Huacai Chen 2022-05-31  215  }
09cfefb7fa70c3 Huacai Chen 2022-05-31  216  
09cfefb7fa70c3 Huacai Chen 2022-05-31  217  static inline void pmd_clear(pmd_t *pmdp)
09cfefb7fa70c3 Huacai Chen 2022-05-31  218  {
09cfefb7fa70c3 Huacai Chen 2022-05-31  219  	pmd_val(*pmdp) = ((unsigned long)invalid_pte_table);
09cfefb7fa70c3 Huacai Chen 2022-05-31  220  }
09cfefb7fa70c3 Huacai Chen 2022-05-31  221  
09cfefb7fa70c3 Huacai Chen 2022-05-31  222  #define set_pmd(pmdptr, pmdval) do { *(pmdptr) = (pmdval); } while (0)
09cfefb7fa70c3 Huacai Chen 2022-05-31  223  
09cfefb7fa70c3 Huacai Chen 2022-05-31  224  #define pmd_phys(pmd)		virt_to_phys((void *)pmd_val(pmd))
09cfefb7fa70c3 Huacai Chen 2022-05-31  225  
09cfefb7fa70c3 Huacai Chen 2022-05-31  226  #ifndef CONFIG_TRANSPARENT_HUGEPAGE
09cfefb7fa70c3 Huacai Chen 2022-05-31  227  #define pmd_page(pmd)		(pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
09cfefb7fa70c3 Huacai Chen 2022-05-31  228  #endif /* CONFIG_TRANSPARENT_HUGEPAGE  */
09cfefb7fa70c3 Huacai Chen 2022-05-31  229  
09cfefb7fa70c3 Huacai Chen 2022-05-31  230  #define pmd_page_vaddr(pmd)	pmd_val(pmd)
09cfefb7fa70c3 Huacai Chen 2022-05-31  231  
09cfefb7fa70c3 Huacai Chen 2022-05-31  232  extern pmd_t mk_pmd(struct page *page, pgprot_t prot);
09cfefb7fa70c3 Huacai Chen 2022-05-31  233  extern void set_pmd_at(struct mm_struct *mm, unsigned long addr, pmd_t *pmdp, pmd_t pmd);
09cfefb7fa70c3 Huacai Chen 2022-05-31  234  
09cfefb7fa70c3 Huacai Chen 2022-05-31  235  #define pte_page(x)		pfn_to_page(pte_pfn(x))
09cfefb7fa70c3 Huacai Chen 2022-05-31  236  #define pte_pfn(x)		((unsigned long)(((x).pte & _PFN_MASK) >> _PFN_SHIFT))
09cfefb7fa70c3 Huacai Chen 2022-05-31  237  #define pfn_pte(pfn, prot)	__pte(((pfn) << _PFN_SHIFT) | pgprot_val(prot))
09cfefb7fa70c3 Huacai Chen 2022-05-31  238  #define pfn_pmd(pfn, prot)	__pmd(((pfn) << _PFN_SHIFT) | pgprot_val(prot))
09cfefb7fa70c3 Huacai Chen 2022-05-31  239  
09cfefb7fa70c3 Huacai Chen 2022-05-31  240  /*
09cfefb7fa70c3 Huacai Chen 2022-05-31  241   * Initialize a new pgd / pmd table with invalid pointers.
09cfefb7fa70c3 Huacai Chen 2022-05-31  242   */
09cfefb7fa70c3 Huacai Chen 2022-05-31  243  extern void pgd_init(unsigned long page);
09cfefb7fa70c3 Huacai Chen 2022-05-31  244  extern void pud_init(unsigned long page, unsigned long pagetable);
09cfefb7fa70c3 Huacai Chen 2022-05-31  245  extern void pmd_init(unsigned long page, unsigned long pagetable);
09cfefb7fa70c3 Huacai Chen 2022-05-31  246  
09cfefb7fa70c3 Huacai Chen 2022-05-31  247  /*
09cfefb7fa70c3 Huacai Chen 2022-05-31  248   * Non-present pages:  high 40 bits are offset, next 8 bits type,
09cfefb7fa70c3 Huacai Chen 2022-05-31  249   * low 16 bits zero.
09cfefb7fa70c3 Huacai Chen 2022-05-31  250   */
09cfefb7fa70c3 Huacai Chen 2022-05-31  251  static inline pte_t mk_swap_pte(unsigned long type, unsigned long offset)
09cfefb7fa70c3 Huacai Chen 2022-05-31  252  { pte_t pte; pte_val(pte) = (type << 16) | (offset << 24); return pte; }
09cfefb7fa70c3 Huacai Chen 2022-05-31  253  
09cfefb7fa70c3 Huacai Chen 2022-05-31  254  #define __swp_type(x)		(((x).val >> 16) & 0xff)
09cfefb7fa70c3 Huacai Chen 2022-05-31  255  #define __swp_offset(x)		((x).val >> 24)
09cfefb7fa70c3 Huacai Chen 2022-05-31  256  #define __swp_entry(type, offset) ((swp_entry_t) { pte_val(mk_swap_pte((type), (offset))) })
09cfefb7fa70c3 Huacai Chen 2022-05-31  257  #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
09cfefb7fa70c3 Huacai Chen 2022-05-31  258  #define __swp_entry_to_pte(x)	((pte_t) { (x).val })
09cfefb7fa70c3 Huacai Chen 2022-05-31  259  #define __pmd_to_swp_entry(pmd) ((swp_entry_t) { pmd_val(pmd) })
09cfefb7fa70c3 Huacai Chen 2022-05-31  260  #define __swp_entry_to_pmd(x)	((pmd_t) { (x).val | _PAGE_HUGE })
09cfefb7fa70c3 Huacai Chen 2022-05-31  261  
09cfefb7fa70c3 Huacai Chen 2022-05-31  262  extern void paging_init(void);
09cfefb7fa70c3 Huacai Chen 2022-05-31  263  
09cfefb7fa70c3 Huacai Chen 2022-05-31  264  #define pte_none(pte)		(!(pte_val(pte) & ~_PAGE_GLOBAL))
09cfefb7fa70c3 Huacai Chen 2022-05-31  265  #define pte_present(pte)	(pte_val(pte) & (_PAGE_PRESENT | _PAGE_PROTNONE))
09cfefb7fa70c3 Huacai Chen 2022-05-31  266  #define pte_no_exec(pte)	(pte_val(pte) & _PAGE_NO_EXEC)
09cfefb7fa70c3 Huacai Chen 2022-05-31  267  
09cfefb7fa70c3 Huacai Chen 2022-05-31  268  static inline void set_pte(pte_t *ptep, pte_t pteval)
09cfefb7fa70c3 Huacai Chen 2022-05-31  269  {
09cfefb7fa70c3 Huacai Chen 2022-05-31  270  	*ptep = pteval;
09cfefb7fa70c3 Huacai Chen 2022-05-31  271  	if (pte_val(pteval) & _PAGE_GLOBAL) {
09cfefb7fa70c3 Huacai Chen 2022-05-31  272  		pte_t *buddy = ptep_buddy(ptep);
09cfefb7fa70c3 Huacai Chen 2022-05-31  273  		/*
09cfefb7fa70c3 Huacai Chen 2022-05-31  274  		 * Make sure the buddy is global too (if it's !none,
09cfefb7fa70c3 Huacai Chen 2022-05-31  275  		 * it better already be global)
09cfefb7fa70c3 Huacai Chen 2022-05-31  276  		 */
46859ac8af52ae Huacai Chen 2022-05-31  277  #ifdef CONFIG_SMP
46859ac8af52ae Huacai Chen 2022-05-31  278  		/*
46859ac8af52ae Huacai Chen 2022-05-31  279  		 * For SMP, multiple CPUs can race, so we need to do
46859ac8af52ae Huacai Chen 2022-05-31  280  		 * this atomically.
46859ac8af52ae Huacai Chen 2022-05-31  281  		 */
46859ac8af52ae Huacai Chen 2022-05-31  282  		unsigned long page_global = _PAGE_GLOBAL;
46859ac8af52ae Huacai Chen 2022-05-31  283  		unsigned long tmp;
46859ac8af52ae Huacai Chen 2022-05-31  284  
46859ac8af52ae Huacai Chen 2022-05-31  285  		__asm__ __volatile__ (
46859ac8af52ae Huacai Chen 2022-05-31  286  		"1:"	__LL	"%[tmp], %[buddy]		\n"
46859ac8af52ae Huacai Chen 2022-05-31  287  		"	bnez	%[tmp], 2f			\n"
46859ac8af52ae Huacai Chen 2022-05-31  288  		"	 or	%[tmp], %[tmp], %[global]	\n"
46859ac8af52ae Huacai Chen 2022-05-31  289  			__SC	"%[tmp], %[buddy]		\n"
46859ac8af52ae Huacai Chen 2022-05-31  290  		"	beqz	%[tmp], 1b			\n"
46859ac8af52ae Huacai Chen 2022-05-31  291  		"	nop					\n"
46859ac8af52ae Huacai Chen 2022-05-31  292  		"2:						\n"
46859ac8af52ae Huacai Chen 2022-05-31  293  		__WEAK_LLSC_MB
46859ac8af52ae Huacai Chen 2022-05-31  294  		: [buddy] "+m" (buddy->pte), [tmp] "=&r" (tmp)
46859ac8af52ae Huacai Chen 2022-05-31  295  		: [global] "r" (page_global));
46859ac8af52ae Huacai Chen 2022-05-31  296  #else /* !CONFIG_SMP */
09cfefb7fa70c3 Huacai Chen 2022-05-31  297  		if (pte_none(*buddy))
09cfefb7fa70c3 Huacai Chen 2022-05-31  298  			pte_val(*buddy) = pte_val(*buddy) | _PAGE_GLOBAL;
46859ac8af52ae Huacai Chen 2022-05-31  299  #endif /* CONFIG_SMP */
09cfefb7fa70c3 Huacai Chen 2022-05-31  300  	}
09cfefb7fa70c3 Huacai Chen 2022-05-31  301  }
09cfefb7fa70c3 Huacai Chen 2022-05-31  302  
09cfefb7fa70c3 Huacai Chen 2022-05-31 @303  static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
09cfefb7fa70c3 Huacai Chen 2022-05-31  304  			      pte_t *ptep, pte_t pteval)
09cfefb7fa70c3 Huacai Chen 2022-05-31  305  {
09cfefb7fa70c3 Huacai Chen 2022-05-31  306  	set_pte(ptep, pteval);
09cfefb7fa70c3 Huacai Chen 2022-05-31  307  }
09cfefb7fa70c3 Huacai Chen 2022-05-31  308  
09cfefb7fa70c3 Huacai Chen 2022-05-31 @309  static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
09cfefb7fa70c3 Huacai Chen 2022-05-31  310  {
09cfefb7fa70c3 Huacai Chen 2022-05-31  311  	/* Preserve global status for the pair */
09cfefb7fa70c3 Huacai Chen 2022-05-31  312  	if (pte_val(*ptep_buddy(ptep)) & _PAGE_GLOBAL)
09cfefb7fa70c3 Huacai Chen 2022-05-31  313  		set_pte_at(mm, addr, ptep, __pte(_PAGE_GLOBAL));
09cfefb7fa70c3 Huacai Chen 2022-05-31  314  	else
09cfefb7fa70c3 Huacai Chen 2022-05-31  315  		set_pte_at(mm, addr, ptep, __pte(0));
09cfefb7fa70c3 Huacai Chen 2022-05-31  316  }
09cfefb7fa70c3 Huacai Chen 2022-05-31  317  
09cfefb7fa70c3 Huacai Chen 2022-05-31  318  #define PGD_T_LOG2	(__builtin_ffs(sizeof(pgd_t)) - 1)
09cfefb7fa70c3 Huacai Chen 2022-05-31  319  #define PMD_T_LOG2	(__builtin_ffs(sizeof(pmd_t)) - 1)
09cfefb7fa70c3 Huacai Chen 2022-05-31  320  #define PTE_T_LOG2	(__builtin_ffs(sizeof(pte_t)) - 1)
09cfefb7fa70c3 Huacai Chen 2022-05-31  321  
09cfefb7fa70c3 Huacai Chen 2022-05-31  322  extern pgd_t swapper_pg_dir[];
09cfefb7fa70c3 Huacai Chen 2022-05-31  323  extern pgd_t invalid_pg_dir[];
09cfefb7fa70c3 Huacai Chen 2022-05-31  324  
09cfefb7fa70c3 Huacai Chen 2022-05-31  325  /*
09cfefb7fa70c3 Huacai Chen 2022-05-31  326   * The following only work if pte_present() is true.
09cfefb7fa70c3 Huacai Chen 2022-05-31  327   * Undefined behaviour if not..
09cfefb7fa70c3 Huacai Chen 2022-05-31  328   */
09cfefb7fa70c3 Huacai Chen 2022-05-31  329  static inline int pte_write(pte_t pte)	{ return pte_val(pte) & _PAGE_WRITE; }
09cfefb7fa70c3 Huacai Chen 2022-05-31  330  static inline int pte_young(pte_t pte)	{ return pte_val(pte) & _PAGE_ACCESSED; }
09cfefb7fa70c3 Huacai Chen 2022-05-31  331  static inline int pte_dirty(pte_t pte)	{ return pte_val(pte) & _PAGE_MODIFIED; }
09cfefb7fa70c3 Huacai Chen 2022-05-31  332  
09cfefb7fa70c3 Huacai Chen 2022-05-31  333  static inline pte_t pte_mkold(pte_t pte)
09cfefb7fa70c3 Huacai Chen 2022-05-31  334  {
09cfefb7fa70c3 Huacai Chen 2022-05-31  335  	pte_val(pte) &= ~_PAGE_ACCESSED;
09cfefb7fa70c3 Huacai Chen 2022-05-31  336  	return pte;
09cfefb7fa70c3 Huacai Chen 2022-05-31  337  }
09cfefb7fa70c3 Huacai Chen 2022-05-31  338  
09cfefb7fa70c3 Huacai Chen 2022-05-31  339  static inline pte_t pte_mkyoung(pte_t pte)
09cfefb7fa70c3 Huacai Chen 2022-05-31  340  {
09cfefb7fa70c3 Huacai Chen 2022-05-31  341  	pte_val(pte) |= _PAGE_ACCESSED;
09cfefb7fa70c3 Huacai Chen 2022-05-31  342  	return pte;
09cfefb7fa70c3 Huacai Chen 2022-05-31  343  }
09cfefb7fa70c3 Huacai Chen 2022-05-31  344  
09cfefb7fa70c3 Huacai Chen 2022-05-31  345  static inline pte_t pte_mkclean(pte_t pte)
09cfefb7fa70c3 Huacai Chen 2022-05-31  346  {
09cfefb7fa70c3 Huacai Chen 2022-05-31  347  	pte_val(pte) &= ~(_PAGE_DIRTY | _PAGE_MODIFIED);
09cfefb7fa70c3 Huacai Chen 2022-05-31  348  	return pte;
09cfefb7fa70c3 Huacai Chen 2022-05-31  349  }
09cfefb7fa70c3 Huacai Chen 2022-05-31  350  
09cfefb7fa70c3 Huacai Chen 2022-05-31  351  static inline pte_t pte_mkdirty(pte_t pte)
09cfefb7fa70c3 Huacai Chen 2022-05-31  352  {
09cfefb7fa70c3 Huacai Chen 2022-05-31  353  	pte_val(pte) |= (_PAGE_DIRTY | _PAGE_MODIFIED);
09cfefb7fa70c3 Huacai Chen 2022-05-31  354  	return pte;
09cfefb7fa70c3 Huacai Chen 2022-05-31  355  }
09cfefb7fa70c3 Huacai Chen 2022-05-31  356  
09cfefb7fa70c3 Huacai Chen 2022-05-31  357  static inline pte_t pte_mkwrite(pte_t pte)
09cfefb7fa70c3 Huacai Chen 2022-05-31  358  {
09cfefb7fa70c3 Huacai Chen 2022-05-31  359  	pte_val(pte) |= (_PAGE_WRITE | _PAGE_DIRTY);
09cfefb7fa70c3 Huacai Chen 2022-05-31  360  	return pte;
09cfefb7fa70c3 Huacai Chen 2022-05-31  361  }
09cfefb7fa70c3 Huacai Chen 2022-05-31  362  
09cfefb7fa70c3 Huacai Chen 2022-05-31 @363  static inline pte_t pte_wrprotect(pte_t pte)
09cfefb7fa70c3 Huacai Chen 2022-05-31  364  {
09cfefb7fa70c3 Huacai Chen 2022-05-31  365  	pte_val(pte) &= ~(_PAGE_WRITE | _PAGE_DIRTY);
09cfefb7fa70c3 Huacai Chen 2022-05-31  366  	return pte;
09cfefb7fa70c3 Huacai Chen 2022-05-31  367  }
09cfefb7fa70c3 Huacai Chen 2022-05-31  368  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

* Re: [PATCH V2] LoongArch: Use TLB for ioremap()
  2022-08-23  3:03 [PATCH V2] LoongArch: Use TLB for ioremap() Huacai Chen
  2022-08-23  7:41 ` kernel test robot
@ 2022-08-24  0:13 ` kernel test robot
  2022-08-24  3:07 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2022-08-24  0:13 UTC (permalink / raw)
  To: Huacai Chen, Arnd Bergmann, Huacai Chen
  Cc: kbuild-all, loongarch, linux-arch, Xuefeng Li, Guo Ren,
	Xuerui Wang, Jiaxun Yang, linux-kernel

Hi Huacai,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v6.0-rc2 next-20220823]
[cannot apply to soc/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Huacai-Chen/LoongArch-Use-TLB-for-ioremap/20220823-110829
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 072e51356cd5a4a1c12c1020bc054c99b98333df
config: loongarch-buildonly-randconfig-r001-20220823 (https://download.01.org/0day-ci/archive/20220824/202208240804.stCUUthX-lkp@intel.com/config)
compiler: loongarch64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/80f55a8feb23743d963d113c803bf54b1287244d
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Huacai-Chen/LoongArch-Use-TLB-for-ioremap/20220823-110829
        git checkout 80f55a8feb23743d963d113c803bf54b1287244d
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=loongarch SHELL=/bin/bash arch/loongarch/kernel/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from include/asm-generic/io.h:1048,
                    from arch/loongarch/include/asm/io.h:94,
                    from arch/loongarch/include/asm/pgtable.h:62,
                    from arch/loongarch/include/asm/uaccess.h:17,
                    from include/linux/uaccess.h:11,
                    from include/linux/sched/task.h:11,
                    from include/linux/sched/signal.h:9,
                    from include/linux/ptrace.h:7,
                    from arch/loongarch/kernel/cpu-probe.c:9:
   include/linux/pgtable.h: In function 'pte_offset_kernel':
   include/linux/pgtable.h:92:25: error: implicit declaration of function 'pmd_page_vaddr'; did you mean 'pgd_page_vaddr'? [-Werror=implicit-function-declaration]
      92 |         return (pte_t *)pmd_page_vaddr(*pmd) + pte_index(address);
         |                         ^~~~~~~~~~~~~~
         |                         pgd_page_vaddr
>> include/linux/pgtable.h:92:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
      92 |         return (pte_t *)pmd_page_vaddr(*pmd) + pte_index(address);
         |                ^
   include/linux/pgtable.h: In function 'virt_to_kpte':
   include/linux/pgtable.h:165:16: error: implicit declaration of function 'pmd_none'; did you mean 'pud_none'? [-Werror=implicit-function-declaration]
     165 |         return pmd_none(*pmd) ? NULL : pte_offset_kernel(pmd, vaddr);
         |                ^~~~~~~~
         |                pud_none
   include/linux/pgtable.h: In function 'ptep_test_and_clear_young':
   include/linux/pgtable.h:207:14: error: implicit declaration of function 'pte_young' [-Werror=implicit-function-declaration]
     207 |         if (!pte_young(pte))
         |              ^~~~~~~~~
   include/linux/pgtable.h:210:17: error: implicit declaration of function 'set_pte_at' [-Werror=implicit-function-declaration]
     210 |                 set_pte_at(vma->vm_mm, address, ptep, pte_mkold(pte));
         |                 ^~~~~~~~~~
   include/linux/pgtable.h:210:55: error: implicit declaration of function 'pte_mkold' [-Werror=implicit-function-declaration]
     210 |                 set_pte_at(vma->vm_mm, address, ptep, pte_mkold(pte));
         |                                                       ^~~~~~~~~
   include/linux/pgtable.h: In function 'ptep_get_and_clear':
   include/linux/pgtable.h:269:9: error: implicit declaration of function 'pte_clear'; did you mean 'pud_clear'? [-Werror=implicit-function-declaration]
     269 |         pte_clear(mm, address, ptep);
         |         ^~~~~~~~~
         |         pud_clear
   include/linux/pgtable.h: In function 'ptep_set_wrprotect':
   include/linux/pgtable.h:455:39: error: implicit declaration of function 'pte_wrprotect'; did you mean 'ptep_set_wrprotect'? [-Werror=implicit-function-declaration]
     455 |         set_pte_at(mm, address, ptep, pte_wrprotect(old_pte));
         |                                       ^~~~~~~~~~~~~
         |                                       ptep_set_wrprotect
   In file included from include/linux/init.h:5,
                    from arch/loongarch/kernel/cpu-probe.c:7:
   include/linux/pgtable.h: In function 'pmd_none_or_clear_bad':
   include/linux/pgtable.h:877:22: error: implicit declaration of function 'pmd_bad'; did you mean 'pud_bad'? [-Werror=implicit-function-declaration]
     877 |         if (unlikely(pmd_bad(*pmd))) {
         |                      ^~~~~~~
   include/linux/compiler.h:78:45: note: in definition of macro 'unlikely'
      78 | # define unlikely(x)    __builtin_expect(!!(x), 0)
         |                                             ^
   include/linux/pgtable.h: In function 'pmd_none_or_trans_huge_or_clear_bad':
   include/linux/pgtable.h:1384:67: error: implicit declaration of function 'pmd_present'; did you mean 'pud_present'? [-Werror=implicit-function-declaration]
    1384 |                 (IS_ENABLED(CONFIG_ARCH_ENABLE_THP_MIGRATION) && !pmd_present(pmdval)))
         |                                                                   ^~~~~~~~~~~
         |                                                                   pud_present
   arch/loongarch/include/asm/pgtable.h: At top level:
   arch/loongarch/include/asm/pgtable.h:199:19: error: static declaration of 'pmd_none' follows non-static declaration
     199 | static inline int pmd_none(pmd_t pmd)
         |                   ^~~~~~~~
   include/linux/pgtable.h:165:16: note: previous implicit declaration of 'pmd_none' with type 'int()'
     165 |         return pmd_none(*pmd) ? NULL : pte_offset_kernel(pmd, vaddr);
         |                ^~~~~~~~
   arch/loongarch/include/asm/pgtable.h:204:19: error: static declaration of 'pmd_bad' follows non-static declaration
     204 | static inline int pmd_bad(pmd_t pmd)
         |                   ^~~~~~~
   include/linux/pgtable.h:877:22: note: previous implicit declaration of 'pmd_bad' with type 'int()'
     877 |         if (unlikely(pmd_bad(*pmd))) {
         |                      ^~~~~~~
   include/linux/compiler.h:78:45: note: in definition of macro 'unlikely'
      78 | # define unlikely(x)    __builtin_expect(!!(x), 0)
         |                                             ^
   arch/loongarch/include/asm/pgtable.h:209:19: error: static declaration of 'pmd_present' follows non-static declaration
     209 | static inline int pmd_present(pmd_t pmd)
         |                   ^~~~~~~~~~~
   include/linux/pgtable.h:1384:67: note: previous implicit declaration of 'pmd_present' with type 'int()'
    1384 |                 (IS_ENABLED(CONFIG_ARCH_ENABLE_THP_MIGRATION) && !pmd_present(pmdval)))
         |                                                                   ^~~~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:303:20: warning: conflicting types for 'set_pte_at'; have 'void(struct mm_struct *, long unsigned int,  pte_t *, pte_t)'
     303 | static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
         |                    ^~~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:303:20: error: static declaration of 'set_pte_at' follows non-static declaration
   include/linux/pgtable.h:210:17: note: previous implicit declaration of 'set_pte_at' with type 'void(struct mm_struct *, long unsigned int,  pte_t *, pte_t)'
     210 |                 set_pte_at(vma->vm_mm, address, ptep, pte_mkold(pte));
         |                 ^~~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:309:20: warning: conflicting types for 'pte_clear'; have 'void(struct mm_struct *, long unsigned int,  pte_t *)'
     309 | static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
         |                    ^~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:309:20: error: static declaration of 'pte_clear' follows non-static declaration
   include/linux/pgtable.h:269:9: note: previous implicit declaration of 'pte_clear' with type 'void(struct mm_struct *, long unsigned int,  pte_t *)'
     269 |         pte_clear(mm, address, ptep);
         |         ^~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:330:19: error: static declaration of 'pte_young' follows non-static declaration
     330 | static inline int pte_young(pte_t pte)  { return pte_val(pte) & _PAGE_ACCESSED; }
         |                   ^~~~~~~~~
   include/linux/pgtable.h:207:14: note: previous implicit declaration of 'pte_young' with type 'int()'
     207 |         if (!pte_young(pte))
         |              ^~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:333:21: error: conflicting types for 'pte_mkold'; have 'pte_t(pte_t)'
     333 | static inline pte_t pte_mkold(pte_t pte)
         |                     ^~~~~~~~~
   include/linux/pgtable.h:210:55: note: previous implicit declaration of 'pte_mkold' with type 'int()'
     210 |                 set_pte_at(vma->vm_mm, address, ptep, pte_mkold(pte));
         |                                                       ^~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:363:21: error: conflicting types for 'pte_wrprotect'; have 'pte_t(pte_t)'
     363 | static inline pte_t pte_wrprotect(pte_t pte)
         |                     ^~~~~~~~~~~~~
   include/linux/pgtable.h:455:39: note: previous implicit declaration of 'pte_wrprotect' with type 'int()'
     455 |         set_pte_at(mm, address, ptep, pte_wrprotect(old_pte));
         |                                       ^~~~~~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:382: warning: "pte_accessible" redefined
     382 | #define pte_accessible pte_accessible
         | 
   include/linux/pgtable.h:780: note: this is the location of the previous definition
     780 | # define pte_accessible(mm, pte)        ((void)(pte), 1)
--
   In file included from include/asm-generic/io.h:1048,
                    from arch/loongarch/include/asm/io.h:94,
                    from arch/loongarch/include/asm/pgtable.h:62,
                    from arch/loongarch/include/asm/uaccess.h:17,
                    from include/linux/uaccess.h:11,
                    from include/linux/sched/task.h:11,
                    from include/linux/sched/signal.h:9,
                    from include/linux/ptrace.h:7,
                    from include/linux/entry-common.h:6,
                    from arch/loongarch/kernel/traps.c:10:
   include/linux/pgtable.h: In function 'pte_offset_kernel':
   include/linux/pgtable.h:92:25: error: implicit declaration of function 'pmd_page_vaddr'; did you mean 'pgd_page_vaddr'? [-Werror=implicit-function-declaration]
      92 |         return (pte_t *)pmd_page_vaddr(*pmd) + pte_index(address);
         |                         ^~~~~~~~~~~~~~
         |                         pgd_page_vaddr
>> include/linux/pgtable.h:92:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
      92 |         return (pte_t *)pmd_page_vaddr(*pmd) + pte_index(address);
         |                ^
   include/linux/pgtable.h: In function 'virt_to_kpte':
   include/linux/pgtable.h:165:16: error: implicit declaration of function 'pmd_none'; did you mean 'pud_none'? [-Werror=implicit-function-declaration]
     165 |         return pmd_none(*pmd) ? NULL : pte_offset_kernel(pmd, vaddr);
         |                ^~~~~~~~
         |                pud_none
   include/linux/pgtable.h: In function 'ptep_test_and_clear_young':
   include/linux/pgtable.h:207:14: error: implicit declaration of function 'pte_young' [-Werror=implicit-function-declaration]
     207 |         if (!pte_young(pte))
         |              ^~~~~~~~~
   include/linux/pgtable.h:210:17: error: implicit declaration of function 'set_pte_at' [-Werror=implicit-function-declaration]
     210 |                 set_pte_at(vma->vm_mm, address, ptep, pte_mkold(pte));
         |                 ^~~~~~~~~~
   include/linux/pgtable.h:210:55: error: implicit declaration of function 'pte_mkold' [-Werror=implicit-function-declaration]
     210 |                 set_pte_at(vma->vm_mm, address, ptep, pte_mkold(pte));
         |                                                       ^~~~~~~~~
   include/linux/pgtable.h: In function 'ptep_get_and_clear':
   include/linux/pgtable.h:269:9: error: implicit declaration of function 'pte_clear'; did you mean 'pud_clear'? [-Werror=implicit-function-declaration]
     269 |         pte_clear(mm, address, ptep);
         |         ^~~~~~~~~
         |         pud_clear
   include/linux/pgtable.h: In function 'ptep_set_wrprotect':
   include/linux/pgtable.h:455:39: error: implicit declaration of function 'pte_wrprotect'; did you mean 'ptep_set_wrprotect'? [-Werror=implicit-function-declaration]
     455 |         set_pte_at(mm, address, ptep, pte_wrprotect(old_pte));
         |                                       ^~~~~~~~~~~~~
         |                                       ptep_set_wrprotect
   In file included from include/linux/build_bug.h:5,
                    from include/linux/bits.h:22,
                    from include/linux/bitops.h:6,
                    from arch/loongarch/kernel/traps.c:6:
   include/linux/pgtable.h: In function 'pmd_none_or_clear_bad':
   include/linux/pgtable.h:877:22: error: implicit declaration of function 'pmd_bad'; did you mean 'pud_bad'? [-Werror=implicit-function-declaration]
     877 |         if (unlikely(pmd_bad(*pmd))) {
         |                      ^~~~~~~
   include/linux/compiler.h:78:45: note: in definition of macro 'unlikely'
      78 | # define unlikely(x)    __builtin_expect(!!(x), 0)
         |                                             ^
   include/linux/pgtable.h: In function 'pmd_none_or_trans_huge_or_clear_bad':
   include/linux/pgtable.h:1384:67: error: implicit declaration of function 'pmd_present'; did you mean 'pud_present'? [-Werror=implicit-function-declaration]
    1384 |                 (IS_ENABLED(CONFIG_ARCH_ENABLE_THP_MIGRATION) && !pmd_present(pmdval)))
         |                                                                   ^~~~~~~~~~~
         |                                                                   pud_present
   arch/loongarch/include/asm/pgtable.h: At top level:
   arch/loongarch/include/asm/pgtable.h:199:19: error: static declaration of 'pmd_none' follows non-static declaration
     199 | static inline int pmd_none(pmd_t pmd)
         |                   ^~~~~~~~
   include/linux/pgtable.h:165:16: note: previous implicit declaration of 'pmd_none' with type 'int()'
     165 |         return pmd_none(*pmd) ? NULL : pte_offset_kernel(pmd, vaddr);
         |                ^~~~~~~~
   arch/loongarch/include/asm/pgtable.h:204:19: error: static declaration of 'pmd_bad' follows non-static declaration
     204 | static inline int pmd_bad(pmd_t pmd)
         |                   ^~~~~~~
   include/linux/pgtable.h:877:22: note: previous implicit declaration of 'pmd_bad' with type 'int()'
     877 |         if (unlikely(pmd_bad(*pmd))) {
         |                      ^~~~~~~
   include/linux/compiler.h:78:45: note: in definition of macro 'unlikely'
      78 | # define unlikely(x)    __builtin_expect(!!(x), 0)
         |                                             ^
   arch/loongarch/include/asm/pgtable.h:209:19: error: static declaration of 'pmd_present' follows non-static declaration
     209 | static inline int pmd_present(pmd_t pmd)
         |                   ^~~~~~~~~~~
   include/linux/pgtable.h:1384:67: note: previous implicit declaration of 'pmd_present' with type 'int()'
    1384 |                 (IS_ENABLED(CONFIG_ARCH_ENABLE_THP_MIGRATION) && !pmd_present(pmdval)))
         |                                                                   ^~~~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:303:20: warning: conflicting types for 'set_pte_at'; have 'void(struct mm_struct *, long unsigned int,  pte_t *, pte_t)'
     303 | static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
         |                    ^~~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:303:20: error: static declaration of 'set_pte_at' follows non-static declaration
   include/linux/pgtable.h:210:17: note: previous implicit declaration of 'set_pte_at' with type 'void(struct mm_struct *, long unsigned int,  pte_t *, pte_t)'
     210 |                 set_pte_at(vma->vm_mm, address, ptep, pte_mkold(pte));
         |                 ^~~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:309:20: warning: conflicting types for 'pte_clear'; have 'void(struct mm_struct *, long unsigned int,  pte_t *)'
     309 | static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
         |                    ^~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:309:20: error: static declaration of 'pte_clear' follows non-static declaration
   include/linux/pgtable.h:269:9: note: previous implicit declaration of 'pte_clear' with type 'void(struct mm_struct *, long unsigned int,  pte_t *)'
     269 |         pte_clear(mm, address, ptep);
         |         ^~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:330:19: error: static declaration of 'pte_young' follows non-static declaration
     330 | static inline int pte_young(pte_t pte)  { return pte_val(pte) & _PAGE_ACCESSED; }
         |                   ^~~~~~~~~
   include/linux/pgtable.h:207:14: note: previous implicit declaration of 'pte_young' with type 'int()'
     207 |         if (!pte_young(pte))
         |              ^~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:333:21: error: conflicting types for 'pte_mkold'; have 'pte_t(pte_t)'
     333 | static inline pte_t pte_mkold(pte_t pte)
         |                     ^~~~~~~~~
   include/linux/pgtable.h:210:55: note: previous implicit declaration of 'pte_mkold' with type 'int()'
     210 |                 set_pte_at(vma->vm_mm, address, ptep, pte_mkold(pte));
         |                                                       ^~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:363:21: error: conflicting types for 'pte_wrprotect'; have 'pte_t(pte_t)'
     363 | static inline pte_t pte_wrprotect(pte_t pte)
         |                     ^~~~~~~~~~~~~
   include/linux/pgtable.h:455:39: note: previous implicit declaration of 'pte_wrprotect' with type 'int()'
     455 |         set_pte_at(mm, address, ptep, pte_wrprotect(old_pte));
         |                                       ^~~~~~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:382: warning: "pte_accessible" redefined
     382 | #define pte_accessible pte_accessible
         | 
--
   In file included from include/asm-generic/io.h:1048,
                    from arch/loongarch/include/asm/io.h:94,
                    from arch/loongarch/include/asm/pgtable.h:62,
                    from arch/loongarch/include/asm/uaccess.h:17,
                    from include/linux/uaccess.h:11,
                    from include/linux/sched/task.h:11,
                    from include/linux/sched/signal.h:9,
                    from include/linux/rcuwait.h:6,
                    from include/linux/percpu-rwsem.h:7,
                    from include/linux/fs.h:33,
                    from arch/loongarch/include/asm/elf.h:9,
                    from include/linux/elf.h:6,
                    from include/linux/module.h:19,
                    from include/linux/device/driver.h:21,
                    from include/linux/device.h:32,
                    from include/linux/acpi.h:15,
                    from arch/loongarch/kernel/irq.c:6:
   include/linux/pgtable.h: In function 'pte_offset_kernel':
   include/linux/pgtable.h:92:25: error: implicit declaration of function 'pmd_page_vaddr'; did you mean 'pgd_page_vaddr'? [-Werror=implicit-function-declaration]
      92 |         return (pte_t *)pmd_page_vaddr(*pmd) + pte_index(address);
         |                         ^~~~~~~~~~~~~~
         |                         pgd_page_vaddr
>> include/linux/pgtable.h:92:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
      92 |         return (pte_t *)pmd_page_vaddr(*pmd) + pte_index(address);
         |                ^
   include/linux/pgtable.h: In function 'virt_to_kpte':
   include/linux/pgtable.h:165:16: error: implicit declaration of function 'pmd_none'; did you mean 'pud_none'? [-Werror=implicit-function-declaration]
     165 |         return pmd_none(*pmd) ? NULL : pte_offset_kernel(pmd, vaddr);
         |                ^~~~~~~~
         |                pud_none
   include/linux/pgtable.h: In function 'ptep_test_and_clear_young':
   include/linux/pgtable.h:207:14: error: implicit declaration of function 'pte_young' [-Werror=implicit-function-declaration]
     207 |         if (!pte_young(pte))
         |              ^~~~~~~~~
   include/linux/pgtable.h:210:17: error: implicit declaration of function 'set_pte_at' [-Werror=implicit-function-declaration]
     210 |                 set_pte_at(vma->vm_mm, address, ptep, pte_mkold(pte));
         |                 ^~~~~~~~~~
   include/linux/pgtable.h:210:55: error: implicit declaration of function 'pte_mkold' [-Werror=implicit-function-declaration]
     210 |                 set_pte_at(vma->vm_mm, address, ptep, pte_mkold(pte));
         |                                                       ^~~~~~~~~
   include/linux/pgtable.h: In function 'ptep_get_and_clear':
   include/linux/pgtable.h:269:9: error: implicit declaration of function 'pte_clear'; did you mean 'pud_clear'? [-Werror=implicit-function-declaration]
     269 |         pte_clear(mm, address, ptep);
         |         ^~~~~~~~~
         |         pud_clear
   include/linux/pgtable.h: In function 'ptep_set_wrprotect':
   include/linux/pgtable.h:455:39: error: implicit declaration of function 'pte_wrprotect'; did you mean 'ptep_set_wrprotect'? [-Werror=implicit-function-declaration]
     455 |         set_pte_at(mm, address, ptep, pte_wrprotect(old_pte));
         |                                       ^~~~~~~~~~~~~
         |                                       ptep_set_wrprotect
   In file included from include/linux/kernel.h:20,
                    from arch/loongarch/kernel/irq.c:5:
   include/linux/pgtable.h: In function 'pmd_none_or_clear_bad':
   include/linux/pgtable.h:877:22: error: implicit declaration of function 'pmd_bad'; did you mean 'pud_bad'? [-Werror=implicit-function-declaration]
     877 |         if (unlikely(pmd_bad(*pmd))) {
         |                      ^~~~~~~
   include/linux/compiler.h:78:45: note: in definition of macro 'unlikely'
      78 | # define unlikely(x)    __builtin_expect(!!(x), 0)
         |                                             ^
   include/linux/pgtable.h: In function 'pmd_none_or_trans_huge_or_clear_bad':
   include/linux/pgtable.h:1384:67: error: implicit declaration of function 'pmd_present'; did you mean 'pud_present'? [-Werror=implicit-function-declaration]
    1384 |                 (IS_ENABLED(CONFIG_ARCH_ENABLE_THP_MIGRATION) && !pmd_present(pmdval)))
         |                                                                   ^~~~~~~~~~~
         |                                                                   pud_present
   arch/loongarch/include/asm/pgtable.h: At top level:
   arch/loongarch/include/asm/pgtable.h:199:19: error: static declaration of 'pmd_none' follows non-static declaration
     199 | static inline int pmd_none(pmd_t pmd)
         |                   ^~~~~~~~
   include/linux/pgtable.h:165:16: note: previous implicit declaration of 'pmd_none' with type 'int()'
     165 |         return pmd_none(*pmd) ? NULL : pte_offset_kernel(pmd, vaddr);
         |                ^~~~~~~~
   arch/loongarch/include/asm/pgtable.h:204:19: error: static declaration of 'pmd_bad' follows non-static declaration
     204 | static inline int pmd_bad(pmd_t pmd)
         |                   ^~~~~~~
   include/linux/pgtable.h:877:22: note: previous implicit declaration of 'pmd_bad' with type 'int()'
     877 |         if (unlikely(pmd_bad(*pmd))) {
         |                      ^~~~~~~
   include/linux/compiler.h:78:45: note: in definition of macro 'unlikely'
      78 | # define unlikely(x)    __builtin_expect(!!(x), 0)
         |                                             ^
   arch/loongarch/include/asm/pgtable.h:209:19: error: static declaration of 'pmd_present' follows non-static declaration
     209 | static inline int pmd_present(pmd_t pmd)
         |                   ^~~~~~~~~~~
   include/linux/pgtable.h:1384:67: note: previous implicit declaration of 'pmd_present' with type 'int()'
    1384 |                 (IS_ENABLED(CONFIG_ARCH_ENABLE_THP_MIGRATION) && !pmd_present(pmdval)))
         |                                                                   ^~~~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:303:20: warning: conflicting types for 'set_pte_at'; have 'void(struct mm_struct *, long unsigned int,  pte_t *, pte_t)'
     303 | static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
         |                    ^~~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:303:20: error: static declaration of 'set_pte_at' follows non-static declaration
   include/linux/pgtable.h:210:17: note: previous implicit declaration of 'set_pte_at' with type 'void(struct mm_struct *, long unsigned int,  pte_t *, pte_t)'
     210 |                 set_pte_at(vma->vm_mm, address, ptep, pte_mkold(pte));
         |                 ^~~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:309:20: warning: conflicting types for 'pte_clear'; have 'void(struct mm_struct *, long unsigned int,  pte_t *)'
     309 | static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
         |                    ^~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:309:20: error: static declaration of 'pte_clear' follows non-static declaration
   include/linux/pgtable.h:269:9: note: previous implicit declaration of 'pte_clear' with type 'void(struct mm_struct *, long unsigned int,  pte_t *)'
     269 |         pte_clear(mm, address, ptep);
         |         ^~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:330:19: error: static declaration of 'pte_young' follows non-static declaration
     330 | static inline int pte_young(pte_t pte)  { return pte_val(pte) & _PAGE_ACCESSED; }
         |                   ^~~~~~~~~
   include/linux/pgtable.h:207:14: note: previous implicit declaration of 'pte_young' with type 'int()'
     207 |         if (!pte_young(pte))
         |              ^~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:333:21: error: conflicting types for 'pte_mkold'; have 'pte_t(pte_t)'
     333 | static inline pte_t pte_mkold(pte_t pte)
         |                     ^~~~~~~~~
   include/linux/pgtable.h:210:55: note: previous implicit declaration of 'pte_mkold' with type 'int()'
     210 |                 set_pte_at(vma->vm_mm, address, ptep, pte_mkold(pte));
         |                                                       ^~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:363:21: error: conflicting types for 'pte_wrprotect'; have 'pte_t(pte_t)'
     363 | static inline pte_t pte_wrprotect(pte_t pte)
         |                     ^~~~~~~~~~~~~
   include/linux/pgtable.h:455:39: note: previous implicit declaration of 'pte_wrprotect' with type 'int()'
     455 |         set_pte_at(mm, address, ptep, pte_wrprotect(old_pte));
         |                                       ^~~~~~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:382: warning: "pte_accessible" redefined
     382 | #define pte_accessible pte_accessible
         | 
   include/linux/pgtable.h:780: note: this is the location of the previous definition
     780 | # define pte_accessible(mm, pte)        ((void)(pte), 1)
..


vim +92 include/linux/pgtable.h

974b9b2c68f3d3 Mike Rapoport 2020-06-08  88  
974b9b2c68f3d3 Mike Rapoport 2020-06-08  89  #ifndef pte_offset_kernel
974b9b2c68f3d3 Mike Rapoport 2020-06-08  90  static inline pte_t *pte_offset_kernel(pmd_t *pmd, unsigned long address)
974b9b2c68f3d3 Mike Rapoport 2020-06-08  91  {
974b9b2c68f3d3 Mike Rapoport 2020-06-08 @92  	return (pte_t *)pmd_page_vaddr(*pmd) + pte_index(address);
974b9b2c68f3d3 Mike Rapoport 2020-06-08  93  }
974b9b2c68f3d3 Mike Rapoport 2020-06-08  94  #define pte_offset_kernel pte_offset_kernel
974b9b2c68f3d3 Mike Rapoport 2020-06-08  95  #endif
974b9b2c68f3d3 Mike Rapoport 2020-06-08  96  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

* Re: [PATCH V2] LoongArch: Use TLB for ioremap()
  2022-08-23  3:03 [PATCH V2] LoongArch: Use TLB for ioremap() Huacai Chen
  2022-08-23  7:41 ` kernel test robot
  2022-08-24  0:13 ` kernel test robot
@ 2022-08-24  3:07 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2022-08-24  3:07 UTC (permalink / raw)
  To: Huacai Chen, Arnd Bergmann, Huacai Chen
  Cc: kbuild-all, loongarch, linux-arch, Xuefeng Li, Guo Ren,
	Xuerui Wang, Jiaxun Yang, linux-kernel

Hi Huacai,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.0-rc2 next-20220823]
[cannot apply to soc/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Huacai-Chen/LoongArch-Use-TLB-for-ioremap/20220823-110829
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 072e51356cd5a4a1c12c1020bc054c99b98333df
config: loongarch-randconfig-r006-20220823 (https://download.01.org/0day-ci/archive/20220824/202208241152.Bp1fUWJ1-lkp@intel.com/config)
compiler: loongarch64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/80f55a8feb23743d963d113c803bf54b1287244d
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Huacai-Chen/LoongArch-Use-TLB-for-ioremap/20220823-110829
        git checkout 80f55a8feb23743d963d113c803bf54b1287244d
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=loongarch SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

    1348 | static inline int pmd_none_or_trans_huge_or_clear_bad(pmd_t *pmd)
         |                                                       ^~~~~
         |                                                       pud_t
   include/linux/pgtable.h:1405:38: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
    1405 | static inline int pmd_trans_unstable(pmd_t *pmd)
         |                                      ^~~~~
         |                                      pud_t
   include/linux/pgtable.h:1420:45: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
    1420 | static inline int pmd_devmap_trans_unstable(pmd_t *pmd)
         |                                             ^~~~~
         |                                             pud_t
   include/linux/pgtable.h:1439:32: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
    1439 | static inline int pmd_protnone(pmd_t pmd)
         |                                ^~~~~
         |                                pud_t
   include/linux/pgtable.h:1476:32: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
    1476 | static inline int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot)
         |                                ^~~~~
         |                                pud_t
   include/linux/pgtable.h:1485:34: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
    1485 | static inline int pmd_clear_huge(pmd_t *pmd)
         |                                  ^~~~~
         |                                  pud_t
   include/linux/pgtable.h:1497:37: error: unknown type name 'pmd_t'; did you mean 'pud_t'?
    1497 | static inline int pmd_free_pte_page(pmd_t *pmd, unsigned long addr)
         |                                     ^~~~~
         |                                     pud_t
   arch/loongarch/include/asm/pgtable.h:164:19: error: static declaration of 'pud_none' follows non-static declaration
     164 | static inline int pud_none(pud_t pud)
         |                   ^~~~~~~~
   include/linux/pgtable.h:864:13: note: previous implicit declaration of 'pud_none' with type 'int()'
     864 |         if (pud_none(*pud))
         |             ^~~~~~~~
   arch/loongarch/include/asm/pgtable.h:169:19: error: static declaration of 'pud_bad' follows non-static declaration
     169 | static inline int pud_bad(pud_t pud)
         |                   ^~~~~~~
   include/linux/pgtable.h:866:22: note: previous implicit declaration of 'pud_bad' with type 'int()'
     866 |         if (unlikely(pud_bad(*pud))) {
         |                      ^~~~~~~
   include/linux/compiler.h:78:45: note: in definition of macro 'unlikely'
      78 | # define unlikely(x)    __builtin_expect(!!(x), 0)
         |                                             ^
   arch/loongarch/include/asm/pgtable.h:184:22: error: conflicting types for 'pud_pgtable'; have 'pmd_t *(pud_t)'
     184 | static inline pmd_t *pud_pgtable(pud_t pud)
         |                      ^~~~~~~~~~~
   include/linux/pgtable.h:111:16: note: previous implicit declaration of 'pud_pgtable' with type 'int()'
     111 |         return pud_pgtable(*pud) + pmd_index(address);
         |                ^~~~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:199:19: error: static declaration of 'pmd_none' follows non-static declaration
     199 | static inline int pmd_none(pmd_t pmd)
         |                   ^~~~~~~~
   include/linux/pgtable.h:165:16: note: previous implicit declaration of 'pmd_none' with type 'int()'
     165 |         return pmd_none(*pmd) ? NULL : pte_offset_kernel(pmd, vaddr);
         |                ^~~~~~~~
   arch/loongarch/include/asm/pgtable.h:303:20: warning: conflicting types for 'set_pte_at'; have 'void(struct mm_struct *, long unsigned int,  pte_t *, pte_t)'
     303 | static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
         |                    ^~~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:303:20: error: static declaration of 'set_pte_at' follows non-static declaration
   include/linux/pgtable.h:210:17: note: previous implicit declaration of 'set_pte_at' with type 'void(struct mm_struct *, long unsigned int,  pte_t *, pte_t)'
     210 |                 set_pte_at(vma->vm_mm, address, ptep, pte_mkold(pte));
         |                 ^~~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:309:20: warning: conflicting types for 'pte_clear'; have 'void(struct mm_struct *, long unsigned int,  pte_t *)'
     309 | static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
         |                    ^~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:309:20: error: static declaration of 'pte_clear' follows non-static declaration
   include/linux/pgtable.h:269:9: note: previous implicit declaration of 'pte_clear' with type 'void(struct mm_struct *, long unsigned int,  pte_t *)'
     269 |         pte_clear(mm, address, ptep);
         |         ^~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:330:19: error: static declaration of 'pte_young' follows non-static declaration
     330 | static inline int pte_young(pte_t pte)  { return pte_val(pte) & _PAGE_ACCESSED; }
         |                   ^~~~~~~~~
   include/linux/pgtable.h:207:14: note: previous implicit declaration of 'pte_young' with type 'int()'
     207 |         if (!pte_young(pte))
         |              ^~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:333:21: error: conflicting types for 'pte_mkold'; have 'pte_t(pte_t)'
     333 | static inline pte_t pte_mkold(pte_t pte)
         |                     ^~~~~~~~~
   include/linux/pgtable.h:210:55: note: previous implicit declaration of 'pte_mkold' with type 'int()'
     210 |                 set_pte_at(vma->vm_mm, address, ptep, pte_mkold(pte));
         |                                                       ^~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:363:21: error: conflicting types for 'pte_wrprotect'; have 'pte_t(pte_t)'
     363 | static inline pte_t pte_wrprotect(pte_t pte)
         |                     ^~~~~~~~~~~~~
   include/linux/pgtable.h:455:39: note: previous implicit declaration of 'pte_wrprotect' with type 'int()'
     455 |         set_pte_at(mm, address, ptep, pte_wrprotect(old_pte));
         |                                       ^~~~~~~~~~~~~
   arch/loongarch/include/asm/pgtable.h:382: warning: "pte_accessible" redefined
     382 | #define pte_accessible pte_accessible
         | 
   include/linux/pgtable.h:780: note: this is the location of the previous definition
     780 | # define pte_accessible(mm, pte)        ((void)(pte), 1)
         | 
   In file included from include/linux/dax.h:6:
   include/linux/mm.h: In function 'pmd_alloc':
   include/linux/mm.h:2205:21: error: returning 'int *' from a function with incompatible return type 'pmd_t *' [-Werror=incompatible-pointer-types]
    2204 |         return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
         |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    2205 |                 NULL: pmd_offset(pud, address);
         |                 ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/filemap.c: In function 'filemap_map_pmd':
>> mm/filemap.c:3237:13: error: implicit declaration of function 'pmd_trans_huge'; did you mean 'pud_trans_huge'? [-Werror=implicit-function-declaration]
    3237 |         if (pmd_trans_huge(*vmf->pmd)) {
         |             ^~~~~~~~~~~~~~
         |             pud_trans_huge
   mm/filemap.c:3256:13: error: implicit declaration of function 'pmd_devmap_trans_unstable'; did you mean 'pud_trans_unstable'? [-Werror=implicit-function-declaration]
    3256 |         if (pmd_devmap_trans_unstable(vmf->pmd)) {
         |             ^~~~~~~~~~~~~~~~~~~~~~~~~
         |             pud_trans_unstable
   mm/filemap.c: In function 'filemap_map_pages':
   include/linux/pgtable.h:94:27: warning: initialization of 'pte_t *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
      94 | #define pte_offset_kernel pte_offset_kernel
         |                           ^~~~~~~~~~~~~~~~~
   include/linux/pgtable.h:103:41: note: in expansion of macro 'pte_offset_kernel'
     103 | #define pte_offset_map(dir, address)    pte_offset_kernel((dir), (address))
         |                                         ^~~~~~~~~~~~~~~~~
   include/linux/mm.h:2298:24: note: in expansion of macro 'pte_offset_map'
    2298 |         pte_t *__pte = pte_offset_map(pmd, address);    \
         |                        ^~~~~~~~~~~~~~
   mm/filemap.c:3347:20: note: in expansion of macro 'pte_offset_map_lock'
    3347 |         vmf->pte = pte_offset_map_lock(vma->vm_mm, vmf->pmd, addr, &vmf->ptl);
         |                    ^~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors


vim +3237 mm/filemap.c

54cb8821de07f2 Nicholas Piggin    2007-07-19  3231  
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3232  static bool filemap_map_pmd(struct vm_fault *vmf, struct page *page)
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3233  {
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3234  	struct mm_struct *mm = vmf->vma->vm_mm;
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3235  
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3236  	/* Huge page is mapped? No need to proceed. */
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19 @3237  	if (pmd_trans_huge(*vmf->pmd)) {
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3238  		unlock_page(page);
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3239  		put_page(page);
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3240  		return true;
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3241  	}
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3242  
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3243  	if (pmd_none(*vmf->pmd) && PageTransHuge(page)) {
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3244  		vm_fault_t ret = do_set_pmd(vmf, page);
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3245  		if (!ret) {
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3246  			/* The page is mapped successfully, reference consumed. */
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3247  			unlock_page(page);
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3248  			return true;
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3249  		}
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3250  	}
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3251  
03c4f20454e023 Qi Zheng           2021-11-05  3252  	if (pmd_none(*vmf->pmd))
03c4f20454e023 Qi Zheng           2021-11-05  3253  		pmd_install(mm, vmf->pmd, &vmf->prealloc_pte);
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3254  
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3255  	/* See comment in handle_pte_fault() */
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3256  	if (pmd_devmap_trans_unstable(vmf->pmd)) {
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3257  		unlock_page(page);
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3258  		put_page(page);
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3259  		return true;
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3260  	}
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3261  
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3262  	return false;
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3263  }
f9ce0be71d1fbb Kirill A. Shutemov 2020-12-19  3264  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

end of thread, other threads:[~2022-08-24  3:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-23  3:03 [PATCH V2] LoongArch: Use TLB for ioremap() Huacai Chen
2022-08-23  7:41 ` kernel test robot
2022-08-24  0:13 ` kernel test robot
2022-08-24  3:07 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).