1. 03 9月, 2019 1 次提交
  2. 23 8月, 2019 2 次提交
  3. 22 8月, 2019 5 次提交
  4. 21 8月, 2019 1 次提交
    • W
      iommu/arm-smmu-v3: Document ordering guarantees of command insertion · 05cbaf4d
      Will Deacon 提交于
      It turns out that we've always relied on some subtle ordering guarantees
      when inserting commands into the SMMUv3 command queue. With the recent
      changes to elide locking when possible, these guarantees become more
      subtle and even more important.
      
      Add a comment documented the barrier semantics of command insertion so
      that we don't have to derive the behaviour from scratch each time it
      comes up on the list.
      Signed-off-by: NWill Deacon <will@kernel.org>
      05cbaf4d
  5. 08 8月, 2019 2 次提交
  6. 06 8月, 2019 1 次提交
  7. 30 7月, 2019 11 次提交
  8. 24 7月, 2019 1 次提交
  9. 04 7月, 2019 1 次提交
  10. 02 7月, 2019 1 次提交
    • W
      iommu/arm-smmu-v3: Fix compilation when CONFIG_CMA=n · 900a85ca
      Will Deacon 提交于
      When compiling a kernel without support for CMA, CONFIG_CMA_ALIGNMENT
      is not defined which results in the following build failure:
      
      In file included from ./include/linux/list.h:9:0
                       from ./include/linux/kobject.h:19,
                       from ./include/linux/of.h:17
                       from ./include/linux/irqdomain.h:35,
                       from ./include/linux/acpi.h:13,
                       from drivers/iommu/arm-smmu-v3.c:12:
      drivers/iommu/arm-smmu-v3.c: In function ‘arm_smmu_device_hw_probe’:
      drivers/iommu/arm-smmu-v3.c:194:40: error: ‘CONFIG_CMA_ALIGNMENT’ undeclared (first use in this function)
       #define Q_MAX_SZ_SHIFT   (PAGE_SHIFT + CONFIG_CMA_ALIGNMENT)
      
      Fix the breakage by capping the maximum queue size based on MAX_ORDER
      when CMA is not enabled.
      Reported-by: NZhangshaokun <zhangshaokun@hisilicon.com>
      Signed-off-by: NWill Deacon <will@kernel.org>
      Tested-by: NShaokun Zhang <zhangshaokun@hisilicon.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      900a85ca
  11. 25 6月, 2019 1 次提交
  12. 24 6月, 2019 1 次提交
    • S
      driver_find_device: Unify the match function with class_find_device() · 92ce7e83
      Suzuki K Poulose 提交于
      The driver_find_device() accepts a match function pointer to
      filter the devices for lookup, similar to bus/class_find_device().
      However, there is a minor difference in the prototype for the
      match parameter for driver_find_device() with the now unified
      version accepted by {bus/class}_find_device(), where it doesn't
      accept a "const" qualifier for the data argument. This prevents
      us from reusing the generic match functions for driver_find_device().
      
      For this reason, change the prototype of the driver_find_device() to
      make the "match" parameter in line with {bus/class}_find_device()
      and adjust its callers to use the const qualifier. Also, we could
      now promote the "data" parameter to const as we pass it down
      as a const parameter to the match functions.
      
      Cc: Corey Minyard <minyard@acm.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Thierry Reding <thierry.reding@gmail.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
      Cc: Sebastian Ott <sebott@linux.ibm.com>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: Nehal Shah <nehal-bakulchandra.shah@amd.com>
      Cc: Shyam Sundar S K <shyam-sundar.s-k@amd.com>
      Cc: Lee Jones <lee.jones@linaro.org>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Signed-off-by: NSuzuki K Poulose <suzuki.poulose@arm.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      92ce7e83
  13. 19 6月, 2019 1 次提交
    • W
      iommu/arm-smmu-v3: Increase maximum size of queues · d25f6ead
      Will Deacon 提交于
      We've been artificially limiting the size of our queues to 4k so that we
      don't end up allocating huge amounts of physically-contiguous memory at
      probe time. However, 4k is only enough for 256 commands in the command
      queue, so instead let's try to allocate the largest queue that the SMMU
      supports, retrying with a smaller size if the allocation fails.
      
      The caveat here is that we have to limit our upper bound based on
      CONFIG_CMA_ALIGNMENT to ensure that our queue allocations remain
      natually aligned, which is required by the SMMU architecture.
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      d25f6ead
  14. 23 4月, 2019 7 次提交
    • W
      iommu/arm-smmu-v3: Don't disable SMMU in kdump kernel · 3f54c447
      Will Deacon 提交于
      Disabling the SMMU when probing from within a kdump kernel so that all
      incoming transactions are terminated can prevent the core of the crashed
      kernel from being transferred off the machine if all I/O devices are
      behind the SMMU.
      
      Instead, continue to probe the SMMU after it is disabled so that we can
      reinitialise it entirely and re-attach the DMA masters as they are reset.
      Since the kdump kernel may not have drivers for all of the active DMA
      masters, we suppress fault reporting to avoid spamming the console and
      swamping the IRQ threads.
      Reported-by: N"Leizhen (ThunderTown)" <thunder.leizhen@huawei.com>
      Tested-by: N"Leizhen (ThunderTown)" <thunder.leizhen@huawei.com>
      Tested-by: NBhupesh Sharma <bhsharma@redhat.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      3f54c447
    • J
      iommu/arm-smmu-v3: Disable tagged pointers · b2fc9b4b
      Jean-Philippe Brucker 提交于
      The ARM architecture has a "Top Byte Ignore" (TBI) option that makes the
      MMU mask out bits [63:56] of an address, allowing a userspace application
      to store data in its pointers. This option is incompatible with PCI ATS.
      
      If TBI is enabled in the SMMU and userspace triggers DMA transactions on
      tagged pointers, the endpoint might create ATC entries for addresses that
      include a tag. Software would then have to send ATC invalidation packets
      for each 255 possible alias of an address, or just wipe the whole address
      space. This is not a viable option, so disable TBI.
      
      The impact of this change is unclear, since there are very few users of
      tagged pointers, much less SVA. But the requirement introduced by this
      patch doesn't seem excessive: a userspace application using both tagged
      pointers and SVA should now sanitize addresses (clear the tag) before
      using them for device DMA.
      Signed-off-by: NJean-Philippe Brucker <jean-philippe.brucker@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      b2fc9b4b
    • J
      iommu/arm-smmu-v3: Add support for PCI ATS · 9ce27afc
      Jean-Philippe Brucker 提交于
      PCIe devices can implement their own TLB, named Address Translation Cache
      (ATC). Enable Address Translation Service (ATS) for devices that support
      it and send them invalidation requests whenever we invalidate the IOTLBs.
      
      ATC invalidation is allowed to take up to 90 seconds, according to the
      PCIe spec, so it is possible to get a SMMU command queue timeout during
      normal operations. However we expect implementations to complete
      invalidation in reasonable time.
      
      We only enable ATS for "trusted" devices, and currently rely on the
      pci_dev->untrusted bit. For ATS we have to trust that:
      
      (a) The device doesn't issue "translated" memory requests for addresses
          that weren't returned by the SMMU in a Translation Completion. In
          particular, if we give control of a device or device partition to a VM
          or userspace, software cannot program the device to access arbitrary
          "translated" addresses.
      
      (b) The device follows permissions granted by the SMMU in a Translation
          Completion. If the device requested read+write permission and only
          got read, then it doesn't write.
      
      (c) The device doesn't send Translated transactions for an address that
          was invalidated by an ATC invalidation.
      
      Note that the PCIe specification explicitly requires all of these, so we
      can assume that implementations will cleanly shield ATCs from software.
      
      All ATS translated requests still go through the SMMU, to walk the stream
      table and check that the device is actually allowed to send translated
      requests.
      Signed-off-by: NJean-Philippe Brucker <jean-philippe.brucker@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      9ce27afc
    • J
      iommu/arm-smmu-v3: Link domains and devices · 2a7e62f5
      Jean-Philippe Brucker 提交于
      When removing a mapping from a domain, we need to send an invalidation to
      all devices that might have stored it in their Address Translation Cache
      (ATC). In addition when updating the context descriptor of a live domain,
      we'll need to send invalidations for all devices attached to it.
      
      Maintain a list of devices in each domain, protected by a spinlock. It is
      updated every time we attach or detach devices to and from domains.
      
      It needs to be a spinlock because we'll invalidate ATC entries from
      within hardirq-safe contexts, but it may be possible to relax the read
      side with RCU later.
      Signed-off-by: NJean-Philippe Brucker <jean-philippe.brucker@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      2a7e62f5
    • J
      iommu/arm-smmu-v3: Add a master->domain pointer · 8be39a1a
      Jean-Philippe Brucker 提交于
      As we're going to track domain-master links more closely for ATS and CD
      invalidation, add pointer to the attached domain in struct
      arm_smmu_master. As a result, arm_smmu_strtab_ent is redundant and can be
      removed.
      Signed-off-by: NJean-Philippe Brucker <jean-philippe.brucker@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      8be39a1a
    • J
      iommu/arm-smmu-v3: Store SteamIDs in master · bcecaee4
      Jean-Philippe Brucker 提交于
      Simplify the attach/detach code a bit by keeping a pointer to the stream
      IDs in the master structure. Although not completely obvious here, it does
      make the subsequent support for ATS, PRI and PASID a bit simpler.
      Signed-off-by: NJean-Philippe Brucker <jean-philippe.brucker@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      bcecaee4
    • J
      iommu/arm-smmu-v3: Rename arm_smmu_master_data to arm_smmu_master · b54f4260
      Jean-Philippe Brucker 提交于
      The arm_smmu_master_data structure already represents more than just the
      firmware data associated to a master, and will be used extensively to
      represent a device's state when implementing more SMMU features. Rename
      the structure to arm_smmu_master.
      Signed-off-by: NJean-Philippe Brucker <jean-philippe.brucker@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      b54f4260
  15. 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
  16. 17 12月, 2018 1 次提交
  17. 10 12月, 2018 2 次提交
    • W
      iommu/arm-smmu-v3: Use explicit mb() when moving cons pointer · a868e853
      Will Deacon 提交于
      After removing an entry from a queue (e.g. reading an event in
      arm_smmu_evtq_thread()) it is necessary to advance the MMIO consumer
      pointer to free the queue slot back to the SMMU. A memory barrier is
      required here so that all reads targetting the queue entry have
      completed before the consumer pointer is updated.
      
      The implementation of queue_inc_cons() relies on a writel() to complete
      the previous reads, but this is incorrect because writel() is only
      guaranteed to complete prior writes. This patch replaces the call to
      writel() with an mb(); writel_relaxed() sequence, which gives us the
      read->write ordering which we require.
      
      Cc: Robin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      a868e853
    • Z
      iommu/arm-smmu-v3: Avoid memory corruption from Hisilicon MSI payloads · 84a9a757
      Zhen Lei 提交于
      The GITS_TRANSLATER MMIO doorbell register in the ITS hardware is
      architected to be 4 bytes in size, yet on hi1620 and earlier, Hisilicon
      have allocated the adjacent 4 bytes to carry some IMPDEF sideband
      information which results in an 8-byte MSI payload being delivered when
      signalling an interrupt:
      
      MSIAddr:
      	 |----4bytes----|----4bytes----|
      	 |    MSIData   |    IMPDEF    |
      
      This poses no problem for the ITS hardware because the adjacent 4 bytes
      are reserved in the memory map. However, when delivering MSIs to memory,
      as we do in the SMMUv3 driver for signalling the completion of a SYNC
      command, the extended payload will corrupt the 4 bytes adjacent to the
      "sync_count" member in struct arm_smmu_device. Fortunately, the current
      layout allocates these bytes to padding, but this is fragile and we
      should make this explicit.
      Reviewed-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NZhen Lei <thunder.leizhen@huawei.com>
      [will: Rewrote commit message and comment]
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      84a9a757