Skip to contentSkip to conversation

drm/amd/amdgpu: Avoid writing GMC registers under sriov in gmc9

PATCH Superseded YuBiao Wang 2 participants 3 messages Nov 4, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/amdgpu: Avoid writing GMC registers under sriov in gmc9

[Why]
For Vega10, disabling gart of gfxhub and mmhub could mess up KIQ and PSP under sriov mode, and lead to DMAR on host side.

[How]
Skip writing GMC registers under sriov.

---
 drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c | 26 +++++++++++++-----------
 1 file changed, 14 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c +14 -12
index bda1542ef1dd..f9a7349eb601 100644
@@ -348,18 +348,20 @@ static void gfxhub_v1_0_gart_disable(struct amdgpu_device *adev)
 		WREG32_SOC15_OFFSET(GC, 0, mmVM_CONTEXT0_CNTL,
 				    i * hub->ctx_distance, 0);
 
-	/* Setup TLB control */
-	tmp = RREG32_SOC15(GC, 0, mmMC_VM_MX_L1_TLB_CNTL);
-	tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, ENABLE_L1_TLB, 0);
-	tmp = REG_SET_FIELD(tmp,
-				MC_VM_MX_L1_TLB_CNTL,
-				ENABLE_ADVANCED_DRIVER_MODEL,
-				0);
-	WREG32_SOC15_RLC(GC, 0, mmMC_VM_MX_L1_TLB_CNTL, tmp);
-
-	/* Setup L2 cache */
-	WREG32_FIELD15(GC, 0, VM_L2_CNTL, ENABLE_L2_CACHE, 0);
-	WREG32_SOC15(GC, 0, mmVM_L2_CNTL3, 0);
+	if (!amdgpu_sriov_vf(adev)) {
+		/* Setup TLB control */
+		tmp = RREG32_SOC15(GC, 0, mmMC_VM_MX_L1_TLB_CNTL);
+		tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, ENABLE_L1_TLB, 0);
+		tmp = REG_SET_FIELD(tmp,
+					MC_VM_MX_L1_TLB_CNTL,
+					ENABLE_ADVANCED_DRIVER_MODEL,
+					0);
+		WREG32_SOC15_RLC(GC, 0, mmMC_VM_MX_L1_TLB_CNTL, tmp);
+
+		/* Setup L2 cache */
+		WREG32_FIELD15(GC, 0, VM_L2_CNTL, ENABLE_L2_CACHE, 0);
+		WREG32_SOC15(GC, 0, mmVM_L2_CNTL3, 0);
+	}
 }
 
 /**
Signature · 1 line
2.25.1
maintainer
#1 lore raw

Am 04.11.21 um 03:55 schrieb YuBiao Wang:

Quoted 23 lines

[Why]
For Vega10, disabling gart of gfxhub and mmhub could mess up KIQ and PSP under sriov mode, and lead to DMAR on host side.

[How]
Skip writing GMC registers under sriov.

---
  drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c | 26 +++++++++++++-----------
  1 file changed, 14 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c +0 -3
index bda1542ef1dd..f9a7349eb601 100644
@@ -348,18 +348,20 @@ static void gfxhub_v1_0_gart_disable(struct amdgpu_device *adev)
  		WREG32_SOC15_OFFSET(GC, 0, mmVM_CONTEXT0_CNTL,
  				    i * hub->ctx_distance, 0);
 
-	/* Setup TLB control */
-	tmp = RREG32_SOC15(GC, 0, mmMC_VM_MX_L1_TLB_CNTL);
-	tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, ENABLE_L1_TLB, 0);

drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c static void gfxhub_v1_0_gart_disable(struct amdgpu_device *adev) · line 351

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c +1 -9
-	tmp = REG_SET_FIELD(tmp,
-				MC_VM_MX_L1_TLB_CNTL,
-				ENABLE_ADVANCED_DRIVER_MODEL,
-				0);
-	WREG32_SOC15_RLC(GC, 0, mmMC_VM_MX_L1_TLB_CNTL, tmp);
-
-	/* Setup L2 cache */
-	WREG32_FIELD15(GC, 0, VM_L2_CNTL, ENABLE_L2_CACHE, 0);
-	WREG32_SOC15(GC, 0, mmVM_L2_CNTL3, 0);
+	if (!amdgpu_sriov_vf(adev)) {

Maybe make that an "if (amdgpu_sriov_vf(adev)) return", but in general feel free to add an Acked-by: Christian König <[email protected]> to the patch.

Additional to that the patch should probably be send to the public mailing list instead.

Regards,
Christian.

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c +13 -0
+		/* Setup TLB control */
+		tmp = RREG32_SOC15(GC, 0, mmMC_VM_MX_L1_TLB_CNTL);
+		tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, ENABLE_L1_TLB, 0);
+		tmp = REG_SET_FIELD(tmp,
+					MC_VM_MX_L1_TLB_CNTL,
+					ENABLE_ADVANCED_DRIVER_MODEL,
+					0);
+		WREG32_SOC15_RLC(GC, 0, mmMC_VM_MX_L1_TLB_CNTL, tmp);
+
+		/* Setup L2 cache */
+		WREG32_FIELD15(GC, 0, VM_L2_CNTL, ENABLE_L2_CACHE, 0);
+		WREG32_SOC15(GC, 0, mmVM_L2_CNTL3, 0);
+	}
  }
 
  /**
maintainer
#2 lore raw

Am 04.11.21 um 08:49 schrieb Christian König:

Quoted 39 lines

Am 04.11.21 um 03:55 schrieb YuBiao Wang:

Quoted 25 lines

[Why]
For Vega10, disabling gart of gfxhub and mmhub could mess up KIQ and PSP under sriov mode, and lead to DMAR on host side.

[How]
Skip writing GMC registers under sriov.

---
  drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c | 26 +++++++++++++-----------

  1 file changed, 14 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c +0 -0
index bda1542ef1dd..f9a7349eb601 100644
@@ -348,18 +348,20 @@ static void gfxhub_v1_0_gart_disable(struct 
 amdgpu_device *adev)
           WREG32_SOC15_OFFSET(GC, 0, mmVM_CONTEXT0_CNTL,
                       i * hub->ctx_distance, 0);

  -    /* Setup TLB control */
-    tmp = RREG32_SOC15(GC, 0, mmMC_VM_MX_L1_TLB_CNTL);
-    tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, ENABLE_L1_TLB, 0); -    tmp = REG_SET_FIELD(tmp,
-                MC_VM_MX_L1_TLB_CNTL,

Quoted 8 lines

-                ENABLE_ADVANCED_DRIVER_MODEL,
-                0);
-    WREG32_SOC15_RLC(GC, 0, mmMC_VM_MX_L1_TLB_CNTL, tmp); -
-    /* Setup L2 cache */
-    WREG32_FIELD15(GC, 0, VM_L2_CNTL, ENABLE_L2_CACHE, 0); -    WREG32_SOC15(GC, 0, mmVM_L2_CNTL3, 0);
+    if (!amdgpu_sriov_vf(adev)) {

Maybe make that an "if (amdgpu_sriov_vf(adev)) return", but in general feel free to add an Acked-by: Christian König <[email protected]> to the patch.

Quoted 1 line

Additional to that the patch should probably be send to the public mailing list instead.

Please forget that last comment, just noticed the public list is on CC as well.

Thanks,
Christian.

Quoted 21 lines

Regards,
Christian.

Quoted 16 lines

+        /* Setup TLB control */
+        tmp = RREG32_SOC15(GC, 0, mmMC_VM_MX_L1_TLB_CNTL); +        tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, ENABLE_L1_TLB, 0);
+        tmp = REG_SET_FIELD(tmp,
+                    MC_VM_MX_L1_TLB_CNTL,
+                    ENABLE_ADVANCED_DRIVER_MODEL,
+                    0);
+        WREG32_SOC15_RLC(GC, 0, mmMC_VM_MX_L1_TLB_CNTL, tmp); +
+        /* Setup L2 cache */
+        WREG32_FIELD15(GC, 0, VM_L2_CNTL, ENABLE_L2_CACHE, 0); +        WREG32_SOC15(GC, 0, mmVM_L2_CNTL3, 0);
+    }
  }
    /**