From e796284434b0f2abae7d56cf734caef176a2c9fc Mon Sep 17 00:00:00 2001 From: Max Krummenacher Date: Tue, 3 Dec 2019 19:40:57 +0100 Subject: linux-toradex-rt_4.14-2.0.x: prevent bug backtraces Signed-off-by: Max Krummenacher --- ...-imx_sc_thermal-prevent-BUG-with-rt-patch.patch | 53 ++++++++++++++++++++++ .../0002-ddr-perf-prevent-BUG-with-rt-patch.patch | 34 ++++++++++++++ .../linux/linux-toradex-rt_4.14-2.0.x.bb | 2 + 3 files changed, 89 insertions(+) create mode 100644 recipes-kernel/linux/linux-toradex-rt-4.14-2.0.x/0001-imx_sc_thermal-prevent-BUG-with-rt-patch.patch create mode 100644 recipes-kernel/linux/linux-toradex-rt-4.14-2.0.x/0002-ddr-perf-prevent-BUG-with-rt-patch.patch (limited to 'recipes-kernel/linux') diff --git a/recipes-kernel/linux/linux-toradex-rt-4.14-2.0.x/0001-imx_sc_thermal-prevent-BUG-with-rt-patch.patch b/recipes-kernel/linux/linux-toradex-rt-4.14-2.0.x/0001-imx_sc_thermal-prevent-BUG-with-rt-patch.patch new file mode 100644 index 0000000..c796fa4 --- /dev/null +++ b/recipes-kernel/linux/linux-toradex-rt-4.14-2.0.x/0001-imx_sc_thermal-prevent-BUG-with-rt-patch.patch @@ -0,0 +1,53 @@ +From 4e6114a23a21db5741375070add8ccc16697db67 Mon Sep 17 00:00:00 2001 +From: Max Krummenacher +Date: Tue, 24 Sep 2019 14:15:50 +0200 +Subject: [PATCH 1/2] imx_sc_thermal: prevent BUG() with rt patch + +With the RT patch applied the kernel prints a BUG backtrace during boot: + +| BUG: using smp_processor_id() in preemptible [00000000] code: swapper/0/1 + +Prevent this by avoiding the smp_processor_id call and just check the both +CPU clusters which may be there in a i.MX8 series SoC. + +Signed-off-by: Max Krummenacher +--- + drivers/thermal/imx_sc_thermal.c | 13 +++++++------ + 1 file changed, 7 insertions(+), 6 deletions(-) + +diff --git a/drivers/thermal/imx_sc_thermal.c b/drivers/thermal/imx_sc_thermal.c +index 8c5049020cd8..51a6c73315ba 100644 +--- a/drivers/thermal/imx_sc_thermal.c ++++ b/drivers/thermal/imx_sc_thermal.c +@@ -58,6 +58,7 @@ sc_ipc_t tsens_ipcHandle; + static int imx_sc_tsens_get_temp(void *data, int *temp) + { + struct imx_sc_sensor *sensor = data; ++ int hw_id; + sc_err_t sciErr; + int16_t celsius; + int8_t tenths; +@@ -65,14 +66,14 @@ static int imx_sc_tsens_get_temp(void *data, int *temp) + sciErr = sc_misc_get_temp(tsens_ipcHandle, sensor->hw_id, + SC_C_TEMP, &celsius, &tenths); + /* +- * if the SS power domain is down, read temp will fail, so +- * we can return the temp of CPU domain instead. ++ * if the SS power domain is down, read temp will fail, ++ * try the temp of the potentially two CPU domains instead. + */ +- if (sciErr != SC_ERR_NONE) { +- sciErr = sc_misc_get_temp(tsens_ipcHandle, +- sensor_hw_id[topology_physical_package_id(smp_processor_id())], ++ hw_id = 0; ++ while (sciErr != SC_ERR_NONE) { ++ sciErr = sc_misc_get_temp(tsens_ipcHandle, sensor_hw_id[hw_id++], + SC_C_TEMP, &celsius, &tenths); +- if (sciErr != SC_ERR_NONE) { ++ if (hw_id > 1) { + pr_err("read temp sensor:%d failed\n", sensor->hw_id); + return -EINVAL; + } +-- +2.20.1 + diff --git a/recipes-kernel/linux/linux-toradex-rt-4.14-2.0.x/0002-ddr-perf-prevent-BUG-with-rt-patch.patch b/recipes-kernel/linux/linux-toradex-rt-4.14-2.0.x/0002-ddr-perf-prevent-BUG-with-rt-patch.patch new file mode 100644 index 0000000..9296878 --- /dev/null +++ b/recipes-kernel/linux/linux-toradex-rt-4.14-2.0.x/0002-ddr-perf-prevent-BUG-with-rt-patch.patch @@ -0,0 +1,34 @@ +From 066e66d9222f70d3e21a7df077ac6b623881c9cc Mon Sep 17 00:00:00 2001 +From: Max Krummenacher +Date: Tue, 24 Sep 2019 14:19:24 +0200 +Subject: [PATCH 2/2] ddr-perf: prevent BUG() with rt patch + +With the RT patch applied the kernel prints a BUG backtrace during boot: + +| BUG: using smp_processor_id() in preemptible [00000000] code: swapper/0/1 + +Prevent this by replacing the smp_processor_id() call with a get_cpu() .. +put_cpu() construct. + +Signed-off-by: Max Krummenacher +--- + drivers/perf/ddr-perf.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/drivers/perf/ddr-perf.c b/drivers/perf/ddr-perf.c +index 73fe52ee8b95..744a6454d6a4 100644 +--- a/drivers/perf/ddr-perf.c ++++ b/drivers/perf/ddr-perf.c +@@ -470,7 +470,8 @@ static int ddr_perf_probe(struct platform_device *pdev) + + pmu->devtype = (struct fsl_ddr_devtype_data *)of_id->data; + +- cpumask_set_cpu(smp_processor_id(), &pmu->cpu); ++ cpumask_set_cpu(get_cpu(), &pmu->cpu); ++ put_cpu(); + ret = perf_pmu_register(&(pmu->pmu), name, -1); + if (ret) + goto ddr_perf_err; +-- +2.20.1 + diff --git a/recipes-kernel/linux/linux-toradex-rt_4.14-2.0.x.bb b/recipes-kernel/linux/linux-toradex-rt_4.14-2.0.x.bb index f69e1e2..e2ebd82 100644 --- a/recipes-kernel/linux/linux-toradex-rt_4.14-2.0.x.bb +++ b/recipes-kernel/linux/linux-toradex-rt_4.14-2.0.x.bb @@ -8,6 +8,8 @@ SUMMARY = "Real-Time Linux kernel for Toradex Freescale i.MX based modules" MIRRORS += "${KERNELORG_MIRROR}/linux/kernel/projects/rt/4.14/older/ ${KERNELORG_MIRROR}/linux/kernel/projects/rt/4.14/" SRC_URI += " \ ${KERNELORG_MIRROR}/linux/kernel/projects/rt/4.14/older/patch-4.14.126-rt62.patch.xz;name=rt-patch \ + file://0001-imx_sc_thermal-prevent-BUG-with-rt-patch.patch \ + file://0002-ddr-perf-prevent-BUG-with-rt-patch.patch \ " SRC_URI[rt-patch.md5sum] = "47f2bb663112711d7270902e7e42cd16" -- cgit v1.2.3