Skip to contentSkip to conversation

mips: ralink: mt7621: avoid casting away __iomem in wraparound test

PATCH Applied Rosen Penev 2 participants 2 messages Oct 4 – Nov 17

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mips: ralink: mt7621: avoid casting away __iomem in wraparound test

CPHYSADDR() casts its argument to an integer, which strips the __iomem annotation from dm and triggers a sparse warning. Compute the physical address from detect_magic directly. The result is unchanged since the sum never exceeds the 512MB KSEG mask.

Fixes 4ddaf88aadd3 ("mips: ralink: mt7621: add missing __iomem")
Assisted-by LLM
---
 arch/mips/ralink/mt7621.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/ralink/mt7621.c +1 -1
index ae7b8cfedd5f..2d10c74b13c1 100644
@@ -65,7 +65,7 @@ static bool __init mt7621_addr_wraparound_test(phys_addr_t size)
 {
 	void __iomem *dm = (void __iomem *)KSEG1ADDR(&detect_magic);
 
-	if (CPHYSADDR(dm + size) >= MT7621_LOWMEM_MAX_SIZE)
+	if (CPHYSADDR(&detect_magic) + size >= MT7621_LOWMEM_MAX_SIZE)
 		return true;
 	__raw_writel(MT7621_MEM_TEST_PATTERN, dm);
 	if (__raw_readl(dm) != __raw_readl(dm + size))
Signature · 1 line
2.56.0
maintainer Applied
#1 lore raw
Quoted 29 lines · Rosen Penev

CPHYSADDR() casts its argument to an integer, which strips the __iomem annotation from dm and triggers a sparse warning. Compute the physical address from detect_magic directly. The result is unchanged since the sum never exceeds the 512MB KSEG mask.

Fixes 4ddaf88aadd3 ("mips: ralink: mt7621: add missing __iomem")
Assisted-by LLM
---
 arch/mips/ralink/mt7621.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/ralink/mt7621.c +1 -1
index ae7b8cfedd5f..2d10c74b13c1 100644
@@ -65,7 +65,7 @@ static bool __init mt7621_addr_wraparound_test(phys_addr_t size)
 {
 	void __iomem *dm = (void __iomem *)KSEG1ADDR(&detect_magic);
 
-	if (CPHYSADDR(dm + size) >= MT7621_LOWMEM_MAX_SIZE)
+	if (CPHYSADDR(&detect_magic) + size >= MT7621_LOWMEM_MAX_SIZE)
 		return true;
 	__raw_writel(MT7621_MEM_TEST_PATTERN, dm);
 	if (__raw_readl(dm) != __raw_readl(dm + size))
Signature · 1 line
2.56.0

applied to mips-next

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]