Skip to content

Commit 78b1f56

Browse files
committed
Merge branch 'pm-cpufreq'
Merge cpufreq updates for 6.7-rc1: - Add support for several Qualcomm SoC versions and other similar changes (Christian Marangi, Dmitry Baryshkov, Luca Weiss, Neil Armstrong, Richard Acayan, Robert Marko, Rohit Agarwal, Stephan Gerhold and Varadarajan Narayanan). - Clean up the tegra cpufreq driver (Sumit Gupta). - Use of_property_read_reg() to parse "reg" in pmac32 driver (Rob Herring). - Add support for TI's am62p5 Soc (Bryan Brattlof). - Make ARM_BRCMSTB_AVS_CPUFREQ depends on !ARM_SCMI_CPUFREQ (Florian Fainelli). - Update Kconfig to mention i.MX7 as well (Alexander Stein). - Revise global turbo disable check in intel_pstate (Srinivas Pandruvada). - Carry out initialization of sg_cpu in the schedutil cpufreq governor in one loop (Liao Chang). - Simplify the condition for storing 'down_threshold' in the conservative cpufreq governor (Liao Chang). - Use fine-grained mutex in the userspace cpufreq governor (Liao Chang). - Move is_managed indicator in the userspace cpufreq governor into a per-policy structure (Liao Chang). - Rebuild sched-domains when removing cpufreq driver (Pierre Gondois). - Fix buffer overflow detection in trans_stats() (Christian Marangi). * pm-cpufreq: (32 commits) dt-bindings: cpufreq: qcom-hw: document SM8650 CPUFREQ Hardware cpufreq: arm: Kconfig: Add i.MX7 to supported SoC for ARM_IMX_CPUFREQ_DT cpufreq: qcom-nvmem: add support for IPQ8064 cpufreq: qcom-nvmem: also accept operating-points-v2-krait-cpu cpufreq: qcom-nvmem: drop pvs_ver for format a fuses dt-bindings: cpufreq: qcom-cpufreq-nvmem: Document krait-cpu cpufreq: qcom-nvmem: add support for IPQ6018 dt-bindings: cpufreq: qcom-cpufreq-nvmem: document IPQ6018 cpufreq: qcom-nvmem: Add MSM8909 cpufreq: qcom-nvmem: Simplify driver data allocation cpufreq: stats: Fix buffer overflow detection in trans_stats() dt-bindings: cpufreq: cpufreq-qcom-hw: Add SDX75 compatible cpufreq: ARM_BRCMSTB_AVS_CPUFREQ cannot be used with ARM_SCMI_CPUFREQ cpufreq: ti-cpufreq: Add opp support for am62p5 SoCs cpufreq: dt-platdev: add am62p5 to blocklist cpufreq: tegra194: remove redundant AND with cpu_online_mask cpufreq: tegra194: use refclk delta based loop instead of udelay cpufreq: tegra194: save CPU data to avoid repeated SMP calls cpufreq: Rebuild sched-domains when removing cpufreq driver cpufreq: userspace: Move is_managed indicator into per-policy structure ...
2 parents c1bdc9a + 7c35584 commit 78b1f56

File tree

15 files changed

+387
-180
lines changed

15 files changed

+387
-180
lines changed

Documentation/devicetree/bindings/cpufreq/cpufreq-qcom-hw.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ properties:
2323
- enum:
2424
- qcom,qcm2290-cpufreq-hw
2525
- qcom,sc7180-cpufreq-hw
26+
- qcom,sdm670-cpufreq-hw
2627
- qcom,sdm845-cpufreq-hw
2728
- qcom,sm6115-cpufreq-hw
2829
- qcom,sm6350-cpufreq-hw
@@ -36,11 +37,13 @@ properties:
3637
- qcom,sa8775p-cpufreq-epss
3738
- qcom,sc7280-cpufreq-epss
3839
- qcom,sc8280xp-cpufreq-epss
40+
- qcom,sdx75-cpufreq-epss
3941
- qcom,sm6375-cpufreq-epss
4042
- qcom,sm8250-cpufreq-epss
4143
- qcom,sm8350-cpufreq-epss
4244
- qcom,sm8450-cpufreq-epss
4345
- qcom,sm8550-cpufreq-epss
46+
- qcom,sm8650-cpufreq-epss
4447
- const: qcom,cpufreq-epss
4548

4649
reg:
@@ -128,6 +131,7 @@ allOf:
128131
- qcom,qdu1000-cpufreq-epss
129132
- qcom,sc7180-cpufreq-hw
130133
- qcom,sc8280xp-cpufreq-epss
134+
- qcom,sdm670-cpufreq-hw
131135
- qcom,sdm845-cpufreq-hw
132136
- qcom,sm6115-cpufreq-hw
133137
- qcom,sm6350-cpufreq-hw

Documentation/devicetree/bindings/cpufreq/qcom-cpufreq-nvmem.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ select:
2727
enum:
2828
- qcom,apq8064
2929
- qcom,apq8096
30+
- qcom,ipq5332
31+
- qcom,ipq6018
3032
- qcom,ipq8064
3133
- qcom,ipq8074
34+
- qcom,ipq9574
35+
- qcom,msm8909
3236
- qcom,msm8939
3337
- qcom,msm8960
3438
- qcom,msm8974
@@ -43,7 +47,9 @@ patternProperties:
4347
- if:
4448
properties:
4549
compatible:
46-
const: operating-points-v2-kryo-cpu
50+
enum:
51+
- operating-points-v2-krait-cpu
52+
- operating-points-v2-kryo-cpu
4753
then:
4854
$ref: /schemas/opp/opp-v2-kryo-cpu.yaml#
4955

drivers/cpufreq/Kconfig.arm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ config ARM_VEXPRESS_SPC_CPUFREQ
9090

9191
config ARM_BRCMSTB_AVS_CPUFREQ
9292
tristate "Broadcom STB AVS CPUfreq driver"
93-
depends on ARCH_BRCMSTB || COMPILE_TEST
93+
depends on (ARCH_BRCMSTB && !ARM_SCMI_CPUFREQ) || COMPILE_TEST
9494
default y
9595
help
9696
Some Broadcom STB SoCs use a co-processor running proprietary firmware
@@ -124,8 +124,8 @@ config ARM_IMX_CPUFREQ_DT
124124
tristate "Freescale i.MX8M cpufreq support"
125125
depends on ARCH_MXC && CPUFREQ_DT
126126
help
127-
This adds cpufreq driver support for Freescale i.MX8M series SoCs,
128-
based on cpufreq-dt.
127+
This adds cpufreq driver support for Freescale i.MX7/i.MX8M
128+
series SoCs, based on cpufreq-dt.
129129

130130
If in doubt, say N.
131131

drivers/cpufreq/cpufreq-dt-platdev.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,11 @@ static const struct of_device_id blocklist[] __initconst = {
142142
{ .compatible = "nvidia,tegra234", },
143143

144144
{ .compatible = "qcom,apq8096", },
145+
{ .compatible = "qcom,msm8909", },
145146
{ .compatible = "qcom,msm8996", },
146147
{ .compatible = "qcom,msm8998", },
147148
{ .compatible = "qcom,qcm2290", },
149+
{ .compatible = "qcom,qcm6490", },
148150
{ .compatible = "qcom,qcs404", },
149151
{ .compatible = "qcom,qdu1000", },
150152
{ .compatible = "qcom,sa8155p" },
@@ -176,7 +178,9 @@ static const struct of_device_id blocklist[] __initconst = {
176178
{ .compatible = "ti,omap3", },
177179
{ .compatible = "ti,am625", },
178180
{ .compatible = "ti,am62a7", },
181+
{ .compatible = "ti,am62p5", },
179182

183+
{ .compatible = "qcom,ipq6018", },
180184
{ .compatible = "qcom,ipq8064", },
181185
{ .compatible = "qcom,apq8064", },
182186
{ .compatible = "qcom,msm8974", },

drivers/cpufreq/cpufreq.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,7 +1544,7 @@ static int cpufreq_online(unsigned int cpu)
15441544

15451545
/*
15461546
* Register with the energy model before
1547-
* sched_cpufreq_governor_change() is called, which will result
1547+
* sugov_eas_rebuild_sd() is called, which will result
15481548
* in rebuilding of the sched domains, which should only be done
15491549
* once the energy model is properly initialized for the policy
15501550
* first.
@@ -2652,7 +2652,6 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
26522652
ret = cpufreq_start_governor(policy);
26532653
if (!ret) {
26542654
pr_debug("governor change\n");
2655-
sched_cpufreq_governor_change(policy, old_gov);
26562655
return 0;
26572656
}
26582657
cpufreq_exit_governor(policy);

drivers/cpufreq/cpufreq_conservative.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,7 @@ static ssize_t down_threshold_store(struct gov_attr_set *attr_set,
187187
ret = sscanf(buf, "%u", &input);
188188

189189
/* cannot be lower than 1 otherwise freq will not fall */
190-
if (ret != 1 || input < 1 || input > 100 ||
191-
input >= dbs_data->up_threshold)
190+
if (ret != 1 || input < 1 || input >= dbs_data->up_threshold)
192191
return -EINVAL;
193192

194193
cs_tuners->down_threshold = input;

drivers/cpufreq/cpufreq_stats.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,23 +131,23 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf)
131131
len += sysfs_emit_at(buf, len, " From : To\n");
132132
len += sysfs_emit_at(buf, len, " : ");
133133
for (i = 0; i < stats->state_num; i++) {
134-
if (len >= PAGE_SIZE)
134+
if (len >= PAGE_SIZE - 1)
135135
break;
136136
len += sysfs_emit_at(buf, len, "%9u ", stats->freq_table[i]);
137137
}
138-
if (len >= PAGE_SIZE)
139-
return PAGE_SIZE;
138+
if (len >= PAGE_SIZE - 1)
139+
return PAGE_SIZE - 1;
140140

141141
len += sysfs_emit_at(buf, len, "\n");
142142

143143
for (i = 0; i < stats->state_num; i++) {
144-
if (len >= PAGE_SIZE)
144+
if (len >= PAGE_SIZE - 1)
145145
break;
146146

147147
len += sysfs_emit_at(buf, len, "%9u: ", stats->freq_table[i]);
148148

149149
for (j = 0; j < stats->state_num; j++) {
150-
if (len >= PAGE_SIZE)
150+
if (len >= PAGE_SIZE - 1)
151151
break;
152152

153153
if (pending)
@@ -157,12 +157,12 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf)
157157

158158
len += sysfs_emit_at(buf, len, "%9u ", count);
159159
}
160-
if (len >= PAGE_SIZE)
160+
if (len >= PAGE_SIZE - 1)
161161
break;
162162
len += sysfs_emit_at(buf, len, "\n");
163163
}
164164

165-
if (len >= PAGE_SIZE) {
165+
if (len >= PAGE_SIZE - 1) {
166166
pr_warn_once("cpufreq transition table exceeds PAGE_SIZE. Disabling\n");
167167
return -EFBIG;
168168
}

drivers/cpufreq/cpufreq_userspace.c

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
#include <linux/mutex.h>
1616
#include <linux/slab.h>
1717

18-
static DEFINE_PER_CPU(unsigned int, cpu_is_managed);
19-
static DEFINE_MUTEX(userspace_mutex);
18+
struct userspace_policy {
19+
unsigned int is_managed;
20+
unsigned int setspeed;
21+
struct mutex mutex;
22+
};
2023

2124
/**
2225
* cpufreq_set - set the CPU frequency
@@ -28,19 +31,19 @@ static DEFINE_MUTEX(userspace_mutex);
2831
static int cpufreq_set(struct cpufreq_policy *policy, unsigned int freq)
2932
{
3033
int ret = -EINVAL;
31-
unsigned int *setspeed = policy->governor_data;
34+
struct userspace_policy *userspace = policy->governor_data;
3235

3336
pr_debug("cpufreq_set for cpu %u, freq %u kHz\n", policy->cpu, freq);
3437

35-
mutex_lock(&userspace_mutex);
36-
if (!per_cpu(cpu_is_managed, policy->cpu))
38+
mutex_lock(&userspace->mutex);
39+
if (!userspace->is_managed)
3740
goto err;
3841

39-
*setspeed = freq;
42+
userspace->setspeed = freq;
4043

4144
ret = __cpufreq_driver_target(policy, freq, CPUFREQ_RELATION_L);
4245
err:
43-
mutex_unlock(&userspace_mutex);
46+
mutex_unlock(&userspace->mutex);
4447
return ret;
4548
}
4649

@@ -51,67 +54,74 @@ static ssize_t show_speed(struct cpufreq_policy *policy, char *buf)
5154

5255
static int cpufreq_userspace_policy_init(struct cpufreq_policy *policy)
5356
{
54-
unsigned int *setspeed;
57+
struct userspace_policy *userspace;
5558

56-
setspeed = kzalloc(sizeof(*setspeed), GFP_KERNEL);
57-
if (!setspeed)
59+
userspace = kzalloc(sizeof(*userspace), GFP_KERNEL);
60+
if (!userspace)
5861
return -ENOMEM;
5962

60-
policy->governor_data = setspeed;
63+
mutex_init(&userspace->mutex);
64+
65+
policy->governor_data = userspace;
6166
return 0;
6267
}
6368

69+
/*
70+
* Any routine that writes to the policy struct will hold the "rwsem" of
71+
* policy struct that means it is free to free "governor_data" here.
72+
*/
6473
static void cpufreq_userspace_policy_exit(struct cpufreq_policy *policy)
6574
{
66-
mutex_lock(&userspace_mutex);
6775
kfree(policy->governor_data);
6876
policy->governor_data = NULL;
69-
mutex_unlock(&userspace_mutex);
7077
}
7178

7279
static int cpufreq_userspace_policy_start(struct cpufreq_policy *policy)
7380
{
74-
unsigned int *setspeed = policy->governor_data;
81+
struct userspace_policy *userspace = policy->governor_data;
7582

7683
BUG_ON(!policy->cur);
7784
pr_debug("started managing cpu %u\n", policy->cpu);
7885

79-
mutex_lock(&userspace_mutex);
80-
per_cpu(cpu_is_managed, policy->cpu) = 1;
81-
*setspeed = policy->cur;
82-
mutex_unlock(&userspace_mutex);
86+
mutex_lock(&userspace->mutex);
87+
userspace->is_managed = 1;
88+
userspace->setspeed = policy->cur;
89+
mutex_unlock(&userspace->mutex);
8390
return 0;
8491
}
8592

8693
static void cpufreq_userspace_policy_stop(struct cpufreq_policy *policy)
8794
{
88-
unsigned int *setspeed = policy->governor_data;
95+
struct userspace_policy *userspace = policy->governor_data;
8996

9097
pr_debug("managing cpu %u stopped\n", policy->cpu);
9198

92-
mutex_lock(&userspace_mutex);
93-
per_cpu(cpu_is_managed, policy->cpu) = 0;
94-
*setspeed = 0;
95-
mutex_unlock(&userspace_mutex);
99+
mutex_lock(&userspace->mutex);
100+
userspace->is_managed = 0;
101+
userspace->setspeed = 0;
102+
mutex_unlock(&userspace->mutex);
96103
}
97104

98105
static void cpufreq_userspace_policy_limits(struct cpufreq_policy *policy)
99106
{
100-
unsigned int *setspeed = policy->governor_data;
107+
struct userspace_policy *userspace = policy->governor_data;
101108

102-
mutex_lock(&userspace_mutex);
109+
mutex_lock(&userspace->mutex);
103110

104111
pr_debug("limit event for cpu %u: %u - %u kHz, currently %u kHz, last set to %u kHz\n",
105-
policy->cpu, policy->min, policy->max, policy->cur, *setspeed);
106-
107-
if (policy->max < *setspeed)
108-
__cpufreq_driver_target(policy, policy->max, CPUFREQ_RELATION_H);
109-
else if (policy->min > *setspeed)
110-
__cpufreq_driver_target(policy, policy->min, CPUFREQ_RELATION_L);
112+
policy->cpu, policy->min, policy->max, policy->cur, userspace->setspeed);
113+
114+
if (policy->max < userspace->setspeed)
115+
__cpufreq_driver_target(policy, policy->max,
116+
CPUFREQ_RELATION_H);
117+
else if (policy->min > userspace->setspeed)
118+
__cpufreq_driver_target(policy, policy->min,
119+
CPUFREQ_RELATION_L);
111120
else
112-
__cpufreq_driver_target(policy, *setspeed, CPUFREQ_RELATION_L);
121+
__cpufreq_driver_target(policy, userspace->setspeed,
122+
CPUFREQ_RELATION_L);
113123

114-
mutex_unlock(&userspace_mutex);
124+
mutex_unlock(&userspace->mutex);
115125
}
116126

117127
static struct cpufreq_governor cpufreq_gov_userspace = {

drivers/cpufreq/intel_pstate.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -571,13 +571,9 @@ static void intel_pstate_hybrid_hwp_adjust(struct cpudata *cpu)
571571
static inline void update_turbo_state(void)
572572
{
573573
u64 misc_en;
574-
struct cpudata *cpu;
575574

576-
cpu = all_cpu_data[0];
577575
rdmsrl(MSR_IA32_MISC_ENABLE, misc_en);
578-
global.turbo_disabled =
579-
(misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE ||
580-
cpu->pstate.max_pstate == cpu->pstate.turbo_pstate);
576+
global.turbo_disabled = misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE;
581577
}
582578

583579
static int min_perf_pct_min(void)

drivers/cpufreq/pmac32-cpufreq.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/device.h>
2525
#include <linux/hardirq.h>
2626
#include <linux/of.h>
27+
#include <linux/of_address.h>
2728

2829
#include <asm/machdep.h>
2930
#include <asm/irq.h>
@@ -378,18 +379,16 @@ static int pmac_cpufreq_cpu_init(struct cpufreq_policy *policy)
378379

379380
static u32 read_gpio(struct device_node *np)
380381
{
381-
const u32 *reg = of_get_property(np, "reg", NULL);
382-
u32 offset;
382+
u64 offset;
383383

384-
if (reg == NULL)
384+
if (of_property_read_reg(np, 0, &offset, NULL) < 0)
385385
return 0;
386386
/* That works for all keylargos but shall be fixed properly
387387
* some day... The problem is that it seems we can't rely
388388
* on the "reg" property of the GPIO nodes, they are either
389389
* relative to the base of KeyLargo or to the base of the
390390
* GPIO space, and the device-tree doesn't help.
391391
*/
392-
offset = *reg;
393392
if (offset < KEYLARGO_GPIO_LEVELS0)
394393
offset += KEYLARGO_GPIO_LEVELS0;
395394
return offset;

0 commit comments

Comments
 (0)