Skip to contentSkip to conversation

drm/amd/amdgpu: Fix incorrect logic to increment VCN doorbell index

PATCH In review Bokun Zhang 2 participants 2 messages Nov 7, 2020 – Nov 9, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/amdgpu: Fix incorrect logic to increment VCN doorbell index

- The original logic uses a counter based index assignment, which is incorrect if we only assign VCN1 to this VF but no VCN0

The doorbell index is absolute, so we can calculate it by using index variable i and j

Change-Id Ica36b2bc80efa896f3753f2f2e2539ca2ca6649f
---
 drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +9 -6
index 269002816109..3970a0ccb6a5 100644
@@ -155,6 +155,13 @@ static int vcn_v3_0_sw_init(void *handle)
 	if (r)
 		return r;
 
+	/*
+	 * Note: doorbell assignment is fixed for SRIOV multiple VCN engines
+	 * Formula:
+	 *   vcn_db_base  = adev->doorbell_index.vcn.vcn_ring0_1 << 1;
+	 *   dec_ring_i   = vcn_db_base + i * (adev->vcn.num_enc_rings + 1)
+	 *   enc_ring_i,j = vcn_db_base + i * (adev->vcn.num_enc_rings + 1) + 1 + j
+	 */
 	if (amdgpu_sriov_vf(adev)) {
 		vcn_doorbell_index = adev->doorbell_index.vcn.vcn_ring0_1;
 		/* get DWORD offset */
@@ -192,9 +199,7 @@ static int vcn_v3_0_sw_init(void *handle)
 		ring = &adev->vcn.inst[i].ring_dec;
 		ring->use_doorbell = true;
 		if (amdgpu_sriov_vf(adev)) {
-			ring->doorbell_index = vcn_doorbell_index;
-			/* NOTE: increment so next VCN engine use next DOORBELL DWORD */
-			vcn_doorbell_index++;
+			ring->doorbell_index = vcn_doorbell_index + i * (adev->vcn.num_enc_rings + 1);
 		} else {
 			ring->doorbell_index = (adev->doorbell_index.vcn.vcn_ring0_1 << 1) + 8 * i;
 		}
@@ -216,9 +221,7 @@ static int vcn_v3_0_sw_init(void *handle)
 			ring = &adev->vcn.inst[i].ring_enc[j];
 			ring->use_doorbell = true;
 			if (amdgpu_sriov_vf(adev)) {
-				ring->doorbell_index = vcn_doorbell_index;
-				/* NOTE: increment so next VCN engine use next DOORBELL DWORD */
-				vcn_doorbell_index++;
+				ring->doorbell_index = vcn_doorbell_index + i * (adev->vcn.num_enc_rings + 1) + 1 + j;
 			} else {
 				ring->doorbell_index = (adev->doorbell_index.vcn.vcn_ring0_1 << 1) + 2 + j + 8 * i;
 			}
Signature · 6 lines
2.25.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by on v1 1/1
#1 lore raw

[AMD Official Use Only - Internal Distribution Only]

_____________________________________
Monk Liu|GPU Virtualization Team |AMD

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Bokun Zhang
Sent: Saturday, November 7, 2020 10:03 AM
To: [email protected]
Cc: Zhang, Bokun <[email protected]>
Subject: [PATCH] drm/amd/amdgpu: Fix incorrect logic to increment VCN doorbell index

- The original logic uses a counter based index assignment, which is incorrect if we only assign VCN1 to this VF but no VCN0

The doorbell index is absolute, so we can calculate it by using index variable i and j

Change-Id Ica36b2bc80efa896f3753f2f2e2539ca2ca6649f
---
 drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +9 -6
index 269002816109..3970a0ccb6a5 100644
@@ -155,6 +155,13 @@ static int vcn_v3_0_sw_init(void *handle)
 if (r)
 return r;
 
+/*
+ * Note: doorbell assignment is fixed for SRIOV multiple VCN engines
+ * Formula:
+ *   vcn_db_base  = adev->doorbell_index.vcn.vcn_ring0_1 << 1;
+ *   dec_ring_i   = vcn_db_base + i * (adev->vcn.num_enc_rings + 1)
+ *   enc_ring_i,j = vcn_db_base + i * (adev->vcn.num_enc_rings + 1) + 1 + j
+ */
 if (amdgpu_sriov_vf(adev)) {
 vcn_doorbell_index = adev->doorbell_index.vcn.vcn_ring0_1;
 /* get DWORD offset */
@@ -192,9 +199,7 @@ static int vcn_v3_0_sw_init(void *handle)
 ring = &adev->vcn.inst[i].ring_dec;
 ring->use_doorbell = true;
 if (amdgpu_sriov_vf(adev)) {
-ring->doorbell_index = vcn_doorbell_index;
-/* NOTE: increment so next VCN engine use next DOORBELL DWORD */
-vcn_doorbell_index++;
+ring->doorbell_index = vcn_doorbell_index + i * (adev->vcn.num_enc_rings + 1);
 } else {
 ring->doorbell_index = (adev->doorbell_index.vcn.vcn_ring0_1 << 1) + 8 * i;
 }
@@ -216,9 +221,7 @@ static int vcn_v3_0_sw_init(void *handle)
 ring = &adev->vcn.inst[i].ring_enc[j];
 ring->use_doorbell = true;
 if (amdgpu_sriov_vf(adev)) {
-ring->doorbell_index = vcn_doorbell_index;
-/* NOTE: increment so next VCN engine use next DOORBELL DWORD */
-vcn_doorbell_index++;
+ring->doorbell_index = vcn_doorbell_index + i * (adev->vcn.num_enc_rings + 1) + 1 + j;
 } else {
 ring->doorbell_index = (adev->doorbell_index.vcn.vcn_ring0_1 << 1) + 2 + j + 8 * i;
 }

--
2.25.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=04%7C01%7Cmonk.liu%40amd.com%7C0ec09d9e179b4721263608d882c13981%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637403114148624558%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000&amp;sdata=Bn03tzCw6gyiI%2Fq78gJ%2BQQUGAJdABHG1Fup87tgSP0A%3D&amp;reserved=0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx