974b9b2c68
mm: consolidate pte_index() and pte_offset_*() definitions
...
All architectures define pte_index() as
(address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)
and all architectures define pte_offset_kernel() as an entry in the array
of PTEs indexed by the pte_index().
For the most architectures the pte_offset_kernel() implementation relies
on the availability of pmd_page_vaddr() that converts a PMD entry value to
the virtual address of the page containing PTEs array.
Let's move x86 definitions of the PTE accessors to the generic place in
<linux/pgtable.h> and then simply drop the respective definitions from the
other architectures.
The architectures that didn't provide pmd_page_vaddr() are updated to have
that defined.
The generic implementation of pte_offset_kernel() can be overridden by an
architecture and alpha makes use of this because it has special ordering
requirements for its version of pte_offset_kernel().
[rppt@linux.ibm.com: v2]
Link: http://lkml.kernel.org/r/20200514170327.31389-11-rppt@kernel.org
[rppt@linux.ibm.com: update]
Link: http://lkml.kernel.org/r/20200514170327.31389-12-rppt@kernel.org
[rppt@linux.ibm.com: update]
Link: http://lkml.kernel.org/r/20200514170327.31389-13-rppt@kernel.org
[akpm@linux-foundation.org: fix x86 warning]
[sfr@canb.auug.org.au: fix powerpc build]
Link: http://lkml.kernel.org/r/20200607153443.GB738695@linux.ibm.com
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com >
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brian Cain <bcain@codeaurora.org >
Cc: Catalin Marinas <catalin.marinas@arm.com >
Cc: Chris Zankel <chris@zankel.net >
Cc: "David S. Miller" <davem@davemloft.net >
Cc: Geert Uytterhoeven <geert@linux-m68k.org >
Cc: Greentime Hu <green.hu@gmail.com >
Cc: Greg Ungerer <gerg@linux-m68k.org >
Cc: Guan Xuetao <gxt@pku.edu.cn >
Cc: Guo Ren <guoren@kernel.org >
Cc: Heiko Carstens <heiko.carstens@de.ibm.com >
Cc: Helge Deller <deller@gmx.de >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ley Foon Tan <ley.foon.tan@intel.com >
Cc: Mark Salter <msalter@redhat.com >
Cc: Matthew Wilcox <willy@infradead.org >
Cc: Matt Turner <mattst88@gmail.com >
Cc: Max Filippov <jcmvbkbc@gmail.com >
Cc: Michael Ellerman <mpe@ellerman.id.au >
Cc: Michal Simek <monstr@monstr.eu >
Cc: Nick Hu <nickhu@andestech.com >
Cc: Paul Walmsley <paul.walmsley@sifive.com >
Cc: Richard Weinberger <richard@nod.at >
Cc: Rich Felker <dalias@libc.org >
Cc: Russell King <linux@armlinux.org.uk >
Cc: Stafford Horne <shorne@gmail.com >
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: Tony Luck <tony.luck@intel.com >
Cc: Vincent Chen <deanbo422@gmail.com >
Cc: Vineet Gupta <vgupta@synopsys.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yoshinori Sato <ysato@users.sourceforge.jp >
Link: http://lkml.kernel.org/r/20200514170327.31389-10-rppt@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2020-06-09 09:39:14 -07:00
c910951a85
csky: replace definitions of __pXd_offset() with pXd_index()
...
All architectures use pXd_index() to get an entry in the page table page
corresponding to a virtual address.
Align csky with other architectures.
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brian Cain <bcain@codeaurora.org >
Cc: Catalin Marinas <catalin.marinas@arm.com >
Cc: Chris Zankel <chris@zankel.net >
Cc: "David S. Miller" <davem@davemloft.net >
Cc: Geert Uytterhoeven <geert@linux-m68k.org >
Cc: Greentime Hu <green.hu@gmail.com >
Cc: Greg Ungerer <gerg@linux-m68k.org >
Cc: Guan Xuetao <gxt@pku.edu.cn >
Cc: Guo Ren <guoren@kernel.org >
Cc: Heiko Carstens <heiko.carstens@de.ibm.com >
Cc: Helge Deller <deller@gmx.de >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ley Foon Tan <ley.foon.tan@intel.com >
Cc: Mark Salter <msalter@redhat.com >
Cc: Matthew Wilcox <willy@infradead.org >
Cc: Matt Turner <mattst88@gmail.com >
Cc: Max Filippov <jcmvbkbc@gmail.com >
Cc: Michael Ellerman <mpe@ellerman.id.au >
Cc: Michal Simek <monstr@monstr.eu >
Cc: Nick Hu <nickhu@andestech.com >
Cc: Paul Walmsley <paul.walmsley@sifive.com >
Cc: Richard Weinberger <richard@nod.at >
Cc: Rich Felker <dalias@libc.org >
Cc: Russell King <linux@armlinux.org.uk >
Cc: Stafford Horne <shorne@gmail.com >
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: Tony Luck <tony.luck@intel.com >
Cc: Vincent Chen <deanbo422@gmail.com >
Cc: Vineet Gupta <vgupta@synopsys.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yoshinori Sato <ysato@users.sourceforge.jp >
Link: http://lkml.kernel.org/r/20200514170327.31389-5-rppt@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2020-06-09 09:39:13 -07:00
ca5999fde0
mm: introduce include/linux/pgtable.h
...
The include/linux/pgtable.h is going to be the home of generic page table
manipulation functions.
Start with moving asm-generic/pgtable.h to include/linux/pgtable.h and
make the latter include asm/pgtable.h.
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brian Cain <bcain@codeaurora.org >
Cc: Catalin Marinas <catalin.marinas@arm.com >
Cc: Chris Zankel <chris@zankel.net >
Cc: "David S. Miller" <davem@davemloft.net >
Cc: Geert Uytterhoeven <geert@linux-m68k.org >
Cc: Greentime Hu <green.hu@gmail.com >
Cc: Greg Ungerer <gerg@linux-m68k.org >
Cc: Guan Xuetao <gxt@pku.edu.cn >
Cc: Guo Ren <guoren@kernel.org >
Cc: Heiko Carstens <heiko.carstens@de.ibm.com >
Cc: Helge Deller <deller@gmx.de >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ley Foon Tan <ley.foon.tan@intel.com >
Cc: Mark Salter <msalter@redhat.com >
Cc: Matthew Wilcox <willy@infradead.org >
Cc: Matt Turner <mattst88@gmail.com >
Cc: Max Filippov <jcmvbkbc@gmail.com >
Cc: Michael Ellerman <mpe@ellerman.id.au >
Cc: Michal Simek <monstr@monstr.eu >
Cc: Nick Hu <nickhu@andestech.com >
Cc: Paul Walmsley <paul.walmsley@sifive.com >
Cc: Richard Weinberger <richard@nod.at >
Cc: Rich Felker <dalias@libc.org >
Cc: Russell King <linux@armlinux.org.uk >
Cc: Stafford Horne <shorne@gmail.com >
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: Tony Luck <tony.luck@intel.com >
Cc: Vincent Chen <deanbo422@gmail.com >
Cc: Vineet Gupta <vgupta@synopsys.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yoshinori Sato <ysato@users.sourceforge.jp >
Link: http://lkml.kernel.org/r/20200514170327.31389-3-rppt@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2020-06-09 09:39:13 -07:00
78e7c5af08
mm/special: create generic fallbacks for pte_special() and pte_mkspecial()
...
Currently there are many platforms that dont enable ARCH_HAS_PTE_SPECIAL
but required to define quite similar fallback stubs for special page
table entry helpers such as pte_special() and pte_mkspecial(), as they
get build in generic MM without a config check. This creates two
generic fallback stub definitions for these helpers, eliminating much
code duplication.
mips platform has a special case where pte_special() and pte_mkspecial()
visibility is wider than what ARCH_HAS_PTE_SPECIAL enablement requires.
This restricts those symbol visibility in order to avoid redefinitions
which is now exposed through this new generic stubs and subsequent build
failure. arm platform set_pte_at() definition needs to be moved into a
C file just to prevent a build failure.
[anshuman.khandual@arm.com: use defined(CONFIG_ARCH_HAS_PTE_SPECIAL) in mips per Thomas]
Link: http://lkml.kernel.org/r/1583851924-21603-1-git-send-email-anshuman.khandual@arm.com
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Acked-by: Guo Ren <guoren@kernel.org > [csky]
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org > [m68k]
Acked-by: Stafford Horne <shorne@gmail.com > [openrisc]
Acked-by: Helge Deller <deller@gmx.de > [parisc]
Cc: Richard Henderson <rth@twiddle.net >
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru >
Cc: Matt Turner <mattst88@gmail.com >
Cc: Russell King <linux@armlinux.org.uk >
Cc: Brian Cain <bcain@codeaurora.org >
Cc: Tony Luck <tony.luck@intel.com >
Cc: Fenghua Yu <fenghua.yu@intel.com >
Cc: Sam Creasey <sammy@sammy.net >
Cc: Michal Simek <monstr@monstr.eu >
Cc: Ralf Baechle <ralf@linux-mips.org >
Cc: Paul Burton <paulburton@kernel.org >
Cc: Nick Hu <nickhu@andestech.com >
Cc: Greentime Hu <green.hu@gmail.com >
Cc: Vincent Chen <deanbo422@gmail.com >
Cc: Ley Foon Tan <ley.foon.tan@intel.com >
Cc: Jonas Bonn <jonas@southpole.se >
Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi >
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com >
Cc: "David S. Miller" <davem@davemloft.net >
Cc: Jeff Dike <jdike@addtoit.com >
Cc: Richard Weinberger <richard@nod.at >
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com >
Cc: Guan Xuetao <gxt@pku.edu.cn >
Cc: Chris Zankel <chris@zankel.net >
Cc: Max Filippov <jcmvbkbc@gmail.com >
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de >
Link: http://lkml.kernel.org/r/1583802551-15406-1-git-send-email-anshuman.khandual@arm.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2020-04-10 15:36:21 -07:00
f136008f31
csky: Separate fixaddr_init from highmem
...
After fixaddr_init is separated from highmem, we could use tcm
without highmem selected. (610 (abiv1) don't support highmem,
but it could use tcm now.)
Signed-off-by: Guo Ren <guoren@linux.alibaba.com >
2020-02-21 15:43:24 +08:00
0055f67b59
csky: use generic ioremap
...
Use the generic ioremap_prot and iounmap helpers.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Acked-by: Guo Ren <guoren@kernel.org >
2019-11-12 11:37:52 +01:00
80b29b6b8c
Merge tag 'csky-for-linus-5.4-rc1' of git://github.com/c-sky/csky-linux
...
Pull csky updates from Guo Ren:
"This round of csky subsystem just some fixups:
- Fix mb() synchronization problem
- Fix dma_alloc_coherent with PAGE_SO attribute
- Fix cache_op failed when cross memory ZONEs
- Optimize arch_sync_dma_for_cpu/device with dma_inv_range
- Fix ioremap function losing
- Fix arch_get_unmapped_area() implementation
- Fix defer cache flush for 610
- Support kernel non-aligned access
- Fix 610 vipt cache flush mechanism
- Fix add zero_fp fixup perf backtrace panic
- Move static keyword to the front of declaration
- Fix csky_pmu.max_period assignment
- Use generic free_initrd_mem()
- entry: Remove unneeded need_resched() loop"
* tag 'csky-for-linus-5.4-rc1' of git://github.com/c-sky/csky-linux:
csky: Move static keyword to the front of declaration
csky: entry: Remove unneeded need_resched() loop
csky: Fixup csky_pmu.max_period assignment
csky: Fixup add zero_fp fixup perf backtrace panic
csky: Use generic free_initrd_mem()
csky: Fixup 610 vipt cache flush mechanism
csky: Support kernel non-aligned access
csky: Fixup defer cache flush for 610
csky: Fixup arch_get_unmapped_area() implementation
csky: Fixup ioremap function losing
csky: Optimize arch_sync_dma_for_cpu/device with dma_inv_range
csky/dma: Fixup cache_op failed when cross memory ZONEs
csky: Fixup dma_alloc_coherent with PAGE_SO attribute
csky: Fixup mb() synchronization problem
2019-09-30 10:16:17 -07:00
782de70c42
mm: consolidate pgtable_cache_init() and pgd_cache_init()
...
Both pgtable_cache_init() and pgd_cache_init() are used to initialize kmem
cache for page table allocations on several architectures that do not use
PAGE_SIZE tables for one or more levels of the page table hierarchy.
Most architectures do not implement these functions and use __weak default
NOP implementation of pgd_cache_init(). Since there is no such default
for pgtable_cache_init(), its empty stub is duplicated among most
architectures.
Rename the definitions of pgd_cache_init() to pgtable_cache_init() and
drop empty stubs of pgtable_cache_init().
Link: http://lkml.kernel.org/r/1566457046-22637-1-git-send-email-rppt@linux.ibm.com
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com >
Acked-by: Will Deacon <will@kernel.org > [arm64]
Acked-by: Thomas Gleixner <tglx@linutronix.de > [x86]
Cc: Catalin Marinas <catalin.marinas@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Matthew Wilcox <willy@infradead.org >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2019-09-24 15:54:09 -07:00
7f80fe207d
csky: Fixup dma_alloc_coherent with PAGE_SO attribute
...
This bug is from commit: 2b070ccdf8
(fixup abiv2 mmap(... O_SYNC)
failed). In that patch we remove the _PAGE_SO for memory noncache
mapping and this will cause problem when drivers use dma descriptors
to control the transcations without dma_w/rmb().
After referencing other archs' implementation, pgprot_writecombine is
introduced for mmap(... O_SYNC).
Signed-off-by: Guo Ren <ren_guo@c-sky.com >
2019-07-31 11:05:25 +08:00
9d35dc3006
csky: Revert mmu ASID mechanism
...
Current C-SKY ASID mechanism is from mips and it doesn't work well
with multi-cores. ASID per core mechanism is not suitable for C-SKY
SMP tlb maintain operations, eg: tlbi.vas need share the same asid
in all processors and it'll invalid the tlb entry in all cores with
the same asid.
This patch is prepare for new ASID mechanism.
Signed-off-by: Guo Ren <ren_guo@c-sky.com >
Cc: Arnd Bergmann <arnd@arndb.de >
2019-07-19 14:21:36 +08:00
76d21d186a
csky: Fixup io-range page attribute for mmap("/dev/mem")
...
Some user space drivers need accessing IO address and IO remap need
SO(strong order) page-attribute to make IO operation correct. So we
need add SO-page-attr for all non-memory address.
Signed-off-by: Guo Ren <ren_guo@c-sky.com >
Reported-by: Fan Xiaodong <xiaodong.fan@boyahualu.com >
2019-02-13 09:48:14 +08:00
62eebea655
csky: Fixup _PAGE_GLOBAL bit for 610 tlb entry
...
C-SKY CPU 8xx's _PAGE_GLOBAL is BIT(0), but 610's _PAGE_GLOBAL is
BIT(6). Use _PAGE_GLOBAL macro instead of bad magic number.
Signed-off-by: Guo Ren <ren_guo@c-sky.com >
2019-02-13 09:48:14 +08:00
013de2d667
csky: MMU and page table management
...
This patch adds files related to memory management and here is our
memory-layout:
Fixmap : 0xffc02000 – 0xfffff000 (4 MB - 12KB)
Pkmap : 0xff800000 – 0xffc00000 (4 MB)
Vmalloc : 0xf0200000 – 0xff000000 (238 MB)
Lowmem : 0x80000000 – 0xc0000000 (1GB)
abiv1 CPU (CK610) is VIPT cache and it doesn't support highmem.
abiv2 CPUs are all PIPT cache and they could support highmem.
Lowmem is directly mapped by msa0 & msa1 reg, and we needn't setup
memory page table for it.
Link:https://lore.kernel.org/lkml/20180518215548.GH17671@n2100.armlinux.org.uk/
Signed-off-by: Guo Ren <ren_guo@c-sky.com >
Cc: Christoph Hellwig <hch@infradead.org >
Reviewed-by: Arnd Bergmann <arnd@arndb.de >
2018-10-25 23:36:19 +08:00