]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
iommu: Add "iommu.strict" command line option
authorZhen Lei <thunder.leizhen@huawei.com>
Thu, 20 Sep 2018 16:10:23 +0000 (17:10 +0100)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Mon, 14 Jan 2019 09:28:55 +0000 (09:28 +0000)
BugLink: https://bugs.launchpad.net/bugs/1806488
Add a generic command line option to enable lazy unmapping via IOVA
flush queues, which will initally be suuported by iommu-dma. This echoes
the semantics of "intel_iommu=strict" (albeit with the opposite default
value), but in the driver-agnostic fashion of "iommu.passthrough".

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
[rm: move handling out of SMMUv3 driver, clean up documentation]
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
[will: dropped broken printk when parsing command-line option]
Signed-off-by: Will Deacon <will.deacon@arm.com>
(backported from commit 68a6efe86f6a16e25556a2aff40efad41097b486)
[ dannf: Trival context fix in drivers/iommu/iommu.c ]
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Documentation/admin-guide/kernel-parameters.txt
drivers/iommu/iommu.c

index 551e635f1097fc12219eb2021fc02f47a7e2298a..43b61d87c9a399a1de400ef853f78fa37b97f256 100644 (file)
                nobypass        [PPC/POWERNV]
                        Disable IOMMU bypass, using IOMMU for PCI devices.
 
+       iommu.strict=   [ARM64] Configure TLB invalidation behaviour
+                       Format: { "0" | "1" }
+                       0 - Lazy mode.
+                         Request that DMA unmap operations use deferred
+                         invalidation of hardware TLBs, for increased
+                         throughput at the cost of reduced device isolation.
+                         Will fall back to strict mode if not supported by
+                         the relevant IOMMU driver.
+                       1 - Strict mode (default).
+                         DMA unmap operations invalidate IOMMU hardware TLBs
+                         synchronously.
+
        iommu.passthrough=
                        [ARM64] Configure DMA to bypass the IOMMU by default.
                        Format: { "0" | "1" }
index 3de5c0bcb5cc9f32b6fb615ce38f5729ae86d407..09acf6ed42dd47cd47a7d0674dacbc1da2ac3d48 100644 (file)
@@ -37,6 +37,7 @@
 static struct kset *iommu_group_kset;
 static DEFINE_IDA(iommu_group_ida);
 static unsigned int iommu_def_domain_type = IOMMU_DOMAIN_DMA;
+static bool iommu_dma_strict __read_mostly = true;
 
 struct iommu_callback_data {
        const struct iommu_ops *ops;
@@ -125,6 +126,12 @@ static int __init iommu_set_def_domain_type(char *str)
 }
 early_param("iommu.passthrough", iommu_set_def_domain_type);
 
+static int __init iommu_dma_setup(char *str)
+{
+       return kstrtobool(str, &iommu_dma_strict);
+}
+early_param("iommu.strict", iommu_dma_setup);
+
 static ssize_t iommu_group_attr_show(struct kobject *kobj,
                                     struct attribute *__attr, char *buf)
 {
@@ -1035,6 +1042,13 @@ struct iommu_group *iommu_group_get_for_dev(struct device *dev)
                group->default_domain = dom;
                if (!group->domain)
                        group->domain = dom;
+
+               if (dom && !iommu_dma_strict) {
+                       int attr = 1;
+                       iommu_domain_set_attr(dom,
+                                             DOMAIN_ATTR_DMA_USE_FLUSH_QUEUE,
+                                             &attr);
+               }
        }
 
        ret = iommu_group_add_device(group, dev);