1. 30 8月, 2019 13 次提交
  2. 31 5月, 2019 1 次提交
  3. 26 4月, 2019 1 次提交
    • W
      iommu/mediatek: Fix leaked of_node references · 1eb8e4e2
      Wen Yang 提交于
      The call to of_parse_phandle returns a node pointer with refcount
      incremented thus it must be explicitly decremented after the last
      usage.
      
      581 static int mtk_iommu_probe(struct platform_device *pdev)
      582 {
          ...
      626         for (i = 0; i < larb_nr; i++) {
      627                 struct device_node *larbnode;
          ...
      631                 larbnode = of_parse_phandle(...);
      632                 if (!larbnode)
      633                         return -EINVAL;
      634
      635                 if (!of_device_is_available(larbnode))
      636                         continue;             ---> leaked here
      637
          ...
      643                 if (!plarbdev)
      644                         return -EPROBE_DEFER; ---> leaked here
          ...
      647                 component_match_add_release(dev, &match, release_of,
      648                                             compare_of, larbnode);
                                         ---> release_of will call of_node_put
      649         }
          ...
      650
      
      Detected by coccinelle with the following warnings:
      ./drivers/iommu/mtk_iommu.c:644:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 631, but without a corresponding object release within this function.
      Signed-off-by: NWen Yang <wen.yang99@zte.com.cn>
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Matthias Brugger <matthias.bgg@gmail.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-mediatek@lists.infradead.org
      Cc: linux-kernel@vger.kernel.org
      Reviewed-by: NMatthias Brugger <mbrugger@suse.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      1eb8e4e2
  4. 17 12月, 2018 1 次提交
  5. 06 11月, 2018 1 次提交
  6. 31 10月, 2018 1 次提交
  7. 08 8月, 2018 1 次提交
  8. 21 3月, 2018 1 次提交
    • Y
      iommu/mediatek: Fix protect memory setting · 70ca608b
      Yong Wu 提交于
      In MediaTek's IOMMU design, When a iommu translation fault occurs
      (HW can NOT translate the destination address to a valid physical
      address), the IOMMU HW output the dirty data into a special memory
      to avoid corrupting the main memory, this is called "protect memory".
      the register(0x114) for protect memory is a little different between
      mt8173 and mt2712.
      
      In the mt8173, bit[30:6] in the register represents [31:7] of the
      physical address. In the 4GB mode, the register bit[31] should be 1.
      While in the mt2712, the bits don't shift. bit[31:7] in the register
      represents [31:7] in the physical address, and bit[1:0] in the
      register represents bit[33:32] of the physical address if it has.
      
      Fixes: e6dec923 ("iommu/mediatek: Add mt2712 IOMMU support")
      Reported-by: NHonghui Zhang <honghui.zhang@mediatek.com>
      Signed-off-by: NYong Wu <yong.wu@mediatek.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      70ca608b
  9. 02 10月, 2017 1 次提交
    • R
      iommu/io-pgtable-arm-v7s: Convert to IOMMU API TLB sync · 4d689b61
      Robin Murphy 提交于
      Now that the core API issues its own post-unmap TLB sync call, push that
      operation out from the io-pgtable-arm-v7s internals into the users. For
      now, we leave the invalidation implicit in the unmap operation, since
      none of the current users would benefit much from any change to that.
      
      Note that the conversion of msm_iommu is implicit, since that apparently
      has no specific TLB sync operation anyway.
      
      CC: Yong Wu <yong.wu@mediatek.com>
      CC: Rob Clark <robdclark@gmail.com>
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      4d689b61
  10. 27 9月, 2017 1 次提交
    • Y
      iommu/mediatek: Limit the physical address in 32bit for v7s · 1ff9b17c
      Yong Wu 提交于
      The ARM short descriptor has already limited the physical address
      to 32bit after the commit <76557391> ("iommu/io-pgtable: Sanitise
      map/unmap addresses"). But in MediaTek 4GB mode, the physical address
      is from 0x1_0000_0000 to 0x1_ffff_ffff. this will cause:
      
      WARNING: CPU: 4 PID: 3900 at
      xxx/drivers/iommu/io-pgtable-arm-v7s.c:482 arm_v7s_map+0x40/0xf8
      Modules linked in:
      
      CPU: 4 PID: 3900 Comm: weston Tainted: G S      W       4.9.44 #1
      Hardware name: MediaTek MT2712m1v1 board (DT)
      task: ffffffc0eaa5b280 task.stack: ffffffc0e9858000
      PC is at arm_v7s_map+0x40/0xf8
      LR is at mtk_iommu_map+0x64/0x90
      pc : [<ffffff80085b09e8>] lr : [<ffffff80085b29fc>] pstate: 000001c5
      sp : ffffffc0e985b920
      x29: ffffffc0e985b920 x28: 0000000127d00000
      x27: 0000000000100000 x26: ffffff8008f9e000
      x25: 0000000000000003 x24: 0000000000100000
      x23: 0000000127d00000 x22: 00000000ff800000
      x21: ffffffc0f7ec8ce0 x20: 0000000000000003
      x19: 0000000000000003 x18: 0000000000000002
      x17: 0000007f7e5d72c0 x16: ffffff80082b0f08
      x15: 0000000000000001 x14: 000000000000003f
      x13: 0000000000000000 x12: 0000000000000028
      x11: 0088000000000000 x10: 0000000000000000
      x9 : ffffff80092fa000 x8 : ffffffc0e9858000
      x7 : ffffff80085b29d8 x6 : 0000000000000000
      x5 : ffffff80085b09a8 x4 : 0000000000000003
      x3 : 0000000000100000 x2 : 0000000127d00000
      x1 : 00000000ff800000 x0 : 0000000000000001
      ...
      Call trace:
      [<ffffff80085b09e8>] arm_v7s_map+0x40/0xf8
      [<ffffff80085b29fc>] mtk_iommu_map+0x64/0x90
      [<ffffff80085ab5f8>] iommu_map+0x100/0x3a0
      [<ffffff80085ab99c>] default_iommu_map_sg+0x104/0x168
      [<ffffff80085aead8>] iommu_dma_alloc+0x238/0x3f8
      [<ffffff8008098b30>] __iommu_alloc_attrs+0xa8/0x260
      [<ffffff80085f364c>] mtk_drm_gem_create+0xac/0x180
      [<ffffff80085f3894>] mtk_drm_gem_dumb_create+0x54/0xc8
      [<ffffff80085d576c>] drm_mode_create_dumb_ioctl+0xa4/0xd8
      [<ffffff80085cb2a0>] drm_ioctl+0x1c0/0x490
      
      In order to satify this, Limit the physical address to 32bit.
      Signed-off-by: NYong Wu <yong.wu@mediatek.com>
      Acked-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      1ff9b17c
  11. 28 8月, 2017 2 次提交
    • Y
      iommu/mediatek: Fix a build warning of BIT(32) in ARM · 41939980
      Yong Wu 提交于
      The commit ("iommu/mediatek: Enlarge the validate PA range
      for 4GB mode") introduce the following build warning while ARCH=arm:
      
         drivers/iommu/mtk_iommu.c: In function 'mtk_iommu_iova_to_phys':
         include/linux/bitops.h:6:24: warning: left shift count >= width
      of type [-Wshift-count-overflow]
          #define BIT(nr)   (1UL << (nr))
                                 ^
      >> drivers/iommu/mtk_iommu.c:407:9: note: in expansion of macro 'BIT'
            pa |= BIT(32);
      
        drivers/iommu/mtk_iommu.c: In function 'mtk_iommu_probe':
         include/linux/bitops.h:6:24: warning: left shift count >= width
      of type [-Wshift-count-overflow]
          #define BIT(nr)   (1UL << (nr))
                                 ^
         drivers/iommu/mtk_iommu.c:589:35: note: in expansion of macro 'BIT'
           data->enable_4GB = !!(max_pfn > (BIT(32) >> PAGE_SHIFT));
      
      Use BIT_ULL instead of BIT.
      Reported-by: Nkernel test robot <lkp@intel.com>
      Signed-off-by: NYong Wu <yong.wu@mediatek.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      41939980
    • Y
      iommu/mediatek: Fix a build fail of m4u_type · 4f1c8ea1
      Yong Wu 提交于
      The commit ("iommu/mediatek: Enlarge the validate PA range
      for 4GB mode") introduce the following build error:
      
         drivers/iommu/mtk_iommu.c: In function 'mtk_iommu_hw_init':
      >> drivers/iommu/mtk_iommu.c:536:30: error: 'const struct mtk_iommu_data'
       has no member named 'm4u_type'; did you mean 'm4u_dom'?
           if (data->enable_4GB && data->m4u_type != M4U_MT8173) {
      
      This patch fix it, use "m4u_plat" instead of "m4u_type".
      Reported-by: Nkernel test robot <lkp@intel.com>
      Signed-off-by: NYong Wu <yong.wu@mediatek.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      4f1c8ea1
  12. 22 8月, 2017 6 次提交
  13. 20 7月, 2017 1 次提交
    • R
      iommu/mtk: Avoid redundant TLB syncs locally · 98a8f63e
      Robin Murphy 提交于
      Under certain circumstances, the io-pgtable code may end up issuing two
      TLB sync operations without any intervening invalidations. This goes
      badly for the M4U hardware, since it means the second sync ends up
      polling for a non-existent operation to finish, and as a result times
      out and warns. The io_pgtable_tlb_* helpers implement a high-level
      optimisation to avoid issuing the second sync at all in such cases, but
      in order to work correctly that requires all pagetable operations to be
      serialised under a lock, thus is no longer applicable to all io-pgtable
      users.
      
      Since we're the only user actually relying on this flag for correctness,
      let's reimplement it locally to avoid the headache of trying to make the
      high-level version concurrency-safe for other users.
      
      CC: Yong Wu <yong.wu@mediatek.com>
      CC: Matthias Brugger <matthias.bgg@gmail.com>
      Tested-by: NYong Wu <yong.wu@mediatek.com>
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      98a8f63e
  14. 10 2月, 2017 2 次提交
  15. 27 1月, 2017 1 次提交
  16. 15 11月, 2016 1 次提交
  17. 10 11月, 2016 2 次提交
  18. 21 6月, 2016 2 次提交
  19. 09 5月, 2016 1 次提交
    • R
      iommu: Allow selecting page sizes per domain · d16e0faa
      Robin Murphy 提交于
      Many IOMMUs support multiple page table formats, meaning that any given
      domain may only support a subset of the hardware page sizes presented in
      iommu_ops->pgsize_bitmap. There are also certain use-cases where the
      creator of a domain may want to control which page sizes are used, for
      example to force the use of hugepage mappings to reduce pagetable walk
      depth.
      
      To this end, add a per-domain pgsize_bitmap to represent the subset of
      page sizes actually in use, to make it possible for domains with
      different requirements to coexist.
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      [rm: hijacked and rebased original patch with new commit message]
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Acked-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      d16e0faa