]> git.baikalelectronics.ru Git - kernel.git/commitdiff
platform/x86/amd/pmf: Add helper routine to update SPS thermals
authorShyam Sundar S K <Shyam-sundar.S-k@amd.com>
Wed, 25 Jan 2023 09:59:32 +0000 (15:29 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Feb 2023 10:28:06 +0000 (11:28 +0100)
[ Upstream commit c5258d39fc4cbed37e20945715e7eb102f26d65b ]

Add helper routine to update the static slider information
and remove the duplicate code occurrences after this change.

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/20230125095936.3292883-2-Shyam-sundar.S-k@amd.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Stable-dep-of: 635f79bc73cf ("platform/x86/amd/pmf: Fix to update SPS default pprof thermals")
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/platform/x86/amd/pmf/auto-mode.c
drivers/platform/x86/amd/pmf/cnqf.c
drivers/platform/x86/amd/pmf/pmf.h
drivers/platform/x86/amd/pmf/sps.c

index 85ce9ed25b85779ab24ac2de7abbb8b4d1c7e0c4..96a8e1832c05e9cbc9f50bb1305e7bfb92318213 100644 (file)
@@ -275,13 +275,8 @@ int amd_pmf_reset_amt(struct amd_pmf_dev *dev)
         */
 
        if (is_apmf_func_supported(dev, APMF_FUNC_STATIC_SLIDER_GRANULAR)) {
-               int mode = amd_pmf_get_pprof_modes(dev);
-
-               if (mode < 0)
-                       return mode;
-
                dev_dbg(dev->dev, "resetting AMT thermals\n");
-               amd_pmf_update_slider(dev, SLIDER_OP_SET, mode, NULL);
+               amd_pmf_set_sps_power_limits(dev);
        }
        return 0;
 }
index 668c7c0fea831cf1db6d902b3da228e24a9cfaef..ef2ac30ff15ecae59a9a3e9b49ab00f16600f7fd 100644 (file)
@@ -307,13 +307,9 @@ static ssize_t cnqf_enable_store(struct device *dev,
                                 const char *buf, size_t count)
 {
        struct amd_pmf_dev *pdev = dev_get_drvdata(dev);
-       int mode, result, src;
+       int result, src;
        bool input;
 
-       mode = amd_pmf_get_pprof_modes(pdev);
-       if (mode < 0)
-               return mode;
-
        result = kstrtobool(buf, &input);
        if (result)
                return result;
@@ -325,7 +321,7 @@ static ssize_t cnqf_enable_store(struct device *dev,
                amd_pmf_set_cnqf(pdev, src, config_store.current_mode, NULL);
        } else {
                if (is_apmf_func_supported(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR))
-                       amd_pmf_update_slider(pdev, SLIDER_OP_SET, mode, NULL);
+                       amd_pmf_set_sps_power_limits(pdev);
        }
 
        dev_dbg(pdev->dev, "Received CnQF %s\n", input ? "on" : "off");
index 84bbe2c6ea612b88ab9aea13e3d139f46f98e670..b5b77a353b965ba11de0c0696448b805fe8df71e 100644 (file)
@@ -394,6 +394,7 @@ int apmf_get_static_slider_granular(struct amd_pmf_dev *pdev,
 
 
 int apmf_update_fan_idx(struct amd_pmf_dev *pdev, bool manual, u32 idx);
+int amd_pmf_set_sps_power_limits(struct amd_pmf_dev *pmf);
 
 /* Auto Mode Layer */
 int apmf_get_auto_mode_def(struct amd_pmf_dev *pdev, struct apmf_auto_mode *data);
index dba7e36962dc1eadd034dcd8e61d9ebfe51fd93f..5f842d6e6db2f5b2268a3c62d7d92e5bad72be5b 100644 (file)
@@ -70,6 +70,19 @@ void amd_pmf_update_slider(struct amd_pmf_dev *dev, bool op, int idx,
        }
 }
 
+int amd_pmf_set_sps_power_limits(struct amd_pmf_dev *pmf)
+{
+       int mode;
+
+       mode = amd_pmf_get_pprof_modes(pmf);
+       if (mode < 0)
+               return mode;
+
+       amd_pmf_update_slider(pmf, SLIDER_OP_SET, mode, NULL);
+
+       return 0;
+}
+
 static int amd_pmf_profile_get(struct platform_profile_handler *pprof,
                               enum platform_profile_option *profile)
 {
@@ -105,15 +118,10 @@ static int amd_pmf_profile_set(struct platform_profile_handler *pprof,
                               enum platform_profile_option profile)
 {
        struct amd_pmf_dev *pmf = container_of(pprof, struct amd_pmf_dev, pprof);
-       int mode;
 
        pmf->current_profile = profile;
-       mode = amd_pmf_get_pprof_modes(pmf);
-       if (mode < 0)
-               return mode;
 
-       amd_pmf_update_slider(pmf, SLIDER_OP_SET, mode, NULL);
-       return 0;
+       return amd_pmf_set_sps_power_limits(pmf);
 }
 
 int amd_pmf_init_sps(struct amd_pmf_dev *dev)