1. 23 4月, 2019 1 次提交
  2. 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
  3. 17 12月, 2018 1 次提交
  4. 10 12月, 2018 3 次提交
    • 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
    • R
      iommu/arm-smmu-v3: Fix big-endian CMD_SYNC writes · 3cd508a8
      Robin Murphy 提交于
      When we insert the sync sequence number into the CMD_SYNC.MSIData field,
      we do so in CPU-native byte order, before writing out the whole command
      as explicitly little-endian dwords. Thus on big-endian systems, the SMMU
      will receive and write back a byteswapped version of sync_nr, which would
      be perfect if it were targeting a similarly-little-endian ITS, but since
      it's actually writing back to memory being polled by the CPUs, they're
      going to end up seeing the wrong thing.
      
      Since the SMMU doesn't care what the MSIData actually contains, the
      minimal-overhead solution is to simply add an extra byteswap initially,
      such that it then writes back the big-endian format directly.
      
      Cc: <stable@vger.kernel.org>
      Fixes: 37de98f8 ("iommu/arm-smmu-v3: Use CMD_SYNC completion MSI")
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      3cd508a8
  5. 03 12月, 2018 1 次提交
    • P
      iommu/arm-smmu: Make arm-smmu-v3 explicitly non-modular · c07b6426
      Paul Gortmaker 提交于
      The Kconfig currently controlling compilation of this code is:
      
      drivers/iommu/Kconfig:config ARM_SMMU_V3
      drivers/iommu/Kconfig:  bool "ARM Ltd. System MMU Version 3 (SMMUv3) Support"
      
      ...meaning that it currently is not being built as a module by anyone.
      
      Lets remove the modular code that is essentially orphaned, so that
      when reading the driver there is no doubt it is builtin-only.
      
      Since module_platform_driver() uses the same init level priority as
      builtin_platform_driver() the init ordering remains unchanged with
      this commit.
      
      We explicitly disallow a driver unbind, since that doesn't have a
      sensible use case anyway, but unlike most drivers, we can't delete the
      function tied to the ".remove" field.  This is because as of commit
      7aa8619a ("iommu/arm-smmu-v3: Implement shutdown method") the
      .remove function was given a one line wrapper and re-used to provide a
      .shutdown service.  So we delete the wrapper and re-name the function
      from remove to shutdown.
      
      We add a moduleparam.h include since the file does actually declare
      some module parameters, and leaving them as such is the easiest way
      currently to remain backwards compatible with existing use cases.
      
      Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code.
      
      We also delete the MODULE_LICENSE tag etc. since all that information
      is already contained at the top of the file in the comments.
      
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Nate Watterson <nwatters@codeaurora.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: iommu@lists.linux-foundation.org
      Acked-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NPaul Gortmaker <paul.gortmaker@windriver.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      c07b6426
  6. 11 10月, 2018 2 次提交
  7. 01 10月, 2018 5 次提交
    • Z
      iommu/arm-smmu-v3: Add support for non-strict mode · 9662b99a
      Zhen Lei 提交于
      Now that io-pgtable knows how to dodge strict TLB maintenance, all
      that's left to do is bridge the gap between the IOMMU core requesting
      DOMAIN_ATTR_DMA_USE_FLUSH_QUEUE for default domains, and showing the
      appropriate IO_PGTABLE_QUIRK_NON_STRICT flag to alloc_io_pgtable_ops().
      Signed-off-by: NZhen Lei <thunder.leizhen@huawei.com>
      [rm: convert to domain attribute, tweak commit message]
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      9662b99a
    • Z
      iommu/arm-smmu-v3: Implement flush_iotlb_all hook · 07fdef34
      Zhen Lei 提交于
      .flush_iotlb_all is currently stubbed to arm_smmu_iotlb_sync() since the
      only time it would ever need to actually do anything is for callers
      doing their own explicit batching, e.g.:
      
      	iommu_unmap_fast(domain, ...);
      	iommu_unmap_fast(domain, ...);
      	iommu_iotlb_flush_all(domain, ...);
      
      where since io-pgtable still issues the TLBI commands implicitly in the
      unmap instead of implementing .iotlb_range_add, the "flush" only needs
      to ensure completion of those already-in-flight invalidations.
      
      However, we're about to start using it in anger with flush queues, so
      let's get a proper implementation wired up.
      Signed-off-by: NZhen Lei <thunder.leizhen@huawei.com>
      Reviewed-by: NRobin Murphy <robin.murphy@arm.com>
      [rm: document why it wasn't a bug]
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      07fdef34
    • Z
      iommu/arm-smmu-v3: Avoid back-to-back CMD_SYNC operations · 901510ee
      Zhen Lei 提交于
      Putting adjacent CMD_SYNCs into the command queue is nonsensical, but
      can happen when multiple CPUs are inserting commands. Rather than leave
      the poor old hardware to chew through these operations, we can instead
      drop the subsequent SYNCs and poll for completion of the first. This
      has been shown to improve IO performance under pressure, where the
      number of SYNC operations reduces by about a third:
      
      	CMD_SYNCs reduced:	19542181
      	CMD_SYNCs total:	58098548	(include reduced)
      	CMDs total:		116197099	(TLBI:SYNC about 1:1)
      Signed-off-by: NZhen Lei <thunder.leizhen@huawei.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      901510ee
    • Z
      iommu/arm-smmu-v3: Fix unexpected CMD_SYNC timeout · 0f02477d
      Zhen Lei 提交于
      The condition break condition of:
      
      	(int)(VAL - sync_idx) >= 0
      
      in the __arm_smmu_sync_poll_msi() polling loop requires that sync_idx
      must be increased monotonically according to the sequence of the CMDs in
      the cmdq.
      
      However, since the msidata is populated using atomic_inc_return_relaxed()
      before taking the command-queue spinlock, then the following scenario
      can occur:
      
      CPU0			CPU1
      msidata=0
      			msidata=1
      			insert cmd1
      insert cmd0
      			smmu execute cmd1
      smmu execute cmd0
      			poll timeout, because msidata=1 is overridden by
      			cmd0, that means VAL=0, sync_idx=1.
      
      This is not a functional problem, since the caller will eventually either
      timeout or exit due to another CMD_SYNC, however it's clearly not what
      the code is supposed to be doing. Fix it, by incrementing the sequence
      count with the command-queue lock held, allowing us to drop the atomic
      operations altogether.
      Signed-off-by: NZhen Lei <thunder.leizhen@huawei.com>
      [will: dropped the specialised cmd building routine for now]
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      0f02477d
    • J
      iommu/arm-smmu-v3: Fix a couple of minor comment typos · 657135f3
      John Garry 提交于
      Fix some comment typos spotted.
      Signed-off-by: NJohn Garry <john.garry@huawei.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      657135f3
  8. 08 8月, 2018 1 次提交
  9. 27 7月, 2018 2 次提交
  10. 26 7月, 2018 1 次提交
  11. 10 7月, 2018 1 次提交
    • R
      iommu: Remove IOMMU_OF_DECLARE · ac6bbf0c
      Rob Herring 提交于
      Now that we use the driver core to stop deferred probe for missing
      drivers, IOMMU_OF_DECLARE can be removed.
      
      This is slightly less optimal than having a list of built-in drivers in
      that we'll now defer probe twice before giving up. This shouldn't have a
      significant impact on boot times as past discussions about deferred
      probe have given no evidence of deferred probe having a substantial
      impact.
      
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Kukjin Kim <kgene@kernel.org>
      Cc: Krzysztof Kozlowski <krzk@kernel.org>
      Cc: Rob Clark <robdclark@gmail.com>
      Cc: Heiko Stuebner <heiko@sntech.de>
      Cc: Frank Rowand <frowand.list@gmail.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-samsung-soc@vger.kernel.org
      Cc: linux-arm-msm@vger.kernel.org
      Cc: linux-rockchip@lists.infradead.org
      Cc: devicetree@vger.kernel.org
      Acked-by: NWill Deacon <will.deacon@arm.com>
      Acked-by: NMarek Szyprowski <m.szyprowski@samsung.com>
      Acked-by: NJoerg Roedel <jroedel@suse.de>
      Signed-off-by: NRob Herring <robh@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ac6bbf0c
  12. 27 3月, 2018 8 次提交
  13. 17 1月, 2018 1 次提交
  14. 03 1月, 2018 2 次提交
  15. 20 10月, 2017 10 次提交
    • R
      iommu/arm-smmu-v3: Use burst-polling for sync completion · 8ff0f723
      Robin Murphy 提交于
      While CMD_SYNC is unlikely to complete immediately such that we never go
      round the polling loop, with a lightly-loaded queue it may still do so
      long before the delay period is up. If we have no better completion
      notifier, use similar logic as we have for SMMUv2 to spin a number of
      times before each backoff, so that we have more chance of catching syncs
      which complete relatively quickly and avoid delaying unnecessarily.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      8ff0f723
    • W
      iommu/arm-smmu-v3: Consolidate identical timeouts · a529ea19
      Will Deacon 提交于
      We have separate (identical) timeout values for polling for a queue to
      drain and waiting for an MSI to signal CMD_SYNC completion. In reality,
      we only wait for the command queue to drain if we're waiting on a sync,
      so just merged these two timeouts into a single constant.
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      a529ea19
    • W
      iommu/arm-smmu-v3: Split arm_smmu_cmdq_issue_sync in half · 49806599
      Will Deacon 提交于
      arm_smmu_cmdq_issue_sync is a little unwieldy now that it supports both
      MSI and event-based polling, so split it into two functions to make things
      easier to follow.
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      49806599
    • R
      iommu/arm-smmu-v3: Use CMD_SYNC completion MSI · 37de98f8
      Robin Murphy 提交于
      As an IRQ, the CMD_SYNC interrupt is not particularly useful, not least
      because we often need to wait for sync completion within someone else's
      IRQ handler anyway. However, when the SMMU is both coherent and supports
      MSIs, we can have a lot more fun by not using it as an interrupt at all.
      Following the example suggested in the architecture and using a write
      targeting normal memory, we can let callers wait on a status variable
      outside the lock instead of having to stall the entire queue or even
      touch MMIO registers. Since multiple sync commands are guaranteed to
      complete in order, a simple incrementing sequence count is all we need
      to unambiguously support any realistic number of overlapping waiters.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      37de98f8
    • R
      iommu/arm-smmu-v3: Forget about cmdq-sync interrupt · dce032a1
      Robin Murphy 提交于
      The cmdq-sync interrupt is never going to be particularly useful, since
      for stage 1 DMA at least we'll often need to wait for sync completion
      within someone else's IRQ handler, thus have to implement polling
      anyway. Beyond that, the overhead of taking an interrupt, then still
      having to grovel around in the queue to figure out *which* sync command
      completed, doesn't seem much more attractive than simple polling either.
      
      Furthermore, if an implementation both has wired interrupts and supports
      MSIs, then we don't want to be taking the IRQ unnecessarily if we're
      using the MSI write to update memory. Let's just make life simpler by
      not even bothering to claim it in the first place.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      dce032a1
    • R
      iommu/arm-smmu-v3: Specialise CMD_SYNC handling · 2f657add
      Robin Murphy 提交于
      CMD_SYNC already has a bit of special treatment here and there, but as
      we're about to extend it with more functionality for completing outside
      the CMDQ lock, things are going to get rather messy if we keep trying to
      cram everything into a single generic command interface. Instead, let's
      break out the issuing of CMD_SYNC into its own specific helper where
      upcoming changes will have room to breathe.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      2f657add
    • R
      iommu/arm-smmu-v3: Correct COHACC override message · 2a22baa2
      Robin Murphy 提交于
      Slightly confusingly, when reporting a mismatch of the ID register
      value, we still refer to the IORT COHACC override flag as the
      "dma-coherent property" if we booted with ACPI. Update the message
      to be firmware-agnostic in line with SMMUv2.
      Acked-by: NLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Reported-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      2a22baa2
    • Y
      iommu/arm-smmu-v3: Avoid ILLEGAL setting of STE.S1STALLD and CD.S · 9cff86fd
      Yisheng Xie 提交于
      According to Spec, it is ILLEGAL to set STE.S1STALLD if STALL_MODEL
      is not 0b00, which means we should not disable stall mode if stall
      or terminate mode is not configuable.
      
      Meanwhile, it is also ILLEGAL when STALL_MODEL==0b10 && CD.S==0 which
      means if stall mode is force we should always set CD.S.
      
      As Jean-Philippe's suggestion, this patch introduce a feature bit
      ARM_SMMU_FEAT_STALL_FORCE, which means smmu only supports stall force.
      Therefore, we can avoid the ILLEGAL setting of STE.S1STALLD.by checking
      ARM_SMMU_FEAT_STALL_FORCE.
      
      This patch keeps the ARM_SMMU_FEAT_STALLS as the meaning of stall supported
      (force or configuable) to easy to expand the future function, i.e. we can
      only use ARM_SMMU_FEAT_STALLS to check whether we should register fault
      handle or enable master can_stall, etc to supporte platform SVM.
      
      The feature bit, STE.S1STALLD and CD.S setting will be like:
      
      STALL_MODEL  FEATURE                                         S1STALLD CD.S
      0b00         ARM_SMMU_FEAT_STALLS                                 0b1 0b0
      0b01         !ARM_SMMU_FEAT_STALLS && !ARM_SMMU_FEAT_STALL_FORCE  0b0 0b0
      0b10         ARM_SMMU_FEAT_STALLS && ARM_SMMU_FEAT_STALL_FORCE    0b0 0b1
      
      after apply this patch.
      Signed-off-by: NYisheng Xie <xieyisheng1@huawei.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      9cff86fd
    • W
      iommu/arm-smmu-v3: Ensure we sync STE when only changing config field · 704c0382
      Will Deacon 提交于
      The SMMUv3 architecture permits caching of data structures deemed to be
      "reachable" by the SMU, which includes STEs marked as invalid. When
      transitioning an STE to a bypass/fault configuration at init or detach
      time, we mistakenly elide the CMDQ_OP_CFGI_STE operation in some cases,
      therefore potentially leaving the old STE state cached in the SMMU.
      
      This patch fixes the problem by ensuring that we perform the
      CMDQ_OP_CFGI_STE operation irrespective of the validity of the previous
      STE.
      Reviewed-by: NRobin Murphy <robin.murphy@arm.com>
      Reported-by: NEric Auger <eric.auger@redhat.com>
      Reviewed-by: NEric Auger <eric.auger@redhat.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      704c0382
    • R
      iommu/arm-smmu: Remove ACPICA workarounds · 6948d4a7
      Robin Murphy 提交于
      Now that the kernel headers have synced with the relevant upstream
      ACPICA updates, it's time to clean up the temporary local definitions.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      6948d4a7