Skip to content

Commit 3da0139

Browse files
Shyam Sundar S Kjwrdegoede
authored andcommitted
platform/x86/amd/pmf: Remove smart_pc_status enum
Improve code readability by removing smart_pc_status enum, as the same can be done with a simple true/false check; Update the code checks accordingly. Also add a missing return on amd_pmf_init_smart_pc() success, to skip trying to setup the auto / slider modes which should not be used in this case. Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Link: https://lore.kernel.org/r/20240216064112.962582-1-Shyam-sundar.S-k@amd.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
1 parent f0ddb8a commit 3da0139

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

drivers/platform/x86/amd/pmf/core.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,14 @@ static void amd_pmf_init_features(struct amd_pmf_dev *dev)
330330
dev_dbg(dev->dev, "SPS enabled and Platform Profiles registered\n");
331331
}
332332

333-
if (!amd_pmf_init_smart_pc(dev)) {
333+
amd_pmf_init_smart_pc(dev);
334+
if (dev->smart_pc_enabled) {
334335
dev_dbg(dev->dev, "Smart PC Solution Enabled\n");
335-
} else if (is_apmf_func_supported(dev, APMF_FUNC_AUTO_MODE)) {
336+
/* If Smart PC is enabled, no need to check for other features */
337+
return;
338+
}
339+
340+
if (is_apmf_func_supported(dev, APMF_FUNC_AUTO_MODE)) {
336341
amd_pmf_init_auto_mode(dev);
337342
dev_dbg(dev->dev, "Auto Mode Init done\n");
338343
} else if (is_apmf_func_supported(dev, APMF_FUNC_DYN_SLIDER_AC) ||
@@ -351,7 +356,7 @@ static void amd_pmf_deinit_features(struct amd_pmf_dev *dev)
351356
amd_pmf_deinit_sps(dev);
352357
}
353358

354-
if (!dev->smart_pc_enabled) {
359+
if (dev->smart_pc_enabled) {
355360
amd_pmf_deinit_smart_pc(dev);
356361
} else if (is_apmf_func_supported(dev, APMF_FUNC_AUTO_MODE)) {
357362
amd_pmf_deinit_auto_mode(dev);

drivers/platform/x86/amd/pmf/pmf.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -441,11 +441,6 @@ struct apmf_dyn_slider_output {
441441
struct apmf_cnqf_power_set ps[APMF_CNQF_MAX];
442442
} __packed;
443443

444-
enum smart_pc_status {
445-
PMF_SMART_PC_ENABLED,
446-
PMF_SMART_PC_DISABLED,
447-
};
448-
449444
/* Smart PC - TA internals */
450445
enum system_state {
451446
SYSTEM_STATE_S0i3,

drivers/platform/x86/amd/pmf/tee-if.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,15 +260,15 @@ static int amd_pmf_start_policy_engine(struct amd_pmf_dev *dev)
260260
res = amd_pmf_invoke_cmd_init(dev);
261261
if (res == TA_PMF_TYPE_SUCCESS) {
262262
/* Now its safe to announce that smart pc is enabled */
263-
dev->smart_pc_enabled = PMF_SMART_PC_ENABLED;
263+
dev->smart_pc_enabled = true;
264264
/*
265265
* Start collecting the data from TA FW after a small delay
266266
* or else, we might end up getting stale values.
267267
*/
268268
schedule_delayed_work(&dev->pb_work, msecs_to_jiffies(pb_actions_ms * 3));
269269
} else {
270270
dev_err(dev->dev, "ta invoke cmd init failed err: %x\n", res);
271-
dev->smart_pc_enabled = PMF_SMART_PC_DISABLED;
271+
dev->smart_pc_enabled = false;
272272
return res;
273273
}
274274

0 commit comments

Comments
 (0)