uniontech inclusion
category: bugfix
bugzilla: NA
CVE: NA
Due to a problem with the IOMMU hardware of Phytium S2500/FT-2500,
running the following commands on a Phytium S2500/FT-2500 machine
will cause the system to hang
"dd if=/dev/zero of=tmp.img bs=1M count=409600"
and "I/O error" will be printed in the console.
This patch can solve the problem on Phytium S2500/FT-2500
by passthrough IOMMU.After installing the kernel using this patch,
use the following command to check the parameter "iommu.passthrough=on":
"cat /proc/cmdline"
Signed-off-by: Guo Hui <guohui(a)uniontech.com>
---
arch/arm64/include/asm/cputype.h | 4 ++++
init/main.c | 16 ++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/arch/arm64/include/asm/cputype.h b/arch/arm64/include/asm/cputype.h
index f33947af79d9..32687e4316fb 100644
--- a/arch/arm64/include/asm/cputype.h
+++ b/arch/arm64/include/asm/cputype.h
@@ -85,6 +85,8 @@
#define APM_CPU_PART_POTENZA 0x000
+#define PHYTIUM_CPU_PART_2500 0X663
+
#define CAVIUM_CPU_PART_THUNDERX 0x0A1
#define CAVIUM_CPU_PART_THUNDERX_81XX 0x0A2
#define CAVIUM_CPU_PART_THUNDERX_83XX 0x0A3
@@ -123,6 +125,8 @@
#define MIDR_NVIDIA_CARMEL MIDR_CPU_MODEL(ARM_CPU_IMP_NVIDIA, NVIDIA_CPU_PART_CARMEL)
#define MIDR_HISI_TSV110 MIDR_CPU_MODEL(ARM_CPU_IMP_HISI, HISI_CPU_PART_TSV110)
#define MIDR_HISI_TSV200 MIDR_CPU_MODEL(ARM_CPU_IMP_HISI, HISI_CPU_PART_TSV200)
+#define MIDR_FT_2500 MIDR_CPU_MODEL(ARM_CPU_IMP_PHYTIUM, \
+ PHYTIUM_CPU_PART_2500)
#ifndef __ASSEMBLY__
diff --git a/init/main.c b/init/main.c
index c149972b46ad..388d6bd3b5b3 100644
--- a/init/main.c
+++ b/init/main.c
@@ -473,6 +473,22 @@ void __init parse_early_param(void)
static int done __initdata;
static char tmp_cmdline[COMMAND_LINE_SIZE] __initdata;
+#ifdef CONFIG_ARM_GIC_PHYTIUM_2500
+ if ((read_cpuid_id() & MIDR_CPU_MODEL_MASK) == MIDR_FT_2500) {
+ char *iommu_cmd = " iommu.passthrough=on";
+ int iommu_cmd_len = strlen(iommu_cmd);
+ int boot_cmd_line_len = strlen(boot_command_line);
+ int last_args_len = COMMAND_LINE_SIZE - boot_cmd_line_len;
+
+ if (last_args_len >= (iommu_cmd_len + 1)) {
+ pr_info("FT S2500 iommu type: IOMMU_DOMAIN_IDENTITY");
+ strncat(boot_command_line, iommu_cmd, iommu_cmd_len);
+ } else {
+ pr_err("FT S2500 boot_cmd_line is too long, add 'iommu.passthrough=on' failed.");
+ }
+ }
+#endif
+
if (done)
return;
--
2.20.1