[PATCH v2] drm/amd/pm: only poweron/off vcn/jpeg when they are valid.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.zhang@xxxxxxx>
---
 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




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux