drm/amdgpu: Simplify calculation in *get_sleep_divider_id_from_clock
authorNils Wallménius <nils.wallmenius@gmail.com>
Thu, 5 May 2016 07:07:47 +0000 (09:07 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 11 May 2016 16:31:23 +0000 (12:31 -0400)
a / (1 << b) is equivalent to a >> b for unsigned values

Signed-off-by: Nils Wallménius <nils.wallmenius@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/ci_dpm.c
drivers/gpu/drm/amd/amdgpu/kv_dpm.c
drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.c
drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c
drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c

index 4d50c43c0939904f2155a1fed9a4f45aec745e4a..b2c2f3761c68555b8593859a022bddd8668702d0 100644 (file)
@@ -2560,7 +2560,7 @@ static u8 ci_get_sleep_divider_id_from_clock(struct amdgpu_device *adev,
                return 0;
 
        for (i = CISLAND_MAX_DEEPSLEEP_DIVIDER_ID;  ; i--) {
-               tmp = sclk / (1 << i);
+               tmp = sclk >> i;
                if (tmp >= min || i == 0)
                        break;
        }
index 4bc107a4546e6e50fa35c9588c75831a47af6e59..bc7997b649c08defc3e77d27c5c6eb915cdb4b77 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)
@@ -2185,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;
        }
index 9847e20860bc49984d3a335cb69af01fa63d3732..cc4b714c0c09cc5560297159fe6233926478653f 100644 (file)
@@ -1907,7 +1907,7 @@ static uint8_t fiji_get_sleep_divider_id_from_clock(struct pp_hwmgr *hwmgr,
 
        PP_ASSERT_WITH_CODE((clock >= min), "Engine clock can't satisfy stutter requirement!", return 0);
        for (i = FIJI_MAX_DEEPSLEEP_DIVIDER_ID;  ; i--) {
-               temp = clock / (1UL << i);
+               temp = clock >> i;
 
                if (temp >= min || i == 0)
                        break;
index c911ab881d6aff62746fbb4a364017bc6d888a37..93768fa1dcdc34e9a970713b6d77a03bcf80df74 100644 (file)
@@ -1177,7 +1177,7 @@ static int polaris10_populate_single_graphic_level(struct pp_hwmgr *hwmgr,
        */
        PP_ASSERT_WITH_CODE((clock >= POLARIS10_MINIMUM_ENGINE_CLOCK), "Engine clock can't satisfy stutter requirement!", return 0);
        for (i = POLARIS10_MAX_DEEPSLEEP_DIVIDER_ID;  ; i--) {
-               temp = clock / (1UL << i);
+               temp = clock >> i;
 
                if (temp >= POLARIS10_MINIMUM_ENGINE_CLOCK || i == 0)
                        break;
index 8969f1ef1de5687b5e48f651ca7acf527874f001..13f97708e54cb316dbca43bca30bcd240299e164 100644 (file)
@@ -2426,7 +2426,7 @@ static uint8_t tonga_get_sleep_divider_id_from_clock(struct pp_hwmgr *hwmgr,
                        "Engine clock can't satisfy stutter requirement!", return 0);
 
        for (i = TONGA_MAX_DEEPSLEEP_DIVIDER_ID;; i--) {
-               temp = engine_clock / (1 << i);
+               temp = engine_clock >> i;
 
                if(temp >= min || i == 0)
                        break;