Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <mpe@ellerman.id.au>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20241218105523.416573-12-mpe@ellerman.id.au

authored by

Michael Ellerman and committed by
Madhavan Srinivasan
15efd61f de9cc058

+155 -88
+12 -58
arch/powerpc/include/asm/io-defs.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* This file is meant to be include multiple times by other headers */ 3 - /* last 2 argments are used by platforms/cell/io-workarounds.[ch] */ 4 3 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))
+143 -30
arch/powerpc/include/asm/io.h
··· 580 580 _memcpy_fromio(dst, src, n) 581 581 #endif /* !CONFIG_EEH */ 582 582 583 - #ifdef CONFIG_PPC_INDIRECT_PIO 584 - #define DEF_PCI_HOOK_pio(x) x 585 - #else 586 - #define DEF_PCI_HOOK_pio(x) NULL 587 - #endif 583 + static inline u8 readb(const PCI_IO_ADDR addr) 584 + { 585 + return __do_readb(addr); 586 + } 587 + #define readb readb 588 588 589 - #define DEF_PCI_HOOK_mem(x) NULL 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 + 715 + #ifdef CONFIG_PPC_INDIRECT_PIO 716 + #define DEF_PCI_HOOK(x) x 717 + #else 718 + #define DEF_PCI_HOOK(x) NULL 719 + #endif 590 720 591 721 /* Structure containing all the hooks */ 592 722 extern struct ppc_pci_io { 593 723 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; 596 726 597 727 #include <asm/io-defs.h> 598 728 ··· 732 602 } ppc_pci_io; 733 603 734 604 /* The inline wrappers */ 735 - #define DEF_PCI_AC_RET(name, ret, at, al, space, aa) \ 605 + #define DEF_PCI_AC_RET(name, ret, at, al) \ 736 606 static inline ret name at \ 737 607 { \ 738 - if (DEF_PCI_HOOK_##space(ppc_pci_io.name) != NULL) \ 608 + if (DEF_PCI_HOOK(ppc_pci_io.name) != NULL) \ 739 609 return ppc_pci_io.name al; \ 740 610 return __do_##name al; \ 741 611 } 742 612 743 - #define DEF_PCI_AC_NORET(name, at, al, space, aa) \ 613 + #define DEF_PCI_AC_NORET(name, at, al) \ 744 614 static inline void name at \ 745 615 { \ 746 - if (DEF_PCI_HOOK_##space(ppc_pci_io.name) != NULL) \ 616 + if (DEF_PCI_HOOK(ppc_pci_io.name) != NULL) \ 747 617 ppc_pci_io.name al; \ 748 618 else \ 749 619 __do_##name al; \ ··· 754 624 #undef DEF_PCI_AC_RET 755 625 #undef DEF_PCI_AC_NORET 756 626 757 - /* Some drivers check for the presence of readq & writeq with 758 - * a #ifdef, so we make them happy here. 759 - */ 760 - #define readb readb 761 - #define readw readw 762 - #define readl readl 763 - #define writeb writeb 764 - #define writew writew 765 - #define writel writel 766 - #define readsb readsb 767 - #define readsw readsw 768 - #define readsl readsl 769 - #define writesb writesb 770 - #define writesw writesw 771 - #define writesl writesl 627 + // Signal to asm-generic/io.h that we have implemented these. 772 628 #define inb inb 773 629 #define inw inw 774 630 #define inl inl ··· 771 655 #define readq readq 772 656 #define writeq writeq 773 657 #endif 774 - #define memset_io memset_io 775 - #define memcpy_fromio memcpy_fromio 776 - #define memcpy_toio memcpy_toio 777 658 778 659 /* 779 660 * We don't do relaxed operations yet, at least not with this semantic