On 8/27/2024 04:36, Perry Yuan wrote:
From: Perry Yuan <Perry.Yuan@xxxxxxx>
Introduces power management callbacks for the `amd_hfi` driver.
Specifically, the `suspend` and `resume` callbacks have been added
to handle the necessary operations during system low power states
and wake-up.
Signed-off-by: Perry Yuan <Perry.Yuan@xxxxxxx>
Reviewed-by: Mario Limonciello <mario.limonciello@xxxxxxx>
---
drivers/platform/x86/amd/hfi/hfi.c | 34 ++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/drivers/platform/x86/amd/hfi/hfi.c b/drivers/platform/x86/amd/hfi/hfi.c
index 57b642c4c522..c3da2edf8590 100644
--- a/drivers/platform/x86/amd/hfi/hfi.c
+++ b/drivers/platform/x86/amd/hfi/hfi.c
@@ -304,6 +304,39 @@ static void amd_hfi_remove(struct platform_device *pdev)
mutex_destroy(&dev->lock);
}
+static int amd_hfi_pm_resume(struct device *dev)
+{
+ int cpu, err;
+
+ for_each_present_cpu(cpu) {
+ err = amd_hfi_set_state(cpu, true);
+ if (err < 0) {
+ dev_err(dev, "failed to enable workload class config: %d\n", err);
+ return err;
+ }
+ }
+
+ return 0;
+}
+
+static int amd_hfi_pm_suspend(struct device *dev)
+{
+ int err, cpu;
+
+ for_each_possible_cpu(cpu) {
+ err = amd_hfi_set_state(cpu, false);
+ if (err < 0) {
+ dev_err(dev, "failed to disable workload class config: %d\n", err);
+ return err;
+ }
+ }
+
+ return 0;
+}
+
+static DEFINE_SIMPLE_DEV_PM_OPS(amd_hfi_pm_ops,
+ amd_hfi_pm_suspend, amd_hfi_pm_resume);
+
static int amd_set_hfi_ipcc_score(struct amd_hfi_cpuinfo *hfi_cpuinfo, int cpu)
{
int i, *hfi_scores;
@@ -569,6 +602,7 @@ static struct platform_driver amd_hfi_driver = {
.driver = {
.name = AMD_HFI_DRIVER,
.owner = THIS_MODULE,
+ .pm = &amd_hfi_pm_ops,
.acpi_match_table = ACPI_PTR(amd_hfi_platform_match),
},
.probe = amd_hfi_probe,