diff options
author | Kevin Wang | 2019-01-24 08:27:02 +0100 |
---|---|---|
committer | Alex Deucher | 2019-03-19 21:04:00 +0100 |
commit | f14a323db5b0f6cca18b7908337c84b16b2f4e92 (patch) | |
tree | a3ae3da4e78a092d9ddec8aae759411c57aef7cc /drivers/gpu/drm/amd/powerplay/smu_v11_0.c | |
parent | drm/amd/powerplay: dpm clk can be set only when performance level is manual (diff) | |
download | kernel-qcow2-linux-f14a323db5b0f6cca18b7908337c84b16b2f4e92.tar.gz kernel-qcow2-linux-f14a323db5b0f6cca18b7908337c84b16b2f4e92.tar.xz kernel-qcow2-linux-f14a323db5b0f6cca18b7908337c84b16b2f4e92.zip |
drm/amd/powerplay: implement update enabled feature state to smc for smu11
change:
1.when enable smu feature, the feature id will store sw-bitmap and smu
controller.
2.add feature mutex lock to protect feature bitmap changed when update
feature enabled state.
Signed-off-by: Kevin Wang <kevin1.wang@amd.com>
Reviewed-by: Huang Rui <ray.huang@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/powerplay/smu_v11_0.c')
-rw-r--r-- | drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c index 0e7f81a50dcf..400d981bda5a 100644 --- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c +++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c @@ -615,27 +615,67 @@ static int smu_v11_0_init_display(struct smu_context *smu) return ret; } +static int smu_v11_0_update_feature_enable_state(struct smu_context *smu, uint32_t feature_id, bool enabled) +{ + uint32_t feature_low = 0, feature_high = 0; + int ret = 0; + + if (feature_id >= 0 && feature_id < 31) + feature_low = (1 << feature_id); + else if (feature_id > 31 && feature_id < 63) + feature_high = (1 << feature_id); + else + return -EINVAL; + + if (enabled) { + ret = smu_send_smc_msg_with_param(smu, SMU_MSG_EnableSmuFeaturesLow, + feature_low); + if (ret) + return ret; + ret = smu_send_smc_msg_with_param(smu, SMU_MSG_EnableSmuFeaturesHigh, + feature_high); + if (ret) + return ret; + + } else { + ret = smu_send_smc_msg_with_param(smu, SMU_MSG_DisableSmuFeaturesLow, + feature_low); + if (ret) + return ret; + ret = smu_send_smc_msg_with_param(smu, SMU_MSG_DisableSmuFeaturesHigh, + feature_high); + if (ret) + return ret; + + } + + return ret; +} + static int smu_v11_0_set_allowed_mask(struct smu_context *smu) { struct smu_feature *feature = &smu->smu_feature; int ret = 0; uint32_t feature_mask[2]; + mutex_lock(&feature->mutex); if (bitmap_empty(feature->allowed, SMU_FEATURE_MAX) || feature->feature_num < 64) - return -EINVAL; + goto failed; bitmap_copy((unsigned long *)feature_mask, feature->allowed, 64); ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetAllowedFeaturesMaskHigh, feature_mask[1]); if (ret) - return ret; + goto failed; ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetAllowedFeaturesMaskLow, feature_mask[0]); if (ret) - return ret; + goto failed; +failed: + mutex_unlock(&feature->mutex); return ret; } @@ -1578,6 +1618,7 @@ static const struct smu_funcs smu_v11_0_funcs = { .get_enabled_mask = smu_v11_0_get_enabled_mask, .enable_all_mask = smu_v11_0_enable_all_mask, .disable_all_mask = smu_v11_0_disable_all_mask, + .update_feature_enable_state = smu_v11_0_update_feature_enable_state, .notify_display_change = smu_v11_0_notify_display_change, .get_power_limit = smu_v11_0_get_power_limit, .get_current_clk_freq = smu_v11_0_get_current_clk_freq, |