Skip to contentSkip to conversation

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

PATCH In review Huang, JinHuiEric 5 participants 7 messages Nov 5, 2019 – Nov 6, 2019 5 messages 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 | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +16 -3
index 829d623..e44a3ea 100644
@@ -3885,9 +3885,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;
 }
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): 1572992808-20397-1-git-send-email-JinhuiEric.Huang-5C7GfCeVMHo@public.gmane.org

Reviewed-by Felix Kuehling
#2 lore raw
Quoted 4 lines · JinHuiEric

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

Quoted 24 lines
---
  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 19 ++++++++++++++++---
  1 file changed, 16 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +9 -3
index 829d623..e44a3ea 100644
@@ -3885,9 +3885,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++;

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

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

#3 lore raw
In reply to a message not in the archive
Quoted 26 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 | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +6 -3
index 829d623..e44a3ea 100644
@@ -3885,9 +3885,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);

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

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +10 -0
+                       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);
+       }

Is there a reason we can't use the same regs on bare metal and SR-IOV?
I'd like to minimize the deltas if possible.

Alex

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -1
        mutex_unlock(&adev->gfx.gpu_clock_mutex);
        return clock;
 }
--

2.7.4

_______________________________________________
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

A message that is not in the archive (sent off-list or not yet received): CADnq5_NDEXUD84z8srp8NNMNvDVwLNZsZUSek=U2hMwkDKxaNw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#5 lore raw
Quoted 31 lines · Alex Deucher
Quoted 29 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 | 19 ++++++++++++++++---
  1 file changed, 16 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +10 -3
index 829d623..e44a3ea 100644
@@ -3885,9 +3885,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));
Quoted 8 lines

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

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +6 -0
+               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);
+       }

Is there a reason we can't use the same regs on bare metal and SR-IOV?
I'd like to minimize the deltas if possible.

As Jerry's request, this change will avoid P1 policy protection on RLC_GPU_CLOCK_COUNT_LSB/MSB.

Eric

Quoted 13 lines

Alex

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -1
         mutex_unlock(&adev->gfx.gpu_clock_mutex);
         return clock;
  }
--

2.7.4

_______________________________________________
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

A message that is not in the archive (sent off-list or not yet received): 968d3fe1-4faf-f003-3ec4-10fd5c35cdd8-5C7GfCeVMHo@public.gmane.org

#7 lore raw

Hi Alex,

Under the SRIOV mode, the L1 policy prevent the write to mmRLC_CAPTURE_GPU_CLOCK_COUNT on VF, so the RLC_GPU_CLOCK_COUNT_LSB/MSB doesn't get updated for each read under SRIOV VF.

On the other hand, the read from RLC_REFCLOCK_TIMESTAMP_LSB/MSB doesn't rely on any write, so it is available on VF. And of cause it is available for bare metal also. However, the RLC_REFCLOCK_TIMESTAMP_LSB/MSB will reset to zero under two cases: 1) GFXOFF 2) Reset. Since SRIOV doesn't have GFXOFF, and after reset, the guest will have to restart the app, so there is no problem for SRIOV to switch to this new register set.

On bare metal, there is concern with these two cases. We didn't get confirmation from Rocm team that the counter reset to zero after 1) GFXOFF 2) Reset will not affect the usage of GPU timestamp, we can't make the switch for bare metal. I would be more than happy to switch all over if we can..

Jerry

-----Original Message-----
From: Huang, JinHuiEric <[email protected]>
Sent: Tuesday, November 5, 2019 6:48 PM
To: Alex Deucher <[email protected]>
Cc: [email protected]; Jiang, Jerry (SW) <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: change read of GPU clock counter on Vega10 VF

Quoted 32 lines · Alex Deucher
Quoted 30 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 | 19 ++++++++++++++++---
  1 file changed, 16 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +10 -3
index 829d623..e44a3ea 100644
@@ -3885,9 +3885,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));
Quoted 8 lines

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

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +6 -0
+               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);
+       }

Is there a reason we can't use the same regs on bare metal and SR-IOV?
I'd like to minimize the deltas if possible.

As Jerry's request, this change will avoid P1 policy protection on RLC_GPU_CLOCK_COUNT_LSB/MSB.

Eric

Quoted 13 lines

Alex

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -1
         mutex_unlock(&adev->gfx.gpu_clock_mutex);
         return clock;
  }
--

2.7.4

_______________________________________________
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

A message that is not in the archive (sent off-list or not yet received): BL0PR12MB250054D0D1FE729D1E0E15D3EE790-b4cIHhjg/p89/[email protected]

#9 lore raw

The current bare metal registers also get reset with gfxoff and GPU reset.

Alex

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Jiang, Jerry (SW) <[email protected]>
Sent: Tuesday, November 5, 2019 7:04 PM
To: Huang, JinHuiEric <[email protected]>; Alex Deucher <[email protected]>
Cc: [email protected] <[email protected]>
Subject: RE: [PATCH] drm/amdgpu: change read of GPU clock counter on Vega10 VF

Hi Alex,

Under the SRIOV mode, the L1 policy prevent the write to mmRLC_CAPTURE_GPU_CLOCK_COUNT on VF, so the RLC_GPU_CLOCK_COUNT_LSB/MSB doesn't get updated for each read under SRIOV VF.

On the other hand, the read from RLC_REFCLOCK_TIMESTAMP_LSB/MSB doesn't rely on any write, so it is available on VF. And of cause it is available for bare metal also. However, the RLC_REFCLOCK_TIMESTAMP_LSB/MSB will reset to zero under two cases: 1) GFXOFF 2) Reset. Since SRIOV doesn't have GFXOFF, and after reset, the guest will have to restart the app, so there is no problem for SRIOV to switch to this new register set.

On bare metal, there is concern with these two cases. We didn't get confirmation from Rocm team that the counter reset to zero after 1) GFXOFF 2) Reset will not affect the usage of GPU timestamp, we can't make the switch for bare metal. I would be more than happy to switch all over if we can..

Jerry

-----Original Message-----
From: Huang, JinHuiEric <[email protected]>
Sent: Tuesday, November 5, 2019 6:48 PM
To: Alex Deucher <[email protected]>
Cc: [email protected]; Jiang, Jerry (SW) <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: change read of GPU clock counter on Vega10 VF

Quoted 32 lines · Alex Deucher
Quoted 30 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 | 19 ++++++++++++++++---
  1 file changed, 16 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +10 -3
index 829d623..e44a3ea 100644
@@ -3885,9 +3885,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));
Quoted 8 lines

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

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +6 -0
+               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);
+       }

Is there a reason we can't use the same regs on bare metal and SR-IOV?
I'd like to minimize the deltas if possible.

As Jerry's request, this change will avoid P1 policy protection on RLC_GPU_CLOCK_COUNT_LSB/MSB.

Eric

Quoted 13 lines

Alex

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -1
         mutex_unlock(&adev->gfx.gpu_clock_mutex);
         return clock;
  }
--

2.7.4

_______________________________________________
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

_______________________________________________
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): CY4PR12MB1813EEC3C3C3B0DA5CF0DECBF7790-rpdhrqHFk05Nhq0cRkx5WwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#11 lore raw

Ashkan,

Can you comment on the observation from Alex regarding RLC_GPU_CLOCK_COUNT_LSB/MSB register with GFXoff and GPU reset?

If the statement from Alex is the real situation, we can simply our change.

Jerry

From: Deucher, Alexander <[email protected]>
Sent: Wednesday, November 6, 2019 9:10 AM
To: Jiang, Jerry (SW) <[email protected]>; Huang, JinHuiEric <[email protected]>; Alex Deucher <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] drm/amdgpu: change read of GPU clock counter on Vega10 VF

The current bare metal registers also get reset with gfxoff and GPU reset.

Alex

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org<mailto:[email protected]>> on behalf of Jiang, Jerry (SW) <[email protected]<mailto:[email protected]>>
Sent: Tuesday, November 5, 2019 7:04 PM
To: Huang, JinHuiEric <[email protected]<mailto:[email protected]>>; Alex Deucher <[email protected]<mailto:[email protected]>>
Cc: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>
Subject: RE: [PATCH] drm/amdgpu: change read of GPU clock counter on Vega10 VF

Hi Alex,

Under the SRIOV mode, the L1 policy prevent the write to mmRLC_CAPTURE_GPU_CLOCK_COUNT on VF, so the RLC_GPU_CLOCK_COUNT_LSB/MSB doesn't get updated for each read under SRIOV VF.

On the other hand, the read from RLC_REFCLOCK_TIMESTAMP_LSB/MSB doesn't rely on any write, so it is available on VF. And of cause it is available for bare metal also. However, the RLC_REFCLOCK_TIMESTAMP_LSB/MSB will reset to zero under two cases: 1) GFXOFF 2) Reset. Since SRIOV doesn't have GFXOFF, and after reset, the guest will have to restart the app, so there is no problem for SRIOV to switch to this new register set.

On bare metal, there is concern with these two cases. We didn't get confirmation from Rocm team that the counter reset to zero after 1) GFXOFF 2) Reset will not affect the usage of GPU timestamp, we can't make the switch for bare metal. I would be more than happy to switch all over if we can..

Jerry

-----Original Message-----
From: Huang, JinHuiEric <[email protected]<mailto:[email protected]>>
Sent: Tuesday, November 5, 2019 6:48 PM
To: Alex Deucher <[email protected]<mailto:[email protected]>>
Cc: [email protected]<mailto:[email protected]>; Jiang, Jerry (SW) <[email protected]<mailto:[email protected]>>
Subject: Re: [PATCH] drm/amdgpu: change read of GPU clock counter on Vega10 VF

Quoted 32 lines · Alex Deucher
Quoted 30 lines · On Tue, Nov 5, 2019 at 5:26 PM Huang, 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 | 19 ++++++++++++++++---
  1 file changed, 16 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +10 -3
index 829d623..e44a3ea 100644
@@ -3885,9 +3885,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));
Quoted 8 lines

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

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +6 -0
+               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);
+       }

Is there a reason we can't use the same regs on bare metal and SR-IOV?
I'd like to minimize the deltas if possible.

As Jerry's request, this change will avoid P1 policy protection on RLC_GPU_CLOCK_COUNT_LSB/MSB.

Eric

Quoted 13 lines

Alex

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -1
         mutex_unlock(&adev->gfx.gpu_clock_mutex);
         return clock;
  }
--

2.7.4

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

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

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