If vcn is disabled in kernel parameters, don't touch vcn, otherwise it may cause vcn hang.
v2: delete unnecessary logs Signed-off-by: Yifan Zhang <yifan1.zh...@amd.com> --- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 30 ++++++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c index f005a90c35af..b5fe4defd12c 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c @@ -1454,6 +1454,21 @@ static int smu_start_smc_engine(struct smu_context *smu) return ret; } +static bool is_vcn_enabled(struct amdgpu_device *adev) +{ + int i; + + for (i = 0; i < adev->num_ip_blocks; i++) { + if ((adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_VCN || + adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_JPEG) && + !adev->ip_blocks[i].status.valid) + + return false; + } + + return true; +} + static int smu_hw_init(void *handle) { int ret; @@ -1475,8 +1490,13 @@ static int smu_hw_init(void *handle) ret = smu_set_gfx_imu_enable(smu); if (ret) return ret; - smu_dpm_set_vcn_enable(smu, true); - smu_dpm_set_jpeg_enable(smu, true); + /* + * don't poweron vcn/jpeg when they are skipped. + */ + if (is_vcn_enabled(adev)) { + smu_dpm_set_vcn_enable(smu, true); + smu_dpm_set_jpeg_enable(smu, true); + } smu_set_gfx_cgpg(smu, true); } @@ -1651,8 +1671,10 @@ static int smu_hw_fini(void *handle) if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev)) return 0; - smu_dpm_set_vcn_enable(smu, false); - smu_dpm_set_jpeg_enable(smu, false); + if (is_vcn_enabled(adev)) { + smu_dpm_set_vcn_enable(smu, false); + smu_dpm_set_jpeg_enable(smu, false); + } adev->vcn.cur_state = AMD_PG_STATE_GATE; adev->jpeg.cur_state = AMD_PG_STATE_GATE; -- 2.37.3