1. 05 Apr, 2016 1 commit
    • Arnd Bergmann's avatar
      iommu: provide of_xlate pointer unconditionally · b70bb984
      Arnd Bergmann authored
      
      
      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: default avatarArnd Bergmann <arnd@arndb.de>
      Fixes: 0df4fabe
      
       ("iommu/mediatek: Add mt8173 IOMMU driver")
      Reviewed-by: default avatarRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      b70bb984
  2. 29 Jan, 2016 1 commit
  3. 21 Oct, 2015 3 commits
  4. 15 Oct, 2015 1 commit
    • Robin Murphy's avatar
      iommu: Implement common IOMMU ops for DMA mapping · 0db2e5d1
      Robin Murphy authored
      
      
      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: default avatarRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      0db2e5d1
  5. 17 Jul, 2015 1 commit
    • Nicolas Iooss's avatar
      include, lib: add __printf attributes to several function prototypes · 8db14860
      Nicolas Iooss authored
      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: default avatarNicolas 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: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      8db14860
  6. 11 Jun, 2015 1 commit
  7. 09 Jun, 2015 3 commits
  8. 31 Mar, 2015 3 commits
  9. 01 Dec, 2014 2 commits
  10. 14 Nov, 2014 2 commits
  11. 04 Nov, 2014 1 commit
    • Olav Haugan's avatar
      iommu: Add iommu_map_sg() function · 315786eb
      Olav Haugan authored
      
      
      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: default avatarOlav Haugan <ohaugan@codeaurora.org>
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      315786eb
  12. 29 Sep, 2014 1 commit
    • Will Deacon's avatar
      iommu: introduce domain attribute for nesting IOMMUs · c02607aa
      Will Deacon authored
      
      
      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: default avatarJoerg Roedel <jroedel@suse.de>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      c02607aa
  13. 25 Sep, 2014 3 commits
  14. 08 Jul, 2014 1 commit
    • Alex Williamson's avatar
      iommu: Fix IOMMU sysfs stubs · e09f8ea5
      Alex Williamson authored
      
      
      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: default avatarAlex Williamson <alex.williamson@redhat.com>
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      e09f8ea5
  15. 07 Jul, 2014 1 commit
  16. 04 Jul, 2014 2 commits
    • Alex Williamson's avatar
      iommu: Add sysfs support for IOMMUs · c61959ec
      Alex Williamson authored
      
      
      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: default avatarAlex Williamson <alex.williamson@redhat.com>
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      c61959ec
    • Alex Williamson's avatar
      iommu/core: Create central IOMMU group lookup/creation interface · 104a1c13
      Alex Williamson authored
      
      
      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: default avatarAlex Williamson <alex.williamson@redhat.com>
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      104a1c13
  17. 07 Jan, 2014 1 commit
  18. 30 Dec, 2013 1 commit
  19. 16 Dec, 2013 1 commit
  20. 25 Sep, 2013 1 commit
    • Shuah Khan's avatar
      iommu: Change iommu driver to call io_page_fault trace event · 56fa4849
      Shuah Khan authored
      
      
      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: default avatarShuah Khan <shuah.kh@samsung.com>
      Signed-off-by: default avatarJoerg Roedel <joro@8bytes.org>
      56fa4849
  21. 14 Aug, 2013 1 commit
  22. 24 Apr, 2013 1 commit
  23. 19 Apr, 2013 1 commit
  24. 02 Apr, 2013 2 commits
  25. 06 Feb, 2013 4 commits