1. 18 8月, 2017 1 次提交
    • R
      iommu: Avoid NULL group dereference · 1464d0b1
      Robin Murphy 提交于
      The recently-removed FIXME in iommu_get_domain_for_dev() turns out to
      have been a little misleading, since that check is still worthwhile even
      when groups *are* universal. We have a few IOMMU-aware drivers which
      only care whether their device is already attached to an existing domain
      or not, for which the previous behaviour of iommu_get_domain_for_dev()
      was ideal, and who now crash if their device does not have an IOMMU.
      
      With IOMMU groups now serving as a reliable indicator of whether a
      device has an IOMMU or not (barring false-positives from VFIO no-IOMMU
      mode), drivers could arguably do this:
      
      	group = iommu_group_get(dev);
      	if (group) {
      		domain = iommu_get_domain_for_dev(dev);
      		iommu_group_put(group);
      	}
      
      However, rather than duplicate that code across multiple callsites,
      particularly when it's still only the domain they care about, let's skip
      straight to the next step and factor out the check into the common place
      it applies - in iommu_get_domain_for_dev() itself. Sure, it ends up
      looking rather familiar, but now it's backed by the reasoning of having
      a robust API able to do the expected thing for all devices regardless.
      
      Fixes: 05f80300 ("iommu: Finish making iommu_group support mandatory")
      Reported-by: NShawn Lin <shawn.lin@rock-chips.com>
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      1464d0b1
  2. 10 8月, 2017 1 次提交
    • R
      iommu: Finish making iommu_group support mandatory · 05f80300
      Robin Murphy 提交于
      Now that all the drivers properly implementing the IOMMU API support
      groups (I'm ignoring the etnaviv GPU MMUs which seemingly only do just
      enough to convince the ARM DMA mapping ops), we can remove the FIXME
      workarounds from the core code. In the process, it also seems logical to
      make the .device_group callback non-optional for drivers calling
      iommu_group_get_for_dev() - the current callers all implement it anyway,
      and it doesn't make sense for any future callers not to either.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      05f80300
  3. 28 6月, 2017 2 次提交
  4. 27 4月, 2017 1 次提交
  5. 20 4月, 2017 1 次提交
  6. 06 4月, 2017 1 次提交
    • W
      iommu: Allow default domain type to be set on the kernel command line · fccb4e3b
      Will Deacon 提交于
      The IOMMU core currently initialises the default domain for each group
      to IOMMU_DOMAIN_DMA, under the assumption that devices will use
      IOMMU-backed DMA ops by default. However, in some cases it is desirable
      for the DMA ops to bypass the IOMMU for performance reasons, reserving
      use of translation for subsystems such as VFIO that require it for
      enforcing device isolation.
      
      Rather than modify each IOMMU driver to provide different semantics for
      DMA domains, instead we introduce a command line parameter that can be
      used to change the type of the default domain. Passthrough can then be
      specified using "iommu.passthrough=1" on the kernel command line.
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      fccb4e3b
  7. 22 3月, 2017 1 次提交
    • 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
  8. 10 2月, 2017 4 次提交
  9. 06 2月, 2017 2 次提交
  10. 23 1月, 2017 5 次提交
  11. 17 1月, 2017 1 次提交
    • R
      iommu: Handle default domain attach failure · 797a8b4d
      Robin Murphy 提交于
      We wouldn't normally expect ops->attach_dev() to fail, but on IOMMUs
      with limited hardware resources, or generally misconfigured systems,
      it is certainly possible. We report failure correctly from the external
      iommu_attach_device() interface, but do not do so in iommu_group_add()
      when attaching to the default domain. The result of failure there is
      that the device, group and domain all get left in a broken,
      part-configured state which leads to weird errors and misbehaviour down
      the line when IOMMU API calls sort-of-but-don't-quite work.
      
      Check the return value of __iommu_attach_device() on the default domain,
      and refactor the error handling paths to cope with its failure and clean
      up correctly in such cases.
      
      Fixes: e39cb8a3 ("iommu: Make sure a device is always attached to a domain")
      Reported-by: NPunit Agrawal <punit.agrawal@arm.com>
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      797a8b4d
  12. 29 11月, 2016 1 次提交
    • L
      iommu: Make of_iommu_set/get_ops() DT agnostic · e4f10ffe
      Lorenzo Pieralisi 提交于
      The of_iommu_{set/get}_ops() API is used to associate a device
      tree node with a specific set of IOMMU operations. The same
      kernel interface is required on systems booting with ACPI, where
      devices are not associated with a device tree node, therefore
      the interface requires generalization.
      
      The struct device fwnode member represents the fwnode token associated
      with the device and the struct it points at is firmware specific;
      regardless, it is initialized on both ACPI and DT systems and makes an
      ideal candidate to use it to associate a set of IOMMU operations to a
      given device, through its struct device.fwnode member pointer, paving
      the way for representing per-device iommu_ops (ie an iommu instance
      associated with a device).
      
      Convert the DT specific of_iommu_{set/get}_ops() interface to
      use struct device.fwnode as a look-up token, making the interface
      usable on ACPI systems and rename the data structures and the
      registration API so that they are made to represent their usage
      more clearly.
      Signed-off-by: NLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Acked-by: NWill Deacon <will.deacon@arm.com>
      Reviewed-by: NRobin Murphy <robin.murphy@arm.com>
      Reviewed-by: NTomasz Nowicki <tn@semihalf.com>
      Tested-by: NHanjun Guo <hanjun.guo@linaro.org>
      Tested-by: NTomasz Nowicki <tn@semihalf.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Hanjun Guo <hanjun.guo@linaro.org>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Joerg Roedel <joro@8bytes.org>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      e4f10ffe
  13. 15 11月, 2016 1 次提交
  14. 16 9月, 2016 1 次提交
    • R
      iommu: Introduce iommu_fwspec · 57f98d2f
      Robin Murphy 提交于
      Introduce a common structure to hold the per-device firmware data that
      most IOMMU drivers need to keep track of. This enables us to configure
      much of that data from common firmware code, and consolidate a lot of
      the equivalent implementations, device look-up tables, etc. which are
      currently strewn across IOMMU drivers.
      
      This will also be enable us to address the outstanding "multiple IOMMUs
      on the platform bus" problem by tweaking IOMMU API calls to prefer
      dev->fwspec->ops before falling back to dev->bus->iommu_ops, and thus
      gracefully handle those troublesome systems which we currently cannot.
      
      As the first user, hook up the OF IOMMU configuration mechanism. The
      driver-defined nature of DT cells means that we still need the drivers
      to translate and add the IDs themselves, but future users such as the
      much less free-form ACPI IORT will be much simpler and self-contained.
      
      CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Suggested-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>
      57f98d2f
  15. 13 7月, 2016 3 次提交
  16. 09 5月, 2016 1 次提交
    • R
      iommu: Allow selecting page sizes per domain · d16e0faa
      Robin Murphy 提交于
      Many IOMMUs support multiple page table formats, meaning that any given
      domain may only support a subset of the hardware page sizes presented in
      iommu_ops->pgsize_bitmap. There are also certain use-cases where the
      creator of a domain may want to control which page sizes are used, for
      example to force the use of hugepage mappings to reduce pagetable walk
      depth.
      
      To this end, add a per-domain pgsize_bitmap to represent the subset of
      page sizes actually in use, to make it possible for domains with
      different requirements to coexist.
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      [rm: hijacked and rebased original patch with new commit message]
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Acked-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      d16e0faa
  17. 12 4月, 2016 1 次提交
  18. 07 4月, 2016 1 次提交
  19. 25 2月, 2016 1 次提交
  20. 16 12月, 2015 1 次提交
    • D
      Revert "scatterlist: use sg_phys()" · 3e6110fd
      Dan Williams 提交于
      commit db0fa0cb "scatterlist: use sg_phys()" did replacements of
      the form:
      
          phys_addr_t phys = page_to_phys(sg_page(s));
          phys_addr_t phys = sg_phys(s) & PAGE_MASK;
      
      However, this breaks platforms where sizeof(phys_addr_t) >
      sizeof(unsigned long).  Revert for 4.3 and 4.4 to make room for a
      combined helper in 4.5.
      
      Cc: <stable@vger.kernel.org>
      Cc: Jens Axboe <axboe@fb.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Russell King <linux@arm.linux.org.uk>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Fixes: db0fa0cb ("scatterlist: use sg_phys()")
      Suggested-by: NJoerg Roedel <joro@8bytes.org>
      Reported-by: NVitaly Lavrov <vel21ripn@gmail.com>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      3e6110fd
  21. 22 10月, 2015 5 次提交
  22. 17 8月, 2015 1 次提交
    • D
      scatterlist: use sg_phys() · db0fa0cb
      Dan Williams 提交于
      Coccinelle cleanup to replace open coded sg to physical address
      translations.  This is in preparation for introducing scatterlists that
      reference __pfn_t.
      
      // sg_phys.cocci: convert usage page_to_phys(sg_page(sg)) to sg_phys(sg)
      // usage: make coccicheck COCCI=sg_phys.cocci MODE=patch
      
      virtual patch
      
      @@
      struct scatterlist *sg;
      @@
      
      - page_to_phys(sg_page(sg)) + sg->offset
      + sg_phys(sg)
      
      @@
      struct scatterlist *sg;
      @@
      
      - page_to_phys(sg_page(sg))
      + sg_phys(sg) & PAGE_MASK
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      db0fa0cb
  23. 30 6月, 2015 1 次提交
  24. 11 6月, 2015 2 次提交