Merge branch '4.8/omapdrm-pll' (omapdrm PLL work)
[cascardo/linux.git] / drivers / gpu / drm / amd / amdgpu / kv_dpm.c
index 4bd1e55..a789a86 100644 (file)
@@ -135,11 +135,6 @@ static void sumo_take_smu_control(struct amdgpu_device *adev, bool enable)
 #endif
 }
 
-static u32 sumo_get_sleep_divider_from_id(u32 id)
-{
-       return 1 << id;
-}
-
 static void sumo_construct_sclk_voltage_mapping_table(struct amdgpu_device *adev,
                                                      struct sumo_sclk_voltage_mapping_table *sclk_voltage_mapping_table,
                                                      ATOM_AVAILABLE_SCLK_LIST *table)
@@ -2176,8 +2171,7 @@ static u8 kv_get_sleep_divider_id_from_clock(struct amdgpu_device *adev,
        struct kv_power_info *pi = kv_get_pi(adev);
        u32 i;
        u32 temp;
-       u32 min = (min_sclk_in_sr > KV_MINIMUM_ENGINE_CLOCK) ?
-               min_sclk_in_sr : KV_MINIMUM_ENGINE_CLOCK;
+       u32 min = max(min_sclk_in_sr, (u32)KV_MINIMUM_ENGINE_CLOCK);
 
        if (sclk < min)
                return 0;
@@ -2186,7 +2180,7 @@ static u8 kv_get_sleep_divider_id_from_clock(struct amdgpu_device *adev,
                return 0;
 
        for (i = KV_MAX_DEEPSLEEP_DIVIDER_ID; i > 0; i--) {
-               temp = sclk / sumo_get_sleep_divider_from_id(i);
+               temp = sclk >> i;
                if (temp >= min)
                        break;
        }
@@ -2258,7 +2252,7 @@ static void kv_apply_state_adjust_rules(struct amdgpu_device *adev,
        if (pi->caps_stable_p_state) {
                stable_p_state_sclk = (max_limits->sclk * 75) / 100;
 
-               for (i = table->count - 1; i >= 0; i++) {
+               for (i = table->count - 1; i >= 0; i--) {
                        if (stable_p_state_sclk >= table->entries[i].clk) {
                                stable_p_state_sclk = table->entries[i].clk;
                                break;
@@ -3244,6 +3238,7 @@ static int kv_dpm_set_powergating_state(void *handle,
 }
 
 const struct amd_ip_funcs kv_dpm_ip_funcs = {
+       .name = "kv_dpm",
        .early_init = kv_dpm_early_init,
        .late_init = kv_dpm_late_init,
        .sw_init = kv_dpm_sw_init,