1. 25 9月, 2014 5 次提交
    • M
      iommu: Fix bus notifier breakage · fb3e3065
      Mark Salter 提交于
      iommu_bus_init() registers a bus notifier on the given bus by using
      a statically defined notifier block:
      
        static struct notifier_block iommu_bus_nb = {
                .notifier_call = iommu_bus_notifier,
        };
      
      This same notifier block is used for all busses. This causes a
      problem for notifiers registered after iommu has registered this
      callback on multiple busses. The problem is that a subsequent
      notifier being registered on a bus which has this iommu notifier
      will also get linked in to the notifier list of all other busses
      which have this iommu notifier.
      
      This patch fixes this by allocating the notifier_block at runtime.
      Some error checking is also added to catch any allocation failure
      or notifier registration error.
      Signed-off-by: NMark Salter <msalter@redhat.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      fb3e3065
    • A
      iommu: Rework iommu_group_get_for_pci_dev() · f096c061
      Alex Williamson 提交于
      It turns out that our assumption that aliases are always to the same
      slot isn't true.  One particular platform reports an IVRS alias of the
      SATA controller (00:11.0) for the legacy IDE controller (00:14.1).
      When we hit this, we attempt to use a single IOMMU group for
      everything on the same bus, which in this case is the root complex.
      We already have multiple groups defined for the root complex by this
      point, resulting in multiple WARN_ON hits.
      
      This patch makes these sorts of aliases work again with IOMMU groups
      by reworking how we search through the PCI address space to find
      existing groups.  This should also now handle looped dependencies and
      all sorts of crazy inter-dependencies that we'll likely never see.
      
      The recursion used here should never be very deep.  It's unlikely to
      have individual aliases and only theoretical that we'd ever see a
      chain where one alias causes us to search through to yet another
      alias.  We're also only dealing with PCIe device on a single bus,
      which means we'll typically only see multiple slots in use on the root
      complex.  Loops are also a theoretically possibility, which I've
      tested using fake DMA alias quirks and prevent from causing problems
      using a bitmap of the devfn space that's been visited.
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      Cc: stable@vger.kernel.org # 3.17
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      f096c061
    • J
      iommu: Remove iommu_domain_has_cap() API function · 24278a24
      Joerg Roedel 提交于
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      24278a24
    • J
      iommu: Introduce iommu_capable API function · 3c0e0ca0
      Joerg Roedel 提交于
      This function will replace the current iommu_domain_has_cap
      function and clean up the interface while at it.
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      3c0e0ca0
    • J
      iommu: Convert iommu-caps from define to enum · 1aed0748
      Joerg Roedel 提交于
      Allow compile-time type-checking.
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      1aed0748
  2. 26 8月, 2014 1 次提交
  3. 19 8月, 2014 1 次提交
  4. 07 7月, 2014 1 次提交
  5. 04 7月, 2014 1 次提交
  6. 24 9月, 2013 8 次提交
    • F
      iommu: No need to pass '0x' when '%pa' is used · abedb049
      Fabio Estevam 提交于
      Commit 6197ca82 (iommu: Use %pa and %zx instead of casting) introduced the
      usage of '%pa', but still kept the '0x', which leads to printing '0x0x'.
      
      Remove the '0x' when '%pa' is used.
      Signed-off-by: NFabio Estevam <fabio.estevam@freescale.com>
      Signed-off-by: NJoerg Roedel <joro@8bytes.org>
      abedb049
    • S
      iommu: Change iommu driver to call unmap trace event · 3a50639c
      Shuah Khan 提交于
      Change iommu driver to call unmap trace event. This iommu_map_unmap class
      event can be enabled to trigger when iommu unmap iommu ops is called. Trace
      information includes iova, physical address (map event only), and size.
      
      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] ....     1.854102: unmap: IOMMU: iova=0x00000000cb800000 size=0x400
      Signed-off-by: NShuah Khan <shuah.kh@samsung.com>
      Signed-off-by: NJoerg Roedel <joro@8bytes.org>
      3a50639c
    • S
      iommu: Change iommu driver to call map trace event · e0be7c86
      Shuah Khan 提交于
      Change iommu driver to call map trace event. This iommu_map_unmap class event
      can be enabled to trigger when iommu map iommu ops is called. Trace information
      includes iova, physical address (map event only), and size.
      
      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] ....     1.854102: map: IOMMU: iova=0x00000000cb800000 paddr=0x00000000cf9fffff size=0x400
      Signed-off-by: NShuah Khan <shuah.kh@samsung.com>
      Signed-off-by: NJoerg Roedel <joro@8bytes.org>
      e0be7c86
    • S
      iommu: Change iommu driver to call detach_device_to_domain trace event · 69980630
      Shuah Khan 提交于
      Change iommu driver to call detach_device_to_domain trace event. This
      iommu_device class event can be enabled to trigger when devices are detached
      from a domain. Trace information includes device name.
      
      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] ....     1.854102: detach_device_from_domain: IOMMU: device=0000:00:02.0
      Signed-off-by: NShuah Khan <shuah.kh@samsung.com>
      Signed-off-by: NJoerg Roedel <joro@8bytes.org>
      69980630
    • S
      iommu: Change iommu driver to call attach_device_to_domain trace event · b54db778
      Shuah Khan 提交于
      Change iommu driver to call attach_device_to_domain trace event. This
      iommu_device class event can be enabled to trigger when devices are attached
      to a domain. Trace information includes device name.
      
      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] ....     1.854102: attach_device_to_domain: IOMMU: device=0000:00:02.0
      Signed-off-by: NShuah Khan <shuah.kh@samsung.com>
      Signed-off-by: NJoerg Roedel <joro@8bytes.org>
      b54db778
    • S
      iommu: Change iommu driver to call remove_device_to_group trace event · 2e757086
      Shuah Khan 提交于
      Change iommu driver to call remove_device_to_group trace event. This
      iommu_group class event can be enabled to trigger when devices get
      removed from an iommu group. Trace information includes iommu group id and
      device name.
      
      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] ....     1.854101: remove_device_from_group: IOMMU: groupID=0 device=0000:00:02.0
      Signed-off-by: NShuah Khan <shuah.kh@samsung.com>
      Signed-off-by: NJoerg Roedel <joro@8bytes.org>
      2e757086
    • S
      iommu: Change iommu driver to call add_device_to_group trace event · d1cf7e82
      Shuah Khan 提交于
      Change iommu driver to call add_device_to_group trace event. This iommu_group
      class event can be enabled to trigger when devices get added to an iommu group.
      Trace information includes iommu group id and device name.
      
      Testing:
      The following is trace is generated when intel-iommu driver adds devices to
      to iommu groups during boot-time during its initialization:
      
             swapper/0-1     [003] ....     1.854793: add_device_to_group: IOMMU: groupID=0 device=0000:00:00.0
             swapper/0-1     [003] ....     1.854797: add_device_to_group: IOMMU: groupID=1 device=0000:00:02.0
      Signed-off-by: NShuah Khan <shuah.kh@samsung.com>
      Signed-off-by: NJoerg Roedel <joro@8bytes.org>
      d1cf7e82
    • S
      iommu: Add event tracing feature to iommu · 7f6db171
      Shuah Khan 提交于
      Add tracing feature to iommu to report various iommu events. Classes
      iommu_group, iommu_device, and iommu_map_unmap are defined.
      
      iommu_group class events can be enabled to trigger when devices get added
      to and removed from an iommu group. Trace information includes iommu group
      id and device name.
      
      iommu:add_device_to_group
      iommu:remove_device_from_group
      
      iommu_device class events can be enabled to trigger when devices are attached
      to and detached from a domain. Trace information includes device name.
      
      iommu:attach_device_to_domain
      iommu:detach_device_from_domain
      
      iommu_map_unmap class events can be enabled to trigger when iommu map and
      unmap iommu ops. Trace information includes iova, physical address (map event
      only), and size.
      
      iommu:map
      iommu:unmap
      Signed-off-by: NShuah Khan <shuah.kh@samsung.com>
      Signed-off-by: NJoerg Roedel <joro@8bytes.org>
      7f6db171
  7. 24 6月, 2013 1 次提交
  8. 23 6月, 2013 1 次提交
  9. 20 6月, 2013 1 次提交
    • A
      iommu: Split iommu_unmaps · bd13969b
      Alex Williamson 提交于
      iommu_map splits requests into pages that the iommu driver reports
      that it can handle.  The iommu_unmap path does not do the same.  This
      can cause problems not only from callers that might expect the same
      behavior as the map path, but even from the failure path of iommu_map,
      should it fail at a point where it has mapped and needs to unwind a
      set of pages that the iommu driver cannot handle directly.  amd_iommu,
      for example, will BUG_ON if asked to unmap a non power of 2 size.
      
      Fix this by extracting and generalizing the sizing code from the
      iommu_map path and use it for both map and unmap.
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      Signed-off-by: NJoerg Roedel <joro@8bytes.org>
      bd13969b
  10. 25 4月, 2013 1 次提交
  11. 03 4月, 2013 2 次提交
  12. 06 2月, 2013 4 次提交
  13. 11 1月, 2013 1 次提交
    • A
      iommu: moving initialization earlier · 097e3635
      Alexey Kardashevskiy 提交于
      The iommu_init() initializes IOMMU internal structures and data
      required for the IOMMU API as iommu_group_alloc().
      It is registered as a subsys_initcall now.
      
      One of the IOMMU users is going to be a PCI subsystem on POWER.
      It discovers new IOMMU tables during the PCI scan so the logical
      place to call iommu_group_alloc() is the moment when a new group
      is discovered. However PCI scan is done from subsys_initcall hook
      as IOMMU does so PCI hook can be (and is) called before the IOMMU one.
      
      The patch moves IOMMU subsystem initialization one step earlier
      to make sure that IOMMU is initialized before PCI scan begins.
      Signed-off-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      Signed-off-by: NJoerg Roedel <joro@8bytes.org>
      097e3635
  14. 11 7月, 2012 2 次提交
  15. 25 6月, 2012 1 次提交
    • A
      iommu: IOMMU Groups · d72e31c9
      Alex Williamson 提交于
      IOMMU device groups are currently a rather vague associative notion
      with assembly required by the user or user level driver provider to
      do anything useful.  This patch intends to grow the IOMMU group concept
      into something a bit more consumable.
      
      To do this, we first create an object representing the group, struct
      iommu_group.  This structure is allocated (iommu_group_alloc) and
      filled (iommu_group_add_device) by the iommu driver.  The iommu driver
      is free to add devices to the group using it's own set of policies.
      This allows inclusion of devices based on physical hardware or topology
      limitations of the platform, as well as soft requirements, such as
      multi-function trust levels or peer-to-peer protection of the
      interconnects.  Each device may only belong to a single iommu group,
      which is linked from struct device.iommu_group.  IOMMU groups are
      maintained using kobject reference counting, allowing for automatic
      removal of empty, unreferenced groups.  It is the responsibility of
      the iommu driver to remove devices from the group
      (iommu_group_remove_device).
      
      IOMMU groups also include a userspace representation in sysfs under
      /sys/kernel/iommu_groups.  When allocated, each group is given a
      dynamically assign ID (int).  The ID is managed by the core IOMMU group
      code to support multiple heterogeneous iommu drivers, which could
      potentially collide in group naming/numbering.  This also keeps group
      IDs to small, easily managed values.  A directory is created under
      /sys/kernel/iommu_groups for each group.  A further subdirectory named
      "devices" contains links to each device within the group.  The iommu_group
      file in the device's sysfs directory, which formerly contained a group
      number when read, is now a link to the iommu group.  Example:
      
      $ ls -l /sys/kernel/iommu_groups/26/devices/
      total 0
      lrwxrwxrwx. 1 root root 0 Apr 17 12:57 0000:00:1e.0 ->
      		../../../../devices/pci0000:00/0000:00:1e.0
      lrwxrwxrwx. 1 root root 0 Apr 17 12:57 0000:06:0d.0 ->
      		../../../../devices/pci0000:00/0000:00:1e.0/0000:06:0d.0
      lrwxrwxrwx. 1 root root 0 Apr 17 12:57 0000:06:0d.1 ->
      		../../../../devices/pci0000:00/0000:00:1e.0/0000:06:0d.1
      
      $ ls -l  /sys/kernel/iommu_groups/26/devices/*/iommu_group
      [truncating perms/owner/timestamp]
      /sys/kernel/iommu_groups/26/devices/0000:00:1e.0/iommu_group ->
      					../../../kernel/iommu_groups/26
      /sys/kernel/iommu_groups/26/devices/0000:06:0d.0/iommu_group ->
      					../../../../kernel/iommu_groups/26
      /sys/kernel/iommu_groups/26/devices/0000:06:0d.1/iommu_group ->
      					../../../../kernel/iommu_groups/26
      
      Groups also include several exported functions for use by user level
      driver providers, for example VFIO.  These include:
      
      iommu_group_get(): Acquires a reference to a group from a device
      iommu_group_put(): Releases reference
      iommu_group_for_each_dev(): Iterates over group devices using callback
      iommu_group_[un]register_notifier(): Allows notification of device add
              and remove operations relevant to the group
      iommu_group_id(): Return the group number
      
      This patch also extends the IOMMU API to allow attaching groups to
      domains.  This is currently a simple wrapper for iterating through
      devices within a group, but it's expected that the IOMMU API may
      eventually make groups a more integral part of domains.
      
      Groups intentionally do not try to manage group ownership.  A user
      level driver provider must independently acquire ownership for each
      device within a group before making use of the group as a whole.
      This may change in the future if group usage becomes more pervasive
      across both DMA and IOMMU ops.
      
      Groups intentionally do not provide a mechanism for driver locking
      or otherwise manipulating driver matching/probing of devices within
      the group.  Such interfaces are generic to devices and beyond the
      scope of IOMMU groups.  If implemented, user level providers have
      ready access via iommu_group_for_each_dev and group notifiers.
      
      iommu_device_group() is removed here as it has no users.  The
      replacement is:
      
      	group = iommu_group_get(dev);
      	id = iommu_group_id(group);
      	iommu_group_put(group);
      
      AMD-Vi & Intel VT-d support re-added in following patches.
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      Acked-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: NJoerg Roedel <joerg.roedel@amd.com>
      d72e31c9
  16. 23 5月, 2012 1 次提交
    • O
      iommu/core: pass a user-provided token to fault handlers · 77ca2332
      Ohad Ben-Cohen 提交于
      Sometimes a single IOMMU user may have to deal with several
      different IOMMU devices (e.g. remoteproc).
      
      When an IOMMU fault happens, such users have to regain their
      context in order to deal with the fault.
      
      Users can't use the private fields of neither the iommu_domain nor
      the IOMMU device, because those are already used by the IOMMU core
      and low level driver (respectively).
      
      This patch just simply allows users to pass a private token (most
      notably their own context pointer) to iommu_set_fault_handler(),
      and then makes sure it is provided back to the users whenever
      an IOMMU fault happens.
      
      The patch also adopts remoteproc to the new fault handling
      interface, but the real functionality using this (recovery of
      remote processors) will only be added later in a subsequent patch
      set.
      
      Cc: Fernando Guzman Lugo <fernando.lugo@ti.com>
      Signed-off-by: NOhad Ben-Cohen <ohad@wizery.com>
      Signed-off-by: NJoerg Roedel <joerg.roedel@amd.com>
      77ca2332
  17. 16 12月, 2011 1 次提交
  18. 15 11月, 2011 1 次提交
    • A
      iommu: Add iommu_device_group callback and iommu_group sysfs entry · 1460432c
      Alex Williamson 提交于
      An IOMMU group is a set of devices for which the IOMMU cannot
      distinguish transactions.  For PCI devices, a group often occurs
      when a PCI bridge is involved.  Transactions from any device
      behind the bridge appear to be sourced from the bridge itself.
      We leave it to the IOMMU driver to define the grouping restraints
      for their platform.
      
      Using this new interface, the group for a device can be retrieved
      using the iommu_device_group() callback.  Users will compare the
      value returned against the value returned for other devices to
      determine whether they are part of the same group.  Devices with
      no group are not translated by the IOMMU.  There should be no
      expectations about the group numbers as they may be arbitrarily
      assigned by the IOMMU driver and may not be persistent across boots.
      
      We also provide a sysfs interface to the group numbers here so
      that userspace can understand IOMMU dependencies between devices
      for managing safe, userspace drivers.
      
      [Some code changes by Joerg Roedel <joerg.roedel@amd.com>]
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      Signed-off-by: NJoerg Roedel <joerg.roedel@amd.com>
      1460432c
  19. 10 11月, 2011 3 次提交
    • O
      iommu/core: remove the temporary pgsize settings · 6c274d1c
      Ohad Ben-Cohen 提交于
      Now that all IOMMU drivers are exporting their supported pgsizes,
      we can remove the default pgsize settings in register_iommu().
      Signed-off-by: NOhad Ben-Cohen <ohad@wizery.com>
      Signed-off-by: NJoerg Roedel <joerg.roedel@amd.com>
      6c274d1c
    • O
      iommu/core: split mapping to page sizes as supported by the hardware · 7d3002cc
      Ohad Ben-Cohen 提交于
      When mapping a memory region, split it to page sizes as supported
      by the iommu hardware. Always prefer bigger pages, when possible,
      in order to reduce the TLB pressure.
      
      The logic to do that is now added to the IOMMU core, so neither the iommu
      drivers themselves nor users of the IOMMU API have to duplicate it.
      
      This allows a more lenient granularity of mappings; traditionally the
      IOMMU API took 'order' (of a page) as a mapping size, and directly let
      the low level iommu drivers handle the mapping, but now that the IOMMU
      core can split arbitrary memory regions into pages, we can remove this
      limitation, so users don't have to split those regions by themselves.
      
      Currently the supported page sizes are advertised once and they then
      remain static. That works well for OMAP and MSM but it would probably
      not fly well with intel's hardware, where the page size capabilities
      seem to have the potential to be different between several DMA
      remapping devices.
      
      register_iommu() currently sets a default pgsize behavior, so we can convert
      the IOMMU drivers in subsequent patches. After all the drivers
      are converted, the temporary default settings will be removed.
      
      Mainline users of the IOMMU API (kvm and omap-iovmm) are adopted
      to deal with bytes instead of page order.
      
      Many thanks to Joerg Roedel <Joerg.Roedel@amd.com> for significant review!
      Signed-off-by: NOhad Ben-Cohen <ohad@wizery.com>
      Cc: David Brown <davidb@codeaurora.org>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Joerg Roedel <Joerg.Roedel@amd.com>
      Cc: Stepan Moskovchenko <stepanm@codeaurora.org>
      Cc: KyongHo Cho <pullip.cho@samsung.com>
      Cc: Hiroshi DOYU <hdoyu@nvidia.com>
      Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
      Cc: kvm@vger.kernel.org
      Signed-off-by: NJoerg Roedel <joerg.roedel@amd.com>
      7d3002cc
    • O
      iommu/core: stop converting bytes to page order back and forth · 5009065d
      Ohad Ben-Cohen 提交于
      Express sizes in bytes rather than in page order, to eliminate the
      size->order->size conversions we have whenever the IOMMU API is calling
      the low level drivers' map/unmap methods.
      
      Adopt all existing drivers.
      Signed-off-by: NOhad Ben-Cohen <ohad@wizery.com>
      Cc: David Brown <davidb@codeaurora.org>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Joerg Roedel <Joerg.Roedel@amd.com>
      Cc: Stepan Moskovchenko <stepanm@codeaurora.org>
      Cc: KyongHo Cho <pullip.cho@samsung.com>
      Cc: Hiroshi DOYU <hdoyu@nvidia.com>
      Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
      Signed-off-by: NJoerg Roedel <joerg.roedel@amd.com>
      5009065d
  20. 21 10月, 2011 3 次提交