[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220614062835.7196-6-lecopzer.chen@mediatek.com>
Date: Tue, 14 Jun 2022 14:28:34 +0800
From: Lecopzer Chen <lecopzer.chen@...iatek.com>
To: <linux-arm-kernel@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>
CC: <pmladek@...e.com>, <acme@...nel.org>, <akpm@...ux-foundation.org>,
<alexander.shishkin@...ux.intel.com>, <catalin.marinas@....com>,
<davem@...emloft.net>, <jolsa@...hat.com>, <jthierry@...hat.com>,
<keescook@...omium.org>, <kernelfans@...il.com>,
<lecopzer.chen@...iatek.com>, <linux-mediatek@...ts.infradead.org>,
<linux-perf-users@...r.kernel.org>, <mark.rutland@....com>,
<masahiroy@...nel.org>, <matthias.bgg@...il.com>, <maz@...nel.org>,
<mcgrof@...nel.org>, <mingo@...hat.com>, <namhyung@...nel.org>,
<nixiaoming@...wei.com>, <peterz@...radead.org>,
<sparclinux@...r.kernel.org>, <sumit.garg@...aro.org>,
<wangqing@...o.com>, <will@...nel.org>, <yj.chiang@...iatek.com>
Subject: [PATCH v6 5/6] arm64: add hw_nmi_get_sample_period for preparation of lockup detector
Set safe maximum CPU frequency to 5 GHz in case a particular platform
doesn't implement cpufreq driver.
Although, architecture doesn't put any restrictions on
maximum frequency but 5 GHz seems to be safe maximum given the available
Arm CPUs in the market which are clocked much less than 5 GHz.
On the other hand, we can't make it much higher as it would lead to
a large hard-lockup detection timeout on parts which are running
slower (eg. 1GHz on Developerbox) and doesn't possess a cpufreq driver.
[1]:http://lore.kernel.org/linux-arm-kernel/1610712101-14929-1-git-send-email-sumit.garg@linaro.org
Co-developed-by: Sumit Garg <sumit.garg@...aro.org>
Signed-off-by: Sumit Garg <sumit.garg@...aro.org>
Co-developed-by: Pingfan Liu <kernelfans@...il.com>
Signed-off-by: Pingfan Liu <kernelfans@...il.com>
Signed-off-by: Lecopzer Chen <lecopzer.chen@...iatek.com>
---
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/watchdog_hld.c | 25 +++++++++++++++++++++++++
2 files changed, 26 insertions(+)
create mode 100644 arch/arm64/kernel/watchdog_hld.c
diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
index fa7981d0d917..303b69ad5366 100644
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -46,6 +46,7 @@ obj-$(CONFIG_MODULES) += module.o
obj-$(CONFIG_ARM64_MODULE_PLTS) += module-plts.o
obj-$(CONFIG_PERF_EVENTS) += perf_regs.o perf_callchain.o
obj-$(CONFIG_HW_PERF_EVENTS) += perf_event.o
+obj-$(CONFIG_HARDLOCKUP_DETECTOR_PERF) += watchdog_hld.o
obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o
obj-$(CONFIG_CPU_PM) += sleep.o suspend.o
obj-$(CONFIG_CPU_IDLE) += cpuidle.o
diff --git a/arch/arm64/kernel/watchdog_hld.c b/arch/arm64/kernel/watchdog_hld.c
new file mode 100644
index 000000000000..de43318e4dd6
--- /dev/null
+++ b/arch/arm64/kernel/watchdog_hld.c
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/cpufreq.h>
+
+/*
+ * Safe maximum CPU frequency in case a particular platform doesn't implement
+ * cpufreq driver. Although, architecture doesn't put any restrictions on
+ * maximum frequency but 5 GHz seems to be safe maximum given the available
+ * Arm CPUs in the market which are clocked much less than 5 GHz. On the other
+ * hand, we can't make it much higher as it would lead to a large hard-lockup
+ * detection timeout on parts which are running slower (eg. 1GHz on
+ * Developerbox) and doesn't possess a cpufreq driver.
+ */
+#define SAFE_MAX_CPU_FREQ 5000000000UL // 5 GHz
+u64 hw_nmi_get_sample_period(int watchdog_thresh)
+{
+ unsigned int cpu = smp_processor_id();
+ unsigned long max_cpu_freq;
+
+ max_cpu_freq = cpufreq_get_hw_max_freq(cpu) * 1000UL;
+ if (!max_cpu_freq)
+ max_cpu_freq = SAFE_MAX_CPU_FREQ;
+
+ return (u64)max_cpu_freq * watchdog_thresh;
+}
+
--
2.25.1
Powered by blists - more mailing lists