1. 11 Mar, 2019 3 commits
    • Archer Yan's avatar
      MIPS: Fix kernel crash for R6 in jump label branch function · 47c25036
      Archer Yan authored
      Insert Branch instruction instead of NOP to make sure assembler don't
      patch code in forbidden slot. In jump label function, it might
      be possible to patch Control Transfer Instructions(CTIs) into
      forbidden slot, which will generate Reserved Instruction exception
      in MIPS release 6.
      Signed-off-by: default avatarArcher Yan <ayan@wavecomp.com>
      Reviewed-by: default avatarPaul Burton <paul.burton@mips.com>
      [paul.burton@mips.com:
        - Add MIPS prefix to subject.
        - Mark for stable from v4.0, which introduced r6 support, onwards.]
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: linux-mips@vger.kernel.org
      Cc: stable@vger.kernel.org # v4.0+
      47c25036
    • Yasha Cherikovsky's avatar
      MIPS: Ensure ELF appended dtb is relocated · 3f0a53bc
      Yasha Cherikovsky authored
      This fixes booting with the combination of CONFIG_RELOCATABLE=y
      and CONFIG_MIPS_ELF_APPENDED_DTB=y.
      
      Sections that appear after the relocation table are not relocated
      on system boot (except .bss, which has special handling).
      
      With CONFIG_MIPS_ELF_APPENDED_DTB, the dtb is part of the
      vmlinux ELF, so it must be relocated together with everything else.
      
      Fixes: 069fd766 ("MIPS: Reserve space for relocation table")
      Signed-off-by: default avatarYasha Cherikovsky <yasha.che3@gmail.com>
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Paul Burton <paul.burton@mips.com>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Cc: stable@vger.kernel.org # v4.7+
      3f0a53bc
    • Yifeng Li's avatar
      mips: loongson64: lemote-2f: Add IRQF_NO_SUSPEND to "cascade" irqaction. · 5f5f67da
      Yifeng Li authored
      Timekeeping IRQs from CS5536 MFGPT are routed to i8259, which then
      triggers the "cascade" IRQ on MIPS CPU. Without IRQF_NO_SUSPEND in
      cascade_irqaction, MFGPT interrupts will be masked in suspend mode,
      and the machine would be unable to resume once suspended.
      
      Previously, MIPS IRQs were not disabled properly, so the original
      code appeared to work. Commit a3e6c1ef ("MIPS: IRQ: Fix disable_irq on
      CPU IRQs") uncovers the bug. To fix it, add IRQF_NO_SUSPEND to
      cascade_irqaction.
      
      This commit is functionally identical to 0add9c2f ("MIPS:
      Loongson-3: Add IRQF_NO_SUSPEND to Cascade irqaction"), but it forgot
      to apply the same fix to Loongson2.
      Signed-off-by: default avatarYifeng Li <tomli@tomli.me>
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: linux-mips@vger.kernel.org
      Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: linux-kernel@vger.kernel.org
      Cc: stable@vger.kernel.org # v3.19+
      5f5f67da
  2. 25 Feb, 2019 1 commit
    • Hauke Mehrtens's avatar
      MIPS: lantiq: Remove separate GPHY Firmware loader · aeb669d4
      Hauke Mehrtens authored
      The separate GPHY Firmware loader driver is not used any more, the GPHY
      firmware is now loaded by the GSWIP switch driver which also makes use
      of the GPHY.
      Remove the old unused GPHY firmware loader driver.
      
      The GPHY firmware is useless without an Ethernet and switch driver, it
      should not harm if loading this does not work for system using an old
      device tree.
      I am not aware of any vendor separating the device tree from the kernel
      binary, it should be ok to remove this.
      
      The code and the functionality form this separate GPHY firmware loader
      was added to the gswip driver in commit 14fceff4 ("net: dsa: Add
      Lantiq / Intel DSA driver for vrx200")
      Signed-off-by: default avatarHauke Mehrtens <hauke@hauke-m.de>
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: linux-mips@vger.kernel.org
      Cc: devicetree@vger.kernel.org
      Cc: john@phrozen.org
      Cc: netdev@vger.kernel.org
      aeb669d4
  3. 21 Feb, 2019 1 commit
  4. 19 Feb, 2019 10 commits
    • Thomas Bogendoerfer's avatar
      MIPS: SGI-IP27: rework HUB interrupts · 69a07a41
      Thomas Bogendoerfer authored
      This commit rearranges the HUB interrupt code by using MIPS_IRQ_CPU
      interrupt handling code and modern Linux IRQ framework features to get
      rid of global arrays. It also adds support for irq affinity setting.
      Signed-off-by: default avatarThomas Bogendoerfer <tbogendoerfer@suse.de>
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: linux-mips@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      69a07a41
    • Thomas Bogendoerfer's avatar
      MIPS: SGI-IP27: do boot CPU init later · 2c865620
      Thomas Bogendoerfer authored
      To make use of per_cpu variables in interrupt code per_cpu_init() must
      be done after setup_per_cpu_areas(). This is achieved by calling it
      in smp_prepare_boot_cpu() via a new smp_ops method.
      Signed-off-by: default avatarThomas Bogendoerfer <tbogendoerfer@suse.de>
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: linux-mips@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      2c865620
    • Thomas Bogendoerfer's avatar
      MIPS: SGI-IP27: do xtalk scanning later · 9707b7e6
      Thomas Bogendoerfer authored
      Move xtalk scanning to a later boot stage to be able using things like
      kmalloc and friends.
      Signed-off-by: default avatarThomas Bogendoerfer <tbogendoerfer@suse.de>
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: linux-mips@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      9707b7e6
    • Thomas Bogendoerfer's avatar
      MIPS: SGI-IP27: use pr_info/pr_emerg and pr_cont to fix output · ab68280e
      Thomas Bogendoerfer authored
      Topology and NMI output needs pr_cont() to look the way it was in the
      old days of printk.
      Signed-off-by: default avatarThomas Bogendoerfer <tbogendoerfer@suse.de>
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: linux-mips@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      ab68280e
    • Thomas Bogendoerfer's avatar
      MIPS: SGI-IP27: clean up bridge access and header files · a44d924c
      Thomas Bogendoerfer authored
      Introduced bridge_read/bridge_write/bridge_set/bridge_clr for accessing
      bridge register and get rid of volatile declarations. Also removed
      all typedefs from arch/mips/include/asm/pci/bridge.h and cleaned up
      language in arch/mips/pci/ops-bridge.c
      Signed-off-by: default avatarThomas Bogendoerfer <tbogendoerfer@suse.de>
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: linux-mips@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      a44d924c
    • Thomas Bogendoerfer's avatar
      MIPS: SGI-IP27: get rid of volatile and hubreg_t · db0e7d4e
      Thomas Bogendoerfer authored
      Replace hub register access with __raw_readq/__raw_writeq and get
      rid of hubreg_t completely. Also remove no longer (probably never
      used) used defines
      Signed-off-by: default avatarThomas Bogendoerfer <tbogendoerfer@suse.de>
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: linux-mips@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      db0e7d4e
    • Liu Xiang's avatar
      MIPS: irq: Allocate accurate order pages for irq stack · 72faa7a7
      Liu Xiang authored
      The irq_pages is the number of pages for irq stack, but not the
      order which is needed by __get_free_pages().
      We can use get_order() to calculate the accurate order.
      Signed-off-by: default avatarLiu Xiang <liu.xiang6@zte.com.cn>
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Fixes: fe8bd18f ("MIPS: Introduce irq_stack")
      Cc: linux-mips@vger.kernel.org
      Cc: stable@vger.kernel.org # v4.11+
      72faa7a7
    • Paul Burton's avatar
      MIPS: dma-noncoherent: Remove bogus condition in dma_sync_phys() · d411da06
      Paul Burton authored
      Commit e36863a5 ("MIPS: HIGHMEM DMA on noncoherent MIPS32
      processors") introduced code which:
      
        1) Calculates an offset within a page, by ANDing an address
           with ~PAGE_MASK.
      
        2) Checks whether that offset is >= PAGE_SIZE.
      
      This check can never evaluate true, making the code it guards
      unreachable. smatch spots bogus arithmetic resulting from the
      impossible condition, resulting in the following warning:
      
        arch/mips/mm/dma-noncoherent.c:125
          dma_sync_phys() warn: mask and shift to zero
      
      Fix this by removing the impossible to satisfy condition & the
      unreachable code it guards.
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: linux-mips@vger.kernel.org
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Marek Szyprowski <m.szyprowski@samsung.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      d411da06
    • Paul Burton's avatar
      MIPS: eBPF: Remove REG_32BIT_ZERO_EX · 66b6572a
      Paul Burton authored
      REG_32BIT_ZERO_EX and REG_64BIT are always handled in exactly the same
      way, and reg_val_propagate_range() never actually sets any register to
      type REG_32BIT_ZERO_EX.
      
      Remove the redundant & unused REG_32BIT_ZERO_EX.
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: linux-mips@vger.kernel.org
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: netdev@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: Jiong Wang <jiong.wang@netronome.com>
      66b6572a
    • Paul Burton's avatar
      MIPS: eBPF: Always return sign extended 32b values · bdc18902
      Paul Burton authored
      The function prototype used to call JITed eBPF code (ie. the type of the
      struct bpf_prog bpf_func field) returns an unsigned int. The MIPS n64
      ABI that MIPS64 kernels target defines that 32 bit integers should
      always be sign extended when passed in registers as either arguments or
      return values.
      
      This means that when returning any value which may not already be sign
      extended (ie. of type REG_64BIT or REG_32BIT_ZERO_EX) we need to perform
      that sign extension in order to comply with the n64 ABI. Without this we
      see strange looking test failures from test_bpf.ko, such as:
      
        test_bpf: #65 ALU64_MOV_X:
          dst = 4294967295 jited:1 ret -1 != -1 FAIL (1 times)
      
      Although the return value printed matches the expected value, this is
      only because printf is only examining the least significant 32 bits of
      the 64 bit register value we returned. The register holding the expected
      value is sign extended whilst the v0 register was set to a zero extended
      value by our JITed code, so when compared by a conditional branch
      instruction the values are not equal.
      
      We already handle this when the return value register is of type
      REG_32BIT_ZERO_EX, so simply extend this to also cover REG_64BIT.
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Fixes: b6bd53f9 ("MIPS: Add missing file for eBPF JIT.")
      Cc: stable@vger.kernel.org # v4.13+
      Cc: linux-mips@vger.kernel.org
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: netdev@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: Jiong Wang <jiong.wang@netronome.com>
      bdc18902
  5. 15 Feb, 2019 1 commit
  6. 11 Feb, 2019 1 commit
  7. 07 Feb, 2019 6 commits
  8. 06 Feb, 2019 1 commit
    • Paul Burton's avatar
      MIPS: Fix set_pte() for Netlogic XLR using cmpxchg64() · c7e2d71d
      Paul Burton authored
      Commit 46011e6e ("MIPS: Make set_pte() SMP safe.") introduced an
      open-coded version of cmpxchg() within set_pte(), that always operated
      on a value the size of an unsigned long. That is, it used ll/sc
      instructions when CONFIG_32BIT=y or lld/scd instructions when
      CONFIG_64BIT=y.
      
      This was broken for configurations in which pte_t is larger than an
      unsigned long (with the exception of XPA configurations which have a
      different implementation of set_pte()), because we no longer update the
      whole PTE. Indeed commit 46011e6e ("MIPS: Make set_pte() SMP safe.")
      notes:
      
      > The case of CONFIG_64BIT_PHYS_ADDR && CONFIG_CPU_MIPS32 is *not*
      > handled.
      
      In practice this affects Netlogic XLR/XLS systems including
      nlm_xlr_defconfig.
      
      Commit 82f4f66d ("MIPS: Remove open-coded cmpxchg() in set_pte()")
      then replaced this open-coded version of cmpxchg() with an actual call
      to cmpxchg(). Unfortunately the configurations mentioned above then fail
      to build because cmpxchg() can only operate on values 32 bits or smaller
      in size, resulting in:
      
        arch/mips/include/asm/cmpxchg.h:166:11: error:
          call to '__cmpxchg_called_with_bad_pointer' declared with
          attribute error: Bad argument size for cmpxchg
      
      One option that would fix the build failure & restore the previous
      behaviour would be to cast the pte pointer to a pointer to unsigned
      long, so that cmpxchg() would operate on just 32 bits of the PTE as it
      has been since commit 46011e6e ("MIPS: Make set_pte() SMP safe.").
      That feels like an ugly hack though, and the behaviour of set_pte() is
      likely a little broken.
      
      Instead we take advantage of the fact that the affected configurations
      already know at compile time that the CPU will support 64 bits (ie. have
      hardcoded cpu_has_64bits in cpu-feature-overrides.h) in order to allow
      cmpxchg64() to be used in these configurations. set_pte() then makes use
      of cmpxchg64() when necessary.
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Fixes: 46011e6e ("MIPS: Make set_pte() SMP safe.")
      Fixes: 82f4f66d ("MIPS: Remove open-coded cmpxchg() in set_pte()")
      c7e2d71d
  9. 05 Feb, 2019 1 commit
    • Paul Burton's avatar
      MIPS: Export mm switching functions used by KVM · 6782f26c
      Paul Burton authored
      KVM makes use of check_switch_mmu_context(), check_mmu_context() &
      get_new_mmu_context() which are no longer static inline functions in a
      header. As such they need to be exported for KVM to successfully build
      as a module, which was previously overlooked. Add the missing exports.
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Fixes: 4ebea49c ("MIPS: mm: Un-inline get_new_mmu_context")
      Fixes: 42d5b846 ("MIPS: mm: Unify ASID version checks")
      6782f26c
  10. 04 Feb, 2019 15 commits
    • Paul Burton's avatar
      MIPS: Loongson32: Remove DMA & NAND devices from ls1b/board.c · 62c2766c
      Paul Burton authored
      Commit 7b3415f5 ("MIPS: Loongson32: Remove unused platform devices")
      removed the definitions of platform devices which have no in tree
      drivers from common Loongson32 code, but missed their removal from
      Loongson 1B board code in arch/mips/loongson32/ls1b/board.c. This causes
      build failures due to the missing declarations of ls1x_dma_pdev,
      ls1x_nand_pdev & their associated *_set_platdata functions.
      
      Remove the dead code from arch/mips/loongson32/ls1b/board.c to fix the
      build.
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Fixes: 7b3415f5 ("MIPS: Loongson32: Remove unused platform devices")
      62c2766c
    • Paul Burton's avatar
      MIPS: Loongson32: Fix config brokenness; select SYS_SUPPORTS_32BIT_KERNEL · d6c2fba5
      Paul Burton authored
      Commit a96d68ba ("MIPS: Loongson32: clarify we don't support MIPS16
      and merge configs") attempted to reduce duplication in Kconfig by
      consolidating some selects common to Loongson 1B & 1C CPUs under
      CPU_LOONGSON1. Unfortunately it clearly wasn't tested because by
      removing SYS_SUPPORTS_32BIT_KERNEL it prevented 32BIT from being enabled
      leading to all sorts of strange build errors from a kernel configured to
      build as neither 32 nor 64 bit.
      
      Both loongson1b_defconfig & loongson1c_defconfig failed to build due to
      this problem.
      
      Revert the cleanup portions of commit a96d68ba ("MIPS: Loongson32:
      clarify we don't support MIPS16 and merge configs"), keeping only its
      removal of the selection of SYS_SUPPORTS_MIPS16.
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Fixes: a96d68ba ("MIPS: Loongson32: clarify we don't support MIPS16 and merge configs")
      d6c2fba5
    • Paul Burton's avatar
      MIPS: Don't select ARCH_HAS_SYNC_DMA_FOR_CPU when DMA is coherent · 9ae1f262
      Paul Burton authored
      Commit f263f2a2 ("MIPS: Compile post DMA flush only when needed")
      pushed the selection of ARCH_HAS_SYNC_DMA_FOR_CPU down to various
      SYS_HAS_CPU_* Kconfig entries corresponding to CPUs for which
      cpu_needs_post_dma_flush() might return true, but unfortunately missed
      the fact that some of these CPUs can be used in configurations with
      DMA_NONCOHERENT=n. When this is the case the kernel build does not
      include our definition of arch_sync_dma_for_cpu() from
      arch/mips/mm/dma-noncoherent.c and the build fails with a link error.
      
      One example of this problem is ip27_defconfig:
      
        kernel/dma/direct.o: In function `dma_direct_sync_single_for_cpu':
        direct.c:(.text+0x6c): undefined reference to `arch_sync_dma_for_cpu'
        kernel/dma/direct.o: In function `dma_direct_sync_sg_for_cpu':
        direct.c:(.text+0x1f0): undefined reference to `arch_sync_dma_for_cpu'
        kernel/dma/direct.o: In function `dma_direct_alloc':
        direct.c:(.text+0xc20): undefined reference to `arch_dma_alloc'
        kernel/dma/direct.o: In function `dma_direct_free':
        direct.c:(.text+0xc3c): undefined reference to `arch_dma_free'
        make[1]: *** [Makefile:1021: vmlinux] Error 1
        make: *** [Makefile:152: sub-make] Error 2
      
      Fix this by selecting ARCH_HAS_SYNC_DMA_FOR_CPU only when
      DMA_NONCOHERENT is also selected. The SYS_HAS_CPU_BMIPS5000 case is left
      as-is because systems with that CPU always select DMA_NONCOHERENT
      anyway.
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Fixes: f263f2a2 ("MIPS: Compile post DMA flush only when needed")
      9ae1f262
    • Paul Burton's avatar
      MIPS: Enable hugepage support for MIPS64r6 · afd375dc
      Paul Burton authored
      Our hugepage support already exists for MIPS64 CPUs, and is already
      enabled for older architecture revisions. There's nothing MIPSr6
      specific involved, and our hugepage support already works fine for
      MIPS64r6 CPUs such as the I6500, so allow it to be selected in Kconfig.
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: linux-mips@vger.kernel.org
      afd375dc
    • Paul Burton's avatar
      MIPS: Remove open-coded cmpxchg() in set_pte() · 82f4f66d
      Paul Burton authored
      set_pte() contains an open coded version of cmpxchg() - it atomically
      replaces the buddy pte's value if it is currently zero. Simplify the
      code considerably by just using cmpxchg() instead of reinventing it.
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: linux-mips@vger.kernel.org
      82f4f66d
    • Paul Burton's avatar
      MIPS: MemoryMapID (MMID) Support · c8790d65
      Paul Burton authored
      Introduce support for using MemoryMapIDs (MMIDs) as an alternative to
      Address Space IDs (ASIDs). The major difference between the two is that
      MMIDs are global - ie. an MMID uniquely identifies an address space
      across all coherent CPUs. In contrast ASIDs are non-global per-CPU IDs,
      wherein each address space is allocated a separate ASID for each CPU
      upon which it is used. This global namespace allows a new GINVT
      instruction be used to globally invalidate TLB entries associated with a
      particular MMID across all coherent CPUs in the system, removing the
      need for IPIs to invalidate entries with separate ASIDs on each CPU.
      
      The allocation scheme used here is largely borrowed from arm64 (see
      arch/arm64/mm/context.c). In essence we maintain a bitmap to track
      available MMIDs, and MMIDs in active use at the time of a rollover to a
      new MMID version are preserved in the new version. The allocation scheme
      requires efficient 64 bit atomics in order to perform reasonably, so
      this support depends upon CONFIG_GENERIC_ATOMIC64=n (ie. currently it
      will only be included in MIPS64 kernels).
      
      The first, and currently only, available CPU with support for MMIDs is
      the MIPS I6500. This CPU supports 16 bit MMIDs, and so for now we cap
      our MMIDs to 16 bits wide in order to prevent the bitmap growing to
      absurd sizes if any future CPU does implement 32 bit MMIDs as the
      architecture manuals suggest is recommended.
      
      When MMIDs are in use we also make use of GINVT instruction which is
      available due to the global nature of MMIDs. By executing a sequence of
      GINVT & SYNC 0x14 instructions we can avoid the overhead of an IPI to
      each remote CPU in many cases. One complication is that GINVT will
      invalidate wired entries (in all cases apart from type 0, which targets
      the entire TLB). In order to avoid GINVT invalidating any wired TLB
      entries we set up, we make sure to create those entries using a reserved
      MMID (0) that we never associate with any address space.
      
      Also of note is that KVM will require further work in order to support
      MMIDs & GINVT, since KVM is involved in allocating IDs for guests & in
      configuring the MMU. That work is not part of this patch, so for now
      when MMIDs are in use KVM is disabled.
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: linux-mips@vger.kernel.org
      c8790d65
    • Paul Burton's avatar
      MIPS: Add GINVT instruction helpers · 53511389
      Paul Burton authored
      Add a family of ginvt_* functions making it easy to emit a GINVT
      instruction to globally invalidate TLB entries. We make use of the
      _ASM_MACRO infrastructure to support emitting the instructions even if
      the assembler isn't new enough to support them natively.
      
      An associated STYPE_GINV definition & sync_ginv() function are added to
      emit a sync instruction of type 0x14, which operates as a completion
      barrier for these new GINVT (and GINVI) instructions.
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: linux-mips@vger.kernel.org
      53511389
    • Paul Burton's avatar
      MIPS: mm: Add set_cpu_context() for ASID assignments · 0b317c38
      Paul Burton authored
      When we gain MMID support we'll be storing MMIDs as atomic64_t values
      and accessing them via atomic64_* functions. This necessitates that we
      don't use cpu_context() as the left hand side of an assignment, ie. as a
      modifiable lvalue. In preparation for this introduce a new
      set_cpu_context() function & replace all assignments with cpu_context()
      on their left hand side with an equivalent call to set_cpu_context().
      
      To enforce that cpu_context() should not be used for assignments, we
      rewrite it as a static inline function.
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: linux-mips@vger.kernel.org
      0b317c38
    • Paul Burton's avatar
      MIPS: mm: Unify ASID version checks · 42d5b846
      Paul Burton authored
      Introduce a new check_mmu_context() function to check an mm's ASID
      version & get a new one if it's outdated, and a
      check_switch_mmu_context() function which additionally sets up the new
      ASID & page directory. Simplify switch_mm() & various
      get_new_mmu_context() callsites in MIPS KVM by making use of the new
      functions, which will help reduce the amount of code that requires
      modification to gain MMID support.
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: linux-mips@vger.kernel.org
      42d5b846
    • Paul Burton's avatar
      MIPS: mm: Un-inline get_new_mmu_context · 4ebea49c
      Paul Burton authored
      In preparation for adding MMID support to get_new_mmu_context() which
      will increase the size of the function somewhat, move it from
      asm/mmu_context.h into a C file.
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: linux-mips@vger.kernel.org
      4ebea49c
    • Paul Burton's avatar
      MIPS: mm: Split obj-y to a file per line · 7e8556d0
      Paul Burton authored
      Split always-included objects to one per line in order to make it easier
      to modify the list of included objects.
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: linux-mips@vger.kernel.org
      7e8556d0
    • Paul Burton's avatar
      MIPS: mm: Remove local_flush_tlb_mm() · 558ec8ad
      Paul Burton authored
      All 3 variants of local_flush_tlb_mm() are now effectively simple calls
      to drop_mmu_context(). Remove them and use drop_mmu_context() directly.
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: linux-mips@vger.kernel.org
      558ec8ad
    • Paul Burton's avatar
      MIPS: mm: Remove redundant preempt_disable in local_flush_tlb_mm() · f7908a00
      Paul Burton authored
      The r4k variant of local_flush_tlb_mm() wraps its call to
      drop_mmu_context() with a preempt_disable() & preempt_enable() pair, but
      this is redundant since drop_mmu_context() disables interrupts and from
      Documentation/preempt-locking.txt:
      
        Note that you do not need to explicitly prevent preemption if you are
        holding any locks or interrupts are disabled, since preemption is
        implicitly disabled in those cases.
      
      Remove the redundant preempt_disable() & preempt_enable() calls.
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: linux-mips@vger.kernel.org
      f7908a00
    • Paul Burton's avatar
      MIPS: mm: Move drop_mmu_context() comment into appropriate block · 6067d47e
      Paul Burton authored
      drop_mmu_context() is preceded by a comment indicating what happens if
      the mm provided is currently active on the local CPU. Move that comment
      into the block that executes in this case, adjusting slightly to reflect
      its new location.
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: linux-mips@vger.kernel.org
      6067d47e
    • Paul Burton's avatar
      MIPS: mm: Consolidate drop_mmu_context() has-ASID checks · c9b2a3dc
      Paul Burton authored
      If an mm does not have an ASID on the local CPU then drop_mmu_context()
      is always redundant, since there's no context to "drop". Various callers
      of drop_mmu_context() check whether the mm has been allocated an ASID
      before making the call. Move that check into drop_mmu_context() and
      remove it from callers to simplify them.
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: linux-mips@vger.kernel.org
      c9b2a3dc