drm/amd/pp: Revert gfx/compute profile switch sysfs
[linux-2.6-block.git] / drivers / gpu / drm / amd / powerplay / hwmgr / vega10_hwmgr.c
index a7c610a0e7e1d875e07517434c826e043413fe43..d90a0f1dbb5557a1d31bc9759f22596a7590b2b0 100644 (file)
@@ -190,8 +190,7 @@ static int vega10_set_features_platform_caps(struct pp_hwmgr *hwmgr)
                        (struct vega10_hwmgr *)(hwmgr->backend);
        struct phm_ppt_v2_information *table_info =
                        (struct phm_ppt_v2_information *)hwmgr->pptable;
-       struct cgs_system_info sys_info = {0};
-       int result;
+       struct amdgpu_device *adev = hwmgr->adev;
 
        phm_cap_set(hwmgr->platform_descriptor.platformCaps,
                        PHM_PlatformCaps_SclkDeepSleep);
@@ -206,15 +205,11 @@ static int vega10_set_features_platform_caps(struct pp_hwmgr *hwmgr)
        phm_cap_set(hwmgr->platform_descriptor.platformCaps,
                        PHM_PlatformCaps_EnableSMU7ThermalManagement);
 
-       sys_info.size = sizeof(struct cgs_system_info);
-       sys_info.info_id = CGS_SYSTEM_INFO_PG_FLAGS;
-       result = cgs_query_system_info(hwmgr->device, &sys_info);
-
-       if (!result && (sys_info.value & AMD_PG_SUPPORT_UVD))
+       if (adev->pg_flags & AMD_PG_SUPPORT_UVD)
                phm_cap_set(hwmgr->platform_descriptor.platformCaps,
                                PHM_PlatformCaps_UVDPowerGating);
 
-       if (!result && (sys_info.value & AMD_PG_SUPPORT_VCE))
+       if (adev->pg_flags & AMD_PG_SUPPORT_VCE)
                phm_cap_set(hwmgr->platform_descriptor.platformCaps,
                                PHM_PlatformCaps_VCEPowerGating);
 
@@ -304,6 +299,8 @@ static void vega10_init_dpm_defaults(struct pp_hwmgr *hwmgr)
 {
        struct vega10_hwmgr *data = (struct vega10_hwmgr *)(hwmgr->backend);
        int i;
+       uint32_t sub_vendor_id, hw_revision;
+       struct amdgpu_device *adev = hwmgr->adev;
 
        vega10_initialize_power_tune_defaults(hwmgr);
 
@@ -368,6 +365,7 @@ static void vega10_init_dpm_defaults(struct pp_hwmgr *hwmgr)
                        FEATURE_FAN_CONTROL_BIT;
        data->smu_features[GNLD_ACG].smu_feature_id = FEATURE_ACG_BIT;
        data->smu_features[GNLD_DIDT].smu_feature_id = FEATURE_GFX_EDC_BIT;
+       data->smu_features[GNLD_PCC_LIMIT].smu_feature_id = FEATURE_PCC_LIMIT_CONTROL_BIT;
 
        if (!data->registry_data.prefetcher_dpm_key_disabled)
                data->smu_features[GNLD_DPM_PREFETCHER].supported = true;
@@ -437,6 +435,15 @@ static void vega10_init_dpm_defaults(struct pp_hwmgr *hwmgr)
        if (data->registry_data.didt_support)
                data->smu_features[GNLD_DIDT].supported = true;
 
+       hw_revision = adev->pdev->revision;
+       sub_vendor_id = adev->pdev->subsystem_vendor;
+
+       if ((hwmgr->chip_id == 0x6862 ||
+               hwmgr->chip_id == 0x6861 ||
+               hwmgr->chip_id == 0x6868) &&
+               (hw_revision == 0) &&
+               (sub_vendor_id != 0x1002))
+               data->smu_features[GNLD_PCC_LIMIT].supported = true;
 }
 
 #ifdef PPLIB_VEGA10_EVV_SUPPORT
@@ -750,7 +757,7 @@ static int vega10_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
        struct vega10_hwmgr *data;
        uint32_t config_telemetry = 0;
        struct pp_atomfwctrl_voltage_table vol_table;
-       struct cgs_system_info sys_info = {0};
+       struct amdgpu_device *adev = hwmgr->adev;
        uint32_t reg;
 
        data = kzalloc(sizeof(struct vega10_hwmgr), GFP_KERNEL);
@@ -843,10 +850,7 @@ static int vega10_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
        hwmgr->platform_descriptor.clockStep.engineClock = 500;
        hwmgr->platform_descriptor.clockStep.memoryClock = 500;
 
-       sys_info.size = sizeof(struct cgs_system_info);
-       sys_info.info_id = CGS_SYSTEM_INFO_GFX_CU_INFO;
-       result = cgs_query_system_info(hwmgr->device, &sys_info);
-       data->total_active_cus = sys_info.value;
+       data->total_active_cus = adev->gfx.cu_info.number;
        /* Setup default Overdrive Fan control settings */
        data->odn_fan_table.target_fan_speed =
                        hwmgr->thermal_controller.advanceFanControlParameters.usMaxFanRPM;
@@ -2404,34 +2408,6 @@ static int vega10_populate_and_upload_avfs_fuse_override(struct pp_hwmgr *hwmgr)
        return result;
 }
 
-static int vega10_save_default_power_profile(struct pp_hwmgr *hwmgr)
-{
-       struct vega10_hwmgr *data = (struct vega10_hwmgr *)(hwmgr->backend);
-       struct vega10_single_dpm_table *dpm_table = &(data->dpm_table.gfx_table);
-       uint32_t min_level;
-
-       hwmgr->default_gfx_power_profile.type = AMD_PP_GFX_PROFILE;
-       hwmgr->default_compute_power_profile.type = AMD_PP_COMPUTE_PROFILE;
-
-       /* Optimize compute power profile: Use only highest
-        * 2 power levels (if more than 2 are available)
-        */
-       if (dpm_table->count > 2)
-               min_level = dpm_table->count - 2;
-       else if (dpm_table->count == 2)
-               min_level = 1;
-       else
-               min_level = 0;
-
-       hwmgr->default_compute_power_profile.min_sclk =
-                       dpm_table->dpm_levels[min_level].value;
-
-       hwmgr->gfx_power_profile = hwmgr->default_gfx_power_profile;
-       hwmgr->compute_power_profile = hwmgr->default_compute_power_profile;
-
-       return 0;
-}
-
 /**
 * Initializes the SMC table and uploads it
 *
@@ -2575,7 +2551,6 @@ static int vega10_init_smc_table(struct pp_hwmgr *hwmgr)
        PP_ASSERT_WITH_CODE(!result, "Attempt to enable AVFS feature Failed!",
                                        return result);
        vega10_acg_enable(hwmgr);
-       vega10_save_default_power_profile(hwmgr);
 
        return 0;
 }
@@ -2852,12 +2827,32 @@ static int vega10_start_dpm(struct pp_hwmgr *hwmgr, uint32_t bitmap)
        return 0;
 }
 
+static int vega10_enable_disable_PCC_limit_feature(struct pp_hwmgr *hwmgr, bool enable)
+{
+       struct vega10_hwmgr *data =
+                       (struct vega10_hwmgr *)(hwmgr->backend);
+
+       if (data->smu_features[GNLD_PCC_LIMIT].supported) {
+               if (enable == data->smu_features[GNLD_PCC_LIMIT].enabled)
+                       pr_info("GNLD_PCC_LIMIT has been %s \n", enable ? "enabled" : "disabled");
+               PP_ASSERT_WITH_CODE(!vega10_enable_smc_features(hwmgr,
+                               enable, data->smu_features[GNLD_PCC_LIMIT].smu_feature_bitmap),
+                               "Attempt to Enable PCC Limit feature Failed!",
+                               return -EINVAL);
+               data->smu_features[GNLD_PCC_LIMIT].enabled = enable;
+       }
+
+       return 0;
+}
+
 static int vega10_enable_dpm_tasks(struct pp_hwmgr *hwmgr)
 {
        struct vega10_hwmgr *data =
                        (struct vega10_hwmgr *)(hwmgr->backend);
        int tmp_result, result = 0;
 
+       vega10_enable_disable_PCC_limit_feature(hwmgr, true);
+
        if ((hwmgr->smu_version == 0x001c2c00) ||
                        (hwmgr->smu_version == 0x001c2d00))
                smum_send_msg_to_smc_with_parameter(hwmgr,
@@ -4711,6 +4706,8 @@ static int vega10_disable_dpm_tasks(struct pp_hwmgr *hwmgr)
        tmp_result =  vega10_acg_disable(hwmgr);
        PP_ASSERT_WITH_CODE((tmp_result == 0),
                        "Failed to disable acg!", result = tmp_result);
+
+       vega10_enable_disable_PCC_limit_feature(hwmgr, false);
        return result;
 }
 
@@ -4728,62 +4725,6 @@ static int vega10_power_off_asic(struct pp_hwmgr *hwmgr)
        return result;
 }
 
-static void vega10_find_min_clock_index(struct pp_hwmgr *hwmgr,
-               uint32_t *sclk_idx, uint32_t *mclk_idx,
-               uint32_t min_sclk, uint32_t min_mclk)
-{
-       struct vega10_hwmgr *data = (struct vega10_hwmgr *)(hwmgr->backend);
-       struct vega10_dpm_table *dpm_table = &(data->dpm_table);
-       uint32_t i;
-
-       for (i = 0; i < dpm_table->gfx_table.count; i++) {
-               if (dpm_table->gfx_table.dpm_levels[i].enabled &&
-                       dpm_table->gfx_table.dpm_levels[i].value >= min_sclk) {
-                       *sclk_idx = i;
-                       break;
-               }
-       }
-
-       for (i = 0; i < dpm_table->mem_table.count; i++) {
-               if (dpm_table->mem_table.dpm_levels[i].enabled &&
-                       dpm_table->mem_table.dpm_levels[i].value >= min_mclk) {
-                       *mclk_idx = i;
-                       break;
-               }
-       }
-}
-
-static int vega10_set_power_profile_state(struct pp_hwmgr *hwmgr,
-               struct amd_pp_profile *request)
-{
-       struct vega10_hwmgr *data = (struct vega10_hwmgr *)(hwmgr->backend);
-       uint32_t sclk_idx = ~0, mclk_idx = ~0;
-
-       if (hwmgr->dpm_level != AMD_DPM_FORCED_LEVEL_AUTO)
-               return -EINVAL;
-
-       vega10_find_min_clock_index(hwmgr, &sclk_idx, &mclk_idx,
-                       request->min_sclk, request->min_mclk);
-
-       if (sclk_idx != ~0) {
-               if (!data->registry_data.sclk_dpm_key_disabled)
-                       smum_send_msg_to_smc_with_parameter(
-                                       hwmgr,
-                                       PPSMC_MSG_SetSoftMinGfxclkByIndex,
-                                       sclk_idx);
-       }
-
-       if (mclk_idx != ~0) {
-               if (!data->registry_data.mclk_dpm_key_disabled)
-                       smum_send_msg_to_smc_with_parameter(
-                                       hwmgr,
-                                       PPSMC_MSG_SetSoftMinUclkByIndex,
-                                       mclk_idx);
-       }
-
-       return 0;
-}
-
 static int vega10_get_sclk_od(struct pp_hwmgr *hwmgr)
 {
        struct vega10_hwmgr *data = (struct vega10_hwmgr *)(hwmgr->backend);
@@ -5077,7 +5018,6 @@ static const struct pp_hwmgr_func vega10_hwmgr_funcs = {
                        vega10_check_smc_update_required_for_display_configuration,
        .power_off_asic = vega10_power_off_asic,
        .disable_smc_firmware_ctf = vega10_thermal_disable_alert,
-       .set_power_profile_state = vega10_set_power_profile_state,
        .get_sclk_od = vega10_get_sclk_od,
        .set_sclk_od = vega10_set_sclk_od,
        .get_mclk_od = vega10_get_mclk_od,