diff mbox series

[v2,16/38] ppc: io.h: Use addrmap_ translation APIs only in post-relocation phase

Message ID 1613663886-83811-17-git-send-email-bmeng.cn@gmail.com
State Superseded
Delegated to: Priyanka Jain
Headers show
Series ppc: qemu: Convert qemu-ppce500 to driver model and enable additional driver support | expand

Commit Message

Bin Meng Feb. 18, 2021, 3:57 p.m. UTC
In phys_to_virt() and virt_to_phys(), if CONFIG_ADDR_MAP is defined,
they use addrmap_ translation APIs to do the address translation.
However these APIs only work in post-relocation phase.

Update the code logic to fall back to use the default one when in
pre-relocation phase.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---

(no changes since v1)

 arch/powerpc/include/asm/io.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

Comments

Priyanka Jain Feb. 22, 2021, 8:55 a.m. UTC | #1
>-----Original Message-----
>From: Bin Meng <bmeng.cn@gmail.com>
>Sent: Thursday, February 18, 2021 9:28 PM
>To: Simon Glass <sjg@chromium.org>; Alexander Graf <agraf@csgraf.de>;
>Priyanka Jain <priyanka.jain@nxp.com>
>Cc: U-Boot Mailing List <u-boot@lists.denx.de>; Tom Rini
><trini@konsulko.com>
>Subject: [PATCH v2 16/38] ppc: io.h: Use addrmap_ translation APIs only in
>post-relocation phase
>
>In phys_to_virt() and virt_to_phys(), if CONFIG_ADDR_MAP is defined, they
>use addrmap_ translation APIs to do the address translation.
>However these APIs only work in post-relocation phase.
>
>Update the code logic to fall back to use the default one when in pre-
>relocation phase.
>
>Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
>---
>
>(no changes since v1)
>
> arch/powerpc/include/asm/io.h | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
diff mbox series

Patch

diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
index 6d76e3e..998a82a 100644
--- a/arch/powerpc/include/asm/io.h
+++ b/arch/powerpc/include/asm/io.h
@@ -10,7 +10,10 @@ 
 #include <asm/byteorder.h>
 
 #ifdef CONFIG_ADDR_MAP
+#include <asm/global_data.h>
 #include <addr_map.h>
+
+DECLARE_GLOBAL_DATA_PTR;
 #endif
 
 #define SIO_CONFIG_RA   0x398
@@ -303,20 +306,20 @@  static inline void out_be32(volatile unsigned __iomem *addr, u32 val)
 static inline void *phys_to_virt(phys_addr_t paddr)
 {
 #ifdef CONFIG_ADDR_MAP
-	return addrmap_phys_to_virt(paddr);
-#else
-	return (void *)((unsigned long)paddr);
+	if (gd->flags & GD_FLG_RELOC)
+		return addrmap_phys_to_virt(paddr);
 #endif
+	return (void *)((unsigned long)paddr);
 }
 #define phys_to_virt phys_to_virt
 
 static inline phys_addr_t virt_to_phys(void * vaddr)
 {
 #ifdef CONFIG_ADDR_MAP
-	return addrmap_virt_to_phys(vaddr);
-#else
-	return (phys_addr_t)((unsigned long)vaddr);
+	if (gd->flags & GD_FLG_RELOC)
+		return addrmap_virt_to_phys(vaddr);
 #endif
+	return (phys_addr_t)((unsigned long)vaddr);
 }
 #define virt_to_phys virt_to_phys