Patch "thermal: intel: hfi: Add syscore callbacks for system-wide PM" has been added to the 6.7-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    thermal: intel: hfi: Add syscore callbacks for system-wide PM

to the 6.7-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     thermal-intel-hfi-add-syscore-callbacks-for-system-w.patch
and it can be found in the queue-6.7 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 49cd51dd1a6c35f57633ae76718ba7e45b1dded0
Author: Ricardo Neri <ricardo.neri-calderon@xxxxxxxxxxxxxxx>
Date:   Tue Jan 9 19:07:04 2024 -0800

    thermal: intel: hfi: Add syscore callbacks for system-wide PM
    
    [ Upstream commit 97566d09fd02d2ab329774bb89a2cdf2267e86d9 ]
    
    The kernel allocates a memory buffer and provides its location to the
    hardware, which uses it to update the HFI table. This allocation occurs
    during boot and remains constant throughout runtime.
    
    When resuming from hibernation, the restore kernel allocates a second
    memory buffer and reprograms the HFI hardware with the new location as
    part of a normal boot. The location of the second memory buffer may
    differ from the one allocated by the image kernel.
    
    When the restore kernel transfers control to the image kernel, its HFI
    buffer becomes invalid, potentially leading to memory corruption if the
    hardware writes to it (the hardware continues to use the buffer from the
    restore kernel).
    
    It is also possible that the hardware "forgets" the address of the memory
    buffer when resuming from "deep" suspend. Memory corruption may also occur
    in such a scenario.
    
    To prevent the described memory corruption, disable HFI when preparing to
    suspend or hibernate. Enable it when resuming.
    
    Add syscore callbacks to handle the package of the boot CPU (packages of
    non-boot CPUs are handled via CPU offline). Syscore ops always run on the
    boot CPU. Additionally, HFI only needs to be disabled during "deep" suspend
    and hibernation. Syscore ops only run in these cases.
    
    Cc: 6.1+ <stable@xxxxxxxxxxxxxxx> # 6.1+
    Signed-off-by: Ricardo Neri <ricardo.neri-calderon@xxxxxxxxxxxxxxx>
    [ rjw: Comment adjustment, subject and changelog edits ]
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c
index bb25c75acd45..1c5a429b2e3e 100644
--- a/drivers/thermal/intel/intel_hfi.c
+++ b/drivers/thermal/intel/intel_hfi.c
@@ -35,7 +35,9 @@
 #include <linux/processor.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
+#include <linux/suspend.h>
 #include <linux/string.h>
+#include <linux/syscore_ops.h>
 #include <linux/topology.h>
 #include <linux/workqueue.h>
 
@@ -568,6 +570,30 @@ static __init int hfi_parse_features(void)
 	return 0;
 }
 
+static void hfi_do_enable(void)
+{
+	/* This code runs only on the boot CPU. */
+	struct hfi_cpu_info *info = &per_cpu(hfi_cpu_info, 0);
+	struct hfi_instance *hfi_instance = info->hfi_instance;
+
+	/* No locking needed. There is no concurrency with CPU online. */
+	hfi_set_hw_table(hfi_instance);
+	hfi_enable();
+}
+
+static int hfi_do_disable(void)
+{
+	/* No locking needed. There is no concurrency with CPU offline. */
+	hfi_disable();
+
+	return 0;
+}
+
+static struct syscore_ops hfi_pm_ops = {
+	.resume = hfi_do_enable,
+	.suspend = hfi_do_disable,
+};
+
 void __init intel_hfi_init(void)
 {
 	struct hfi_instance *hfi_instance;
@@ -599,6 +625,8 @@ void __init intel_hfi_init(void)
 	if (!hfi_updates_wq)
 		goto err_nomem;
 
+	register_syscore_ops(&hfi_pm_ops);
+
 	return;
 
 err_nomem:




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux