Commit 16909aa8 authored by Shyam Sundar S K's avatar Shyam Sundar S K Committed by Hans de Goede

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: default avatarShyam Sundar S K <Shyam-sundar.S-k@amd.com>
Reviewed-by: default avatarMario Limonciello <mario.limonciello@amd.com>
Link: https://lore.kernel.org/r/20230125095936.3292883-3-Shyam-sundar.S-k@amd.comReviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
parent c5258d39
...@@ -103,7 +103,7 @@ int amd_pmf_trans_cnqf(struct amd_pmf_dev *dev, int socket_power, ktime_t time_l ...@@ -103,7 +103,7 @@ int amd_pmf_trans_cnqf(struct amd_pmf_dev *dev, int socket_power, ktime_t time_l
src = amd_pmf_cnqf_get_power_source(dev); src = amd_pmf_cnqf_get_power_source(dev);
if (dev->current_profile == PLATFORM_PROFILE_BALANCED) { if (is_pprof_balanced(dev)) {
amd_pmf_set_cnqf(dev, src, config_store.current_mode, NULL); amd_pmf_set_cnqf(dev, src, config_store.current_mode, NULL);
} else { } else {
/* /*
...@@ -317,7 +317,7 @@ static ssize_t cnqf_enable_store(struct device *dev, ...@@ -317,7 +317,7 @@ static ssize_t cnqf_enable_store(struct device *dev,
src = amd_pmf_cnqf_get_power_source(pdev); src = amd_pmf_cnqf_get_power_source(pdev);
pdev->cnqf_enabled = input; pdev->cnqf_enabled = input;
if (pdev->cnqf_enabled && pdev->current_profile == PLATFORM_PROFILE_BALANCED) { if (pdev->cnqf_enabled && is_pprof_balanced(pdev)) {
amd_pmf_set_cnqf(pdev, src, config_store.current_mode, NULL); amd_pmf_set_cnqf(pdev, src, config_store.current_mode, NULL);
} else { } else {
if (is_apmf_func_supported(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR)) 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) ...@@ -382,7 +382,7 @@ int amd_pmf_init_cnqf(struct amd_pmf_dev *dev)
dev->cnqf_enabled = amd_pmf_check_flags(dev); dev->cnqf_enabled = amd_pmf_check_flags(dev);
/* update the thermal for CnQF */ /* update the thermal for CnQF */
if (dev->cnqf_enabled && dev->current_profile == PLATFORM_PROFILE_BALANCED) { if (dev->cnqf_enabled && is_pprof_balanced(dev)) {
src = amd_pmf_cnqf_get_power_source(dev); src = amd_pmf_cnqf_get_power_source(dev);
amd_pmf_set_cnqf(dev, src, config_store.current_mode, NULL); amd_pmf_set_cnqf(dev, src, config_store.current_mode, NULL);
} }
......
...@@ -391,6 +391,7 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev); ...@@ -391,6 +391,7 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev);
void amd_pmf_deinit_sps(struct amd_pmf_dev *dev); void amd_pmf_deinit_sps(struct amd_pmf_dev *dev);
int apmf_get_static_slider_granular(struct amd_pmf_dev *pdev, int apmf_get_static_slider_granular(struct amd_pmf_dev *pdev,
struct apmf_static_slider_granular_output *output); struct apmf_static_slider_granular_output *output);
bool is_pprof_balanced(struct amd_pmf_dev *pmf);
int apmf_update_fan_idx(struct amd_pmf_dev *pdev, bool manual, u32 idx); int apmf_update_fan_idx(struct amd_pmf_dev *pdev, bool manual, u32 idx);
......
...@@ -83,6 +83,11 @@ int amd_pmf_set_sps_power_limits(struct amd_pmf_dev *pmf) ...@@ -83,6 +83,11 @@ int amd_pmf_set_sps_power_limits(struct amd_pmf_dev *pmf)
return 0; return 0;
} }
bool is_pprof_balanced(struct amd_pmf_dev *pmf)
{
return (pmf->current_profile == PLATFORM_PROFILE_BALANCED) ? true : false;
}
static int amd_pmf_profile_get(struct platform_profile_handler *pprof, static int amd_pmf_profile_get(struct platform_profile_handler *pprof,
enum platform_profile_option *profile) enum platform_profile_option *profile)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment