Power management fixes for 6.18-rc6

- Fix issues related to using inadequate data types and incorrect use
    of atomic variables in the compressed hibernation images handling
    code that were introduced during the 6.9 development cycle (Mario
    Limonciello)
 
  - Move a X86_FEATURE_IDA check from turbo_is_disabled() to the places
    where a new value for MSR_IA32_PERF_CTL is computed in intel_pstate
    to address a regression preventing users from enabling turbo
    frequencies post-boot (Srinivas Pandruvada)
 -----BEGIN PGP SIGNATURE-----
 
 iQFGBAABCAAwFiEEcM8Aw/RY0dgsiRUR7l+9nS/U47UFAmkWOnoSHHJqd0Byand5
 c29ja2kubmV0AAoJEO5fvZ0v1OO14gkH/08TYjtNEvC6acD2r5gJTpacdnExWopL
 NFmRyhuZM21Ja2gd1q0xtPvcTdAz3rkhB4vqn9KQ0oLkfXj08/+zpRyOP3PzVVSp
 bvE/Am28s/VChjDg/MFcP7o/fLSNoL73wK6er+i721KIV1uscK4FydkPNs6gpBHw
 03FkUJX8jRjil0Cp6km2O0Zo5SEgm/U6wDjR5Azpdru8VKbI1RaxCMsR0/HnlA9Y
 pUAph9NX1UBBjdMFFdn8++Vna8XJX4qe9CiYT7KwGbGx5jUpVBaT9d/hPm0O/mJt
 VvNe3Dl5soFM/3yibsvV4sTcZHNPTsIKjuKIqwL4F0TCGug9kxwjFBk=
 =r3Fq
 -----END PGP SIGNATURE-----

Merge tag 'pm-6.18-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull power management fixes from Rafael Wysocki:
 "These fix issues related to the handling of compressed hibernation
  images and a recent intel_pstate driver regression:

   - Fix issues related to using inadequate data types and incorrect use
     of atomic variables in the compressed hibernation images handling
     code that were introduced during the 6.9 development cycle (Mario
     Limonciello)

   - Move a X86_FEATURE_IDA check from turbo_is_disabled() to the places
     where a new value for MSR_IA32_PERF_CTL is computed in intel_pstate
     to address a regression preventing users from enabling turbo
     frequencies post-boot (Srinivas Pandruvada)"

* tag 'pm-6.18-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  cpufreq: intel_pstate: Check IDA only before MSR_IA32_PERF_CTL writes
  PM: hibernate: Fix style issues in save_compressed_image()
  PM: hibernate: Use atomic64_t for compressed_size variable
  PM: hibernate: Emit an error when image writing fails
pull/1354/merge
Linus Torvalds 2025-11-13 16:31:07 -08:00
commit aecba2e013
2 changed files with 17 additions and 14 deletions

View File

@ -603,9 +603,6 @@ static bool turbo_is_disabled(void)
{
u64 misc_en;
if (!cpu_feature_enabled(X86_FEATURE_IDA))
return true;
rdmsrq(MSR_IA32_MISC_ENABLE, misc_en);
return !!(misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE);
@ -2106,7 +2103,8 @@ static u64 atom_get_val(struct cpudata *cpudata, int pstate)
u32 vid;
val = (u64)pstate << 8;
if (READ_ONCE(global.no_turbo) && !READ_ONCE(global.turbo_disabled))
if (READ_ONCE(global.no_turbo) && !READ_ONCE(global.turbo_disabled) &&
cpu_feature_enabled(X86_FEATURE_IDA))
val |= (u64)1 << 32;
vid_fp = cpudata->vid.min + mul_fp(
@ -2271,7 +2269,8 @@ static u64 core_get_val(struct cpudata *cpudata, int pstate)
u64 val;
val = (u64)pstate << 8;
if (READ_ONCE(global.no_turbo) && !READ_ONCE(global.turbo_disabled))
if (READ_ONCE(global.no_turbo) && !READ_ONCE(global.turbo_disabled) &&
cpu_feature_enabled(X86_FEATURE_IDA))
val |= (u64)1 << 32;
return val;

View File

@ -635,7 +635,7 @@ struct cmp_data {
};
/* Indicates the image size after compression */
static atomic_t compressed_size = ATOMIC_INIT(0);
static atomic64_t compressed_size = ATOMIC_INIT(0);
/*
* Compression function that runs in its own thread.
@ -664,7 +664,7 @@ static int compress_threadfn(void *data)
d->ret = crypto_acomp_compress(d->cr);
d->cmp_len = d->cr->dlen;
atomic_set(&compressed_size, atomic_read(&compressed_size) + d->cmp_len);
atomic64_add(d->cmp_len, &compressed_size);
atomic_set_release(&d->stop, 1);
wake_up(&d->done);
}
@ -689,14 +689,14 @@ static int save_compressed_image(struct swap_map_handle *handle,
ktime_t start;
ktime_t stop;
size_t off;
unsigned thr, run_threads, nr_threads;
unsigned int thr, run_threads, nr_threads;
unsigned char *page = NULL;
struct cmp_data *data = NULL;
struct crc_data *crc = NULL;
hib_init_batch(&hb);
atomic_set(&compressed_size, 0);
atomic64_set(&compressed_size, 0);
/*
* We'll limit the number of threads for compression to limit memory
@ -877,11 +877,14 @@ out_finish:
stop = ktime_get();
if (!ret)
ret = err2;
if (!ret)
if (!ret) {
swsusp_show_speed(start, stop, nr_to_write, "Wrote");
pr_info("Image size after compression: %lld kbytes\n",
(atomic64_read(&compressed_size) / 1024));
pr_info("Image saving done\n");
swsusp_show_speed(start, stop, nr_to_write, "Wrote");
pr_info("Image size after compression: %d kbytes\n",
(atomic_read(&compressed_size) / 1024));
} else {
pr_err("Image saving failed: %d\n", ret);
}
out_clean:
hib_finish_batch(&hb);
@ -899,7 +902,8 @@ out_clean:
}
vfree(data);
}
if (page) free_page((unsigned long)page);
if (page)
free_page((unsigned long)page);
return ret;
}