Skip to content

Commit 1fe2523

Browse files
committed
Merge branch 'pm-cpufreq'
Merge cpufreq updates for 6.19-rc1: - Add OPP and bandwidth support for Tegra186 (Aaron Kling) - Optimizations for parameter array handling in the amd-pstate cpufreq driver (Mario Limonciello) - Fix for mode changes with offline CPUs in the amd-pstate cpufreq driver (Gautham Shenoy) - Preserve freq_table_sorted across suspend/hibernate in the cpufreq core (Zihuan Zhang) - Adjust energy model rules for Intel hybrid platforms in the intel_pstate cpufreq driver and improve printing of debug messages in it (Rafael Wysocki) - Replace deprecated strcpy() in cpufreq_unregister_governor() (Thorsten Blum) - Fix duplicate hyperlink target errors in the intel_pstate cpufreq driver documentation and use :ref: directive for internal linking in it (Swaraj Gaikwad, Bagas Sanjaya) - Add Diamond Rapids OOB mode support to the intel_pstate cpufreq driver (Kuppuswamy Sathyanarayanan) - Use mutex guard for driver locking in the intel_pstate driver and eliminate some code duplication from it (Rafael Wysocki) - Replace udelay() with usleep_range() in ACPI cpufreq (Kaushlendra Kumar) - Minor improvements to various cpufreq drivers (Christian Marangi, Hal Feng, Jie Zhan, Marco Crivellari, Miaoqian Lin, and Shuhao Fu) * pm-cpufreq: (27 commits) cpufreq: qcom-nvmem: fix compilation warning for qcom_cpufreq_ipq806x_match_list cpufreq: ACPI: Replace udelay() with usleep_range() cpufreq: intel_pstate: Eliminate some code duplication cpufreq: intel_pstate: Use mutex guard for driver locking cpufreq/amd-pstate: Call cppc_set_auto_sel() only for online CPUs cpufreq/amd-pstate: Add static asserts for EPP indices cpufreq/amd-pstate: Fix some whitespace issues cpufreq/amd-pstate: Adjust return values in amd_pstate_update_status() cpufreq/amd-pstate: Make amd_pstate_get_mode_string() never return NULL cpufreq/amd-pstate: Drop NULL value from amd_pstate_mode_string cpufreq/amd-pstate: Use sysfs_match_string() for epp cpufreq: tegra194: add WQ_PERCPU to alloc_workqueue users cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM Documentation: intel-pstate: Use :ref: directive for internal linking cpufreq: intel_pstate: Add Diamond Rapids OOB mode support Documentation: intel_pstate: fix duplicate hyperlink target errors cpufreq: CPPC: Don't warn if FIE init fails to read counters cpufreq: nforce2: fix reference count leak in nforce2 cpufreq: tegra186: add OPP support and set bandwidth cpufreq: dt-platdev: Add JH7110S SOC to the allowlist ...
2 parents f086594 + ded4feb commit 1fe2523

12 files changed

Lines changed: 389 additions & 234 deletions

Documentation/admin-guide/pm/intel_pstate.rst

Lines changed: 74 additions & 59 deletions
Large diffs are not rendered by default.

drivers/cpufreq/acpi-cpufreq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ static unsigned int check_freqs(struct cpufreq_policy *policy,
395395
cur_freq = extract_freq(policy, get_cur_val(mask, data));
396396
if (cur_freq == freq)
397397
return 1;
398-
udelay(10);
398+
usleep_range(10, 15);
399399
}
400400
return 0;
401401
}

drivers/cpufreq/amd-pstate.c

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ static const char * const amd_pstate_mode_string[] = {
6565
[AMD_PSTATE_PASSIVE] = "passive",
6666
[AMD_PSTATE_ACTIVE] = "active",
6767
[AMD_PSTATE_GUIDED] = "guided",
68-
NULL,
6968
};
69+
static_assert(ARRAY_SIZE(amd_pstate_mode_string) == AMD_PSTATE_MAX);
7070

7171
const char *amd_pstate_get_mode_string(enum amd_pstate_mode mode)
7272
{
73-
if (mode < 0 || mode >= AMD_PSTATE_MAX)
74-
return NULL;
73+
if (mode < AMD_PSTATE_UNDEFINED || mode >= AMD_PSTATE_MAX)
74+
mode = AMD_PSTATE_UNDEFINED;
7575
return amd_pstate_mode_string[mode];
7676
}
7777
EXPORT_SYMBOL_GPL(amd_pstate_get_mode_string);
@@ -110,6 +110,7 @@ enum energy_perf_value_index {
110110
EPP_INDEX_BALANCE_PERFORMANCE,
111111
EPP_INDEX_BALANCE_POWERSAVE,
112112
EPP_INDEX_POWERSAVE,
113+
EPP_INDEX_MAX,
113114
};
114115

115116
static const char * const energy_perf_strings[] = {
@@ -118,16 +119,17 @@ static const char * const energy_perf_strings[] = {
118119
[EPP_INDEX_BALANCE_PERFORMANCE] = "balance_performance",
119120
[EPP_INDEX_BALANCE_POWERSAVE] = "balance_power",
120121
[EPP_INDEX_POWERSAVE] = "power",
121-
NULL
122122
};
123+
static_assert(ARRAY_SIZE(energy_perf_strings) == EPP_INDEX_MAX);
123124

124125
static unsigned int epp_values[] = {
125126
[EPP_INDEX_DEFAULT] = 0,
126127
[EPP_INDEX_PERFORMANCE] = AMD_CPPC_EPP_PERFORMANCE,
127128
[EPP_INDEX_BALANCE_PERFORMANCE] = AMD_CPPC_EPP_BALANCE_PERFORMANCE,
128129
[EPP_INDEX_BALANCE_POWERSAVE] = AMD_CPPC_EPP_BALANCE_POWERSAVE,
129130
[EPP_INDEX_POWERSAVE] = AMD_CPPC_EPP_POWERSAVE,
130-
};
131+
};
132+
static_assert(ARRAY_SIZE(epp_values) == EPP_INDEX_MAX);
131133

132134
typedef int (*cppc_mode_transition_fn)(int);
133135

@@ -183,7 +185,7 @@ static inline int get_mode_idx_from_str(const char *str, size_t size)
183185
{
184186
int i;
185187

186-
for (i=0; i < AMD_PSTATE_MAX; i++) {
188+
for (i = 0; i < AMD_PSTATE_MAX; i++) {
187189
if (!strncmp(str, amd_pstate_mode_string[i], size))
188190
return i;
189191
}
@@ -1137,16 +1139,15 @@ static ssize_t show_amd_pstate_hw_prefcore(struct cpufreq_policy *policy,
11371139
static ssize_t show_energy_performance_available_preferences(
11381140
struct cpufreq_policy *policy, char *buf)
11391141
{
1140-
int i = 0;
1141-
int offset = 0;
1142+
int offset = 0, i;
11421143
struct amd_cpudata *cpudata = policy->driver_data;
11431144

11441145
if (cpudata->policy == CPUFREQ_POLICY_PERFORMANCE)
11451146
return sysfs_emit_at(buf, offset, "%s\n",
11461147
energy_perf_strings[EPP_INDEX_PERFORMANCE]);
11471148

1148-
while (energy_perf_strings[i] != NULL)
1149-
offset += sysfs_emit_at(buf, offset, "%s ", energy_perf_strings[i++]);
1149+
for (i = 0; i < ARRAY_SIZE(energy_perf_strings); i++)
1150+
offset += sysfs_emit_at(buf, offset, "%s ", energy_perf_strings[i]);
11501151

11511152
offset += sysfs_emit_at(buf, offset, "\n");
11521153

@@ -1157,15 +1158,10 @@ static ssize_t store_energy_performance_preference(
11571158
struct cpufreq_policy *policy, const char *buf, size_t count)
11581159
{
11591160
struct amd_cpudata *cpudata = policy->driver_data;
1160-
char str_preference[21];
11611161
ssize_t ret;
11621162
u8 epp;
11631163

1164-
ret = sscanf(buf, "%20s", str_preference);
1165-
if (ret != 1)
1166-
return -EINVAL;
1167-
1168-
ret = match_string(energy_perf_strings, -1, str_preference);
1164+
ret = sysfs_match_string(energy_perf_strings, buf);
11691165
if (ret < 0)
11701166
return -EINVAL;
11711167

@@ -1282,7 +1278,7 @@ static int amd_pstate_change_mode_without_dvr_change(int mode)
12821278
if (cpu_feature_enabled(X86_FEATURE_CPPC) || cppc_state == AMD_PSTATE_ACTIVE)
12831279
return 0;
12841280

1285-
for_each_present_cpu(cpu) {
1281+
for_each_online_cpu(cpu) {
12861282
cppc_set_auto_sel(cpu, (cppc_state == AMD_PSTATE_PASSIVE) ? 0 : 1);
12871283
}
12881284

@@ -1353,9 +1349,8 @@ int amd_pstate_update_status(const char *buf, size_t size)
13531349
return -EINVAL;
13541350

13551351
mode_idx = get_mode_idx_from_str(buf, size);
1356-
1357-
if (mode_idx < 0 || mode_idx >= AMD_PSTATE_MAX)
1358-
return -EINVAL;
1352+
if (mode_idx < 0)
1353+
return mode_idx;
13591354

13601355
if (mode_state_machine[cppc_state][mode_idx]) {
13611356
guard(mutex)(&amd_pstate_driver_lock);

drivers/cpufreq/cppc_cpufreq.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,15 @@ static void cppc_cpufreq_cpu_fie_init(struct cpufreq_policy *policy)
142142
init_irq_work(&cppc_fi->irq_work, cppc_irq_work);
143143

144144
ret = cppc_get_perf_ctrs(cpu, &cppc_fi->prev_perf_fb_ctrs);
145-
if (ret) {
146-
pr_warn("%s: failed to read perf counters for cpu:%d: %d\n",
147-
__func__, cpu, ret);
148145

149-
/*
150-
* Don't abort if the CPU was offline while the driver
151-
* was getting registered.
152-
*/
153-
if (cpu_online(cpu))
154-
return;
146+
/*
147+
* Don't abort as the CPU was offline while the driver was
148+
* getting registered.
149+
*/
150+
if (ret && cpu_online(cpu)) {
151+
pr_debug("%s: failed to read perf counters for cpu:%d: %d\n",
152+
__func__, cpu, ret);
153+
return;
155154
}
156155
}
157156

drivers/cpufreq/cpufreq-dt-platdev.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ static const struct of_device_id allowlist[] __initconst = {
8787
{ .compatible = "st-ericsson,u9540", },
8888

8989
{ .compatible = "starfive,jh7110", },
90+
{ .compatible = "starfive,jh7110s", },
9091

9192
{ .compatible = "ti,omap2", },
9293
{ .compatible = "ti,omap4", },

drivers/cpufreq/cpufreq-nforce2.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ static unsigned int nforce2_fsb_read(int bootfsb)
145145
pci_read_config_dword(nforce2_sub5, NFORCE2_BOOTFSB, &fsb);
146146
fsb /= 1000000;
147147

148+
pci_dev_put(nforce2_sub5);
149+
148150
/* Check if PLL register is already set */
149151
pci_read_config_byte(nforce2_dev, NFORCE2_PLLENABLE, (u8 *)&temp);
150152

@@ -426,6 +428,7 @@ static int __init nforce2_init(void)
426428
static void __exit nforce2_exit(void)
427429
{
428430
cpufreq_unregister_driver(&nforce2_driver);
431+
pci_dev_put(nforce2_dev);
429432
}
430433

431434
module_init(nforce2_init);

drivers/cpufreq/cpufreq.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,9 +1421,12 @@ static int cpufreq_policy_online(struct cpufreq_policy *policy,
14211421
* If there is a problem with its frequency table, take it
14221422
* offline and drop it.
14231423
*/
1424-
ret = cpufreq_table_validate_and_sort(policy);
1425-
if (ret)
1426-
goto out_offline_policy;
1424+
if (policy->freq_table_sorted != CPUFREQ_TABLE_SORTED_ASCENDING &&
1425+
policy->freq_table_sorted != CPUFREQ_TABLE_SORTED_DESCENDING) {
1426+
ret = cpufreq_table_validate_and_sort(policy);
1427+
if (ret)
1428+
goto out_offline_policy;
1429+
}
14271430

14281431
/* related_cpus should at least include policy->cpus. */
14291432
cpumask_copy(policy->related_cpus, policy->cpus);
@@ -2550,7 +2553,7 @@ void cpufreq_unregister_governor(struct cpufreq_governor *governor)
25502553
for_each_inactive_policy(policy) {
25512554
if (!strcmp(policy->last_governor, governor->name)) {
25522555
policy->governor = NULL;
2553-
strcpy(policy->last_governor, "\0");
2556+
policy->last_governor[0] = '\0';
25542557
}
25552558
}
25562559
read_unlock_irqrestore(&cpufreq_driver_lock, flags);

0 commit comments

Comments
 (0)