1. 12 May, 2020 2 commits
  2. 11 May, 2020 1 commit
  3. 09 May, 2020 3 commits
  4. 08 May, 2020 3 commits
    • Gustavo A. R. Silva's avatar
      MIPS: Replace zero-length array with flexible-array · c4ad6ea9
      Gustavo A. R. Silva authored
      The current codebase makes use of the zero-length array language
      extension to the C90 standard, but the preferred mechanism to declare
      variable-length types such as these ones is a flexible array member[1][2],
      introduced in C99:
      
      struct foo {
              int stuff;
              struct boo array[];
      };
      
      By making use of the mechanism above, we will get a compiler warning
      in case the flexible array does not occur last in the structure, which
      will help us prevent some kind of undefined behavior bugs from being
      inadvertently introduced[3] to the codebase from now on.
      
      Also, notice that, dynamic memory allocations won't be affected by
      this change:
      
      "Flexible array members have incomplete type, and so the sizeof operator
      may not be applied. As a quirk of the original implementation of
      zero-length arrays, sizeof evaluates to zero."[1]
      
      sizeof(flexible-array-member) triggers a warning because flexible array
      members have incomplete type[1]. There are some instances of code in
      which the sizeof operator is being incorrectly/erroneously applied to
      zero-length arrays and the result is zero. Such instances may be hiding
      some bugs. So, this work (flexible-array member conversions) will also
      help to get completely rid of those sorts of issues.
      
      This issue was found with the help of Coccinelle.
      
      [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
      [2] https://github.com/KSPP/linux/issues/21
      [3] commit 76497732 ("cxgb3/l2t: Fix undefined behaviour")
      Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      c4ad6ea9
    • Tiezhu Yang's avatar
      MIPS: Loongson: Add DMA support for LS7A · 68fbb972
      Tiezhu Yang authored
      In the current market, the most used bridge chip on the Loongson platform
      are RS780E and LS7A, the RS780E bridge chip is already supported by the
      mainline kernel.
      
      If use the default implementation of __phys_to_dma() and __dma_to_phys()
      in dma-direct.h when CONFIG_ARCH_HAS_PHYS_TO_DMA is not set, it works
      well used with LS7A on the Loongson single-way and multi-way platform,
      and also works well used with RS780E on the Loongson single-way platform,
      but the DMA address will be wrong on the non-node0 used with RS780E on
      the Loongson multi-way platform.
      
      Just as the description in the code comment, the devices get node id from
      40 bit of HyperTransport bus, so we extract 2 bit node id (bit 44~45) from
      48 bit address space of Loongson CPU and embed it into HyperTransport bus
      (bit 37-38), this operation can be done only at the software level used
      with RS780E on the Loongson multi-way platform, because it has no hardware
      function to translate address of node id, this is a hardware compatibility
      problem.
      
      Device
          |
          | DMA address
          |
      Host Bridge
          |
          | HT bus address (40 bit)
          |
         CPU
          |
          | physical address (48 bit)
          |
         RAM
      
      The LS7A has dma_node_id_offset field in the DMA route config register,
      the hardware can use the dma_node_id_offset to translate address of
      node id automatically, so we can get correct address when just use the
      dma_pfn_offset field in struct device.
      
      For the above reasons, in order to maintain downward compatibility
      to support the RS780E bridge chip, it is better to use the platform
      dependent implementation of __phys_to_dma() and __dma_to_phys().
      Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      68fbb972
    • Huacai Chen's avatar
      MIPS: inst.h: Stop including asm.h to avoid various build failures · e701656e
      Huacai Chen authored
      Commit d339cd02 ("MIPS: Move unaligned load/store helpers to
      inst.h") causes a lot of build failures because macros in asm.h conflict
      with various subsystems. Some of these conflictions has been fixed (such
      as LONG, PANIC and PRINT) by adjusting asm.h, but some of them is nearly
      impossible to fix (such as PTR and END). The only reason of including
      asm.h in inst.h is that we need the PTR macro which is used by unaligned
      load/store helpers. So in this patch we define a new PTR_STR macro and
      use it to replace STR(PTR), then we can stop including asm.h to avoid
      various build failures.
      
      Fixes: d339cd02 ("MIPS: Move unaligned load/store helpers to inst.h")
      Reported-by: default avatarkbuild test robot <lkp@intel.com>
      Signed-off-by: default avatarHuacai Chen <chenhc@lemote.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      e701656e
  5. 07 May, 2020 9 commits
  6. 04 May, 2020 1 commit
  7. 02 May, 2020 3 commits
  8. 30 Apr, 2020 3 commits
  9. 29 Apr, 2020 9 commits
  10. 28 Apr, 2020 2 commits
  11. 26 Apr, 2020 3 commits
    • Jiaxun Yang's avatar
      MIPS: Kernel: Identify Loongson-2K processors · 0cf2ea11
      Jiaxun Yang authored
      Loongson-2K (Loongson64 Reduced) is a family of SoC shipped with
      gs264e core.
      Signed-off-by: default avatarJiaxun Yang <jiaxun.yang@flygoat.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      0cf2ea11
    • Tiezhu Yang's avatar
      MIPS: Loongson: Add support for perf tool · e2e13925
      Tiezhu Yang authored
      In order to use perf tool on the Loongson platform, we should enable kernel
      support for various performance events provided by software and hardware,
      so add CONFIG_PERF_EVENTS=y to loongson3_defconfig.
      
      E.g. without this patch:
      
      [loongson@localhost perf]$ ./perf list
      
      List of pre-defined events (to be used in -e):
      
        duration_time                                      [Tool event]
      
        rNNN                                               [Raw hardware event descriptor]
        cpu/t1=v1[,t2=v2,t3 ...]/modifier                  [Raw hardware event descriptor]
         (see 'man perf-list' on how to encode it)
      
        mem:<addr>[/len][:access]                          [Hardware breakpoint]
      
      With this patch:
      
      [loongson@localhost perf]$ ./perf list
      
      List of pre-defined events (to be used in -e):
      
        branch-instructions OR branches                    [Hardware event]
        branch-misses                                      [Hardware event]
        cpu-cycles OR cycles                               [Hardware event]
        instructions                                       [Hardware event]
      
        alignment-faults                                   [Software event]
        bpf-output                                         [Software event]
        context-switches OR cs                             [Software event]
        cpu-clock                                          [Software event]
        cpu-migrations OR migrations                       [Software event]
        dummy                                              [Software event]
        emulation-faults                                   [Software event]
        major-faults                                       [Software event]
        minor-faults                                       [Software event]
        page-faults OR faults                              [Software event]
        task-clock                                         [Software event]
      
        duration_time                                      [Tool event]
      
        L1-dcache-load-misses                              [Hardware cache event]
        L1-dcache-store-misses                             [Hardware cache event]
        L1-icache-load-misses                              [Hardware cache event]
        branch-load-misses                                 [Hardware cache event]
        branch-loads                                       [Hardware cache event]
        dTLB-load-misses                                   [Hardware cache event]
        dTLB-store-misses                                  [Hardware cache event]
        iTLB-load-misses                                   [Hardware cache event]
      
        rNNN                                               [Raw hardware event descriptor]
        cpu/t1=v1[,t2=v2,t3 ...]/modifier                  [Raw hardware event descriptor]
         (see 'man perf-list' on how to encode it)
      
        mem:<addr>[/len][:access]                          [Hardware breakpoint]
      Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      e2e13925
    • Huacai Chen's avatar
      MIPS: Rename the "Fill" cache ops to avoid build failure · a44f8309
      Huacai Chen authored
      MIPS define a "Fill" macro as a cache operation in cacheops.h, this
      will cause build failure under some special configurations because in
      seq_file.c there is a "Fill" label. To avoid this failure we rename the
      "Fill" macro to "Fill_I" which has the same coding style as other cache
      operations in cacheops.h (we think renaming the "Fill" macro is more
      reasonable than renaming the "Fill" label).
      
      Callers of "Fill" macro is also updated.
      Signed-off-by: default avatarHuacai Chen <chenhc@lemote.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      a44f8309
  12. 24 Apr, 2020 1 commit