Skip to content

Commit 15efd61

Browse files
mpemaddy-kerneldev
authored andcommitted
powerpc/io: Unhook MMIO accessors
Now that PPC_INDIRECT_MMIO is removed, it's not possible/necessary to hook any of the "memory" accessors, so turn them back into regular static inlines, and restrict the hooking mechanism to the "pio" accessors only. Move the #defines that signal each routine is implemented next to the implementation, and update the out-of-date comment. Signed-off-by: Michael Ellerman <[email protected]> Signed-off-by: Madhavan Srinivasan <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent de9cc05 commit 15efd61

File tree

2 files changed

+153
-86
lines changed

2 files changed

+153
-86
lines changed

arch/powerpc/include/asm/io-defs.h

Lines changed: 12 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,15 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22
/* This file is meant to be include multiple times by other headers */
3-
/* last 2 argments are used by platforms/cell/io-workarounds.[ch] */
43

5-
DEF_PCI_AC_RET(readb, u8, (const PCI_IO_ADDR addr), (addr), mem, addr)
6-
DEF_PCI_AC_RET(readw, u16, (const PCI_IO_ADDR addr), (addr), mem, addr)
7-
DEF_PCI_AC_RET(readl, u32, (const PCI_IO_ADDR addr), (addr), mem, addr)
8-
DEF_PCI_AC_RET(readw_be, u16, (const PCI_IO_ADDR addr), (addr), mem, addr)
9-
DEF_PCI_AC_RET(readl_be, u32, (const PCI_IO_ADDR addr), (addr), mem, addr)
10-
DEF_PCI_AC_NORET(writeb, (u8 val, PCI_IO_ADDR addr), (val, addr), mem, addr)
11-
DEF_PCI_AC_NORET(writew, (u16 val, PCI_IO_ADDR addr), (val, addr), mem, addr)
12-
DEF_PCI_AC_NORET(writel, (u32 val, PCI_IO_ADDR addr), (val, addr), mem, addr)
13-
DEF_PCI_AC_NORET(writew_be, (u16 val, PCI_IO_ADDR addr), (val, addr), mem, addr)
14-
DEF_PCI_AC_NORET(writel_be, (u32 val, PCI_IO_ADDR addr), (val, addr), mem, addr)
15-
16-
#ifdef __powerpc64__
17-
DEF_PCI_AC_RET(readq, u64, (const PCI_IO_ADDR addr), (addr), mem, addr)
18-
DEF_PCI_AC_RET(readq_be, u64, (const PCI_IO_ADDR addr), (addr), mem, addr)
19-
DEF_PCI_AC_NORET(writeq, (u64 val, PCI_IO_ADDR addr), (val, addr), mem, addr)
20-
DEF_PCI_AC_NORET(writeq_be, (u64 val, PCI_IO_ADDR addr), (val, addr), mem, addr)
21-
#endif /* __powerpc64__ */
22-
23-
DEF_PCI_AC_RET(inb, u8, (unsigned long port), (port), pio, port)
24-
DEF_PCI_AC_RET(inw, u16, (unsigned long port), (port), pio, port)
25-
DEF_PCI_AC_RET(inl, u32, (unsigned long port), (port), pio, port)
26-
DEF_PCI_AC_NORET(outb, (u8 val, unsigned long port), (val, port), pio, port)
27-
DEF_PCI_AC_NORET(outw, (u16 val, unsigned long port), (val, port), pio, port)
28-
DEF_PCI_AC_NORET(outl, (u32 val, unsigned long port), (val, port), pio, port)
29-
30-
DEF_PCI_AC_NORET(readsb, (const PCI_IO_ADDR a, void *b, unsigned long c),
31-
(a, b, c), mem, a)
32-
DEF_PCI_AC_NORET(readsw, (const PCI_IO_ADDR a, void *b, unsigned long c),
33-
(a, b, c), mem, a)
34-
DEF_PCI_AC_NORET(readsl, (const PCI_IO_ADDR a, void *b, unsigned long c),
35-
(a, b, c), mem, a)
36-
DEF_PCI_AC_NORET(writesb, (PCI_IO_ADDR a, const void *b, unsigned long c),
37-
(a, b, c), mem, a)
38-
DEF_PCI_AC_NORET(writesw, (PCI_IO_ADDR a, const void *b, unsigned long c),
39-
(a, b, c), mem, a)
40-
DEF_PCI_AC_NORET(writesl, (PCI_IO_ADDR a, const void *b, unsigned long c),
41-
(a, b, c), mem, a)
42-
43-
DEF_PCI_AC_NORET(insb, (unsigned long p, void *b, unsigned long c),
44-
(p, b, c), pio, p)
45-
DEF_PCI_AC_NORET(insw, (unsigned long p, void *b, unsigned long c),
46-
(p, b, c), pio, p)
47-
DEF_PCI_AC_NORET(insl, (unsigned long p, void *b, unsigned long c),
48-
(p, b, c), pio, p)
49-
DEF_PCI_AC_NORET(outsb, (unsigned long p, const void *b, unsigned long c),
50-
(p, b, c), pio, p)
51-
DEF_PCI_AC_NORET(outsw, (unsigned long p, const void *b, unsigned long c),
52-
(p, b, c), pio, p)
53-
DEF_PCI_AC_NORET(outsl, (unsigned long p, const void *b, unsigned long c),
54-
(p, b, c), pio, p)
55-
56-
DEF_PCI_AC_NORET(memset_io, (PCI_IO_ADDR a, int c, unsigned long n),
57-
(a, c, n), mem, a)
58-
DEF_PCI_AC_NORET(memcpy_fromio, (void *d, const PCI_IO_ADDR s, unsigned long n),
59-
(d, s, n), mem, s)
60-
DEF_PCI_AC_NORET(memcpy_toio, (PCI_IO_ADDR d, const void *s, unsigned long n),
61-
(d, s, n), mem, d)
4+
DEF_PCI_AC_RET(inb, u8, (unsigned long port), (port))
5+
DEF_PCI_AC_RET(inw, u16, (unsigned long port), (port))
6+
DEF_PCI_AC_RET(inl, u32, (unsigned long port), (port))
7+
DEF_PCI_AC_NORET(outb, (u8 val, unsigned long port), (val, port))
8+
DEF_PCI_AC_NORET(outw, (u16 val, unsigned long port), (val, port))
9+
DEF_PCI_AC_NORET(outl, (u32 val, unsigned long port), (val, port))
10+
DEF_PCI_AC_NORET(insb, (unsigned long p, void *b, unsigned long c), (p, b, c))
11+
DEF_PCI_AC_NORET(insw, (unsigned long p, void *b, unsigned long c), (p, b, c))
12+
DEF_PCI_AC_NORET(insl, (unsigned long p, void *b, unsigned long c), (p, b, c))
13+
DEF_PCI_AC_NORET(outsb, (unsigned long p, const void *b, unsigned long c), (p, b, c))
14+
DEF_PCI_AC_NORET(outsw, (unsigned long p, const void *b, unsigned long c), (p, b, c))
15+
DEF_PCI_AC_NORET(outsl, (unsigned long p, const void *b, unsigned long c), (p, b, c))

arch/powerpc/include/asm/io.h

Lines changed: 141 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -580,19 +580,149 @@ __do_out_asm(_rec_outl, "stwbrx")
580580
_memcpy_fromio(dst, src, n)
581581
#endif /* !CONFIG_EEH */
582582

583+
static inline u8 readb(const PCI_IO_ADDR addr)
584+
{
585+
return __do_readb(addr);
586+
}
587+
#define readb readb
588+
589+
static inline u16 readw(const PCI_IO_ADDR addr)
590+
{
591+
return __do_readw(addr);
592+
}
593+
#define readw readw
594+
595+
static inline u32 readl(const PCI_IO_ADDR addr)
596+
{
597+
return __do_readl(addr);
598+
}
599+
#define readl readl
600+
601+
static inline u16 readw_be(const PCI_IO_ADDR addr)
602+
{
603+
return __do_readw_be(addr);
604+
}
605+
606+
static inline u32 readl_be(const PCI_IO_ADDR addr)
607+
{
608+
return __do_readl_be(addr);
609+
}
610+
611+
static inline void writeb(u8 val, PCI_IO_ADDR addr)
612+
{
613+
__do_writeb(val, addr);
614+
}
615+
#define writeb writeb
616+
617+
static inline void writew(u16 val, PCI_IO_ADDR addr)
618+
{
619+
__do_writew(val, addr);
620+
}
621+
#define writew writew
622+
623+
static inline void writel(u32 val, PCI_IO_ADDR addr)
624+
{
625+
__do_writel(val, addr);
626+
}
627+
#define writel writel
628+
629+
static inline void writew_be(u16 val, PCI_IO_ADDR addr)
630+
{
631+
__do_writew_be(val, addr);
632+
}
633+
634+
static inline void writel_be(u32 val, PCI_IO_ADDR addr)
635+
{
636+
__do_writel_be(val, addr);
637+
}
638+
639+
static inline void readsb(const PCI_IO_ADDR a, void *b, unsigned long c)
640+
{
641+
__do_readsb(a, b, c);
642+
}
643+
#define readsb readsb
644+
645+
static inline void readsw(const PCI_IO_ADDR a, void *b, unsigned long c)
646+
{
647+
__do_readsw(a, b, c);
648+
}
649+
#define readsw readsw
650+
651+
static inline void readsl(const PCI_IO_ADDR a, void *b, unsigned long c)
652+
{
653+
__do_readsl(a, b, c);
654+
}
655+
#define readsl readsl
656+
657+
static inline void writesb(PCI_IO_ADDR a, const void *b, unsigned long c)
658+
{
659+
__do_writesb(a, b, c);
660+
}
661+
#define writesb writesb
662+
663+
static inline void writesw(PCI_IO_ADDR a, const void *b, unsigned long c)
664+
{
665+
__do_writesw(a, b, c);
666+
}
667+
#define writesw writesw
668+
669+
static inline void writesl(PCI_IO_ADDR a, const void *b, unsigned long c)
670+
{
671+
__do_writesl(a, b, c);
672+
}
673+
#define writesl writesl
674+
675+
static inline void memset_io(PCI_IO_ADDR a, int c, unsigned long n)
676+
{
677+
__do_memset_io(a, c, n);
678+
}
679+
#define memset_io memset_io
680+
681+
static inline void memcpy_fromio(void *d, const PCI_IO_ADDR s, unsigned long n)
682+
{
683+
__do_memcpy_fromio(d, s, n);
684+
}
685+
#define memcpy_fromio memcpy_fromio
686+
687+
static inline void memcpy_toio(PCI_IO_ADDR d, const void *s, unsigned long n)
688+
{
689+
__do_memcpy_toio(d, s, n);
690+
}
691+
#define memcpy_toio memcpy_toio
692+
693+
#ifdef __powerpc64__
694+
static inline u64 readq(const PCI_IO_ADDR addr)
695+
{
696+
return __do_readq(addr);
697+
}
698+
699+
static inline u64 readq_be(const PCI_IO_ADDR addr)
700+
{
701+
return __do_readq_be(addr);
702+
}
703+
704+
static inline void writeq(u64 val, PCI_IO_ADDR addr)
705+
{
706+
__do_writeq(val, addr);
707+
}
708+
709+
static inline void writeq_be(u64 val, PCI_IO_ADDR addr)
710+
{
711+
__do_writeq_be(val, addr);
712+
}
713+
#endif /* __powerpc64__ */
714+
583715
#ifdef CONFIG_PPC_INDIRECT_PIO
584-
#define DEF_PCI_HOOK_pio(x) x
716+
#define DEF_PCI_HOOK(x) x
585717
#else
586-
#define DEF_PCI_HOOK_pio(x) NULL
718+
#define DEF_PCI_HOOK(x) NULL
587719
#endif
588720

589-
#define DEF_PCI_HOOK_mem(x) NULL
590-
591721
/* Structure containing all the hooks */
592722
extern struct ppc_pci_io {
593723

594-
#define DEF_PCI_AC_RET(name, ret, at, al, space, aa) ret (*name) at;
595-
#define DEF_PCI_AC_NORET(name, at, al, space, aa) void (*name) at;
724+
#define DEF_PCI_AC_RET(name, ret, at, al) ret (*name) at;
725+
#define DEF_PCI_AC_NORET(name, at, al) void (*name) at;
596726

597727
#include <asm/io-defs.h>
598728

@@ -602,18 +732,18 @@ extern struct ppc_pci_io {
602732
} ppc_pci_io;
603733

604734
/* The inline wrappers */
605-
#define DEF_PCI_AC_RET(name, ret, at, al, space, aa) \
735+
#define DEF_PCI_AC_RET(name, ret, at, al) \
606736
static inline ret name at \
607737
{ \
608-
if (DEF_PCI_HOOK_##space(ppc_pci_io.name) != NULL) \
738+
if (DEF_PCI_HOOK(ppc_pci_io.name) != NULL) \
609739
return ppc_pci_io.name al; \
610740
return __do_##name al; \
611741
}
612742

613-
#define DEF_PCI_AC_NORET(name, at, al, space, aa) \
743+
#define DEF_PCI_AC_NORET(name, at, al) \
614744
static inline void name at \
615745
{ \
616-
if (DEF_PCI_HOOK_##space(ppc_pci_io.name) != NULL) \
746+
if (DEF_PCI_HOOK(ppc_pci_io.name) != NULL) \
617747
ppc_pci_io.name al; \
618748
else \
619749
__do_##name al; \
@@ -624,21 +754,7 @@ static inline void name at \
624754
#undef DEF_PCI_AC_RET
625755
#undef DEF_PCI_AC_NORET
626756

627-
/* Some drivers check for the presence of readq & writeq with
628-
* a #ifdef, so we make them happy here.
629-
*/
630-
#define readb readb
631-
#define readw readw
632-
#define readl readl
633-
#define writeb writeb
634-
#define writew writew
635-
#define writel writel
636-
#define readsb readsb
637-
#define readsw readsw
638-
#define readsl readsl
639-
#define writesb writesb
640-
#define writesw writesw
641-
#define writesl writesl
757+
// Signal to asm-generic/io.h that we have implemented these.
642758
#define inb inb
643759
#define inw inw
644760
#define inl inl
@@ -655,9 +771,6 @@ static inline void name at \
655771
#define readq readq
656772
#define writeq writeq
657773
#endif
658-
#define memset_io memset_io
659-
#define memcpy_fromio memcpy_fromio
660-
#define memcpy_toio memcpy_toio
661774

662775
/*
663776
* We don't do relaxed operations yet, at least not with this semantic

0 commit comments

Comments
 (0)