linuxtorvalds / rpms / kernel

Forked from rpms/kernel 2 years ago
Clone
Justin Vreeland 794d92
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Justin Vreeland 794d92
From: Laura Abbott <labbott@redhat.com>
Justin Vreeland 794d92
Date: Mon, 20 May 2019 22:21:02 -0400
Justin Vreeland 794d92
Subject: [PATCH] iommu/arm-smmu: workaround DMA mode issues
Justin Vreeland 794d92
Justin Vreeland 794d92
Message-id: <20190520222102.19488-1-labbott@redhat.com>
Justin Vreeland 794d92
Patchwork-id: 259215
Justin Vreeland 794d92
O-Subject: [ARK INTERNAL PATCH] iommu/arm-smmu: workaround DMA mode issues
Justin Vreeland 794d92
Bugzilla:
Justin Vreeland 794d92
RH-Acked-by: Mark Langsdorf <mlangsdo@redhat.com>
Justin Vreeland 794d92
RH-Acked-by: Mark Salter <msalter@redhat.com>
Justin Vreeland 794d92
Justin Vreeland 794d92
From: Mark Salter <msalter@redhat.com>
Justin Vreeland 794d92
Justin Vreeland 794d92
Rebased for v5.2-rc1
Justin Vreeland 794d92
Justin Vreeland 794d92
	Bugzilla: 1652259
Justin Vreeland 794d92
	Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=19244562
Justin Vreeland 794d92
	Upstream status: RHEL only.
Justin Vreeland 794d92
Justin Vreeland 794d92
	rhel8 commit 65feb1ed0ec9a088a63a90d46c0f7563ac96ad0f
Justin Vreeland 794d92
	Author: Mark Salter <msalter@redhat.com>
Justin Vreeland 794d92
	Date:   Wed Nov 21 17:15:59 2018 +0100
Justin Vreeland 794d92
Justin Vreeland 794d92
	    [iommu] iommu/arm-smmu: workaround DMA mode issues
Justin Vreeland 794d92
Justin Vreeland 794d92
	    Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1624077
Justin Vreeland 794d92
	    Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=18112820
Justin Vreeland 794d92
	    Testing: Verified iommu.passthrough=1 no longer needed on gigabyte platforms.
Justin Vreeland 794d92
	    Upstream Status: RHEL-only
Justin Vreeland 794d92
Justin Vreeland 794d92
	    In RHEL_ALT 7.5 we carried a RHEL-only patch which forced the arm smmuv2
Justin Vreeland 794d92
	    into bypass mode due to performance issues on CN88xx. This was intended
Justin Vreeland 794d92
	    to be a temporary hack until the issues were resolved. Another vendor
Justin Vreeland 794d92
	    had issues with the iommu in bypass mode so we reverted the RHEL-only
Justin Vreeland 794d92
	    patch so that iommu is in DMA mode by default (upstream default).
Justin Vreeland 794d92
Justin Vreeland 794d92
	    It turns on that there are remaining SMMU DMA mode issues on Gigabyte
Justin Vreeland 794d92
	    platformws with CN88xx cpus. The problem manifests itself by pcie
Justin Vreeland 794d92
	    card drivers failing to initialize the cards when SMMU is in DMA mode.
Justin Vreeland 794d92
	    The root cause has not been determined yet, but looks likely to be
Justin Vreeland 794d92
	    a hw or firmware issue. This patch forces bypass mode for Gigabyte
Justin Vreeland 794d92
	    platforms. CN88xx isn't officially supported in RHEL but we have a
Justin Vreeland 794d92
	    lot of them being used internally for testing, so I think we want
Justin Vreeland 794d92
	    this to support that use case in RHEL8.
Justin Vreeland 794d92
Justin Vreeland 794d92
	    Signed-off-by: Mark Salter <msalter@redhat.com>
Justin Vreeland 794d92
	    Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
Justin Vreeland 794d92
Justin Vreeland 794d92
	Acked-by: Mark Salter <msalter@redhat.com>
Justin Vreeland 794d92
	Acked-by: Donald Dutile <ddutile@redhat.com>
Justin Vreeland 794d92
Justin Vreeland 794d92
Upstream Status: RHEL only
Justin Vreeland 794d92
Signed-off-by: Laura Abbott <labbott@redhat.com>
Justin Vreeland 794d92
---
Justin Vreeland 794d92
 drivers/iommu/iommu.c | 22 ++++++++++++++++++++++
Justin Vreeland 794d92
 1 file changed, 22 insertions(+)
Justin Vreeland 794d92
Justin Vreeland 794d92
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
Justin Vreeland 794d92
index 609bd25bf154..c701912b13ab 100644
Justin Vreeland 794d92
--- a/drivers/iommu/iommu.c
Justin Vreeland 794d92
+++ b/drivers/iommu/iommu.c
Justin Vreeland 794d92
@@ -7,6 +7,7 @@
Justin Vreeland 794d92
 #define pr_fmt(fmt)    "iommu: " fmt
Justin Vreeland 794d92
Justin Vreeland 794d92
 #include <linux/device.h>
Justin Vreeland 794d92
+#include <linux/dmi.h>
Justin Vreeland 794d92
 #include <linux/kernel.h>
Justin Vreeland 794d92
 #include <linux/bug.h>
Justin Vreeland 794d92
 #include <linux/types.h>
Justin Vreeland 794d92
@@ -2849,3 +2850,24 @@ int iommu_sva_get_pasid(struct iommu_sva *handle)
Justin Vreeland 794d92
 	return ops->sva_get_pasid(handle);
Justin Vreeland 794d92
 }
Justin Vreeland 794d92
 EXPORT_SYMBOL_GPL(iommu_sva_get_pasid);
Justin Vreeland 794d92
+
Justin Vreeland 794d92
+#ifdef CONFIG_ARM64
Justin Vreeland 794d92
+static int __init iommu_quirks(void)
Justin Vreeland 794d92
+{
Justin Vreeland 794d92
+	const char *vendor, *name;
Justin Vreeland 794d92
+
Justin Vreeland 794d92
+	vendor = dmi_get_system_info(DMI_SYS_VENDOR);
Justin Vreeland 794d92
+	name = dmi_get_system_info(DMI_PRODUCT_NAME);
Justin Vreeland 794d92
+
Justin Vreeland 794d92
+	if (vendor &&
Justin Vreeland 794d92
+	    (strncmp(vendor, "GIGABYTE", 8) == 0 && name &&
Justin Vreeland 794d92
+	     (strncmp(name, "R120", 4) == 0 ||
Justin Vreeland 794d92
+	      strncmp(name, "R270", 4) == 0))) {
Justin Vreeland 794d92
+		pr_warn("Gigabyte %s detected, force iommu passthrough mode", name);
Justin Vreeland 794d92
+		iommu_def_domain_type = IOMMU_DOMAIN_IDENTITY;
Justin Vreeland 794d92
+	}
Justin Vreeland 794d92
+
Justin Vreeland 794d92
+	return 0;
Justin Vreeland 794d92
+}
Justin Vreeland 794d92
+arch_initcall(iommu_quirks);
Justin Vreeland 794d92
+#endif
Justin Vreeland 794d92
-- 
Justin Vreeland 794d92
2.28.0
Justin Vreeland 794d92