Skip to content
  1. Aug 19, 2023
    • Barry Song's avatar
      arm64: support batched/deferred tlb shootdown during page reclamation/migration · 43b3dfdd
      Barry Song authored
      On x86, batched and deferred tlb shootdown has lead to 90% performance
      increase on tlb shootdown.  on arm64, HW can do tlb shootdown without
      software IPI.  But sync tlbi is still quite expensive.
      
      Even running a simplest program which requires swapout can
      prove this is true,
       #include <sys/types.h>
       #include <unistd.h>
       #include <sys/mman.h>
       #include <string.h>
      
       int main()
       {
       #define SIZE (1 * 1024 * 1024)
               volatile unsigned char *p = mmap(NULL, SIZE, PROT_READ | PROT_WRITE,
                                                MAP_SHARED | MAP_ANONYMOUS, -1, 0);
      
               memset(p, 0x88, SIZE);
      
               for (int k = 0; k < 10000; k++) {
                       /* swap in */
                       for (int i = 0; i < SIZE; i += 4096) {
                               (void)p[i];
                       }
      
                       /* swap out */
                       madvise(p, SIZE, MADV_PAGEOUT);
               }
       }
      
      Perf result on snapdragon 888 with 8 cores by using zRAM
      as the swap block device.
      
       ~ # perf record taskset -c 4 ./a.out
       [ perf record: Woken up 10 times to write data ]
       [ perf record: Captured and wrote 2.297 MB perf.data (60084 samples) ]
       ~ # perf report
       # To display the perf.data header info, please use --header/--header-only options.
       # To display the perf.data header info, please use --header/--header-only options.
       #
       #
       # Total Lost Samples: 0
       #
       # Samples: 60K of event 'cycles'
       # Event count (approx.): 35706225414
       #
       # Overhead  Command  Shared Object      Symbol
       # ........  .......  .................  ......
       #
          21.07%  a.out    [kernel.kallsyms]  [k] _raw_spin_unlock_irq
           8.23%  a.out    [kernel.kallsyms]  [k] _raw_spin_unlock_irqrestore
           6.67%  a.out    [kernel.kallsyms]  [k] filemap_map_pages
           6.16%  a.out    [kernel.kallsyms]  [k] __zram_bvec_write
           5.36%  a.out    [kernel.kallsyms]  [k] ptep_clear_flush
           3.71%  a.out    [kernel.kallsyms]  [k] _raw_spin_lock
           3.49%  a.out    [kernel.kallsyms]  [k] memset64
           1.63%  a.out    [kernel.kallsyms]  [k] clear_page
           1.42%  a.out    [kernel.kallsyms]  [k] _raw_spin_unlock
           1.26%  a.out    [kernel.kallsyms]  [k] mod_zone_state.llvm.8525150236079521930
           1.23%  a.out    [kernel.kallsyms]  [k] xas_load
           1.15%  a.out    [kernel.kallsyms]  [k] zram_slot_lock
      
      ptep_clear_flush() takes 5.36% CPU in the micro-benchmark swapping in/out
      a page mapped by only one process.  If the page is mapped by multiple
      processes, typically, like more than 100 on a phone, the overhead would be
      much higher as we have to run tlb flush 100 times for one single page. 
      Plus, tlb flush overhead will increase with the number of CPU cores due to
      the bad scalability of tlb shootdown in HW, so those ARM64 servers should
      expect much higher overhead.
      
      Further perf annonate shows 95% cpu time of ptep_clear_flush is actually
      used by the final dsb() to wait for the completion of tlb flush.  This
      provides us a very good chance to leverage the existing batched tlb in
      kernel.  The minimum modification is that we only send async tlbi in the
      first stage and we send dsb while we have to sync in the second stage.
      
      With the above simplest micro benchmark, collapsed time to finish the
      program decreases around 5%.
      
      Typical collapsed time w/o patch:
       ~ # time taskset -c 4 ./a.out
       0.21user 14.34system 0:14.69elapsed
      w/ patch:
       ~ # time taskset -c 4 ./a.out
       0.22user 13.45system 0:13.80elapsed
      
      Also tested with benchmark in the commit on Kunpeng920 arm64 server
      and observed an improvement around 12.5% with command
      `time ./swap_bench`.
              w/o             w/
      real    0m13.460s       0m11.771s
      user    0m0.248s        0m0.279s
      sys     0m12.039s       0m11.458s
      
      Originally it's noticed a 16.99% overhead of ptep_clear_flush()
      which has been eliminated by this patch:
      
      [root@localhost yang]# perf record -- ./swap_bench && perf report
      [...]
      16.99%  swap_bench  [kernel.kallsyms]  [k] ptep_clear_flush
      
      It is tested on 4,8,128 CPU platforms and shows to be beneficial on
      large systems but may not have improvement on small systems like on
      a 4 CPU platform.
      
      Also this patch improve the performance of page migration. Using pmbench
      and tries to migrate the pages of pmbench between node 0 and node 1 for
      100 times for 1G memory, this patch decrease the time used around 20%
      (prev 18.338318910 sec after 13.981866350 sec) and saved the time used
      by ptep_clear_flush().
      
      Link: https://lkml.kernel.org/r/20230717131004.12662-5-yangyicong@huawei.com
      
      
      Tested-by: default avatarYicong Yang <yangyicong@hisilicon.com>
      Tested-by: default avatarXin Hao <xhao@linux.alibaba.com>
      Tested-by: default avatarPunit Agrawal <punit.agrawal@bytedance.com>
      Signed-off-by: default avatarBarry Song <v-songbaohua@oppo.com>
      Signed-off-by: default avatarYicong Yang <yangyicong@hisilicon.com>
      Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Reviewed-by: default avatarXin Hao <xhao@linux.alibaba.com>
      Reviewed-by: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
      Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Nadav Amit <namit@vmware.com>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Anshuman Khandual <khandual@linux.vnet.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Barry Song <baohua@kernel.org>
      Cc: Darren Hart <darren@os.amperecomputing.com>
      Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
      Cc: lipeifeng <lipeifeng@oppo.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ryan Roberts <ryan.roberts@arm.com>
      Cc: Steven Miao <realmz6@gmail.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Zeng Tao <prime.zeng@hisilicon.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      43b3dfdd
    • Yicong Yang's avatar
      mm/tlbbatch: introduce arch_flush_tlb_batched_pending() · db6c1f6f
      Yicong Yang authored
      Currently we'll flush the mm in flush_tlb_batched_pending() to avoid race
      between reclaim unmaps pages by batched TLB flush and mprotect/munmap/etc.
      Other architectures like arm64 may only need a synchronization
      barrier(dsb) here rather than a full mm flush.  So add
      arch_flush_tlb_batched_pending() to allow an arch-specific implementation
      here.  This intends no functional changes on x86 since still a full mm
      flush for x86.
      
      Link: https://lkml.kernel.org/r/20230717131004.12662-4-yangyicong@huawei.com
      
      
      Signed-off-by: default avatarYicong Yang <yangyicong@hisilicon.com>
      Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Cc: Anshuman Khandual <khandual@linux.vnet.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Barry Song <baohua@kernel.org>
      Cc: Barry Song <v-songbaohua@oppo.com>
      Cc: Darren Hart <darren@os.amperecomputing.com>
      Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Cc: lipeifeng <lipeifeng@oppo.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Nadav Amit <namit@vmware.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Punit Agrawal <punit.agrawal@bytedance.com>
      Cc: Ryan Roberts <ryan.roberts@arm.com>
      Cc: Steven Miao <realmz6@gmail.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Xin Hao <xhao@linux.alibaba.com>
      Cc: Zeng Tao <prime.zeng@hisilicon.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      db6c1f6f
    • Barry Song's avatar
      mm/tlbbatch: rename and extend some functions · f73419bb
      Barry Song authored
      This patch does some preparation works to extend batched TLB flush to
      arm64. Including:
      - Extend set_tlb_ubc_flush_pending() and arch_tlbbatch_add_mm()
        to accept an additional argument for address, architectures
        like arm64 may need this for tlbi.
      - Rename arch_tlbbatch_add_mm() to arch_tlbbatch_add_pending()
        to match its current function since we don't need to handle
        mm on architectures like arm64 and add_mm is not proper,
        add_pending will make sense to both as on x86 we're pending the
        TLB flush operations while on arm64 we're pending the synchronize
        operations.
      
      This intends no functional changes on x86.
      
      Link: https://lkml.kernel.org/r/20230717131004.12662-3-yangyicong@huawei.com
      
      
      Tested-by: default avatarYicong Yang <yangyicong@hisilicon.com>
      Tested-by: default avatarXin Hao <xhao@linux.alibaba.com>
      Tested-by: default avatarPunit Agrawal <punit.agrawal@bytedance.com>
      Signed-off-by: default avatarBarry Song <v-songbaohua@oppo.com>
      Signed-off-by: default avatarYicong Yang <yangyicong@hisilicon.com>
      Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Reviewed-by: default avatarXin Hao <xhao@linux.alibaba.com>
      Reviewed-by: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
      Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Nadav Amit <namit@vmware.com>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Anshuman Khandual <khandual@linux.vnet.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Barry Song <baohua@kernel.org>
      Cc: Darren Hart <darren@os.amperecomputing.com>
      Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
      Cc: lipeifeng <lipeifeng@oppo.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ryan Roberts <ryan.roberts@arm.com>
      Cc: Steven Miao <realmz6@gmail.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Zeng Tao <prime.zeng@hisilicon.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      f73419bb
    • Anshuman Khandual's avatar
      mm/tlbbatch: introduce arch_tlbbatch_should_defer() · 65c8d30e
      Anshuman Khandual authored
      Patch series "arm64: support batched/deferred tlb shootdown during page
      reclamation/migration", v11.
      
      Though ARM64 has the hardware to do tlb shootdown, the hardware
      broadcasting is not free.  A simplest micro benchmark shows even on
      snapdragon 888 with only 8 cores, the overhead for ptep_clear_flush is
      huge even for paging out one page mapped by only one process: 5.36% a.out
      [kernel.kallsyms] [k] ptep_clear_flush
      
      While pages are mapped by multiple processes or HW has more CPUs, the cost
      should become even higher due to the bad scalability of tlb shootdown. 
      The same benchmark can result in 16.99% CPU consumption on ARM64 server
      with around 100 cores according to the test on patch 4/4.
      
      This patchset leverages the existing BATCHED_UNMAP_TLB_FLUSH by
      1. only send tlbi instructions in the first stage -
      	arch_tlbbatch_add_mm()
      2. wait for the completion of tlbi by dsb while doing tlbbatch
      	sync in arch_tlbbatch_flush()
      
      Testing on snapdragon shows the overhead of ptep_clear_flush is removed by
      the patchset.  The micro benchmark becomes 5% faster even for one page
      mapped by single process on snapdragon 888.
      
      Since BATCHED_UNMAP_TLB_FLUSH is implemented only on x86, the patchset
      does some renaming/extension for the current implementation first (Patch
      1-3), then add the support on arm64 (Patch 4).
      		
      
      This patch (of 4):
      
      The entire scheme of deferred TLB flush in reclaim path rests on the fact
      that the cost to refill TLB entries is less than flushing out individual
      entries by sending IPI to remote CPUs.  But architecture can have
      different ways to evaluate that.  Hence apart from checking
      TTU_BATCH_FLUSH in the TTU flags, rest of the decision should be
      architecture specific.
      
      [yangyicong@hisilicon.com: rebase and fix incorrect return value type]
      Link: https://lkml.kernel.org/r/20230717131004.12662-1-yangyicong@huawei.com
      Link: https://lkml.kernel.org/r/20230717131004.12662-2-yangyicong@huawei.com
      
      
      Signed-off-by: default avatarAnshuman Khandual <khandual@linux.vnet.ibm.com>
      [https://lore.kernel.org/linuxppc-dev/20171101101735.2318-2-khandual@linux.vnet.ibm.com/
      
      ]
      Signed-off-by: default avatarYicong Yang <yangyicong@hisilicon.com>
      Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Reviewed-by: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
      Reviewed-by: default avatarBarry Song <baohua@kernel.org>
      Reviewed-by: default avatarXin Hao <xhao@linux.alibaba.com>
      Tested-by: default avatarPunit Agrawal <punit.agrawal@bytedance.com>
      Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Darren Hart <darren@os.amperecomputing.com>
      Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: lipeifeng <lipeifeng@oppo.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ryan Roberts <ryan.roberts@arm.com>
      Cc: Steven Miao <realmz6@gmail.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Zeng Tao <prime.zeng@hisilicon.com>
      Cc: Barry Song <v-songbaohua@oppo.com>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Nadav Amit <namit@vmware.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      65c8d30e
    • Baoquan He's avatar
      mm: ioremap: remove unneeded ioremap_allowed and iounmap_allowed · 95da27c4
      Baoquan He authored
      Now there are no users of ioremap_allowed and iounmap_allowed, clean
      them up.
      
      Link: https://lkml.kernel.org/r/20230706154520.11257-20-bhe@redhat.com
      
      
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Reviewed-by: default avatarMike Rapoport (IBM) <rppt@kernel.org>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      95da27c4
    • Baoquan He's avatar
      arm64 : mm: add wrapper function ioremap_prot() · 8f03d74f
      Baoquan He authored
      Since hook functions ioremap_allowed() and iounmap_allowed() will be
      obsoleted, add wrapper function ioremap_prot() to contain the the specific
      handling in addition to generic_ioremap_prot() invocation.
      
      Link: https://lkml.kernel.org/r/20230706154520.11257-19-bhe@redhat.com
      
      
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Reviewed-by: default avatarMike Rapoport (IBM) <rppt@kernel.org>
      Acked-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      8f03d74f
    • Christophe Leroy's avatar
      powerpc: mm: convert to GENERIC_IOREMAP · 8d05554d
      Christophe Leroy authored
      By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(),
      generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap()
      and iounmap() are all visible and available to arch. Arch needs to
      provide wrapper functions to override the generic versions if there's
      arch specific handling in its ioremap_prot(), ioremap() or iounmap().
      This change will simplify implementation by removing duplicated code
      with generic_ioremap_prot() and generic_iounmap(), and has the equivalent
      functioality as before.
      
      Here, add wrapper functions ioremap_prot() and iounmap() for powerpc's
      special operation when ioremap() and iounmap().
      
      Link: https://lkml.kernel.org/r/20230706154520.11257-18-bhe@redhat.com
      
      
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarMike Rapoport (IBM) <rppt@kernel.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      8d05554d
    • Baoquan He's avatar
      mm: move is_ioremap_addr() into new header file · 016fec91
      Baoquan He authored
      Now is_ioremap_addr() is only used in kernel/iomem.c and gonna be used in
      mm/ioremap.c.  Move it into its own new header file linux/ioremap.h.
      
      Link: https://lkml.kernel.org/r/20230706154520.11257-17-bhe@redhat.com
      
      
      Suggested-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Mike Rapoport (IBM) <rppt@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      016fec91
    • Christophe Leroy's avatar
      mm/ioremap: consider IOREMAP space in generic ioremap · ab1cd020
      Christophe Leroy authored
      Architectures like powerpc have a dedicated space for IOREMAP mappings.
      
      If so, use it in generic_ioremap_prot().
      
      Link: https://lkml.kernel.org/r/20230706154520.11257-16-bhe@redhat.com
      
      
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Mike Rapoport (IBM) <rppt@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      ab1cd020
    • Baoquan He's avatar
      parisc: mm: convert to GENERIC_IOREMAP · 426b313f
      Baoquan He authored
      By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(),
      generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and
      iounmap() are all visible and available to arch.  Arch needs to provide
      wrapper functions to override the generic versions if there's arch
      specific handling in its ioremap_prot(), ioremap() or iounmap().  This
      change will simplify implementation by removing duplicated code with
      generic_ioremap_prot() and generic_iounmap(), and has the equivalent
      functioality as before.
      
      Here, add wrapper function ioremap_prot() for parisc's special operation
      when iounmap().
      
      Link: https://lkml.kernel.org/r/20230706154520.11257-15-bhe@redhat.com
      
      
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarMike Rapoport (IBM) <rppt@kernel.org>
      Acked-by: default avatarHelge Deller <deller@gmx.de>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      426b313f
    • Baoquan He's avatar
      xtensa: mm: convert to GENERIC_IOREMAP · ca6c1af3
      Baoquan He authored
      By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(),
      generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and
      iounmap() are all visible and available to arch.  Arch needs to provide
      wrapper functions to override the generic versions if there's arch
      specific handling in its ioremap_prot(), ioremap() or iounmap().  This
      change will simplify implementation by removing duplicated code with
      generic_ioremap_prot() and generic_iounmap(), and has the equivalent
      functioality as before.
      
      Here, add wrapper functions ioremap_prot(), ioremap() and iounmap() for
      xtensa's special operation when ioremap() and iounmap().
      
      Link: https://lkml.kernel.org/r/20230706154520.11257-14-bhe@redhat.com
      
      
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarMike Rapoport (IBM) <rppt@kernel.org>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      ca6c1af3
    • Baoquan He's avatar
      sh: mm: convert to GENERIC_IOREMAP · 0453c9a7
      Baoquan He authored
      By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(),
      generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and
      iounmap() are all visible and available to arch.  Arch needs to provide
      wrapper functions to override the generic versions if there's arch
      specific handling in its ioremap_prot(), ioremap() or iounmap().  This
      change will simplify implementation by removing duplicated code with
      generic_ioremap_prot() and generic_iounmap(), and has the equivalent
      functioality as before.
      
      Here, add wrapper functions ioremap_prot() and iounmap() for SuperH's
      special operation when ioremap() and iounmap().
      
      Link: https://lkml.kernel.org/r/20230706154520.11257-13-bhe@redhat.com
      
      
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Mike Rapoport (IBM) <rppt@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      0453c9a7
    • Baoquan He's avatar
      sh: add <asm-generic/io.h> including · b94692e8
      Baoquan He authored
      In <asm-generic/io.h>, it provides a generic implementation of all
      I/O accessors.
      
      For some port|mm io functions, SuperH has its own implementation in
      arch/sh/kernel/iomap.c and arch/sh/include/asm/io_noioport.h.  These will
      conflict with those in <asm-generic/io.h> and cause compiling error. 
      Hence add macro definitions to ensure that the SuperH version of them will
      override the generic version.
      
      [arnd@arndb.de: fix asm-generic/io.h inclusion]
        Link: https://lkml.kernel.org/r/20230802141658.2064864-1-arnd@kernel.org
      Link: https://lkml.kernel.org/r/20230706154520.11257-12-bhe@redhat.com
      
      
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Mike Rapoport (IBM) <rppt@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      b94692e8
    • Baoquan He's avatar
      s390: mm: convert to GENERIC_IOREMAP · b43b3fff
      Baoquan He authored
      By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(),
      generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and
      iounmap() are all visible and available to arch.  Arch needs to provide
      wrapper functions to override the generic versions if there's arch
      specific handling in its ioremap_prot(), ioremap() or iounmap().  This
      change will simplify implementation by removing duplicated code with
      generic_ioremap_prot() and generic_iounmap(), and has the equivalent
      functioality as before.
      
      Here, add wrapper functions ioremap_prot() and iounmap() for s390's
      special operation when ioremap() and iounmap().
      
      And also replace including <asm-generic/io.h> with <asm/io.h> in
      arch/s390/kernel/perf_cpum_sf.c, otherwise building error will be seen
      because macro defined in <asm/io.h> can't be seen in perf_cpum_sf.c.
      
      Link: https://lkml.kernel.org/r/20230706154520.11257-11-bhe@redhat.com
      
      
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Reviewed-by: default avatarNiklas Schnelle <schnelle@linux.ibm.com>
      Tested-by: default avatarNiklas Schnelle <schnelle@linux.ibm.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarMike Rapoport (IBM) <rppt@kernel.org>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Helge Deller <deller@gmx.de>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      b43b3fff
    • Baoquan He's avatar
      openrisc: mm: convert to GENERIC_IOREMAP · 9b994429
      Baoquan He authored
      By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(),
      generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and
      iounmap() are all visible and available to arch.  Arch needs to provide
      wrapper functions to override the generic versions if there's arch
      specific handling in its ioremap_prot(), ioremap() or iounmap().  This
      change will simplify implementation by removing duplicated code with
      generic_ioremap_prot() and generic_iounmap(), and has the equivalent
      functioality as before.
      
      For openrisc, the current ioremap() and iounmap() are the same as generic
      version.  After taking GENERIC_IOREMAP way, the old ioremap() and
      iounmap() can be completely removed.
      
      Link: https://lkml.kernel.org/r/20230706154520.11257-10-bhe@redhat.com
      
      
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarMike Rapoport (IBM) <rppt@kernel.org>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      9b994429
    • Baoquan He's avatar
      ia64: mm: convert to GENERIC_IOREMAP · 38d110ab
      Baoquan He authored
      By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(),
      generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and
      iounmap() are all visible and available to arch.  Arch needs to provide
      wrapper functions to override the generic versions if there's arch
      specific handling in its ioremap_prot(), ioremap() or iounmap().  This
      change will simplify implementation by removing duplicated code with
      generic_ioremap_prot() and generic_iounmap(), and has the equivalent
      functioality as before.
      
      Here, add wrapper functions ioremap_prot() and iounmap() for ia64's
      special operation when ioremap() and iounmap().
      
      Link: https://lkml.kernel.org/r/20230706154520.11257-9-bhe@redhat.com
      
      
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarMike Rapoport (IBM) <rppt@kernel.org>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      38d110ab
    • Baoquan He's avatar
      arc: mm: convert to GENERIC_IOREMAP · 06dfae39
      Baoquan He authored
      By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(),
      generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and
      iounmap() are all visible and available to arch.  Arch needs to provide
      wrapper functions to override the generic versions if there's arch
      specific handling in its ioremap_prot(), ioremap() or iounmap().  This
      change will simplify implementation by removing duplicated code with
      generic_ioremap_prot() and generic_iounmap(), and has the equivalent
      functioality as before.
      
      Here, add wrapper functions ioremap_prot() and iounmap() for arc's special
      operation when ioremap_prot() and iounmap().
      
      Link: https://lkml.kernel.org/r/20230706154520.11257-8-bhe@redhat.com
      
      
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarMike Rapoport (IBM) <rppt@kernel.org>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      06dfae39
    • Baoquan He's avatar
      mm/ioremap: add slab availability checking in ioremap_prot · a5f61648
      Baoquan He authored
      Several architectures has done checking if slab if available in
      ioremap_prot().  In fact it should be done in generic ioremap_prot() since
      on any architecutre, slab allocator must be available before
      get_vm_area_caller() and vunmap() are used.
      
      Add the checking into generic_ioremap_prot().
      
      Link: https://lkml.kernel.org/r/20230706154520.11257-7-bhe@redhat.com
      
      
      Suggested-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Reviewed-by: default avatarMike Rapoport (IBM) <rppt@kernel.org>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      a5f61648
    • Baoquan He's avatar
      mm: ioremap: allow ARCH to have its own ioremap method definition · dfdc6ba9
      Baoquan He authored
      Architectures can be converted to GENERIC_IOREMAP, to take standard
      ioremap_xxx() and iounmap() way.  But some ARCH-es could have specific
      handling for ioremap_prot(), ioremap() and iounmap(), than standard
      methods.
      
      In oder to convert these ARCH-es to take GENERIC_IOREMAP method, allow
      these architecutres to have their own ioremap_prot(), ioremap() and
      iounmap() definitions.
      
      Link: https://lkml.kernel.org/r/20230706154520.11257-6-bhe@redhat.com
      
      
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Reviewed-by: default avatarMike Rapoport (IBM) <rppt@kernel.org>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      dfdc6ba9
    • Christophe Leroy's avatar
      mm/ioremap: define generic_ioremap_prot() and generic_iounmap() · 7613366a
      Christophe Leroy authored
      Define a generic version of ioremap_prot() and iounmap() that
      architectures can call after they have performed the necessary alteration
      to parameters and/or necessary verifications.
      
      Link: https://lkml.kernel.org/r/20230706154520.11257-5-bhe@redhat.com
      
      
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Reviewed-by: default avatarMike Rapoport (IBM) <rppt@kernel.org>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      7613366a
    • Baoquan He's avatar
      openrisc: mm: remove unneeded early ioremap code · 53c98e35
      Baoquan He authored
      Under arch/openrisc, there isn't any place where ioremap() is called.  It
      means that there isn't early ioremap handling needed in openrisc, So the
      early ioremap handling code in ioremap() of arch/openrisc/mm/ioremap.c is
      unnecessary and can be removed.
      
      And also remove the special handling in iounmap() since no page is got
      from fixmap pool along with early ioremap code removing in ioremap().
      
      Link: https://lore.kernel.org/linux-mm/YwxfxKrTUtAuejKQ@oscomms1/
      Link: https://lkml.kernel.org/r/20230706154520.11257-4-bhe@redhat.com
      
      
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Acked-by: default avatarStafford Horne <shorne@gmail.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarMike Rapoport (IBM) <rppt@kernel.org>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      53c98e35
    • Baoquan He's avatar
      hexagon: mm: convert to GENERIC_IOREMAP · 5bd2cc56
      Baoquan He authored
      By taking GENERIC_IOREMAP method, the generic ioremap_prot() and iounmap()
      are visible and available to arch.  This change will simplify
      implementation by removing duplicated code with generic ioremap_prot() and
      iounmap(), and has the equivalent functioality.
      
      For hexagon, the current ioremap() and iounmap() are the same as generic
      version.  After taking GENERIC_IOREMAP way, the old ioremap() and
      iounmap() can be completely removed.
      
      Link: https://lkml.kernel.org/r/20230706154520.11257-3-bhe@redhat.com
      
      
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Mike Rapoport (IBM) <rppt@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      5bd2cc56
    • Baoquan He's avatar
      asm-generic/iomap.h: remove ARCH_HAS_IOREMAP_xx macros · 0b1f77e7
      Baoquan He authored
      Patch series "mm: ioremap: Convert architectures to take GENERIC_IOREMAP
      way", v8.
      
      Motivation and implementation:
      ==============================
      Currently, many architecutres have't taken the standard GENERIC_IOREMAP
      way to implement ioremap_prot(), iounmap(), and ioremap_xx(), but make
      these functions specifically under each arch's folder.  Those cause many
      duplicated code of ioremap() and iounmap().
      
      In this patchset, firstly introduce generic_ioremap_prot() and
      generic_iounmap() to extract the generic code for GENERIC_IOREMAP.  By
      taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(),
      generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and
      iounmap() are all visible and available to arch.  Arch needs to provide
      wrapper functions to override the generic version if there's arch specific
      handling in its corresponding ioremap_prot(), ioremap() or iounmap(). 
      With these changes, duplicated ioremap/iounmap() code uder ARCH-es are
      removed, and the equivalent functioality is kept as before.
      
      Background info:
      ================
      
      1) The converting more architectures to take GENERIC_IOREMAP way is
         suggested by Christoph in below discussion:
         https://lore.kernel.org/all/Yp7h0Jv6vpgt6xdZ@infradead.org/T/#u
      
      2) In the previous v1 to v3, it's basically further action after arm64
         has converted to GENERIC_IOREMAP way in below patchset.  It's done by
         adding hook ioremap_allowed() and iounmap_allowed() in ARCH to add ARCH
         specific handling the middle of ioremap_prot() and iounmap().
      
      [PATCH v5 0/6] arm64: Cleanup ioremap() and support ioremap_prot()
      https://lore.kernel.org/all/20220607125027.44946-1-wangkefeng.wang@huawei.com/T/#u
      
      Later, during v3 reviewing, Christophe Leroy suggested to introduce
      generic_ioremap_prot() and generic_iounmap() to generic codes, and ARCH
      can provide wrapper function ioremap_prot(), ioremap() or iounmap() if
      needed.  Christophe made a RFC patchset as below to specially demonstrate
      his idea.  This is what v4 and now v5 is doing.
      
      [RFC PATCH 0/8] mm: ioremap: Convert architectures to take GENERIC_IOREMAP way
      https://lore.kernel.org/all/cover.1665568707.git.christophe.leroy@csgroup.eu/T/#u
      
      Testing:
      ========
      In v8, I only applied this patchset onto the latest linus's tree to build
      and run on arm64 and s390.
      
      
      This patch (of 19):
      
      Let's use '#define ioremap_xx' and "#ifdef ioremap_xx" instead.
      
      To remove defined ARCH_HAS_IOREMAP_xx macros in <asm/io.h> of each ARCH,
      the ARCH's own ioremap_wc|wt|np definition need be above "#include
      <asm-generic/iomap.h>.  Otherwise the redefinition error would be seen
      during compiling.  So the relevant adjustments are made to avoid compiling
      error:
      
        loongarch:
        - doesn't include <asm-generic/iomap.h>, defining ARCH_HAS_IOREMAP_WC
          is redundant, so simply remove it.
      
        m68k:
        - selected GENERIC_IOMAP, <asm-generic/iomap.h> has been added in
          <asm-generic/io.h>, and <asm/kmap.h> is included above
          <asm-generic/iomap.h>, so simply remove ARCH_HAS_IOREMAP_WT defining.
      
        mips:
        - move "#include <asm-generic/iomap.h>" below ioremap_wc definition
          in <asm/io.h>
      
        powerpc:
        - remove "#include <asm-generic/iomap.h>" in <asm/io.h> because it's
          duplicated with the one in <asm-generic/io.h>, let's rely on the
          latter.
      
        x86:
        - selected GENERIC_IOMAP, remove #include <asm-generic/iomap.h> in
          the middle of <asm/io.h>. Let's rely on <asm-generic/io.h>.
      
      Link: https://lkml.kernel.org/r/20230706154520.11257-2-bhe@redhat.com
      
      
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Acked-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
      Reviewed-by: default avatarMike Rapoport (IBM) <rppt@kernel.org>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Helge Deller <deller@gmx.de>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      0b1f77e7
    • Andrew Donnellan's avatar
      lib/test_meminit: allocate pages up to order MAX_ORDER · efb78fa8
      Andrew Donnellan authored
      test_pages() tests the page allocator by calling alloc_pages() with
      different orders up to order 10.
      
      However, different architectures and platforms support different maximum
      contiguous allocation sizes.  The default maximum allocation order
      (MAX_ORDER) is 10, but architectures can use CONFIG_ARCH_FORCE_MAX_ORDER
      to override this.  On platforms where this is less than 10, test_meminit()
      will blow up with a WARN().  This is expected, so let's not do that.
      
      Replace the hardcoded "10" with the MAX_ORDER macro so that we test
      allocations up to the expected platform limit.
      
      Link: https://lkml.kernel.org/r/20230714015238.47931-1-ajd@linux.ibm.com
      Fixes: 5015a300
      
       ("lib: introduce test_meminit module")
      Signed-off-by: default avatarAndrew Donnellan <ajd@linux.ibm.com>
      Reviewed-by: default avatarAlexander Potapenko <glider@google.com>
      Cc: Xiaoke Wang <xkernel.wang@foxmail.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      efb78fa8
    • Kemeng Shi's avatar
      mm/page_ext: move functions around for minor cleanups to page_ext · eb0da7f6
      Kemeng Shi authored
      1. move page_ext_get and page_ext_put down to remove forward
         declaration of lookup_page_ext.
      
      2. move page_ext_init_flatmem_late down to existing non SPARS block to
         remove a new non SPARS block and to keep code for non SPARS tight.
      
      Link: https://lkml.kernel.org/r/20230714114749.1743032-4-shikemeng@huaweicloud.com
      
      
      Signed-off-by: default avatarKemeng Shi <shikemeng@huaweicloud.com>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      eb0da7f6
    • Kemeng Shi's avatar
      mm/page_ext: remove rollback for untouched mem_section in online_page_ext · 3c09be5a
      Kemeng Shi authored
      If init_section_page_ext failed, we only need rollback for mem_section
      before failed mem_section.  Make rollback end point to failed mem_section
      to remove unnecessary rollback.
      
      As pfn += PAGES_PER_SECTION will be executed even if init_section_page_ext
      failed.  So pfn points to mem_section after failed mem_section.  Subtract
      one mem_section from pfn to get failed mem_section.
      
      Link: https://lkml.kernel.org/r/20230714114749.1743032-3-shikemeng@huaweicloud.com
      
      
      Signed-off-by: default avatarKemeng Shi <shikemeng@huaweicloud.com>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      3c09be5a
    • Kemeng Shi's avatar
      mm/page_ext: remove unused return value of offline_page_ext · 063ff7cd
      Kemeng Shi authored
      Patch series "minor cleanups for page_ext".
      
      This series contains some random minor cleanups for page_ext.  More
      details can be found in respective patches.  
      
      
      This patch (of 3):
      
      offline_page_ext always returns 0 and no caller checks the return value. 
      Just remove unused return value of offline_page_ext.
      
      Link: https://lkml.kernel.org/r/20230714114749.1743032-1-shikemeng@huaweicloud.com
      Link: https://lkml.kernel.org/r/20230714114749.1743032-2-shikemeng@huaweicloud.com
      
      
      Signed-off-by: default avatarKemeng Shi <shikemeng@huaweicloud.com>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      063ff7cd
    • Matthew Wilcox (Oracle)'s avatar
      buffer: remove set_bh_page() · 5f6d2862
      Matthew Wilcox (Oracle) authored
      With all users converted to folio_set_bh(), remove this function.
      
      Link: https://lkml.kernel.org/r/20230713035512.4139457-8-willy@infradead.org
      
      
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: David Sterba <dsterba@suse.com>
      Cc: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Pankaj Raghav <p.raghav@samsung.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Cc: Tom Rix <trix@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      5f6d2862
    • Matthew Wilcox (Oracle)'s avatar
      jbd2: use a folio in jbd2_journal_write_metadata_buffer() · 8147c4c4
      Matthew Wilcox (Oracle) authored
      The primary goal here is removing the use of set_bh_page().  Take the
      opportunity to switch from kmap_atomic() to kmap_local().  This simplifies
      the function as the offset is already added to the pointer.
      
      Link: https://lkml.kernel.org/r/20230713035512.4139457-7-willy@infradead.org
      
      
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: David Sterba <dsterba@suse.com>
      Cc: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Pankaj Raghav <p.raghav@samsung.com>
      Cc: Tom Rix <trix@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      8147c4c4
    • Matthew Wilcox (Oracle)'s avatar
      ntfs3: convert ntfs_get_block_vbo() to use a folio · 07811230
      Matthew Wilcox (Oracle) authored
      Remove a user of set_bh_page().
      
      Link: https://lkml.kernel.org/r/20230713035512.4139457-6-willy@infradead.org
      
      
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Cc: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: David Sterba <dsterba@suse.com>
      Cc: Jan Kara <jack@suse.com>
      Cc: Pankaj Raghav <p.raghav@samsung.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      07811230
    • Matthew Wilcox (Oracle)'s avatar
      migrate: use folio_set_bh() instead of set_bh_page() · d5db4f9d
      Matthew Wilcox (Oracle) authored
      This function was converted before folio_set_bh() existed.  Catch up to
      the new API.
      
      Link: https://lkml.kernel.org/r/20230713035512.4139457-5-willy@infradead.org
      
      
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: David Sterba <dsterba@suse.com>
      Cc: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Pankaj Raghav <p.raghav@samsung.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Cc: Tom Rix <trix@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      d5db4f9d
    • Matthew Wilcox (Oracle)'s avatar
      affs: convert data read and write to use folios · 34113026
      Matthew Wilcox (Oracle) authored
      We still need to convert to/from folios in write_begin & write_end to fit
      the API, but this removes a lot of calls to old page-based functions,
      removing many hidden calls to compound_head().
      
      Link: https://lkml.kernel.org/r/20230713035512.4139457-4-willy@infradead.org
      
      
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Reviewed-by: default avatarPankaj Raghav <p.raghav@samsung.com>
      Acked-by: default avatarDavid Sterba <dsterba@suse.com>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: Jan Kara <jack@suse.com>
      Cc: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Cc: Tom Rix <trix@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      34113026
    • Matthew Wilcox (Oracle)'s avatar
      affs: convert affs_symlink_read_folio() to use the folio · 41a638a1
      Matthew Wilcox (Oracle) authored
      Remove use of the old page APIs.  That includes use of setting PageError
      on error; simply not setting the uptodate flag is sufficient.
      
      Link: https://lkml.kernel.org/r/20230713035512.4139457-3-willy@infradead.org
      
      
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Acked-by: default avatarDavid Sterba <dsterba@suse.com>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: Jan Kara <jack@suse.com>
      Cc: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Pankaj Raghav <p.raghav@samsung.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Cc: Tom Rix <trix@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      41a638a1
    • Matthew Wilcox (Oracle)'s avatar
      highmem: add memcpy_to_folio() and memcpy_from_folio() · b23d03ef
      Matthew Wilcox (Oracle) authored
      Patch series "More filesystem folio conversions for 6.6".
      
      Remove the only spots in affs which actually use a struct page; there
      are a few places where one is mentioned, but it's part of the interface.
      
      The rest of this is removing the remaining calls to set_bh_page(),
      and then removing the function before any new users show up.
      
      
      This patch (of 7):
      
      These are the folio equivalent of memcpy_to_page() and memcpy_from_page().
      
      [agruenba@redhat.com: use correct chunk size in memcpy()]
        Link: https://lkml.kernel.org/r/20230802144354.1023099-1-agruenba@redhat.com
      Link: https://lkml.kernel.org/r/20230713035512.4139457-1-willy@infradead.org
      Link: https://lkml.kernel.org/r/20230713035512.4139457-2-willy@infradead.org
      
      
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Cc: David Sterba <dsterba@suse.com>
      Cc: Jan Kara <jack@suse.com>
      Cc: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
      Cc: Pankaj Raghav <p.raghav@samsung.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Andreas Gruenbacher <agruenba@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      b23d03ef
    • Kemeng Shi's avatar
      mm/page_table_check: remove unused parameter in [__]page_table_check_pud_set · 6d144436
      Kemeng Shi authored
      Remove unused addr in __page_table_check_pud_set and
      page_table_check_pud_set.
      
      Link: https://lkml.kernel.org/r/20230713172636.1705415-9-shikemeng@huaweicloud.com
      
      
      Signed-off-by: default avatarKemeng Shi <shikemeng@huaweicloud.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      6d144436
    • Kemeng Shi's avatar
      mm/page_table_check: remove unused parameter in [__]page_table_check_pmd_set · a3b83713
      Kemeng Shi authored
      Remove unused addr in __page_table_check_pmd_set and
      page_table_check_pmd_set.
      
      Link: https://lkml.kernel.org/r/20230713172636.1705415-8-shikemeng@huaweicloud.com
      
      
      Signed-off-by: default avatarKemeng Shi <shikemeng@huaweicloud.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      a3b83713
    • Kemeng Shi's avatar
      mm/page_table_check: remove unused parameter in [__]page_table_check_pte_set · 1066293d
      Kemeng Shi authored
      Remove unused addr in __page_table_check_pte_set and
      page_table_check_pte_set.
      
      Link: https://lkml.kernel.org/r/20230713172636.1705415-7-shikemeng@huaweicloud.com
      
      
      Signed-off-by: default avatarKemeng Shi <shikemeng@huaweicloud.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      1066293d
    • Kemeng Shi's avatar
      mm/page_table_check: remove unused parameter in [__]page_table_check_pud_clear · 931c38e1
      Kemeng Shi authored
      Remove unused addr in __page_table_check_pud_clear and
      page_table_check_pud_clear.
      
      Link: https://lkml.kernel.org/r/20230713172636.1705415-6-shikemeng@huaweicloud.com
      
      
      Signed-off-by: default avatarKemeng Shi <shikemeng@huaweicloud.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      931c38e1
    • Kemeng Shi's avatar
      mm/page_table_check: remove unused parameter in [__]page_table_check_pmd_clear · 1831414c
      Kemeng Shi authored
      Remove unused addr in page_table_check_pmd_clear and
      __page_table_check_pmd_clear.
      
      Link: https://lkml.kernel.org/r/20230713172636.1705415-5-shikemeng@huaweicloud.com
      
      
      Signed-off-by: default avatarKemeng Shi <shikemeng@huaweicloud.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      1831414c
    • Kemeng Shi's avatar
      mm/page_table_check: remove unused parameter in [__]page_table_check_pte_clear · aa232204
      Kemeng Shi authored
      Remove unused addr in page_table_check_pte_clear and
      __page_table_check_pte_clear.
      
      Link: https://lkml.kernel.org/r/20230713172636.1705415-4-shikemeng@huaweicloud.com
      
      
      Signed-off-by: default avatarKemeng Shi <shikemeng@huaweicloud.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      aa232204