1. 24 6月, 2017 2 次提交
    • 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/arm-smmu: Plumb in new ACPI identifiers · 84c24379
      Robin Murphy 提交于
      Revision C of IORT now allows us to identify ARM MMU-401 and the Cavium
      ThunderX implementation. Wire them up so that we can probe these models
      once firmware starts using the new codes in place of generic ones, and
      so that the appropriate features and quirks get enabled when we do.
      
      For the sake of backports and mitigating sychronisation problems with
      the ACPICA headers, we'll carry a backup copy of the new definitions
      locally for the short term to make life simpler.
      
      CC: stable@vger.kernel.org # 4.10
      Acked-by: NRobert Richter <rrichter@cavium.com>
      Tested-by: NRobert Richter <rrichter@cavium.com>
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      84c24379
  2. 26 4月, 2017 1 次提交
  3. 25 4月, 2017 1 次提交
  4. 20 4月, 2017 1 次提交
  5. 06 4月, 2017 9 次提交
  6. 22 3月, 2017 2 次提交
    • R
      iommu/dma: Make PCI window reservation generic · 273df963
      Robin Murphy 提交于
      Now that we're applying the IOMMU API reserved regions to our IOVA
      domains, we shouldn't need to privately special-case PCI windows, or
      indeed anything else which isn't specific to our iommu-dma layer.
      However, since those aren't IOMMU-specific either, rather than start
      duplicating code into IOMMU drivers let's transform the existing
      function into an iommu_get_resv_regions() helper that they can share.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      273df963
    • R
      iommu: Disambiguate MSI region types · 9d3a4de4
      Robin Murphy 提交于
      The introduction of reserved regions has left a couple of rough edges
      which we could do with sorting out sooner rather than later. Since we
      are not yet addressing the potential dynamic aspect of software-managed
      reservations and presenting them at arbitrary fixed addresses, it is
      incongruous that we end up displaying hardware vs. software-managed MSI
      regions to userspace differently, especially since ARM-based systems may
      actually require one or the other, or even potentially both at once,
      (which iommu-dma currently has no hope of dealing with at all). Let's
      resolve the former user-visible inconsistency ASAP before the ABI has
      been baked into a kernel release, in a way that also lays the groundwork
      for the latter shortcoming to be addressed by follow-up patches.
      
      For clarity, rename the software-managed type to IOMMU_RESV_SW_MSI, use
      IOMMU_RESV_MSI to describe the hardware type, and document everything a
      little bit. Since the x86 MSI remapping hardware falls squarely under
      this meaning of IOMMU_RESV_MSI, apply that type to their regions as well,
      so that we tell the same story to userspace across all platforms.
      
      Secondly, as the various region types require quite different handling,
      and it really makes little sense to ever try combining them, convert the
      bitfield-esque #defines to a plain enum in the process before anyone
      gets the wrong impression.
      
      Fixes: d30ddcaa ("iommu: Add a new type field in iommu_resv_region")
      Reviewed-by: NEric Auger <eric.auger@redhat.com>
      CC: Alex Williamson <alex.williamson@redhat.com>
      CC: David Woodhouse <dwmw2@infradead.org>
      CC: kvm@vger.kernel.org
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      9d3a4de4
  7. 10 2月, 2017 2 次提交
  8. 27 1月, 2017 2 次提交
    • T
      iommu/arm-smmu: Fix for ThunderX erratum #27704 · 3677a649
      Tomasz Nowicki 提交于
      The goal of erratum #27704 workaround was to make sure that ASIDs and VMIDs
      are unique across all SMMU instances on affected Cavium systems.
      
      Currently, the workaround code partitions ASIDs and VMIDs by increasing
      global cavium_smmu_context_count which in turn becomes the base ASID and VMID
      value for the given SMMU instance upon the context bank initialization.
      
      For systems with multiple SMMU instances this approach implies the risk
      of crossing 8-bit ASID, like for 1-socket CN88xx capable of 4 SMMUv2,
      128 context banks each:
      SMMU_0 (0-127 ASID RANGE)
      SMMU_1 (127-255 ASID RANGE)
      SMMU_2 (256-383 ASID RANGE) <--- crossing 8-bit ASID
      SMMU_3 (384-511 ASID RANGE) <--- crossing 8-bit ASID
      
      Since now we use 8-bit ASID (SMMU_CBn_TCR2.AS = 0) we effectively misconfigure
      ASID[15:8] bits of SMMU_CBn_TTBRm register for SMMU_2/3. Moreover, we still
      assume non-zero ASID[15:8] bits upon context invalidation. In the end,
      except SMMU_0/1 devices all other devices under other SMMUs will fail on guest
      power off/on. Since we try to invalidate TLB with 16-bit ASID but we actually
      have 8-bit zero padded 16-bit entry.
      
      This patch adds 16-bit ASID support for stage-1 AArch64 contexts so that
      we use ASIDs consistently for all SMMU instances.
      Signed-off-by: NTomasz Nowicki <tn@semihalf.com>
      Reviewed-by: NRobin Murphy <robin.murphy@arm.com>
      Reviewed-by: NTirumalesh Chalamarla  <Tirumalesh.Chalamarla@cavium.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      3677a649
    • A
      iommu/arm-smmu: Support for Extended Stream ID (16 bit) · dc0eaa4e
      Aleksey Makarov 提交于
      It is the time we have the real 16-bit Stream ID user, which is the
      ThunderX. Its IO topology uses 1:1 map for Requester ID to Stream ID
      translation for each root complex which allows to get full 16-bit
      Stream ID.  Firmware assigns bus IDs that are greater than 128 (0x80)
      to some buses under PEM (external PCIe interface).  Eventually SMMU
      drops devices on that buses because their Stream ID is out of range:
      
        pci 0006:90:00.0: stream ID 0x9000 out of range for SMMU (0x7fff)
      
      To fix above issue enable the Extended Stream ID optional feature
      when available.
      Reviewed-by: NTomasz Nowicki <tomasz.nowicki@caviumnetworks.com>
      Signed-off-by: NAleksey Makarov <aleksey.makarov@linaro.org>
      Tested-by: NTomasz Nowicki <tomasz.nowicki@caviumnetworks.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      dc0eaa4e
  9. 23 1月, 2017 2 次提交
  10. 19 1月, 2017 1 次提交
  11. 29 11月, 2016 5 次提交
  12. 15 11月, 2016 1 次提交
  13. 08 11月, 2016 3 次提交
  14. 16 9月, 2016 8 次提交
    • R
      iommu/arm-smmu: Set domain geometry · 455eb7d3
      Robin Murphy 提交于
      For non-aperture-based IOMMUs, the domain geometry seems to have become
      the de-facto way of indicating the input address space size. That is
      quite a useful thing from the users' perspective, so let's do the same.
      Reviewed-by: NEric Auger <eric.auger@redhat.com>
      Tested-by: NLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      455eb7d3
    • R
      iommu/arm-smmu: Wire up generic configuration support · 021bb842
      Robin Murphy 提交于
      With everything else now in place, fill in an of_xlate callback and the
      appropriate registration to plumb into the generic configuration
      machinery, and watch everything just work.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      021bb842
    • R
      iommu/arm-smmu: Convert to iommu_fwspec · adfec2e7
      Robin Murphy 提交于
      In the final step of preparation for full generic configuration support,
      swap our fixed-size master_cfg for the generic iommu_fwspec. For the
      legacy DT bindings, the driver simply gets to act as its own 'firmware'.
      Farewell, arbitrary MAX_MASTER_STREAMIDS!
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      adfec2e7
    • R
      iommu/arm-smmu: Intelligent SMR allocation · 588888a7
      Robin Murphy 提交于
      Stream Match Registers are one of the more awkward parts of the SMMUv2
      architecture; there are typically never enough to assign one to each
      stream ID in the system, and configuring them such that a single ID
      matches multiple entries is catastrophically bad - at best, every
      transaction raises a global fault; at worst, they go *somewhere*.
      
      To address the former issue, we can mask ID bits such that a single
      register may be used to match multiple IDs belonging to the same device
      or group, but doing so also heightens the risk of the latter problem
      (which can be nasty to debug).
      
      Tackle both problems at once by replacing the simple bitmap allocator
      with something much cleverer. Now that we have convenient in-memory
      representations of the stream mapping table, it becomes straightforward
      to properly validate new SMR entries against the current state, opening
      the door to arbitrary masking and SMR sharing.
      
      Another feature which falls out of this is that with IDs shared by
      separate devices being automatically accounted for, simply associating a
      group pointer with the S2CR offers appropriate group allocation almost
      for free, so hook that up in the process.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      588888a7
    • R
      iommu/arm-smmu: Add a stream map entry iterator · d3097e39
      Robin Murphy 提交于
      We iterate over the SMEs associated with a master config quite a lot in
      various places, and are about to do so even more. Let's wrap the idiom
      in a handy iterator macro before the repetition gets out of hand.
      Tested-by: NLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      d3097e39
    • R
      iommu/arm-smmu: Streamline SMMU data lookups · d6fc5d97
      Robin Murphy 提交于
      Simplify things somewhat by stashing our arm_smmu_device instance in
      drvdata, so that it's readily available to our driver model callbacks.
      Then we can excise the private list entirely, since the driver core
      already has a perfectly good list of SMMU devices we can use in the one
      instance we actually need to. Finally, make a further modest code saving
      with the relatively new of_device_get_match_data() helper.
      Tested-by: NLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      d6fc5d97
    • R
      iommu/arm-smmu: Refactor mmu-masters handling · f80cd885
      Robin Murphy 提交于
      To be able to support the generic bindings and handle of_xlate() calls,
      we need to be able to associate SMMUs and stream IDs directly with
      devices *before* allocating IOMMU groups. Furthermore, to support real
      default domains with multi-device groups we also have to handle domain
      attach on a per-device basis, as the "whole group at a time" assumption
      fails to properly handle subsequent devices added to a group after the
      first has already triggered default domain creation and attachment.
      
      To that end, use the now-vacant dev->archdata.iommu field for easy
      config and SMMU instance lookup, and unify config management by chopping
      down the platform-device-specific tree and probing the "mmu-masters"
      property on-demand instead. This may add a bit of one-off overhead to
      initially adding a new device, but we're about to deprecate that binding
      in favour of the inherently-more-efficient generic ones anyway.
      
      For the sake of simplicity, this patch does temporarily regress the case
      of aliasing PCI devices by losing the duplicate stream ID detection that
      the previous per-group config had. Stay tuned, because we'll be back to
      fix that in a better and more general way momentarily...
      Tested-by: NLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      f80cd885
    • R
      iommu/arm-smmu: Keep track of S2CR state · 8e8b203e
      Robin Murphy 提交于
      Making S2CRs first-class citizens within the driver with a high-level
      representation of their state offers a neat solution to a few problems:
      
      Firstly, the information about which context a device's stream IDs are
      associated with is already present by necessity in the S2CR. With that
      state easily accessible we can refer directly to it and obviate the need
      to track an IOMMU domain in each device's archdata (its earlier purpose
      of enforcing correct attachment of multi-device groups now being handled
      by the IOMMU core itself).
      
      Secondly, the core API now deprecates explicit domain detach and expects
      domain attach to move devices smoothly from one domain to another; for
      SMMUv2, this notion maps directly to simply rewriting the S2CRs assigned
      to the device. By giving the driver a suitable abstraction of those
      S2CRs to work with, we can massively reduce the overhead of the current
      heavy-handed "detach, free resources, reallocate resources, attach"
      approach.
      
      Thirdly, making the software state hardware-shaped and attached to the
      SMMU instance once again makes suspend/resume of this register group
      that much simpler to implement in future.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      8e8b203e