mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-12 21:44:06 +08:00
powerpc/mm: refactor ioremap_range() and use ioremap_page_range()
book3s64's ioremap_range() is almost same as fallback ioremap_range(), except that it calls radix__ioremap_range() when radix is enabled. radix__ioremap_range() is also very similar to the other ones, expect that it calls ioremap_page_range when slab is available. PPC32 __ioremap_caller() have a loop doing the same thing as ioremap_range() so use it on PPC32 as well. Lets keep only one version of ioremap_range() which calls ioremap_page_range() on all platforms when slab is available. At the same time, drop the nid parameter which is not used. Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/4b1dca7096b01823b101be7338983578641547f1.1566309263.git.christophe.leroy@c-s.fr
This commit is contained in:
parent
f381d5711f
commit
191e42063a
@ -266,9 +266,6 @@ extern void radix__vmemmap_remove_mapping(unsigned long start,
|
||||
extern int radix__map_kernel_page(unsigned long ea, unsigned long pa,
|
||||
pgprot_t flags, unsigned int psz);
|
||||
|
||||
extern int radix__ioremap_range(unsigned long ea, phys_addr_t pa,
|
||||
unsigned long size, pgprot_t prot, int nid);
|
||||
|
||||
static inline unsigned long radix__get_tree_size(void)
|
||||
{
|
||||
unsigned long rts_field;
|
||||
|
@ -722,6 +722,8 @@ void __iomem *ioremap_coherent(phys_addr_t address, unsigned long size);
|
||||
|
||||
extern void iounmap(volatile void __iomem *addr);
|
||||
|
||||
int ioremap_range(unsigned long ea, phys_addr_t pa, unsigned long size, pgprot_t prot);
|
||||
|
||||
extern void __iomem *__ioremap_caller(phys_addr_t, unsigned long size,
|
||||
pgprot_t prot, void *caller);
|
||||
|
||||
|
@ -446,24 +446,3 @@ int pmd_move_must_withdraw(struct spinlock *new_pmd_ptl,
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int ioremap_range(unsigned long ea, phys_addr_t pa, unsigned long size, pgprot_t prot, int nid)
|
||||
{
|
||||
unsigned long i;
|
||||
|
||||
if (radix_enabled())
|
||||
return radix__ioremap_range(ea, pa, size, prot, nid);
|
||||
|
||||
for (i = 0; i < size; i += PAGE_SIZE) {
|
||||
int err = map_kernel_page(ea + i, pa + i, prot);
|
||||
if (err) {
|
||||
if (slab_is_available())
|
||||
unmap_kernel_range(ea, size);
|
||||
else
|
||||
WARN_ON_ONCE(1); /* Should clean up */
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1218,26 +1218,6 @@ int pmd_free_pte_page(pmd_t *pmd, unsigned long addr)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int radix__ioremap_range(unsigned long ea, phys_addr_t pa, unsigned long size,
|
||||
pgprot_t prot, int nid)
|
||||
{
|
||||
if (likely(slab_is_available())) {
|
||||
int err = ioremap_page_range(ea, ea + size, pa, prot);
|
||||
if (err)
|
||||
unmap_kernel_range(ea, size);
|
||||
return err;
|
||||
} else {
|
||||
unsigned long i;
|
||||
|
||||
for (i = 0; i < size; i += PAGE_SIZE) {
|
||||
int err = map_kernel_page(ea + i, pa + i, prot);
|
||||
if (WARN_ON_ONCE(err)) /* Should clean up */
|
||||
return err;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int __init arch_ioremap_p4d_supported(void)
|
||||
{
|
||||
return 0;
|
||||
|
@ -1,6 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <linux/io.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include <asm/io-workarounds.h>
|
||||
|
||||
unsigned long ioremap_bot;
|
||||
@ -56,3 +58,25 @@ void __iomem *ioremap_prot(phys_addr_t addr, unsigned long size, unsigned long f
|
||||
return __ioremap_caller(addr, size, pte_pgprot(pte), caller);
|
||||
}
|
||||
EXPORT_SYMBOL(ioremap_prot);
|
||||
|
||||
int ioremap_range(unsigned long ea, phys_addr_t pa, unsigned long size, pgprot_t prot)
|
||||
{
|
||||
unsigned long i;
|
||||
|
||||
if (slab_is_available()) {
|
||||
int err = ioremap_page_range(ea, ea + size, pa, prot);
|
||||
|
||||
if (err)
|
||||
unmap_kernel_range(ea, size);
|
||||
return err;
|
||||
}
|
||||
|
||||
for (i = 0; i < size; i += PAGE_SIZE) {
|
||||
int err = map_kernel_page(ea + i, pa + i, prot);
|
||||
|
||||
if (WARN_ON_ONCE(err)) /* Should clean up */
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ EXPORT_SYMBOL(ioremap_wt);
|
||||
void __iomem *
|
||||
__ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *caller)
|
||||
{
|
||||
unsigned long v, i;
|
||||
unsigned long v;
|
||||
phys_addr_t p;
|
||||
int err;
|
||||
|
||||
@ -76,9 +76,7 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *call
|
||||
* Should check if it is a candidate for a BAT mapping
|
||||
*/
|
||||
|
||||
err = 0;
|
||||
for (i = 0; i < size && err == 0; i += PAGE_SIZE)
|
||||
err = map_kernel_page(v + i, p + i, prot);
|
||||
err = ioremap_range((unsigned long)v, p, size, prot);
|
||||
if (err) {
|
||||
if (slab_is_available())
|
||||
vunmap((void *)v);
|
||||
|
@ -4,25 +4,6 @@
|
||||
#include <linux/slab.h>
|
||||
#include <linux/vmalloc.h>
|
||||
|
||||
int __weak ioremap_range(unsigned long ea, phys_addr_t pa, unsigned long size,
|
||||
pgprot_t prot, int nid)
|
||||
{
|
||||
unsigned long i;
|
||||
|
||||
for (i = 0; i < size; i += PAGE_SIZE) {
|
||||
int err = map_kernel_page(ea + i, pa + i, prot);
|
||||
if (err) {
|
||||
if (slab_is_available())
|
||||
unmap_kernel_range(ea, size);
|
||||
else
|
||||
WARN_ON_ONCE(1); /* Should clean up */
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Low level function to establish the page tables for an IO mapping
|
||||
*/
|
||||
@ -41,7 +22,7 @@ void __iomem *__ioremap_at(phys_addr_t pa, void *ea, unsigned long size, pgprot_
|
||||
WARN_ON(((unsigned long)ea) & ~PAGE_MASK);
|
||||
WARN_ON(size & ~PAGE_MASK);
|
||||
|
||||
if (ioremap_range((unsigned long)ea, pa, size, prot, NUMA_NO_NODE))
|
||||
if (ioremap_range((unsigned long)ea, pa, size, prot))
|
||||
return NULL;
|
||||
|
||||
return (void __iomem *)ea;
|
||||
|
Loading…
Reference in New Issue
Block a user