1. 24 Jun, 2018 40 commits
    • Rickard Strandqvist's avatar
      arch: mips: mm: page: Remove unused function · 829caee7
      Rickard Strandqvist authored
      Remove the function sb1_dma_init() that is not used anywhere.
      
      This was partially found by using a static code analysis program called cppcheck.
      Signed-off-by: default avatarRickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
      Patchwork: https://patchwork.linux-mips.org/patch/8873/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: John Crispin <blogic@openwrt.org>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      829caee7
    • Rickard Strandqvist's avatar
      arch: mips: pci: pci-ip27.c: Remove unused function · ff404a93
      Rickard Strandqvist authored
      Remove the function pci_enable_swapping() that is not used anywhere.
      
      This was partially found by using a static code analysis program called cppcheck.
      Signed-off-by: default avatarRickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
      Patchwork: https://patchwork.linux-mips.org/patch/8867/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: John Crispin <blogic@openwrt.org>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      ff404a93
    • Paul Burton's avatar
      MIPS: Malta: Use PIIX4 poweroff driver to power down · dd129c63
      Paul Burton authored
      Remove the platform code used to power down the system, instead relying
      upon the new PIIX4 poweroff driver. This reduces the amount of platform
      code required for the Malta board in preparation for allowing it to be
      part of a more generic kernel.
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Patchwork: https://patchwork.linux-mips.org/patch/14282/
      dd129c63
    • Paul Burton's avatar
      MIPS: Malta: Cleanup DMA coherence #ifdefs · a07539c0
      Paul Burton authored
      DMA coherence is not user-selectable in Kconfig, and Malta selects
      CONFIG_DMA_MAYBE_COHERENT which in turn selects CONFIG_DMA_NONCOHERENT.
      Remove #ifdefs whose conditions can therefore never be true for Malta.
      
      This removes a significant amount of code from bonito_quirks_setup(),
      but the code is duplicated in plat_enable_iocoherency() anyway so we
      lose nothing but duplication.
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Patchwork: https://patchwork.linux-mips.org/patch/14188/
      a07539c0
    • Paul Burton's avatar
      MIPS: Set MIPS_IC_SNOOPS_REMOTE for systems with CM · d1c5872c
      Paul Burton authored
      In systems that include a MIPS Coherency Manager, the icache always
      fills from a cache which is coherent across all CPUs. In I6400 & I6500
      systems the icache fills from the dcache which is coherent across all
      CPUs. In all other CM-based systems the icache fills from the L2 cache
      which is shared between all cores.
      
      This means that an icache will always see stores from remote CPUs
      without needing to write them back any further than that L2, which is
      what the cpu_icache_snoops_remote_store feature is used to test. In
      order for it to return 1 without needing a per-platform override (which
      is what Malta has relied upon so far) set the MIPS_IC_SNOOPS_REMOTE flag
      when a CM is present.
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/16200/
      d1c5872c
    • Joshua Kinard's avatar
      MIPS: Use !pci_is_root_bus(bus) in ops-bridge.c · 8fd2d6ea
      Joshua Kinard authored
      This is a manual cherrypick of commit c7ddc3d137b7 from Alastair
      Bridgewater's IP35 tree that replaces two cases of
      "if (bus->number > 0)" with a more correct "if (!pci_is_root_bus(bus))"
      in arch/mips/pci/ops-bridge.c.
      
      Cc: linux-mips@linux-mips.org
      Cc: Alastair Bridgewater <alastair.bridgewater@gmail.com>
      Suggested-by: default avatarAlastair Bridgewater <alastair.bridgewater@gmail.com>
      Signed-off-by: default avatarJoshua Kinard <kumba@gentoo.org>
      Patchwork: https://patchwork.linux-mips.org/patch/17501/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Linux/MIPS <linux-mips@linux-mips.org>
      8fd2d6ea
    • Paul Burton's avatar
      MIPS: Schedule on CPUs we need to lose FPU for a mode switch · 8c8d953c
      Paul Burton authored
      Commit 6b832257 ("MIPS: Force CPUs to lose FP context during mode
      switches") ensures that we react to PR_SET_FP_MODE prctl syscalls
      quickly by broadcasting an IPI in order to cause CPUs to lose FPU access
      when necessary. Whilst it achieves that, unfortunately it causes all
      sorts of strange race conditions because:
      
       1) The IPI may arrive at a point where the FPU is in the process of
          being enabled, but that process is not yet complete leading to a
          state we aren't prepared to handle. For example:
      
          [  370.215903] do_cpu invoked from kernel context![#1]:
          [  370.221064] CPU: 0 PID: 963 Comm: fp-prctl Not tainted 4.9.0-rc5-00323-g210db32-dirty #226
          [  370.229420] task: a8000000fd672e00 task.stack: a8000000fd630000
          [  370.235399] $ 0   : 0000000000000000 0000000000000001 0000000000000001 a8000000fd630000
          [  370.243882] $ 4   : a8000000fd672e00 0000000000000000 0000000000000453 0000000000000000
          [  370.252317] $ 8   : 0000000000000000 a8000000fd637c28 1000000000000000 0000000000000010
          [  370.260753] $12   : 00000000140084e0 ffffffff80109c00 0000000000000000 0000000000000002
          [  370.269179] $16   : ffffffff8092f080 a8000000fd672e00 ffffffff80107fe8 a8000000fd485000
          [  370.277612] $20   : ffffffff8084d328 ffffffff80940000 0000000000000009 ffffffff80930000
          [  370.286038] $24   : 0000000000000000 900000001612048c
          [  370.294476] $28   : a8000000fd630000 a8000000fd637ac0 ffffffff80937300 ffffffff8010807c
          [  370.302909] Hi    : 0000000000000000
          [  370.306595] Lo    : 0000000000000200
          [  370.310376] epc   : ffffffff80115d38 _save_fp+0x10/0xa0
          [  370.315784] ra    : ffffffff8010807c prepare_for_fp_mode_switch+0x94/0x1b0
          [  370.322707] Status: 140084e2 KX SX UX KERNEL EXL
          [  370.327980] Cause : 1080002c (ExcCode 0b)
          [  370.332091] PrId  : 0001a428 (MIPS P6600)
          [  370.336179] Modules linked in:
          [  370.339486] Process fp-prctl (pid: 963, threadinfo=a8000000fd630000, task=a8000000fd672e00, tls=00000000756e67d0)
          [  370.349724] Stack : 0000000000000000 a8000000fd557dc0 0000000000000000 ffffffff801ca8e0
          [  370.358161]         0000000000000000 a8000000fd637b9c 0000000000000009 ffffffff80923780
          [  370.366575]         ffffffff80850000 ffffffff8011610c 00000000000000b8 ffffffff801a5084
          [  370.374989]         ffffffff8084a370 ffffffff8084a388 ffffffff80923780 ffffffff80923828
          [  370.383395]         0000000000010000 ffffffff809237a8 0000000000020000 ffffffff80a40000
          [  370.391817]         000000000000007c 00000000004a0000 00000000756dedd0 ffffffff801a5188
          [  370.400230]         a800000002014900 0000000000000001 ffffffff80923780 0000000080923828
          [  370.408644]         ffffffff80923780 ffffffff80923780 ffffffff80923828 ffffffff801a521c
          [  370.417066]         ffffffff80923780 ffffffff80923828 0000000000010000 ffffffff801a8f84
          [  370.425472]         ffffffff80a40000 a8000000fd637c20 ffffffff80a39240 0000000000000001
          [  370.433885]         ...
          [  370.436562] Call Trace:
          [  370.439222] [<ffffffff80115d38>] _save_fp+0x10/0xa0
          [  370.444305] [<ffffffff8010807c>] prepare_for_fp_mode_switch+0x94/0x1b0
          [  370.451035] [<ffffffff801ca8e0>] flush_smp_call_function_queue+0xf8/0x230
          [  370.457991] [<ffffffff8011610c>] ipi_call_interrupt+0xc/0x20
          [  370.463814] [<ffffffff801a5084>] __handle_irq_event_percpu+0xc4/0x1a8
          [  370.470404] [<ffffffff801a5188>] handle_irq_event_percpu+0x20/0x68
          [  370.476734] [<ffffffff801a521c>] handle_irq_event+0x4c/0x88
          [  370.482486] [<ffffffff801a8f84>] handle_edge_irq+0x12c/0x210
          [  370.488316] [<ffffffff801a47a0>] generic_handle_irq+0x38/0x48
          [  370.494280] [<ffffffff804a2dbc>] gic_handle_shared_int+0x194/0x268
          [  370.500616] [<ffffffff801a47a0>] generic_handle_irq+0x38/0x48
          [  370.506529] [<ffffffff80107e60>] do_IRQ+0x18/0x28
          [  370.511445] [<ffffffff804a1524>] plat_irq_dispatch+0xc4/0x140
          [  370.517339] [<ffffffff80106230>] ret_from_irq+0x0/0x4
          [  370.522583] [<ffffffff8010fad4>] do_ri+0x4fc/0x7e8
          [  370.527546] [<ffffffff80106220>] ret_from_exception+0x0/0x10
      
       2) The IPI may arrive during kernel use of the FPU, since we generally
          only disable preemption around use of the FPU & leave interrupts
          enabled. This can lead to us unexpectedly losing access to the FPU
          in places where it previously had not been possible. For example:
      
          do_cpu invoked from kernel context![#2]:
          CPU: 2 PID: 7338 Comm: fp-prctl Tainted: G      D         4.7.0-00424-g49b0c82
          #2
          task: 838e4000 ti: 88d38000 task.ti: 88d38000
          $ 0   : 00000000 00000001 ffffffff 88d3fef8
          $ 4   : 838e4000 88d38004 00000000 00000001
          $ 8   : 3400fc01 801f8020 808e9100 24000000
          $12   : dbffffff 807b69d8 807b0000 00000000
          $16   : 00000000 80786150 00400fc4 809c0398
          $20   : 809c0338 0040273c 88d3ff28 808e9d30
          $24   : 808e9d30 00400fb4
          $28   : 88d38000 88d3fe88 00000000 8011a2ac
          Hi    : 0040273c
          Lo    : 88d3ff28
          epc   : 80114178 _restore_fp+0x10/0xa0
          ra    : 8011a2ac mipsr2_decoder+0xd5c/0x1660
          Status: 1400fc03    KERNEL EXL IE
          Cause : 1080002c (ExcCode 0b)
          PrId  : 0001a920 (MIPS I6400)
          Modules linked in:
          Process fp-prctl (pid: 7338, threadinfo=88d38000, task=838e4000, tls=766527d0)
          Stack : 00000000 00000000 00000000 88d3fe98 00000000 00000000 809c0398 809c0338
                808e9100 00000000 88d3ff28 00400fc4 00400fc4 0040273c 7fb69e18 004a0000
                004a0000 004a0000 7664add0 8010de18 00000000 00000000 88d3fef8 88d3ff28
                808e9100 00000000 766527d0 8010e534 000c0000 85755000 8181d580 00000000
                00000000 00000000 004a0000 00000000 766527d0 7fb69e18 004a0000 80105c20
                ...
          Call Trace:
          [<80114178>] _restore_fp+0x10/0xa0
          [<8011a2ac>] mipsr2_decoder+0xd5c/0x1660
          [<8010de18>] do_ri+0x90/0x6b8
          [<80105c20>] ret_from_exception+0x0/0x10
      
      At first glance a simple fix may seem to be to disable interrupts around
      kernel use of the FPU rather than merely preemption, however this would
      introduce further overhead outside of the mode switch path & doesn't
      solve the third problem:
      
       3) The IPI may arrive whilst the kernel is running code that will lead
          to a preempt_disable() call & FPU usage soon. If this happens then
          the IPI will be serviced & we'll proceed to enable an FPU whilst the
          mode switch is in progress, leading to strange & inconsistent
          behaviour.
      
      Further to all of this is a separate but related problem:
      
       4) There are various paths through which we may enable the FPU without
          the user having triggered a coprocessor 1 disabled exception. These
          paths are those in which we emulate instructions & then enable the
          FPU with the expectation that the user might execute an FP
          instruction shortly afterwards. However these paths have not
          previously checked whether an FP mode switch is underway for the
          task, and therefore could enable the FPU whilst such a mode switch
          is in progress leading to strange & inconsistent behaviour for user
          code.
      
      This patch fixes all of the above by taking a step back & re-examining
      our approach to FP mode switches. Up until now we have taken these basic
      steps:
      
       a) Prevent any threads that are part of the affected process from being
          able to obtain ownership of the FPU.
      
       b) Cause any threads that are part of the affected process and already
          have ownership of an FPU to lose it.
      
       c) Set the thread flags for each thread that is part of the affected
          process to reflect the new FP mode.
      
       d) Allow threads to obtain ownership of the FPU again.
      
      This approach is however more complex than necessary. All that we really
      require is that the mode switch has occurred for all threads that are
      part of the affected process before mips_set_process_fp_mode(), and thus
      the PR_SET_FP_MODE prctl() syscall, returns. This doesn't require that
      we stop threads from owning or using an FPU whilst a mode switch occurs,
      only that we force them to relinquish it after the mode switch has
      occurred such that they next own an FPU with the correct mode
      configured. Our basic steps therefore simplify to:
      
       A) Set the thread flags for each thread that is part of the affected
          process to reflect the new FP mode.
      
       B) Cause any threads that are part of the affected process and already
          have ownership of an FPU to lose it.
      
      We implement B) by forcing each CPU which might be running a thread
      which is part of the affected process to schedule a no-op function,
      which causes the affected thread to lose its FPU ownership when it is
      descheduled.
      
      The end result is simpler FP mode switching with less overhead in the
      FPU enable path (ie. enable_restore_fp_context()) and fewer moving
      parts.
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Fixes: 9791554b ("MIPS,prctl: add PR_[GS]ET_FP_MODE prctl options for MIPS")
      Fixes: 6b832257 ("MIPS: Force CPUs to lose FP context during mode switches")
      Cc: James Hogan <jhogan@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Cc: stable <stable@vger.kernel.org> # v4.0+
      8c8d953c
    • Rob Herring's avatar
      MIPS: lantiq: remove unnecessary of_platform_default_populate call · 9667bb03
      Rob Herring authored
      The DT core will call of_platform_default_populate, so it is not necessary
      for arch specific code to call it unless there are custom match entries,
      auxdata or parent device. Neither of those apply here, so remove the call.
      
      Cc: John Crispin <john@phrozen.org>
      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
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
      Patchwork: https://patchwork.linux-mips.org/patch/19592/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: linux-kernel@vger.kernel.org
      9667bb03
    • Rob Herring's avatar
      MIPS: generic: remove unnecessary of_platform_populate call · 6a7ec6c5
      Rob Herring authored
      The DT core will call of_platform_populate, so it is not necessary for
      arch specific code to call it unless there are custom match entries,
      auxdata or parent device. Neither of those apply here, so remove the call.
      
      Cc: Paul Burton <paul.burton@mips.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: linux-mips@linux-mips.org
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
      Patchwork: https://patchwork.linux-mips.org/patch/19591/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: linux-kernel@vger.kernel.org
      6a7ec6c5
    • Rob Herring's avatar
      MIPS: bmips: remove unnecessary call to register "simple-bus" · 0279455f
      Rob Herring authored
      The DT core will register "simple-bus" by default, so it is not necessary
      for arch specific code to do so unless there are custom match entries,
      auxdata or parent device. Neither of those apply here, so remove the call.
      
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: Florian Fainelli <f.fainelli@gmail.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
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
      Patchwork: https://patchwork.linux-mips.org/patch/19590/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: linux-kernel@vger.kernel.org
      0279455f
    • Rob Herring's avatar
      MIPS: netlogic: remove unnecessary of_platform_bus_probe call · 40c911ed
      Rob Herring authored
      The DT core code will probe "simple-bus" by default, so remove
      the Netlogic specific call. The probing of simple-bus happens at
      arch_initcall_sync, so the call being removed here is already a nop.
      
      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
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
      Patchwork: https://patchwork.linux-mips.org/patch/19589/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: linux-kernel@vger.kernel.org
      40c911ed
    • Rob Herring's avatar
      MIPS: octeon: use of_platform_populate to probe devices · f072f9ce
      Rob Herring authored
      of_platform_bus_probe is deprecated in favor of of_platform_populate.
      of_platform_populate is stricter requiring compatible properties for
      matching rather than name or type. Octeon uses compatible strings for
      matching, so convert it to of_platform_populate.
      
      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
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
      Patchwork: https://patchwork.linux-mips.org/patch/19588/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: linux-kernel@vger.kernel.org
      f072f9ce
    • Heiher's avatar
      MIPS: Fix ejtag handler on SMP · c8bf3805
      Heiher authored
      On SMP systems, the shared ejtag debug buffer may be overwritten by
      other cores, because every cores can generate ejtag exception at
      same time.
      
      Unfortunately, in that context, it's difficult to relax more registers
      to access per cpu buffers. so use ll/sc to serialize the access.
      
      [paul.burton@mips.com:
        This could in theory be backported at least as far back as the
        beginning of the git era, however in general it's exceedingly rare
        that anyone would hit this without further changes, so it doesn't seem
        worthwhile marking for backport.]
      Signed-off-by: default avatarHeiher <r@hev.cc>
      Patchwork: https://patchwork.linux-mips.org/patch/19507/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: jhogan@kernel.org
      Cc: ralf@linux-mips.org
      c8bf3805
    • Masahiro Yamada's avatar
      MIPS: boot: merge build rules of vmlinux.*.itb by using pattern rule · be462bd9
      Masahiro Yamada authored
      Merge the build rule of vmlinux.{gz,bz2,lzma,lzo}.itb, and also move
      'targets' close to the related code.
      
      [paul.burton@mips.com:
        - Remove leading tabs from assignments to itb_addr_cells, since after
          this patch moves the additions to the 'targets' variable the
          assignments to itb_addr_cells wound up being treated as part of the
          uImage rule above them, causing the .its to incorrectly be generated
          with empty ADDR_CELLS.]
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Patchwork: https://patchwork.linux-mips.org/patch/19095/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: linux-kernel@vger.kernel.org
      be462bd9
    • Masahiro Yamada's avatar
      MIPS: boot: add missing targets for vmlinux.*.its · 92b34a97
      Masahiro Yamada authored
      The build rule of vmlinux.*.its is invoked by $(call if_changed,...)
      but it always rebuilds the target needlessly due to missing targets.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Patchwork: https://patchwork.linux-mips.org/patch/19092/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: linux-kernel@vger.kernel.org
      92b34a97
    • Masahiro Yamada's avatar
      MIPS: boot: fix build rule of vmlinux.its.S · 67e09db5
      Masahiro Yamada authored
      As Documentation/kbuild/makefile.txt says, it is a typical mistake
      to forget the FORCE prerequisite for the rule invoked by if_changed.
      
      Add the FORCE to the prerequisite, but it must be filtered-out from
      the files passed to the 'cat' command.  Because this rule generates
      .vmlinux.its.S.cmd, vmlinux.its.S must be specified as targets so
      that the .cmd file is included.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Patchwork: https://patchwork.linux-mips.org/patch/19097/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: linux-kernel@vger.kernel.org
      67e09db5
    • Masahiro Yamada's avatar
      MIPS: boot: do not include $(cpp_flags) for preprocessing ITS · 321f95b6
      Masahiro Yamada authored
      $(CPP) is used here to perform macro replacement in ITS.  Do not
      pass $(cpp_flags) because it pulls in more options for dependency
      file generation etc. but none of which is necessary here.  ITS files
      do not include any header file, so $(call if_change,...) is enough.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Patchwork: https://patchwork.linux-mips.org/patch/19093/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: linux-kernel@vger.kernel.org
      321f95b6
    • Masahiro Yamada's avatar
      Revert "MIPS: boot: Define __ASSEMBLY__ for its.S build" · 902b923d
      Masahiro Yamada authored
      This reverts commit 0f9da844.
      
      It is true that commit 0f9da844 ("MIPS: boot: Define __ASSEMBLY__
      for its.S build") fixed the build error, but it should not have
      defined __ASSEMBLY__ just for textual substitution in arbitrary data.
      The file is image tree source in this case, but the purpose of using
      CPP is to replace some macros.
      
      I merged a better solution, commit a95b37e2 ("kbuild: get
      <linux/compiler_types.h> out of <linux/kconfig.h>").  The original
      fix-up is no longer needed.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Patchwork: https://patchwork.linux-mips.org/patch/19096/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: linux-kernel@vger.kernel.org
      902b923d
    • Nicholas Mc Guire's avatar
      MIPS: Octeon: assign bool true/false not 1/0 · 7896de7b
      Nicholas Mc Guire authored
      Booleans should be assigned true/false not 1/0 as comparison is not needed
      Signed-off-by: default avatarNicholas Mc Guire <hofrat@osadl.org>
      Patchwork: https://patchwork.linux-mips.org/patch/19559/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: David Daney <david.daney@cavium.com>
      Cc: "Steven J. Hill" <Steven.Hill@cavium.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: Colin Ian King <colin.king@canonical.com>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      7896de7b
    • Christoph Hellwig's avatar
      MIPS: remove unneeded includes from dma-mapping.h · 803ad26e
      Christoph Hellwig authored
      Keep this file as light as possible as it gets pulled into every
      driver using dma mapping APIs.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Patchwork: https://patchwork.linux-mips.org/patch/19552/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: Tom Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-mips@linux-mips.org
      803ad26e
    • Christoph Hellwig's avatar
      MIPS: remove the old dma-default implementation · 28f512d9
      Christoph Hellwig authored
      Now unused.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Patchwork: https://patchwork.linux-mips.org/patch/19551/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: Tom Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-mips@linux-mips.org
      28f512d9
    • Christoph Hellwig's avatar
      MIPS: bmips: use generic dma noncoherent ops · d59098a0
      Christoph Hellwig authored
      Provide phys_to_dma/dma_to_phys helpers, and the special
      arch_sync_dma_for_cpu_all hook, everything else is generic
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Patchwork: https://patchwork.linux-mips.org/patch/19550/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: Tom Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-mips@linux-mips.org
      d59098a0
    • Christoph Hellwig's avatar
      dma-noncoherent: add a arch_sync_dma_for_cpu_all hook · faef8772
      Christoph Hellwig authored
      The MIPS bmips platform needs a global flush when transferring ownership
      back to the CPU.  Add a hook for that to the dma-noncoherent
      implementation.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Patchwork: https://patchwork.linux-mips.org/patch/19549/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: Tom Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-mips@linux-mips.org
      faef8772
    • Christoph Hellwig's avatar
      MIPS: jazz: split dma mapping operations from dma-default · c5e2bbb4
      Christoph Hellwig authored
      Jazz actually has a very basic IOMMU, so split the ops into a separate
      implementation from the generic default support (which is about to go
      away anyway).
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Patchwork: https://patchwork.linux-mips.org/patch/19548/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: Tom Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-mips@linux-mips.org
      c5e2bbb4
    • Christoph Hellwig's avatar
      MIPS: ath25: use generic dma noncoherent ops · d1f2564a
      Christoph Hellwig authored
      Provide phys_to_dma/dma_to_phys helpers only if PCI support is
      enabled, everything else is generic.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Patchwork: https://patchwork.linux-mips.org/patch/19547/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: Tom Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-mips@linux-mips.org
      d1f2564a
    • Christoph Hellwig's avatar
      MIPS: IP32: use generic dma noncoherent ops · 03df8229
      Christoph Hellwig authored
      Provide phys_to_dma/dma_to_phys helpers, everything else is generic.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Patchwork: https://patchwork.linux-mips.org/patch/19546/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: Tom Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-mips@linux-mips.org
      03df8229
    • Christoph Hellwig's avatar
      MIPS: loongson64: use generic dma noncoherent ops · e905086e
      Christoph Hellwig authored
      Provide phys_to_dma/dma_to_phys helpers, everything else is generic.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Patchwork: https://patchwork.linux-mips.org/patch/19545/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: Tom Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-mips@linux-mips.org
      e905086e
    • Christoph Hellwig's avatar
      MIPS: use generic dma noncoherent ops for simple noncoherent platforms · f8c55dc6
      Christoph Hellwig authored
      Convert everything not overriding dma-coherence.h to the generic
      noncoherent ops.  The new dma-noncoherent.c file duplicates a lot of
      the code in dma-default.c, but that file will be gone by the end of
      this series.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Patchwork: https://patchwork.linux-mips.org/patch/19544/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: Tom Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-mips@linux-mips.org
      f8c55dc6
    • Christoph Hellwig's avatar
      MIPS: move coherentio setup to setup.c · aa4db775
      Christoph Hellwig authored
      We want to be able to use it even when not building dma-default.c
      in the near future.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Patchwork: https://patchwork.linux-mips.org/patch/19543/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: Tom Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-mips@linux-mips.org
      aa4db775
    • Christoph Hellwig's avatar
      MIPS: IP27: use dma_direct_ops · 54aed4dd
      Christoph Hellwig authored
      IP27 is coherent and has a reasonably direct mapping, just with a little
      per-bus offset added into the dma address.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Patchwork: https://patchwork.linux-mips.org/patch/19542/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: Tom Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-mips@linux-mips.org
      54aed4dd
    • Christoph Hellwig's avatar
      MIPS: use dma_direct_ops for coherent I/O · dffbfde7
      Christoph Hellwig authored
      Switch the simple cache coherent architectures that don't require any
      DMA address translation to dma_direct_ops.
      
      We'll soon use at least parts of the direct DMA ops implementation for
      all platforms, so select the symbol globally.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Patchwork: https://patchwork.linux-mips.org/patch/19540/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: Tom Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-mips@linux-mips.org
      dffbfde7
    • Christoph Hellwig's avatar
      MIPS: loongson: remove loongson-3 handling from dma-coherence.h · d7e64bf9
      Christoph Hellwig authored
      Loongson3 is dma coherent and uses swiotlb, so it will never used any
      of these helpers.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Patchwork: https://patchwork.linux-mips.org/patch/19541/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: Tom Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-mips@linux-mips.org
      d7e64bf9
    • Christoph Hellwig's avatar
      MIPS: loongson: untangle dma implementations · d3bc81be
      Christoph Hellwig authored
      Only loongson-3 is DMA coherent and uses swiotlb.  So move the dma
      address translations stubs directly to the loongson-3 code, and remove
      a few Kconfig indirections.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Patchwork: https://patchwork.linux-mips.org/patch/19539/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: Tom Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-mips@linux-mips.org
      d3bc81be
    • Christoph Hellwig's avatar
      MIPS: Octeon: move swiotlb declarations out of dma-coherence.h · a330a9c5
      Christoph Hellwig authored
      No need to pull them into a global header.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Patchwork: https://patchwork.linux-mips.org/patch/19538/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: Tom Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-mips@linux-mips.org
      a330a9c5
    • Christoph Hellwig's avatar
      MIPS: Octeon: remove mips dma-default stubs · 1f99e4b1
      Christoph Hellwig authored
      Octeon doesn't use the dma-default code, and now doesn't built it either,
      so these stubs can be removed.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Patchwork: https://patchwork.linux-mips.org/patch/19537/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: Tom Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-mips@linux-mips.org
      1f99e4b1
    • Christoph Hellwig's avatar
      MIPS: make the default mips dma implementation optional · 3369ddb6
      Christoph Hellwig authored
      Octeon and loonson64 already don't use it at all, and we're going to
      migrate more plaforms away from it.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Patchwork: https://patchwork.linux-mips.org/patch/19536/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: Tom Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-mips@linux-mips.org
      3369ddb6
    • Christoph Hellwig's avatar
      MIPS: remove the mips_dma_map_ops indirection · d3b83dcc
      Christoph Hellwig authored
      And use mips_default_dma_map_ops directly.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Patchwork: https://patchwork.linux-mips.org/patch/19535/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: Tom Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-mips@linux-mips.org
      d3b83dcc
    • Christoph Hellwig's avatar
      MIPS: consolidate the swiotlb implementations · f6d302e3
      Christoph Hellwig authored
      Octeon and Loongson share exactly the same code, move it into a common
      implementation, and use that implementation directly from get_arch_dma_ops.
      
      Also provide the expected dma-direct.h helpers directly instead of
      delegating to platform dma-coherence.h headers.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Patchwork: https://patchwork.linux-mips.org/patch/19534/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: Tom Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-mips@linux-mips.org
      f6d302e3
    • Christoph Hellwig's avatar
      MIPS: loongson: remove loongson_dma_supported · e799de3e
      Christoph Hellwig authored
      swiotlb_dma_supported will always return true for a mask large enough to
      cover the DMA addresses for all physical memory, which is the right
      thing to do for swiotlb based dma ops.  This function returned false
      if the mask was bigger than a firmware set dma_mask_bits that apparently
      can be either 32 or 64, and which seems completely buggys if it actually
      is not 64, as the false return negates the whole point of swiotlb.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Patchwork: https://patchwork.linux-mips.org/patch/19533/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: Tom Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-mips@linux-mips.org
      e799de3e
    • Christoph Hellwig's avatar
      MIPS: Octeon: refactor swiotlb code · 97f9f976
      Christoph Hellwig authored
      Share a common set of swiotlb operations, and to instead branch out in
      __phys_to_dma/__dma_to_phys for the PCI vs non-PCI case.  Also use const
      structures for the PCI methods so that attackers can't use them as
      exploit vectors.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Patchwork: https://patchwork.linux-mips.org/patch/19532/Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: David Daney <david.daney@cavium.com>
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: Tom Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-mips@linux-mips.org
      97f9f976