]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/amdgpu: change read of GPU clock counter on Vega10 VF
authorEric Huang <JinhuiEric.Huang@amd.com>
Tue, 5 Nov 2019 21:29:57 +0000 (16:29 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 6 Nov 2019 21:27:48 +0000 (16:27 -0500)
Using unified VBIOS has performance drop in sriov environment.
The fix is switching to another register instead.

Signed-off-by: Eric Huang <JinhuiEric.Huang@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c

index 6d963f29187ce2f49f199f66191a2ee7c1602c6e..b1f3334e9c527d40a494b72dc2b1c05d1ccc97ae 100644 (file)
@@ -3884,9 +3884,22 @@ 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 {
+                       if (i != 0)
+                               udelay(1);
+                       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++;
+               } 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;
 }