Presently, the default domain of a group is allocated during boot time and it
cannot be changed later. So, the device would typically be either in identity
(pass_through) mode or the device would be in DMA mode as long as the
system is up and running. There is no way to change the default domain type
dynamically i.e. after booting, a device cannot switch between identity mode and
DMA mode.

Assume a use case where-in the priviliged user would want to use the device in
pass-through mode when the device is used for host so that it would be high
performing. Presently, this is not supported and hence add support to change the
default domain of a group dynamically.

Support this through a sysfs file, namely 
"/sys/kernel/iommu_groups/<grp_id>/type".

Changes from RFC:
-----------------
1. Added support for "auto" type, so that kernel selects one among identity or
   dma mode.
2. Use "system_state" in device_def_domain_type() instead of an argument.

Testing:
--------
Tested by dynamically changing network device from
1. identity mode to dma and making sure ping works
2. dma mode to identity mode and making sure ping works
Tested only for intel_iommu/vt-d. Haven't tested on other architectures.

Sai Praneeth Prakhya (4):
  iommu/vt-d: Modify device_def_domain_type() to use at runtime
  iommu: Add device_def_domain_type() call back function to iommu_ops
  iommu: Add support to change default domain of an iommu_group
  iommu: Document usage of "/sys/kernel/iommu_groups/<grp_id>/type" file

 .../ABI/testing/sysfs-kernel-iommu_groups     |  35 +++
 drivers/iommu/intel-iommu.c                   |  44 +++-
 drivers/iommu/iommu.c                         | 232 +++++++++++++++++-
 include/linux/iommu.h                         |   4 +
 4 files changed, 301 insertions(+), 14 deletions(-)

Cc: Christoph Hellwig <[email protected]>
Cc: Joerg Roedel <[email protected]>
Cc: Ashok Raj <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: Lu Baolu <[email protected]>
Cc: Sohil Mehta <[email protected]>
Cc: Robin Murphy <[email protected]>
Cc: Jacob Pan <[email protected]>
Signed-off-by: Sai Praneeth Prakhya <[email protected]>

-- 
2.19.1
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reply via email to