Commit 14b4d976 authored by Christophe Leroy's avatar Christophe Leroy Committed by Michael Ellerman

powerpc/mm: rework io-workaround invocation.

ppc_md.ioremap() is only used for I/O workaround on CELL platform,
so indirect function call can be avoided.

This patch reworks the io-workaround and ioremap() functions to
use the global 'io_workaround_inited' flag for the activation
of io-workaround.

When CONFIG_PPC_IO_WORKAROUNDS or CONFIG_PPC_INDIRECT_MMIO are not
selected, the I/O workaround ioremap() voids and the global flag is
not used.
Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/5fa3ef069fbd0f152512afaae19e7a60161454cf.1566309262.git.christophe.leroy@c-s.fr
parent 492643e8
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#ifndef _IO_WORKAROUNDS_H #ifndef _IO_WORKAROUNDS_H
#define _IO_WORKAROUNDS_H #define _IO_WORKAROUNDS_H
#ifdef CONFIG_PPC_IO_WORKAROUNDS
#include <linux/io.h> #include <linux/io.h>
#include <asm/pci-bridge.h> #include <asm/pci-bridge.h>
...@@ -32,4 +33,23 @@ extern int spiderpci_iowa_init(struct iowa_bus *, void *); ...@@ -32,4 +33,23 @@ extern int spiderpci_iowa_init(struct iowa_bus *, void *);
#define SPIDER_PCI_DUMMY_READ 0x0810 #define SPIDER_PCI_DUMMY_READ 0x0810
#define SPIDER_PCI_DUMMY_READ_BASE 0x0814 #define SPIDER_PCI_DUMMY_READ_BASE 0x0814
#endif
#if defined(CONFIG_PPC_IO_WORKAROUNDS) && defined(CONFIG_PPC_INDIRECT_MMIO)
extern bool io_workaround_inited;
static inline bool iowa_is_active(void)
{
return unlikely(io_workaround_inited);
}
#else
static inline bool iowa_is_active(void)
{
return false;
}
#endif
void __iomem *iowa_ioremap(phys_addr_t addr, unsigned long size,
pgprot_t prot, void *caller);
#endif /* _IO_WORKAROUNDS_H */ #endif /* _IO_WORKAROUNDS_H */
...@@ -31,8 +31,6 @@ struct pci_host_bridge; ...@@ -31,8 +31,6 @@ struct pci_host_bridge;
struct machdep_calls { struct machdep_calls {
char *name; char *name;
#ifdef CONFIG_PPC64 #ifdef CONFIG_PPC64
void __iomem * (*ioremap)(phys_addr_t addr, unsigned long size,
pgprot_t prot, void *caller);
#ifdef CONFIG_PM #ifdef CONFIG_PM
void (*iommu_save)(void); void (*iommu_save)(void);
void (*iommu_restore)(void); void (*iommu_restore)(void);
......
...@@ -149,8 +149,8 @@ static const struct ppc_pci_io iowa_pci_io = { ...@@ -149,8 +149,8 @@ static const struct ppc_pci_io iowa_pci_io = {
}; };
#ifdef CONFIG_PPC_INDIRECT_MMIO #ifdef CONFIG_PPC_INDIRECT_MMIO
static void __iomem *iowa_ioremap(phys_addr_t addr, unsigned long size, void __iomem *iowa_ioremap(phys_addr_t addr, unsigned long size,
pgprot_t prot, void *caller) pgprot_t prot, void *caller)
{ {
struct iowa_bus *bus; struct iowa_bus *bus;
void __iomem *res = __ioremap_caller(addr, size, prot, caller); void __iomem *res = __ioremap_caller(addr, size, prot, caller);
...@@ -163,20 +163,17 @@ static void __iomem *iowa_ioremap(phys_addr_t addr, unsigned long size, ...@@ -163,20 +163,17 @@ static void __iomem *iowa_ioremap(phys_addr_t addr, unsigned long size,
} }
return res; return res;
} }
#else /* CONFIG_PPC_INDIRECT_MMIO */
#define iowa_ioremap NULL
#endif /* !CONFIG_PPC_INDIRECT_MMIO */ #endif /* !CONFIG_PPC_INDIRECT_MMIO */
bool io_workaround_inited;
/* Enable IO workaround */ /* Enable IO workaround */
static void io_workaround_init(void) static void io_workaround_init(void)
{ {
static int io_workaround_inited;
if (io_workaround_inited) if (io_workaround_inited)
return; return;
ppc_pci_io = iowa_pci_io; ppc_pci_io = iowa_pci_io;
ppc_md.ioremap = iowa_ioremap; io_workaround_inited = true;
io_workaround_inited = 1;
} }
/* Register new bus to support workaround */ /* Register new bus to support workaround */
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <asm/page.h> #include <asm/page.h>
#include <asm/prom.h> #include <asm/prom.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/io-workarounds.h>
#include <asm/mmu_context.h> #include <asm/mmu_context.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
#include <asm/mmu.h> #include <asm/mmu.h>
...@@ -208,8 +209,8 @@ void __iomem * ioremap(phys_addr_t addr, unsigned long size) ...@@ -208,8 +209,8 @@ void __iomem * ioremap(phys_addr_t addr, unsigned long size)
pgprot_t prot = pgprot_noncached(PAGE_KERNEL); pgprot_t prot = pgprot_noncached(PAGE_KERNEL);
void *caller = __builtin_return_address(0); void *caller = __builtin_return_address(0);
if (ppc_md.ioremap) if (iowa_is_active())
return ppc_md.ioremap(addr, size, prot, caller); return iowa_ioremap(addr, size, prot, caller);
return __ioremap_caller(addr, size, prot, caller); return __ioremap_caller(addr, size, prot, caller);
} }
...@@ -218,8 +219,8 @@ void __iomem * ioremap_wc(phys_addr_t addr, unsigned long size) ...@@ -218,8 +219,8 @@ void __iomem * ioremap_wc(phys_addr_t addr, unsigned long size)
pgprot_t prot = pgprot_noncached_wc(PAGE_KERNEL); pgprot_t prot = pgprot_noncached_wc(PAGE_KERNEL);
void *caller = __builtin_return_address(0); void *caller = __builtin_return_address(0);
if (ppc_md.ioremap) if (iowa_is_active())
return ppc_md.ioremap(addr, size, prot, caller); return iowa_ioremap(addr, size, prot, caller);
return __ioremap_caller(addr, size, prot, caller); return __ioremap_caller(addr, size, prot, caller);
} }
...@@ -228,8 +229,8 @@ void __iomem *ioremap_coherent(phys_addr_t addr, unsigned long size) ...@@ -228,8 +229,8 @@ void __iomem *ioremap_coherent(phys_addr_t addr, unsigned long size)
pgprot_t prot = pgprot_cached(PAGE_KERNEL); pgprot_t prot = pgprot_cached(PAGE_KERNEL);
void *caller = __builtin_return_address(0); void *caller = __builtin_return_address(0);
if (ppc_md.ioremap) if (iowa_is_active())
return ppc_md.ioremap(addr, size, prot, caller); return iowa_ioremap(addr, size, prot, caller);
return __ioremap_caller(addr, size, prot, caller); return __ioremap_caller(addr, size, prot, caller);
} }
...@@ -250,8 +251,8 @@ void __iomem * ioremap_prot(phys_addr_t addr, unsigned long size, ...@@ -250,8 +251,8 @@ void __iomem * ioremap_prot(phys_addr_t addr, unsigned long size,
*/ */
pte = pte_mkprivileged(pte); pte = pte_mkprivileged(pte);
if (ppc_md.ioremap) if (iowa_is_active())
return ppc_md.ioremap(addr, size, pte_pgprot(pte), caller); return iowa_ioremap(addr, size, pte_pgprot(pte), caller);
return __ioremap_caller(addr, size, pte_pgprot(pte), caller); return __ioremap_caller(addr, size, pte_pgprot(pte), caller);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment