forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 297b60346df8beafee954a0fd7c2d64f33f3b9bc
kernel/arch/x86/kernel/cpu/aperfmperf.c
....@@ -1,18 +1,19 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * x86 APERF/MPERF KHz calculation for
34 * /sys/.../cpufreq/scaling_cur_freq
45 *
56 * Copyright (C) 2017 Intel Corp.
67 * Author: Len Brown <len.brown@intel.com>
7
- *
8
- * This file is licensed under GPLv2.
98 */
109
1110 #include <linux/delay.h>
1211 #include <linux/ktime.h>
1312 #include <linux/math64.h>
1413 #include <linux/percpu.h>
14
+#include <linux/cpufreq.h>
1515 #include <linux/smp.h>
16
+#include <linux/sched/isolation.h>
1617
1718 #include "cpu.h"
1819
....@@ -82,7 +83,10 @@
8283 if (!cpu_khz)
8384 return 0;
8485
85
- if (!static_cpu_has(X86_FEATURE_APERFMPERF))
86
+ if (!boot_cpu_has(X86_FEATURE_APERFMPERF))
87
+ return 0;
88
+
89
+ if (!housekeeping_cpu(cpu, HK_FLAG_MISC))
8690 return 0;
8791
8892 aperfmperf_snapshot_cpu(cpu, ktime_get(), true);
....@@ -98,12 +102,15 @@
98102 if (!cpu_khz)
99103 return;
100104
101
- if (!static_cpu_has(X86_FEATURE_APERFMPERF))
105
+ if (!boot_cpu_has(X86_FEATURE_APERFMPERF))
102106 return;
103107
104
- for_each_online_cpu(cpu)
108
+ for_each_online_cpu(cpu) {
109
+ if (!housekeeping_cpu(cpu, HK_FLAG_MISC))
110
+ continue;
105111 if (!aperfmperf_snapshot_cpu(cpu, now, false))
106112 wait = true;
113
+ }
107114
108115 if (wait)
109116 msleep(APERFMPERF_REFRESH_DELAY_MS);
....@@ -114,7 +121,10 @@
114121 if (!cpu_khz)
115122 return 0;
116123
117
- if (!static_cpu_has(X86_FEATURE_APERFMPERF))
124
+ if (!boot_cpu_has(X86_FEATURE_APERFMPERF))
125
+ return 0;
126
+
127
+ if (!housekeeping_cpu(cpu, HK_FLAG_MISC))
118128 return 0;
119129
120130 if (aperfmperf_snapshot_cpu(cpu, ktime_get(), true))