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.
Unified · Split
| @@ -45,6 +45,7 @@ obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o entry-ftrace.o · 44 unmodified lines | |||
| 45 | obj-$(CONFIG_MODULES) += module.o | 45 | obj-$(CONFIG_MODULES) += module.o |
| 46 | obj-$(CONFIG_ARM64_MODULE_PLTS) += module-plts.o | 46 | obj-$(CONFIG_ARM64_MODULE_PLTS) += module-plts.o |
| 47 | obj-$(CONFIG_PERF_EVENTS) += perf_regs.o perf_callchain.o | 47 | obj-$(CONFIG_PERF_EVENTS) += perf_regs.o perf_callchain.o |
| 48 | obj-$(CONFIG_HARDLOCKUP_DETECTOR_PERF) += watchdog_hld.o | ||
| 48 | obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o | 49 | obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o |
| 49 | obj-$(CONFIG_CPU_PM) += sleep.o suspend.o | 50 | obj-$(CONFIG_CPU_PM) += sleep.o suspend.o |
| 50 | obj-$(CONFIG_CPU_IDLE) += cpuidle.o | 51 | obj-$(CONFIG_CPU_IDLE) += cpuidle.o |
| @@ -0,0 +1,24 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | #include <linux/cpufreq.h> | ||
| 3 | |||
| 4 | /* | ||
| 5 | * Safe maximum CPU frequency in case a particular platform doesn't implement | ||
| 6 | * cpufreq driver. Although, architecture doesn't put any restrictions on | ||
| 7 | * maximum frequency but 5 GHz seems to be safe maximum given the available | ||
| 8 | * Arm CPUs in the market which are clocked much less than 5 GHz. On the other | ||
| 9 | * hand, we can't make it much higher as it would lead to a large hard-lockup | ||
| 10 | * detection timeout on parts which are running slower (eg. 1GHz on | ||
| 11 | * Developerbox) and doesn't possess a cpufreq driver. | ||
| 12 | */ | ||
| 13 | #define SAFE_MAX_CPU_FREQ 5000000000UL // 5 GHz | ||
| 14 | u64 hw_nmi_get_sample_period(int watchdog_thresh) | ||
| 15 | { | ||
| 16 | unsigned int cpu = smp_processor_id(); | ||
| 17 | unsigned long max_cpu_freq; | ||
| 18 | |||
| 19 | max_cpu_freq = cpufreq_get_hw_max_freq(cpu) * 1000UL; | ||
| 20 | if (!max_cpu_freq) | ||
| 21 | max_cpu_freq = SAFE_MAX_CPU_FREQ; | ||
| 22 | |||
| 23 | return (u64)max_cpu_freq * watchdog_thresh; | ||
| 24 | } | ||