Skip to contentSkip to conversation

drm/amdgpu: change read of GPU clock counter on Vega10 VF

PATCH In review Huang, JinHuiEric 2 participants 2 messages Nov 5, 2019 1 message not in the archive

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

PATCH 1/1 drm/amdgpu: change read of GPU clock counter on Vega10 VF

Using unified VBIOS has performance drop in sriov environment. The fix is switching to another register instead.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +15 -3
index 829d623..6770bd1 100644
@@ -3885,9 +3885,21 @@ static uint64_t gfx_v9_0_get_gpu_clock_counter(struct amdgpu_device *adev)
 	uint64_t clock;
 
 	mutex_lock(&adev->gfx.gpu_clock_mutex);
-	WREG32_SOC15(GC, 0, mmRLC_CAPTURE_GPU_CLOCK_COUNT, 1);
-	clock = (uint64_t)RREG32_SOC15(GC, 0, mmRLC_GPU_CLOCK_COUNT_LSB) |
-		((uint64_t)RREG32_SOC15(GC, 0, mmRLC_GPU_CLOCK_COUNT_MSB) << 32ULL);
+	if (adev->asic_type == CHIP_VEGA10 && amdgpu_sriov_runtime(adev)) {
+		uint32_t tmp, lsb, msb, i = 0;
+		do {
+			tmp = RREG32_SOC15(GC, 0, mmRLC_REFCLOCK_TIMESTAMP_MSB);
+			lsb = RREG32_SOC15(GC, 0, mmRLC_REFCLOCK_TIMESTAMP_LSB);
+			msb = RREG32_SOC15(GC, 0, mmRLC_REFCLOCK_TIMESTAMP_MSB);
+			i++;
+			udelay(1);
+		} while (unlikely(tmp != msb) && (i < adev->usec_timeout));
+		clock = (uint64_t)lsb | ((uint64_t)msb << 32ULL);
+	} else {
+		WREG32_SOC15(GC, 0, mmRLC_CAPTURE_GPU_CLOCK_COUNT, 1);
+		clock = (uint64_t)RREG32_SOC15(GC, 0, mmRLC_GPU_CLOCK_COUNT_LSB) |
+			((uint64_t)RREG32_SOC15(GC, 0, mmRLC_GPU_CLOCK_COUNT_MSB) << 32ULL);
+	}
 	mutex_unlock(&adev->gfx.gpu_clock_mutex);
 	return clock;
 }
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): 1572991381-19907-1-git-send-email-JinhuiEric.Huang-5C7GfCeVMHo@public.gmane.org

#2 lore raw
Quoted 17 lines · JinHuiEric

Using unified VBIOS has performance drop in sriov environment. The fix is switching to another register instead.

---
  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 18 +++++++++++++++---
  1 file changed, 15 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -1
index 829d623..6770bd1 100644
@@ -3885,9 +3885,21 @@ static uint64_t gfx_v9_0_get_gpu_clock_counter(struct amdgpu_device *adev)
  	uint64_t clock;
 
  	mutex_lock(&adev->gfx.gpu_clock_mutex);
-	WREG32_SOC15(GC, 0, mmRLC_CAPTURE_GPU_CLOCK_COUNT, 1);

drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static uint64_t gfx_v9_0_get_gpu_clock_counter(struct amdgpu_device *adev) · line 3895

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +8 -2
-	clock = (uint64_t)RREG32_SOC15(GC, 0, mmRLC_GPU_CLOCK_COUNT_LSB) |
-		((uint64_t)RREG32_SOC15(GC, 0, mmRLC_GPU_CLOCK_COUNT_MSB) << 32ULL);
+	if (adev->asic_type == CHIP_VEGA10 && amdgpu_sriov_runtime(adev)) {
+		uint32_t tmp, lsb, msb, i = 0;
+		do {
+			tmp = RREG32_SOC15(GC, 0, mmRLC_REFCLOCK_TIMESTAMP_MSB);
+			lsb = RREG32_SOC15(GC, 0, mmRLC_REFCLOCK_TIMESTAMP_LSB);
+			msb = RREG32_SOC15(GC, 0, mmRLC_REFCLOCK_TIMESTAMP_MSB);
+			i++;
+			udelay(1);

This udelay should be conditional. In the likely case that tmp == msb, you should never have to delay at all. Maybe put the delay at the start of the loop with a condition:

    if (i != 0)
        udelay(1);

So that it only applies before the second and later loops.

Regards,
  Felix

drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static uint64_t gfx_v9_0_get_gpu_clock_counter(struct amdgpu_device *adev) · line 3905

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +7 -0
+		} while (unlikely(tmp != msb) && (i < adev->usec_timeout));
+		clock = (uint64_t)lsb | ((uint64_t)msb << 32ULL);
+	} else {
+		WREG32_SOC15(GC, 0, mmRLC_CAPTURE_GPU_CLOCK_COUNT, 1);
+		clock = (uint64_t)RREG32_SOC15(GC, 0, mmRLC_GPU_CLOCK_COUNT_LSB) |
+			((uint64_t)RREG32_SOC15(GC, 0, mmRLC_GPU_CLOCK_COUNT_MSB) << 32ULL);
+	}
  	mutex_unlock(&adev->gfx.gpu_clock_mutex);
  	return clock;
  }

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