diff mbox series

[v2,10/11] sh: mm: Convert to GENERIC_IOREMAP

Message ID 20220820003125.353570-11-bhe@redhat.com (mailing list archive)
State New
Headers show
Series mm: ioremap: Convert architectures to take GENERIC_IOREMAP way | expand

Commit Message

Baoquan He Aug. 20, 2022, 12:31 a.m. UTC
Add hook arch_ioremap() and arch_iounmap for sh's special operation when
ioremap() and iounmap(), then ioremap_cache() is converted to use
ioremap_prot() from GENERIC_IOREMAP.

Signed-off-by: Baoquan He <bhe@redhat.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: linux-sh@vger.kernel.org
---
 arch/sh/Kconfig          |  1 +
 arch/sh/include/asm/io.h | 47 +++++++++----------------------
 arch/sh/mm/ioremap.c     | 61 ++++++++--------------------------------
 3 files changed, 26 insertions(+), 83 deletions(-)

Comments

kernel test robot Aug. 20, 2022, 3:41 a.m. UTC | #1
Hi Baoquan,

I love your patch! Yet something to improve:

[auto build test ERROR on akpm-mm/mm-everything]

url:    https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/mm-ioremap-Convert-architectures-to-take-GENERIC_IOREMAP-way/20220820-083435
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
config: sh-allmodconfig
compiler: sh4-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/503a31451202f89e58bc5f0a49261398fafbd90e
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Baoquan-He/mm-ioremap-Convert-architectures-to-take-GENERIC_IOREMAP-way/20220820-083435
        git checkout 503a31451202f89e58bc5f0a49261398fafbd90e
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sh prepare

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/io.h:13,
                    from include/linux/irq.h:20,
                    from include/asm-generic/hardirq.h:17,
                    from arch/sh/include/asm/hardirq.h:9,
                    from include/linux/hardirq.h:11,
                    from include/linux/interrupt.h:11,
                    from include/linux/kernel_stat.h:9,
                    from include/linux/cgroup.h:26,
                    from include/linux/memcontrol.h:13,
                    from include/linux/swap.h:9,
                    from include/linux/suspend.h:5,
                    from arch/sh/kernel/asm-offsets.c:16:
>> arch/sh/include/asm/io.h:259: warning: "ioremap_cache" redefined
     259 | #define ioremap_cache ioremap_cache
         | 
   arch/sh/include/asm/io.h:257: note: this is the location of the previous definition
     257 | #define ioremap_cache(addr, size)  \
         | 
   In file included from arch/sh/include/asm/io.h:263:
>> include/asm-generic/io.h:689:14: error: conflicting types for 'insb'; have 'void(long unsigned int,  void *, unsigned int)'
     689 | #define insb insb
         |              ^~~~
   include/asm-generic/io.h:690:20: note: in expansion of macro 'insb'
     690 | static inline void insb(unsigned long addr, void *buffer, unsigned int count)
         |                    ^~~~
   In file included from arch/sh/include/asm/io.h:220:
   arch/sh/include/asm/io_noioport.h:56:20: note: previous definition of 'insb' with type 'void(long unsigned int,  void *, long unsigned int)'
      56 | static inline void insb(unsigned long port, void *dst, unsigned long count)
         |                    ^~~~
>> include/asm-generic/io.h:697:14: error: conflicting types for 'insw'; have 'void(long unsigned int,  void *, unsigned int)'
     697 | #define insw insw
         |              ^~~~
   include/asm-generic/io.h:698:20: note: in expansion of macro 'insw'
     698 | static inline void insw(unsigned long addr, void *buffer, unsigned int count)
         |                    ^~~~
   arch/sh/include/asm/io_noioport.h:61:20: note: previous definition of 'insw' with type 'void(long unsigned int,  void *, long unsigned int)'
      61 | static inline void insw(unsigned long port, void *dst, unsigned long count)
         |                    ^~~~
>> include/asm-generic/io.h:705:14: error: conflicting types for 'insl'; have 'void(long unsigned int,  void *, unsigned int)'
     705 | #define insl insl
         |              ^~~~
   include/asm-generic/io.h:706:20: note: in expansion of macro 'insl'
     706 | static inline void insl(unsigned long addr, void *buffer, unsigned int count)
         |                    ^~~~
   arch/sh/include/asm/io_noioport.h:66:20: note: previous definition of 'insl' with type 'void(long unsigned int,  void *, long unsigned int)'
      66 | static inline void insl(unsigned long port, void *dst, unsigned long count)
         |                    ^~~~
>> include/asm-generic/io.h:713:15: error: conflicting types for 'outsb'; have 'void(long unsigned int,  const void *, unsigned int)'
     713 | #define outsb outsb
         |               ^~~~~
   include/asm-generic/io.h:714:20: note: in expansion of macro 'outsb'
     714 | static inline void outsb(unsigned long addr, const void *buffer,
         |                    ^~~~~
   arch/sh/include/asm/io_noioport.h:71:20: note: previous definition of 'outsb' with type 'void(long unsigned int,  const void *, long unsigned int)'
      71 | static inline void outsb(unsigned long port, const void *src, unsigned long count)
         |                    ^~~~~
>> include/asm-generic/io.h:722:15: error: conflicting types for 'outsw'; have 'void(long unsigned int,  const void *, unsigned int)'
     722 | #define outsw outsw
         |               ^~~~~
   include/asm-generic/io.h:723:20: note: in expansion of macro 'outsw'
     723 | static inline void outsw(unsigned long addr, const void *buffer,
         |                    ^~~~~
   arch/sh/include/asm/io_noioport.h:76:20: note: previous definition of 'outsw' with type 'void(long unsigned int,  const void *, long unsigned int)'
      76 | static inline void outsw(unsigned long port, const void *src, unsigned long count)
         |                    ^~~~~
>> include/asm-generic/io.h:731:15: error: conflicting types for 'outsl'; have 'void(long unsigned int,  const void *, unsigned int)'
     731 | #define outsl outsl
         |               ^~~~~
   include/asm-generic/io.h:732:20: note: in expansion of macro 'outsl'
     732 | static inline void outsl(unsigned long addr, const void *buffer,
         |                    ^~~~~
   arch/sh/include/asm/io_noioport.h:81:20: note: previous definition of 'outsl' with type 'void(long unsigned int,  const void *, long unsigned int)'
      81 | static inline void outsl(unsigned long port, const void *src, unsigned long count)
         |                    ^~~~~
>> include/asm-generic/io.h:792:17: error: conflicting types for 'ioread8'; have 'u8(const volatile void *)' {aka 'unsigned char(const volatile void *)'}
     792 | #define ioread8 ioread8
         |                 ^~~~~~~
   include/asm-generic/io.h:793:18: note: in expansion of macro 'ioread8'
     793 | static inline u8 ioread8(const volatile void __iomem *addr)
         |                  ^~~~~~~
   In file included from arch/sh/include/asm/io.h:22:
   include/asm-generic/iomap.h:29:21: note: previous declaration of 'ioread8' with type 'unsigned int(const void *)'
      29 | extern unsigned int ioread8(const void __iomem *);
         |                     ^~~~~~~
>> include/asm-generic/io.h:800:18: error: conflicting types for 'ioread16'; have 'u16(const volatile void *)' {aka 'short unsigned int(const volatile void *)'}
     800 | #define ioread16 ioread16
         |                  ^~~~~~~~
   include/asm-generic/io.h:801:19: note: in expansion of macro 'ioread16'
     801 | static inline u16 ioread16(const volatile void __iomem *addr)
         |                   ^~~~~~~~
   include/asm-generic/iomap.h:30:21: note: previous declaration of 'ioread16' with type 'unsigned int(const void *)'
      30 | extern unsigned int ioread16(const void __iomem *);
         |                     ^~~~~~~~
>> include/asm-generic/io.h:808:18: error: conflicting types for 'ioread32'; have 'u32(const volatile void *)' {aka 'unsigned int(const volatile void *)'}
     808 | #define ioread32 ioread32
         |                  ^~~~~~~~
   include/asm-generic/io.h:809:19: note: in expansion of macro 'ioread32'
     809 | static inline u32 ioread32(const volatile void __iomem *addr)
         |                   ^~~~~~~~
   include/asm-generic/iomap.h:32:21: note: previous declaration of 'ioread32' with type 'unsigned int(const void *)'
      32 | extern unsigned int ioread32(const void __iomem *);
         |                     ^~~~~~~~
>> include/asm-generic/io.h:826:18: error: conflicting types for 'iowrite8'; have 'void(u8,  volatile void *)' {aka 'void(unsigned char,  volatile void *)'}
     826 | #define iowrite8 iowrite8
         |                  ^~~~~~~~
   include/asm-generic/io.h:827:20: note: in expansion of macro 'iowrite8'
     827 | static inline void iowrite8(u8 value, volatile void __iomem *addr)
         |                    ^~~~~~~~
   include/asm-generic/iomap.h:50:13: note: previous declaration of 'iowrite8' with type 'void(u8,  void *)' {aka 'void(unsigned char,  void *)'}
      50 | extern void iowrite8(u8, void __iomem *);
         |             ^~~~~~~~
>> include/asm-generic/io.h:834:19: error: conflicting types for 'iowrite16'; have 'void(u16,  volatile void *)' {aka 'void(short unsigned int,  volatile void *)'}
     834 | #define iowrite16 iowrite16
         |                   ^~~~~~~~~
   include/asm-generic/io.h:835:20: note: in expansion of macro 'iowrite16'
     835 | static inline void iowrite16(u16 value, volatile void __iomem *addr)
         |                    ^~~~~~~~~
   include/asm-generic/iomap.h:51:13: note: previous declaration of 'iowrite16' with type 'void(u16,  void *)' {aka 'void(short unsigned int,  void *)'}
      51 | extern void iowrite16(u16, void __iomem *);
         |             ^~~~~~~~~
>> include/asm-generic/io.h:842:19: error: conflicting types for 'iowrite32'; have 'void(u32,  volatile void *)' {aka 'void(unsigned int,  volatile void *)'}
     842 | #define iowrite32 iowrite32
         |                   ^~~~~~~~~
   include/asm-generic/io.h:843:20: note: in expansion of macro 'iowrite32'
     843 | static inline void iowrite32(u32 value, volatile void __iomem *addr)
         |                    ^~~~~~~~~
   include/asm-generic/iomap.h:53:13: note: previous declaration of 'iowrite32' with type 'void(u32,  void *)' {aka 'void(unsigned int,  void *)'}
      53 | extern void iowrite32(u32, void __iomem *);
         |             ^~~~~~~~~
>> include/asm-generic/io.h:860:20: error: conflicting types for 'ioread16be'; have 'u16(const volatile void *)' {aka 'short unsigned int(const volatile void *)'}
     860 | #define ioread16be ioread16be
         |                    ^~~~~~~~~~
   include/asm-generic/io.h:861:19: note: in expansion of macro 'ioread16be'
     861 | static inline u16 ioread16be(const volatile void __iomem *addr)
         |                   ^~~~~~~~~~
   include/asm-generic/iomap.h:31:21: note: previous declaration of 'ioread16be' with type 'unsigned int(const void *)'
      31 | extern unsigned int ioread16be(const void __iomem *);
         |                     ^~~~~~~~~~
>> include/asm-generic/io.h:868:20: error: conflicting types for 'ioread32be'; have 'u32(const volatile void *)' {aka 'unsigned int(const volatile void *)'}
     868 | #define ioread32be ioread32be
         |                    ^~~~~~~~~~
   include/asm-generic/io.h:869:19: note: in expansion of macro 'ioread32be'
     869 | static inline u32 ioread32be(const volatile void __iomem *addr)
         |                   ^~~~~~~~~~
   include/asm-generic/iomap.h:33:21: note: previous declaration of 'ioread32be' with type 'unsigned int(const void *)'
      33 | extern unsigned int ioread32be(const void __iomem *);
         |                     ^~~~~~~~~~
>> include/asm-generic/io.h:886:21: error: conflicting types for 'iowrite16be'; have 'void(u16,  volatile void *)' {aka 'void(short unsigned int,  volatile void *)'}
     886 | #define iowrite16be iowrite16be
         |                     ^~~~~~~~~~~
   include/asm-generic/io.h:887:20: note: in expansion of macro 'iowrite16be'
     887 | static inline void iowrite16be(u16 value, void volatile __iomem *addr)
         |                    ^~~~~~~~~~~
   include/asm-generic/iomap.h:52:13: note: previous declaration of 'iowrite16be' with type 'void(u16,  void *)' {aka 'void(short unsigned int,  void *)'}
      52 | extern void iowrite16be(u16, void __iomem *);
         |             ^~~~~~~~~~~
>> include/asm-generic/io.h:894:21: error: conflicting types for 'iowrite32be'; have 'void(u32,  volatile void *)' {aka 'void(unsigned int,  volatile void *)'}
     894 | #define iowrite32be iowrite32be
         |                     ^~~~~~~~~~~
   include/asm-generic/io.h:895:20: note: in expansion of macro 'iowrite32be'
     895 | static inline void iowrite32be(u32 value, volatile void __iomem *addr)
         |                    ^~~~~~~~~~~
   include/asm-generic/iomap.h:54:13: note: previous declaration of 'iowrite32be' with type 'void(u32,  void *)' {aka 'void(unsigned int,  void *)'}
      54 | extern void iowrite32be(u32, void __iomem *);
         |             ^~~~~~~~~~~
>> include/asm-generic/io.h:912:21: error: conflicting types for 'ioread8_rep'; have 'void(const volatile void *, void *, unsigned int)'
     912 | #define ioread8_rep ioread8_rep
         |                     ^~~~~~~~~~~
   include/asm-generic/io.h:913:20: note: in expansion of macro 'ioread8_rep'
     913 | static inline void ioread8_rep(const volatile void __iomem *addr, void *buffer,
         |                    ^~~~~~~~~~~
   include/asm-generic/iomap.h:82:13: note: previous declaration of 'ioread8_rep' with type 'void(const void *, void *, long unsigned int)'
      82 | extern void ioread8_rep(const void __iomem *port, void *buf, unsigned long count);
         |             ^~~~~~~~~~~
   include/asm-generic/io.h: In function 'ioread8_rep':
>> include/asm-generic/io.h:916:16: warning: passing argument 1 of '__raw_readsb' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     916 |         readsb(addr, buffer, count);
         |                ^~~~
   arch/sh/include/asm/io.h:59:46: note: in definition of macro 'readsb'
      59 | #define readsb(p,d,l)           __raw_readsb(p,d,l)
         |                                              ^
   arch/sh/include/asm/io.h:103:60: note: expected 'volatile void *' but argument is of type 'const volatile void *'
     103 | static inline void pfx##reads##bwlq(volatile void __iomem *mem,         \
         |                                     ~~~~~~~~~~~~~~~~~~~~~~~^~~
   arch/sh/include/asm/io.h:114:1: note: in expansion of macro '__BUILD_MEMORY_STRING'
     114 | __BUILD_MEMORY_STRING(__raw_, b, u8)
         | ^~~~~~~~~~~~~~~~~~~~~
   include/asm-generic/io.h: At top level:
>> include/asm-generic/io.h:921:22: error: conflicting types for 'ioread16_rep'; have 'void(const volatile void *, void *, unsigned int)'
     921 | #define ioread16_rep ioread16_rep
         |                      ^~~~~~~~~~~~
   include/asm-generic/io.h:922:20: note: in expansion of macro 'ioread16_rep'
     922 | static inline void ioread16_rep(const volatile void __iomem *addr,
         |                    ^~~~~~~~~~~~
   include/asm-generic/iomap.h:83:13: note: previous declaration of 'ioread16_rep' with type 'void(const void *, void *, long unsigned int)'
      83 | extern void ioread16_rep(const void __iomem *port, void *buf, unsigned long count);
         |             ^~~~~~~~~~~~
   include/asm-generic/io.h: In function 'ioread16_rep':
   include/asm-generic/io.h:925:16: warning: passing argument 1 of '__raw_readsw' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     925 |         readsw(addr, buffer, count);
         |                ^~~~
   arch/sh/include/asm/io.h:60:46: note: in definition of macro 'readsw'
      60 | #define readsw(p,d,l)           __raw_readsw(p,d,l)
         |                                              ^
   arch/sh/include/asm/io.h:103:60: note: expected 'volatile void *' but argument is of type 'const volatile void *'
     103 | static inline void pfx##reads##bwlq(volatile void __iomem *mem,         \
         |                                     ~~~~~~~~~~~~~~~~~~~~~~~^~~
   arch/sh/include/asm/io.h:115:1: note: in expansion of macro '__BUILD_MEMORY_STRING'
     115 | __BUILD_MEMORY_STRING(__raw_, w, u16)
         | ^~~~~~~~~~~~~~~~~~~~~
   include/asm-generic/io.h: At top level:
   include/asm-generic/io.h:930:22: error: conflicting types for 'ioread32_rep'; have 'void(const volatile void *, void *, unsigned int)'
     930 | #define ioread32_rep ioread32_rep
         |                      ^~~~~~~~~~~~
   include/asm-generic/io.h:931:20: note: in expansion of macro 'ioread32_rep'
     931 | static inline void ioread32_rep(const volatile void __iomem *addr,
         |                    ^~~~~~~~~~~~
   include/asm-generic/iomap.h:84:13: note: previous declaration of 'ioread32_rep' with type 'void(const void *, void *, long unsigned int)'
      84 | extern void ioread32_rep(const void __iomem *port, void *buf, unsigned long count);
         |             ^~~~~~~~~~~~
   include/asm-generic/io.h: In function 'ioread32_rep':
   include/asm-generic/io.h:934:16: warning: passing argument 1 of '__raw_readsl' discards 'volatile' qualifier from pointer target type [-Wdiscarded-qualifiers]
     934 |         readsl(addr, buffer, count);
         |                ^~~~
   arch/sh/include/asm/io.h:61:46: note: in definition of macro 'readsl'
      61 | #define readsl(p,d,l)           __raw_readsl(p,d,l)
         |                                              ^
   arch/sh/include/asm/io.h:118:39: note: expected 'const void *' but argument is of type 'const volatile void *'
     118 | void __raw_readsl(const void __iomem *addr, void *data, int longlen);
         |                   ~~~~~~~~~~~~~~~~~~~~^~~~
   include/asm-generic/io.h: At top level:
   include/asm-generic/io.h:950:22: error: conflicting types for 'iowrite8_rep'; have 'void(volatile void *, const void *, unsigned int)'
     950 | #define iowrite8_rep iowrite8_rep
         |                      ^~~~~~~~~~~~
   include/asm-generic/io.h:951:20: note: in expansion of macro 'iowrite8_rep'
     951 | static inline void iowrite8_rep(volatile void __iomem *addr,
         |                    ^~~~~~~~~~~~
   include/asm-generic/iomap.h:86:13: note: previous declaration of 'iowrite8_rep' with type 'void(void *, const void *, long unsigned int)'
      86 | extern void iowrite8_rep(void __iomem *port, const void *buf, unsigned long count);
         |             ^~~~~~~~~~~~
   include/asm-generic/io.h:960:23: error: conflicting types for 'iowrite16_rep'; have 'void(volatile void *, const void *, unsigned int)'
     960 | #define iowrite16_rep iowrite16_rep
         |                       ^~~~~~~~~~~~~
   include/asm-generic/io.h:961:20: note: in expansion of macro 'iowrite16_rep'
     961 | static inline void iowrite16_rep(volatile void __iomem *addr,
         |                    ^~~~~~~~~~~~~
   include/asm-generic/iomap.h:87:13: note: previous declaration of 'iowrite16_rep' with type 'void(void *, const void *, long unsigned int)'
      87 | extern void iowrite16_rep(void __iomem *port, const void *buf, unsigned long count);
         |             ^~~~~~~~~~~~~
   include/asm-generic/io.h:970:23: error: conflicting types for 'iowrite32_rep'; have 'void(volatile void *, const void *, unsigned int)'
     970 | #define iowrite32_rep iowrite32_rep
         |                       ^~~~~~~~~~~~~
   include/asm-generic/io.h:971:20: note: in expansion of macro 'iowrite32_rep'
     971 | static inline void iowrite32_rep(volatile void __iomem *addr,
         |                    ^~~~~~~~~~~~~
   include/asm-generic/iomap.h:88:13: note: previous declaration of 'iowrite32_rep' with type 'void(void *, const void *, long unsigned int)'
      88 | extern void iowrite32_rep(void __iomem *port, const void *buf, unsigned long count);
         |             ^~~~~~~~~~~~~
   include/asm-generic/io.h: In function 'iowrite32_rep':
   include/asm-generic/io.h:975:17: warning: passing argument 1 of '__raw_writesl' discards 'volatile' qualifier from pointer target type [-Wdiscarded-qualifiers]
     975 |         writesl(addr, buffer, count);
         |                 ^~~~
   arch/sh/include/asm/io.h:65:47: note: in definition of macro 'writesl'
      65 | #define writesl(p,d,l)          __raw_writesl(p,d,l)
         |                                               ^
   arch/sh/include/asm/io.h:117:34: note: expected 'void *' but argument is of type 'volatile void *'
     117 | void __raw_writesl(void __iomem *addr, const void *data, int longlen);
         |                    ~~~~~~~~~~~~~~^~~~
   include/asm-generic/io.h: At top level:
   include/asm-generic/io.h:1177:19: error: conflicting types for 'memset_io'; have 'void(volatile void *, int,  size_t)' {aka 'void(volatile void *, int,  unsigned int)'}
    1177 | #define memset_io memset_io
         |                   ^~~~~~~~~
   include/asm-generic/io.h:1186:20: note: in expansion of macro 'memset_io'
    1186 | static inline void memset_io(volatile void __iomem *addr, int value,
         |                    ^~~~~~~~~
   arch/sh/include/asm/io.h:230:6: note: previous declaration of 'memset_io' with type 'void(volatile void *, int,  long unsigned int)'
     230 | void memset_io(volatile void __iomem *, int, unsigned long);
         |      ^~~~~~~~~
   include/asm-generic/io.h:1194:23: error: conflicting types for 'memcpy_fromio'; have 'void(void *, const volatile void *, size_t)' {aka 'void(void *, const volatile void *, unsigned int)'}
    1194 | #define memcpy_fromio memcpy_fromio
         |                       ^~~~~~~~~~~~~
   include/asm-generic/io.h:1203:20: note: in expansion of macro 'memcpy_fromio'
    1203 | static inline void memcpy_fromio(void *buffer,
         |                    ^~~~~~~~~~~~~
   arch/sh/include/asm/io.h:228:6: note: previous declaration of 'memcpy_fromio' with type 'void(void *, const volatile void *, long unsigned int)'
     228 | void memcpy_fromio(void *, const volatile void __iomem *, unsigned long);
         |      ^~~~~~~~~~~~~
   include/asm-generic/io.h:1212:21: error: conflicting types for 'memcpy_toio'; have 'void(volatile void *, const void *, size_t)' {aka 'void(volatile void *, const void *, unsigned int)'}
    1212 | #define memcpy_toio memcpy_toio


vim +689 include/asm-generic/io.h

9216efafc52ff9 Thierry Reding 2014-10-01  682  
9ab3a7a0d2b417 Thierry Reding 2014-07-04  683  /*
9ab3a7a0d2b417 Thierry Reding 2014-07-04  684   * {in,out}s{b,w,l}{,_p}() are variants of the above that repeatedly access a
9ab3a7a0d2b417 Thierry Reding 2014-07-04  685   * single I/O port multiple times.
9ab3a7a0d2b417 Thierry Reding 2014-07-04  686   */
9ab3a7a0d2b417 Thierry Reding 2014-07-04  687  
9ab3a7a0d2b417 Thierry Reding 2014-07-04  688  #ifndef insb
9ab3a7a0d2b417 Thierry Reding 2014-07-04 @689  #define insb insb
9ab3a7a0d2b417 Thierry Reding 2014-07-04  690  static inline void insb(unsigned long addr, void *buffer, unsigned int count)
9ab3a7a0d2b417 Thierry Reding 2014-07-04  691  {
9ab3a7a0d2b417 Thierry Reding 2014-07-04  692  	readsb(PCI_IOBASE + addr, buffer, count);
9ab3a7a0d2b417 Thierry Reding 2014-07-04  693  }
9ab3a7a0d2b417 Thierry Reding 2014-07-04  694  #endif
9ab3a7a0d2b417 Thierry Reding 2014-07-04  695  
9ab3a7a0d2b417 Thierry Reding 2014-07-04  696  #ifndef insw
9ab3a7a0d2b417 Thierry Reding 2014-07-04 @697  #define insw insw
9ab3a7a0d2b417 Thierry Reding 2014-07-04  698  static inline void insw(unsigned long addr, void *buffer, unsigned int count)
9ab3a7a0d2b417 Thierry Reding 2014-07-04  699  {
9ab3a7a0d2b417 Thierry Reding 2014-07-04  700  	readsw(PCI_IOBASE + addr, buffer, count);
9ab3a7a0d2b417 Thierry Reding 2014-07-04  701  }
9ab3a7a0d2b417 Thierry Reding 2014-07-04  702  #endif
9ab3a7a0d2b417 Thierry Reding 2014-07-04  703  
9ab3a7a0d2b417 Thierry Reding 2014-07-04  704  #ifndef insl
9ab3a7a0d2b417 Thierry Reding 2014-07-04 @705  #define insl insl
9ab3a7a0d2b417 Thierry Reding 2014-07-04  706  static inline void insl(unsigned long addr, void *buffer, unsigned int count)
9ab3a7a0d2b417 Thierry Reding 2014-07-04  707  {
9ab3a7a0d2b417 Thierry Reding 2014-07-04  708  	readsl(PCI_IOBASE + addr, buffer, count);
9ab3a7a0d2b417 Thierry Reding 2014-07-04  709  }
9ab3a7a0d2b417 Thierry Reding 2014-07-04  710  #endif
9ab3a7a0d2b417 Thierry Reding 2014-07-04  711  
9ab3a7a0d2b417 Thierry Reding 2014-07-04  712  #ifndef outsb
9ab3a7a0d2b417 Thierry Reding 2014-07-04 @713  #define outsb outsb
9ab3a7a0d2b417 Thierry Reding 2014-07-04  714  static inline void outsb(unsigned long addr, const void *buffer,
9ab3a7a0d2b417 Thierry Reding 2014-07-04  715  			 unsigned int count)
9ab3a7a0d2b417 Thierry Reding 2014-07-04  716  {
9ab3a7a0d2b417 Thierry Reding 2014-07-04  717  	writesb(PCI_IOBASE + addr, buffer, count);
9ab3a7a0d2b417 Thierry Reding 2014-07-04  718  }
9ab3a7a0d2b417 Thierry Reding 2014-07-04  719  #endif
9ab3a7a0d2b417 Thierry Reding 2014-07-04  720  
9ab3a7a0d2b417 Thierry Reding 2014-07-04  721  #ifndef outsw
9ab3a7a0d2b417 Thierry Reding 2014-07-04 @722  #define outsw outsw
9ab3a7a0d2b417 Thierry Reding 2014-07-04  723  static inline void outsw(unsigned long addr, const void *buffer,
9ab3a7a0d2b417 Thierry Reding 2014-07-04  724  			 unsigned int count)
9ab3a7a0d2b417 Thierry Reding 2014-07-04  725  {
9ab3a7a0d2b417 Thierry Reding 2014-07-04  726  	writesw(PCI_IOBASE + addr, buffer, count);
9ab3a7a0d2b417 Thierry Reding 2014-07-04  727  }
9ab3a7a0d2b417 Thierry Reding 2014-07-04  728  #endif
9ab3a7a0d2b417 Thierry Reding 2014-07-04  729  
9ab3a7a0d2b417 Thierry Reding 2014-07-04  730  #ifndef outsl
9ab3a7a0d2b417 Thierry Reding 2014-07-04 @731  #define outsl outsl
9ab3a7a0d2b417 Thierry Reding 2014-07-04  732  static inline void outsl(unsigned long addr, const void *buffer,
9ab3a7a0d2b417 Thierry Reding 2014-07-04  733  			 unsigned int count)
9ab3a7a0d2b417 Thierry Reding 2014-07-04  734  {
9ab3a7a0d2b417 Thierry Reding 2014-07-04  735  	writesl(PCI_IOBASE + addr, buffer, count);
9ab3a7a0d2b417 Thierry Reding 2014-07-04  736  }
9ab3a7a0d2b417 Thierry Reding 2014-07-04  737  #endif
9ab3a7a0d2b417 Thierry Reding 2014-07-04  738  
9ab3a7a0d2b417 Thierry Reding 2014-07-04  739  #ifndef insb_p
9ab3a7a0d2b417 Thierry Reding 2014-07-04  740  #define insb_p insb_p
9ab3a7a0d2b417 Thierry Reding 2014-07-04  741  static inline void insb_p(unsigned long addr, void *buffer, unsigned int count)
9ab3a7a0d2b417 Thierry Reding 2014-07-04  742  {
9ab3a7a0d2b417 Thierry Reding 2014-07-04  743  	insb(addr, buffer, count);
9ab3a7a0d2b417 Thierry Reding 2014-07-04  744  }
9ab3a7a0d2b417 Thierry Reding 2014-07-04  745  #endif
9ab3a7a0d2b417 Thierry Reding 2014-07-04  746  
9ab3a7a0d2b417 Thierry Reding 2014-07-04  747  #ifndef insw_p
9ab3a7a0d2b417 Thierry Reding 2014-07-04  748  #define insw_p insw_p
9ab3a7a0d2b417 Thierry Reding 2014-07-04  749  static inline void insw_p(unsigned long addr, void *buffer, unsigned int count)
9ab3a7a0d2b417 Thierry Reding 2014-07-04  750  {
9ab3a7a0d2b417 Thierry Reding 2014-07-04  751  	insw(addr, buffer, count);
9ab3a7a0d2b417 Thierry Reding 2014-07-04  752  }
9ab3a7a0d2b417 Thierry Reding 2014-07-04  753  #endif
9ab3a7a0d2b417 Thierry Reding 2014-07-04  754  
9ab3a7a0d2b417 Thierry Reding 2014-07-04  755  #ifndef insl_p
9ab3a7a0d2b417 Thierry Reding 2014-07-04  756  #define insl_p insl_p
9ab3a7a0d2b417 Thierry Reding 2014-07-04  757  static inline void insl_p(unsigned long addr, void *buffer, unsigned int count)
9ab3a7a0d2b417 Thierry Reding 2014-07-04  758  {
9ab3a7a0d2b417 Thierry Reding 2014-07-04  759  	insl(addr, buffer, count);
9ab3a7a0d2b417 Thierry Reding 2014-07-04  760  }
9ab3a7a0d2b417 Thierry Reding 2014-07-04  761  #endif
9ab3a7a0d2b417 Thierry Reding 2014-07-04  762  
9ab3a7a0d2b417 Thierry Reding 2014-07-04  763  #ifndef outsb_p
9ab3a7a0d2b417 Thierry Reding 2014-07-04  764  #define outsb_p outsb_p
9ab3a7a0d2b417 Thierry Reding 2014-07-04  765  static inline void outsb_p(unsigned long addr, const void *buffer,
9ab3a7a0d2b417 Thierry Reding 2014-07-04  766  			   unsigned int count)
9ab3a7a0d2b417 Thierry Reding 2014-07-04  767  {
9ab3a7a0d2b417 Thierry Reding 2014-07-04  768  	outsb(addr, buffer, count);
9ab3a7a0d2b417 Thierry Reding 2014-07-04  769  }
9ab3a7a0d2b417 Thierry Reding 2014-07-04  770  #endif
9ab3a7a0d2b417 Thierry Reding 2014-07-04  771  
9ab3a7a0d2b417 Thierry Reding 2014-07-04  772  #ifndef outsw_p
9ab3a7a0d2b417 Thierry Reding 2014-07-04  773  #define outsw_p outsw_p
9ab3a7a0d2b417 Thierry Reding 2014-07-04  774  static inline void outsw_p(unsigned long addr, const void *buffer,
9ab3a7a0d2b417 Thierry Reding 2014-07-04  775  			   unsigned int count)
9ab3a7a0d2b417 Thierry Reding 2014-07-04  776  {
9ab3a7a0d2b417 Thierry Reding 2014-07-04  777  	outsw(addr, buffer, count);
9ab3a7a0d2b417 Thierry Reding 2014-07-04  778  }
9ab3a7a0d2b417 Thierry Reding 2014-07-04  779  #endif
9ab3a7a0d2b417 Thierry Reding 2014-07-04  780  
9ab3a7a0d2b417 Thierry Reding 2014-07-04  781  #ifndef outsl_p
9ab3a7a0d2b417 Thierry Reding 2014-07-04  782  #define outsl_p outsl_p
9ab3a7a0d2b417 Thierry Reding 2014-07-04  783  static inline void outsl_p(unsigned long addr, const void *buffer,
9ab3a7a0d2b417 Thierry Reding 2014-07-04  784  			   unsigned int count)
9ab3a7a0d2b417 Thierry Reding 2014-07-04  785  {
9ab3a7a0d2b417 Thierry Reding 2014-07-04  786  	outsl(addr, buffer, count);
9ab3a7a0d2b417 Thierry Reding 2014-07-04  787  }
9ab3a7a0d2b417 Thierry Reding 2014-07-04  788  #endif
9ab3a7a0d2b417 Thierry Reding 2014-07-04  789  
9216efafc52ff9 Thierry Reding 2014-10-01  790  #ifndef CONFIG_GENERIC_IOMAP
9216efafc52ff9 Thierry Reding 2014-10-01  791  #ifndef ioread8
9216efafc52ff9 Thierry Reding 2014-10-01 @792  #define ioread8 ioread8
9216efafc52ff9 Thierry Reding 2014-10-01  793  static inline u8 ioread8(const volatile void __iomem *addr)
9216efafc52ff9 Thierry Reding 2014-10-01  794  {
9216efafc52ff9 Thierry Reding 2014-10-01  795  	return readb(addr);
9216efafc52ff9 Thierry Reding 2014-10-01  796  }
9216efafc52ff9 Thierry Reding 2014-10-01  797  #endif
9216efafc52ff9 Thierry Reding 2014-10-01  798  
9216efafc52ff9 Thierry Reding 2014-10-01  799  #ifndef ioread16
9216efafc52ff9 Thierry Reding 2014-10-01 @800  #define ioread16 ioread16
9216efafc52ff9 Thierry Reding 2014-10-01  801  static inline u16 ioread16(const volatile void __iomem *addr)
9216efafc52ff9 Thierry Reding 2014-10-01  802  {
9216efafc52ff9 Thierry Reding 2014-10-01  803  	return readw(addr);
9216efafc52ff9 Thierry Reding 2014-10-01  804  }
9216efafc52ff9 Thierry Reding 2014-10-01  805  #endif
9216efafc52ff9 Thierry Reding 2014-10-01  806  
9216efafc52ff9 Thierry Reding 2014-10-01  807  #ifndef ioread32
9216efafc52ff9 Thierry Reding 2014-10-01 @808  #define ioread32 ioread32
9216efafc52ff9 Thierry Reding 2014-10-01  809  static inline u32 ioread32(const volatile void __iomem *addr)
9216efafc52ff9 Thierry Reding 2014-10-01  810  {
9216efafc52ff9 Thierry Reding 2014-10-01  811  	return readl(addr);
9216efafc52ff9 Thierry Reding 2014-10-01  812  }
9216efafc52ff9 Thierry Reding 2014-10-01  813  #endif
9216efafc52ff9 Thierry Reding 2014-10-01  814  
9e44fb1816dba8 Horia Geantă   2016-05-19  815  #ifdef CONFIG_64BIT
9e44fb1816dba8 Horia Geantă   2016-05-19  816  #ifndef ioread64
9e44fb1816dba8 Horia Geantă   2016-05-19  817  #define ioread64 ioread64
9e44fb1816dba8 Horia Geantă   2016-05-19  818  static inline u64 ioread64(const volatile void __iomem *addr)
9e44fb1816dba8 Horia Geantă   2016-05-19  819  {
9e44fb1816dba8 Horia Geantă   2016-05-19  820  	return readq(addr);
9e44fb1816dba8 Horia Geantă   2016-05-19  821  }
9e44fb1816dba8 Horia Geantă   2016-05-19  822  #endif
9e44fb1816dba8 Horia Geantă   2016-05-19  823  #endif /* CONFIG_64BIT */
9e44fb1816dba8 Horia Geantă   2016-05-19  824  
9216efafc52ff9 Thierry Reding 2014-10-01  825  #ifndef iowrite8
9216efafc52ff9 Thierry Reding 2014-10-01 @826  #define iowrite8 iowrite8
9216efafc52ff9 Thierry Reding 2014-10-01  827  static inline void iowrite8(u8 value, volatile void __iomem *addr)
9216efafc52ff9 Thierry Reding 2014-10-01  828  {
9216efafc52ff9 Thierry Reding 2014-10-01  829  	writeb(value, addr);
9216efafc52ff9 Thierry Reding 2014-10-01  830  }
9216efafc52ff9 Thierry Reding 2014-10-01  831  #endif
9216efafc52ff9 Thierry Reding 2014-10-01  832  
9216efafc52ff9 Thierry Reding 2014-10-01  833  #ifndef iowrite16
9216efafc52ff9 Thierry Reding 2014-10-01 @834  #define iowrite16 iowrite16
9216efafc52ff9 Thierry Reding 2014-10-01  835  static inline void iowrite16(u16 value, volatile void __iomem *addr)
9216efafc52ff9 Thierry Reding 2014-10-01  836  {
9216efafc52ff9 Thierry Reding 2014-10-01  837  	writew(value, addr);
9216efafc52ff9 Thierry Reding 2014-10-01  838  }
9216efafc52ff9 Thierry Reding 2014-10-01  839  #endif
9216efafc52ff9 Thierry Reding 2014-10-01  840  
9216efafc52ff9 Thierry Reding 2014-10-01  841  #ifndef iowrite32
9216efafc52ff9 Thierry Reding 2014-10-01 @842  #define iowrite32 iowrite32
9216efafc52ff9 Thierry Reding 2014-10-01  843  static inline void iowrite32(u32 value, volatile void __iomem *addr)
9216efafc52ff9 Thierry Reding 2014-10-01  844  {
9216efafc52ff9 Thierry Reding 2014-10-01  845  	writel(value, addr);
9216efafc52ff9 Thierry Reding 2014-10-01  846  }
9216efafc52ff9 Thierry Reding 2014-10-01  847  #endif
9216efafc52ff9 Thierry Reding 2014-10-01  848  
9e44fb1816dba8 Horia Geantă   2016-05-19  849  #ifdef CONFIG_64BIT
9e44fb1816dba8 Horia Geantă   2016-05-19  850  #ifndef iowrite64
9e44fb1816dba8 Horia Geantă   2016-05-19  851  #define iowrite64 iowrite64
9e44fb1816dba8 Horia Geantă   2016-05-19  852  static inline void iowrite64(u64 value, volatile void __iomem *addr)
9e44fb1816dba8 Horia Geantă   2016-05-19  853  {
9e44fb1816dba8 Horia Geantă   2016-05-19  854  	writeq(value, addr);
9e44fb1816dba8 Horia Geantă   2016-05-19  855  }
9e44fb1816dba8 Horia Geantă   2016-05-19  856  #endif
9e44fb1816dba8 Horia Geantă   2016-05-19  857  #endif /* CONFIG_64BIT */
9e44fb1816dba8 Horia Geantă   2016-05-19  858  
9216efafc52ff9 Thierry Reding 2014-10-01  859  #ifndef ioread16be
9216efafc52ff9 Thierry Reding 2014-10-01 @860  #define ioread16be ioread16be
9216efafc52ff9 Thierry Reding 2014-10-01  861  static inline u16 ioread16be(const volatile void __iomem *addr)
9216efafc52ff9 Thierry Reding 2014-10-01  862  {
7a1aedba706194 Horia Geantă   2016-05-19  863  	return swab16(readw(addr));
9216efafc52ff9 Thierry Reding 2014-10-01  864  }
9216efafc52ff9 Thierry Reding 2014-10-01  865  #endif
9216efafc52ff9 Thierry Reding 2014-10-01  866  
9216efafc52ff9 Thierry Reding 2014-10-01  867  #ifndef ioread32be
9216efafc52ff9 Thierry Reding 2014-10-01 @868  #define ioread32be ioread32be
9216efafc52ff9 Thierry Reding 2014-10-01  869  static inline u32 ioread32be(const volatile void __iomem *addr)
9216efafc52ff9 Thierry Reding 2014-10-01  870  {
7a1aedba706194 Horia Geantă   2016-05-19  871  	return swab32(readl(addr));
9216efafc52ff9 Thierry Reding 2014-10-01  872  }
9216efafc52ff9 Thierry Reding 2014-10-01  873  #endif
9216efafc52ff9 Thierry Reding 2014-10-01  874  
9e44fb1816dba8 Horia Geantă   2016-05-19  875  #ifdef CONFIG_64BIT
9e44fb1816dba8 Horia Geantă   2016-05-19  876  #ifndef ioread64be
9e44fb1816dba8 Horia Geantă   2016-05-19  877  #define ioread64be ioread64be
9e44fb1816dba8 Horia Geantă   2016-05-19  878  static inline u64 ioread64be(const volatile void __iomem *addr)
9e44fb1816dba8 Horia Geantă   2016-05-19  879  {
9e44fb1816dba8 Horia Geantă   2016-05-19  880  	return swab64(readq(addr));
9e44fb1816dba8 Horia Geantă   2016-05-19  881  }
9e44fb1816dba8 Horia Geantă   2016-05-19  882  #endif
9e44fb1816dba8 Horia Geantă   2016-05-19  883  #endif /* CONFIG_64BIT */
9e44fb1816dba8 Horia Geantă   2016-05-19  884  
9216efafc52ff9 Thierry Reding 2014-10-01  885  #ifndef iowrite16be
9216efafc52ff9 Thierry Reding 2014-10-01 @886  #define iowrite16be iowrite16be
9216efafc52ff9 Thierry Reding 2014-10-01  887  static inline void iowrite16be(u16 value, void volatile __iomem *addr)
9216efafc52ff9 Thierry Reding 2014-10-01  888  {
7a1aedba706194 Horia Geantă   2016-05-19  889  	writew(swab16(value), addr);
9216efafc52ff9 Thierry Reding 2014-10-01  890  }
9216efafc52ff9 Thierry Reding 2014-10-01  891  #endif
9216efafc52ff9 Thierry Reding 2014-10-01  892
Christoph Hellwig Aug. 21, 2022, 7:06 a.m. UTC | #2
> +void __iomem *
> +arch_ioremap(phys_addr_t *paddr, size_t size, unsigned long *prot_val);
> +#define arch_ioremap arch_ioremap

Shouldn't this still be under CONFIG_MMU?
Baoquan He Sept. 1, 2022, 7:36 a.m. UTC | #3
On 08/21/22 at 12:06am, Christoph Hellwig wrote:
> > +void __iomem *
> > +arch_ioremap(phys_addr_t *paddr, size_t size, unsigned long *prot_val);
> > +#define arch_ioremap arch_ioremap
> 
> Shouldn't this still be under CONFIG_MMU?

Yeah, you are right, will put them under CONFIG_MMU.

I thought making GENERIC_IOREMAP depend MMU in Kconfig will contain
that. But people can manually set the Kconfig item freely. Thanks for
pointing it out.

diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 5f220e903e5a..b63ad4698cf8 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -25,6 +25,7 @@ config SUPERH
        select GENERIC_SCHED_CLOCK
        select GENERIC_SMP_IDLE_THREAD
        select GUP_GET_PTE_LOW_HIGH if X2TLB
+       select GENERIC_IOREMAP if MMU

>
Baoquan He Sept. 1, 2022, 10:39 a.m. UTC | #4
Hi,

On 08/20/22 at 11:41am, kernel test robot wrote:
> Hi Baoquan,
> 
> I love your patch! Yet something to improve:
> 
> [auto build test ERROR on akpm-mm/mm-everything]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/mm-ioremap-Convert-architectures-to-take-GENERIC_IOREMAP-way/20220820-083435
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
> config: sh-allmodconfig
> compiler: sh4-linux-gcc (GCC) 12.1.0
> reproduce (this is a W=1 build):
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # https://github.com/intel-lab-lkp/linux/commit/503a31451202f89e58bc5f0a49261398fafbd90e
>         git remote add linux-review https://github.com/intel-lab-lkp/linux
>         git fetch --no-tags linux-review Baoquan-He/mm-ioremap-Convert-architectures-to-take-GENERIC_IOREMAP-way/20220820-083435
>         git checkout 503a31451202f89e58bc5f0a49261398fafbd90e
>         # save the config file
>         mkdir build_dir && cp config build_dir/.config
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sh prepare

I can only find binutils-sh-linux-gnu on fedora, but no gcc-sh-linux-gnu
for cross compiling superh kernel. So I tried above steps, but it failed
as below, any suggestion I can fix it to proceed for reproducing the
reporting issues? Thanks in advance.

[root@ampere-mtsnow-altra-09 ~]# ls
0day  anaconda-ks.cfg  bin  config  EFI_BOOT_ENTRY.TXT  linux  NETBOOT_METHOD.TXT  original-ks.cfg  RECIPE.TXT
[root@ampere-mtsnow-altra-09 ~]# ls 0day/gcc-12.1.0-nolibc/sh4-linux/bin/
sh4-linux-addr2line  sh4-linux-elfedit     sh4-linux-gcc-ranlib  sh4-linux-ld        sh4-linux-objdump  sh4-linux-strip
sh4-linux-ar         sh4-linux-gcc         sh4-linux-gcov        sh4-linux-ld.bfd    sh4-linux-ranlib
sh4-linux-as         sh4-linux-gcc-12.1.0  sh4-linux-gcov-dump   sh4-linux-lto-dump  sh4-linux-readelf
sh4-linux-c++filt    sh4-linux-gcc-ar      sh4-linux-gcov-tool   sh4-linux-nm        sh4-linux-size
sh4-linux-cpp        sh4-linux-gcc-nm      sh4-linux-gprof       sh4-linux-objcopy   sh4-linux-strings
[root@ampere-mtsnow-altra-09 ~]# ls bin
make.cross
[root@ampere-mtsnow-altra-09 ~]# cd linux/
[root@ampere-mtsnow-altra-09 linux]# ls
arch       certs    CREDITS        drivers  init      Kbuild   lib          Makefile  README   security  usr
block      config   crypto         fs       io_uring  Kconfig  LICENSES     mm        samples  sound     virt
build_dir  COPYING  Documentation  include  ipc       kernel   MAINTAINERS  net       scripts  tools
[root@ampere-mtsnow-altra-09 linux]# ls build_dir/  -a
.  ..  arch  .config  .gitignore  include  Makefile  scripts  source  usr

[root@ampere-mtsnow-altra-09 linux]# COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sh prepare
Compiler will be installed in /root/0day
	not a dynamic executable
make --keep-going CONFIG_OF_ALL_DTBS=y CONFIG_DTC=y CROSS_COMPILE=/root/0day/gcc-12.1.0-nolibc/sh4-linux/bin/sh4-linux- --jobs=160 W=1 O=build_dir ARCH=sh prepare
make[1]: Entering directory '/root/linux/build_dir'
/bin/sh: line 1: /root/0day/gcc-12.1.0-nolibc/sh4-linux/bin/sh4-linux-gcc: cannot execute binary file: Exec format error
/bin/sh: line 1: /root/0day/gcc-12.1.0-nolibc/sh4-linux/bin/sh4-linux-gcc: cannot execute binary file: Exec format error
/bin/sh: line 1: /root/0day/gcc-12.1.0-nolibc/sh4-linux/bin/sh4-linux-gcc: cannot execute binary file: Exec format error
  SYNC    include/config/auto.conf.cmd
/bin/sh: line 1: /root/0day/gcc-12.1.0-nolibc/sh4-linux/bin/sh4-linux-gcc: cannot execute binary file: Exec format error
/bin/sh: line 1: /root/0day/gcc-12.1.0-nolibc/sh4-linux/bin/sh4-linux-gcc: cannot execute binary file: Exec format error
/bin/sh: line 1: /root/0day/gcc-12.1.0-nolibc/sh4-linux/bin/sh4-linux-gcc: cannot execute binary file: Exec format error
  GEN     Makefile
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  HOSTCC  scripts/kconfig/confdata.o
  HOSTCC  scripts/kconfig/expr.o
  LEX     scripts/kconfig/lexer.lex.c
  YACC    scripts/kconfig/parser.tab.[ch]
  HOSTCC  scripts/kconfig/menu.o
  HOSTCC  scripts/kconfig/preprocess.o
  HOSTCC  scripts/kconfig/symbol.o
  HOSTCC  scripts/kconfig/util.o
  HOSTCC  scripts/kconfig/lexer.lex.o
  HOSTCC  scripts/kconfig/parser.tab.o
  HOSTLD  scripts/kconfig/conf
/root/0day/gcc-12.1.0-nolibc/sh4-linux/bin/sh4-linux-gcc: unknown compiler
scripts/Kconfig.include:44: Sorry, this compiler is not supported.
make[3]: *** [../scripts/kconfig/Makefile:77: syncconfig] Error 1
make[2]: *** [../Makefile:632: syncconfig] Error 2
make[1]: *** [/root/linux/Makefile:734: include/config/auto.conf.cmd] Error 2
make[1]: Failed to remake makefile 'include/config/auto.conf.cmd'.
make[1]: Failed to remake makefile 'include/config/auto.conf'.
  GEN     Makefile
  SYSHDR  arch/sh/include/generated/uapi/asm/unistd_32.h
  SYSTBL  arch/sh/include/generated/asm/syscall_table.h
Error: kernelrelease not valid - run 'make prepare' to update it
  HOSTCC  scripts/dtc/dtc.o
  HOSTCC  scripts/dtc/flattree.o
  HOSTCC  scripts/dtc/fstree.o
  HOSTCC  scripts/dtc/data.o
  HOSTCC  scripts/dtc/livetree.o
  HOSTCC  scripts/dtc/treesource.o
  HOSTCC  scripts/dtc/srcpos.o
  HOSTCC  scripts/dtc/checks.o
  HOSTCC  scripts/dtc/util.o
  LEX     scripts/dtc/dtc-lexer.lex.c
  YACC    scripts/dtc/dtc-parser.tab.[ch]
  HOSTCC  scripts/dtc/libfdt/fdt_ro.o
  HOSTCC  scripts/dtc/libfdt/fdt.o
  HOSTCC  scripts/dtc/libfdt/fdt_wip.o
  HOSTCC  scripts/dtc/libfdt/fdt_sw.o
  HOSTCC  scripts/dtc/libfdt/fdt_rw.o
  HOSTCC  scripts/dtc/libfdt/fdt_strerror.o
  HOSTCC  scripts/dtc/libfdt/fdt_empty_tree.o
  HOSTCC  scripts/dtc/libfdt/fdt_addresses.o
  HOSTCC  scripts/dtc/libfdt/fdt_overlay.o
  HOSTCC  scripts/dtc/fdtoverlay.o
  HOSTCC  scripts/dtc/dtc-lexer.lex.o
  HOSTCC  scripts/dtc/dtc-parser.tab.o
  HOSTLD  scripts/dtc/fdtoverlay
  HOSTLD  scripts/dtc/dtc
make[1]: Target 'prepare' not remade because of errors.
make[1]: Leaving directory '/root/linux/build_dir'
make: *** [Makefile:222: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.
Chen, Rong A Sept. 1, 2022, 12:11 p.m. UTC | #5
On 9/1/2022 6:39 PM, Baoquan He wrote:
> Hi,
> 
> On 08/20/22 at 11:41am, kernel test robot wrote:
>> Hi Baoquan,
>>
>> I love your patch! Yet something to improve:
>>
>> [auto build test ERROR on akpm-mm/mm-everything]
>>
>> url:    https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/mm-ioremap-Convert-architectures-to-take-GENERIC_IOREMAP-way/20220820-083435
>> base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
>> config: sh-allmodconfig
>> compiler: sh4-linux-gcc (GCC) 12.1.0
>> reproduce (this is a W=1 build):
>>          wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>>          chmod +x ~/bin/make.cross
>>          # https://github.com/intel-lab-lkp/linux/commit/503a31451202f89e58bc5f0a49261398fafbd90e
>>          git remote add linux-review https://github.com/intel-lab-lkp/linux
>>          git fetch --no-tags linux-review Baoquan-He/mm-ioremap-Convert-architectures-to-take-GENERIC_IOREMAP-way/20220820-083435
>>          git checkout 503a31451202f89e58bc5f0a49261398fafbd90e
>>          # save the config file
>>          mkdir build_dir && cp config build_dir/.config
>>          COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sh prepare
> 
> I can only find binutils-sh-linux-gnu on fedora, but no gcc-sh-linux-gnu
> for cross compiling superh kernel. So I tried above steps, but it failed
> as below, any suggestion I can fix it to proceed for reproducing the
> reporting issues? Thanks in advance.

Hi Baoquan,

Sorry for the inconvenience, /root/0day/gcc-12.1.0-nolibc/sh4-linux/bin
/sh4-linux-gcc is for x86_64 machine, as the name "ampere-mtsnow-altra",
is it a arm server?

the tool for arm64 can be downloaded from 
https://cdn.kernel.org/pub/tools/crosstool/files/bin/arm64/12.1.0/

Best Regards,
Rong Chen

> 
> [root@ampere-mtsnow-altra-09 ~]# ls
> 0day  anaconda-ks.cfg  bin  config  EFI_BOOT_ENTRY.TXT  linux  NETBOOT_METHOD.TXT  original-ks.cfg  RECIPE.TXT
> [root@ampere-mtsnow-altra-09 ~]# ls 0day/gcc-12.1.0-nolibc/sh4-linux/bin/
> sh4-linux-addr2line  sh4-linux-elfedit     sh4-linux-gcc-ranlib  sh4-linux-ld        sh4-linux-objdump  sh4-linux-strip
> sh4-linux-ar         sh4-linux-gcc         sh4-linux-gcov        sh4-linux-ld.bfd    sh4-linux-ranlib
> sh4-linux-as         sh4-linux-gcc-12.1.0  sh4-linux-gcov-dump   sh4-linux-lto-dump  sh4-linux-readelf
> sh4-linux-c++filt    sh4-linux-gcc-ar      sh4-linux-gcov-tool   sh4-linux-nm        sh4-linux-size
> sh4-linux-cpp        sh4-linux-gcc-nm      sh4-linux-gprof       sh4-linux-objcopy   sh4-linux-strings
> [root@ampere-mtsnow-altra-09 ~]# ls bin
> make.cross
> [root@ampere-mtsnow-altra-09 ~]# cd linux/
> [root@ampere-mtsnow-altra-09 linux]# ls
> arch       certs    CREDITS        drivers  init      Kbuild   lib          Makefile  README   security  usr
> block      config   crypto         fs       io_uring  Kconfig  LICENSES     mm        samples  sound     virt
> build_dir  COPYING  Documentation  include  ipc       kernel   MAINTAINERS  net       scripts  tools
> [root@ampere-mtsnow-altra-09 linux]# ls build_dir/  -a
> .  ..  arch  .config  .gitignore  include  Makefile  scripts  source  usr
> 
> [root@ampere-mtsnow-altra-09 linux]# COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sh prepare
> Compiler will be installed in /root/0day
> 	not a dynamic executable
> make --keep-going CONFIG_OF_ALL_DTBS=y CONFIG_DTC=y CROSS_COMPILE=/root/0day/gcc-12.1.0-nolibc/sh4-linux/bin/sh4-linux- --jobs=160 W=1 O=build_dir ARCH=sh prepare
> make[1]: Entering directory '/root/linux/build_dir'
> /bin/sh: line 1: /root/0day/gcc-12.1.0-nolibc/sh4-linux/bin/sh4-linux-gcc: cannot execute binary file: Exec format error
> /bin/sh: line 1: /root/0day/gcc-12.1.0-nolibc/sh4-linux/bin/sh4-linux-gcc: cannot execute binary file: Exec format error
> /bin/sh: line 1: /root/0day/gcc-12.1.0-nolibc/sh4-linux/bin/sh4-linux-gcc: cannot execute binary file: Exec format error
>    SYNC    include/config/auto.conf.cmd
> /bin/sh: line 1: /root/0day/gcc-12.1.0-nolibc/sh4-linux/bin/sh4-linux-gcc: cannot execute binary file: Exec format error
> /bin/sh: line 1: /root/0day/gcc-12.1.0-nolibc/sh4-linux/bin/sh4-linux-gcc: cannot execute binary file: Exec format error
> /bin/sh: line 1: /root/0day/gcc-12.1.0-nolibc/sh4-linux/bin/sh4-linux-gcc: cannot execute binary file: Exec format error
>    GEN     Makefile
>    HOSTCC  scripts/basic/fixdep
>    HOSTCC  scripts/kconfig/conf.o
>    HOSTCC  scripts/kconfig/confdata.o
>    HOSTCC  scripts/kconfig/expr.o
>    LEX     scripts/kconfig/lexer.lex.c
>    YACC    scripts/kconfig/parser.tab.[ch]
>    HOSTCC  scripts/kconfig/menu.o
>    HOSTCC  scripts/kconfig/preprocess.o
>    HOSTCC  scripts/kconfig/symbol.o
>    HOSTCC  scripts/kconfig/util.o
>    HOSTCC  scripts/kconfig/lexer.lex.o
>    HOSTCC  scripts/kconfig/parser.tab.o
>    HOSTLD  scripts/kconfig/conf
> /root/0day/gcc-12.1.0-nolibc/sh4-linux/bin/sh4-linux-gcc: unknown compiler
> scripts/Kconfig.include:44: Sorry, this compiler is not supported.
> make[3]: *** [../scripts/kconfig/Makefile:77: syncconfig] Error 1
> make[2]: *** [../Makefile:632: syncconfig] Error 2
> make[1]: *** [/root/linux/Makefile:734: include/config/auto.conf.cmd] Error 2
> make[1]: Failed to remake makefile 'include/config/auto.conf.cmd'.
> make[1]: Failed to remake makefile 'include/config/auto.conf'.
>    GEN     Makefile
>    SYSHDR  arch/sh/include/generated/uapi/asm/unistd_32.h
>    SYSTBL  arch/sh/include/generated/asm/syscall_table.h
> Error: kernelrelease not valid - run 'make prepare' to update it
>    HOSTCC  scripts/dtc/dtc.o
>    HOSTCC  scripts/dtc/flattree.o
>    HOSTCC  scripts/dtc/fstree.o
>    HOSTCC  scripts/dtc/data.o
>    HOSTCC  scripts/dtc/livetree.o
>    HOSTCC  scripts/dtc/treesource.o
>    HOSTCC  scripts/dtc/srcpos.o
>    HOSTCC  scripts/dtc/checks.o
>    HOSTCC  scripts/dtc/util.o
>    LEX     scripts/dtc/dtc-lexer.lex.c
>    YACC    scripts/dtc/dtc-parser.tab.[ch]
>    HOSTCC  scripts/dtc/libfdt/fdt_ro.o
>    HOSTCC  scripts/dtc/libfdt/fdt.o
>    HOSTCC  scripts/dtc/libfdt/fdt_wip.o
>    HOSTCC  scripts/dtc/libfdt/fdt_sw.o
>    HOSTCC  scripts/dtc/libfdt/fdt_rw.o
>    HOSTCC  scripts/dtc/libfdt/fdt_strerror.o
>    HOSTCC  scripts/dtc/libfdt/fdt_empty_tree.o
>    HOSTCC  scripts/dtc/libfdt/fdt_addresses.o
>    HOSTCC  scripts/dtc/libfdt/fdt_overlay.o
>    HOSTCC  scripts/dtc/fdtoverlay.o
>    HOSTCC  scripts/dtc/dtc-lexer.lex.o
>    HOSTCC  scripts/dtc/dtc-parser.tab.o
>    HOSTLD  scripts/dtc/fdtoverlay
>    HOSTLD  scripts/dtc/dtc
> make[1]: Target 'prepare' not remade because of errors.
> make[1]: Leaving directory '/root/linux/build_dir'
> make: *** [Makefile:222: __sub-make] Error 2
> make: Target 'prepare' not remade because of errors.
> _______________________________________________
> kbuild-all mailing list -- kbuild-all@lists.01.org
> To unsubscribe send an email to kbuild-all-leave@lists.01.org
>
Baoquan He Sept. 1, 2022, 12:31 p.m. UTC | #6
On 09/01/22 at 08:11pm, Chen, Rong A wrote:
> 
> 
> On 9/1/2022 6:39 PM, Baoquan He wrote:
> > Hi,
> > 
> > On 08/20/22 at 11:41am, kernel test robot wrote:
> > > Hi Baoquan,
> > > 
> > > I love your patch! Yet something to improve:
> > > 
> > > [auto build test ERROR on akpm-mm/mm-everything]
> > > 
> > > url:    https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/mm-ioremap-Convert-architectures-to-take-GENERIC_IOREMAP-way/20220820-083435
> > > base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
> > > config: sh-allmodconfig
> > > compiler: sh4-linux-gcc (GCC) 12.1.0
> > > reproduce (this is a W=1 build):
> > >          wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> > >          chmod +x ~/bin/make.cross
> > >          # https://github.com/intel-lab-lkp/linux/commit/503a31451202f89e58bc5f0a49261398fafbd90e
> > >          git remote add linux-review https://github.com/intel-lab-lkp/linux
> > >          git fetch --no-tags linux-review Baoquan-He/mm-ioremap-Convert-architectures-to-take-GENERIC_IOREMAP-way/20220820-083435
> > >          git checkout 503a31451202f89e58bc5f0a49261398fafbd90e
> > >          # save the config file
> > >          mkdir build_dir && cp config build_dir/.config
> > >          COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sh prepare
> > 
> > I can only find binutils-sh-linux-gnu on fedora, but no gcc-sh-linux-gnu
> > for cross compiling superh kernel. So I tried above steps, but it failed
> > as below, any suggestion I can fix it to proceed for reproducing the
> > reporting issues? Thanks in advance.
> 
> Hi Baoquan,
> 
> Sorry for the inconvenience, /root/0day/gcc-12.1.0-nolibc/sh4-linux/bin
> /sh4-linux-gcc is for x86_64 machine, as the name "ampere-mtsnow-altra",
> is it a arm server?

Oops, I thought the cross compilig can be done on any platform. Since
I need test arm64 patch in this patchset, so didn't get x86 system to
reproduce. Didn't realize lkp has an assumption. I will get a x86 system
to test this.

Thanks for your help!
> 
> the tool for arm64 can be downloaded from
> https://cdn.kernel.org/pub/tools/crosstool/files/bin/arm64/12.1.0/
> 
> Best Regards,
> Rong Chen
> 
> > 
> > [root@ampere-mtsnow-altra-09 ~]# ls
> > 0day  anaconda-ks.cfg  bin  config  EFI_BOOT_ENTRY.TXT  linux  NETBOOT_METHOD.TXT  original-ks.cfg  RECIPE.TXT
> > [root@ampere-mtsnow-altra-09 ~]# ls 0day/gcc-12.1.0-nolibc/sh4-linux/bin/
> > sh4-linux-addr2line  sh4-linux-elfedit     sh4-linux-gcc-ranlib  sh4-linux-ld        sh4-linux-objdump  sh4-linux-strip
> > sh4-linux-ar         sh4-linux-gcc         sh4-linux-gcov        sh4-linux-ld.bfd    sh4-linux-ranlib
> > sh4-linux-as         sh4-linux-gcc-12.1.0  sh4-linux-gcov-dump   sh4-linux-lto-dump  sh4-linux-readelf
> > sh4-linux-c++filt    sh4-linux-gcc-ar      sh4-linux-gcov-tool   sh4-linux-nm        sh4-linux-size
> > sh4-linux-cpp        sh4-linux-gcc-nm      sh4-linux-gprof       sh4-linux-objcopy   sh4-linux-strings
> > [root@ampere-mtsnow-altra-09 ~]# ls bin
> > make.cross
> > [root@ampere-mtsnow-altra-09 ~]# cd linux/
> > [root@ampere-mtsnow-altra-09 linux]# ls
> > arch       certs    CREDITS        drivers  init      Kbuild   lib          Makefile  README   security  usr
> > block      config   crypto         fs       io_uring  Kconfig  LICENSES     mm        samples  sound     virt
> > build_dir  COPYING  Documentation  include  ipc       kernel   MAINTAINERS  net       scripts  tools
> > [root@ampere-mtsnow-altra-09 linux]# ls build_dir/  -a
> > .  ..  arch  .config  .gitignore  include  Makefile  scripts  source  usr
> > 
> > [root@ampere-mtsnow-altra-09 linux]# COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sh prepare
> > Compiler will be installed in /root/0day
> > 	not a dynamic executable
> > make --keep-going CONFIG_OF_ALL_DTBS=y CONFIG_DTC=y CROSS_COMPILE=/root/0day/gcc-12.1.0-nolibc/sh4-linux/bin/sh4-linux- --jobs=160 W=1 O=build_dir ARCH=sh prepare
> > make[1]: Entering directory '/root/linux/build_dir'
> > /bin/sh: line 1: /root/0day/gcc-12.1.0-nolibc/sh4-linux/bin/sh4-linux-gcc: cannot execute binary file: Exec format error
> > /bin/sh: line 1: /root/0day/gcc-12.1.0-nolibc/sh4-linux/bin/sh4-linux-gcc: cannot execute binary file: Exec format error
> > /bin/sh: line 1: /root/0day/gcc-12.1.0-nolibc/sh4-linux/bin/sh4-linux-gcc: cannot execute binary file: Exec format error
> >    SYNC    include/config/auto.conf.cmd
> > /bin/sh: line 1: /root/0day/gcc-12.1.0-nolibc/sh4-linux/bin/sh4-linux-gcc: cannot execute binary file: Exec format error
> > /bin/sh: line 1: /root/0day/gcc-12.1.0-nolibc/sh4-linux/bin/sh4-linux-gcc: cannot execute binary file: Exec format error
> > /bin/sh: line 1: /root/0day/gcc-12.1.0-nolibc/sh4-linux/bin/sh4-linux-gcc: cannot execute binary file: Exec format error
> >    GEN     Makefile
> >    HOSTCC  scripts/basic/fixdep
> >    HOSTCC  scripts/kconfig/conf.o
> >    HOSTCC  scripts/kconfig/confdata.o
> >    HOSTCC  scripts/kconfig/expr.o
> >    LEX     scripts/kconfig/lexer.lex.c
> >    YACC    scripts/kconfig/parser.tab.[ch]
> >    HOSTCC  scripts/kconfig/menu.o
> >    HOSTCC  scripts/kconfig/preprocess.o
> >    HOSTCC  scripts/kconfig/symbol.o
> >    HOSTCC  scripts/kconfig/util.o
> >    HOSTCC  scripts/kconfig/lexer.lex.o
> >    HOSTCC  scripts/kconfig/parser.tab.o
> >    HOSTLD  scripts/kconfig/conf
> > /root/0day/gcc-12.1.0-nolibc/sh4-linux/bin/sh4-linux-gcc: unknown compiler
> > scripts/Kconfig.include:44: Sorry, this compiler is not supported.
> > make[3]: *** [../scripts/kconfig/Makefile:77: syncconfig] Error 1
> > make[2]: *** [../Makefile:632: syncconfig] Error 2
> > make[1]: *** [/root/linux/Makefile:734: include/config/auto.conf.cmd] Error 2
> > make[1]: Failed to remake makefile 'include/config/auto.conf.cmd'.
> > make[1]: Failed to remake makefile 'include/config/auto.conf'.
> >    GEN     Makefile
> >    SYSHDR  arch/sh/include/generated/uapi/asm/unistd_32.h
> >    SYSTBL  arch/sh/include/generated/asm/syscall_table.h
> > Error: kernelrelease not valid - run 'make prepare' to update it
> >    HOSTCC  scripts/dtc/dtc.o
> >    HOSTCC  scripts/dtc/flattree.o
> >    HOSTCC  scripts/dtc/fstree.o
> >    HOSTCC  scripts/dtc/data.o
> >    HOSTCC  scripts/dtc/livetree.o
> >    HOSTCC  scripts/dtc/treesource.o
> >    HOSTCC  scripts/dtc/srcpos.o
> >    HOSTCC  scripts/dtc/checks.o
> >    HOSTCC  scripts/dtc/util.o
> >    LEX     scripts/dtc/dtc-lexer.lex.c
> >    YACC    scripts/dtc/dtc-parser.tab.[ch]
> >    HOSTCC  scripts/dtc/libfdt/fdt_ro.o
> >    HOSTCC  scripts/dtc/libfdt/fdt.o
> >    HOSTCC  scripts/dtc/libfdt/fdt_wip.o
> >    HOSTCC  scripts/dtc/libfdt/fdt_sw.o
> >    HOSTCC  scripts/dtc/libfdt/fdt_rw.o
> >    HOSTCC  scripts/dtc/libfdt/fdt_strerror.o
> >    HOSTCC  scripts/dtc/libfdt/fdt_empty_tree.o
> >    HOSTCC  scripts/dtc/libfdt/fdt_addresses.o
> >    HOSTCC  scripts/dtc/libfdt/fdt_overlay.o
> >    HOSTCC  scripts/dtc/fdtoverlay.o
> >    HOSTCC  scripts/dtc/dtc-lexer.lex.o
> >    HOSTCC  scripts/dtc/dtc-parser.tab.o
> >    HOSTLD  scripts/dtc/fdtoverlay
> >    HOSTLD  scripts/dtc/dtc
> > make[1]: Target 'prepare' not remade because of errors.
> > make[1]: Leaving directory '/root/linux/build_dir'
> > make: *** [Makefile:222: __sub-make] Error 2
> > make: Target 'prepare' not remade because of errors.
> > _______________________________________________
> > kbuild-all mailing list -- kbuild-all@lists.01.org
> > To unsubscribe send an email to kbuild-all-leave@lists.01.org
> > 
>
Baoquan He Sept. 2, 2022, 9:48 a.m. UTC | #7
On 08/20/22 at 11:41am, kernel test robot wrote:
> Hi Baoquan,
> 
> I love your patch! Yet something to improve:
> 
> [auto build test ERROR on akpm-mm/mm-everything]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Baoquan-He/mm-ioremap-Convert-architectures-to-take-GENERIC_IOREMAP-way/20220820-083435
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
> config: sh-allmodconfig
> compiler: sh4-linux-gcc (GCC) 12.1.0
> reproduce (this is a W=1 build):
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # https://github.com/intel-lab-lkp/linux/commit/503a31451202f89e58bc5f0a49261398fafbd90e
>         git remote add linux-review https://github.com/intel-lab-lkp/linux
>         git fetch --no-tags linux-review Baoquan-He/mm-ioremap-Convert-architectures-to-take-GENERIC_IOREMAP-way/20220820-083435
>         git checkout 503a31451202f89e58bc5f0a49261398fafbd90e
>         # save the config file
>         mkdir build_dir && cp config build_dir/.config
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sh prepare

I finally find gcc-sh-linux-gnu and its dependency on rpmfind.net, and
succeeded to reproduce the building failure.
isl-0.16.1-13
cross-gcc-common
gcc-sh-linux-gnu

Based on previous fixing patch for parisc, below draft patch can fix all
reported building issues on sh.

diff --git a/arch/sh/include/asm/io.h b/arch/sh/include/asm/io.h
index 3c5ff82a511a..eb550c72922d 100644
--- a/arch/sh/include/asm/io.h
+++ b/arch/sh/include/asm/io.h
@@ -225,6 +225,9 @@ __BUILD_IOPORT_STRING(q, u64)
 #define IO_SPACE_LIMIT 0xffffffff
 
 /* We really want to try and get these to memcpy etc */
+#define memset_io memset_io
+#define memcpy_fromio memcpy_fromio
+#define memcpy_toio memcpy_toio
 void memcpy_fromio(void *, const volatile void __iomem *, unsigned long);
 void memcpy_toio(volatile void __iomem *, const void *, unsigned long);
 void memset_io(volatile void __iomem *, int, unsigned long);
@@ -256,18 +259,17 @@ int arch_iounmap(void __iomem *addr);
 
 #define ioremap_cache(addr, size)  \
 	ioremap_prot((addr), (size), pgprot_val(PAGE_KERNEL))
-#define ioremap_cache ioremap_cache
 
 #define ioremap_uc	ioremap
 
-#include <asm-generic/io.h>
-
 /*
  * Convert a physical pointer to a virtual kernel pointer for /dev/mem
  * access
  */
 #define xlate_dev_mem_ptr(p)	__va(p)
 
+#include <asm-generic/io.h>
+
 #define ARCH_HAS_VALID_PHYS_ADDR_RANGE
 int valid_phys_addr_range(phys_addr_t addr, size_t size);
 int valid_mmap_phys_addr_range(unsigned long pfn, size_t size);
diff --git a/arch/sh/include/asm/io_noioport.h b/arch/sh/include/asm/io_noioport.h
index f7938fe0f911..5ba4116b4265 100644
--- a/arch/sh/include/asm/io_noioport.h
+++ b/arch/sh/include/asm/io_noioport.h
@@ -53,6 +53,13 @@ static inline void ioport_unmap(void __iomem *addr)
 #define outw_p(x, addr)	outw((x), (addr))
 #define outl_p(x, addr)	outl((x), (addr))
 
+#define insb insb
+#define insw insw
+#define insl insl
+#define outsb outsb
+#define outsw outsw
+#define outsl outsl
+
 static inline void insb(unsigned long port, void *dst, unsigned long count)
 {
 	BUG();
diff --git a/arch/sh/mm/ioremap.c b/arch/sh/mm/ioremap.c
index 720a9186b06b..725a1623675a 100644
--- a/arch/sh/mm/ioremap.c
+++ b/arch/sh/mm/ioremap.c
@@ -72,7 +72,7 @@ __ioremap_29bit(phys_addr_t offset, unsigned long size, pgprot_t prot)
 #define __ioremap_29bit(offset, size, prot)		NULL
 #endif /* CONFIG_29BIT */
 
-void __iomem *
+void __iomem * __ref
 arch_ioremap(phys_addr_t *paddr, size_t size, unsigned long *prot_val)
 {
 	unsigned long last_addr, phys_addr = *paddr;
@@ -102,7 +102,8 @@ arch_ioremap(phys_addr_t *paddr, size_t size, unsigned long *prot_val)
 	 * First try to remap through the PMB.
 	 * PMB entries are all pre-faulted.
 	 */
-	mapped = pmb_remap_caller(phys_addr, size, pgprot, caller);
+	mapped = pmb_remap_caller(phys_addr, size, pgprot,
+			__builtin_return_address(0));
 	if (mapped && !IS_ERR(mapped))
 		return mapped;
 
@@ -129,7 +130,6 @@ static inline int iomapping_nontranslatable(unsigned long offset)
 int arch_iounmap(void __iomem *addr)
 {
 	unsigned long vaddr = (unsigned long __force)addr;
-	struct vm_struct *p;
 
 	/*
 	 * Nothing to do if there is no translatable mapping.
diff mbox series

Patch

diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 5f220e903e5a..b63ad4698cf8 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -25,6 +25,7 @@  config SUPERH
 	select GENERIC_SCHED_CLOCK
 	select GENERIC_SMP_IDLE_THREAD
 	select GUP_GET_PTE_LOW_HIGH if X2TLB
+	select GENERIC_IOREMAP if MMU
 	select HAVE_ARCH_AUDITSYSCALL
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_SECCOMP_FILTER
diff --git a/arch/sh/include/asm/io.h b/arch/sh/include/asm/io.h
index fba90e670ed4..3c5ff82a511a 100644
--- a/arch/sh/include/asm/io.h
+++ b/arch/sh/include/asm/io.h
@@ -242,45 +242,26 @@  unsigned long long poke_real_address_q(unsigned long long addr,
 #define phys_to_virt(address)	(__va(address))
 #endif
 
-#ifdef CONFIG_MMU
-void iounmap(void __iomem *addr);
-void __iomem *__ioremap_caller(phys_addr_t offset, unsigned long size,
-			       pgprot_t prot, void *caller);
-
-static inline void __iomem *ioremap(phys_addr_t offset, unsigned long size)
-{
-	return __ioremap_caller(offset, size, PAGE_KERNEL_NOCACHE,
-			__builtin_return_address(0));
-}
-
-static inline void __iomem *
-ioremap_cache(phys_addr_t offset, unsigned long size)
-{
-	return __ioremap_caller(offset, size, PAGE_KERNEL,
-			__builtin_return_address(0));
-}
-#define ioremap_cache ioremap_cache
+/*
+ * I/O memory mapping functions.
+ */
+void __iomem *
+arch_ioremap(phys_addr_t *paddr, size_t size, unsigned long *prot_val);
+#define arch_ioremap arch_ioremap
 
-#ifdef CONFIG_HAVE_IOREMAP_PROT
-static inline void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size,
-		unsigned long flags)
-{
-	return __ioremap_caller(offset, size, __pgprot(flags),
-			__builtin_return_address(0));
-}
-#endif /* CONFIG_HAVE_IOREMAP_PROT */
+int arch_iounmap(void __iomem *addr);
+#define arch_iounmap arch_iounmap
 
-#else /* CONFIG_MMU */
-static inline void __iomem *ioremap(phys_addr_t offset, size_t size)
-{
-	return (void __iomem *)(unsigned long)offset;
-}
+#define _PAGE_IOREMAP pgprot_val(PAGE_KERNEL_NOCACHE)
 
-static inline void iounmap(volatile void __iomem *addr) { }
-#endif /* CONFIG_MMU */
+#define ioremap_cache(addr, size)  \
+	ioremap_prot((addr), (size), pgprot_val(PAGE_KERNEL))
+#define ioremap_cache ioremap_cache
 
 #define ioremap_uc	ioremap
 
+#include <asm-generic/io.h>
+
 /*
  * Convert a physical pointer to a virtual kernel pointer for /dev/mem
  * access
diff --git a/arch/sh/mm/ioremap.c b/arch/sh/mm/ioremap.c
index 21342581144d..720a9186b06b 100644
--- a/arch/sh/mm/ioremap.c
+++ b/arch/sh/mm/ioremap.c
@@ -72,22 +72,12 @@  __ioremap_29bit(phys_addr_t offset, unsigned long size, pgprot_t prot)
 #define __ioremap_29bit(offset, size, prot)		NULL
 #endif /* CONFIG_29BIT */
 
-/*
- * Remap an arbitrary physical address space into the kernel virtual
- * address space. Needed when the kernel wants to access high addresses
- * directly.
- *
- * NOTE! We need to allow non-page-aligned mappings too: we will obviously
- * have to convert them into an offset in a page-aligned mapping, but the
- * caller shouldn't need to know that small detail.
- */
-void __iomem * __ref
-__ioremap_caller(phys_addr_t phys_addr, unsigned long size,
-		 pgprot_t pgprot, void *caller)
+void __iomem *
+arch_ioremap(phys_addr_t *paddr, size_t size, unsigned long *prot_val)
 {
-	struct vm_struct *area;
-	unsigned long offset, last_addr, addr, orig_addr;
+	unsigned long last_addr, phys_addr = *paddr;
 	void __iomem *mapped;
+	pgprot_t pgprot = __pgprot(*prot_val);
 
 	mapped = __ioremap_trapped(phys_addr, size);
 	if (mapped)
@@ -100,7 +90,7 @@  __ioremap_caller(phys_addr_t phys_addr, unsigned long size,
 	/* Don't allow wraparound or zero size */
 	last_addr = phys_addr + size - 1;
 	if (!size || last_addr < phys_addr)
-		return NULL;
+		return IOMEM_ERR_PTR(-EINVAL);
 
 	/*
 	 * If we can't yet use the regular approach, go the fixmap route.
@@ -116,30 +106,8 @@  __ioremap_caller(phys_addr_t phys_addr, unsigned long size,
 	if (mapped && !IS_ERR(mapped))
 		return mapped;
 
-	/*
-	 * Mappings have to be page-aligned
-	 */
-	offset = phys_addr & ~PAGE_MASK;
-	phys_addr &= PAGE_MASK;
-	size = PAGE_ALIGN(last_addr+1) - phys_addr;
-
-	/*
-	 * Ok, go for it..
-	 */
-	area = get_vm_area_caller(size, VM_IOREMAP, caller);
-	if (!area)
-		return NULL;
-	area->phys_addr = phys_addr;
-	orig_addr = addr = (unsigned long)area->addr;
-
-	if (ioremap_page_range(addr, addr + size, phys_addr, pgprot)) {
-		vunmap((void *)orig_addr);
-		return NULL;
-	}
-
-	return (void __iomem *)(offset + (char *)orig_addr);
+	return NULL;
 }
-EXPORT_SYMBOL(__ioremap_caller);
 
 /*
  * Simple checks for non-translatable mappings.
@@ -158,7 +126,7 @@  static inline int iomapping_nontranslatable(unsigned long offset)
 	return 0;
 }
 
-void iounmap(void __iomem *addr)
+int arch_iounmap(void __iomem *addr)
 {
 	unsigned long vaddr = (unsigned long __force)addr;
 	struct vm_struct *p;
@@ -167,26 +135,19 @@  void iounmap(void __iomem *addr)
 	 * Nothing to do if there is no translatable mapping.
 	 */
 	if (iomapping_nontranslatable(vaddr))
-		return;
+		return -EINVAL;
 
 	/*
 	 * There's no VMA if it's from an early fixed mapping.
 	 */
 	if (iounmap_fixed(addr) == 0)
-		return;
+		return -EINVAL;
 
 	/*
 	 * If the PMB handled it, there's nothing else to do.
 	 */
 	if (pmb_unmap(addr) == 0)
-		return;
+		return -EINVAL;
 
-	p = remove_vm_area((void *)(vaddr & PAGE_MASK));
-	if (!p) {
-		printk(KERN_ERR "%s: bad address %p\n", __func__, addr);
-		return;
-	}
-
-	kfree(p);
+	return 0;
 }
-EXPORT_SYMBOL(iounmap);