[PATCH v2 02/11] mm: ioremap: fixup the physical address and page prot

Christophe Leroy christophe.leroy at csgroup.eu
Sun Aug 21 23:30:59 PDT 2022



Le 20/08/2022 à 02:31, Baoquan He a écrit :
> On some architectures, the physical address need be fixed up before
> doing mapping, e.g, parisc. And on architectures, e.g arc, the
> parameter 'prot' passed into ioremap_prot() need be adjusted too.
> 
> In oder to convert them to take GENERIC_IOREMAP method, we need wrap
> the address fixing up code and page prot adjusting code into arch_ioremap()
> and pass the new address and 'prot' out for ioremap_prot() handling.

Is it really the best approach ? Wouldn't it be better to have helpers 
to do that, those helpers being called by the ioremap_prot(), instead of 
doing it inside the arch_ioremap() function ?

> 
> This is a preparation patch, no functionality change.

Could this be squashed into previous patch ?

> 
> Signed-off-by: Baoquan He <bhe at redhat.com>
> ---
>   arch/arm64/include/asm/io.h | 3 ++-
>   arch/arm64/mm/ioremap.c     | 5 +++--
>   include/asm-generic/io.h    | 4 ++--
>   mm/ioremap.c                | 2 +-
>   4 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h
> index dd7e1c2dc86c..6a5578ddbbf6 100644
> --- a/arch/arm64/include/asm/io.h
> +++ b/arch/arm64/include/asm/io.h
> @@ -139,7 +139,8 @@ extern void __memset_io(volatile void __iomem *, int, size_t);
>    * I/O memory mapping functions.
>    */
>   
> -void __iomem *arch_ioremap(phys_addr_t phys_addr, size_t size, unsigned long prot);
> +void __iomem *
> +arch_ioremap(phys_addr_t *paddr, size_t size, unsigned long *prot_val);
>   #define arch_ioremap arch_ioremap
>   
>   #define _PAGE_IOREMAP PROT_DEVICE_nGnRE
> diff --git a/arch/arm64/mm/ioremap.c b/arch/arm64/mm/ioremap.c
> index b0f4cea86f0e..ef75ffef4dbc 100644
> --- a/arch/arm64/mm/ioremap.c
> +++ b/arch/arm64/mm/ioremap.c
> @@ -3,9 +3,10 @@
>   #include <linux/mm.h>
>   #include <linux/io.h>
>   
> -void __iomem *arch_ioremap(phys_addr_t phys_addr, size_t size, unsigned long prot)
> +void __iomem *
> +arch_ioremap(phys_addr_t *paddr, size_t size, unsigned long *prot_val)
>   {
> -	unsigned long last_addr, offset;
> +	unsigned long last_addr, offset, phys_addr = *paddr;
>   
>   	offset = phys_addr & (~PAGE_MASK);
>   	phys_addr -= offset;
> diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
> index 7b6bfb62ef80..fb9bda2be8ed 100644
> --- a/include/asm-generic/io.h
> +++ b/include/asm-generic/io.h
> @@ -1059,8 +1059,8 @@ static inline void iounmap(volatile void __iomem *addr)
>    */
>   #ifndef arch_ioremap
>   #define arch_ioremap arch_ioremap
> -static inline void __iomem *arch_ioremap(phys_addr_t phys_addr, size_t size,
> -				   unsigned long prot)
> +static inline void __iomem *arch_ioremap(phys_addr_t *paddr, size_t size,
> +				   unsigned long *prot_val)
>   {
>   	return NULL;
>   }
> diff --git a/mm/ioremap.c b/mm/ioremap.c
> index 99fde69becc7..7914b5cf5b78 100644
> --- a/mm/ioremap.c
> +++ b/mm/ioremap.c
> @@ -19,7 +19,7 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size,
>   	struct vm_struct *area;
>   	void __iomem *ioaddr;
>   
> -	ioaddr = arch_ioremap(phys_addr, size, prot);
> +	ioaddr = arch_ioremap(&phys_addr, size, &prot);
>   	if (IS_ERR(ioaddr))
>   		return NULL;
>   	else if (ioaddr)


More information about the linux-arm-kernel mailing list