The ColdFire SoC internal peripherals are mapped into virtual address
space using the ACR registers of the cache control unit. This means we
are using a 1:1 physical:virtual mapping for them that does not rely on
page table mappings. We can quickly determine if we are accessing an
internal peripheral device given the physical or vitrual address using
the same range check.

The implications of this mapping is that an ioremap should return the
physical address as the virtual mapping __iomem cookie as well. So fix
ioremap() to deal with this on ColdFire. Of course you need to take
care of this in the iounmap() path as well.

Reported-by: Angelo Dureghello <[email protected]>
Signed-off-by: Greg Ungerer <[email protected]>
Reviewed-by: Angelo Dureghello <[email protected]>
---
 arch/m68k/mm/kmap.c | 8 ++++++++
 1 file changed, 8 insertions(+)

v2: rebase to v4.17-rc1
    fix compilation warnings
    drop read/write iomem() conversions

diff --git a/arch/m68k/mm/kmap.c b/arch/m68k/mm/kmap.c
index c2a3832..411a308 100644
--- a/arch/m68k/mm/kmap.c
+++ b/arch/m68k/mm/kmap.c
@@ -125,6 +125,10 @@ void __iomem *__ioremap(unsigned long physaddr, unsigned 
long size, int cachefla
                        return (void __iomem *)physaddr;
        }
 #endif
+#ifdef CONFIG_COLDFIRE
+       if (__cf_internalio(physaddr))
+               return (void __iomem *) physaddr;
+#endif
 
 #ifdef DEBUG
        printk("ioremap: 0x%lx,0x%lx(%d) - ", physaddr, size, cacheflag);
@@ -235,6 +239,10 @@ void iounmap(void __iomem *addr)
             ((unsigned long)addr > 0x60000000)))
                        free_io_area((__force void *)addr);
 #else
+#ifdef CONFIG_COLDFIRE
+       if (cf_internalio(addr))
+               return;
+#endif
        free_io_area((__force void *)addr);
 #endif
 }
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to