Blob Blame History Raw
From: Joerg Roedel <jroedel@suse.de>
Date: Wed, 14 Aug 2019 15:01:17 +0200
Subject: [PATCH 01/11] iommu: Remember when default domain type was set on
 kernel command line
Patch-mainline: v5.4-rc1
Git-commit: faf1498993cdf65fd3a624b7653bc91909135a55
References: bsc#1136039

Introduce an extensible concept to remember when certain
configuration settings for the IOMMU code have been set on
the kernel command line.

This will be used later to prevent overwriting these
settings with other defaults.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
 drivers/iommu/iommu.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -43,6 +43,7 @@ static unsigned int iommu_def_domain_typ
 static unsigned int iommu_def_domain_type = IOMMU_DOMAIN_DMA;
 #endif
 static bool iommu_dma_strict __read_mostly = true;
+static u32 iommu_cmd_line __read_mostly;
 
 struct iommu_callback_data {
 	const struct iommu_ops *ops;
@@ -82,6 +83,18 @@ static const char * const iommu_group_re
 	[IOMMU_RESV_SW_MSI]	= "msi",
 };
 
+#define IOMMU_CMD_LINE_DMA_API		BIT(0)
+
+static void iommu_set_cmd_line_dma_api(void)
+{
+	iommu_cmd_line |= IOMMU_CMD_LINE_DMA_API;
+}
+
+static bool __maybe_unused iommu_cmd_line_dma_api(void)
+{
+	return !!(iommu_cmd_line & IOMMU_CMD_LINE_DMA_API);
+}
+
 #define IOMMU_GROUP_ATTR(_name, _mode, _show, _store)		\
 struct iommu_group_attribute iommu_group_attr_##_name =		\
 	__ATTR(_name, _mode, _show, _store)
@@ -126,6 +139,8 @@ static int __init iommu_set_def_domain_t
 	if (!str || strtobool(str, &pt))
 		return -EINVAL;
 
+	iommu_set_cmd_line_dma_api();
+
 	iommu_def_domain_type = pt ? IOMMU_DOMAIN_IDENTITY : IOMMU_DOMAIN_DMA;
 	return 0;
 }