mirror of
https://github.com/torvalds/linux.git
synced 2026-12-01 11:03:37 +00:00
By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated code with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for arc's special operation when ioremap_prot() and iounmap(). Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Baoquan He <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Mike Rapoport (IBM) <[email protected]> Cc: Vineet Gupta <[email protected]> Cc: Alexander Gordeev <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Brian Cain <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Christian Borntraeger <[email protected]> Cc: Christophe Leroy <[email protected]> Cc: Chris Zankel <[email protected]> Cc: David Laight <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: Gerald Schaefer <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Helge Deller <[email protected]> Cc: "James E.J. Bottomley" <[email protected]> Cc: John Paul Adrian Glaubitz <[email protected]> Cc: Jonas Bonn <[email protected]> Cc: Kefeng Wang <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Max Filippov <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Nathan Chancellor <[email protected]> Cc: Nicholas Piggin <[email protected]> Cc: Niklas Schnelle <[email protected]> Cc: Rich Felker <[email protected]> Cc: Stafford Horne <[email protected]> Cc: Stefan Kristiansson <[email protected]> Cc: Sven Schnelle <[email protected]> Cc: Vasily Gorbik <[email protected]> Cc: Will Deacon <[email protected]> Cc: Yoshinori Sato <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
65 lines
1.6 KiB
C
65 lines
1.6 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
|
|
*/
|
|
|
|
#include <linux/vmalloc.h>
|
|
#include <linux/init.h>
|
|
#include <linux/module.h>
|
|
#include <linux/io.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/cache.h>
|
|
|
|
static inline bool arc_uncached_addr_space(phys_addr_t paddr)
|
|
{
|
|
if (is_isa_arcompact()) {
|
|
if (paddr >= ARC_UNCACHED_ADDR_SPACE)
|
|
return true;
|
|
} else if (paddr >= perip_base && paddr <= perip_end) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
void __iomem *ioremap(phys_addr_t paddr, unsigned long size)
|
|
{
|
|
/*
|
|
* If the region is h/w uncached, MMU mapping can be elided as optim
|
|
* The cast to u32 is fine as this region can only be inside 4GB
|
|
*/
|
|
if (arc_uncached_addr_space(paddr))
|
|
return (void __iomem *)(u32)paddr;
|
|
|
|
return ioremap_prot(paddr, size,
|
|
pgprot_val(pgprot_noncached(PAGE_KERNEL)));
|
|
}
|
|
EXPORT_SYMBOL(ioremap);
|
|
|
|
/*
|
|
* ioremap with access flags
|
|
* Cache semantics wise it is same as ioremap - "forced" uncached.
|
|
* However unlike vanilla ioremap which bypasses ARC MMU for addresses in
|
|
* ARC hardware uncached region, this one still goes thru the MMU as caller
|
|
* might need finer access control (R/W/X)
|
|
*/
|
|
void __iomem *ioremap_prot(phys_addr_t paddr, size_t size,
|
|
unsigned long flags)
|
|
{
|
|
pgprot_t prot = __pgprot(flags);
|
|
|
|
/* force uncached */
|
|
return generic_ioremap_prot(paddr, size, pgprot_noncached(prot));
|
|
}
|
|
EXPORT_SYMBOL(ioremap_prot);
|
|
|
|
void iounmap(volatile void __iomem *addr)
|
|
{
|
|
/* weird double cast to handle phys_addr_t > 32 bits */
|
|
if (arc_uncached_addr_space((phys_addr_t)(u32)addr))
|
|
return;
|
|
|
|
generic_iounmap(addr);
|
|
}
|
|
EXPORT_SYMBOL(iounmap);
|