History

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

Linus Torvalds committed 1 year ago

Commit aecba2e2 parents 6a3cc1b 161284b2 files · +17 −14Browse files

Unified · Split

2 files
  1. drivers/cpufreq/intel_pstate.c +4 −5
  2. kernel/power/swap.c +13 −9
drivers/cpufreq/intel_pstate.c+4−5
@@ -603,9 +603,6 @@ static bool turbo_is_disabled(void) · 602 unmodified lines
603{603{
604 u64 misc_en;604 u64 misc_en;
605 605
606 if (!cpu_feature_enabled(X86_FEATURE_IDA))
607 return true;
608
609 rdmsrq(MSR_IA32_MISC_ENABLE, misc_en);606 rdmsrq(MSR_IA32_MISC_ENABLE, misc_en);
610 607
611 return !!(misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE);608 return !!(misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE);
@@ -2106,7 +2103,8 @@ static u64 atom_get_val(struct cpudata *cpudata, int pstate) · 1494 unmodified lines
2106 u32 vid;2103 u32 vid;
2107 2104
2108 val = (u64)pstate << 8;2105 val = (u64)pstate << 8;
2109 if (READ_ONCE(global.no_turbo) && !READ_ONCE(global.turbo_disabled))2106 if (READ_ONCE(global.no_turbo) && !READ_ONCE(global.turbo_disabled) &&
2107 cpu_feature_enabled(X86_FEATURE_IDA))
2110 val |= (u64)1 << 32;2108 val |= (u64)1 << 32;
2111 2109
2112 vid_fp = cpudata->vid.min + mul_fp(2110 vid_fp = cpudata->vid.min + mul_fp(
@@ -2271,7 +2269,8 @@ static u64 core_get_val(struct cpudata *cpudata, int pstate) · 158 unmodified lines
2271 u64 val;2269 u64 val;
2272 2270
2273 val = (u64)pstate << 8;2271 val = (u64)pstate << 8;
2274 if (READ_ONCE(global.no_turbo) && !READ_ONCE(global.turbo_disabled))2272 if (READ_ONCE(global.no_turbo) && !READ_ONCE(global.turbo_disabled) &&
2273 cpu_feature_enabled(X86_FEATURE_IDA))
2275 val |= (u64)1 << 32;2274 val |= (u64)1 << 32;
2276 2275
2277 return val;2276 return val;
kernel/power/swap.c+13−9
@@ -635,7 +635,7 @@ struct cmp_data { · 634 unmodified lines
635};635};
636 636
637/* Indicates the image size after compression */637/* Indicates the image size after compression */
638static atomic_t compressed_size = ATOMIC_INIT(0);638static atomic64_t compressed_size = ATOMIC_INIT(0);
639 639
640/*640/*
641 * Compression function that runs in its own thread.641 * Compression function that runs in its own thread.
@@ -664,7 +664,7 @@ static int compress_threadfn(void *data) · 22 unmodified lines
664 d->ret = crypto_acomp_compress(d->cr);664 d->ret = crypto_acomp_compress(d->cr);
665 d->cmp_len = d->cr->dlen;665 d->cmp_len = d->cr->dlen;
666 666
667 atomic_set(&compressed_size, atomic_read(&compressed_size) + d->cmp_len);667 atomic64_add(d->cmp_len, &compressed_size);
668 atomic_set_release(&d->stop, 1);668 atomic_set_release(&d->stop, 1);
669 wake_up(&d->done);669 wake_up(&d->done);
670 }670 }
@@ -689,14 +689,14 @@ static int save_compressed_image(struct swap_map_handle *handle, · 18 unmodified lines
689 ktime_t start;689 ktime_t start;
690 ktime_t stop;690 ktime_t stop;
691 size_t off;691 size_t off;
692 unsigned thr, run_threads, nr_threads;692 unsigned int thr, run_threads, nr_threads;
693 unsigned char *page = NULL;693 unsigned char *page = NULL;
694 struct cmp_data *data = NULL;694 struct cmp_data *data = NULL;
695 struct crc_data *crc = NULL;695 struct crc_data *crc = NULL;
696 696
697 hib_init_batch(&hb);697 hib_init_batch(&hb);
698 698
699 atomic_set(&compressed_size, 0);699 atomic64_set(&compressed_size, 0);
700 700
701 /*701 /*
702 * We'll limit the number of threads for compression to limit memory702 * We'll limit the number of threads for compression to limit memory
@@ -877,11 +877,14 @@ out_finish: · 174 unmodified lines
877 stop = ktime_get();877 stop = ktime_get();
878 if (!ret)878 if (!ret)
879 ret = err2;879 ret = err2;
880 if (!ret)880 if (!ret) {
881 swsusp_show_speed(start, stop, nr_to_write, "Wrote");
882 pr_info("Image size after compression: %lld kbytes\n",
883 (atomic64_read(&compressed_size) / 1024));
881 pr_info("Image saving done\n");884 pr_info("Image saving done\n");
882 swsusp_show_speed(start, stop, nr_to_write, "Wrote");885 } else {
883 pr_info("Image size after compression: %d kbytes\n",886 pr_err("Image saving failed: %d\n", ret);
884 (atomic_read(&compressed_size) / 1024));887 }
885 888
886out_clean:889out_clean:
887 hib_finish_batch(&hb);890 hib_finish_batch(&hb);
@@ -899,7 +902,8 @@ out_clean: · 11 unmodified lines
899 }902 }
900 vfree(data);903 vfree(data);
901 }904 }
902 if (page) free_page((unsigned long)page);905 if (page)
906 free_page((unsigned long)page);
903 907
904 return ret;908 return ret;
905}909}