All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] riscv: set the width of the physical address/size data type based on arch
@ 2025-05-06  9:24 Sughosh Ganu
  2025-05-06  9:49 ` Heinrich Schuchardt
  0 siblings, 1 reply; 10+ messages in thread
From: Sughosh Ganu @ 2025-05-06  9:24 UTC (permalink / raw)
  To: u-boot; +Cc: Tom Rini, Rick Chen, Leo, Heinrich Schuchardt, Sughosh Ganu

U-Boot has support for both the 32-bit and 64-bit RiscV platforms. Set
the width of the phys_{addr,size}_t data types based on the register
size of the architecture.

Currently, even the 32-bit RiscV platforms have a 64-bit
phys_{addr,size}_t data types. This causes issues on the 32-bit
platforms, where the upper 32-bits of the variables of these types
can have junk data, and that can cause all kinds of side-effects.

This was discovered on the qemu Riscv 32-bit platform  when the return
value of an LMB API was checked, and some LMB allocation that ought
not to have failed, was failing. The upper 32-bits of the address
variable contained garbage, resulting in failures.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
---

Note:
Although the LMB API cleanup series depends on this patch, I am
sending it separately so that it gets noticed by the RiscV
maintainers. Sometimes a patch may not get the required attention when
sent as part of another seemingly unrelated series.


 arch/riscv/include/asm/types.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/riscv/include/asm/types.h b/arch/riscv/include/asm/types.h
index 49f7a5d6b3a..45d806c83eb 100644
--- a/arch/riscv/include/asm/types.h
+++ b/arch/riscv/include/asm/types.h
@@ -35,8 +35,13 @@ typedef u64 dma_addr_t;
 typedef u32 dma_addr_t;
 #endif
 
-typedef unsigned long long phys_addr_t;
-typedef unsigned long long phys_size_t;
+#ifdef CONFIG_PHYS_64BIT
+typedef u64 phys_addr_t;
+typedef u64 phys_size_t;
+#else
+typedef u32 phys_addr_t;
+typedef u32 phys_size_t;
+#endif
 
 #endif /* __KERNEL__ */
 
-- 
2.34.1


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

end of thread, other threads:[~2025-05-12  9:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-06  9:24 [PATCH] riscv: set the width of the physical address/size data type based on arch Sughosh Ganu
2025-05-06  9:49 ` Heinrich Schuchardt
2025-05-06 10:49   ` Sughosh Ganu
2025-05-06 11:05     ` Heinrich Schuchardt
2025-05-06 11:13       ` Sughosh Ganu
2025-05-07  7:49       ` Sughosh Ganu
2025-05-07  9:41         ` Sughosh Ganu
2025-05-07 15:48           ` Tom Rini
2025-05-07 18:37             ` Sughosh Ganu
2025-05-12  9:21               ` Leo Liang

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.