drm/amdgpu/gfx9: switch to golden tsc registers for renoir+
Subsystems (3)
PATCH 1/1 drm/amdgpu/gfx9: switch to golden tsc registers for renoir+
From: Alex Deucher <[email protected]>
commit 53af98c091bc ("drm/amdgpu/gfx9: switch to golden tsc registers for renoir+")
Renoir and newer gfx9 APUs have new TSC register that is not part of the gfxoff tile, so it can be read without needing to disable gfx off.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 46 ++++++++++++++++++++------- 1 file changed, 35 insertions(+), 11 deletions(-)
This is necessary for s0i3 to work well on GNOME41 which tries to access timestamps during suspend process causing GFX to wake up.
Modified to take use ASIC IDs rather than IP version checking Please apply this to both 5.14.y and 5.15.y.
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +35 -11
@@ -140,6 +140,11 @@ MODULE_FIRMWARE("amdgpu/aldebaran_rlc.bin");#define mmTCP_CHAN_STEER_5_ARCT 0x0b0c#define mmTCP_CHAN_STEER_5_ARCT_BASE_IDX 0 +#define mmGOLDEN_TSC_COUNT_UPPER_Renoir 0x0025 +#define mmGOLDEN_TSC_COUNT_UPPER_Renoir_BASE_IDX 1 +#define mmGOLDEN_TSC_COUNT_LOWER_Renoir 0x0026 +#define mmGOLDEN_TSC_COUNT_LOWER_Renoir_BASE_IDX 1 +enum ta_ras_gfx_subblock {/*CPC*/ TA_RAS_BLOCK__GFX_CPC_INDEX_START =0 ,
@@ -4228,19 +4233,38 @@ static uint64_t gfx_v9_0_kiq_read_clock(struct amdgpu_device *adev)static uint64_t gfx_v9_0_get_gpu_clock_counter (struct amdgpu_device *adev) { -uint64_t clock; +uint64_t clock, clock_lo, clock_hi, hi_check; -amdgpu_gfx_off_ctrl (adev, false); -mutex_lock (&adev->gfx.gpu_clock_mutex); -if (adev->asic_type ==CHIP_VEGA10 &&amdgpu_sriov_runtime (adev)) { - clock =gfx_v9_0_kiq_read_clock (adev); - }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 ); +switch (adev->asic_type) { +case CHIP_RENOIR : +preempt_disable (); + clock_hi =RREG32_SOC15_NO_KIQ (SMUIO ,0 , mmGOLDEN_TSC_COUNT_UPPER_Renoir); + clock_lo =RREG32_SOC15_NO_KIQ (SMUIO ,0 , mmGOLDEN_TSC_COUNT_LOWER_Renoir); + hi_check =RREG32_SOC15_NO_KIQ (SMUIO ,0 , mmGOLDEN_TSC_COUNT_UPPER_Renoir); +/* The SMUIO TSC clock frequency is 100MHz, which sets 32-bit carry over +* roughly every 42 seconds. +*/ +if (hi_check != clock_hi) { + clock_lo =RREG32_SOC15_NO_KIQ (SMUIO ,0 , mmGOLDEN_TSC_COUNT_LOWER_Renoir); + clock_hi = hi_check; + } +preempt_enable (); + clock = clock_lo | (clock_hi <<32ULL ); +break ; +default : +amdgpu_gfx_off_ctrl (adev, false); +mutex_lock (&adev->gfx.gpu_clock_mutex); +if (adev->asic_type ==CHIP_VEGA10 &&amdgpu_sriov_runtime (adev)) { + clock =gfx_v9_0_kiq_read_clock (adev); + }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); +amdgpu_gfx_off_ctrl (adev, true); +break ; } -mutex_unlock (&adev->gfx.gpu_clock_mutex); -amdgpu_gfx_off_ctrl (adev, true);return clock; }
Signature · 1 line
2.25.1
PATCH 1/1 drm/amdgpu/gfx10: add wraparound gpu counter check for APUs as well
From: Alex Deucher <[email protected]>
commit 244ee398855d ("drm/amdgpu/gfx10: add wraparound gpu counter check for APUs as well")
Apply the same check we do for dGPUs for APUs as well.
--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
Modified to take use ASIC IDs rather than IP version checking Please apply to both 5.14.y and 5.15.y.
When applying to 5.14.y this also has a dependency of:
commit 5af4438f1e83 ("drm/amdgpu: Read clock counter via MMIO to reduce delay (v5)") If necessary I can send that separately.
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +13 -2
@@ -7729,8 +7729,19 @@ static uint64_t gfx_v10_0_get_gpu_clock_counter(struct amdgpu_device *adev)switch (adev->asic_type) {case CHIP_VANGOGH :case CHIP_YELLOW_CARP : - clock = (uint64_t )RREG32_SOC15 (SMUIO ,0 , mmGOLDEN_TSC_COUNT_LOWER_Vangogh) | - ((uint64_t )RREG32_SOC15 (SMUIO ,0 , mmGOLDEN_TSC_COUNT_UPPER_Vangogh) <<32ULL ); +preempt_disable (); + clock_hi =RREG32_SOC15_NO_KIQ (SMUIO ,0 , mmGOLDEN_TSC_COUNT_UPPER_Vangogh); + clock_lo =RREG32_SOC15_NO_KIQ (SMUIO ,0 , mmGOLDEN_TSC_COUNT_LOWER_Vangogh); + hi_check =RREG32_SOC15_NO_KIQ (SMUIO ,0 , mmGOLDEN_TSC_COUNT_UPPER_Vangogh); +/* The SMUIO TSC clock frequency is 100MHz, which sets 32-bit carry over +* roughly every 42 seconds. +*/ +if (hi_check != clock_hi) { + clock_lo =RREG32_SOC15_NO_KIQ (SMUIO ,0 , mmGOLDEN_TSC_COUNT_LOWER_Vangogh); + clock_hi = hi_check; + } +preempt_enable (); + clock = clock_lo | (clock_hi <<32ULL );break ;default :preempt_disable ();
Signature · 1 line
2.25.1
Deucher, Alexander
maintainerRE: [PATCH] drm/amdgpu/gfx10: add wraparound gpu counter check for APUs as well
[AMD Official Use Only]
Quoted 12 lines
-----Original Message-----
From: Limonciello, Mario <[email protected]>
Sent: Monday, November 29, 2021 1:25 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Tuikov, Luben <[email protected]>; Limonciello, Mario <[email protected]>
Subject: [PATCH] drm/amdgpu/gfx10: add wraparound gpu counter check for APUs as wellFrom: Alex Deucher <[email protected]>
Quoted 8 lines
commit
244ee398855d("drm/amdgpu/gfx10: add wraparound gpu counter check for APUs as well")Apply the same check we do for dGPUs for APUs as well.
Acked-by Luben Tuikov <[email protected]>Signed-off-by Alex Deucher <[email protected]>Signed-off-by Mario Limnonciello <[email protected]>
I just send these out earlier today and Greg applied them. I forgot to cc you.
Alex
Quoted 48 lines
--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)Modified to take use ASIC IDs rather than IP version checking Please apply to both 5.14.y and 5.15.y.
When applying to 5.14.y this also has a dependency of:
commit5af4438f1e83("drm/amdgpu: Read clock counter via MMIO to reduce delay (v5)") If necessary I can send that separately.drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +0
-1@@ -7729,8 +7729,19 @@ static uint64_t gfx_v10_0_get_gpu_clock_counter(struct amdgpu_device *adev) switch (adev->asic_type) {case CHIP_VANGOGH :case CHIP_YELLOW_CARP : - clock = (uint64_t)RREG32_SOC15(SMUIO, 0,
mmGOLDEN_TSC_COUNT_LOWER_Vangogh) |drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +0
-1- ((uint64_t)RREG32_SOC15(SMUIO, 0,
mmGOLDEN_TSC_COUNT_UPPER_Vangogh) << 32ULL);drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +2
-0+preempt_disable (); + clock_hi = RREG32_SOC15_NO_KIQ(SMUIO, 0,
mmGOLDEN_TSC_COUNT_UPPER_Vangogh);drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-0+ clock_lo = RREG32_SOC15_NO_KIQ(SMUIO, 0,
mmGOLDEN_TSC_COUNT_LOWER_Vangogh);drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-0+ hi_check = RREG32_SOC15_NO_KIQ(SMUIO, 0,
mmGOLDEN_TSC_COUNT_UPPER_Vangogh);drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-0+/* The SMUIO TSC clock frequency is 100MHz, which sets 32- bit carry over
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +4
-0+* roughly every 42 seconds. +*/ +if (hi_check != clock_hi) { + clock_lo = RREG32_SOC15_NO_KIQ(SMUIO, 0,
mmGOLDEN_TSC_COUNT_LOWER_Vangogh);drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +4
-1+ clock_hi = hi_check; + } +preempt_enable (); + clock = clock_lo | (clock_hi <<32ULL );break ;default :preempt_disable (); --2.25.1
RE: [PATCH] drm/amdgpu/gfx10: add wraparound gpu counter check for APUs as well
Quoted 27 lines
-----Original Message-----
From: Deucher, Alexander <[email protected]>
Sent: Monday, November 29, 2021 12:28
To: Limonciello, Mario <[email protected]>; [email protected]
Cc: Tuikov, Luben <[email protected]>
Subject: RE: [PATCH] drm/amdgpu/gfx10: add wraparound gpu counter check for APUs as well[AMD Official Use Only]
Quoted 15 lines
-----Original Message-----
From: Limonciello, Mario <[email protected]>
Sent: Monday, November 29, 2021 1:25 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Tuikov, Luben <[email protected]>; Limonciello, Mario <[email protected]>
Subject: [PATCH] drm/amdgpu/gfx10: add wraparound gpu counter check for APUs as wellFrom: Alex Deucher <[email protected]>
commit
244ee398855d("drm/amdgpu/gfx10: add wraparound gpu counter check for APUs as well")
Quoted 7 lines
Quoted 5 lines
Apply the same check we do for dGPUs for APUs as well.
Acked-by Luben Tuikov <[email protected]>Signed-off-by Alex Deucher <[email protected]>Signed-off-by Mario Limnonciello <[email protected]>I just send these out earlier today and Greg applied them. I forgot to cc you.
Oh, ok thanks!
Quoted 51 lines
Alex
Quoted 48 lines
--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)Modified to take use ASIC IDs rather than IP version checking Please apply to both 5.14.y and 5.15.y.
When applying to 5.14.y this also has a dependency of:
commit5af4438f1e83("drm/amdgpu: Read clock counter via MMIO to reduce delay (v5)") If necessary I can send that separately.drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +0
-1@@ -7729,8 +7729,19 @@ static uint64_t gfx_v10_0_get_gpu_clock_counter(struct amdgpu_device *adev) switch (adev->asic_type) {case CHIP_VANGOGH :case CHIP_YELLOW_CARP : - clock = (uint64_t)RREG32_SOC15(SMUIO, 0,
mmGOLDEN_TSC_COUNT_LOWER_Vangogh) |drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +0
-1- ((uint64_t)RREG32_SOC15(SMUIO, 0,
mmGOLDEN_TSC_COUNT_UPPER_Vangogh) << 32ULL);drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +2
-0+preempt_disable (); + clock_hi = RREG32_SOC15_NO_KIQ(SMUIO, 0,
mmGOLDEN_TSC_COUNT_UPPER_Vangogh);drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-0+ clock_lo = RREG32_SOC15_NO_KIQ(SMUIO, 0,
mmGOLDEN_TSC_COUNT_LOWER_Vangogh);drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-0+ hi_check = RREG32_SOC15_NO_KIQ(SMUIO, 0,
mmGOLDEN_TSC_COUNT_UPPER_Vangogh);drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-0+/* The SMUIO TSC clock frequency is 100MHz, which sets 32- bit carry over
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +4
-0+* roughly every 42 seconds. +*/ +if (hi_check != clock_hi) { + clock_lo = RREG32_SOC15_NO_KIQ(SMUIO, 0,
mmGOLDEN_TSC_COUNT_LOWER_Vangogh);drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +4
-1+ clock_hi = hi_check; + } +preempt_enable (); + clock = clock_lo | (clock_hi <<32ULL );break ;default :preempt_disable (); --2.25.1
Greg KH
maintainerQuoted 16 lines · Mario Limonciello
From: Alex Deucher <[email protected]>
commit
53af98c091bc("drm/amdgpu/gfx9: switch to golden tsc registers for renoir+")Renoir and newer gfx9 APUs have new TSC register that is not part of the gfxoff tile, so it can be read without needing to disable gfx off.
Acked-by Luben Tuikov <[email protected]>Signed-off-by Alex Deucher <[email protected]>Signed-off-by Mario Limonciello <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 46 ++++++++++++++++++++------- 1 file changed, 35 insertions(+), 11 deletions(-)
Quoted 5 lines
This is necessary for s0i3 to work well on GNOME41 which tries to access timestamps during suspend process causing GFX to wake up.
Modified to take use ASIC IDs rather than IP version checking Please apply this to both 5.14.y and 5.15.y.
Please note that 5.14.y is end-of-life as the front page of kernel.org should show.
thanks,
greg k-h
Quoted 26 lines
-----Original Message-----
From: Greg KH <[email protected]>
Sent: Tuesday, November 30, 2021 04:13
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Tuikov, Luben <[email protected]>
Subject: Re: [PATCH] drm/amdgpu/gfx9: switch to golden tsc registers for renoir+Quoted 16 lines · Mario Limonciello
From: Alex Deucher <[email protected]>
commit
53af98c091bc("drm/amdgpu/gfx9: switch to golden tsc registers for renoir+")Renoir and newer gfx9 APUs have new TSC register that is not part of the gfxoff tile, so it can be read without needing to disable gfx off.
Acked-by Luben Tuikov <[email protected]>Signed-off-by Alex Deucher <[email protected]>Signed-off-by Mario Limonciello <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 46 ++++++++++++++++++++------- 1 file changed, 35 insertions(+), 11 deletions(-)
Quoted 9 lines
Quoted 5 lines
This is necessary for s0i3 to work well on GNOME41 which tries to access timestamps during suspend process causing GFX to wake up.
Modified to take use ASIC IDs rather than IP version checking Please apply this to both 5.14.y and 5.15.y.
Please note that 5.14.y is end-of-life as the front page of kernel.org should show.
Thanks, I didn't realize that until now.