1. 23 Jul, 2014 9 commits
  2. 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
  3. 07 Jul, 2014 2 commits
  4. 04 Jul, 2014 18 commits
    • Alex Williamson's avatar
      iommu/amd: Add sysfs support · 066f2e98
      Alex Williamson authored
      AMD-Vi support for IOMMU sysfs.  This allows us to associate devices
      with a specific IOMMU device and examine the capabilities and features
      of that IOMMU.  The AMD IOMMU is hosted on and actual PCI device, so
      we make that device the parent for the IOMMU class device.  This
      initial implementaiton exposes only the capability header and extended
      features register for the IOMMU.
      
      # find /sys | grep ivhd
      /sys/devices/pci0000:00/0000:00:00.2/iommu/ivhd0
      /sys/devices/pci0000:00/0000:00:00.2/iommu/ivhd0/devices
      /sys/devices/pci0000:00/0000:00:00.2/iommu/ivhd0/devices/0000:00:00.0
      /sys/devices/pci0000:00/0000:00:00.2/iommu/ivhd0/devices/0000:00:02.0
      /sys/devices/pci0000:00/0000:00:00.2/iommu/ivhd0/devices/0000:00:04.0
      /sys/devices/pci0000:00/0000:00:00.2/iommu/ivhd0/devices/0000:00:09.0
      /sys/devices/pci0000:00/0000:00:00.2/iommu/ivhd0/devices/0000:00:11.0
      /sys/devices/pci0000:00/0000:00:00.2/iommu/ivhd0/devices/0000:00:12.0
      /sys/devices/pci0000:00/0000:00:00.2/iommu/ivhd0/devices/0000:00:12.2
      /sys/devices/pci0000:00/0000:00:00.2/iommu/ivhd0/devices/0000:00:13.0
      ...
      /sys/devices/pci0000:00/0000:00:00.2/iommu/ivhd0/power
      /sys/devices/pci0000:00/0000:00:00.2/iommu/ivhd0/power/control
      ...
      /sys/devices/pci0000:00/0000:00:00.2/iommu/ivhd0/device
      /sys/devices/pci0000:00/0000:00:00.2/iommu/ivhd0/subsystem
      /sys/devices/pci0000:00/0000:00:00.2/iommu/ivhd0/amd-iommu
      /sys/devices/pci0000:00/0000:00:00.2/iommu/ivhd0/amd-iommu/cap
      /sys/devices/pci0000:00/0000:00:00.2/iommu/ivhd0/amd-iommu/features
      /sys/devices/pci0000:00/0000:00:00.2/iommu/ivhd0/uevent
      /sys/class/iommu/ivhd0
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      066f2e98
    • Alex Williamson's avatar
      iommu/vt-d: Make use of IOMMU sysfs support · a5459cfe
      Alex Williamson authored
      Register our DRHD IOMMUs, cross link devices, and provide a base set
      of attributes for the IOMMU.  Note that IRQ remapping support parses
      the DMAR table very early in boot, well before the iommu_class can
      reasonably be setup, so our registration is split between
      intel_iommu_init(), which occurs later, and alloc_iommu(), which
      typically occurs much earlier, but may happen at any time later
      with IOMMU hot-add support.
      
      On a typical desktop system, this provides the following (pruned):
      
      $ find /sys | grep dmar
      /sys/devices/virtual/iommu/dmar0
      /sys/devices/virtual/iommu/dmar0/devices
      /sys/devices/virtual/iommu/dmar0/devices/0000:00:02.0
      /sys/devices/virtual/iommu/dmar0/intel-iommu
      /sys/devices/virtual/iommu/dmar0/intel-iommu/cap
      /sys/devices/virtual/iommu/dmar0/intel-iommu/ecap
      /sys/devices/virtual/iommu/dmar0/intel-iommu/address
      /sys/devices/virtual/iommu/dmar0/intel-iommu/version
      /sys/devices/virtual/iommu/dmar1
      /sys/devices/virtual/iommu/dmar1/devices
      /sys/devices/virtual/iommu/dmar1/devices/0000:00:00.0
      /sys/devices/virtual/iommu/dmar1/devices/0000:00:01.0
      /sys/devices/virtual/iommu/dmar1/devices/0000:00:16.0
      /sys/devices/virtual/iommu/dmar1/devices/0000:00:1a.0
      /sys/devices/virtual/iommu/dmar1/devices/0000:00:1b.0
      /sys/devices/virtual/iommu/dmar1/devices/0000:00:1c.0
      ...
      /sys/devices/virtual/iommu/dmar1/intel-iommu
      /sys/devices/virtual/iommu/dmar1/intel-iommu/cap
      /sys/devices/virtual/iommu/dmar1/intel-iommu/ecap
      /sys/devices/virtual/iommu/dmar1/intel-iommu/address
      /sys/devices/virtual/iommu/dmar1/intel-iommu/version
      /sys/class/iommu/dmar0
      /sys/class/iommu/dmar1
      
      (devices also link back to the dmar units)
      
      This makes address, version, capabilities, and extended capabilities
      available, just like printed on boot.  I've tried not to duplicate
      data that can be found in the DMAR table, with the exception of the
      address, which provides an easy way to associate the sysfs device with
      a DRHD entry in the DMAR.  It's tempting to add scopes and RMRR data
      here, but the full DMAR table is already exposed under /sys/firmware/
      and therefore already provides a way for userspace to learn such
      details.
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      a5459cfe
    • 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: Remove pci.h · fd2852d5
      Alex Williamson authored
      The single helper here no longer has any users.
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      fd2852d5
    • Alex Williamson's avatar
      iommu/fsl: Use iommu_group_get_for_dev() for IOMMU groups · 7319eded
      Alex Williamson authored
      Drop custom code and use IOMMU provided grouping support for PCI.
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      Acked-by: default avatarVarun Sethi <varun.sethi@freescale.com>
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      7319eded
    • Alex Williamson's avatar
      iommu/vt-d: Update to use PCI DMA aliases · 579305f7
      Alex Williamson authored
      VT-d code currently makes use of pci_find_upstream_pcie_bridge() in
      order to find the topology based alias of a device.  This function has
      a few problems.  First, it doesn't check the entire alias path of the
      device to the root bus, therefore if a PCIe device is masked upstream,
      the wrong result is produced.  Also, it's known to get confused and
      give up when it crosses a bridge from a conventional PCI bus to a PCIe
      bus that lacks a PCIe capability.  The PCI-core provided DMA alias
      support solves both of these problems and additionally adds support
      for DMA function quirks allowing VT-d to work with devices like
      Marvell and Ricoh with known broken requester IDs.
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      579305f7
    • Alex Williamson's avatar
      iommu/vt-d: Use iommu_group_get_for_dev() · e17f9ff4
      Alex Williamson authored
      The IOMMU code now provides a common interface for finding or
      creating an IOMMU group for a device on PCI buses.  Make use of it
      and remove piles of code.
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      e17f9ff4
    • Alex Williamson's avatar
      iommu/amd: Use iommu_group_get_for_dev() · 65d5352f
      Alex Williamson authored
      The common iommu_group_get_for_dev() allows us to greatly simplify
      our group lookup for a new device.  Also, since we insert IVRS
      aliases into the PCI DMA alias quirks, we should alway come up with
      the same results as the existing code.
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      Cc: Joerg Roedel <joro@8bytes.org>
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      65d5352f
    • Alex Williamson's avatar
      iommu/amd: Update to use PCI DMA aliases · c1931090
      Alex Williamson authored
      AMD-Vi already has a concept of an alias provided via the IVRS table.
      Now that PCI-core also understands aliases, we need to incorporate
      both aspects when programming the IOMMU.  IVRS is generally quite
      reliable, so we continue to prefer it when an alias is present.  For
      cases where we have an IVRS alias that does not match the PCI alias
      or where PCI does not report an alias, report the mismatch to allow
      us to collect more quirks and dynamically incorporate the alias into
      the device alias quirks where possible.
      
      This should allow AMD-Vi to work with devices like Marvell and Ricoh
      with DMA function alias quirks unknown to the BIOS.
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      Cc: Joerg Roedel <joro@8bytes.org>
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      c1931090
    • 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
    • Yijing Wang's avatar
      iommu/vt-d: Suppress compiler warnings · aa4d066a
      Yijing Wang authored
      suppress compiler warnings:
      drivers/iommu/intel-iommu.c: In function ‘device_to_iommu’:
      drivers/iommu/intel-iommu.c:673: warning: ‘segment’ may be used uninitialized in this function
      drivers/iommu/intel-iommu.c: In function ‘get_domain_for_dev.clone.3’:
      drivers/iommu/intel-iommu.c:2217: warning: ‘bridge_bus’ may be used uninitialized in this function
      drivers/iommu/intel-iommu.c:2217: warning: ‘bridge_devfn’ may be used uninitialized in this function
      Signed-off-by: default avatarYijing Wang <wangyijing@huawei.com>
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      aa4d066a
    • Yijing Wang's avatar
      effad4b5
    • Joerg Roedel's avatar
      iommu/vt-d: Don't use magic number in dma_pte_superpage · c3c75eb7
      Joerg Roedel authored
      Use the already defined DMA_PTE_LARGE_PAGE for testing
      instead of hardcoding the value again.
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      c3c75eb7
    • Yijing Wang's avatar
      iommu/vt-d: Fix reference count in iommu_prepare_isa · 9b27e82d
      Yijing Wang authored
      Decrease the device reference count avoid memory leak.
      Signed-off-by: default avatarYijing Wang <wangyijing@huawei.com>
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      9b27e82d
    • Yijing Wang's avatar
      iommu/vt-d: Use inline function dma_pte_superpage instead of macros · e16922af
      Yijing Wang authored
      Use inline function dma_pte_superpage() instead of macro for
      better readability.
      Signed-off-by: default avatarYijing Wang <wangyijing@huawei.com>
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      e16922af
    • Yijing Wang's avatar
      iommu/vt-d: Clear the redundant assignment for domain->nid · 8f9d41b4
      Yijing Wang authored
      Alloc_domain() will initialize domain->nid to -1. So the
      initialization for domain->nid in md_domain_init() is redundant,
      clear it.
      Signed-off-by: default avatarYijing Wang <wangyijing@huawei.com>
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      8f9d41b4
    • Yijing Wang's avatar
      iommu/vt-d: Clear the redundant assignment in dmar_enable_qi · 435bbb46
      Yijing Wang authored
      __dmar_enable_qi() will initialize free_head,free_tail and
      free_cnt for q_inval. Remove the redundant initialization
      in dmar_enable_qi().
      Signed-off-by: default avatarYijing Wang <wangyijing@huawei.com>
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      435bbb46
    • Yijing Wang's avatar
      iommu/vt-d: Use list_for_each_safe() to simplify code · 3a74ca01
      Yijing Wang authored
      Use list_for_each_entry_safe() instead of list_entry()
      to simplify code.
      Signed-off-by: default avatarYijing Wang <wangyijing@huawei.com>
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      3a74ca01
  5. 29 Jun, 2014 10 commits