1. 24 May, 2020 5 commits
    • Joshua Kinard's avatar
      MIPS: SGI-IP30: Reorder the macros in war.h · b34a1a71
      Joshua Kinard authored
      Fix the ordering of the macros in arch/mips/mach-ip30/war.h to match
      those in arch/mips/mach-ip27/war.h.
      Signed-off-by: default avatarJoshua Kinard <kumba@gentoo.org>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      b34a1a71
    • WANG Xuerui's avatar
      MIPS: emulate CPUCFG instruction on older Loongson64 cores · ec7a9318
      WANG Xuerui authored
      CPUCFG is the instruction for querying processor characteristics on
      newer Loongson processors, much like CPUID of x86. Since the instruction
      is supposedly designed to provide a unified way to do feature detection
      (without having to, for example, parse /proc/cpuinfo which is too
      heavyweight), it is important to provide compatibility for older cores
      without native support. Fortunately, most of the fields can be
      synthesized without changes to semantics. Performance is not really big
      a concern, because feature detection logic is not expected to be
      invoked very often in typical userland applications.
      
      The instruction can't be emulated on LOONGSON_2EF cores, according to
      FlyGoat's experiments. Because the LWC2 opcode is assigned to other
      valid instructions on 2E and 2F, no RI exception is raised for us to
      intercept. So compatibility is only extended back furthest to
      Loongson-3A1000. Loongson-2K is covered too, as it is basically a remix
      of various blocks from the 3A/3B models from a kernel perspective.
      
      This is lightly based on Loongson's work on their Linux 3.10 fork, for
      being the authority on the right feature flags to fill in, where things
      aren't otherwise discoverable.
      Signed-off-by: default avatarWANG Xuerui <git@xen0n.name>
      Reviewed-by: default avatarJiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      ec7a9318
    • Huacai Chen's avatar
      MIPS: Tidy up CP0.Config6 bits definition · 8267e78f
      Huacai Chen authored
      CP0.Config6 is a Vendor-defined register whose bits definitions are
      different from one to another. Recently, Xuerui's Loongson-3 patch and
      Serge's P5600 patch make the definitions inconsistency and unclear.
      
      To make life easy, this patch tidy the definition up:
      1, Add a _MTI_ infix for proAptiv/P5600 feature bits;
      2, Add a _LOONGSON_ infix for Loongson-3 feature bits;
      3, Add bit6/bit7 definition for Loongson-3 which will be used later.
      
      All existing users of these macros are updated.
      
      Cc: WANG Xuerui <git@xen0n.name>
      Cc: Serge Semin <Sergey.Semin@baikalelectronics.ru>
      Signed-off-by: default avatarHuacai Chen <chenhc@lemote.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      8267e78f
    • Tiezhu Yang's avatar
      MIPS: DTS: Only build subdir of current platform · 41528ba6
      Tiezhu Yang authored
      Add config check in Makefile to only build the subdir of current platform.
      
      E.g. without this patch:
      
        AR      arch/mips/built-in.a
        AR      arch/mips/boot/dts/brcm/built-in.a
        AR      arch/mips/boot/dts/cavium-octeon/built-in.a
        AR      arch/mips/boot/dts/img/built-in.a
        AR      arch/mips/boot/dts/ingenic/built-in.a
        AR      arch/mips/boot/dts/lantiq/built-in.a
        DTC     arch/mips/boot/dts/loongson/loongson3_4core_rs780e.dtb
        DTB     arch/mips/boot/dts/loongson/loongson3_4core_rs780e.dtb.S
        AS      arch/mips/boot/dts/loongson/loongson3_4core_rs780e.dtb.o
        DTC     arch/mips/boot/dts/loongson/loongson3_8core_rs780e.dtb
        DTB     arch/mips/boot/dts/loongson/loongson3_8core_rs780e.dtb.S
        AS      arch/mips/boot/dts/loongson/loongson3_8core_rs780e.dtb.o
        AR      arch/mips/boot/dts/loongson/built-in.a
        AR      arch/mips/boot/dts/mscc/built-in.a
        AR      arch/mips/boot/dts/mti/built-in.a
        AR      arch/mips/boot/dts/netlogic/built-in.a
        AR      arch/mips/boot/dts/ni/built-in.a
        AR      arch/mips/boot/dts/pic32/built-in.a
        AR      arch/mips/boot/dts/qca/built-in.a
        AR      arch/mips/boot/dts/ralink/built-in.a
        AR      arch/mips/boot/dts/xilfpga/built-in.a
        AR      arch/mips/boot/dts/built-in.a
      
      With this patch:
      
        AR      arch/mips/built-in.a
        DTC     arch/mips/boot/dts/loongson/loongson3_4core_rs780e.dtb
        DTB     arch/mips/boot/dts/loongson/loongson3_4core_rs780e.dtb.S
        AS      arch/mips/boot/dts/loongson/loongson3_4core_rs780e.dtb.o
        DTC     arch/mips/boot/dts/loongson/loongson3_8core_rs780e.dtb
        DTB     arch/mips/boot/dts/loongson/loongson3_8core_rs780e.dtb.S
        AS      arch/mips/boot/dts/loongson/loongson3_8core_rs780e.dtb.o
        AR      arch/mips/boot/dts/loongson/built-in.a
        AR      arch/mips/boot/dts/built-in.a
      Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      41528ba6
    • Ben Hutchings's avatar
      MIPS: Fix exception handler memcpy() · f39293fd
      Ben Hutchings authored
      The exception handler subroutines are declared as a single char, but
      when copied to the required addresses the copy length is 0x80.
      
      When range checks are enabled for memcpy() this results in a build
      failure, with error messages such as:
      
      In file included from arch/mips/mti-malta/malta-init.c:15:
      In function 'memcpy',
          inlined from 'mips_nmi_setup' at arch/mips/mti-malta/malta-init.c:98:2:
      include/linux/string.h:376:4: error: call to '__read_overflow2' declared with attribute error: detected read beyond size of object passed as 2nd parameter
        376 |    __read_overflow2();
            |    ^~~~~~~~~~~~~~~~~~
      
      Change the declarations to use type char[].
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      Signed-off-by: default avatarYunQiang Su <syq@debian.org>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      f39293fd
  2. 22 May, 2020 9 commits
    • Serge Semin's avatar
      mips: cevt-r4k: Update the r4k-clockevent frequency in sync with CPU · 21e1a03e
      Serge Semin authored
      Due to being embedded into the CPU cores MIPS count/compare timer
      frequency is changed together with the CPU clocks alteration.
      In case if frequency really changes the kernel clockevent framework
      must be notified, otherwise the kernel timers won't work correctly.
      Fix this by calling clockevents_update_freq() for each r4k clockevent
      handlers registered per available CPUs.
      
      Traditionally MIPS r4k-clock are clocked with CPU frequency divided by 2.
      But this isn't true for some of the platforms. Due to this we have to save
      the basic CPU frequency, so then use it to scale the initial timer
      frequency (mips_hpt_frequency) and pass the updated value further to the
      clockevent framework.
      Signed-off-by: default avatarSerge Semin <Sergey.Semin@baikalelectronics.ru>
      Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Paul Burton <paulburton@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: devicetree@vger.kernel.org
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      21e1a03e
    • Serge Semin's avatar
      mips: csrc-r4k: Mark R4K timer as unstable if CPU freq changes · 38586428
      Serge Semin authored
      Commit 07d69579 ("MIPS: Don't register r4k sched clock when CPUFREQ
      enabled") disabled the r4k-clock usage for scheduler ticks counting due
      to the scheduler being non-tolerant for unstable clocks sources. For the
      same reason the clock should be used in the system clocksource framework
      with care. As soon as CPU frequency changes the clocksource framework
      should be notified about this by marking the R4K timer being unstable
      (which it really is, since the ticks rate has been changed synchronously
      with the CPU frequency).
      Signed-off-by: default avatarSerge Semin <Sergey.Semin@baikalelectronics.ru>
      Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Paul Burton <paulburton@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: devicetree@vger.kernel.org
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      38586428
    • Serge Semin's avatar
      mips: Add udelay lpj numbers adjustment · ed26aacf
      Serge Semin authored
      Loops-per-jiffies is a special number which represents a number of
      noop-loop cycles per CPU-scheduler quantum - jiffies. As you
      understand aside from CPU-specific implementation it depends on
      the CPU frequency. So when a platform has the CPU frequency fixed,
      we have no problem and the current udelay interface will work
      just fine. But as soon as CPU-freq driver is enabled and the cores
      frequency changes, we'll end up with distorted udelay's. In order
      to fix this we have to accordinly adjust the per-CPU udelay_val
      (the same as the global loops_per_jiffy) number. This can be done
      in the CPU-freq transition event handler. We subscribe to that event
      in the MIPS arch time-inititalization method.
      Co-developed-by: default avatarAlexey Malahov <Alexey.Malahov@baikalelectronics.ru>
      Signed-off-by: default avatarAlexey Malahov <Alexey.Malahov@baikalelectronics.ru>
      Signed-off-by: default avatarSerge Semin <Sergey.Semin@baikalelectronics.ru>
      Reviewed-by: default avatarJiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Paul Burton <paulburton@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: devicetree@vger.kernel.org
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      ed26aacf
    • Serge Semin's avatar
      mips: Add CPS_NS16550_WIDTH config · ad42e0a8
      Serge Semin authored
      On some platforms IO-memory might require to use a proper load/store
      instructions (like Baikal-T1 IO-memory). To fix the cps-vec UART debug
      printout let's add the CONFIG_CPS_NS16550_WIDTH config to determine which
      instructions lb/sb, lh/sh or lw/sw are required for MMIO operations.
      Signed-off-by: default avatarSerge Semin <Sergey.Semin@baikalelectronics.ru>
      Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Paul Burton <paulburton@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: devicetree@vger.kernel.org
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      ad42e0a8
    • Serge Semin's avatar
      mips: Add CONFIG/CONFIG6/Cause reg fields macro · 999079c8
      Serge Semin authored
      There are bit fields which persist in the MIPS CONFIG and CONFIG6
      registers, but haven't been described in the generic mipsregs.h
      header so far. In particular, the generic CONFIG bitfields are
      BE - endian mode, BM - burst mode, SB - SimpleBE, OCP interface mode
      indicator, UDI - user-defined "CorExtend" instructions, DSP - data
      scratch pad RAM present, ISP - instruction scratch pad RAM present,
      etc. The core-specific CONFIG6 bitfields are JRCD - jump register
      cache prediction disable, R6 - MIPSr6 extensions enable, IFUPerfCtl -
      IFU performance control, SPCD - sleep state performance counter, DLSB -
      disable load/store bonding. A new exception code reported in the
      ExcCode field of the Cause register: 30 - Parity/ECC error exception
      happened on either fetch, load or cache refill. Lets add them to the
      mipsregs.h header to be used in future platform code, which have them
      utilized.
      Signed-off-by: default avatarSerge Semin <Sergey.Semin@baikalelectronics.ru>
      Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Paul Burton <paulburton@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: devicetree@vger.kernel.org
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      999079c8
    • Serge Semin's avatar
      mips: Add CP0 Write Merge config support · 742318ad
      Serge Semin authored
      CP0 config register may indicate whether write-through merging
      is allowed. Currently there are two types of the merging available:
      SysAD Valid and Full modes. Whether each of them are supported by
      the core is implementation dependent. Moreover whether the ability
      to change the mode also depends on the chip family instance. Taking
      into account all of this we created a dedicated mm_config() method
      to detect and enable merging if it's supported. It is called for
      MIPS-type processors at CPU-probe stage and attempts to detect whether
      the write merging is available. If it's known to be supported and
      switchable, then switch on the full mode. Otherwise just perform the
      CP0.Config.MM field analysis.
      
      In addition there are platforms like InterAptiv/ProAptiv, which do have
      the MM bit field set by default, but having write-through cacheing
      unsupported makes write-merging also unsupported. In this case we just
      ignore the MM field value.
      Co-developed-by: default avatarAlexey Malahov <Alexey.Malahov@baikalelectronics.ru>
      Signed-off-by: default avatarAlexey Malahov <Alexey.Malahov@baikalelectronics.ru>
      Signed-off-by: default avatarSerge Semin <Sergey.Semin@baikalelectronics.ru>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Paul Burton <paulburton@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: devicetree@vger.kernel.org
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      742318ad
    • Serge Semin's avatar
      mips: Fix cpu_has_mips64r1/2 activation for MIPS32 CPUs · a2ac81c6
      Serge Semin authored
      Commit 1aeba347 ("MIPS: Hardcode cpu_has_mips* where target ISA
      allows") updated the cpu_has_mips* macro to be replaced with a constant
      expression where it's possible. By mistake it wasn't done correctly
      for cpu_has_mips64r1/cpu_has_mips64r2 macro. They are defined to
      be replaced with conditional expression __isa_range_or_flag(), which
      means either ISA revision being within the range or the corresponding
      CPU options flag was set at the probe stage or both being true at the
      same time. But the ISA level value doesn't indicate whether the ISA is
      MIPS32 or MIPS64. Due to this if we select MIPS32r1 - MIPS32r5
      architectures the __isa_range() macro will activate the
      cpu_has_mips64rX flags, which is incorrect. In order to fix the
      problem we make sure the 64bits CPU support is enabled by means of
      checking the flag cpu_has_64bits aside with proper ISA range and specific
      Revision flag being set.
      
      Fixes: 1aeba347 ("MIPS: Hardcode cpu_has_mips* where target ISA allows")
      Signed-off-by: default avatarSerge Semin <Sergey.Semin@baikalelectronics.ru>
      Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Paul Burton <paulburton@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: devicetree@vger.kernel.org
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      a2ac81c6
    • Serge Semin's avatar
      mips: Add MIPS Warrior P5600 support · 281e3aea
      Serge Semin authored
      This is a MIPS32 Release 5 based IP core with XPA, EVA, dual/quad issue
      exec pipes, MMU with two-levels TLB, UCA, MSA, MDU core level features
      and system level features like up to six P5600 calculation cores, CM2
      with L2 cache, IOCU/IOMMU (though might be unused depending on the
      system-specific IP core configuration), GIC, CPC, virtualisation module,
      eJTAG and PDtrace.
      
      As being MIPS32 Release 5 based core it provides all the features
      available by the CPU_MIPS32_R5 config, while adding a few more like
      UCA attribute support, availability of CPU-freq (by means of L2/CM
      clock ratio setting), EI/VI GIC modes detection at runtime.
      
      In addition to this if P5600 architecture is enabled modern GNU GCC
      provides a specific tuning for P5600 processors with respect to the
      classic MIPS32 Release 5. First of all branch-likely avoidance is
      activated only when the code is compiled with the speed optimization
      (avoidance is always enabled for the pure MIPS32 Release 5
      architecture). Secondly the madd/msub avoidance is enabled since
      madd/msub utilization isn't profitable due to overhead of getting the
      result out of the HI/LO registers. Multiply-accumulate instructions are
      activated and utilized together with the necessary code reorder when
      multiply-add/multiply-subtract statements are met. Finally load/store
      bonding is activated by default. All of these optimizations may make
      the code relatively faster than if just MIP32 release 5 architecture
      was requested.
      Co-developed-by: default avatarAlexey Malahov <Alexey.Malahov@baikalelectronics.ru>
      Signed-off-by: default avatarAlexey Malahov <Alexey.Malahov@baikalelectronics.ru>
      Signed-off-by: default avatarSerge Semin <Sergey.Semin@baikalelectronics.ru>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Paul Burton <paulburton@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: devicetree@vger.kernel.org
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      281e3aea
    • Serge Semin's avatar
      mips: Add MIPS Release 5 support · ab7c01fd
      Serge Semin authored
      There are five MIPS32/64 architecture releases currently available:
      from 1 to 6 except fourth one, which was intentionally skipped.
      Three of them can be called as major: 1st, 2nd and 6th, that not only
      have some system level alterations, but also introduced significant
      core/ISA level updates. The rest of the MIPS architecture releases are
      minor.
      
      Even though they don't have as much ISA/system/core level changes
      as the major ones with respect to the previous releases, they still
      provide a set of updates (I'd say they were intended to be the
      intermediate releases before a major one) that might be useful for the
      kernel and user-level code, when activated by the kernel or compiler.
      In particular the following features were introduced or ended up being
      available at/after MIPS32/64 Release 5 architecture:
      + the last release of the misaligned memory access instructions,
      + virtualisation - VZ ASE - is optional component of the arch,
      + SIMD - MSA ASE - is optional component of the arch,
      + DSP ASE is optional component of the arch,
      + CP0.Status.FR=1 for CP1.FIR.F64=1 (pure 64-bit FPU general registers)
        must be available if FPU is implemented,
      + CP1.FIR.Has2008 support is required so CP1.FCSR.{ABS2008,NAN2008} bits
        are available.
      + UFR/UNFR aliases to access CP0.Status.FR from user-space by means of
        ctc1/cfc1 instructions (enabled by CP0.Config5.UFR),
      + CP0.COnfig5.LLB=1 and eretnc instruction are implemented to without
        accidentally clearing LL-bit when returning from an interrupt,
        exception, or error trap,
      + XPA feature together with extended versions of CPx registers is
        introduced, which needs to have mfhc0/mthc0 instructions available.
      
      So due to these changes GNU GCC provides an extended instructions set
      support for MIPS32/64 Release 5 by default like eretnc/mfhc0/mthc0. Even
      though the architecture alteration isn't that big, it still worth to be
      taken into account by the kernel software. Finally we can't deny that
      some optimization/limitations might be found in future and implemented
      on some level in kernel or compiler. In this case having even
      intermediate MIPS architecture releases support would be more than
      useful.
      
      So the most of the changes provided by this commit can be split into
      either compile- or runtime configs related. The compile-time related
      changes are caused by adding the new CONFIG_CPU_MIPS32_R5/CONFIG_CPU_MIPSR5
      configs and concern the code activating MIPSR2 or MIPSR6 already
      implemented features (like eretnc/LLbit, mthc0/mfhc0). In addition
      CPU_HAS_MSA can be now freely enabled for MIPS32/64 release 5 based
      platforms as this is done for CPU_MIPS32_R6 CPUs. The runtime changes
      concerns the features which are handled with respect to the MIPS ISA
      revision detected at run-time by means of CP0.Config.{AT,AR} bits. Alas
      these fields can be used to detect either r1 or r2 or r6 releases.
      But since we know which CPUs in fact support the R5 arch, we can manually
      set MIPS_CPU_ISA_M32R5/MIPS_CPU_ISA_M64R5 bit of c->isa_level and then
      use cpu_has_mips32r5/cpu_has_mips64r5 where it's appropriate.
      
      Since XPA/EVA provide too complex alterationss and to have them used with
      MIPS32 Release 2 charged kernels (for compatibility with current platform
      configs) they are left to be setup as a separate kernel configs.
      Co-developed-by: default avatarAlexey Malahov <Alexey.Malahov@baikalelectronics.ru>
      Signed-off-by: default avatarAlexey Malahov <Alexey.Malahov@baikalelectronics.ru>
      Signed-off-by: default avatarSerge Semin <Sergey.Semin@baikalelectronics.ru>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Paul Burton <paulburton@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: devicetree@vger.kernel.org
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      ab7c01fd
  3. 21 May, 2020 2 commits
  4. 20 May, 2020 2 commits
  5. 19 May, 2020 3 commits
  6. 18 May, 2020 2 commits
  7. 17 May, 2020 6 commits
  8. 15 May, 2020 5 commits
  9. 13 May, 2020 6 commits