1. 19 1月, 2017 1 次提交
  2. 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
  3. 15 11月, 2016 1 次提交
  4. 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
  5. 13 7月, 2016 1 次提交
  6. 09 5月, 2016 2 次提交
  7. 07 4月, 2016 1 次提交
  8. 05 4月, 2016 1 次提交
    • A
      iommu: provide of_xlate pointer unconditionally · b70bb984
      Arnd Bergmann 提交于
      iommu drivers that support the standard DT bindings use a of_xlate
      callback pointer, but that is only part of struct iommu_ops when
      CONFIG_OF_IOMMU is enabled, leading to build errors in randconfig
      builds when that is not provided:
      
      drivers/iommu/mtk_iommu.c:497:2: error: unknown field 'of_xlate' specified in initializer
        .of_xlate = mtk_iommu_of_xlate,
        ^
      drivers/iommu/mtk_iommu.c:497:14: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
        .of_xlate = mtk_iommu_of_xlate,
                    ^~~~~~~~~~~~~~~~~~
      drivers/iommu/mtk_iommu.c:497:14: note: (near initialization for 'mtk_iommu_ops.domain_get_attr')
      
      We can work around it by adding more #ifdefs in each driver, but
      it seems nicer to just allow setting the pointer even if it is
      unused. This makes the driver code look nicer, and it gives better
      compile-time coverage when test building on other architectures.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Fixes: 0df4fabe ("iommu/mediatek: Add mt8173 IOMMU driver")
      Reviewed-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      b70bb984
  9. 29 1月, 2016 1 次提交
  10. 22 10月, 2015 3 次提交
  11. 15 10月, 2015 1 次提交
    • R
      iommu: Implement common IOMMU ops for DMA mapping · 0db2e5d1
      Robin Murphy 提交于
      Taking inspiration from the existing arch/arm code, break out some
      generic functions to interface the DMA-API to the IOMMU-API. This will
      do the bulk of the heavy lifting for IOMMU-backed dma-mapping.
      
      Since associating an IOVA allocator with an IOMMU domain is a fairly
      common need, rather than introduce yet another private structure just to
      do this for ourselves, extend the top-level struct iommu_domain with the
      notion. A simple opaque cookie allows reuse by other IOMMU API users
      with their various different incompatible allocator types.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      0db2e5d1
  12. 18 7月, 2015 1 次提交
    • N
      include, lib: add __printf attributes to several function prototypes · 8db14860
      Nicolas Iooss 提交于
      Using __printf attributes helps to detect several format string issues
      at compile time (even though -Wformat-security is currently disabled in
      Makefile).  For example it can detect when formatting a pointer as a
      number, like the issue fixed in commit a3fa71c4 ("wl18xx: show
      rx_frames_per_rates as an array as it really is"), or when the arguments
      do not match the format string, c.f.  for example commit 5ce1aca8
      ("reiserfs: fix __RASSERT format string").
      
      To prevent similar bugs in the future, add a __printf attribute to every
      function prototype which needs one in include/linux/ and lib/.  These
      functions were mostly found by using gcc's -Wsuggest-attribute=format
      flag.
      Signed-off-by: NNicolas Iooss <nicolas.iooss_linux@m4x.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Felipe Balbi <balbi@ti.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8db14860
  13. 11 6月, 2015 1 次提交
  14. 09 6月, 2015 3 次提交
  15. 31 3月, 2015 3 次提交
  16. 02 12月, 2014 2 次提交
  17. 14 11月, 2014 2 次提交
  18. 04 11月, 2014 1 次提交
    • O
      iommu: Add iommu_map_sg() function · 315786eb
      Olav Haugan 提交于
      Mapping and unmapping are more often than not in the critical path.
      map_sg allows IOMMU driver implementations to optimize the process
      of mapping buffers into the IOMMU page tables.
      
      Instead of mapping a buffer one page at a time and requiring potentially
      expensive TLB operations for each page, this function allows the driver
      to map all pages in one go and defer TLB maintenance until after all
      pages have been mapped.
      
      Additionally, the mapping operation would be faster in general since
      clients does not have to keep calling map API over and over again for
      each physically contiguous chunk of memory that needs to be mapped to a
      virtually contiguous region.
      Signed-off-by: NOlav Haugan <ohaugan@codeaurora.org>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      315786eb
  19. 30 9月, 2014 1 次提交
    • W
      iommu: introduce domain attribute for nesting IOMMUs · c02607aa
      Will Deacon 提交于
      Some IOMMUs, such as the ARM SMMU, support two stages of translation.
      The idea behind such a scheme is to allow a guest operating system to
      use the IOMMU for DMA mappings in the first stage of translation, with
      the hypervisor then installing mappings in the second stage to provide
      isolation of the DMA to the physical range assigned to that virtual
      machine.
      
      In order to allow IOMMU domains to be used for second-stage translation,
      this patch adds a new iommu_attr (IOMMU_ATTR_NESTING) for setting
      second-stage domains prior to device attach. The attribute can also be
      queried to see if a domain is actually making use of nesting.
      Acked-by: NJoerg Roedel <jroedel@suse.de>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      c02607aa
  20. 25 9月, 2014 3 次提交
  21. 08 7月, 2014 1 次提交
    • A
      iommu: Fix IOMMU sysfs stubs · e09f8ea5
      Alex Williamson 提交于
      0-day kernel build testing reports:
      
         arch/x86/kvm/x86.o: In function `iommu_device_destroy':
      >> (.text+0x7a0a): multiple definition of `iommu_device_destroy'
         arch/x86/kvm/../../../virt/kvm/vfio.o:vfio.c:(.text+0x490): first defined here
         arch/x86/kvm/x86.o: In function `iommu_device_link':
      >> (.text+0x7a15): multiple definition of `iommu_device_link'
         arch/x86/kvm/../../../virt/kvm/vfio.o:vfio.c:(.text+0x49b): first defined here
         arch/x86/kvm/x86.o: In function `iommu_device_unlink':
      >> (.text+0x7a25): multiple definition of `iommu_device_unlink'
         arch/x86/kvm/../../../virt/kvm/vfio.o:vfio.c:(.text+0x4ab): first defined here
         arch/x86/kvm/x86.o: In function `iommu_device_create':
      >> (.text+0x79f8): multiple definition of `iommu_device_create'
         arch/x86/kvm/../../../virt/kvm/vfio.o:vfio.c:(.text+0x47e): first defined here
      
      These are due to failing to define the stubs as static inline.  Fix.
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      e09f8ea5
  22. 07 7月, 2014 1 次提交
  23. 04 7月, 2014 2 次提交
    • A
      iommu: Add sysfs support for IOMMUs · c61959ec
      Alex Williamson 提交于
      IOMMUs currently have no common representation to userspace, most
      seem to have no representation at all aside from a few printks
      on bootup.  There are however features of IOMMUs that are useful
      to know about.  For instance the IOMMU might support superpages,
      making use of processor large/huge pages more important in a device
      assignment scenario.  It's also useful to create cross links between
      devices and IOMMU hardware units, so that users might be able to
      load balance their devices to avoid thrashing a single hardware unit.
      
      This patch adds a device create and destroy interface as well as
      device linking, making it very lightweight for an IOMMU driver to add
      basic support.  IOMMU drivers can provide additional attributes
      automatically by using an attribute_group.
      
      The attributes exposed are expected to be relatively device specific,
      the means to retrieve them certainly are, so there are currently no
      common attributes for the new class created here.
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      c61959ec
    • A
      iommu/core: Create central IOMMU group lookup/creation interface · 104a1c13
      Alex Williamson 提交于
      Currently each IOMMU driver that supports IOMMU groups has its own
      code for discovering the base device used in grouping.  This code
      is generally not specific to the IOMMU hardware, but to the bus of
      the devices managed by the IOMMU.  We can therefore create a common
      interface for supporting devices on different buses.
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      104a1c13
  24. 07 1月, 2014 1 次提交
  25. 30 12月, 2013 1 次提交
  26. 17 12月, 2013 1 次提交
  27. 25 9月, 2013 1 次提交
    • S
      iommu: Change iommu driver to call io_page_fault trace event · 56fa4849
      Shuah Khan 提交于
      Change iommu driver call io_page_fault trace event. This iommu_error class
      event can be enabled to trigger when an iommu error occurs. Trace information
      includes driver name, device name, iova, and flags.
      
      Testing:
      Added trace calls to iommu_prepare_identity_map() for testing some of the
      conditions that are hard to trigger. Here is the trace from the testing:
      
             swapper/0-1     [003] ....     2.003774: io_page_fault: IOMMU:pci 0000:00:02.0 iova=0x00000000cb800000 flags=0x0002
             swapper/0-1     [003] ....     2.004098: io_page_fault: IOMMU:pci 0000:00:1d.0 iova=0x00000000cadc6000 flags=0x0002
             swapper/0-1     [003] ....     2.004115: io_page_fault: IOMMU:pci 0000:00:1a.0 iova=0x00000000cadc6000 flags=0x0002
             swapper/0-1     [003] ....     2.004129: io_page_fault: IOMMU:pci 0000:00:1f.0 iova=0x0000000000000000 flags=0x0002
      Signed-off-by: NShuah Khan <shuah.kh@samsung.com>
      Signed-off-by: NJoerg Roedel <joro@8bytes.org>
      56fa4849
  28. 14 8月, 2013 1 次提交