All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/6] arm64: Cleanup ioremap() and support ioremap_prot()
@ 2022-05-19  8:25 ` Kefeng Wang
  0 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-19  8:25 UTC (permalink / raw)
  To: catalin.marinas, will, akpm, linux-arm-kernel, linux-kernel
  Cc: linux-mm, hch, arnd, anshuman.khandual, Kefeng Wang

1. Enhance generic ioremap to make it more useful.
2. Let's arm64 use GENERIC_IOREMAP to cleanup code.
3. Support HAVE_IOREMAP_PROT on arm64, which enable generic_access_phys(),
   it is useful when debug(eg, gdb) via access_process_vm device memory
   infrastructure.

v3:
- add cleanup patch to kill ARM's unused arch_iounmap(the naming will be
  used in GENERIC_IOREMAP) and add comments for arch_ioremap/arch_iounmap
  hooks, per Anshuman Khandual
- collect ack/review 

v2:
- s/addr/phys_addr in ioremap_prot, suggested by Andrew Morton 
- rename arch_ioremap/iounmap_check to arch_ioremap/iounmad
  and change return value, per Christoph Hellwig and Andrew Morton
- and use 'ifndef arch_ioremap' instead of weak function, per Arnd Bergmann
- collect ack/review

Kefeng Wang (6):
  ARM: mm: kill unused runtime hook arch_iounmap()
  mm: ioremap: Use more sensibly name in ioremap_prot()
  mm: ioremap: Setup phys_addr of struct vm_struct
  mm: ioremap: Add arch_ioremap/iounmap()
  arm64: mm: Convert to GENERIC_IOREMAP
  arm64: Add HAVE_IOREMAP_PROT support

 .../features/vm/ioremap_prot/arch-support.txt |  2 +-
 arch/arm/include/asm/io.h                     |  4 +-
 arch/arm/mm/ioremap.c                         |  9 +-
 arch/arm/mm/nommu.c                           |  9 +-
 arch/arm64/Kconfig                            |  2 +
 arch/arm64/include/asm/io.h                   | 20 +++--
 arch/arm64/include/asm/pgtable.h              | 10 +++
 arch/arm64/kernel/acpi.c                      |  2 +-
 arch/arm64/mm/hugetlbpage.c                   | 10 ---
 arch/arm64/mm/ioremap.c                       | 85 +++----------------
 include/asm-generic/io.h                      | 26 +++++-
 mm/ioremap.c                                  | 30 +++++--
 12 files changed, 88 insertions(+), 121 deletions(-)

-- 
2.35.3


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

* [PATCH v3 0/6] arm64: Cleanup ioremap() and support ioremap_prot()
@ 2022-05-19  8:25 ` Kefeng Wang
  0 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-19  8:25 UTC (permalink / raw)
  To: catalin.marinas, will, akpm, linux-arm-kernel, linux-kernel
  Cc: linux-mm, hch, arnd, anshuman.khandual, Kefeng Wang

1. Enhance generic ioremap to make it more useful.
2. Let's arm64 use GENERIC_IOREMAP to cleanup code.
3. Support HAVE_IOREMAP_PROT on arm64, which enable generic_access_phys(),
   it is useful when debug(eg, gdb) via access_process_vm device memory
   infrastructure.

v3:
- add cleanup patch to kill ARM's unused arch_iounmap(the naming will be
  used in GENERIC_IOREMAP) and add comments for arch_ioremap/arch_iounmap
  hooks, per Anshuman Khandual
- collect ack/review 

v2:
- s/addr/phys_addr in ioremap_prot, suggested by Andrew Morton 
- rename arch_ioremap/iounmap_check to arch_ioremap/iounmad
  and change return value, per Christoph Hellwig and Andrew Morton
- and use 'ifndef arch_ioremap' instead of weak function, per Arnd Bergmann
- collect ack/review

Kefeng Wang (6):
  ARM: mm: kill unused runtime hook arch_iounmap()
  mm: ioremap: Use more sensibly name in ioremap_prot()
  mm: ioremap: Setup phys_addr of struct vm_struct
  mm: ioremap: Add arch_ioremap/iounmap()
  arm64: mm: Convert to GENERIC_IOREMAP
  arm64: Add HAVE_IOREMAP_PROT support

 .../features/vm/ioremap_prot/arch-support.txt |  2 +-
 arch/arm/include/asm/io.h                     |  4 +-
 arch/arm/mm/ioremap.c                         |  9 +-
 arch/arm/mm/nommu.c                           |  9 +-
 arch/arm64/Kconfig                            |  2 +
 arch/arm64/include/asm/io.h                   | 20 +++--
 arch/arm64/include/asm/pgtable.h              | 10 +++
 arch/arm64/kernel/acpi.c                      |  2 +-
 arch/arm64/mm/hugetlbpage.c                   | 10 ---
 arch/arm64/mm/ioremap.c                       | 85 +++----------------
 include/asm-generic/io.h                      | 26 +++++-
 mm/ioremap.c                                  | 30 +++++--
 12 files changed, 88 insertions(+), 121 deletions(-)

-- 
2.35.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v3 1/6] ARM: mm: kill unused runtime hook arch_iounmap()
  2022-05-19  8:25 ` Kefeng Wang
@ 2022-05-19  8:25   ` Kefeng Wang
  -1 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-19  8:25 UTC (permalink / raw)
  To: catalin.marinas, will, akpm, linux-arm-kernel, linux-kernel
  Cc: linux-mm, hch, arnd, anshuman.khandual, Kefeng Wang, Russell King

Since the following commits,

v5.4
  commit 59d3ae9a5bf6 ("ARM: remove Intel iop33x and iop13xx support")
v5.11
  commit 3e3f354bc383 ("ARM: remove ebsa110 platform")

The runtime hook arch_iounmap() on ARM is useless, kill arch_iounmap()
and __iounmap(), and the naming of arch_iounmap will be used in 
GENERIC_IOREMAP with the later patch.

Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 arch/arm/include/asm/io.h | 4 +---
 arch/arm/mm/ioremap.c     | 9 +--------
 arch/arm/mm/nommu.c       | 9 +--------
 3 files changed, 3 insertions(+), 19 deletions(-)

diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
index 2a0739a2350b..d70727c9968f 100644
--- a/arch/arm/include/asm/io.h
+++ b/arch/arm/include/asm/io.h
@@ -139,11 +139,9 @@ extern void __iomem *__arm_ioremap_caller(phys_addr_t, size_t, unsigned int,
 extern void __iomem *__arm_ioremap_pfn(unsigned long, unsigned long, size_t, unsigned int);
 extern void __iomem *__arm_ioremap_exec(phys_addr_t, size_t, bool cached);
 void __arm_iomem_set_ro(void __iomem *ptr, size_t size);
-extern void __iounmap(volatile void __iomem *addr);
 
 extern void __iomem * (*arch_ioremap_caller)(phys_addr_t, size_t,
 	unsigned int, void *);
-extern void (*arch_iounmap)(volatile void __iomem *);
 
 /*
  * Bad read/write accesses...
@@ -399,7 +397,7 @@ void __iomem *ioremap_wc(resource_size_t res_cookie, size_t size);
 #define ioremap_wc ioremap_wc
 #define ioremap_wt ioremap_wc
 
-void iounmap(volatile void __iomem *iomem_cookie);
+void iounmap(volatile void __iomem *io_addr);
 #define iounmap iounmap
 
 void *arch_memremap_wb(phys_addr_t phys_addr, size_t size);
diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
index 290702328a33..e376926d6736 100644
--- a/arch/arm/mm/ioremap.c
+++ b/arch/arm/mm/ioremap.c
@@ -418,7 +418,7 @@ void *arch_memremap_wb(phys_addr_t phys_addr, size_t size)
 						   __builtin_return_address(0));
 }
 
-void __iounmap(volatile void __iomem *io_addr)
+void iounmap(volatile void __iomem *io_addr)
 {
 	void *addr = (void *)(PAGE_MASK & (unsigned long)io_addr);
 	struct static_vm *svm;
@@ -446,13 +446,6 @@ void __iounmap(volatile void __iomem *io_addr)
 
 	vunmap(addr);
 }
-
-void (*arch_iounmap)(volatile void __iomem *) = __iounmap;
-
-void iounmap(volatile void __iomem *cookie)
-{
-	arch_iounmap(cookie);
-}
 EXPORT_SYMBOL(iounmap);
 
 #ifdef CONFIG_PCI
diff --git a/arch/arm/mm/nommu.c b/arch/arm/mm/nommu.c
index 2658f52903da..c42debaded95 100644
--- a/arch/arm/mm/nommu.c
+++ b/arch/arm/mm/nommu.c
@@ -230,14 +230,7 @@ void *arch_memremap_wb(phys_addr_t phys_addr, size_t size)
 	return (void *)phys_addr;
 }
 
-void __iounmap(volatile void __iomem *addr)
-{
-}
-EXPORT_SYMBOL(__iounmap);
-
-void (*arch_iounmap)(volatile void __iomem *);
-
-void iounmap(volatile void __iomem *addr)
+void iounmap(volatile void __iomem *io_addr)
 {
 }
 EXPORT_SYMBOL(iounmap);
-- 
2.35.3


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

* [PATCH v3 1/6] ARM: mm: kill unused runtime hook arch_iounmap()
@ 2022-05-19  8:25   ` Kefeng Wang
  0 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-19  8:25 UTC (permalink / raw)
  To: catalin.marinas, will, akpm, linux-arm-kernel, linux-kernel
  Cc: linux-mm, hch, arnd, anshuman.khandual, Kefeng Wang, Russell King

Since the following commits,

v5.4
  commit 59d3ae9a5bf6 ("ARM: remove Intel iop33x and iop13xx support")
v5.11
  commit 3e3f354bc383 ("ARM: remove ebsa110 platform")

The runtime hook arch_iounmap() on ARM is useless, kill arch_iounmap()
and __iounmap(), and the naming of arch_iounmap will be used in 
GENERIC_IOREMAP with the later patch.

Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 arch/arm/include/asm/io.h | 4 +---
 arch/arm/mm/ioremap.c     | 9 +--------
 arch/arm/mm/nommu.c       | 9 +--------
 3 files changed, 3 insertions(+), 19 deletions(-)

diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
index 2a0739a2350b..d70727c9968f 100644
--- a/arch/arm/include/asm/io.h
+++ b/arch/arm/include/asm/io.h
@@ -139,11 +139,9 @@ extern void __iomem *__arm_ioremap_caller(phys_addr_t, size_t, unsigned int,
 extern void __iomem *__arm_ioremap_pfn(unsigned long, unsigned long, size_t, unsigned int);
 extern void __iomem *__arm_ioremap_exec(phys_addr_t, size_t, bool cached);
 void __arm_iomem_set_ro(void __iomem *ptr, size_t size);
-extern void __iounmap(volatile void __iomem *addr);
 
 extern void __iomem * (*arch_ioremap_caller)(phys_addr_t, size_t,
 	unsigned int, void *);
-extern void (*arch_iounmap)(volatile void __iomem *);
 
 /*
  * Bad read/write accesses...
@@ -399,7 +397,7 @@ void __iomem *ioremap_wc(resource_size_t res_cookie, size_t size);
 #define ioremap_wc ioremap_wc
 #define ioremap_wt ioremap_wc
 
-void iounmap(volatile void __iomem *iomem_cookie);
+void iounmap(volatile void __iomem *io_addr);
 #define iounmap iounmap
 
 void *arch_memremap_wb(phys_addr_t phys_addr, size_t size);
diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
index 290702328a33..e376926d6736 100644
--- a/arch/arm/mm/ioremap.c
+++ b/arch/arm/mm/ioremap.c
@@ -418,7 +418,7 @@ void *arch_memremap_wb(phys_addr_t phys_addr, size_t size)
 						   __builtin_return_address(0));
 }
 
-void __iounmap(volatile void __iomem *io_addr)
+void iounmap(volatile void __iomem *io_addr)
 {
 	void *addr = (void *)(PAGE_MASK & (unsigned long)io_addr);
 	struct static_vm *svm;
@@ -446,13 +446,6 @@ void __iounmap(volatile void __iomem *io_addr)
 
 	vunmap(addr);
 }
-
-void (*arch_iounmap)(volatile void __iomem *) = __iounmap;
-
-void iounmap(volatile void __iomem *cookie)
-{
-	arch_iounmap(cookie);
-}
 EXPORT_SYMBOL(iounmap);
 
 #ifdef CONFIG_PCI
diff --git a/arch/arm/mm/nommu.c b/arch/arm/mm/nommu.c
index 2658f52903da..c42debaded95 100644
--- a/arch/arm/mm/nommu.c
+++ b/arch/arm/mm/nommu.c
@@ -230,14 +230,7 @@ void *arch_memremap_wb(phys_addr_t phys_addr, size_t size)
 	return (void *)phys_addr;
 }
 
-void __iounmap(volatile void __iomem *addr)
-{
-}
-EXPORT_SYMBOL(__iounmap);
-
-void (*arch_iounmap)(volatile void __iomem *);
-
-void iounmap(volatile void __iomem *addr)
+void iounmap(volatile void __iomem *io_addr)
 {
 }
 EXPORT_SYMBOL(iounmap);
-- 
2.35.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v3 2/6] mm: ioremap: Use more sensibly name in ioremap_prot()
  2022-05-19  8:25 ` Kefeng Wang
@ 2022-05-19  8:25   ` Kefeng Wang
  -1 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-19  8:25 UTC (permalink / raw)
  To: catalin.marinas, will, akpm, linux-arm-kernel, linux-kernel
  Cc: linux-mm, hch, arnd, anshuman.khandual, Kefeng Wang

Use more meaningful and sensibly naming phys_addr
instead addr in ioremap_prot().

Suggested-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 include/asm-generic/io.h |  2 +-
 mm/ioremap.c             | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index 7ce93aaf69f8..e6ffa2519f08 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -964,7 +964,7 @@ static inline void iounmap(volatile void __iomem *addr)
 #elif defined(CONFIG_GENERIC_IOREMAP)
 #include <linux/pgtable.h>
 
-void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot);
+void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, unsigned long prot);
 void iounmap(volatile void __iomem *addr);
 
 static inline void __iomem *ioremap(phys_addr_t addr, size_t size)
diff --git a/mm/ioremap.c b/mm/ioremap.c
index 5fe598ecd9b7..1f9597fbcc07 100644
--- a/mm/ioremap.c
+++ b/mm/ioremap.c
@@ -11,20 +11,20 @@
 #include <linux/io.h>
 #include <linux/export.h>
 
-void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot)
+void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, unsigned long prot)
 {
 	unsigned long offset, vaddr;
 	phys_addr_t last_addr;
 	struct vm_struct *area;
 
 	/* Disallow wrap-around or zero size */
-	last_addr = addr + size - 1;
-	if (!size || last_addr < addr)
+	last_addr = phys_addr + size - 1;
+	if (!size || last_addr < phys_addr)
 		return NULL;
 
 	/* Page-align mappings */
-	offset = addr & (~PAGE_MASK);
-	addr -= offset;
+	offset = phys_addr & (~PAGE_MASK);
+	phys_addr -= offset;
 	size = PAGE_ALIGN(size + offset);
 
 	area = get_vm_area_caller(size, VM_IOREMAP,
@@ -33,7 +33,7 @@ void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot)
 		return NULL;
 	vaddr = (unsigned long)area->addr;
 
-	if (ioremap_page_range(vaddr, vaddr + size, addr, __pgprot(prot))) {
+	if (ioremap_page_range(vaddr, vaddr + size, phys_addr, __pgprot(prot))) {
 		free_vm_area(area);
 		return NULL;
 	}
-- 
2.35.3


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

* [PATCH v3 2/6] mm: ioremap: Use more sensibly name in ioremap_prot()
@ 2022-05-19  8:25   ` Kefeng Wang
  0 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-19  8:25 UTC (permalink / raw)
  To: catalin.marinas, will, akpm, linux-arm-kernel, linux-kernel
  Cc: linux-mm, hch, arnd, anshuman.khandual, Kefeng Wang

Use more meaningful and sensibly naming phys_addr
instead addr in ioremap_prot().

Suggested-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 include/asm-generic/io.h |  2 +-
 mm/ioremap.c             | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index 7ce93aaf69f8..e6ffa2519f08 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -964,7 +964,7 @@ static inline void iounmap(volatile void __iomem *addr)
 #elif defined(CONFIG_GENERIC_IOREMAP)
 #include <linux/pgtable.h>
 
-void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot);
+void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, unsigned long prot);
 void iounmap(volatile void __iomem *addr);
 
 static inline void __iomem *ioremap(phys_addr_t addr, size_t size)
diff --git a/mm/ioremap.c b/mm/ioremap.c
index 5fe598ecd9b7..1f9597fbcc07 100644
--- a/mm/ioremap.c
+++ b/mm/ioremap.c
@@ -11,20 +11,20 @@
 #include <linux/io.h>
 #include <linux/export.h>
 
-void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot)
+void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, unsigned long prot)
 {
 	unsigned long offset, vaddr;
 	phys_addr_t last_addr;
 	struct vm_struct *area;
 
 	/* Disallow wrap-around or zero size */
-	last_addr = addr + size - 1;
-	if (!size || last_addr < addr)
+	last_addr = phys_addr + size - 1;
+	if (!size || last_addr < phys_addr)
 		return NULL;
 
 	/* Page-align mappings */
-	offset = addr & (~PAGE_MASK);
-	addr -= offset;
+	offset = phys_addr & (~PAGE_MASK);
+	phys_addr -= offset;
 	size = PAGE_ALIGN(size + offset);
 
 	area = get_vm_area_caller(size, VM_IOREMAP,
@@ -33,7 +33,7 @@ void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot)
 		return NULL;
 	vaddr = (unsigned long)area->addr;
 
-	if (ioremap_page_range(vaddr, vaddr + size, addr, __pgprot(prot))) {
+	if (ioremap_page_range(vaddr, vaddr + size, phys_addr, __pgprot(prot))) {
 		free_vm_area(area);
 		return NULL;
 	}
-- 
2.35.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v3 3/6] mm: ioremap: Setup phys_addr of struct vm_struct
  2022-05-19  8:25 ` Kefeng Wang
@ 2022-05-19  8:25   ` Kefeng Wang
  -1 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-19  8:25 UTC (permalink / raw)
  To: catalin.marinas, will, akpm, linux-arm-kernel, linux-kernel
  Cc: linux-mm, hch, arnd, anshuman.khandual, Kefeng Wang, Christoph Hellwig

Show physical address of each ioremap in /proc/vmallocinfo.

Acked-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 mm/ioremap.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mm/ioremap.c b/mm/ioremap.c
index 1f9597fbcc07..7cb9996b0c12 100644
--- a/mm/ioremap.c
+++ b/mm/ioremap.c
@@ -32,6 +32,7 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, unsigned long pro
 	if (!area)
 		return NULL;
 	vaddr = (unsigned long)area->addr;
+	area->phys_addr = phys_addr;
 
 	if (ioremap_page_range(vaddr, vaddr + size, phys_addr, __pgprot(prot))) {
 		free_vm_area(area);
-- 
2.35.3


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

* [PATCH v3 3/6] mm: ioremap: Setup phys_addr of struct vm_struct
@ 2022-05-19  8:25   ` Kefeng Wang
  0 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-19  8:25 UTC (permalink / raw)
  To: catalin.marinas, will, akpm, linux-arm-kernel, linux-kernel
  Cc: linux-mm, hch, arnd, anshuman.khandual, Kefeng Wang, Christoph Hellwig

Show physical address of each ioremap in /proc/vmallocinfo.

Acked-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 mm/ioremap.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mm/ioremap.c b/mm/ioremap.c
index 1f9597fbcc07..7cb9996b0c12 100644
--- a/mm/ioremap.c
+++ b/mm/ioremap.c
@@ -32,6 +32,7 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, unsigned long pro
 	if (!area)
 		return NULL;
 	vaddr = (unsigned long)area->addr;
+	area->phys_addr = phys_addr;
 
 	if (ioremap_page_range(vaddr, vaddr + size, phys_addr, __pgprot(prot))) {
 		free_vm_area(area);
-- 
2.35.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
  2022-05-19  8:25 ` Kefeng Wang
@ 2022-05-19  8:25   ` Kefeng Wang
  -1 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-19  8:25 UTC (permalink / raw)
  To: catalin.marinas, will, akpm, linux-arm-kernel, linux-kernel
  Cc: linux-mm, hch, arnd, anshuman.khandual, Kefeng Wang

Add special hook for architecture to verify or setup addr, size
or prot when ioremap() or iounmap(), which will make the generic
ioremap more useful.

  arch_ioremap() return a pointer,
    - IS_ERR means return an error
    - NULL means continue to remap
    - a non-NULL, non-IS_ERR pointer is directly returned
  arch_iounmap() return a int value,
    - 0 means continue to vunmap
    - error code means skip vunmap and return directly

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 include/asm-generic/io.h | 24 ++++++++++++++++++++++++
 mm/ioremap.c             | 17 ++++++++++++++---
 2 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index e6ffa2519f08..b60f7151e1d6 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -964,6 +964,30 @@ static inline void iounmap(volatile void __iomem *addr)
 #elif defined(CONFIG_GENERIC_IOREMAP)
 #include <linux/pgtable.h>
 
+/*
+ * Arch code can implement the following two special hooks when using GENERIC_IOREMAP
+ * arch_ioremap() return a pointer,
+ *   - IS_ERR means return an error
+ *   - NULL means continue to remap
+ *   - a non-NULL, non-IS_ERR pointer is returned directly
+ * arch_iounmap() return a int,
+ *   - 0 means continue to vunmap
+ *   - error code means skip vunmap and return directly
+ */
+#ifndef arch_ioremap
+static inline void __iomem *arch_ioremap(phys_addr_t phys_addr, size_t size, unsigned long prot)
+{
+	return NULL;
+}
+#endif
+
+#ifndef arch_iounmap
+static inline int arch_iounmap(void __iomem *addr)
+{
+	return 0;
+}
+#endif
+
 void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, unsigned long prot);
 void iounmap(volatile void __iomem *addr);
 
diff --git a/mm/ioremap.c b/mm/ioremap.c
index 7cb9996b0c12..fac7f23b8c4b 100644
--- a/mm/ioremap.c
+++ b/mm/ioremap.c
@@ -16,6 +16,7 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, unsigned long pro
 	unsigned long offset, vaddr;
 	phys_addr_t last_addr;
 	struct vm_struct *area;
+	void __iomem *base;
 
 	/* Disallow wrap-around or zero size */
 	last_addr = phys_addr + size - 1;
@@ -27,8 +28,13 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, unsigned long pro
 	phys_addr -= offset;
 	size = PAGE_ALIGN(size + offset);
 
-	area = get_vm_area_caller(size, VM_IOREMAP,
-			__builtin_return_address(0));
+	base = arch_ioremap(phys_addr, size, prot);
+	if (IS_ERR(base))
+		return NULL;
+	else if (base)
+		return base;
+
+	area = get_vm_area_caller(size, VM_IOREMAP, __builtin_return_address(0));
 	if (!area)
 		return NULL;
 	vaddr = (unsigned long)area->addr;
@@ -45,6 +51,11 @@ EXPORT_SYMBOL(ioremap_prot);
 
 void iounmap(volatile void __iomem *addr)
 {
-	vunmap((void *)((unsigned long)addr & PAGE_MASK));
+	void __iomem *vaddr = (void __iomem *)((unsigned long)addr & PAGE_MASK);
+
+	if (arch_iounmap(vaddr))
+		return;
+
+	vunmap(vaddr);
 }
 EXPORT_SYMBOL(iounmap);
-- 
2.35.3


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

* [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
@ 2022-05-19  8:25   ` Kefeng Wang
  0 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-19  8:25 UTC (permalink / raw)
  To: catalin.marinas, will, akpm, linux-arm-kernel, linux-kernel
  Cc: linux-mm, hch, arnd, anshuman.khandual, Kefeng Wang

Add special hook for architecture to verify or setup addr, size
or prot when ioremap() or iounmap(), which will make the generic
ioremap more useful.

  arch_ioremap() return a pointer,
    - IS_ERR means return an error
    - NULL means continue to remap
    - a non-NULL, non-IS_ERR pointer is directly returned
  arch_iounmap() return a int value,
    - 0 means continue to vunmap
    - error code means skip vunmap and return directly

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 include/asm-generic/io.h | 24 ++++++++++++++++++++++++
 mm/ioremap.c             | 17 ++++++++++++++---
 2 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index e6ffa2519f08..b60f7151e1d6 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -964,6 +964,30 @@ static inline void iounmap(volatile void __iomem *addr)
 #elif defined(CONFIG_GENERIC_IOREMAP)
 #include <linux/pgtable.h>
 
+/*
+ * Arch code can implement the following two special hooks when using GENERIC_IOREMAP
+ * arch_ioremap() return a pointer,
+ *   - IS_ERR means return an error
+ *   - NULL means continue to remap
+ *   - a non-NULL, non-IS_ERR pointer is returned directly
+ * arch_iounmap() return a int,
+ *   - 0 means continue to vunmap
+ *   - error code means skip vunmap and return directly
+ */
+#ifndef arch_ioremap
+static inline void __iomem *arch_ioremap(phys_addr_t phys_addr, size_t size, unsigned long prot)
+{
+	return NULL;
+}
+#endif
+
+#ifndef arch_iounmap
+static inline int arch_iounmap(void __iomem *addr)
+{
+	return 0;
+}
+#endif
+
 void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, unsigned long prot);
 void iounmap(volatile void __iomem *addr);
 
diff --git a/mm/ioremap.c b/mm/ioremap.c
index 7cb9996b0c12..fac7f23b8c4b 100644
--- a/mm/ioremap.c
+++ b/mm/ioremap.c
@@ -16,6 +16,7 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, unsigned long pro
 	unsigned long offset, vaddr;
 	phys_addr_t last_addr;
 	struct vm_struct *area;
+	void __iomem *base;
 
 	/* Disallow wrap-around or zero size */
 	last_addr = phys_addr + size - 1;
@@ -27,8 +28,13 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, unsigned long pro
 	phys_addr -= offset;
 	size = PAGE_ALIGN(size + offset);
 
-	area = get_vm_area_caller(size, VM_IOREMAP,
-			__builtin_return_address(0));
+	base = arch_ioremap(phys_addr, size, prot);
+	if (IS_ERR(base))
+		return NULL;
+	else if (base)
+		return base;
+
+	area = get_vm_area_caller(size, VM_IOREMAP, __builtin_return_address(0));
 	if (!area)
 		return NULL;
 	vaddr = (unsigned long)area->addr;
@@ -45,6 +51,11 @@ EXPORT_SYMBOL(ioremap_prot);
 
 void iounmap(volatile void __iomem *addr)
 {
-	vunmap((void *)((unsigned long)addr & PAGE_MASK));
+	void __iomem *vaddr = (void __iomem *)((unsigned long)addr & PAGE_MASK);
+
+	if (arch_iounmap(vaddr))
+		return;
+
+	vunmap(vaddr);
 }
 EXPORT_SYMBOL(iounmap);
-- 
2.35.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v3 5/6] arm64: mm: Convert to GENERIC_IOREMAP
  2022-05-19  8:25 ` Kefeng Wang
@ 2022-05-19  8:25   ` Kefeng Wang
  -1 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-19  8:25 UTC (permalink / raw)
  To: catalin.marinas, will, akpm, linux-arm-kernel, linux-kernel
  Cc: linux-mm, hch, arnd, anshuman.khandual, Kefeng Wang

Add hook for arm64's special operation when ioremap() and iounmap(),
then ioremap_wc/np/cache is converted to use ioremap_prot()
from GENERIC_IOREMAP, update the Copyright and kill the unused
inclusions.

Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 arch/arm64/Kconfig          |  1 +
 arch/arm64/include/asm/io.h | 20 ++++++---
 arch/arm64/kernel/acpi.c    |  2 +-
 arch/arm64/mm/ioremap.c     | 85 +++++--------------------------------
 4 files changed, 27 insertions(+), 81 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 20ea89d9ac2f..56673209fdb9 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -123,6 +123,7 @@ config ARM64
 	select GENERIC_CPU_VULNERABILITIES
 	select GENERIC_EARLY_IOREMAP
 	select GENERIC_IDLE_POLL_SETUP
+	select GENERIC_IOREMAP
 	select GENERIC_IRQ_IPI
 	select GENERIC_IRQ_PROBE
 	select GENERIC_IRQ_SHOW
diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h
index 3995652daf81..9ba9fc9a6446 100644
--- a/arch/arm64/include/asm/io.h
+++ b/arch/arm64/include/asm/io.h
@@ -163,13 +163,21 @@ extern void __memset_io(volatile void __iomem *, int, size_t);
 /*
  * I/O memory mapping functions.
  */
-extern void __iomem *__ioremap(phys_addr_t phys_addr, size_t size, pgprot_t prot);
-extern void iounmap(volatile void __iomem *addr);
-extern void __iomem *ioremap_cache(phys_addr_t phys_addr, size_t size);
 
-#define ioremap(addr, size)		__ioremap((addr), (size), __pgprot(PROT_DEVICE_nGnRE))
-#define ioremap_wc(addr, size)		__ioremap((addr), (size), __pgprot(PROT_NORMAL_NC))
-#define ioremap_np(addr, size)		__ioremap((addr), (size), __pgprot(PROT_DEVICE_nGnRnE))
+void __iomem *arch_ioremap(phys_addr_t phys_addr, size_t size, unsigned long prot);
+#define arch_ioremap arch_ioremap
+
+int arch_iounmap(void __iomem *addr);
+#define arch_iounmap arch_iounmap
+
+#define _PAGE_IOREMAP PROT_DEVICE_nGnRE
+
+#define ioremap_wc(addr, size)		ioremap_prot((addr), (size), PROT_NORMAL_NC)
+#define ioremap_np(addr, size)		ioremap_prot((addr), (size), PROT_DEVICE_nGnRnE)
+#define ioremap_cache(addr, size) ({							\
+	pfn_is_map_memory(__phys_to_pfn(addr)) ?					\
+	(void __iomem *)__phys_to_virt(addr) : ioremap_prot(addr, size, PROT_NORMAL);	\
+})
 
 /*
  * io{read,write}{16,32,64}be() macros
diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
index e4dea8db6924..a5a256e3f9fe 100644
--- a/arch/arm64/kernel/acpi.c
+++ b/arch/arm64/kernel/acpi.c
@@ -351,7 +351,7 @@ void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
 				prot = __acpi_get_writethrough_mem_attribute();
 		}
 	}
-	return __ioremap(phys, size, prot);
+	return ioremap_prot(phys, size, pgprot_val(prot));
 }
 
 /*
diff --git a/arch/arm64/mm/ioremap.c b/arch/arm64/mm/ioremap.c
index b21f91cd830d..5174dcc576d8 100644
--- a/arch/arm64/mm/ioremap.c
+++ b/arch/arm64/mm/ioremap.c
@@ -1,96 +1,33 @@
 // SPDX-License-Identifier: GPL-2.0-only
-/*
- * Based on arch/arm/mm/ioremap.c
- *
- * (C) Copyright 1995 1996 Linus Torvalds
- * Hacked for ARM by Phil Blundell <philb@gnu.org>
- * Hacked to allow all architectures to build, and various cleanups
- * by Russell King
- * Copyright (C) 2012 ARM Ltd.
- */
 
-#include <linux/export.h>
 #include <linux/mm.h>
 #include <linux/vmalloc.h>
 #include <linux/io.h>
 
-#include <asm/fixmap.h>
-#include <asm/tlbflush.h>
-
-static void __iomem *__ioremap_caller(phys_addr_t phys_addr, size_t size,
-				      pgprot_t prot, void *caller)
+void __iomem *arch_ioremap(phys_addr_t phys_addr, size_t size, unsigned long prot)
 {
-	unsigned long last_addr;
-	unsigned long offset = phys_addr & ~PAGE_MASK;
-	int err;
-	unsigned long addr;
-	struct vm_struct *area;
-
-	/*
-	 * Page align the mapping address and size, taking account of any
-	 * offset.
-	 */
-	phys_addr &= PAGE_MASK;
-	size = PAGE_ALIGN(size + offset);
+	unsigned long last_addr = phys_addr + size - 1;
+	int ret = -EINVAL;
 
-	/*
-	 * Don't allow wraparound, zero size or outside PHYS_MASK.
-	 */
-	last_addr = phys_addr + size - 1;
-	if (!size || last_addr < phys_addr || (last_addr & ~PHYS_MASK))
-		return NULL;
+	/* Don't allow outside PHYS_MASK */
+	if (last_addr & ~PHYS_MASK)
+		return IOMEM_ERR_PTR(ret);
 
-	/*
-	 * Don't allow RAM to be mapped.
-	 */
+	/* Don't allow RAM to be mapped. */
 	if (WARN_ON(pfn_is_map_memory(__phys_to_pfn(phys_addr))))
-		return NULL;
+		return IOMEM_ERR_PTR(ret);
 
-	area = get_vm_area_caller(size, VM_IOREMAP, caller);
-	if (!area)
-		return NULL;
-	addr = (unsigned long)area->addr;
-	area->phys_addr = phys_addr;
-
-	err = ioremap_page_range(addr, addr + size, phys_addr, prot);
-	if (err) {
-		vunmap((void *)addr);
-		return NULL;
-	}
-
-	return (void __iomem *)(offset + addr);
-}
-
-void __iomem *__ioremap(phys_addr_t phys_addr, size_t size, pgprot_t prot)
-{
-	return __ioremap_caller(phys_addr, size, prot,
-				__builtin_return_address(0));
+	return NULL;
 }
-EXPORT_SYMBOL(__ioremap);
 
-void iounmap(volatile void __iomem *io_addr)
+int arch_iounmap(void __iomem *addr)
 {
-	unsigned long addr = (unsigned long)io_addr & PAGE_MASK;
-
 	/*
 	 * We could get an address outside vmalloc range in case
 	 * of ioremap_cache() reusing a RAM mapping.
 	 */
-	if (is_vmalloc_addr((void *)addr))
-		vunmap((void *)addr);
-}
-EXPORT_SYMBOL(iounmap);
-
-void __iomem *ioremap_cache(phys_addr_t phys_addr, size_t size)
-{
-	/* For normal memory we already have a cacheable mapping. */
-	if (pfn_is_map_memory(__phys_to_pfn(phys_addr)))
-		return (void __iomem *)__phys_to_virt(phys_addr);
-
-	return __ioremap_caller(phys_addr, size, __pgprot(PROT_NORMAL),
-				__builtin_return_address(0));
+	return is_vmalloc_addr(addr) ? 0 : -EINVAL;
 }
-EXPORT_SYMBOL(ioremap_cache);
 
 /*
  * Must be called after early_fixmap_init
-- 
2.35.3


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

* [PATCH v3 5/6] arm64: mm: Convert to GENERIC_IOREMAP
@ 2022-05-19  8:25   ` Kefeng Wang
  0 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-19  8:25 UTC (permalink / raw)
  To: catalin.marinas, will, akpm, linux-arm-kernel, linux-kernel
  Cc: linux-mm, hch, arnd, anshuman.khandual, Kefeng Wang

Add hook for arm64's special operation when ioremap() and iounmap(),
then ioremap_wc/np/cache is converted to use ioremap_prot()
from GENERIC_IOREMAP, update the Copyright and kill the unused
inclusions.

Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 arch/arm64/Kconfig          |  1 +
 arch/arm64/include/asm/io.h | 20 ++++++---
 arch/arm64/kernel/acpi.c    |  2 +-
 arch/arm64/mm/ioremap.c     | 85 +++++--------------------------------
 4 files changed, 27 insertions(+), 81 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 20ea89d9ac2f..56673209fdb9 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -123,6 +123,7 @@ config ARM64
 	select GENERIC_CPU_VULNERABILITIES
 	select GENERIC_EARLY_IOREMAP
 	select GENERIC_IDLE_POLL_SETUP
+	select GENERIC_IOREMAP
 	select GENERIC_IRQ_IPI
 	select GENERIC_IRQ_PROBE
 	select GENERIC_IRQ_SHOW
diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h
index 3995652daf81..9ba9fc9a6446 100644
--- a/arch/arm64/include/asm/io.h
+++ b/arch/arm64/include/asm/io.h
@@ -163,13 +163,21 @@ extern void __memset_io(volatile void __iomem *, int, size_t);
 /*
  * I/O memory mapping functions.
  */
-extern void __iomem *__ioremap(phys_addr_t phys_addr, size_t size, pgprot_t prot);
-extern void iounmap(volatile void __iomem *addr);
-extern void __iomem *ioremap_cache(phys_addr_t phys_addr, size_t size);
 
-#define ioremap(addr, size)		__ioremap((addr), (size), __pgprot(PROT_DEVICE_nGnRE))
-#define ioremap_wc(addr, size)		__ioremap((addr), (size), __pgprot(PROT_NORMAL_NC))
-#define ioremap_np(addr, size)		__ioremap((addr), (size), __pgprot(PROT_DEVICE_nGnRnE))
+void __iomem *arch_ioremap(phys_addr_t phys_addr, size_t size, unsigned long prot);
+#define arch_ioremap arch_ioremap
+
+int arch_iounmap(void __iomem *addr);
+#define arch_iounmap arch_iounmap
+
+#define _PAGE_IOREMAP PROT_DEVICE_nGnRE
+
+#define ioremap_wc(addr, size)		ioremap_prot((addr), (size), PROT_NORMAL_NC)
+#define ioremap_np(addr, size)		ioremap_prot((addr), (size), PROT_DEVICE_nGnRnE)
+#define ioremap_cache(addr, size) ({							\
+	pfn_is_map_memory(__phys_to_pfn(addr)) ?					\
+	(void __iomem *)__phys_to_virt(addr) : ioremap_prot(addr, size, PROT_NORMAL);	\
+})
 
 /*
  * io{read,write}{16,32,64}be() macros
diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
index e4dea8db6924..a5a256e3f9fe 100644
--- a/arch/arm64/kernel/acpi.c
+++ b/arch/arm64/kernel/acpi.c
@@ -351,7 +351,7 @@ void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
 				prot = __acpi_get_writethrough_mem_attribute();
 		}
 	}
-	return __ioremap(phys, size, prot);
+	return ioremap_prot(phys, size, pgprot_val(prot));
 }
 
 /*
diff --git a/arch/arm64/mm/ioremap.c b/arch/arm64/mm/ioremap.c
index b21f91cd830d..5174dcc576d8 100644
--- a/arch/arm64/mm/ioremap.c
+++ b/arch/arm64/mm/ioremap.c
@@ -1,96 +1,33 @@
 // SPDX-License-Identifier: GPL-2.0-only
-/*
- * Based on arch/arm/mm/ioremap.c
- *
- * (C) Copyright 1995 1996 Linus Torvalds
- * Hacked for ARM by Phil Blundell <philb@gnu.org>
- * Hacked to allow all architectures to build, and various cleanups
- * by Russell King
- * Copyright (C) 2012 ARM Ltd.
- */
 
-#include <linux/export.h>
 #include <linux/mm.h>
 #include <linux/vmalloc.h>
 #include <linux/io.h>
 
-#include <asm/fixmap.h>
-#include <asm/tlbflush.h>
-
-static void __iomem *__ioremap_caller(phys_addr_t phys_addr, size_t size,
-				      pgprot_t prot, void *caller)
+void __iomem *arch_ioremap(phys_addr_t phys_addr, size_t size, unsigned long prot)
 {
-	unsigned long last_addr;
-	unsigned long offset = phys_addr & ~PAGE_MASK;
-	int err;
-	unsigned long addr;
-	struct vm_struct *area;
-
-	/*
-	 * Page align the mapping address and size, taking account of any
-	 * offset.
-	 */
-	phys_addr &= PAGE_MASK;
-	size = PAGE_ALIGN(size + offset);
+	unsigned long last_addr = phys_addr + size - 1;
+	int ret = -EINVAL;
 
-	/*
-	 * Don't allow wraparound, zero size or outside PHYS_MASK.
-	 */
-	last_addr = phys_addr + size - 1;
-	if (!size || last_addr < phys_addr || (last_addr & ~PHYS_MASK))
-		return NULL;
+	/* Don't allow outside PHYS_MASK */
+	if (last_addr & ~PHYS_MASK)
+		return IOMEM_ERR_PTR(ret);
 
-	/*
-	 * Don't allow RAM to be mapped.
-	 */
+	/* Don't allow RAM to be mapped. */
 	if (WARN_ON(pfn_is_map_memory(__phys_to_pfn(phys_addr))))
-		return NULL;
+		return IOMEM_ERR_PTR(ret);
 
-	area = get_vm_area_caller(size, VM_IOREMAP, caller);
-	if (!area)
-		return NULL;
-	addr = (unsigned long)area->addr;
-	area->phys_addr = phys_addr;
-
-	err = ioremap_page_range(addr, addr + size, phys_addr, prot);
-	if (err) {
-		vunmap((void *)addr);
-		return NULL;
-	}
-
-	return (void __iomem *)(offset + addr);
-}
-
-void __iomem *__ioremap(phys_addr_t phys_addr, size_t size, pgprot_t prot)
-{
-	return __ioremap_caller(phys_addr, size, prot,
-				__builtin_return_address(0));
+	return NULL;
 }
-EXPORT_SYMBOL(__ioremap);
 
-void iounmap(volatile void __iomem *io_addr)
+int arch_iounmap(void __iomem *addr)
 {
-	unsigned long addr = (unsigned long)io_addr & PAGE_MASK;
-
 	/*
 	 * We could get an address outside vmalloc range in case
 	 * of ioremap_cache() reusing a RAM mapping.
 	 */
-	if (is_vmalloc_addr((void *)addr))
-		vunmap((void *)addr);
-}
-EXPORT_SYMBOL(iounmap);
-
-void __iomem *ioremap_cache(phys_addr_t phys_addr, size_t size)
-{
-	/* For normal memory we already have a cacheable mapping. */
-	if (pfn_is_map_memory(__phys_to_pfn(phys_addr)))
-		return (void __iomem *)__phys_to_virt(phys_addr);
-
-	return __ioremap_caller(phys_addr, size, __pgprot(PROT_NORMAL),
-				__builtin_return_address(0));
+	return is_vmalloc_addr(addr) ? 0 : -EINVAL;
 }
-EXPORT_SYMBOL(ioremap_cache);
 
 /*
  * Must be called after early_fixmap_init
-- 
2.35.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v3 6/6] arm64: Add HAVE_IOREMAP_PROT support
  2022-05-19  8:25 ` Kefeng Wang
@ 2022-05-19  8:25   ` Kefeng Wang
  -1 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-19  8:25 UTC (permalink / raw)
  To: catalin.marinas, will, akpm, linux-arm-kernel, linux-kernel
  Cc: linux-mm, hch, arnd, anshuman.khandual, Kefeng Wang

With ioremap_prot() definition from generic ioremap, also move
pte_pgprot() from hugetlbpage.c into pgtable.h, then arm64 could
have HAVE_IOREMAP_PROT, which will enable generic_access_phys()
code, it is useful for debug, eg, gdb.

Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 .../features/vm/ioremap_prot/arch-support.txt          |  2 +-
 arch/arm64/Kconfig                                     |  1 +
 arch/arm64/include/asm/pgtable.h                       | 10 ++++++++++
 arch/arm64/mm/hugetlbpage.c                            | 10 ----------
 4 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/Documentation/features/vm/ioremap_prot/arch-support.txt b/Documentation/features/vm/ioremap_prot/arch-support.txt
index a6dcbe5f47b6..b39ad5d61216 100644
--- a/Documentation/features/vm/ioremap_prot/arch-support.txt
+++ b/Documentation/features/vm/ioremap_prot/arch-support.txt
@@ -9,7 +9,7 @@
     |       alpha: | TODO |
     |         arc: |  ok  |
     |         arm: | TODO |
-    |       arm64: | TODO |
+    |       arm64: |  ok  |
     |        csky: | TODO |
     |       h8300: | TODO |
     |     hexagon: | TODO |
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 56673209fdb9..5e5889049af0 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -186,6 +186,7 @@ config ARM64
 	select HAVE_FUNCTION_GRAPH_TRACER
 	select HAVE_GCC_PLUGINS
 	select HAVE_HW_BREAKPOINT if PERF_EVENTS
+	select HAVE_IOREMAP_PROT
 	select HAVE_IRQ_TIME_ACCOUNTING
 	select HAVE_KVM
 	select HAVE_NMI
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index dff2b483ea50..1402a2739024 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -402,6 +402,16 @@ static inline pgprot_t mk_pmd_sect_prot(pgprot_t prot)
 	return __pgprot((pgprot_val(prot) & ~PMD_TABLE_BIT) | PMD_TYPE_SECT);
 }
 
+/*
+ * Select all bits except the pfn
+ */
+static inline pgprot_t pte_pgprot(pte_t pte)
+{
+	unsigned long pfn = pte_pfn(pte);
+
+	return __pgprot(pte_val(pfn_pte(pfn, __pgprot(0))) ^ pte_val(pte));
+}
+
 #ifdef CONFIG_NUMA_BALANCING
 /*
  * See the comment in include/linux/pgtable.h
diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
index cbace1c9e137..38d03406f6aa 100644
--- a/arch/arm64/mm/hugetlbpage.c
+++ b/arch/arm64/mm/hugetlbpage.c
@@ -100,16 +100,6 @@ int pud_huge(pud_t pud)
 #endif
 }
 
-/*
- * Select all bits except the pfn
- */
-static inline pgprot_t pte_pgprot(pte_t pte)
-{
-	unsigned long pfn = pte_pfn(pte);
-
-	return __pgprot(pte_val(pfn_pte(pfn, __pgprot(0))) ^ pte_val(pte));
-}
-
 static int find_num_contig(struct mm_struct *mm, unsigned long addr,
 			   pte_t *ptep, size_t *pgsize)
 {
-- 
2.35.3


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

* [PATCH v3 6/6] arm64: Add HAVE_IOREMAP_PROT support
@ 2022-05-19  8:25   ` Kefeng Wang
  0 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-19  8:25 UTC (permalink / raw)
  To: catalin.marinas, will, akpm, linux-arm-kernel, linux-kernel
  Cc: linux-mm, hch, arnd, anshuman.khandual, Kefeng Wang

With ioremap_prot() definition from generic ioremap, also move
pte_pgprot() from hugetlbpage.c into pgtable.h, then arm64 could
have HAVE_IOREMAP_PROT, which will enable generic_access_phys()
code, it is useful for debug, eg, gdb.

Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 .../features/vm/ioremap_prot/arch-support.txt          |  2 +-
 arch/arm64/Kconfig                                     |  1 +
 arch/arm64/include/asm/pgtable.h                       | 10 ++++++++++
 arch/arm64/mm/hugetlbpage.c                            | 10 ----------
 4 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/Documentation/features/vm/ioremap_prot/arch-support.txt b/Documentation/features/vm/ioremap_prot/arch-support.txt
index a6dcbe5f47b6..b39ad5d61216 100644
--- a/Documentation/features/vm/ioremap_prot/arch-support.txt
+++ b/Documentation/features/vm/ioremap_prot/arch-support.txt
@@ -9,7 +9,7 @@
     |       alpha: | TODO |
     |         arc: |  ok  |
     |         arm: | TODO |
-    |       arm64: | TODO |
+    |       arm64: |  ok  |
     |        csky: | TODO |
     |       h8300: | TODO |
     |     hexagon: | TODO |
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 56673209fdb9..5e5889049af0 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -186,6 +186,7 @@ config ARM64
 	select HAVE_FUNCTION_GRAPH_TRACER
 	select HAVE_GCC_PLUGINS
 	select HAVE_HW_BREAKPOINT if PERF_EVENTS
+	select HAVE_IOREMAP_PROT
 	select HAVE_IRQ_TIME_ACCOUNTING
 	select HAVE_KVM
 	select HAVE_NMI
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index dff2b483ea50..1402a2739024 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -402,6 +402,16 @@ static inline pgprot_t mk_pmd_sect_prot(pgprot_t prot)
 	return __pgprot((pgprot_val(prot) & ~PMD_TABLE_BIT) | PMD_TYPE_SECT);
 }
 
+/*
+ * Select all bits except the pfn
+ */
+static inline pgprot_t pte_pgprot(pte_t pte)
+{
+	unsigned long pfn = pte_pfn(pte);
+
+	return __pgprot(pte_val(pfn_pte(pfn, __pgprot(0))) ^ pte_val(pte));
+}
+
 #ifdef CONFIG_NUMA_BALANCING
 /*
  * See the comment in include/linux/pgtable.h
diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
index cbace1c9e137..38d03406f6aa 100644
--- a/arch/arm64/mm/hugetlbpage.c
+++ b/arch/arm64/mm/hugetlbpage.c
@@ -100,16 +100,6 @@ int pud_huge(pud_t pud)
 #endif
 }
 
-/*
- * Select all bits except the pfn
- */
-static inline pgprot_t pte_pgprot(pte_t pte)
-{
-	unsigned long pfn = pte_pfn(pte);
-
-	return __pgprot(pte_val(pfn_pte(pfn, __pgprot(0))) ^ pte_val(pte));
-}
-
 static int find_num_contig(struct mm_struct *mm, unsigned long addr,
 			   pte_t *ptep, size_t *pgsize)
 {
-- 
2.35.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 1/6] ARM: mm: kill unused runtime hook arch_iounmap()
  2022-05-19  8:25   ` Kefeng Wang
@ 2022-05-19  8:51     ` Anshuman Khandual
  -1 siblings, 0 replies; 51+ messages in thread
From: Anshuman Khandual @ 2022-05-19  8:51 UTC (permalink / raw)
  To: Kefeng Wang, catalin.marinas, will, akpm, linux-arm-kernel, linux-kernel
  Cc: linux-mm, hch, arnd, Russell King



On 5/19/22 13:55, Kefeng Wang wrote:
> Since the following commits,
> 
> v5.4
>   commit 59d3ae9a5bf6 ("ARM: remove Intel iop33x and iop13xx support")
> v5.11
>   commit 3e3f354bc383 ("ARM: remove ebsa110 platform")
> 
> The runtime hook arch_iounmap() on ARM is useless, kill arch_iounmap()
> and __iounmap(), and the naming of arch_iounmap will be used in 
> GENERIC_IOREMAP with the later patch.
> 
> Cc: Russell King <linux@armlinux.org.uk>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

LGTM, also builds on multiple arm configs but will let Russel take a look.

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

* Re: [PATCH v3 1/6] ARM: mm: kill unused runtime hook arch_iounmap()
@ 2022-05-19  8:51     ` Anshuman Khandual
  0 siblings, 0 replies; 51+ messages in thread
From: Anshuman Khandual @ 2022-05-19  8:51 UTC (permalink / raw)
  To: Kefeng Wang, catalin.marinas, will, akpm, linux-arm-kernel, linux-kernel
  Cc: linux-mm, hch, arnd, Russell King



On 5/19/22 13:55, Kefeng Wang wrote:
> Since the following commits,
> 
> v5.4
>   commit 59d3ae9a5bf6 ("ARM: remove Intel iop33x and iop13xx support")
> v5.11
>   commit 3e3f354bc383 ("ARM: remove ebsa110 platform")
> 
> The runtime hook arch_iounmap() on ARM is useless, kill arch_iounmap()
> and __iounmap(), and the naming of arch_iounmap will be used in 
> GENERIC_IOREMAP with the later patch.
> 
> Cc: Russell King <linux@armlinux.org.uk>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

LGTM, also builds on multiple arm configs but will let Russel take a look.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
  2022-05-19  8:25   ` Kefeng Wang
@ 2022-05-19 18:52     ` Andrew Morton
  -1 siblings, 0 replies; 51+ messages in thread
From: Andrew Morton @ 2022-05-19 18:52 UTC (permalink / raw)
  To: Kefeng Wang
  Cc: catalin.marinas, will, linux-arm-kernel, linux-kernel, linux-mm,
	hch, arnd, anshuman.khandual

On Thu, 19 May 2022 16:25:50 +0800 Kefeng Wang <wangkefeng.wang@huawei.com> wrote:

> Add special hook for architecture to verify or setup addr, size
> or prot when ioremap() or iounmap(), which will make the generic
> ioremap more useful.
> 
>   arch_ioremap() return a pointer,
>     - IS_ERR means return an error
>     - NULL means continue to remap
>     - a non-NULL, non-IS_ERR pointer is directly returned
>   arch_iounmap() return a int value,
>     - 0 means continue to vunmap
>     - error code means skip vunmap and return directly
> 
> ...
>
> --- a/include/asm-generic/io.h
> +++ b/include/asm-generic/io.h
> @@ -964,6 +964,30 @@ static inline void iounmap(volatile void __iomem *addr)
>  #elif defined(CONFIG_GENERIC_IOREMAP)
>  #include <linux/pgtable.h>
>  
> +/*
> + * Arch code can implement the following two special hooks when using GENERIC_IOREMAP
> + * arch_ioremap() return a pointer,
> + *   - IS_ERR means return an error
> + *   - NULL means continue to remap
> + *   - a non-NULL, non-IS_ERR pointer is returned directly
> + * arch_iounmap() return a int,
> + *   - 0 means continue to vunmap
> + *   - error code means skip vunmap and return directly
> + */
> +#ifndef arch_ioremap
> +static inline void __iomem *arch_ioremap(phys_addr_t phys_addr, size_t size, unsigned long prot)
> +{
> +	return NULL;
> +}

Maybe should do

	#define arch_ioremap arch_ioremap

here

> +#endif
> +
> +#ifndef arch_iounmap
> +static inline int arch_iounmap(void __iomem *addr)
> +{
> +	return 0;
> +}

and here.

It shouldn't matter a lot because this file has inclusion guards. 
However it seems tidier and perhaps other code will want to know
whether this was defined.  Dunno.


Otherwise, 

Acked-by: Andrew Morton <akpm@linux-foundation.org>

Please take this patch and [2/6] and [3/6] via the appropriate arm tree.


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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
@ 2022-05-19 18:52     ` Andrew Morton
  0 siblings, 0 replies; 51+ messages in thread
From: Andrew Morton @ 2022-05-19 18:52 UTC (permalink / raw)
  To: Kefeng Wang
  Cc: catalin.marinas, will, linux-arm-kernel, linux-kernel, linux-mm,
	hch, arnd, anshuman.khandual

On Thu, 19 May 2022 16:25:50 +0800 Kefeng Wang <wangkefeng.wang@huawei.com> wrote:

> Add special hook for architecture to verify or setup addr, size
> or prot when ioremap() or iounmap(), which will make the generic
> ioremap more useful.
> 
>   arch_ioremap() return a pointer,
>     - IS_ERR means return an error
>     - NULL means continue to remap
>     - a non-NULL, non-IS_ERR pointer is directly returned
>   arch_iounmap() return a int value,
>     - 0 means continue to vunmap
>     - error code means skip vunmap and return directly
> 
> ...
>
> --- a/include/asm-generic/io.h
> +++ b/include/asm-generic/io.h
> @@ -964,6 +964,30 @@ static inline void iounmap(volatile void __iomem *addr)
>  #elif defined(CONFIG_GENERIC_IOREMAP)
>  #include <linux/pgtable.h>
>  
> +/*
> + * Arch code can implement the following two special hooks when using GENERIC_IOREMAP
> + * arch_ioremap() return a pointer,
> + *   - IS_ERR means return an error
> + *   - NULL means continue to remap
> + *   - a non-NULL, non-IS_ERR pointer is returned directly
> + * arch_iounmap() return a int,
> + *   - 0 means continue to vunmap
> + *   - error code means skip vunmap and return directly
> + */
> +#ifndef arch_ioremap
> +static inline void __iomem *arch_ioremap(phys_addr_t phys_addr, size_t size, unsigned long prot)
> +{
> +	return NULL;
> +}

Maybe should do

	#define arch_ioremap arch_ioremap

here

> +#endif
> +
> +#ifndef arch_iounmap
> +static inline int arch_iounmap(void __iomem *addr)
> +{
> +	return 0;
> +}

and here.

It shouldn't matter a lot because this file has inclusion guards. 
However it seems tidier and perhaps other code will want to know
whether this was defined.  Dunno.


Otherwise, 

Acked-by: Andrew Morton <akpm@linux-foundation.org>

Please take this patch and [2/6] and [3/6] via the appropriate arm tree.


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
  2022-05-19 18:52     ` Andrew Morton
@ 2022-05-20  1:22       ` Kefeng Wang
  -1 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-20  1:22 UTC (permalink / raw)
  To: Andrew Morton
  Cc: catalin.marinas, will, linux-arm-kernel, linux-kernel, linux-mm,
	hch, arnd, anshuman.khandual


On 2022/5/20 2:52, Andrew Morton wrote:
> On Thu, 19 May 2022 16:25:50 +0800 Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>
>> Add special hook for architecture to verify or setup addr, size
>> or prot when ioremap() or iounmap(), which will make the generic
>> ioremap more useful.
>>
>>    arch_ioremap() return a pointer,
>>      - IS_ERR means return an error
>>      - NULL means continue to remap
>>      - a non-NULL, non-IS_ERR pointer is directly returned
>>    arch_iounmap() return a int value,
>>      - 0 means continue to vunmap
>>      - error code means skip vunmap and return directly
>>
>> ...
>>
>> --- a/include/asm-generic/io.h
>> +++ b/include/asm-generic/io.h
>> @@ -964,6 +964,30 @@ static inline void iounmap(volatile void __iomem *addr)
>>   #elif defined(CONFIG_GENERIC_IOREMAP)
>>   #include <linux/pgtable.h>
>>   
>> +/*
>> + * Arch code can implement the following two special hooks when using GENERIC_IOREMAP
>> + * arch_ioremap() return a pointer,
>> + *   - IS_ERR means return an error
>> + *   - NULL means continue to remap
>> + *   - a non-NULL, non-IS_ERR pointer is returned directly
>> + * arch_iounmap() return a int,
>> + *   - 0 means continue to vunmap
>> + *   - error code means skip vunmap and return directly
>> + */
>> +#ifndef arch_ioremap
>> +static inline void __iomem *arch_ioremap(phys_addr_t phys_addr, size_t size, unsigned long prot)
>> +{
>> +	return NULL;
>> +}
> Maybe should do
>
> 	#define arch_ioremap arch_ioremap
>
> here
>
>> +#endif
>> +
>> +#ifndef arch_iounmap
>> +static inline int arch_iounmap(void __iomem *addr)
>> +{
>> +	return 0;
>> +}
> and here.
>
> It shouldn't matter a lot because this file has inclusion guards.
> However it seems tidier and perhaps other code will want to know
> whether this was defined.  Dunno.
>
Oh, forget to add the define part, thanks Andrew.

Hi Catalin, could you help to involve them when taking them, many thanks.

> Otherwise,
>
> Acked-by: Andrew Morton <akpm@linux-foundation.org>
>
> Please take this patch and [2/6] and [3/6] via the appropriate arm tree.
>
> .

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
@ 2022-05-20  1:22       ` Kefeng Wang
  0 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-20  1:22 UTC (permalink / raw)
  To: Andrew Morton
  Cc: catalin.marinas, will, linux-arm-kernel, linux-kernel, linux-mm,
	hch, arnd, anshuman.khandual


On 2022/5/20 2:52, Andrew Morton wrote:
> On Thu, 19 May 2022 16:25:50 +0800 Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>
>> Add special hook for architecture to verify or setup addr, size
>> or prot when ioremap() or iounmap(), which will make the generic
>> ioremap more useful.
>>
>>    arch_ioremap() return a pointer,
>>      - IS_ERR means return an error
>>      - NULL means continue to remap
>>      - a non-NULL, non-IS_ERR pointer is directly returned
>>    arch_iounmap() return a int value,
>>      - 0 means continue to vunmap
>>      - error code means skip vunmap and return directly
>>
>> ...
>>
>> --- a/include/asm-generic/io.h
>> +++ b/include/asm-generic/io.h
>> @@ -964,6 +964,30 @@ static inline void iounmap(volatile void __iomem *addr)
>>   #elif defined(CONFIG_GENERIC_IOREMAP)
>>   #include <linux/pgtable.h>
>>   
>> +/*
>> + * Arch code can implement the following two special hooks when using GENERIC_IOREMAP
>> + * arch_ioremap() return a pointer,
>> + *   - IS_ERR means return an error
>> + *   - NULL means continue to remap
>> + *   - a non-NULL, non-IS_ERR pointer is returned directly
>> + * arch_iounmap() return a int,
>> + *   - 0 means continue to vunmap
>> + *   - error code means skip vunmap and return directly
>> + */
>> +#ifndef arch_ioremap
>> +static inline void __iomem *arch_ioremap(phys_addr_t phys_addr, size_t size, unsigned long prot)
>> +{
>> +	return NULL;
>> +}
> Maybe should do
>
> 	#define arch_ioremap arch_ioremap
>
> here
>
>> +#endif
>> +
>> +#ifndef arch_iounmap
>> +static inline int arch_iounmap(void __iomem *addr)
>> +{
>> +	return 0;
>> +}
> and here.
>
> It shouldn't matter a lot because this file has inclusion guards.
> However it seems tidier and perhaps other code will want to know
> whether this was defined.  Dunno.
>
Oh, forget to add the define part, thanks Andrew.

Hi Catalin, could you help to involve them when taking them, many thanks.

> Otherwise,
>
> Acked-by: Andrew Morton <akpm@linux-foundation.org>
>
> Please take this patch and [2/6] and [3/6] via the appropriate arm tree.
>
> .

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 1/6] ARM: mm: kill unused runtime hook arch_iounmap()
  2022-05-19  8:25   ` Kefeng Wang
@ 2022-05-20 15:28     ` Catalin Marinas
  -1 siblings, 0 replies; 51+ messages in thread
From: Catalin Marinas @ 2022-05-20 15:28 UTC (permalink / raw)
  To: Kefeng Wang, Russell King
  Cc: will, akpm, linux-arm-kernel, linux-kernel, linux-mm, hch, arnd,
	anshuman.khandual

Hi Russell,

On Thu, May 19, 2022 at 04:25:47PM +0800, Kefeng Wang wrote:
> Since the following commits,
> 
> v5.4
>   commit 59d3ae9a5bf6 ("ARM: remove Intel iop33x and iop13xx support")
> v5.11
>   commit 3e3f354bc383 ("ARM: remove ebsa110 platform")
> 
> The runtime hook arch_iounmap() on ARM is useless, kill arch_iounmap()
> and __iounmap(), and the naming of arch_iounmap will be used in 
> GENERIC_IOREMAP with the later patch.
> 
> Cc: Russell King <linux@armlinux.org.uk>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

Probably too late for this merging window but are you ok for this patch
to go in via the arm64 tree (together with the rest of the series)?

Alternatively it could go into your patch system and hopefully land in
5.19 so that we can take the rest for 5.20.

Thanks.

-- 
Catalin

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

* Re: [PATCH v3 1/6] ARM: mm: kill unused runtime hook arch_iounmap()
@ 2022-05-20 15:28     ` Catalin Marinas
  0 siblings, 0 replies; 51+ messages in thread
From: Catalin Marinas @ 2022-05-20 15:28 UTC (permalink / raw)
  To: Kefeng Wang, Russell King
  Cc: will, akpm, linux-arm-kernel, linux-kernel, linux-mm, hch, arnd,
	anshuman.khandual

Hi Russell,

On Thu, May 19, 2022 at 04:25:47PM +0800, Kefeng Wang wrote:
> Since the following commits,
> 
> v5.4
>   commit 59d3ae9a5bf6 ("ARM: remove Intel iop33x and iop13xx support")
> v5.11
>   commit 3e3f354bc383 ("ARM: remove ebsa110 platform")
> 
> The runtime hook arch_iounmap() on ARM is useless, kill arch_iounmap()
> and __iounmap(), and the naming of arch_iounmap will be used in 
> GENERIC_IOREMAP with the later patch.
> 
> Cc: Russell King <linux@armlinux.org.uk>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

Probably too late for this merging window but are you ok for this patch
to go in via the arm64 tree (together with the rest of the series)?

Alternatively it could go into your patch system and hopefully land in
5.19 so that we can take the rest for 5.20.

Thanks.

-- 
Catalin

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 1/6] ARM: mm: kill unused runtime hook arch_iounmap()
  2022-05-19  8:25   ` Kefeng Wang
@ 2022-05-21 20:30     ` Arnd Bergmann
  -1 siblings, 0 replies; 51+ messages in thread
From: Arnd Bergmann @ 2022-05-21 20:30 UTC (permalink / raw)
  To: Kefeng Wang
  Cc: Catalin Marinas, Will Deacon, Andrew Morton, Linux ARM,
	Linux Kernel Mailing List, Linux-MM, Christoph Hellwig,
	Arnd Bergmann, Anshuman Khandual, Russell King

On Thu, May 19, 2022 at 10:25 AM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>
> Since the following commits,
>
> v5.4
>   commit 59d3ae9a5bf6 ("ARM: remove Intel iop33x and iop13xx support")
> v5.11
>   commit 3e3f354bc383 ("ARM: remove ebsa110 platform")
>
> The runtime hook arch_iounmap() on ARM is useless, kill arch_iounmap()
> and __iounmap(), and the naming of arch_iounmap will be used in
> GENERIC_IOREMAP with the later patch.
>
> Cc: Russell King <linux@armlinux.org.uk>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

I had a very similar patch prototyped recently,

Reviewed-by: Arnd Bergmann <arnd@arndb.de>

It would be nice to do the same for arch_ioremap_caller(), which now
has two implementations left for mvebu and imx3, previously we had
more for iop13xx, ebsa110, ixp4xx and msm.

For both armada37x/380 and imx3, the only purpose is to override
the mtype argument, and it feels like there should be a better way
to do this, though I'm not sure what that is. Having an overridable
mtype value per 256MB section of physical address space would
be sufficient for both, but I don't know if that's any better than what
we have.

        Arnd

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

* Re: [PATCH v3 1/6] ARM: mm: kill unused runtime hook arch_iounmap()
@ 2022-05-21 20:30     ` Arnd Bergmann
  0 siblings, 0 replies; 51+ messages in thread
From: Arnd Bergmann @ 2022-05-21 20:30 UTC (permalink / raw)
  To: Kefeng Wang
  Cc: Catalin Marinas, Will Deacon, Andrew Morton, Linux ARM,
	Linux Kernel Mailing List, Linux-MM, Christoph Hellwig,
	Arnd Bergmann, Anshuman Khandual, Russell King

On Thu, May 19, 2022 at 10:25 AM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>
> Since the following commits,
>
> v5.4
>   commit 59d3ae9a5bf6 ("ARM: remove Intel iop33x and iop13xx support")
> v5.11
>   commit 3e3f354bc383 ("ARM: remove ebsa110 platform")
>
> The runtime hook arch_iounmap() on ARM is useless, kill arch_iounmap()
> and __iounmap(), and the naming of arch_iounmap will be used in
> GENERIC_IOREMAP with the later patch.
>
> Cc: Russell King <linux@armlinux.org.uk>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

I had a very similar patch prototyped recently,

Reviewed-by: Arnd Bergmann <arnd@arndb.de>

It would be nice to do the same for arch_ioremap_caller(), which now
has two implementations left for mvebu and imx3, previously we had
more for iop13xx, ebsa110, ixp4xx and msm.

For both armada37x/380 and imx3, the only purpose is to override
the mtype argument, and it feels like there should be a better way
to do this, though I'm not sure what that is. Having an overridable
mtype value per 256MB section of physical address space would
be sufficient for both, but I don't know if that's any better than what
we have.

        Arnd

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
  2022-05-19 18:52     ` Andrew Morton
@ 2022-05-23  3:57       ` Anshuman Khandual
  -1 siblings, 0 replies; 51+ messages in thread
From: Anshuman Khandual @ 2022-05-23  3:57 UTC (permalink / raw)
  To: Andrew Morton, Kefeng Wang
  Cc: catalin.marinas, will, linux-arm-kernel, linux-kernel, linux-mm,
	hch, arnd



On 5/20/22 00:22, Andrew Morton wrote:
> On Thu, 19 May 2022 16:25:50 +0800 Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
> 
>> Add special hook for architecture to verify or setup addr, size
>> or prot when ioremap() or iounmap(), which will make the generic
>> ioremap more useful.
>>
>>   arch_ioremap() return a pointer,
>>     - IS_ERR means return an error
>>     - NULL means continue to remap
>>     - a non-NULL, non-IS_ERR pointer is directly returned
>>   arch_iounmap() return a int value,
>>     - 0 means continue to vunmap
>>     - error code means skip vunmap and return directly
>>
>> ...
>>
>> --- a/include/asm-generic/io.h
>> +++ b/include/asm-generic/io.h
>> @@ -964,6 +964,30 @@ static inline void iounmap(volatile void __iomem *addr)
>>  #elif defined(CONFIG_GENERIC_IOREMAP)
>>  #include <linux/pgtable.h>
>>  
>> +/*
>> + * Arch code can implement the following two special hooks when using GENERIC_IOREMAP
>> + * arch_ioremap() return a pointer,
>> + *   - IS_ERR means return an error
>> + *   - NULL means continue to remap
>> + *   - a non-NULL, non-IS_ERR pointer is returned directly
>> + * arch_iounmap() return a int,
>> + *   - 0 means continue to vunmap
>> + *   - error code means skip vunmap and return directly
>> + */
>> +#ifndef arch_ioremap
>> +static inline void __iomem *arch_ioremap(phys_addr_t phys_addr, size_t size, unsigned long prot)
>> +{
>> +	return NULL;
>> +}
> 
> Maybe should do
> 
> 	#define arch_ioremap arch_ioremap
> 
> here
> 
>> +#endif
>> +
>> +#ifndef arch_iounmap
>> +static inline int arch_iounmap(void __iomem *addr)
>> +{
>> +	return 0;
>> +}
> 
> and here.
> 
> It shouldn't matter a lot because this file has inclusion guards. 
> However it seems tidier and perhaps other code will want to know
> whether this was defined.  Dunno.

+1, agreed.

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
@ 2022-05-23  3:57       ` Anshuman Khandual
  0 siblings, 0 replies; 51+ messages in thread
From: Anshuman Khandual @ 2022-05-23  3:57 UTC (permalink / raw)
  To: Andrew Morton, Kefeng Wang
  Cc: catalin.marinas, will, linux-arm-kernel, linux-kernel, linux-mm,
	hch, arnd



On 5/20/22 00:22, Andrew Morton wrote:
> On Thu, 19 May 2022 16:25:50 +0800 Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
> 
>> Add special hook for architecture to verify or setup addr, size
>> or prot when ioremap() or iounmap(), which will make the generic
>> ioremap more useful.
>>
>>   arch_ioremap() return a pointer,
>>     - IS_ERR means return an error
>>     - NULL means continue to remap
>>     - a non-NULL, non-IS_ERR pointer is directly returned
>>   arch_iounmap() return a int value,
>>     - 0 means continue to vunmap
>>     - error code means skip vunmap and return directly
>>
>> ...
>>
>> --- a/include/asm-generic/io.h
>> +++ b/include/asm-generic/io.h
>> @@ -964,6 +964,30 @@ static inline void iounmap(volatile void __iomem *addr)
>>  #elif defined(CONFIG_GENERIC_IOREMAP)
>>  #include <linux/pgtable.h>
>>  
>> +/*
>> + * Arch code can implement the following two special hooks when using GENERIC_IOREMAP
>> + * arch_ioremap() return a pointer,
>> + *   - IS_ERR means return an error
>> + *   - NULL means continue to remap
>> + *   - a non-NULL, non-IS_ERR pointer is returned directly
>> + * arch_iounmap() return a int,
>> + *   - 0 means continue to vunmap
>> + *   - error code means skip vunmap and return directly
>> + */
>> +#ifndef arch_ioremap
>> +static inline void __iomem *arch_ioremap(phys_addr_t phys_addr, size_t size, unsigned long prot)
>> +{
>> +	return NULL;
>> +}
> 
> Maybe should do
> 
> 	#define arch_ioremap arch_ioremap
> 
> here
> 
>> +#endif
>> +
>> +#ifndef arch_iounmap
>> +static inline int arch_iounmap(void __iomem *addr)
>> +{
>> +	return 0;
>> +}
> 
> and here.
> 
> It shouldn't matter a lot because this file has inclusion guards. 
> However it seems tidier and perhaps other code will want to know
> whether this was defined.  Dunno.

+1, agreed.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
  2022-05-19  8:25   ` Kefeng Wang
@ 2022-05-23 22:17     ` kernel test robot
  -1 siblings, 0 replies; 51+ messages in thread
From: kernel test robot @ 2022-05-23 22:17 UTC (permalink / raw)
  To: Kefeng Wang, catalin.marinas, will, akpm, linux-arm-kernel, linux-kernel
  Cc: kbuild-all, linux-mm, hch, arnd, anshuman.khandual, Kefeng Wang

Hi Kefeng,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on arm64/for-next/core]
[also build test WARNING on arnd-asm-generic/master akpm-mm/mm-everything linus/master v5.18 next-20220523]
[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]

url:    https://github.com/intel-lab-lkp/linux/commits/Kefeng-Wang/arm64-Cleanup-ioremap-and-support-ioremap_prot/20220519-161853
base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
config: csky-randconfig-s032-20220522 (https://download.01.org/0day-ci/archive/20220524/202205240657.BXxrhbgp-lkp@intel.com/config)
compiler: csky-linux-gcc (GCC) 11.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.4-dirty
        # https://github.com/intel-lab-lkp/linux/commit/eb83d30756d3b279ca58791d343dc821291818d0
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Kefeng-Wang/arm64-Cleanup-ioremap-and-support-ioremap_prot/20220519-161853
        git checkout eb83d30756d3b279ca58791d343dc821291818d0
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=csky SHELL=/bin/bash

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


sparse warnings: (new ones prefixed by >>)
>> mm/ioremap.c:59:16: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *addr @@     got void [noderef] __iomem *vaddr @@
   mm/ioremap.c:59:16: sparse:     expected void const *addr
   mm/ioremap.c:59:16: sparse:     got void [noderef] __iomem *vaddr

vim +59 mm/ioremap.c

    51	
    52	void iounmap(volatile void __iomem *addr)
    53	{
    54		void __iomem *vaddr = (void __iomem *)((unsigned long)addr & PAGE_MASK);
    55	
    56		if (arch_iounmap(vaddr))
    57			return;
    58	
  > 59		vunmap(vaddr);

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

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
@ 2022-05-23 22:17     ` kernel test robot
  0 siblings, 0 replies; 51+ messages in thread
From: kernel test robot @ 2022-05-23 22:17 UTC (permalink / raw)
  To: Kefeng Wang, catalin.marinas, will, akpm, linux-arm-kernel, linux-kernel
  Cc: kbuild-all, linux-mm, hch, arnd, anshuman.khandual, Kefeng Wang

Hi Kefeng,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on arm64/for-next/core]
[also build test WARNING on arnd-asm-generic/master akpm-mm/mm-everything linus/master v5.18 next-20220523]
[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]

url:    https://github.com/intel-lab-lkp/linux/commits/Kefeng-Wang/arm64-Cleanup-ioremap-and-support-ioremap_prot/20220519-161853
base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
config: csky-randconfig-s032-20220522 (https://download.01.org/0day-ci/archive/20220524/202205240657.BXxrhbgp-lkp@intel.com/config)
compiler: csky-linux-gcc (GCC) 11.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.4-dirty
        # https://github.com/intel-lab-lkp/linux/commit/eb83d30756d3b279ca58791d343dc821291818d0
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Kefeng-Wang/arm64-Cleanup-ioremap-and-support-ioremap_prot/20220519-161853
        git checkout eb83d30756d3b279ca58791d343dc821291818d0
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=csky SHELL=/bin/bash

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


sparse warnings: (new ones prefixed by >>)
>> mm/ioremap.c:59:16: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *addr @@     got void [noderef] __iomem *vaddr @@
   mm/ioremap.c:59:16: sparse:     expected void const *addr
   mm/ioremap.c:59:16: sparse:     got void [noderef] __iomem *vaddr

vim +59 mm/ioremap.c

    51	
    52	void iounmap(volatile void __iomem *addr)
    53	{
    54		void __iomem *vaddr = (void __iomem *)((unsigned long)addr & PAGE_MASK);
    55	
    56		if (arch_iounmap(vaddr))
    57			return;
    58	
  > 59		vunmap(vaddr);

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 1/6] ARM: mm: kill unused runtime hook arch_iounmap()
  2022-05-20 15:28     ` Catalin Marinas
@ 2022-05-24  2:03       ` Kefeng Wang
  -1 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-24  2:03 UTC (permalink / raw)
  To: Catalin Marinas, Russell King
  Cc: will, akpm, linux-arm-kernel, linux-kernel, linux-mm, hch, arnd,
	anshuman.khandual


On 2022/5/20 23:28, Catalin Marinas wrote:
> Hi Russell,
>
> On Thu, May 19, 2022 at 04:25:47PM +0800, Kefeng Wang wrote:
>> Since the following commits,
>>
>> v5.4
>>    commit 59d3ae9a5bf6 ("ARM: remove Intel iop33x and iop13xx support")
>> v5.11
>>    commit 3e3f354bc383 ("ARM: remove ebsa110 platform")
>>
>> The runtime hook arch_iounmap() on ARM is useless, kill arch_iounmap()
>> and __iounmap(), and the naming of arch_iounmap will be used in
>> GENERIC_IOREMAP with the later patch.
>>
>> Cc: Russell King <linux@armlinux.org.uk>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> Probably too late for this merging window but are you ok for this patch
> to go in via the arm64 tree (together with the rest of the series)?
>
> Alternatively it could go into your patch system and hopefully land in
> 5.19 so that we can take the rest for 5.20.
Russell, should I send it to patch system or let Catalin take it?
>
> Thanks.
>

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

* Re: [PATCH v3 1/6] ARM: mm: kill unused runtime hook arch_iounmap()
@ 2022-05-24  2:03       ` Kefeng Wang
  0 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-24  2:03 UTC (permalink / raw)
  To: Catalin Marinas, Russell King
  Cc: will, akpm, linux-arm-kernel, linux-kernel, linux-mm, hch, arnd,
	anshuman.khandual


On 2022/5/20 23:28, Catalin Marinas wrote:
> Hi Russell,
>
> On Thu, May 19, 2022 at 04:25:47PM +0800, Kefeng Wang wrote:
>> Since the following commits,
>>
>> v5.4
>>    commit 59d3ae9a5bf6 ("ARM: remove Intel iop33x and iop13xx support")
>> v5.11
>>    commit 3e3f354bc383 ("ARM: remove ebsa110 platform")
>>
>> The runtime hook arch_iounmap() on ARM is useless, kill arch_iounmap()
>> and __iounmap(), and the naming of arch_iounmap will be used in
>> GENERIC_IOREMAP with the later patch.
>>
>> Cc: Russell King <linux@armlinux.org.uk>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> Probably too late for this merging window but are you ok for this patch
> to go in via the arm64 tree (together with the rest of the series)?
>
> Alternatively it could go into your patch system and hopefully land in
> 5.19 so that we can take the rest for 5.20.
Russell, should I send it to patch system or let Catalin take it?
>
> Thanks.
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
  2022-05-23 22:17     ` kernel test robot
  (?)
@ 2022-05-24  9:48       ` Kefeng Wang
  -1 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-24  9:48 UTC (permalink / raw)
  To: kernel test robot, catalin.marinas, will, akpm, linux-arm-kernel,
	linux-kernel
  Cc: kbuild-all, linux-mm, hch, arnd, anshuman.khandual


On 2022/5/24 6:17, kernel test robot wrote:
> Hi Kefeng,
>
> Thank you for the patch! Perhaps something to improve:
>
> [auto build test WARNING on arm64/for-next/core]
> [also build test WARNING on arnd-asm-generic/master akpm-mm/mm-everything linus/master v5.18 next-20220523]
> [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]
>
> url:    https://github.com/intel-lab-lkp/linux/commits/Kefeng-Wang/arm64-Cleanup-ioremap-and-support-ioremap_prot/20220519-161853
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
> config: csky-randconfig-s032-20220522 (https://download.01.org/0day-ci/archive/20220524/202205240657.BXxrhbgp-lkp@intel.com/config)
> compiler: csky-linux-gcc (GCC) 11.3.0
> reproduce:
>          wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>          chmod +x ~/bin/make.cross
>          # apt-get install sparse
>          # sparse version: v0.6.4-dirty
>          # https://github.com/intel-lab-lkp/linux/commit/eb83d30756d3b279ca58791d343dc821291818d0
>          git remote add linux-review https://github.com/intel-lab-lkp/linux
>          git fetch --no-tags linux-review Kefeng-Wang/arm64-Cleanup-ioremap-and-support-ioremap_prot/20220519-161853
>          git checkout eb83d30756d3b279ca58791d343dc821291818d0
>          # save the config file
>          mkdir build_dir && cp config build_dir/.config
>          COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=csky SHELL=/bin/bash
>
> If you fix the issue, kindly add following tag where applicable
> Reported-by: kernel test robot <lkp@intel.com>
>
>
> sparse warnings: (new ones prefixed by >>)
>>> mm/ioremap.c:59:16: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *addr @@     got void [noderef] __iomem *vaddr @@
>     mm/ioremap.c:59:16: sparse:     expected void const *addr
>     mm/ioremap.c:59:16: sparse:     got void [noderef] __iomem *vaddr
>
> vim +59 mm/ioremap.c
>
>      51	
>      52	void iounmap(volatile void __iomem *addr)
>      53	{
>      54		void __iomem *vaddr = (void __iomem *)((unsigned long)addr & PAGE_MASK);
>      55	
>      56		if (arch_iounmap(vaddr))
>      57			return;
>      58	
>    > 59		vunmap(vaddr);

1) Will add generic "arch_ioremap/arch_iounmap define"

2) and change this to vunmap((void *)vaddr);

>

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
@ 2022-05-24  9:48       ` Kefeng Wang
  0 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-24  9:48 UTC (permalink / raw)
  To: kernel test robot, catalin.marinas, will, akpm, linux-arm-kernel,
	linux-kernel
  Cc: kbuild-all, linux-mm, hch, arnd, anshuman.khandual


On 2022/5/24 6:17, kernel test robot wrote:
> Hi Kefeng,
>
> Thank you for the patch! Perhaps something to improve:
>
> [auto build test WARNING on arm64/for-next/core]
> [also build test WARNING on arnd-asm-generic/master akpm-mm/mm-everything linus/master v5.18 next-20220523]
> [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]
>
> url:    https://github.com/intel-lab-lkp/linux/commits/Kefeng-Wang/arm64-Cleanup-ioremap-and-support-ioremap_prot/20220519-161853
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
> config: csky-randconfig-s032-20220522 (https://download.01.org/0day-ci/archive/20220524/202205240657.BXxrhbgp-lkp@intel.com/config)
> compiler: csky-linux-gcc (GCC) 11.3.0
> reproduce:
>          wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>          chmod +x ~/bin/make.cross
>          # apt-get install sparse
>          # sparse version: v0.6.4-dirty
>          # https://github.com/intel-lab-lkp/linux/commit/eb83d30756d3b279ca58791d343dc821291818d0
>          git remote add linux-review https://github.com/intel-lab-lkp/linux
>          git fetch --no-tags linux-review Kefeng-Wang/arm64-Cleanup-ioremap-and-support-ioremap_prot/20220519-161853
>          git checkout eb83d30756d3b279ca58791d343dc821291818d0
>          # save the config file
>          mkdir build_dir && cp config build_dir/.config
>          COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=csky SHELL=/bin/bash
>
> If you fix the issue, kindly add following tag where applicable
> Reported-by: kernel test robot <lkp@intel.com>
>
>
> sparse warnings: (new ones prefixed by >>)
>>> mm/ioremap.c:59:16: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *addr @@     got void [noderef] __iomem *vaddr @@
>     mm/ioremap.c:59:16: sparse:     expected void const *addr
>     mm/ioremap.c:59:16: sparse:     got void [noderef] __iomem *vaddr
>
> vim +59 mm/ioremap.c
>
>      51	
>      52	void iounmap(volatile void __iomem *addr)
>      53	{
>      54		void __iomem *vaddr = (void __iomem *)((unsigned long)addr & PAGE_MASK);
>      55	
>      56		if (arch_iounmap(vaddr))
>      57			return;
>      58	
>    > 59		vunmap(vaddr);

1) Will add generic "arch_ioremap/arch_iounmap define"

2) and change this to vunmap((void *)vaddr);

>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
@ 2022-05-24  9:48       ` Kefeng Wang
  0 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-24  9:48 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2645 bytes --]


On 2022/5/24 6:17, kernel test robot wrote:
> Hi Kefeng,
>
> Thank you for the patch! Perhaps something to improve:
>
> [auto build test WARNING on arm64/for-next/core]
> [also build test WARNING on arnd-asm-generic/master akpm-mm/mm-everything linus/master v5.18 next-20220523]
> [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]
>
> url:    https://github.com/intel-lab-lkp/linux/commits/Kefeng-Wang/arm64-Cleanup-ioremap-and-support-ioremap_prot/20220519-161853
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
> config: csky-randconfig-s032-20220522 (https://download.01.org/0day-ci/archive/20220524/202205240657.BXxrhbgp-lkp(a)intel.com/config)
> compiler: csky-linux-gcc (GCC) 11.3.0
> reproduce:
>          wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>          chmod +x ~/bin/make.cross
>          # apt-get install sparse
>          # sparse version: v0.6.4-dirty
>          # https://github.com/intel-lab-lkp/linux/commit/eb83d30756d3b279ca58791d343dc821291818d0
>          git remote add linux-review https://github.com/intel-lab-lkp/linux
>          git fetch --no-tags linux-review Kefeng-Wang/arm64-Cleanup-ioremap-and-support-ioremap_prot/20220519-161853
>          git checkout eb83d30756d3b279ca58791d343dc821291818d0
>          # save the config file
>          mkdir build_dir && cp config build_dir/.config
>          COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=csky SHELL=/bin/bash
>
> If you fix the issue, kindly add following tag where applicable
> Reported-by: kernel test robot <lkp@intel.com>
>
>
> sparse warnings: (new ones prefixed by >>)
>>> mm/ioremap.c:59:16: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *addr @@     got void [noderef] __iomem *vaddr @@
>     mm/ioremap.c:59:16: sparse:     expected void const *addr
>     mm/ioremap.c:59:16: sparse:     got void [noderef] __iomem *vaddr
>
> vim +59 mm/ioremap.c
>
>      51	
>      52	void iounmap(volatile void __iomem *addr)
>      53	{
>      54		void __iomem *vaddr = (void __iomem *)((unsigned long)addr & PAGE_MASK);
>      55	
>      56		if (arch_iounmap(vaddr))
>      57			return;
>      58	
>    > 59		vunmap(vaddr);

1) Will add generic "arch_ioremap/arch_iounmap define"

2) and change this to vunmap((void *)vaddr);

>

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
  2022-05-24  9:48       ` Kefeng Wang
  (?)
@ 2022-05-24 12:35         ` Arnd Bergmann
  -1 siblings, 0 replies; 51+ messages in thread
From: Arnd Bergmann @ 2022-05-24 12:35 UTC (permalink / raw)
  To: Kefeng Wang
  Cc: kernel test robot, Catalin Marinas, Will Deacon, Andrew Morton,
	Linux ARM, Linux Kernel Mailing List, kbuild-all, Linux-MM,
	Christoph Hellwig, Arnd Bergmann, Anshuman Khandual

On Tue, May 24, 2022 at 11:48 AM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
> >>> mm/ioremap.c:59:16: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *addr @@     got void [noderef] __iomem *vaddr @@
> >     mm/ioremap.c:59:16: sparse:     expected void const *addr
> >     mm/ioremap.c:59:16: sparse:     got void [noderef] __iomem *vaddr
> >
> > vim +59 mm/ioremap.c
> >
> >      51
> >      52       void iounmap(volatile void __iomem *addr)
> >      53       {
> >      54               void __iomem *vaddr = (void __iomem *)((unsigned long)addr & PAGE_MASK);
> >      55
> >      56               if (arch_iounmap(vaddr))
> >      57                       return;
> >      58
> >    > 59               vunmap(vaddr);
>
> 1) Will add generic "arch_ioremap/arch_iounmap define"
>
> 2) and change this to vunmap((void *)vaddr);

I think this need an extra __force to actually suppress the sparse
warning, as in

        vunmap((void __force *)vaddr);

Using __force is usually wrong, this is one of the exceptions, so
maybe add a comment
as well.

         Arnd

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
@ 2022-05-24 12:35         ` Arnd Bergmann
  0 siblings, 0 replies; 51+ messages in thread
From: Arnd Bergmann @ 2022-05-24 12:35 UTC (permalink / raw)
  To: Kefeng Wang
  Cc: kernel test robot, Catalin Marinas, Will Deacon, Andrew Morton,
	Linux ARM, Linux Kernel Mailing List, kbuild-all, Linux-MM,
	Christoph Hellwig, Arnd Bergmann, Anshuman Khandual

On Tue, May 24, 2022 at 11:48 AM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
> >>> mm/ioremap.c:59:16: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *addr @@     got void [noderef] __iomem *vaddr @@
> >     mm/ioremap.c:59:16: sparse:     expected void const *addr
> >     mm/ioremap.c:59:16: sparse:     got void [noderef] __iomem *vaddr
> >
> > vim +59 mm/ioremap.c
> >
> >      51
> >      52       void iounmap(volatile void __iomem *addr)
> >      53       {
> >      54               void __iomem *vaddr = (void __iomem *)((unsigned long)addr & PAGE_MASK);
> >      55
> >      56               if (arch_iounmap(vaddr))
> >      57                       return;
> >      58
> >    > 59               vunmap(vaddr);
>
> 1) Will add generic "arch_ioremap/arch_iounmap define"
>
> 2) and change this to vunmap((void *)vaddr);

I think this need an extra __force to actually suppress the sparse
warning, as in

        vunmap((void __force *)vaddr);

Using __force is usually wrong, this is one of the exceptions, so
maybe add a comment
as well.

         Arnd

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
@ 2022-05-24 12:35         ` Arnd Bergmann
  0 siblings, 0 replies; 51+ messages in thread
From: Arnd Bergmann @ 2022-05-24 12:35 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 1149 bytes --]

On Tue, May 24, 2022 at 11:48 AM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
> >>> mm/ioremap.c:59:16: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *addr @@     got void [noderef] __iomem *vaddr @@
> >     mm/ioremap.c:59:16: sparse:     expected void const *addr
> >     mm/ioremap.c:59:16: sparse:     got void [noderef] __iomem *vaddr
> >
> > vim +59 mm/ioremap.c
> >
> >      51
> >      52       void iounmap(volatile void __iomem *addr)
> >      53       {
> >      54               void __iomem *vaddr = (void __iomem *)((unsigned long)addr & PAGE_MASK);
> >      55
> >      56               if (arch_iounmap(vaddr))
> >      57                       return;
> >      58
> >    > 59               vunmap(vaddr);
>
> 1) Will add generic "arch_ioremap/arch_iounmap define"
>
> 2) and change this to vunmap((void *)vaddr);

I think this need an extra __force to actually suppress the sparse
warning, as in

        vunmap((void __force *)vaddr);

Using __force is usually wrong, this is one of the exceptions, so
maybe add a comment
as well.

         Arnd

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
  2022-05-19  8:25   ` Kefeng Wang
@ 2022-05-24 12:37     ` Arnd Bergmann
  -1 siblings, 0 replies; 51+ messages in thread
From: Arnd Bergmann @ 2022-05-24 12:37 UTC (permalink / raw)
  To: Kefeng Wang
  Cc: Catalin Marinas, Will Deacon, Andrew Morton, Linux ARM,
	Linux Kernel Mailing List, Linux-MM, Christoph Hellwig,
	Arnd Bergmann, Anshuman Khandual

On Thu, May 19, 2022 at 10:25 AM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>
> Add special hook for architecture to verify or setup addr, size
> or prot when ioremap() or iounmap(), which will make the generic
> ioremap more useful.
>
>   arch_ioremap() return a pointer,
>     - IS_ERR means return an error
>     - NULL means continue to remap
>     - a non-NULL, non-IS_ERR pointer is directly returned
>   arch_iounmap() return a int value,
>     - 0 means continue to vunmap
>     - error code means skip vunmap and return directly
>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

I don't really like interfaces that mix error pointers and NULL pointer
returns.

Would it be possible to have a special error code other than NULL
for the fallback case?

       arnd

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
@ 2022-05-24 12:37     ` Arnd Bergmann
  0 siblings, 0 replies; 51+ messages in thread
From: Arnd Bergmann @ 2022-05-24 12:37 UTC (permalink / raw)
  To: Kefeng Wang
  Cc: Catalin Marinas, Will Deacon, Andrew Morton, Linux ARM,
	Linux Kernel Mailing List, Linux-MM, Christoph Hellwig,
	Arnd Bergmann, Anshuman Khandual

On Thu, May 19, 2022 at 10:25 AM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>
> Add special hook for architecture to verify or setup addr, size
> or prot when ioremap() or iounmap(), which will make the generic
> ioremap more useful.
>
>   arch_ioremap() return a pointer,
>     - IS_ERR means return an error
>     - NULL means continue to remap
>     - a non-NULL, non-IS_ERR pointer is directly returned
>   arch_iounmap() return a int value,
>     - 0 means continue to vunmap
>     - error code means skip vunmap and return directly
>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

I don't really like interfaces that mix error pointers and NULL pointer
returns.

Would it be possible to have a special error code other than NULL
for the fallback case?

       arnd

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
  2022-05-24 12:35         ` Arnd Bergmann
  (?)
@ 2022-05-24 14:31           ` Kefeng Wang
  -1 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-24 14:31 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: kernel test robot, Catalin Marinas, Will Deacon, Andrew Morton,
	Linux ARM, Linux Kernel Mailing List, kbuild-all, Linux-MM,
	Christoph Hellwig, Anshuman Khandual


On 2022/5/24 20:35, Arnd Bergmann wrote:
> On Tue, May 24, 2022 at 11:48 AM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>>>>> mm/ioremap.c:59:16: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *addr @@     got void [noderef] __iomem *vaddr @@
>>>      mm/ioremap.c:59:16: sparse:     expected void const *addr
>>>      mm/ioremap.c:59:16: sparse:     got void [noderef] __iomem *vaddr
>>>
>>> vim +59 mm/ioremap.c
>>>
>>>       51
>>>       52       void iounmap(volatile void __iomem *addr)
>>>       53       {
>>>       54               void __iomem *vaddr = (void __iomem *)((unsigned long)addr & PAGE_MASK);
>>>       55
>>>       56               if (arch_iounmap(vaddr))
>>>       57                       return;
>>>       58
>>>     > 59               vunmap(vaddr);
>> 1) Will add generic "arch_ioremap/arch_iounmap define"
>>
>> 2) and change this to vunmap((void *)vaddr);
> I think this need an extra __force to actually suppress the sparse
> warning, as in
>
>          vunmap((void __force *)vaddr);
>
> Using __force is usually wrong, this is one of the exceptions, so
> maybe add a comment
> as well.
Right, I found this too, and  using  ___force in local, will update, thank.
>
>           Arnd
>
> .

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
@ 2022-05-24 14:31           ` Kefeng Wang
  0 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-24 14:31 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: kernel test robot, Catalin Marinas, Will Deacon, Andrew Morton,
	Linux ARM, Linux Kernel Mailing List, kbuild-all, Linux-MM,
	Christoph Hellwig, Anshuman Khandual


On 2022/5/24 20:35, Arnd Bergmann wrote:
> On Tue, May 24, 2022 at 11:48 AM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>>>>> mm/ioremap.c:59:16: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *addr @@     got void [noderef] __iomem *vaddr @@
>>>      mm/ioremap.c:59:16: sparse:     expected void const *addr
>>>      mm/ioremap.c:59:16: sparse:     got void [noderef] __iomem *vaddr
>>>
>>> vim +59 mm/ioremap.c
>>>
>>>       51
>>>       52       void iounmap(volatile void __iomem *addr)
>>>       53       {
>>>       54               void __iomem *vaddr = (void __iomem *)((unsigned long)addr & PAGE_MASK);
>>>       55
>>>       56               if (arch_iounmap(vaddr))
>>>       57                       return;
>>>       58
>>>     > 59               vunmap(vaddr);
>> 1) Will add generic "arch_ioremap/arch_iounmap define"
>>
>> 2) and change this to vunmap((void *)vaddr);
> I think this need an extra __force to actually suppress the sparse
> warning, as in
>
>          vunmap((void __force *)vaddr);
>
> Using __force is usually wrong, this is one of the exceptions, so
> maybe add a comment
> as well.
Right, I found this too, and  using  ___force in local, will update, thank.
>
>           Arnd
>
> .

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
@ 2022-05-24 14:31           ` Kefeng Wang
  0 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-24 14:31 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 1312 bytes --]


On 2022/5/24 20:35, Arnd Bergmann wrote:
> On Tue, May 24, 2022 at 11:48 AM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>>>>> mm/ioremap.c:59:16: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *addr @@     got void [noderef] __iomem *vaddr @@
>>>      mm/ioremap.c:59:16: sparse:     expected void const *addr
>>>      mm/ioremap.c:59:16: sparse:     got void [noderef] __iomem *vaddr
>>>
>>> vim +59 mm/ioremap.c
>>>
>>>       51
>>>       52       void iounmap(volatile void __iomem *addr)
>>>       53       {
>>>       54               void __iomem *vaddr = (void __iomem *)((unsigned long)addr & PAGE_MASK);
>>>       55
>>>       56               if (arch_iounmap(vaddr))
>>>       57                       return;
>>>       58
>>>     > 59               vunmap(vaddr);
>> 1) Will add generic "arch_ioremap/arch_iounmap define"
>>
>> 2) and change this to vunmap((void *)vaddr);
> I think this need an extra __force to actually suppress the sparse
> warning, as in
>
>          vunmap((void __force *)vaddr);
>
> Using __force is usually wrong, this is one of the exceptions, so
> maybe add a comment
> as well.
Right, I found this too, and  using  ___force in local, will update, thank.
>
>           Arnd
>
> .

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
  2022-05-24 12:37     ` Arnd Bergmann
@ 2022-05-24 14:32       ` Kefeng Wang
  -1 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-24 14:32 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Catalin Marinas, Will Deacon, Andrew Morton, Linux ARM,
	Linux Kernel Mailing List, Linux-MM, Christoph Hellwig,
	Anshuman Khandual


On 2022/5/24 20:37, Arnd Bergmann wrote:
> On Thu, May 19, 2022 at 10:25 AM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>> Add special hook for architecture to verify or setup addr, size
>> or prot when ioremap() or iounmap(), which will make the generic
>> ioremap more useful.
>>
>>    arch_ioremap() return a pointer,
>>      - IS_ERR means return an error
>>      - NULL means continue to remap
>>      - a non-NULL, non-IS_ERR pointer is directly returned
>>    arch_iounmap() return a int value,
>>      - 0 means continue to vunmap
>>      - error code means skip vunmap and return directly
>>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> I don't really like interfaces that mix error pointers and NULL pointer
> returns.
>
> Would it be possible to have a special error code other than NULL
> for the fallback case?
I don't find a good error code, maybe  ENOTSUPP, any better suggestion?
>
>         arnd
>
> .

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
@ 2022-05-24 14:32       ` Kefeng Wang
  0 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-24 14:32 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Catalin Marinas, Will Deacon, Andrew Morton, Linux ARM,
	Linux Kernel Mailing List, Linux-MM, Christoph Hellwig,
	Anshuman Khandual


On 2022/5/24 20:37, Arnd Bergmann wrote:
> On Thu, May 19, 2022 at 10:25 AM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>> Add special hook for architecture to verify or setup addr, size
>> or prot when ioremap() or iounmap(), which will make the generic
>> ioremap more useful.
>>
>>    arch_ioremap() return a pointer,
>>      - IS_ERR means return an error
>>      - NULL means continue to remap
>>      - a non-NULL, non-IS_ERR pointer is directly returned
>>    arch_iounmap() return a int value,
>>      - 0 means continue to vunmap
>>      - error code means skip vunmap and return directly
>>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> I don't really like interfaces that mix error pointers and NULL pointer
> returns.
>
> Would it be possible to have a special error code other than NULL
> for the fallback case?
I don't find a good error code, maybe  ENOTSUPP, any better suggestion?
>
>         arnd
>
> .

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
  2022-05-24 14:32       ` Kefeng Wang
@ 2022-05-24 14:47         ` Arnd Bergmann
  -1 siblings, 0 replies; 51+ messages in thread
From: Arnd Bergmann @ 2022-05-24 14:47 UTC (permalink / raw)
  To: Kefeng Wang
  Cc: Arnd Bergmann, Catalin Marinas, Will Deacon, Andrew Morton,
	Linux ARM, Linux Kernel Mailing List, Linux-MM,
	Christoph Hellwig, Anshuman Khandual

On Tue, May 24, 2022 at 4:32 PM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
> On 2022/5/24 20:37, Arnd Bergmann wrote:
> > On Thu, May 19, 2022 at 10:25 AM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
> >> Add special hook for architecture to verify or setup addr, size
> >> or prot when ioremap() or iounmap(), which will make the generic
> >> ioremap more useful.
> >>
> >>    arch_ioremap() return a pointer,
> >>      - IS_ERR means return an error
> >>      - NULL means continue to remap
> >>      - a non-NULL, non-IS_ERR pointer is directly returned
> >>    arch_iounmap() return a int value,
> >>      - 0 means continue to vunmap
> >>      - error code means skip vunmap and return directly
> >>
> >> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> > I don't really like interfaces that mix error pointers and NULL pointer
> > returns.
> >
> > Would it be possible to have a special error code other than NULL
> > for the fallback case?
>
> I don't find a good error code, maybe  ENOTSUPP, any better suggestion?

I had another look at the resulting arm64 function, and it appears that
you never actually return a non-error pointer here. If I didn't miss anything,
I think the best way would be to change the return type to just indicate
success or an error code, and drop the case of returning the actual result,
and changing the function name accordingly.

Would that work, or do you actually require returning an __iomem
token from somewhere else?

       Arnd

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
@ 2022-05-24 14:47         ` Arnd Bergmann
  0 siblings, 0 replies; 51+ messages in thread
From: Arnd Bergmann @ 2022-05-24 14:47 UTC (permalink / raw)
  To: Kefeng Wang
  Cc: Arnd Bergmann, Catalin Marinas, Will Deacon, Andrew Morton,
	Linux ARM, Linux Kernel Mailing List, Linux-MM,
	Christoph Hellwig, Anshuman Khandual

On Tue, May 24, 2022 at 4:32 PM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
> On 2022/5/24 20:37, Arnd Bergmann wrote:
> > On Thu, May 19, 2022 at 10:25 AM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
> >> Add special hook for architecture to verify or setup addr, size
> >> or prot when ioremap() or iounmap(), which will make the generic
> >> ioremap more useful.
> >>
> >>    arch_ioremap() return a pointer,
> >>      - IS_ERR means return an error
> >>      - NULL means continue to remap
> >>      - a non-NULL, non-IS_ERR pointer is directly returned
> >>    arch_iounmap() return a int value,
> >>      - 0 means continue to vunmap
> >>      - error code means skip vunmap and return directly
> >>
> >> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> > I don't really like interfaces that mix error pointers and NULL pointer
> > returns.
> >
> > Would it be possible to have a special error code other than NULL
> > for the fallback case?
>
> I don't find a good error code, maybe  ENOTSUPP, any better suggestion?

I had another look at the resulting arm64 function, and it appears that
you never actually return a non-error pointer here. If I didn't miss anything,
I think the best way would be to change the return type to just indicate
success or an error code, and drop the case of returning the actual result,
and changing the function name accordingly.

Would that work, or do you actually require returning an __iomem
token from somewhere else?

       Arnd

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
  2022-05-24 14:47         ` Arnd Bergmann
@ 2022-05-24 14:53           ` Kefeng Wang
  -1 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-24 14:53 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Catalin Marinas, Will Deacon, Andrew Morton, Linux ARM,
	Linux Kernel Mailing List, Linux-MM, Christoph Hellwig,
	Anshuman Khandual


On 2022/5/24 22:47, Arnd Bergmann wrote:
> On Tue, May 24, 2022 at 4:32 PM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>> On 2022/5/24 20:37, Arnd Bergmann wrote:
>>> On Thu, May 19, 2022 at 10:25 AM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>>>> Add special hook for architecture to verify or setup addr, size
>>>> or prot when ioremap() or iounmap(), which will make the generic
>>>> ioremap more useful.
>>>>
>>>>     arch_ioremap() return a pointer,
>>>>       - IS_ERR means return an error
>>>>       - NULL means continue to remap
>>>>       - a non-NULL, non-IS_ERR pointer is directly returned
>>>>     arch_iounmap() return a int value,
>>>>       - 0 means continue to vunmap
>>>>       - error code means skip vunmap and return directly
>>>>
>>>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
>>> I don't really like interfaces that mix error pointers and NULL pointer
>>> returns.
>>>
>>> Would it be possible to have a special error code other than NULL
>>> for the fallback case?
>> I don't find a good error code, maybe  ENOTSUPP, any better suggestion?
> I had another look at the resulting arm64 function, and it appears that
> you never actually return a non-error pointer here. If I didn't miss anything,
> I think the best way would be to change the return type to just indicate
> success or an error code, and drop the case of returning the actual result,
> and changing the function name accordingly.
>
> Would that work, or do you actually require returning an __iomem
> token from somewhere else?

Christoph  suggested in the first version,

https://lore.kernel.org/linux-arm-kernel/Ymq2uX%2FY15HlIpo7@infradead.org/

>         Arnd
>
> .

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
@ 2022-05-24 14:53           ` Kefeng Wang
  0 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-05-24 14:53 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Catalin Marinas, Will Deacon, Andrew Morton, Linux ARM,
	Linux Kernel Mailing List, Linux-MM, Christoph Hellwig,
	Anshuman Khandual


On 2022/5/24 22:47, Arnd Bergmann wrote:
> On Tue, May 24, 2022 at 4:32 PM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>> On 2022/5/24 20:37, Arnd Bergmann wrote:
>>> On Thu, May 19, 2022 at 10:25 AM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>>>> Add special hook for architecture to verify or setup addr, size
>>>> or prot when ioremap() or iounmap(), which will make the generic
>>>> ioremap more useful.
>>>>
>>>>     arch_ioremap() return a pointer,
>>>>       - IS_ERR means return an error
>>>>       - NULL means continue to remap
>>>>       - a non-NULL, non-IS_ERR pointer is directly returned
>>>>     arch_iounmap() return a int value,
>>>>       - 0 means continue to vunmap
>>>>       - error code means skip vunmap and return directly
>>>>
>>>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
>>> I don't really like interfaces that mix error pointers and NULL pointer
>>> returns.
>>>
>>> Would it be possible to have a special error code other than NULL
>>> for the fallback case?
>> I don't find a good error code, maybe  ENOTSUPP, any better suggestion?
> I had another look at the resulting arm64 function, and it appears that
> you never actually return a non-error pointer here. If I didn't miss anything,
> I think the best way would be to change the return type to just indicate
> success or an error code, and drop the case of returning the actual result,
> and changing the function name accordingly.
>
> Would that work, or do you actually require returning an __iomem
> token from somewhere else?

Christoph  suggested in the first version,

https://lore.kernel.org/linux-arm-kernel/Ymq2uX%2FY15HlIpo7@infradead.org/

>         Arnd
>
> .

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
  2022-05-24 14:53           ` Kefeng Wang
@ 2022-05-31  6:13             ` Christoph Hellwig
  -1 siblings, 0 replies; 51+ messages in thread
From: Christoph Hellwig @ 2022-05-31  6:13 UTC (permalink / raw)
  To: Kefeng Wang
  Cc: Arnd Bergmann, Catalin Marinas, Will Deacon, Andrew Morton,
	Linux ARM, Linux Kernel Mailing List, Linux-MM,
	Christoph Hellwig, Anshuman Khandual

On Tue, May 24, 2022 at 10:53:54PM +0800, Kefeng Wang wrote:
> Christoph  suggested in the first version,
> 
> https://lore.kernel.org/linux-arm-kernel/Ymq2uX%2FY15HlIpo7@infradead.org/

Yeah, mostly to eventually also covers mips.  But if this causes
problems now please just dumb it down and we can revisit the interface
when actually needed.

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
@ 2022-05-31  6:13             ` Christoph Hellwig
  0 siblings, 0 replies; 51+ messages in thread
From: Christoph Hellwig @ 2022-05-31  6:13 UTC (permalink / raw)
  To: Kefeng Wang
  Cc: Arnd Bergmann, Catalin Marinas, Will Deacon, Andrew Morton,
	Linux ARM, Linux Kernel Mailing List, Linux-MM,
	Christoph Hellwig, Anshuman Khandual

On Tue, May 24, 2022 at 10:53:54PM +0800, Kefeng Wang wrote:
> Christoph  suggested in the first version,
> 
> https://lore.kernel.org/linux-arm-kernel/Ymq2uX%2FY15HlIpo7@infradead.org/

Yeah, mostly to eventually also covers mips.  But if this causes
problems now please just dumb it down and we can revisit the interface
when actually needed.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
  2022-05-31  6:13             ` Christoph Hellwig
@ 2022-06-01  1:05               ` Kefeng Wang
  -1 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-06-01  1:05 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Arnd Bergmann, Catalin Marinas, Will Deacon, Andrew Morton,
	Linux ARM, Linux Kernel Mailing List, Linux-MM,
	Anshuman Khandual


On 2022/5/31 14:13, Christoph Hellwig wrote:
> On Tue, May 24, 2022 at 10:53:54PM +0800, Kefeng Wang wrote:
>> Christoph  suggested in the first version,
>>
>> https://lore.kernel.org/linux-arm-kernel/Ymq2uX%2FY15HlIpo7@infradead.org/
> Yeah, mostly to eventually also covers mips.  But if this causes
> problems now please just dumb it down and we can revisit the interface
> when actually needed.
> .
OK, will rethink the return value and resend after 5.19-rc1, thanks all.

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

* Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()
@ 2022-06-01  1:05               ` Kefeng Wang
  0 siblings, 0 replies; 51+ messages in thread
From: Kefeng Wang @ 2022-06-01  1:05 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Arnd Bergmann, Catalin Marinas, Will Deacon, Andrew Morton,
	Linux ARM, Linux Kernel Mailing List, Linux-MM,
	Anshuman Khandual


On 2022/5/31 14:13, Christoph Hellwig wrote:
> On Tue, May 24, 2022 at 10:53:54PM +0800, Kefeng Wang wrote:
>> Christoph  suggested in the first version,
>>
>> https://lore.kernel.org/linux-arm-kernel/Ymq2uX%2FY15HlIpo7@infradead.org/
> Yeah, mostly to eventually also covers mips.  But if this causes
> problems now please just dumb it down and we can revisit the interface
> when actually needed.
> .
OK, will rethink the return value and resend after 5.19-rc1, thanks all.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2022-06-01  1:07 UTC | newest]

Thread overview: 51+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-19  8:25 [PATCH v3 0/6] arm64: Cleanup ioremap() and support ioremap_prot() Kefeng Wang
2022-05-19  8:25 ` Kefeng Wang
2022-05-19  8:25 ` [PATCH v3 1/6] ARM: mm: kill unused runtime hook arch_iounmap() Kefeng Wang
2022-05-19  8:25   ` Kefeng Wang
2022-05-19  8:51   ` Anshuman Khandual
2022-05-19  8:51     ` Anshuman Khandual
2022-05-20 15:28   ` Catalin Marinas
2022-05-20 15:28     ` Catalin Marinas
2022-05-24  2:03     ` Kefeng Wang
2022-05-24  2:03       ` Kefeng Wang
2022-05-21 20:30   ` Arnd Bergmann
2022-05-21 20:30     ` Arnd Bergmann
2022-05-19  8:25 ` [PATCH v3 2/6] mm: ioremap: Use more sensibly name in ioremap_prot() Kefeng Wang
2022-05-19  8:25   ` Kefeng Wang
2022-05-19  8:25 ` [PATCH v3 3/6] mm: ioremap: Setup phys_addr of struct vm_struct Kefeng Wang
2022-05-19  8:25   ` Kefeng Wang
2022-05-19  8:25 ` [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap() Kefeng Wang
2022-05-19  8:25   ` Kefeng Wang
2022-05-19 18:52   ` Andrew Morton
2022-05-19 18:52     ` Andrew Morton
2022-05-20  1:22     ` Kefeng Wang
2022-05-20  1:22       ` Kefeng Wang
2022-05-23  3:57     ` Anshuman Khandual
2022-05-23  3:57       ` Anshuman Khandual
2022-05-23 22:17   ` kernel test robot
2022-05-23 22:17     ` kernel test robot
2022-05-24  9:48     ` Kefeng Wang
2022-05-24  9:48       ` Kefeng Wang
2022-05-24  9:48       ` Kefeng Wang
2022-05-24 12:35       ` Arnd Bergmann
2022-05-24 12:35         ` Arnd Bergmann
2022-05-24 12:35         ` Arnd Bergmann
2022-05-24 14:31         ` Kefeng Wang
2022-05-24 14:31           ` Kefeng Wang
2022-05-24 14:31           ` Kefeng Wang
2022-05-24 12:37   ` Arnd Bergmann
2022-05-24 12:37     ` Arnd Bergmann
2022-05-24 14:32     ` Kefeng Wang
2022-05-24 14:32       ` Kefeng Wang
2022-05-24 14:47       ` Arnd Bergmann
2022-05-24 14:47         ` Arnd Bergmann
2022-05-24 14:53         ` Kefeng Wang
2022-05-24 14:53           ` Kefeng Wang
2022-05-31  6:13           ` Christoph Hellwig
2022-05-31  6:13             ` Christoph Hellwig
2022-06-01  1:05             ` Kefeng Wang
2022-06-01  1:05               ` Kefeng Wang
2022-05-19  8:25 ` [PATCH v3 5/6] arm64: mm: Convert to GENERIC_IOREMAP Kefeng Wang
2022-05-19  8:25   ` Kefeng Wang
2022-05-19  8:25 ` [PATCH v3 6/6] arm64: Add HAVE_IOREMAP_PROT support Kefeng Wang
2022-05-19  8:25   ` Kefeng Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.