Skip to content

Commit d813f42

Browse files
committed
Merge tag 'pm-7.0-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull power management fixes from Rafael Wysocki: "These fix two cpufreq issues, one in the core and one in the conservative governor, and two issues related to system sleep: - Restore the cpufreq core behavior changed inadvertently during the 6.19 development cycle to call cpufreq_frequency_table_cpuinfo() for cpufreq policies getting re-initialized which ensures that policy->max and policy->cpuinfo_max_freq will be valid going forward (Viresh Kumar) - Adjust the cached requested frequency in the conservative cpufreq governor on policy limits changes to prevent it from becoming stale in some cases (Viresh Kumar) - Prevent pm_restore_gfp_mask() from triggering a WARN_ON() in some code paths in which it is legitimately called without invoking pm_restrict_gfp_mask() previously (Youngjun Park) - Update snapshot_write_finalize() to take trailing zero pages into account properly which prevents user space restore from failing subsequently in some cases (Alberto Garcia)" * tag 'pm-7.0-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: PM: sleep: Drop spurious WARN_ON() from pm_restore_gfp_mask() PM: hibernate: Drain trailing zero pages on userspace restore cpufreq: conservative: Reset requested_freq on limits change cpufreq: Don't skip cpufreq_frequency_table_cpuinfo()
2 parents 9c2b23a + 042f99c commit d813f42

7 files changed

Lines changed: 35 additions & 7 deletions

File tree

drivers/cpufreq/cpufreq.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,12 +1427,9 @@ static int cpufreq_policy_online(struct cpufreq_policy *policy,
14271427
* If there is a problem with its frequency table, take it
14281428
* offline and drop it.
14291429
*/
1430-
if (policy->freq_table_sorted != CPUFREQ_TABLE_SORTED_ASCENDING &&
1431-
policy->freq_table_sorted != CPUFREQ_TABLE_SORTED_DESCENDING) {
1432-
ret = cpufreq_table_validate_and_sort(policy);
1433-
if (ret)
1434-
goto out_offline_policy;
1435-
}
1430+
ret = cpufreq_table_validate_and_sort(policy);
1431+
if (ret)
1432+
goto out_offline_policy;
14361433

14371434
/* related_cpus should at least include policy->cpus. */
14381435
cpumask_copy(policy->related_cpus, policy->cpus);

drivers/cpufreq/cpufreq_conservative.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,17 @@ static void cs_start(struct cpufreq_policy *policy)
313313
dbs_info->requested_freq = policy->cur;
314314
}
315315

316+
static void cs_limits(struct cpufreq_policy *policy)
317+
{
318+
struct cs_policy_dbs_info *dbs_info = to_dbs_info(policy->governor_data);
319+
320+
/*
321+
* The limits have changed, so may have the current frequency. Reset
322+
* requested_freq to avoid any unintended outcomes due to the mismatch.
323+
*/
324+
dbs_info->requested_freq = policy->cur;
325+
}
326+
316327
static struct dbs_governor cs_governor = {
317328
.gov = CPUFREQ_DBS_GOVERNOR_INITIALIZER("conservative"),
318329
.kobj_type = { .default_groups = cs_groups },
@@ -322,6 +333,7 @@ static struct dbs_governor cs_governor = {
322333
.init = cs_init,
323334
.exit = cs_exit,
324335
.start = cs_start,
336+
.limits = cs_limits,
325337
};
326338

327339
#define CPU_FREQ_GOV_CONSERVATIVE (cs_governor.gov)

drivers/cpufreq/cpufreq_governor.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ EXPORT_SYMBOL_GPL(cpufreq_dbs_governor_stop);
563563

564564
void cpufreq_dbs_governor_limits(struct cpufreq_policy *policy)
565565
{
566+
struct dbs_governor *gov = dbs_governor_of(policy);
566567
struct policy_dbs_info *policy_dbs;
567568

568569
/* Protect gov->gdbs_data against cpufreq_dbs_governor_exit() */
@@ -574,6 +575,8 @@ void cpufreq_dbs_governor_limits(struct cpufreq_policy *policy)
574575
mutex_lock(&policy_dbs->update_mutex);
575576
cpufreq_policy_apply_limits(policy);
576577
gov_update_sample_delay(policy_dbs, 0);
578+
if (gov->limits)
579+
gov->limits(policy);
577580
mutex_unlock(&policy_dbs->update_mutex);
578581

579582
out:

drivers/cpufreq/cpufreq_governor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ struct dbs_governor {
138138
int (*init)(struct dbs_data *dbs_data);
139139
void (*exit)(struct dbs_data *dbs_data);
140140
void (*start)(struct cpufreq_policy *policy);
141+
void (*limits)(struct cpufreq_policy *policy);
141142
};
142143

143144
static inline struct dbs_governor *dbs_governor_of(struct cpufreq_policy *policy)

drivers/cpufreq/freq_table.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,10 @@ int cpufreq_table_validate_and_sort(struct cpufreq_policy *policy)
360360
if (policy_has_boost_freq(policy))
361361
policy->boost_supported = true;
362362

363+
if (policy->freq_table_sorted == CPUFREQ_TABLE_SORTED_ASCENDING ||
364+
policy->freq_table_sorted == CPUFREQ_TABLE_SORTED_DESCENDING)
365+
return 0;
366+
363367
return set_freq_table_sorted(policy);
364368
}
365369

kernel/power/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void pm_restore_gfp_mask(void)
4040
{
4141
WARN_ON(!mutex_is_locked(&system_transition_mutex));
4242

43-
if (WARN_ON(!saved_gfp_count) || --saved_gfp_count)
43+
if (!saved_gfp_count || --saved_gfp_count)
4444
return;
4545

4646
gfp_allowed_mask = saved_gfp_mask;

kernel/power/snapshot.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2855,6 +2855,17 @@ int snapshot_write_finalize(struct snapshot_handle *handle)
28552855
{
28562856
int error;
28572857

2858+
/*
2859+
* Call snapshot_write_next() to drain any trailing zero pages,
2860+
* but make sure we're in the data page region first.
2861+
* This function can return PAGE_SIZE if the kernel was expecting
2862+
* another copy page. Return -ENODATA in that situation.
2863+
*/
2864+
if (handle->cur > nr_meta_pages + 1) {
2865+
error = snapshot_write_next(handle);
2866+
if (error)
2867+
return error > 0 ? -ENODATA : error;
2868+
}
28582869
copy_last_highmem_page();
28592870
error = hibernate_restore_protect_page(handle->buffer);
28602871
/* Do that only if we have loaded the image entirely */

0 commit comments

Comments
 (0)