Skip to contentSkip to conversation

nios2: Fix ioremap

PATCH In review Guenter Roeck 3 participants 3 messages Dec 5, 2019 – Dec 12, 2019 NIOS2 architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nios2: Fix ioremap

Commit 5ace77e0b41a ("nios2: remove __ioremap") removed the following code, with the argument that cacheflag is always 0 and the expression would therefore always be false.

	if (IS_MAPPABLE_UNCACHEABLE(phys_addr) &&
	    IS_MAPPABLE_UNCACHEABLE(last_addr) &&
	    !(cacheflag & _PAGE_CACHED))
		return (void __iomem *)(CONFIG_NIOS2_IO_REGION_BASE + phys_addr);

This did not take the "!" in the expression into account. Result is that nios2 images no longer boot. Restoring the removed code fixes the problem.

Fixes 5ace77e0b41a ("nios2: remove __ioremap")
Cc Christoph Hellwig <[email protected]>
---
 arch/nios2/mm/ioremap.c | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/nios2/mm/ioremap.c +8 -0
index b56af759dcdf..819bdfcc2e71 100644
@@ -138,6 +138,14 @@ void __iomem *ioremap(unsigned long phys_addr, unsigned long size)
 				return NULL;
 	}
 
+	/*
+	 * Map uncached objects in the low part of address space to
+	 * CONFIG_NIOS2_IO_REGION_BASE
+	 */
+	if (IS_MAPPABLE_UNCACHEABLE(phys_addr) &&
+	    IS_MAPPABLE_UNCACHEABLE(last_addr))
+		return (void __iomem *)(CONFIG_NIOS2_IO_REGION_BASE + phys_addr);
+
 	/* Mappings have to be page-aligned */
 	offset = phys_addr & ~PAGE_MASK;
 	phys_addr &= PAGE_MASK;
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#2 lore raw
In reply to Guenter Roeck
Quoted 20 lines

-----Original Message-----
From: Guenter Roeck <[email protected]> On Behalf Of Guenter Roeck
Sent: Thursday, December 5, 2019 10:41 AM
To: Ley Foon Tan <[email protected]>
Cc: [email protected]; [email protected]; Guenter Roeck <[email protected]>; Christoph Hellwig <[email protected]>
Subject: [PATCH] nios2: Fix ioremap

Commit 5ace77e0b41a ("nios2: remove __ioremap") removed the following code, with the argument that cacheflag is always 0 and the expression would therefore always be false.

if (IS_MAPPABLE_UNCACHEABLE(phys_addr) &&
IS_MAPPABLE_UNCACHEABLE(last_addr) && !(cacheflag & _PAGE_CACHED))
return (void __iomem *)(CONFIG_NIOS2_IO_REGION_BASE +
phys_addr);

Quoted 6 lines

This did not take the "!" in the expression into account. Result is that nios2 images no longer boot. Restoring the removed code fixes the problem.

Fixes 5ace77e0b41a ("nios2: remove __ioremap")
Cc Christoph Hellwig <[email protected]>

Will add to next rc.
Thanks.