1. 28 7月, 2018 1 次提交
    • R
      Revert "MIPS: BCM47XX: Enable 74K Core ExternalSync for PCIe erratum" · d5ea019f
      Rafał Miłecki 提交于
      This reverts commit 2a027b47 ("MIPS: BCM47XX: Enable 74K Core
      ExternalSync for PCIe erratum").
      
      Enabling ExternalSync caused a regression for BCM4718A1 (used e.g. in
      Netgear E3000 and ASUS RT-N16): it simply hangs during PCIe
      initialization. It's likely that BCM4717A1 is also affected.
      
      I didn't notice that earlier as the only BCM47XX devices with PCIe I
      own are:
      1) BCM4706 with 2 x 14e4:4331
      2) BCM4706 with 14e4:4360 and 14e4:4331
      it appears that BCM4706 is unaffected.
      
      While BCM5300X-ES300-RDS.pdf seems to document that erratum and its
      workarounds (according to quotes provided by Tokunori) it seems not even
      Broadcom follows them.
      
      According to the provided info Broadcom should define CONF7_ES in their
      SDK's mipsinc.h and implement workaround in the si_mips_init(). Checking
      both didn't reveal such code. It *could* mean Broadcom also had some
      problems with the given workaround.
      Signed-off-by: NRafał Miłecki <rafal@milecki.pl>
      Signed-off-by: NPaul Burton <paul.burton@mips.com>
      Reported-by: NMichael Marley <michael@michaelmarley.com>
      Patchwork: https://patchwork.linux-mips.org/patch/20032/
      URL: https://bugs.openwrt.org/index.php?do=details&task_id=1688
      Cc: Tokunori Ikegami <ikegami@allied-telesis.co.jp>
      Cc: Hauke Mehrtens <hauke@hauke-m.de>
      Cc: Chris Packham <chris.packham@alliedtelesis.co.nz>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      d5ea019f
  2. 19 6月, 2018 1 次提交
    • T
      MIPS: BCM47XX: Enable 74K Core ExternalSync for PCIe erratum · 2a027b47
      Tokunori Ikegami 提交于
      The erratum and workaround are described by BCM5300X-ES300-RDS.pdf as
      below.
      
        R10: PCIe Transactions Periodically Fail
      
          Description: The BCM5300X PCIe does not maintain transaction ordering.
                       This may cause PCIe transaction failure.
          Fix Comment: Add a dummy PCIe configuration read after a PCIe
                       configuration write to ensure PCIe configuration access
                       ordering. Set ES bit of CP0 configu7 register to enable
                       sync function so that the sync instruction is functional.
          Resolution:  hndpci.c: extpci_write_config()
                       hndmips.c: si_mips_init()
                       mipsinc.h CONF7_ES
      
      This is fixed by the CFE MIPS bcmsi chipset driver also for BCM47XX.
      Also the dummy PCIe configuration read is already implemented in the
      Linux BCMA driver.
      
      Enable ExternalSync in Config7 when CONFIG_BCMA_DRIVER_PCI_HOSTMODE=y
      too so that the sync instruction is externalised.
      Signed-off-by: NTokunori Ikegami <ikegami@allied-telesis.co.jp>
      Reviewed-by: NPaul Burton <paul.burton@mips.com>
      Acked-by: NHauke Mehrtens <hauke@hauke-m.de>
      Cc: Chris Packham <chris.packham@alliedtelesis.co.nz>
      Cc: Rafał Miłecki <zajec5@gmail.com>
      Cc: linux-mips@linux-mips.org
      Cc: stable@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/19461/Signed-off-by: NJames Hogan <jhogan@kernel.org>
      2a027b47
  3. 15 5月, 2018 1 次提交
    • M
      MIPS: Probe for MIPS MT perf counters per TC · 8270ab48
      Matt Redfearn 提交于
      Processors implementing the MIPS MT ASE may have performance counters
      implemented per core or per TC. Processors implemented by MIPS
      Technologies signify presence per TC through a bit in the implementation
      specific Config7 register. Currently the code which probes for their
      presence blindly reads a magic number corresponding to this bit, despite
      it potentially having a different meaning in the CPU implementation.
      
      Since CPU features are generally detected by cpu-probe.c, perform the
      detection here instead. Introduce cpu_set_mt_per_tc_perf which checks
      the bit in config7 and call it from MIPS CPUs known to implement this
      bit and the MT ASE, specifically, the 34K, 1004K and interAptiv.
      
      Once the presence of the per-tc counter is indicated in cpu_data, tests
      for it can be updated to use this flag.
      Suggested-by: NJames Hogan <jhogan@kernel.org>
      Signed-off-by: NMatt Redfearn <matt.redfearn@mips.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Matt Redfearn <matt.redfearn@mips.com>
      Cc: Paul Burton <paul.burton@mips.com>
      Cc: Maciej W. Rozycki <macro@mips.com>
      Cc: linux-mips@linux-mips.org>
      Patchwork: https://patchwork.linux-mips.org/patch/19136/Signed-off-by: NJames Hogan <jhogan@kernel.org>
      8270ab48
  4. 20 2月, 2018 1 次提交
  5. 23 1月, 2018 6 次提交
    • J
      MIPS: XPA: Standardise readx/writex accessors · abbd52fd
      James Hogan 提交于
      Now that we are using assembler macros to implement XPA instructions on
      toolchains which don't support them, pass Cop0 register names to the
      __{readx,writex}_32bit_c0_register macros in $n format rather than
      register numbers. Also pass a register select which may be useful in
      future (for example for MemoryMapID field of WatchHi registers on
      I6500).
      
      This is to make them consistent with the normal Cop0 register access
      macros which they were originally based on.
      Signed-off-by: NJames Hogan <jhogan@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/17777/
      abbd52fd
    • J
      MIPS: XPA: Allow use of $0 (zero) to MTHC0 · 3478ba99
      James Hogan 提交于
      Tweak __writex_32bit_c0_register() to allow the compiler to use $0 (the
      zero register) as an input to the mthc0 instruction.
      Signed-off-by: NJames Hogan <jhogan@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/17774/
      3478ba99
    • J
      MIPS: XPA: Use XPA instructions in assembly · 8e4789d2
      James Hogan 提交于
      Utilise XPA instructions MFHC0 & MTHC0 in inline assembly instead of
      directly encoding them with the _ASM_INSN* macros, and transparently
      implement these instructions as assembler macros if the toolchain
      doesn't support them natively, using the recently introduced assembler
      macro helpers.
      
      The old direct encodings were restricted to using the register $at, so
      this allows the extra register moves to go away (saving a grand total of
      24 bytes).
      Signed-off-by: NJames Hogan <jhogan@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/17775/
      8e4789d2
    • J
      MIPS: VZ: Pass GC0 register names in $n format · ed21e007
      James Hogan 提交于
      Now that we are using assembler macros to implement VZ instructions on
      toolchains which don't support them, pass VZ guest Cop0 register names
      to the __{read,write}_{32bit,ulong,64bit}_gc0_register macros in $n
      format rather than register numbers. This is to make them consistent
      with the normal root Cop0 register access macros which they were
      originally based on.
      Signed-off-by: NJames Hogan <jhogan@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/17773/
      ed21e007
    • J
      MIPS: VZ: Update helpers to use new asm macros · 00b4eb40
      James Hogan 提交于
      Update VZ guest register & guest TLB access helpers to use the new
      assembly macros for parsing register names and creating custom assembly
      macro instructions, which has a number of advantages:
      
       - Better code can be generated on toolchains which don't support VZ,
         more closely matching those which do, since there is no need to
         bounce values via the $at register. Some differences still remain due
         to the inability to safely fill branch delay slots and R6 compact
         branch forbidden slots with explicitly encoded instructions,
         resulting in some extra NOPs added by the assembler.
      
       - Some code duplication between toolchains which do and don't support
         VZ instructions is removed, since the helpers are only implemented
         once. When the toolchain doesn't implement the instruction an
         assembly macro implements it instead.
      
       - Instruction encodings are kept together in the source.
      
      On a generic kernel with KVM VZ support enabled this change saves about
      2.5KiB of kernel code when TOOLCHAIN_SUPPORTS_VIRT=n, bringing it down
      to about 0.5KiB more than when TOOLCHAIN_SUPPORTS_VIRT=y on r6, and just
      68 bytes more on r2.
      Signed-off-by: NJames Hogan <jhogan@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/17772/
      00b4eb40
    • J
      MIPS: Add helpers for assembler macro instructions · fc62f53b
      James Hogan 提交于
      Implement a parse_r assembler macro in asm/mipsregs.h to parse a
      register in $n form, and a few C macros for defining assembler macro
      instructions. These can be used to more transparently support older
      binutils versions which don't support for example the msa, virt, xpa, or
      crc instructions.
      
      In particular they overcome the difficulty of turning a register name in
      $n form into an instruction encoding suitable for giving to .word /
      .hword, which is particularly problematic when needed from inline
      assembly where the compiler is responsible for register allocation.
      Traditionally this had required the use of $at and an extra MOV
      instruction, but for CRC instructions with multiple GP register operands
      that approach becomes more difficult.
      
      Three assembler macro creation helpers are added:
      
       - _ASM_MACRO_0(OP, ENC)
         This is to define an assembler macro for an instruction which has no
         operands, for example the VZ TLBGR instruction.
      
       - _ASM_MACRO_2R(OP, R1, R2, ENC)
         This is to define an assembler macro for an instruction which has 2
         register operands, for example the CFCMSA instruction.
      
       - _ASM_MACRO_3R(OP, R1, R2, R3, ENC)
         This is to define an assembler macro for an instruction which has 3
         register operands, for example the crc32 instructions.
      
       - _ASM_MACRO_2R_1S(OP, R1, R2, SEL3, ENC)
         This is to define an assembler macro for a Cop0 move instruction,
         with 2 register operands and an optional register select operand
         which defaults to 0, for example the VZ MFGC0 instruction.
      Suggested-by: NRalf Baechle <ralf@linux-mips.org>
      Signed-off-by: NJames Hogan <jhogan@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Marcin Nowakowski <marcin.nowakowski@mips.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/17770/
      fc62f53b
  6. 10 1月, 2018 2 次提交
    • J
      MIPS: mipsregs.h: Make read_c0_prid use const accessor · 6538953f
      James Hogan 提交于
      Make read_c0_prid() use the new constant accessor macros so that it can
      potentially be optimised or removed by the compiler. This is
      particularly important under virtualisation, where even with hardware
      assisted virtualisation (VZ), access to the PRid register may need to be
      emulated by the hypervisor.
      
      In particular this helps eliminate the read of the PRid register in the
      rather frequently called add_interrupt_randomness() (which calls into
      arch/mips/include/asm/timex.h) when the prid is unused but the read
      can't be removed due to the inline asm being marked __volatile__.
      Reported-by: NYann LeDu <Yann.LeDu@imgtec.com>
      Signed-off-by: NJames Hogan <jhogan@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Maciej W. Rozycki <macro@mips.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/17923/
      6538953f
    • J
      MIPS: mipsregs.h: Add read const Cop0 macros · cd1e0737
      James Hogan 提交于
      Some Cop0 registers are constant and have no side effects when read.
      There is no need for the inline asm to read these to be marked
      __volatile__, and doing so prevents them from being removed by the
      compiler.
      
      Add a few new accessor macros to handle these registers more efficiently
      (especially for the sake of running in a guest where redundant access to
      the register may trap to the hypervisor):
        __read_const_32bit_c0_register()
        __read_const_64bit_c0_register()
        __read_const_ulong_c0_register()
      Signed-off-by: NJames Hogan <jhogan@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Maciej W. Rozycki <macro@mips.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/17922/
      cd1e0737
  7. 09 11月, 2017 1 次提交
  8. 21 9月, 2017 1 次提交
    • J
      MIPS: Fix input modify in __write_64bit_c0_split() · c22c8043
      James Hogan 提交于
      The inline asm in __write_64bit_c0_split() modifies the 64-bit input
      operand by shifting the high register left by 32, and constructing the
      full 64-bit value in the low register (even on a 32-bit kernel), so if
      that value is used again it could cause breakage as GCC would assume the
      registers haven't changed when they have.
      
      To quote the GCC extended asm documentation:
      > Warning: Do not modify the contents of input-only operands (except for
      > inputs tied to outputs). The compiler assumes that on exit from the
      > asm statement these operands contain the same values as they had
      > before executing the statement.
      
      Avoid modifying the input by using a temporary variable as an output
      which is modified instead of the input and not otherwise used. The asm
      is always __volatile__ so GCC shouldn't optimise it out. The low
      register of the temporary output is written before the high register of
      the input is read, so we have two constraint alternatives, one where
      both use the same registers (for when the input value isn't subsequently
      used), and one with an early clobber on the output in case the low
      output uses the same register as the high input. This allows the
      resulting assembly to remain mostly unchanged.
      
      A diff of a MIPS32r6 kernel reveals only three differences, two in
      relation to write_c0_r10k_diag() in cpu_probe() (register allocation
      rearranged slightly but otherwise identical), and one in relation to
      write_c0_cvmmemctl2() in kvm_vz_local_flush_guesttlb_all(), but the
      octeon CPU is only supported on 64-bit kernels where
      __write_64bit_c0_split() isn't used so that shouldn't matter in
      practice. So there currently doesn't appear to be anything broken by
      this bug.
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/17315/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      c22c8043
  9. 30 8月, 2017 1 次提交
  10. 05 7月, 2017 1 次提交
  11. 28 3月, 2017 4 次提交
    • J
      KVM: MIPS/VZ: Handle Octeon III guest.PRid register · 1f48f9be
      James Hogan 提交于
      Octeon III implements a read-only guest CP0_PRid register, so add cases
      to the KVM register access API for Octeon to ensure the correct value is
      read and writes are ignored.
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: "Radim Krčmář" <rkrcmar@redhat.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Andreas Herrmann <andreas.herrmann@caviumnetworks.com>
      Cc: linux-mips@linux-mips.org
      Cc: kvm@vger.kernel.org
      1f48f9be
    • J
      MIPS: Add Octeon III register accessors & definitions · 7d8a528d
      James Hogan 提交于
      Add accessors for some VZ related Cavium Octeon III specific COP0
      registers, along with field definitions. These will mostly be used by
      KVM to set up interrupt routing and partition the TLB between root and
      guest.
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Acked-by: NRalf Baechle <ralf@linux-mips.org>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Andreas Herrmann <andreas.herrmann@caviumnetworks.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: "Radim Krčmář" <rkrcmar@redhat.com>
      Cc: linux-mips@linux-mips.org
      Cc: kvm@vger.kernel.org
      7d8a528d
    • J
      MIPS: Add some missing guest CP0 accessors & defs · eb0bab38
      James Hogan 提交于
      Add some missing guest accessors and register field definitions for KVM
      for MIPS VZ to make use of.
      
      Guest CP0_LLAddr register accessors and definitions for the LLB field
      allow KVM to clear the guest LLB to cancel in-progress LL/SC atomics on
      restore, and to emulate accesses by the guest to the CP0_LLAddr
      register.
      
      Bitwise modifiers and definitions for the guest CP0_Wired and
      CP0_Config1 registers allow KVM to modify fields within the CP0_Wired
      and CP0_Config1 registers.
      
      Finally a definition for the CP0_Config5.SBRI bit allows KVM to
      initialise and allow modification of the guest version of the SBRI bit.
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Acked-by: NRalf Baechle <ralf@linux-mips.org>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: "Radim Krčmář" <rkrcmar@redhat.com>
      Cc: linux-mips@linux-mips.org
      Cc: kvm@vger.kernel.org
      eb0bab38
    • J
      MIPS: Separate MAAR V bit into VL and VH for XPA · f359a111
      James Hogan 提交于
      The MAAR V bit has been renamed VL since another bit called VH is added
      at the top of the register when it is extended to 64-bits on a 32-bit
      processor with XPA. Rename the V definition, fix the various users, and
      add definitions for the VH bit. Also add a definition for the MAARI
      Index field.
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Acked-by: NRalf Baechle <ralf@linux-mips.org>
      Cc: Paul Burton <paul.burton@imgtec.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: "Radim Krčmář" <rkrcmar@redhat.com>
      Cc: linux-mips@linux-mips.org
      Cc: kvm@vger.kernel.org
      f359a111
  12. 14 2月, 2017 1 次提交
    • J
      MIPS: Unify perf counter register definitions · 2654294b
      James Hogan 提交于
      Unify definitions for MIPS performance counter register fields in
      mipsregs.h rather than duplicating them in perf_events and oprofile.
      This will allow future patches to use them to expose performance
      counters to KVM guests.
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Robert Richter <rric@kernel.org>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Cc: oprofile-list@lists.sf.net
      Patchwork: https://patchwork.linux-mips.org/patch/15212/Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      2654294b
  13. 24 11月, 2016 1 次提交
    • P
      MIPS: Mask out limit field when calculating wired entry count · 10313980
      Paul Burton 提交于
      Since MIPSr6 the Wired register is split into 2 fields, with the upper
      16 bits of the register indicating a limit on the value that the wired
      entry count in the bottom 16 bits of the register can take. This means
      that simply reading the wired register doesn't get us a valid TLB entry
      index any longer, and we instead need to retrieve only the lower 16 bits
      of the register. Introduce a new num_wired_entries() function which does
      this on MIPSr6 or higher and simply returns the value of the wired
      register on older architecture revisions, and make use of it when
      reading the number of wired entries.
      
      Since commit e710d666 ("MIPS: tlb-r4k: If there are wired entries,
      don't use TLBINVF") we have been using a non-zero number of wired
      entries to determine whether we should avoid use of the tlbinvf
      instruction (which would invalidate wired entries) and instead loop over
      TLB entries in local_flush_tlb_all(). This loop begins with the number
      of wired entries, or before this patch some large bogus TLB index on
      MIPSr6 systems. Thus since the aforementioned commit some MIPSr6 systems
      with FTLBs have been prone to leaving stale address translations in the
      FTLB & crashing in various weird & wonderful ways when we later observe
      the wrong memory.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Cc: Matt Redfearn <matt.redfearn@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/14557/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      10313980
  14. 30 9月, 2016 1 次提交
    • P
      MIPS: Stop setting I6400 FTLBP · 72c70f01
      Paul Burton 提交于
      The FTLBP field in Config7 for the I6400 is intended as chicken bits for
      debugging rather than as a field that software actually makes use of.
      For best performance, FTLBP should be left at its default value of 0
      with all TLB writes hitting the FTLB by default.
      
      Additionally, since set_ftlb_enable is called from decode_configs before
      decode_config4 which determines the size of the TLBs, this was
      previously always setting FTLBP=3 for a 3:1 FTLB:VTLB write ratio which
      makes abysmal use of the available FTLB resources.
      
      This effectively reverts b0c4e1b79d8a ("MIPS: Set up FTLB probability
      for I6400").
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Fixes: b0c4e1b79d8a ("MIPS: Set up FTLB probability for I6400")
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/14021/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      72c70f01
  15. 16 6月, 2016 2 次提交
  16. 28 5月, 2016 7 次提交
  17. 17 5月, 2016 1 次提交
    • J
      MIPS: Fix VZ probe gas errors with binutils <2.24 · bad50d79
      James Hogan 提交于
      The VZ guest register & TLB access macros introduced in commit "MIPS:
      Add guest CP0 accessors" use VZ ASE specific instructions that aren't
      understood by versions of binutils prior to 2.24.
      
      Add a check for whether the toolchain supports the -mvirt option,
      similar to the MSA toolchain check, and implement the accessors using
      .word if not.
      
      Due to difficulty in converting compiler specified registers (e.g. "$3")
      to usable numbers (e.g. "3") in inline asm, we need to copy to/from a
      temporary register, namely the assembler temporary (at/$1), and specify
      guest CP0 registers numerically in the gc0 macros.
      
      Fixes: 7eb91118 ("MIPS: Add guest CP0 accessors")
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Reported-by: NGuenter Roeck <linux@roeck-us.net>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-next@vger.kernel.org
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/13255/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      bad50d79
  18. 13 5月, 2016 7 次提交