Skip to contentSkip to conversation

drm/amdgpu/sriov: For sriov runtime, use kiq to do invalidate tlb

PATCH New Emily Deng 1 participant 2 messages Aug 15, 2018 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Emily Deng

author
#0 lore raw

PATCH 1/2 drm/amdgpu/sriov: For sriov runtime, use kiq to do invalidate tlb

To avoid the tlb flush not interrupted by world switch, use kiq and one command to do tlb invalidate.

v2:
Add firmware version checking.

v3:
Refine the code, and move the firmware checking into gfx_v9_0_ring_emit_reg_write_reg_wait.

SWDEV-161497

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h      |  4 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c |  3 --
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c    | 15 +++++++-
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c    | 61 ++++++++++++++++++++++++++++++++
 4 files changed, 79 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +4 -0
index 07924d4..67b584b 100644
@@ -210,6 +210,10 @@ enum amdgpu_kiq_irq {
 	AMDGPU_CP_KIQ_IRQ_LAST
 };
 
+#define MAX_KIQ_REG_WAIT       5000 /* in usecs, 5ms */
+#define MAX_KIQ_REG_BAILOUT_INTERVAL   5 /* in msecs, 5ms */
+#define MAX_KIQ_REG_TRY 20
+
 int amdgpu_device_ip_set_clockgating_state(void *dev,
 					   enum amd_ip_block_type block_type,
 					   enum amd_clockgating_state state);
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +0 -3
index 21adb1b6..3885636 100644
@@ -22,9 +22,6 @@
  */
 
 #include "amdgpu.h"
-#define MAX_KIQ_REG_WAIT	5000 /* in usecs, 5ms */
-#define MAX_KIQ_REG_BAILOUT_INTERVAL	5 /* in msecs, 5ms */
-#define MAX_KIQ_REG_TRY 20
 
 uint64_t amdgpu_csa_vaddr(struct amdgpu_device *adev)
 {
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +14 -1
index 76d979e..c9b3db4 100644
@@ -4348,8 +4348,21 @@ static void gfx_v9_0_ring_emit_reg_write_reg_wait(struct amdgpu_ring *ring,
 						  uint32_t ref, uint32_t mask)
 {
 	int usepfp = (ring->funcs->type == AMDGPU_RING_TYPE_GFX);
+	struct amdgpu_device *adev = ring->adev;
+	bool fw_version_ok = false;
 
-	if (amdgpu_sriov_vf(ring->adev))
+	if (ring->funcs->type == AMDGPU_RING_TYPE_GFX) {
+		if ((adev->gfx.me_fw_version >= 0x0000009c) && (adev->gfx.me_feature_version >= 42))
+			if ((adev->gfx.pfp_fw_version >=  0x000000b1) && (adev->gfx.pfp_feature_version >= 42))
+				fw_version_ok = true;
+	} else {
+		if ((adev->gfx.mec_fw_version >=  0x00000193) && (adev->gfx.mec_feature_version >= 42))
+			fw_version_ok = true;
+	}
+
+	fw_version_ok = (adev->asic_type == CHIP_VEGA10) ? fw_version_ok : false;
+
+	if (amdgpu_sriov_vf(adev) && fw_version_ok)
 		gfx_v9_0_wait_reg_mem(ring, usepfp, 0, 1, reg0, reg1,
 				      ref, mask, 0x20);
 	else
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +61 -0

79 lines not on this page · raw message

Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1534326755-17527-1-git-send-email-Emily.Deng-5C7GfCeVMHo@public.gmane.org

author
#2 lore raw

PATCH 2/2 drm/amdgpu: For bare metal, use kiq to do invalidate tlb

Remove the amdgpu_sriov_vf checking.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 2 +-
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 8 +++-----
 2 files changed, 4 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -1
index c9b3db4..4dde406 100644
@@ -4362,7 +4362,7 @@ static void gfx_v9_0_ring_emit_reg_write_reg_wait(struct amdgpu_ring *ring,
 
 	fw_version_ok = (adev->asic_type == CHIP_VEGA10) ? fw_version_ok : false;
 
-	if (amdgpu_sriov_vf(adev) && fw_version_ok)
+	if (fw_version_ok)
 		gfx_v9_0_wait_reg_mem(ring, usepfp, 0, 1, reg0, reg1,
 				      ref, mask, 0x20);
 	else
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +3 -5
index 3419178..4257242 100644
@@ -394,11 +394,9 @@ static void gmc_v9_0_flush_gpu_tlb(struct amdgpu_device *adev,
 		struct amdgpu_vmhub *hub = &adev->vmhub[i];
 		u32 tmp = gmc_v9_0_get_invalidate_req(vmid);
 
-		if (amdgpu_sriov_vf(adev) ) {
-			r = amdgpu_kiq_invalidate_tlb(adev, hub, eng, tmp, vmid);
-			if (!r)
-				continue;
-		}
+		r = amdgpu_kiq_invalidate_tlb(adev, hub, eng, tmp, vmid);
+		if (!r)
+			continue;
 
 		WREG32_NO_KIQ(hub->vm_inv_eng0_req + eng, tmp);
 
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx