1. 17 9月, 2014 3 次提交
    • W
      iommu/arm-smmu: put iommu_domain pointer in dev->archdata.iommu · 844e35bd
      Will Deacon 提交于
      In preparation for nested translation support, stick a pointer to the
      iommu_domain in dev->archdata.iommu. This makes it much easier to grab
      hold of the physical group configuration (e.g. cbndx) when dealing with
      vSMMU accesses from a guest.
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      844e35bd
    • W
      iommu/arm-smmu: add support for multi-master iommu groups · 8f68f8e2
      Will Deacon 提交于
      Whilst the driver currently creates one IOMMU group per device, this
      will soon change when we start supporting non-transparent PCI bridges
      which require all upstream masters to be assigned to the same address
      space.
      
      This patch reworks our IOMMU group code so that we can easily support
      multi-master groups. The master configuration (streamids and smrs) is
      stored as private iommudata on the group, whilst the low-level attach/detach
      code is updated to avoid double alloc/free when dealing with multiple
      masters sharing the same SMMU configuration. This unifies device
      handling, regardless of whether the device sits on the platform or pci
      bus.
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      8f68f8e2
    • W
      iommu/arm-smmu: allow translation stage to be forced on the cmdline · 4cf740b0
      Will Deacon 提交于
      When debugging and testing code on an SMMU that supports nested
      translation, it can be useful to restrict the driver to a particular
      stage of translation.
      
      This patch adds a module parameter to the ARM SMMU driver to allow this
      by restricting the ability of the probe() code to detect support for
      only the specified stage.
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      4cf740b0
  2. 02 9月, 2014 4 次提交
  3. 01 9月, 2014 3 次提交
    • V
      iommu/arm-smmu: remove pgtable_page_{c,d}tor() · 93b14135
      Vladimir Murzin 提交于
      If split page table lock for PTE tables is enabled (CONFIG_SPLIT_PTLOCK_CPUS
      <=NR_CPUS) pgtable_page_ctor() leads to non-atomic allocation for ptlock with
      a spinlock held, resulting in:
      
      ------------[ cut here ]------------
      WARNING: CPU: 0 PID: 466 at kernel/locking/lockdep.c:2742 lockdep_trace_alloc+0xd8/0xf4()
      DEBUG_LOCKS_WARN_ON(irqs_disabled_flags(flags))
      Modules linked in:
      CPU: 0 PID: 466 Comm: dma0chan0-copy0 Not tainted 3.16.0-3d47efb-clean-pl330-dma_test-ve-a15-a32-slr-m
      c-on-3+ #55
      [<80014748>] (unwind_backtrace) from [<80011640>] (show_stack+0x10/0x14)
      [<80011640>] (show_stack) from [<802bf864>] (dump_stack+0x80/0xb4)
      [<802bf864>] (dump_stack) from [<8002385c>] (warn_slowpath_common+0x64/0x88)
      [<8002385c>] (warn_slowpath_common) from [<80023914>] (warn_slowpath_fmt+0x30/0x40)
      [<80023914>] (warn_slowpath_fmt) from [<8005d818>] (lockdep_trace_alloc+0xd8/0xf4)
      [<8005d818>] (lockdep_trace_alloc) from [<800d3d78>] (kmem_cache_alloc+0x24/0x144)
      [<800d3d78>] (kmem_cache_alloc) from [<800bfae4>] (ptlock_alloc+0x18/0x2c)
      [<800bfae4>] (ptlock_alloc) from [<802b1ec0>] (arm_smmu_handle_mapping+0x4c0/0x690)
      [<802b1ec0>] (arm_smmu_handle_mapping) from [<802b0cd8>] (iommu_map+0xe0/0x148)
      [<802b0cd8>] (iommu_map) from [<80019098>] (arm_coherent_iommu_map_page+0x160/0x278)
      [<80019098>] (arm_coherent_iommu_map_page) from [<801f4d78>] (dmatest_func+0x60c/0x1098)
      [<801f4d78>] (dmatest_func) from [<8003f8ac>] (kthread+0xcc/0xe8)
      [<8003f8ac>] (kthread) from [<8000e868>] (ret_from_fork+0x14/0x2c)
      ---[ end trace ce0d27e6f434acf8 ]--
      
      Split page tables lock is not used in the driver. In fact, page tables are
      guarded with domain lock, so remove calls to pgtable_page_{c,d}tor().
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NVladimir Murzin <vladimir.murzin@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      93b14135
    • O
      iommu/arm-smmu: fix programming of SMMU_CBn_TCR for stage 1 · 1fc870c7
      Olav Haugan 提交于
      Stage-1 context banks do not have the SMMU_CBn_TCR[SL0] field since it
      is only applicable to stage-2 context banks.
      
      This patch ensures that we don't set the reserved TCR bits for stage-1
      translations.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NOlav Haugan <ohaugan@codeaurora.org>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      1fc870c7
    • M
      iommu/arm-smmu: avoid calling request_irq in atomic context · a18037b2
      Mitchel Humpherys 提交于
      request_irq shouldn't be called from atomic context since it might
      sleep, but we're calling it with a spinlock held, resulting in:
      
          [    9.172202] BUG: sleeping function called from invalid context at kernel/mm/slub.c:926
          [    9.182989] in_atomic(): 1, irqs_disabled(): 128, pid: 1, name: swapper/0
          [    9.189762] CPU: 1 PID: 1 Comm: swapper/0 Tainted: G        W    3.10.40-gbc1b510b-38437-g55831d3bd9-dirty #97
          [    9.199757] [<c020c448>] (unwind_backtrace+0x0/0x11c) from [<c02097d0>] (show_stack+0x10/0x14)
          [    9.208346] [<c02097d0>] (show_stack+0x10/0x14) from [<c0301d74>] (kmem_cache_alloc_trace+0x3c/0x210)
          [    9.217543] [<c0301d74>] (kmem_cache_alloc_trace+0x3c/0x210) from [<c0276a48>] (request_threaded_irq+0x88/0x11c)
          [    9.227702] [<c0276a48>] (request_threaded_irq+0x88/0x11c) from [<c0931ca4>] (arm_smmu_attach_dev+0x188/0x858)
          [    9.237686] [<c0931ca4>] (arm_smmu_attach_dev+0x188/0x858) from [<c0212cd8>] (arm_iommu_attach_device+0x18/0xd0)
          [    9.247837] [<c0212cd8>] (arm_iommu_attach_device+0x18/0xd0) from [<c093314c>] (arm_smmu_test_probe+0x68/0xd4)
          [    9.257823] [<c093314c>] (arm_smmu_test_probe+0x68/0xd4) from [<c05aadd0>] (driver_probe_device+0x12c/0x330)
          [    9.267629] [<c05aadd0>] (driver_probe_device+0x12c/0x330) from [<c05ab080>] (__driver_attach+0x68/0x8c)
          [    9.277090] [<c05ab080>] (__driver_attach+0x68/0x8c) from [<c05a92d4>] (bus_for_each_dev+0x70/0x84)
          [    9.286118] [<c05a92d4>] (bus_for_each_dev+0x70/0x84) from [<c05aa3b0>] (bus_add_driver+0x100/0x244)
          [    9.295233] [<c05aa3b0>] (bus_add_driver+0x100/0x244) from [<c05ab5d0>] (driver_register+0x9c/0x124)
          [    9.304347] [<c05ab5d0>] (driver_register+0x9c/0x124) from [<c0933088>] (arm_smmu_test_init+0x14/0x38)
          [    9.313635] [<c0933088>] (arm_smmu_test_init+0x14/0x38) from [<c0200618>] (do_one_initcall+0xb8/0x160)
          [    9.322926] [<c0200618>] (do_one_initcall+0xb8/0x160) from [<c1200b7c>] (kernel_init_freeable+0x108/0x1cc)
          [    9.332564] [<c1200b7c>] (kernel_init_freeable+0x108/0x1cc) from [<c0b924b0>] (kernel_init+0xc/0xe4)
          [    9.341675] [<c0b924b0>] (kernel_init+0xc/0xe4) from [<c0205e38>] (ret_from_fork+0x14/0x3c)
      
      Fix this by moving the request_irq out of the critical section. This
      should be okay since smmu_domain->smmu is still being protected by the
      critical section. Also, we still don't program the Stream Match Register
      until after registering our interrupt handler so we shouldn't be missing
      any interrupts.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NMitchel Humpherys <mitchelh@codeaurora.org>
      [will: code cleanup and fixed request_irq token parameter]
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      a18037b2
  4. 09 7月, 2014 1 次提交
    • M
      iommu/arm-smmu: fix some checkpatch issues · 2907320d
      Mitchel Humpherys 提交于
      Fix some issues reported by checkpatch.pl. Mostly whitespace, but also
      includes min=>min_t, kzalloc=>kcalloc, and kmalloc=>kmalloc_array.
      
      The only issue I'm leaving alone is:
      
          arm-smmu.c:853: WARNING: line over 80 characters
          #853: FILE: arm-smmu.c:853:
          +                     (MAIR_ATTR_WBRWA << MAIR_ATTR_SHIFT(MAIR_ATTR_IDX_CACHE)) |
      
      since it seems to be a case where "exceeding 80 columns significantly
      increases readability and does not hide information."
      (Documentation/CodingStyle).
      Signed-off-by: NMitchel Humpherys <mitchelh@codeaurora.org>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      2907320d
  5. 07 7月, 2014 1 次提交
  6. 04 7月, 2014 1 次提交
    • W
      iommu/arm-smmu: fix capability checking prior to device attach · d3bca166
      Will Deacon 提交于
      If somebody attempts to check the capability of an IOMMU domain prior to
      device attach, then we'll try to dereference a NULL SMMU pointer through
      the SMMU domain (since we can't determine the actual SMMU instance until
      we have a device attached).
      
      This patch fixes the capability check so that non-global features are
      reported as being absent when no device is attached to the domain.
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      d3bca166
  7. 03 7月, 2014 4 次提交
    • W
      iommu/arm-smmu: prefer stage-1 mappings where we have a choice · 9c5c92e3
      Will Deacon 提交于
      For an SMMU that supports both Stage-1 and Stage-2 mappings (but not
      nested translation), then we should prefer stage-1 mappings as we
      otherwise rely on the memory attributes of the incoming transactions
      for IOMMU_CACHE mappings.
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      9c5c92e3
    • W
      iommu/arm-smmu: remove support for chained SMMUs · 44680eed
      Will Deacon 提交于
      The ARM SMMU driver has supported chained SMMUs (i.e. SMMUs connected
      back-to-back in series) via the smmu-parent property in device tree.
      This was in anticipation of somebody building such a configuration,
      however that seems not to be the case.
      
      This patch removes the unused chained SMMU hack from the driver. We can
      consider adding it back later if somebody decided they need it, but for
      the time being it's just pointless mess that we're carrying in mainline.
      
      Removal of the feature also makes migration to the generic IOMMU bindings
      easier.
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      44680eed
    • W
      iommu/arm-smmu: caps: add IOMMU_CAP_INTR_REMAP capability · d0948945
      Will Deacon 提交于
      MSIs are just seen as bog standard memory writes by the ARM SMMU, so
      they can be translated (and isolated) in the same way.
      
      This patch adds the IOMMU_CAP_INTR_REMAP capability to the ARM SMMU
      driver and reworks our capabaility code so that we don't assume the
      caps are organised as bits in a bitmask (since this isn't the intention).
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      d0948945
    • W
      iommu/arm-smmu: add support for PCI master devices · a9a1b0b5
      Will Deacon 提交于
      This patch extends the ARM SMMU driver so that it can handle PCI master
      devices in addition to platform devices described in the device tree.
      
      The driver is informed about the PCI host controller in the DT via a
      phandle to the host controller in the mmu-masters property. The host
      controller is then added to the master tree for that SMMU, just like a
      normal master (although it probably doesn't advertise any StreamIDs).
      
      When a device is added to the PCI bus, we set the archdata.iommu pointer
      for that device to describe its StreamID (actually its RequesterID for
      the moment). This allows us to re-use our existing data structures using
      the host controller of_node for everything apart from StreamID
      configuration, where we reach into the archdata for the information we
      require.
      
      Cc: Varun Sethi <varun.sethi@freescale.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      a9a1b0b5
  8. 02 7月, 2014 1 次提交
  9. 02 5月, 2014 2 次提交
  10. 15 4月, 2014 2 次提交
  11. 28 2月, 2014 1 次提交
  12. 25 2月, 2014 4 次提交
  13. 20 2月, 2014 1 次提交
  14. 11 2月, 2014 5 次提交
    • W
      iommu/arm-smmu: fix compilation issue when !CONFIG_ARM_AMBA · d123cf82
      Will Deacon 提交于
      If !CONFIG_ARM_AMBA, we shouldn't try to register ourselves with the
      amba_bustype.
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      d123cf82
    • W
      iommu/arm-smmu: set CBARn.BPSHCFG to NSH for s1-s2-bypass contexts · 57ca90f6
      Will Deacon 提交于
      Whilst trying to bring-up an SMMUv2 implementation with the table
      walker plumbed into a coherent interconnect, I noticed that the memory
      transactions targetting the CPU caches from the SMMU were marked as
      outer-shareable instead of inner-shareable.
      
      After a bunch of digging, it seems that we actually need to program
      CBARn.BPSHCFG for s1-s2-bypass contexts to act as non-shareable in order
      for the shareability configured in the corresponding TTBCR not to be
      overridden with an outer-shareable attribute.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      57ca90f6
    • W
      iommu/arm-smmu: fix table flushing during initial allocations · 6dd35f45
      Will Deacon 提交于
      Now that we populate page tables as we traverse them ("iommu/arm-smmu:
      fix pud/pmd entry fill sequence"), we need to ensure that we flush out
      our zeroed tables after initial allocation, to prevent speculative TLB
      fills using bogus data.
      
      This patch adds additional calls to arm_smmu_flush_pgtable during
      initial table allocation, and moves the dsb required by coherent table
      walkers into the helper.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      6dd35f45
    • W
      iommu/arm-smmu: really fix page table locking · c9d09e27
      Will Deacon 提交于
      Commit a44a9791 ("iommu/arm-smmu: use mutex instead of spinlock for
      locking page tables") replaced the page table spinlock with a mutex, to
      allow blocking allocations to satisfy lazy mapping requests.
      
      Unfortunately, it turns out that IOMMU mappings are created from atomic
      context (e.g. spinlock held during a dma_map), so this change doesn't
      really help us in practice.
      
      This patch is a partial revert of the offending commit, bringing back
      the original spinlock but replacing our page table allocations for any
      levels below the pgd (which is allocated during domain init) with
      GFP_ATOMIC instead of GFP_KERNEL.
      
      Cc: <stable@vger.kernel.org>
      Reported-by: NAndreas Herrmann <andreas.herrmann@calxeda.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      c9d09e27
    • Y
      iommu/arm-smmu: fix pud/pmd entry fill sequence · 97a64420
      Yifan Zhang 提交于
      The ARM SMMU driver's population of puds and pmds is broken, since we
      iterate over the next level of table repeatedly setting the current
      level descriptor to point at the pmd being initialised. This is clearly
      wrong when dealing with multiple pmds/puds.
      
      This patch fixes the problem by moving the pud/pmd population out of the
      loop and instead performing it when we allocate the next level (like we
      correctly do for ptes already). The starting address for the next level
      is then calculated prior to entering the loop.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NYifan Zhang <zhangyf@marvell.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      97a64420
  15. 17 12月, 2013 3 次提交
  16. 07 12月, 2013 3 次提交
  17. 15 11月, 2013 1 次提交