[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d2a39a68666e2dffa8f0ca9ba32deacc722ea2b1.1724748733.git.perry.yuan@amd.com>
Date: Tue, 27 Aug 2024 17:36:57 +0800
From: Perry Yuan <perry.yuan@....com>
To: <hdegoede@...hat.com>, <ilpo.jarvinen@...ux.intel.com>,
<Mario.Limonciello@....com>, <Borislav.Petkov@....com>,
<kprateek.nayak@....com>
CC: <Alexander.Deucher@....com>, <Xinmei.Huang@....com>,
<bharathprabhu.perdoor@....com>, <poonam.aggrwal@....com>, <Li.Meng@....com>,
<platform-driver-x86@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<Xiaojian.Du@....com>
Subject: [PATCH 09/11] platform/x86/: hfi: add power management callback
From: Perry Yuan <Perry.Yuan@....com>
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@....com>
---
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,
--
2.34.1
Powered by blists - more mailing lists