mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 12:11:40 +00:00
8d05554dca
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 powerpc's special operation when ioremap() and iounmap(). Link: https://lkml.kernel.org/r/20230706154520.11257-18-bhe@redhat.com Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: Baoquan He <bhe@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Mike Rapoport (IBM) <rppt@kernel.org> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Nicholas Piggin <npiggin@gmail.com> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Brian Cain <bcain@quicinc.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Christian Borntraeger <borntraeger@linux.ibm.com> Cc: Chris Zankel <chris@zankel.net> Cc: David Laight <David.Laight@ACULAB.COM> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: Helge Deller <deller@gmx.de> Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com> Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> Cc: Jonas Bonn <jonas@southpole.se> Cc: Kefeng Wang <wangkefeng.wang@huawei.com> Cc: Matthew Wilcox <willy@infradead.org> Cc: Max Filippov <jcmvbkbc@gmail.com> Cc: Nathan Chancellor <nathan@kernel.org> Cc: Niklas Schnelle <schnelle@linux.ibm.com> Cc: Rich Felker <dalias@libc.org> Cc: Stafford Horne <shorne@gmail.com> Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Vineet Gupta <vgupta@kernel.org> Cc: Will Deacon <will@kernel.org> Cc: Yoshinori Sato <ysato@users.sourceforge.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
58 lines
1.4 KiB
C
58 lines
1.4 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include <linux/io.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/vmalloc.h>
|
|
|
|
void __iomem *__ioremap_caller(phys_addr_t addr, unsigned long size,
|
|
pgprot_t prot, void *caller)
|
|
{
|
|
phys_addr_t paligned, offset;
|
|
void __iomem *ret;
|
|
int err;
|
|
|
|
/* We don't support the 4K PFN hack with ioremap */
|
|
if (pgprot_val(prot) & H_PAGE_4K_PFN)
|
|
return NULL;
|
|
|
|
/*
|
|
* Choose an address to map it to. Once the vmalloc system is running,
|
|
* we use it. Before that, we map using addresses going up from
|
|
* ioremap_bot. vmalloc will use the addresses from IOREMAP_BASE
|
|
* through ioremap_bot.
|
|
*/
|
|
paligned = addr & PAGE_MASK;
|
|
offset = addr & ~PAGE_MASK;
|
|
size = PAGE_ALIGN(addr + size) - paligned;
|
|
|
|
if (size == 0 || paligned == 0)
|
|
return NULL;
|
|
|
|
if (slab_is_available())
|
|
return generic_ioremap_prot(addr, size, prot);
|
|
|
|
pr_warn("ioremap() called early from %pS. Use early_ioremap() instead\n", caller);
|
|
|
|
err = early_ioremap_range(ioremap_bot, paligned, size, prot);
|
|
if (err)
|
|
return NULL;
|
|
|
|
ret = (void __iomem *)ioremap_bot + offset;
|
|
ioremap_bot += size + PAGE_SIZE;
|
|
|
|
return ret;
|
|
}
|
|
|
|
/*
|
|
* Unmap an IO region and remove it from vmalloc'd list.
|
|
* Access to IO memory should be serialized by driver.
|
|
*/
|
|
void iounmap(volatile void __iomem *token)
|
|
{
|
|
if (!slab_is_available())
|
|
return;
|
|
|
|
generic_iounmap(PCI_FIX_ADDR(token));
|
|
}
|
|
EXPORT_SYMBOL(iounmap);
|