[PATCH 31/32] drm/amdgpu: is_idle for each vcn instance

boyuan.zhang at amd.com boyuan.zhang at amd.com
Tue Oct 8 21:15:52 UTC 2024


From: Boyuan Zhang <boyuan.zhang at amd.com>

Perform is_idle only for the instance of the current vcn IP block,
instead of perform it for all vcn instances.

Signed-off-by: Boyuan Zhang <boyuan.zhang at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c   | 11 +++++------
 drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c   | 11 +++++------
 drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c   | 11 +++++------
 drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c |  9 ++++-----
 drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c | 11 +++++------
 drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c | 11 +++++------
 6 files changed, 29 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c b/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c
index 936d37b8fd3c..0b62729fca89 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c
@@ -1762,14 +1762,13 @@ static void vcn_v2_5_set_enc_ring_funcs(struct amdgpu_device *adev, int inst)
 static bool vcn_v2_5_is_idle(struct amdgpu_ip_block *ip_block)
 {
 	struct amdgpu_device *adev = ip_block->adev;
-	int i, ret = 1;
+	int inst = ip_block->instance;
+	int ret = 1;
 
-	for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
-		if (adev->vcn.harvest_config & (1 << i))
-			continue;
+	if (adev->vcn.harvest_config & (1 << inst))
+		return ret;
 
-		ret &= (RREG32_SOC15(VCN, i, mmUVD_STATUS) == UVD_STATUS__IDLE);
-	}
+	ret &= (RREG32_SOC15(VCN, inst, mmUVD_STATUS) == UVD_STATUS__IDLE);
 
 	return ret;
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
index d1074490fdc9..5b11062b873d 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
@@ -2090,14 +2090,13 @@ static void vcn_v3_0_set_enc_ring_funcs(struct amdgpu_device *adev, int inst)
 static bool vcn_v3_0_is_idle(struct amdgpu_ip_block *ip_block)
 {
 	struct amdgpu_device *adev = ip_block->adev;
-	int i, ret = 1;
+	int inst = ip_block->instance;
+	int ret = 1;
 
-	for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
-		if (adev->vcn.harvest_config & (1 << i))
-			continue;
+	if (adev->vcn.harvest_config & (1 << inst))
+		return ret;
 
-		ret &= (RREG32_SOC15(VCN, i, mmUVD_STATUS) == UVD_STATUS__IDLE);
-	}
+	ret &= (RREG32_SOC15(VCN, inst, mmUVD_STATUS) == UVD_STATUS__IDLE);
 
 	return ret;
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
index a6d3425b499b..69fff5df1c68 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
@@ -1946,14 +1946,13 @@ static void vcn_v4_0_set_unified_ring_funcs(struct amdgpu_device *adev, int inst
 static bool vcn_v4_0_is_idle(struct amdgpu_ip_block *ip_block)
 {
 	struct amdgpu_device *adev = ip_block->adev;
-	int i, ret = 1;
+	int inst = ip_block->instance;
+	int ret = 1;
 
-	for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
-		if (adev->vcn.harvest_config & (1 << i))
-			continue;
+	if (adev->vcn.harvest_config & (1 << inst))
+		return ret;
 
-		ret &= (RREG32_SOC15(VCN, i, regUVD_STATUS) == UVD_STATUS__IDLE);
-	}
+	ret &= (RREG32_SOC15(VCN, inst, regUVD_STATUS) == UVD_STATUS__IDLE);
 
 	return ret;
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c
index 258c14fdfd23..cb30d5e5bc70 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c
@@ -1546,12 +1546,11 @@ static void vcn_v4_0_3_set_unified_ring_funcs(struct amdgpu_device *adev, int in
 static bool vcn_v4_0_3_is_idle(struct amdgpu_ip_block *ip_block)
 {
 	struct amdgpu_device *adev = ip_block->adev;
-	int i, ret = 1;
+	int inst = ip_block->instance;
+	int ret = 1;
 
-	for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
-		ret &= (RREG32_SOC15(VCN, GET_INST(VCN, i), regUVD_STATUS) ==
-                       UVD_STATUS__IDLE);
-	}
+	ret &= (RREG32_SOC15(VCN, GET_INST(VCN, inst), regUVD_STATUS) ==
+				   UVD_STATUS__IDLE);
 
 	return ret;
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c
index 90a39a461e86..68397bea5a18 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c
@@ -1443,14 +1443,13 @@ static void vcn_v4_0_5_set_unified_ring_funcs(struct amdgpu_device *adev, int in
 static bool vcn_v4_0_5_is_idle(struct amdgpu_ip_block *ip_block)
 {
 	struct amdgpu_device *adev = ip_block->adev;
-	int i, ret = 1;
+	int inst = ip_block->instance;
+	int ret = 1;
 
-	for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
-		if (adev->vcn.harvest_config & (1 << i))
-			continue;
+	if (adev->vcn.harvest_config & (1 << inst))
+		return ret;
 
-		ret &= (RREG32_SOC15(VCN, i, regUVD_STATUS) == UVD_STATUS__IDLE);
-	}
+	ret &= (RREG32_SOC15(VCN, inst, regUVD_STATUS) == UVD_STATUS__IDLE);
 
 	return ret;
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c
index 456951bf304f..fd78472b906a 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c
@@ -1170,14 +1170,13 @@ static void vcn_v5_0_0_set_unified_ring_funcs(struct amdgpu_device *adev, int in
 static bool vcn_v5_0_0_is_idle(struct amdgpu_ip_block *ip_block)
 {
 	struct amdgpu_device *adev = ip_block->adev;
-	int i, ret = 1;
+	int inst = ip_block->instance;
+	int ret = 1;
 
-	for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
-		if (adev->vcn.harvest_config & (1 << i))
-			continue;
+	if (adev->vcn.harvest_config & (1 << inst))
+		return ret;
 
-		ret &= (RREG32_SOC15(VCN, i, regUVD_STATUS) == UVD_STATUS__IDLE);
-	}
+	ret &= (RREG32_SOC15(VCN, inst, regUVD_STATUS) == UVD_STATUS__IDLE);
 
 	return ret;
 }
-- 
2.34.1



More information about the amd-gfx mailing list