Skip to content
  1. Jan 24, 2016
    • Maciej W. Rozycki's avatar
      MIPS: math-emu: dsemul: Reduce `get_isa16_mode' clutter · 6d7b1415
      Maciej W. Rozycki authored
      
      
      Signed-off-by: default avatarMaciej W. Rozycki <macro@imgtec.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/12178/
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      6d7b1415
    • Maciej W. Rozycki's avatar
      MIPS: inst.h: Fix some instruction descriptions · 29e28003
      Maciej W. Rozycki authored
      
      
      Fix the description of the microMIPS NOP16 encoding or MM_NOP16, which
      is not equivalent to the MIPS16 NOP instruction.  This is 0x0c00 and
      represents the microMIPS `MOVE16 $0, $0' operation, whereas MIPS16 NOP
      is encoded as 0x6500, representing `MOVE $0, $16'.
      
      Also fix a typo in `mm_fp0_format' description.
      
      Signed-off-by: default avatarMaciej W. Rozycki <macro@imgtec.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/12177/
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      29e28003
    • Maciej W. Rozycki's avatar
      MIPS: math-emu: dsemul: Correct description of the emulation frame · 6e1715f7
      Maciej W. Rozycki authored
      Remove irrelevant content from the description of the emulation frame in
      `mips_dsemul', referring to bare-metal configurations.  Update the text,
      reflecting the change made with commit ba3049ed
      
       ("MIPS: Switch FPU
      emulator trap to BREAK instruction."), where we switched from using an
      address error exception on an unaligned access to the use of a BREAK 514
      instruction causing a breakpoint exception instead.
      
      Signed-off-by: default avatarMaciej W. Rozycki <macro@imgtec.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/12176/
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      6e1715f7
    • Maciej W. Rozycki's avatar
      MIPS: math-emu: Correct the emulation of microMIPS ADDIUPC instruction · 69a1e6cb
      Maciej W. Rozycki authored
      
      
      Emulate the microMIPS ADDIUPC instruction directly in `mips_dsemul'.  If
      executed in the emulation frame, this instruction produces an incorrect
      result, because the value of the PC there is not the same as where the
      instruction originated.
      
      Reshape code so as to handle all microMIPS cases together.
      
      Signed-off-by: default avatarMaciej W. Rozycki <macro@imgtec.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/12175/
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      69a1e6cb
    • Maciej W. Rozycki's avatar
      MIPS: math-emu: Make microMIPS branch delay slot emulation work · 733b8bc1
      Maciej W. Rozycki authored
      Complement commit 102cedc3
      
       ("MIPS: microMIPS: Floating point
      support.") which introduced microMIPS FPU emulation, but did not adjust
      the encoding of the BREAK instruction used to terminate the branch delay
      slot emulation frame.  Consequently the execution of any such frame is
      indeterminate and, depending on CPU configuration, will result in random
      code execution or an offending program being terminated with SIGILL.
      
      This is because the regular MIPS BREAK instruction is encoded with the 0
      major and the 0xd minor opcode, however in the microMIPS instruction set
      this major/minor opcode pair denotes an encoding reserved for the DSP
      ASE.  Instead the microMIPS BREAK instruction is encoded with the 0
      major and the 0x7 minor opcode.
      
      Use the correct BREAK encoding for microMIPS FPU emulation then.
      
      Signed-off-by: default avatarMaciej W. Rozycki <macro@imgtec.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/12174/
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      733b8bc1
    • Maciej W. Rozycki's avatar
      MIPS: math-emu: dsemul: Fix ill formatting of microMIPS part · a87265cf
      Maciej W. Rozycki authored
      Correct formatting breakage introduced with commit 102cedc3
      
       ("MIPS:
      microMIPS: Floating point support."), so that further changes to this
      code can be consistent.
      
      Signed-off-by: default avatarMaciej W. Rozycki <macro@imgtec.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/12173/
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      a87265cf
    • Maciej W. Rozycki's avatar
      MIPS: math-emu: Correctly handle NOP emulation · e4553573
      Maciej W. Rozycki authored
      Fix an issue introduced with commit 9ab4471c
      
       ("MIPS: math-emu:
      Correct delay-slot exception propagation") where the emulation of a NOP
      instruction signals the need to terminate the emulation loop.  This in
      turn, if the PC has not changed from the entry to the loop, will cause
      the kernel to terminate the program with SIGILL.
      
      Consider this program:
      
      static double div(double d)
      {
      	do
      		d /= 2.0;
      	while (d > .5);
      	return d;
      }
      
      int main(int argc, char **argv)
      {
      	return div(argc);
      }
      
      which gets compiled to the following binary code:
      
      00400490 <main>:
        400490:	44840000 	mtc1	a0,$f0
        400494:	3c020040 	lui	v0,0x40
        400498:	d44207f8 	ldc1	$f2,2040(v0)
        40049c:	46800021 	cvt.d.w	$f0,$f0
        4004a0:	46220002 	mul.d	$f0,$f0,$f2
        4004a4:	4620103c 	c.lt.d	$f2,$f0
        4004a8:	4501fffd 	bc1t	4004a0 <main+0x10>
        4004ac:	00000000 	nop
        4004b0:	4620000d 	trunc.w.d	$f0,$f0
        4004b4:	03e00008 	jr	ra
        4004b8:	44020000 	mfc1	v0,$f0
        4004bc:	00000000 	nop
      
      Where the FPU emulator is used, depending on the number of command-line
      arguments this code will either run to completion or terminate with
      SIGILL.
      
      If no arguments are specified, then BC1T will not be taken, NOP will not
      be emulated and code will complete successfully.
      
      If one argument is specified, then BC1T will be taken once and NOP will
      be emulated.  At this point the entry PC value will be 0x400498 and the
      new PC value, set by `mips_dsemul' will be 0x4004a0, the target of BC1T.
      The emulation loop will terminate, but SIGILL will not be issued,
      because the PC has changed.  The FPU emulator will be entered again and
      on the second execution BC1T will not be taken, NOP will not be emulated
      and code will complete successfully.
      
      If two or more arguments are specified, then the first execution of BC1T
      will proceed as above.  Upon reentering the FPU emulator the emulation
      loop will continue to BC1T, at which point the branch will be taken and
      NOP emulated again.  At this point however the entry PC value will be
      0x4004a0, the same as the target of BC1T.  This will make the emulator
      conclude that execution has not advanced and therefore an unsupported
      FPU instruction has been encountered, and SIGILL will be sent to the
      process.
      
      Fix the problem by extending the internal API of `mips_dsemul', making
      it return -1 if no delay slot emulation frame has been made, the
      instruction has been handled and execution of the emulation loop needs
      to continue as if nothing happened.  Remove code from `mips_dsemul' to
      reproduce steps made by the emulation loop at the conclusion of each
      iteration, as those will be reached normally now.  Adjust call sites
      accordingly.  Document the API.
      
      Signed-off-by: default avatarMaciej W. Rozycki <macro@imgtec.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/12172/
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      e4553573
    • Huacai Chen's avatar
      MIPS: Fix some missing CONFIG_CPU_MIPSR6 #ifdefs · 4f33f6c5
      Huacai Chen authored
      Commit be0c37c9 (MIPS: Rearrange PTE bits into fixed positions.)
      defines fixed PTE bits for MIPS R2. Then, commit d7b63141
      
      
      (MIPS: pgtable-bits: Fix XPA damage to R6 definitions.) adds the MIPS
      R6 definitions in the same way as MIPS R2. But some R6 #ifdefs in the
      later commit are missing, so in this patch I fix that.
      
      Signed-off-by: default avatarHuacai Chen <chenhc@lemote.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: Steven J. Hill <Steven.Hill@imgtec.com>
      Cc: Fuxin Zhang <zhangfx@lemote.com>
      Cc: Zhangjin Wu <wuzhangjin@gmail.com>
      Cc: linux-mips@linux-mips.org
      Cc: stable@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/12164/
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      4f33f6c5
    • Huacai Chen's avatar
      MIPS: sync-r4k: reduce skew while synchronization · db0dbd57
      Huacai Chen authored
      While synchronization, count register will go backwards for the master.
      If synchronise_count_master() runs before synchronise_count_slave(),
      skew becomes even more. The skew is very harmful for CPU hotplug (CPU0
      do synchronization with CPU1, then CPU0 do synchronization with CPU2
      and CPU0's count goes backwards, so it will be out of sync with CPU1).
      
      After the commit cf9bfe55
      
       (MIPS: Synchronize MIPS count one
      CPU at a time), we needn't evaluate count_reference at the beginning of
      synchronise_count_master() any more. Thus, we evaluate the initcount (It
      seems like count_reference is redundant) in the 2nd loop. Since we write
      the count register in the last loop, we don't need additional barriers
      (the existing memory barriers are enough).
      
      Moreover, I think we loop 3 times is enough to get a primed instruction
      cache, this can also get less skew than looping 5 times.
      
      Comments are also updated in this patch.
      
      Signed-off-by: default avatarHuacai Chen <chenhc@lemote.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: Steven J. Hill <Steven.Hill@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: Fuxin Zhang <zhangfx@lemote.com>
      Cc: Zhangjin Wu <wuzhangjin@gmail.com>
      Patchwork: https://patchwork.linux-mips.org/patch/12163/
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      db0dbd57
  2. Jan 22, 2016
    • Huacai Chen's avatar
      MIPS: hpet: Choose a safe value for the ETIME check · 5610b125
      Huacai Chen authored
      
      
      This patch is borrowed from x86 hpet driver and explaind below:
      
      Due to the overly intelligent design of HPETs, we need to workaround
      the problem that the compare value which we write is already behind
      the actual counter value at the point where the value hits the real
      compare register. This happens for two reasons:
      
      1) We read out the counter, add the delta and write the result to the
         compare register. When a NMI hits between the read out and the write
         then the counter can be ahead of the event already.
      
      2) The write to the compare register is delayed by up to two HPET
         cycles in AMD chipsets.
      
      We can work around this by reading back the compare register to make
      sure that the written value has hit the hardware. But that is bad
      performance wise for the normal case where the event is far enough in
      the future.
      
      As we already know that the write can be delayed by up to two cycles
      we can avoid the read back of the compare register completely if we
      make the decision whether the delta has elapsed already or not based
      on the following calculation:
      
        cmp = event - actual_count;
      
      If cmp is less than 64 HPET clock cycles, then we decide that the event
      has happened already and return -ETIME. That covers the above #1 and #2
      problems which would cause a wait for HPET wraparound (~306 seconds).
      
      Signed-off-by: default avatarHuacai Chen <chenhc@lemote.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: Steven J. Hill <Steven.Hill@imgtec.com>
      Cc: Fuxin Zhang <zhangfx@lemote.com>
      Cc: Zhangjin Wu <wuzhangjin@gmail.com>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: linux-mips@linux-mips.org
      Cc: stable@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/12162/
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      5610b125
    • Huacai Chen's avatar
      MIPS: Loongson-3: Fix SMP_ASK_C0COUNT IPI handler · 57548432
      Huacai Chen authored
      
      
      When Core-0 handle SMP_ASK_C0COUNT IPI, we should make other cores to
      see the result as soon as possible (especially when Store-Fill-Buffer
      is enabled). Otherwise, C0_Count syncronization makes no sense.
      
      BTW, array is more suitable than per-cpu variable for syncronization,
      and there is a corner case should be avoid: C0_Count of Core-0 can be
      really 0.
      
      Signed-off-by: default avatarHuacai Chen <chenhc@lemote.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: Steven J. Hill <Steven.Hill@imgtec.com>
      Cc: Fuxin Zhang <zhangfx@lemote.com>
      Cc: Zhangjin Wu <wuzhangjin@gmail.com>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: linux-mips@linux-mips.org
      Cc: <stable@vger.kernel.org>
      Patchwork: https://patchwork.linux-mips.org/patch/12160/
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      57548432
    • Huacai Chen's avatar
      MIPS: Loongson-3: Improve -march option and move it to Platform · 5188129b
      Huacai Chen authored
      
      
      If GCC >= 4.9 and Binutils >=2.25, we use -march=loongson3a, otherwise
      we use -march=mips64r2, this can slightly improve performance. Besides,
      arch/mips/loongson64/Platform is a better location rather than arch/
      mips/Makefile.
      
      Signed-off-by: default avatarHuacai Chen <chenhc@lemote.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: Steven J. Hill <Steven.Hill@imgtec.com>
      Cc: Fuxin Zhang <zhangfx@lemote.com>
      Cc: Zhangjin Wu <wuzhangjin@gmail.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/12161/
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      5188129b
    • Huacai Chen's avatar
      MIPS: Cleanup the unused __arch_local_irq_restore() function · 6e526844
      Huacai Chen authored
      
      
      In history, __arch_local_irq_restore() is only used by SMTC. However,
      SMTC support has been removed since 3.16, this patch remove the unused
      function.
      
      Signed-off-by: default avatarHuacai Chen <chenhc@lemote.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: Steven J. Hill <Steven.Hill@imgtec.com>
      Cc: Fuxin Zhang <zhangfx@lemote.com>
      Cc: Zhangjin Wu <wuzhangjin@gmail.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/12159/
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      6e526844
  3. Jan 20, 2016
  4. Jan 04, 2016
    • Alex Smith's avatar
      MIPS: dts: jz4780/ci20: Add NEMC, BCH and NAND device tree nodes · 78800558
      Alex Smith authored
      
      
      Add device tree nodes for the NEMC and BCH to the JZ4780 device tree,
      and make use of them in the Ci20 device tree to add a node for the
      board's NAND.
      
      Note that since the pinctrl driver is not yet upstream, this includes
      neither pin configuration nor busy/write-protect GPIO pins for the
      NAND. Use of the NAND relies on the boot loader to have left the pins
      configured in a usable state, which should be the case when booted
      from the NAND.
      
      [ralf@linux-mips.org: fold in Geert Uytterhoeven's patch and acks from
      Harvey's latest version.]
      
      Signed-off-by: default avatarAlex Smith <alex.smith@imgtec.com>
      Signed-off-by: default avatarHarvey Hunt <harvey.hunt@imgtec.com>
      Reviewed-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
      Cc: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Brian Norris <computersforpeace@gmail.com>
      Cc: Paul Burton <paul.burton@imgtec.com>
      Cc: Alex Smith <alex.smith@imgtec.com>
      Cc: linux-mtd@lists.infradead.org
      Cc: devicetree@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-mips@linux-mips.org
      Cc: linux-mtd@lists.infradead.org
      Patchwork: https://patchwork.linux-mips.org/patch/11695/
      Patchwork: https://patchwork.linux-mips.org/patch/11914/
      Patchwork: https://patchwork.linux-mips.org/patch/11985/
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      78800558
    • Simon Arlott's avatar
      MIPS: bmips: Support SMP on BCM63168 · 16580796
      Simon Arlott authored
      
      
      The BCM63168 requires the same CPU1 fix as BCM6368.
      
      Signed-off-by: default avatarSimon Arlott <simon@fire.lp0.eu>
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: linux-mips@linux-mips.org
      Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
      Patchwork: https://patchwork.linux-mips.org/patch/11487/
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      16580796
    • Alban Bedel's avatar
      MIPS: ath79: Remove some unused code from setup.c · fe8766dd
      Alban Bedel authored
      
      
      Remove the unused defines for the reference clocks rate
      and the useless machine init function.
      
      Signed-off-by: default avatarAlban Bedel <albeu@free.fr>
      Cc: Felix Fietkau <nbd@openwrt.org>
      Cc: Qais Yousef <qais.yousef@imgtec.com>
      Cc: Andrew Bresticker <abrestic@chromium.org>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/11505/
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      fe8766dd
    • Alban Bedel's avatar
      MIPS: ath79: Allow using ath79_ddr_wb_flush() from drivers · c166fe78
      Alban Bedel authored
      
      
      Move the declaration of ath79_ddr_wb_flush() to asm/mach-ath79/ath79.h
      to allow using it from drivers. This is needed to move the CPU IRQ
      driver to drivers/irqchip.
      
      Signed-off-by: default avatarAlban Bedel <albeu@free.fr>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Jason Cooper <jason@lakedaemon.net>
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Cc: Alexander Couzens <lynxis@fe80.eu>
      Cc: Joel Porquet <joel@porquet.org>
      Cc: Andrew Bresticker <abrestic@chromium.org>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/11502/
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      c166fe78
    • Alban Bedel's avatar
      MIPS: ath79: Prepare moving the MISC driver to drivers/irqchip · f9a3e047
      Alban Bedel authored
      
      
      To prepare moving out of the arch directory rework the MISC
      implementation to use irq domains instead of hard coded IRQ numbers.
      Also remove the uses of the ath79_reset_base global pointer in the IRQ
      methods.
      
      Signed-off-by: default avatarAlban Bedel <albeu@free.fr>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Jason Cooper <jason@lakedaemon.net>
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Cc: Alexander Couzens <lynxis@fe80.eu>
      Cc: Joel Porquet <joel@porquet.org>
      Cc: Andrew Bresticker <abrestic@chromium.org>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/11506/
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      f9a3e047
    • Alban Bedel's avatar
      MIPS: ath79: Remove useless #ifdef CONFIG_IRQCHIP · a797a0cf
      Alban Bedel authored
      
      
      IRQCHIP is always enabled, so the #ifdef can just be removed.
      
      Signed-off-by: default avatarAlban Bedel <albeu@free.fr>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Jason Cooper <jason@lakedaemon.net>
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Cc: Alexander Couzens <lynxis@fe80.eu>
      Cc: Joel Porquet <joel@porquet.org>
      Cc: Andrew Bresticker <abrestic@chromium.org>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/11504/
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      a797a0cf
    • Alban Bedel's avatar
      MIPS: ath79: Enable the USB port on the TL-WR1043ND · 76654c7b
      Alban Bedel authored
      
      
      Signed-off-by: default avatarAlban Bedel <albeu@free.fr>
      Cc: linux-mips@linux-mips.org
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: Pawel Moll <pawel.moll@arm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Ian Campbell <ijc+devicetree@hellion.org.uk>
      Cc: Kumar Gala <galak@codeaurora.org>
      Cc: Kishon Vijay Abraham I <kishon@ti.com>
      Cc: devicetree@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/11499/
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      76654c7b