1. 01 2月, 2021 3 次提交
  2. 29 1月, 2021 1 次提交
  3. 08 12月, 2020 2 次提交
  4. 24 7月, 2020 1 次提交
  5. 10 1月, 2020 3 次提交
    • R
      iommu/io-pgtable-arm: Rationalise TCR handling · fb485eb1
      Robin Murphy 提交于
      Although it's conceptually nice for the io_pgtable_cfg to provide a
      standard VMSA TCR value, the reality is that no VMSA-compliant IOMMU
      looks exactly like an Arm CPU, and they all have various other TCR
      controls which io-pgtable can't be expected to understand. Thus since
      there is an expectation that drivers will have to add to the given TCR
      value anyway, let's strip it down to just the essentials that are
      directly relevant to io-pgtable's inner workings - namely the various
      sizes and the walk attributes.
      Tested-by: NJordan Crouse <jcrouse@codeaurora.org>
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      [will: Add missing include of bitfield.h]
      Signed-off-by: NWill Deacon <will@kernel.org>
      fb485eb1
    • R
      iommu/io-pgtable-arm: Improve attribute handling · 7618e479
      Robin Murphy 提交于
      By VMSA rules, using Normal Non-Cacheable type with a shareability
      attribute of anything other than Outer Shareable is liable to lead into
      unpredictable territory:
      
      | Overlaying the shareability attribute (B3-1377, ARM DDI 0406C.c)
      |
      | A memory region with a resultant memory type attribute of Normal, and
      | a resultant cacheability attribute of Inner Non-cacheable, Outer
      | Non-cacheable, must have a resultant shareability attribute of Outer
      | Shareable, otherwise shareability is UNPREDICTABLE
      
      Although the SMMU architectures seem to give some slightly stronger
      guarantees of Non-Cacheable output types becoming implicitly Outer
      Shareable in most cases, we may as well be explicit and not take any
      chances. It's also weird that LPAE attribute handling is currently split
      between prot_to_pte() and init_pte() given that it can all be statically
      determined up-front. Thus, collect *all* the LPAE attributes into
      prot_to_pte() in order to logically pick the shareability based on the
      incoming IOMMU API prot value, and tweak the short-descriptor code to
      stop setting TTBR0.NOS for Non-Cacheable walks.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will@kernel.org>
      7618e479
    • R
      iommu/io-pgtable-arm: Rationalise TTBRn handling · d1e5f26f
      Robin Murphy 提交于
      TTBR1 values have so far been redundant since no users implement any
      support for split address spaces. Crucially, though, one of the main
      reasons for wanting to do so is to be able to manage each half entirely
      independently, e.g. context-switching one set of mappings without
      disturbing the other. Thus it seems unlikely that tying two tables
      together in a single io_pgtable_cfg would ever be particularly desirable
      or useful.
      
      Streamline the configs to just a single conceptual TTBR value
      representing the allocated table. This paves the way for future users to
      support split address spaces by simply allocating a table and dealing
      with the detailed TTBRn logistics themselves.
      Tested-by: NJordan Crouse <jcrouse@codeaurora.org>
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      [will: Drop change to ttbr value]
      Signed-off-by: NWill Deacon <will@kernel.org>
      d1e5f26f
  6. 05 11月, 2019 1 次提交
  7. 30 8月, 2019 4 次提交
  8. 30 7月, 2019 5 次提交
  9. 24 7月, 2019 2 次提交
    • W
      iommu/io-pgtable: Rename iommu_gather_ops to iommu_flush_ops · 298f7889
      Will Deacon 提交于
      In preparation for TLB flush gathering in the IOMMU API, rename the
      iommu_gather_ops structure in io-pgtable to iommu_flush_ops, which
      better describes its purpose and avoids the potential for confusion
      between different levels of the API.
      
      $ find linux/ -type f -name '*.[ch]' | xargs sed -i 's/gather_ops/flush_ops/g'
      Signed-off-by: NWill Deacon <will@kernel.org>
      298f7889
    • W
      iommu/io-pgtable-arm: Remove redundant call to io_pgtable_tlb_sync() · f71da467
      Will Deacon 提交于
      Commit b6b65ca2 ("iommu/io-pgtable-arm: Add support for non-strict
      mode") added an unconditional call to io_pgtable_tlb_sync() immediately
      after the case where we replace a block entry with a table entry during
      an unmap() call. This is redundant, since the IOMMU API will call
      iommu_tlb_sync() on this path and the patch in question mentions this:
      
       | To save having to reason about it too much, make sure the invalidation
       | in arm_lpae_split_blk_unmap() just performs its own unconditional sync
       | to minimise the window in which we're technically violating the break-
       | before-make requirement on a live mapping. This might work out redundant
       | with an outer-level sync for strict unmaps, but we'll never be splitting
       | blocks on a DMA fastpath anyway.
      
      However, this sync gets in the way of deferred TLB invalidation for leaf
      entries and is at best a questionable, unproven hack. Remove it.
      Signed-off-by: NWill Deacon <will@kernel.org>
      f71da467
  10. 25 6月, 2019 2 次提交
  11. 19 6月, 2019 1 次提交
  12. 30 3月, 2019 1 次提交
    • N
      iommu/io-pgtable-arm-v7s: request DMA32 memory, and improve debugging · 0a352554
      Nicolas Boichat 提交于
      IOMMUs using ARMv7 short-descriptor format require page tables (level 1
      and 2) to be allocated within the first 4GB of RAM, even on 64-bit
      systems.
      
      For level 1/2 pages, ensure GFP_DMA32 is used if CONFIG_ZONE_DMA32 is
      defined (e.g.  on arm64 platforms).
      
      For level 2 pages, allocate a slab cache in SLAB_CACHE_DMA32.  Note that
      we do not explicitly pass GFP_DMA[32] to kmem_cache_zalloc, as this is
      not strictly necessary, and would cause a warning in mm/sl*b.c, as we
      did not update GFP_SLAB_BUG_MASK.
      
      Also, print an error when the physical address does not fit in
      32-bit, to make debugging easier in the future.
      
      Link: http://lkml.kernel.org/r/20181210011504.122604-3-drinkcat@chromium.org
      Fixes: ad67f5a6 ("arm64: replace ZONE_DMA with ZONE_DMA32")
      Signed-off-by: NNicolas Boichat <drinkcat@chromium.org>
      Acked-by: NWill Deacon <will.deacon@arm.com>
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Hsin-Yi Wang <hsinyi@chromium.org>
      Cc: Huaisheng Ye <yehs1@lenovo.com>
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Matthias Brugger <matthias.bgg@gmail.com>
      Cc: Mel Gorman <mgorman@techsingularity.net>
      Cc: Michal Hocko <mhocko@suse.com>
      Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Sasha Levin <Alexander.Levin@microsoft.com>
      Cc: Tomasz Figa <tfiga@google.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: Yingjoe Chen <yingjoe.chen@mediatek.com>
      Cc: Yong Wu <yong.wu@mediatek.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      0a352554
  13. 26 2月, 2019 1 次提交
    • N
      iommu/io-pgtable-arm-v7s: Only kmemleak_ignore L2 tables · 032ebd85
      Nicolas Boichat 提交于
      L1 tables are allocated with __get_dma_pages, and therefore already
      ignored by kmemleak.
      
      Without this, the kernel would print this error message on boot,
      when the first L1 table is allocated:
      
      [    2.810533] kmemleak: Trying to color unknown object at 0xffffffd652388000 as Black
      [    2.818190] CPU: 5 PID: 39 Comm: kworker/5:0 Tainted: G S                4.19.16 #8
      [    2.831227] Workqueue: events deferred_probe_work_func
      [    2.836353] Call trace:
      ...
      [    2.852532]  paint_ptr+0xa0/0xa8
      [    2.855750]  kmemleak_ignore+0x38/0x6c
      [    2.859490]  __arm_v7s_alloc_table+0x168/0x1f4
      [    2.863922]  arm_v7s_alloc_pgtable+0x114/0x17c
      [    2.868354]  alloc_io_pgtable_ops+0x3c/0x78
      ...
      
      Fixes: e5fc9753 ("iommu/io-pgtable: Add ARMv7 short descriptor support")
      Signed-off-by: NNicolas Boichat <drinkcat@chromium.org>
      Acked-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      032ebd85
  14. 11 2月, 2019 1 次提交
    • R
      iommu: Allow io-pgtable to be used outside of drivers/iommu/ · b77cf11f
      Rob Herring 提交于
      Move io-pgtable.h to include/linux/ and export alloc_io_pgtable_ops
      and free_io_pgtable_ops. This enables drivers outside drivers/iommu/ to
      use the page table library. Specifically, some ARM Mali GPUs use the
      ARM page table formats.
      
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Matthias Brugger <matthias.bgg@gmail.com>
      Cc: Rob Clark <robdclark@gmail.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-mediatek@lists.infradead.org
      Cc: linux-arm-msm@vger.kernel.org
      Signed-off-by: NRob Herring <robh@kernel.org>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      b77cf11f
  15. 17 12月, 2018 1 次提交
  16. 01 10月, 2018 1 次提交
  17. 26 7月, 2018 1 次提交
  18. 03 5月, 2018 1 次提交
  19. 14 2月, 2018 1 次提交
  20. 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
  21. 27 9月, 2017 1 次提交
  22. 20 7月, 2017 1 次提交
  23. 24 6月, 2017 4 次提交
    • W
      iommu/io-pgtable-arm: Use dma_wmb() instead of wmb() when publishing table · 77f34458
      Will Deacon 提交于
      When writing a new table entry, we must ensure that the contents of the
      table is made visible to the SMMU page table walker before the updated
      table entry itself.
      
      This is currently achieved using wmb(), which expands to an expensive and
      unnecessary DSB instruction. Ideally, we'd just use cmpxchg64_release when
      writing the table entry, but this doesn't have memory ordering semantics
      on !SMP systems.
      
      Instead, use dma_wmb(), which emits DMB OSHST. Strictly speaking, this
      does more than we require (since it targets the outer-shareable domain),
      but it's likely to be significantly faster than the DSB approach.
      Reported-by: NLinu Cherian <linu.cherian@cavium.com>
      Suggested-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      77f34458
    • R
      iommu/io-pgtable-arm-v7s: Support lockless operation · 119ff305
      Robin Murphy 提交于
      Mirroring the LPAE implementation, rework the v7s code to be robust
      against concurrent operations. The same two potential races exist, and
      are solved in the same manner, with the fixed 2-level structure making
      life ever so slightly simpler.
      
      What complicates matters compared to LPAE, however, is large page
      entries, since we can't update a block of 16 PTEs atomically, nor assume
      available software bits to do clever things with. As most users are
      never likely to do partial unmaps anyway (due to DMA API rules), it
      doesn't seem unreasonable for this case to remain behind a serialising
      lock; we just pull said lock down into the bowels of the implementation
      so it's well out of the way of the normal call paths.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      119ff305
    • R
      iommu/io-pgtable: Introduce explicit coherency · 81b3c252
      Robin Murphy 提交于
      Once we remove the serialising spinlock, a potential race opens up for
      non-coherent IOMMUs whereby a caller of .map() can be sure that cache
      maintenance has been performed on their new PTE, but will have no
      guarantee that such maintenance for table entries above it has actually
      completed (e.g. if another CPU took an interrupt immediately after
      writing the table entry, but before initiating the DMA sync).
      
      Handling this race safely will add some potentially non-trivial overhead
      to installing a table entry, which we would much rather avoid on
      coherent systems where it will be unnecessary, and where we are stirivng
      to minimise latency by removing the locking in the first place.
      
      To that end, let's introduce an explicit notion of cache-coherency to
      io-pgtable, such that we will be able to avoid penalising IOMMUs which
      know enough to know when they are coherent.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      81b3c252
    • R
      iommu/io-pgtable-arm-v7s: Refactor split_blk_unmap · b9f1ef30
      Robin Murphy 提交于
      Whilst the short-descriptor format's split_blk_unmap implementation has
      no need to be recursive, it followed the pattern of the LPAE version
      anyway for the sake of consistency. With the latter now reworked for
      both efficiency and future scalability improvements, tweak the former
      similarly, not least to make it less obtuse.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      b9f1ef30