Skip to content

Commit 16909aa

Browse files
Shyam Sundar S Kjwrdegoede
authored andcommitted
platform/x86/amd/pmf: Add helper routine to check pprof is balanced
Add helper routine to check if the current platform profile is balanced mode and remove duplicate code occurrences. Signed-off-by: Shyam Sundar S K <[email protected]> Reviewed-by: Mario Limonciello <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Hans de Goede <[email protected]>
1 parent c5258d3 commit 16909aa

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ int amd_pmf_trans_cnqf(struct amd_pmf_dev *dev, int socket_power, ktime_t time_l
103103

104104
src = amd_pmf_cnqf_get_power_source(dev);
105105

106-
if (dev->current_profile == PLATFORM_PROFILE_BALANCED) {
106+
if (is_pprof_balanced(dev)) {
107107
amd_pmf_set_cnqf(dev, src, config_store.current_mode, NULL);
108108
} else {
109109
/*
@@ -317,7 +317,7 @@ static ssize_t cnqf_enable_store(struct device *dev,
317317
src = amd_pmf_cnqf_get_power_source(pdev);
318318
pdev->cnqf_enabled = input;
319319

320-
if (pdev->cnqf_enabled && pdev->current_profile == PLATFORM_PROFILE_BALANCED) {
320+
if (pdev->cnqf_enabled && is_pprof_balanced(pdev)) {
321321
amd_pmf_set_cnqf(pdev, src, config_store.current_mode, NULL);
322322
} else {
323323
if (is_apmf_func_supported(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR))
@@ -382,7 +382,7 @@ int amd_pmf_init_cnqf(struct amd_pmf_dev *dev)
382382
dev->cnqf_enabled = amd_pmf_check_flags(dev);
383383

384384
/* update the thermal for CnQF */
385-
if (dev->cnqf_enabled && dev->current_profile == PLATFORM_PROFILE_BALANCED) {
385+
if (dev->cnqf_enabled && is_pprof_balanced(dev)) {
386386
src = amd_pmf_cnqf_get_power_source(dev);
387387
amd_pmf_set_cnqf(dev, src, config_store.current_mode, NULL);
388388
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev);
391391
void amd_pmf_deinit_sps(struct amd_pmf_dev *dev);
392392
int apmf_get_static_slider_granular(struct amd_pmf_dev *pdev,
393393
struct apmf_static_slider_granular_output *output);
394+
bool is_pprof_balanced(struct amd_pmf_dev *pmf);
394395

395396

396397
int apmf_update_fan_idx(struct amd_pmf_dev *pdev, bool manual, u32 idx);

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ int amd_pmf_set_sps_power_limits(struct amd_pmf_dev *pmf)
8383
return 0;
8484
}
8585

86+
bool is_pprof_balanced(struct amd_pmf_dev *pmf)
87+
{
88+
return (pmf->current_profile == PLATFORM_PROFILE_BALANCED) ? true : false;
89+
}
90+
8691
static int amd_pmf_profile_get(struct platform_profile_handler *pprof,
8792
enum platform_profile_option *profile)
8893
{

0 commit comments

Comments
 (0)