drm/amd/pm: only poweron/off vcn/jpeg when they are valid.
Subsystems (3)
PATCH 1/1 drm/amd/pm: only poweron/off vcn/jpeg when they are valid.
If vcn is disabled in kernel parameters, don't touch vcn, otherwise it may cause vcn hang.
--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 31 ++++++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +27 -4
@@ -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,14 @@ 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)) { +dev_info (adev->dev,"yep, vcn are valid\n" ); +smu_dpm_set_vcn_enable (smu, true); +smu_dpm_set_jpeg_enable (smu, true); + }smu_set_gfx_cgpg (smu, true); }
@@ -1651,8 +1672,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 ;
Signature · 1 line
2.37.3
[AMD Official Use Only - General]
Quoted 52 lines
-----Original Message-----
From: Zhang, Yifan <[email protected]>
Sent: Thursday, August 31, 2023 2:10 PM
To: [email protected]
Cc: Quan, Evan <[email protected]>; Ma, Li <[email protected]>; Zhang, Yifan <[email protected]>
Subject: [PATCH] drm/amd/pm: only poweron/off vcn/jpeg when they are valid.If vcn is disabled in kernel parameters, don't touch vcn, otherwise it may cause vcn hang.
Signed-off-by Yifan Zhang <[email protected]>--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 31 ++++++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +6
-0@@ -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) &&drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +8
-0+ !adev->ip_blocks[i].status.valid) + +return false; + } + +return true; +} +static int smu_hw_init (void *handle) {int ret;@@ -1475,8 +1490,14 @@ static int smu_hw_init(void *handle) ret =smu_set_gfx_imu_enable (smu);if (ret)return ret;
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_hw_init(void *handle) · line 1500
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +8
-2-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)) { +dev_info (adev->dev,"yep, vcn are valid\n" ); +smu_dpm_set_vcn_enable (smu, true); +smu_dpm_set_jpeg_enable (smu, true); + }
Better to move the "is_vcn_enabled" check into smu_dpm_set_vcn/jpeg_enable. That will make code more tidy. Also, the "dev_info" here is obviously not needed.
Evan
Quoted 18 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4
-3smu_set_gfx_cgpg (smu, true); }@@ -1651,8 +1672,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