Skip to contentSkip to conversation

drm/amdgpu: modify invalidate semaphore limit in gmc10

PATCH In review Changfeng.Zhu 2 participants 2 messages Dec 10, 2019

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

PATCH 2/2 drm/amdgpu: modify invalidate semaphore limit in gmc10

From: changzhu <[email protected]>

It may fail to load guest driver in round 2 when using invalidate semaphore for SRIOV. So it needs to avoid using invalidate semaphore for SRIOV.

Change-Id I2719671cf86a1755b05c5f2ac7420a901abbe916
---
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 32 +++++++++++++++++++-------
 1 file changed, 24 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +24 -8
index 381bb709f021..fd6e3b3b8084 100644
@@ -218,6 +218,24 @@ static uint32_t gmc_v10_0_get_invalidate_req(unsigned int vmid,
 	return req;
 }
 
+/**
+ * gmc_v10_0_use_invalidate_semaphore - judge whether to use semaphore
+ *
+ * @adev: amdgpu_device pointer
+ * @vmhub: vmhub type
+ *
+ */
+static bool gmc_v10_0_use_invalidate_semaphore(struct amdgpu_device *adev,
+				       uint32_t vmhub)
+{
+	if ((vmhub == AMDGPU_MMHUB_0 ||
+	     vmhub == AMDGPU_MMHUB_1) &&
+	    (!amdgpu_sriov_vf(adev)))
+		return true;
+	else
+		return false;
+}
+
 /*
  * GART
  * VMID 0 is the physical GPU addresses as used by the kernel.
@@ -233,6 +251,7 @@ static void gmc_v10_0_flush_vm_hub(struct amdgpu_device *adev, uint32_t vmid,
 	/* Use register 17 for GART */
 	const unsigned eng = 17;
 	unsigned int i;
+	bool value = gmc_v10_0_use_invalidate_semaphore(adev, vmhub);
 
 	spin_lock(&adev->gmc.invalidate_lock);
 	/*
@@ -243,8 +262,7 @@ static void gmc_v10_0_flush_vm_hub(struct amdgpu_device *adev, uint32_t vmid,
 	 */
 
 	/* TODO: It needs to continue working on debugging with semaphore for GFXHUB as well. */
-	if (vmhub == AMDGPU_MMHUB_0 ||
-	    vmhub == AMDGPU_MMHUB_1) {
+	if (value) {
 		for (i = 0; i < adev->usec_timeout; i++) {
 			/* a read return value of 1 means semaphore acuqire */
 			tmp = RREG32_NO_KIQ(hub->vm_inv_eng0_sem + eng);
@@ -277,8 +295,7 @@ static void gmc_v10_0_flush_vm_hub(struct amdgpu_device *adev, uint32_t vmid,
 	}
 
 	/* TODO: It needs to continue working on debugging with semaphore for GFXHUB as well. */
-	if (vmhub == AMDGPU_MMHUB_0 ||
-	    vmhub == AMDGPU_MMHUB_1)
+	if (value)
 		/*
 		 * add semaphore release after invalidation,
 		 * write with 0 means semaphore release
@@ -372,6 +389,7 @@ static uint64_t gmc_v10_0_emit_flush_gpu_tlb(struct amdgpu_ring *ring,
 	struct amdgpu_vmhub *hub = &ring->adev->vmhub[ring->funcs->vmhub];
 	uint32_t req = gmc_v10_0_get_invalidate_req(vmid, 0);
 	unsigned eng = ring->vm_inv_eng;
+	bool value = gmc_v10_0_use_invalidate_semaphore(ring->adev, ring->funcs->vmhub);
 
 	/*
 	 * It may lose gpuvm invalidate acknowldege state across power-gating
@@ -381,8 +399,7 @@ static uint64_t gmc_v10_0_emit_flush_gpu_tlb(struct amdgpu_ring *ring,
 	 */
 
 	/* TODO: It needs to continue working on debugging with semaphore for GFXHUB as well. */
-	if (ring->funcs->vmhub == AMDGPU_MMHUB_0 ||
-	    ring->funcs->vmhub == AMDGPU_MMHUB_1)
+	if (value)
 		/* a read return value of 1 means semaphore acuqire */
 		amdgpu_ring_emit_reg_wait(ring,
 					  hub->vm_inv_eng0_sem + eng, 0x1, 0x1);
@@ -398,8 +415,7 @@ static uint64_t gmc_v10_0_emit_flush_gpu_tlb(struct amdgpu_ring *ring,
 					    req, 1 << vmid);
 
 	/* TODO: It needs to continue working on debugging with semaphore for GFXHUB as well. */
-	if (ring->funcs->vmhub == AMDGPU_MMHUB_0 ||
-	    ring->funcs->vmhub == AMDGPU_MMHUB_1)
+	if (value)
 		/*
 		 * add semaphore release after invalidation,
 		 * write with 0 means semaphore release
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by on v1 2/2
#1 lore raw
Quoted 43 lines · Changfeng.Zhu

From: changzhu <[email protected]>

It may fail to load guest driver in round 2 when using invalidate semaphore for SRIOV. So it needs to avoid using invalidate semaphore for SRIOV.

Change-Id I2719671cf86a1755b05c5f2ac7420a901abbe916
---
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 32 +++++++++++++++++++-------
 1 file changed, 24 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +18 -0
index 381bb709f021..fd6e3b3b8084 100644
@@ -218,6 +218,24 @@ static uint32_t gmc_v10_0_get_invalidate_req(unsigned int vmid,
        return req;
 }
 
+/**
+ * gmc_v10_0_use_invalidate_semaphore - judge whether to use semaphore
+ *
+ * @adev: amdgpu_device pointer
+ * @vmhub: vmhub type
+ *
+ */
+static bool gmc_v10_0_use_invalidate_semaphore(struct amdgpu_device *adev,
+                                      uint32_t vmhub)
+{
+       if ((vmhub == AMDGPU_MMHUB_0 ||
+            vmhub == AMDGPU_MMHUB_1) &&
+           (!amdgpu_sriov_vf(adev)))
+               return true;
+       else
+               return false;
+}
+
 /*
  * GART
  * VMID 0 is the physical GPU addresses as used by the kernel.

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static void gmc_v10_0_flush_vm_hub(struct amdgpu_device *adev, uint32_t vmid, · line 254

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -0
@@ -233,6 +251,7 @@ static void gmc_v10_0_flush_vm_hub(struct amdgpu_device *adev, uint32_t vmid,
        /* Use register 17 for GART */
        const unsigned eng = 17;
        unsigned int i;
+       bool value = gmc_v10_0_use_invalidate_semaphore(adev, vmhub);

Call this use_semaphore or something like that rather than value. Same comment to the instances below as well. With that fixed,

Quoted 54 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +5 -9
        spin_lock(&adev->gmc.invalidate_lock);
        /*
@@ -243,8 +262,7 @@ static void gmc_v10_0_flush_vm_hub(struct amdgpu_device *adev, uint32_t vmid,
         */
 
        /* TODO: It needs to continue working on debugging with semaphore for GFXHUB as well. */
-       if (vmhub == AMDGPU_MMHUB_0 ||
-           vmhub == AMDGPU_MMHUB_1) {
+       if (value) {
                for (i = 0; i < adev->usec_timeout; i++) {
                        /* a read return value of 1 means semaphore acuqire */
                        tmp = RREG32_NO_KIQ(hub->vm_inv_eng0_sem + eng);
@@ -277,8 +295,7 @@ static void gmc_v10_0_flush_vm_hub(struct amdgpu_device *adev, uint32_t vmid,
        }
 
        /* TODO: It needs to continue working on debugging with semaphore for GFXHUB as well. */
-       if (vmhub == AMDGPU_MMHUB_0 ||
-           vmhub == AMDGPU_MMHUB_1)
+       if (value)
                /*
                 * add semaphore release after invalidation,
                 * write with 0 means semaphore release
@@ -372,6 +389,7 @@ static uint64_t gmc_v10_0_emit_flush_gpu_tlb(struct amdgpu_ring *ring,
        struct amdgpu_vmhub *hub = &ring->adev->vmhub[ring->funcs->vmhub];
        uint32_t req = gmc_v10_0_get_invalidate_req(vmid, 0);
        unsigned eng = ring->vm_inv_eng;
+       bool value = gmc_v10_0_use_invalidate_semaphore(ring->adev, ring->funcs->vmhub);
 
        /*
         * It may lose gpuvm invalidate acknowldege state across power-gating
@@ -381,8 +399,7 @@ static uint64_t gmc_v10_0_emit_flush_gpu_tlb(struct amdgpu_ring *ring,
         */
 
        /* TODO: It needs to continue working on debugging with semaphore for GFXHUB as well. */
-       if (ring->funcs->vmhub == AMDGPU_MMHUB_0 ||
-           ring->funcs->vmhub == AMDGPU_MMHUB_1)
+       if (value)
                /* a read return value of 1 means semaphore acuqire */
                amdgpu_ring_emit_reg_wait(ring,
                                          hub->vm_inv_eng0_sem + eng, 0x1, 0x1);
@@ -398,8 +415,7 @@ static uint64_t gmc_v10_0_emit_flush_gpu_tlb(struct amdgpu_ring *ring,
                                            req, 1 << vmid);
 
        /* TODO: It needs to continue working on debugging with semaphore for GFXHUB as well. */
-       if (ring->funcs->vmhub == AMDGPU_MMHUB_0 ||
-           ring->funcs->vmhub == AMDGPU_MMHUB_1)
+       if (value)
                /*
                 * add semaphore release after invalidation,
                 * write with 0 means semaphore release
--

2.17.1

Quoted 4 lines

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

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