OSDN Git Service

drm/amd/powerplay: simplify the code around retrieving power limit
authorEvan Quan <evan.quan@amd.com>
Mon, 8 Jun 2020 08:41:16 +0000 (16:41 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 1 Jul 2020 05:59:18 +0000 (01:59 -0400)
Use the cached max/current power limit for other cases except
.late_init.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
drivers/gpu/drm/amd/powerplay/navi10_ppt.c
drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c
drivers/gpu/drm/amd/powerplay/smu_internal.h

index a5fd128..6757f65 100644 (file)
@@ -831,9 +831,9 @@ static int smu_late_init(void *handle)
                return ret;
        }
 
-       ret = smu_get_power_limit(smu, &smu->default_power_limit, false, false);
+       ret = smu_get_asic_power_limits(smu);
        if (ret) {
-               dev_err(adev->dev, "Failed to get default power limit!\n");
+               dev_err(adev->dev, "Failed to get asic power limits!\n");
                return ret;
        }
 
@@ -2222,8 +2222,7 @@ int smu_get_power_limit(struct smu_context *smu,
                mutex_lock(&smu->mutex);
        }
 
-       if (smu->ppt_funcs->get_power_limit)
-               ret = smu->ppt_funcs->get_power_limit(smu, limit, def);
+       *limit = (def ? smu->max_power_limit : smu->current_power_limit);
 
        if (lock_needed)
                mutex_unlock(&smu->mutex);
index 2c78271..66b8f14 100644 (file)
@@ -1409,9 +1409,7 @@ arcturus_get_profiling_clk_mask(struct smu_context *smu,
        return 0;
 }
 
-static int arcturus_get_power_limit(struct smu_context *smu,
-                                    uint32_t *limit,
-                                    bool cap)
+static int arcturus_get_power_limit(struct smu_context *smu)
 {
        struct smu_11_0_powerplay_table *powerplay_table =
                (struct smu_11_0_powerplay_table *)smu->smu_table.power_play_table;
@@ -1439,8 +1437,6 @@ static int arcturus_get_power_limit(struct smu_context *smu,
        }
        smu->max_power_limit = power_limit;
 
-       *limit = (cap ? smu->max_power_limit : smu->current_power_limit);
-
        return 0;
 }
 
index 574a793..db63ed0 100644 (file)
@@ -487,7 +487,7 @@ struct pptable_funcs {
        int (*set_performance_level)(struct smu_context *smu, enum amd_dpm_forced_level level);
        int (*display_disable_memory_clock_switch)(struct smu_context *smu, bool disable_memory_clock_switch);
        void (*dump_pptable)(struct smu_context *smu);
-       int (*get_power_limit)(struct smu_context *smu, uint32_t *limit, bool asic_default);
+       int (*get_power_limit)(struct smu_context *smu);
        int (*get_dpm_clk_limited)(struct smu_context *smu, enum smu_clk_type clk_type,
                                   uint32_t dpm_level, uint32_t *freq);
        int (*set_df_cstate)(struct smu_context *smu, enum pp_df_cstate state);
index b867f94..2e08369 100644 (file)
@@ -1922,9 +1922,7 @@ static uint32_t navi10_get_pptable_power_limit(struct smu_context *smu)
        return pptable->SocketPowerLimitAc[PPT_THROTTLER_PPT0];
 }
 
-static int navi10_get_power_limit(struct smu_context *smu,
-                                 uint32_t *limit,
-                                 bool cap)
+static int navi10_get_power_limit(struct smu_context *smu)
 {
        struct smu_11_0_powerplay_table *powerplay_table =
                (struct smu_11_0_powerplay_table *)smu->smu_table.power_play_table;
@@ -1952,8 +1950,6 @@ static int navi10_get_power_limit(struct smu_context *smu,
        }
        smu->max_power_limit = power_limit;
 
-       *limit = (cap ? smu->max_power_limit : smu->current_power_limit);
-
        return 0;
 }
 
index c427e23..44719c1 100644 (file)
@@ -1743,9 +1743,7 @@ static uint32_t sienna_cichlid_get_pptable_power_limit(struct smu_context *smu)
        return pptable->SocketPowerLimitAc[PPT_THROTTLER_PPT0];
 }
 
-static int sienna_cichlid_get_power_limit(struct smu_context *smu,
-                                    uint32_t *limit,
-                                    bool cap)
+static int sienna_cichlid_get_power_limit(struct smu_context *smu)
 {
        struct smu_11_0_7_powerplay_table *powerplay_table =
                (struct smu_11_0_7_powerplay_table *)smu->smu_table.power_play_table;
@@ -1773,8 +1771,6 @@ static int sienna_cichlid_get_power_limit(struct smu_context *smu,
        }
        smu->max_power_limit = power_limit;
 
-       *limit = (cap ? smu->max_power_limit : smu->current_power_limit);
-
        return 0;
 }
 
index 9c68c6c..346aea9 100644 (file)
@@ -213,4 +213,7 @@ static inline int smu_send_smc_msg(struct smu_context *smu, enum smu_message_typ
 #define smu_log_thermal_throttling(smu) \
                ((smu)->ppt_funcs->log_thermal_throttling_event ? (smu)->ppt_funcs->log_thermal_throttling_event((smu)) : 0)
 
+#define smu_get_asic_power_limits(smu) \
+               ((smu)->ppt_funcs->get_power_limit ? (smu)->ppt_funcs->get_power_limit((smu)) : 0)
+
 #endif