From: Alex Deucher alexander.deucher@amd.com
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 luben.tuikov@amd.com Signed-off-by: Alex Deucher alexander.deucher@amd.com Signed-off-by: Mario Limonciello mario.limonciello@amd.com --- 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.
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c index 025184a556ee..55f8dd6e56b4 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c @@ -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; }
From: Alex Deucher alexander.deucher@amd.com
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 luben.tuikov@amd.com Signed-off-by: Alex Deucher alexander.deucher@amd.com Signed-off-by: Mario Limnonciello mario.limonciello@amd.com --- 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.
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c index 16dbe593cba2..970d59a21005 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c @@ -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();
[AMD Official Use Only]
-----Original Message----- From: Limonciello, Mario Mario.Limonciello@amd.com Sent: Monday, November 29, 2021 1:25 PM To: stable@vger.kernel.org Cc: Deucher, Alexander Alexander.Deucher@amd.com; Tuikov, Luben Luben.Tuikov@amd.com; Limonciello, Mario Mario.Limonciello@amd.com Subject: [PATCH] drm/amdgpu/gfx10: add wraparound gpu counter check for APUs as well
From: Alex Deucher alexander.deucher@amd.com
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 luben.tuikov@amd.com Signed-off-by: Alex Deucher alexander.deucher@amd.com Signed-off-by: Mario Limnonciello mario.limonciello@amd.com
I just send these out earlier today and Greg applied them. I forgot to cc you.
Alex
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.
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c index 16dbe593cba2..970d59a21005 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c @@ -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();
break; default: preempt_disable();clock = clock_lo | (clock_hi << 32ULL);
-- 2.25.1
-----Original Message----- From: Deucher, Alexander Alexander.Deucher@amd.com Sent: Monday, November 29, 2021 12:28 To: Limonciello, Mario Mario.Limonciello@amd.com; stable@vger.kernel.org Cc: Tuikov, Luben Luben.Tuikov@amd.com Subject: RE: [PATCH] drm/amdgpu/gfx10: add wraparound gpu counter check for APUs as well
[AMD Official Use Only]
-----Original Message----- From: Limonciello, Mario Mario.Limonciello@amd.com Sent: Monday, November 29, 2021 1:25 PM To: stable@vger.kernel.org Cc: Deucher, Alexander Alexander.Deucher@amd.com; Tuikov, Luben Luben.Tuikov@amd.com; Limonciello, Mario Mario.Limonciello@amd.com Subject: [PATCH] drm/amdgpu/gfx10: add wraparound gpu counter check for APUs as well
From: Alex Deucher alexander.deucher@amd.com
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 luben.tuikov@amd.com Signed-off-by: Alex Deucher alexander.deucher@amd.com Signed-off-by: Mario Limnonciello mario.limonciello@amd.com
I just send these out earlier today and Greg applied them. I forgot to cc you.
Oh, ok thanks!
Alex
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.
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c index 16dbe593cba2..970d59a21005 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c @@ -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();
break; default: preempt_disable();clock = clock_lo | (clock_hi << 32ULL);
-- 2.25.1
On Mon, Nov 29, 2021 at 12:25:26PM -0600, Mario Limonciello wrote:
From: Alex Deucher alexander.deucher@amd.com
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 luben.tuikov@amd.com Signed-off-by: Alex Deucher alexander.deucher@amd.com Signed-off-by: Mario Limonciello mario.limonciello@amd.com
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.
Please note that 5.14.y is end-of-life as the front page of kernel.org should show.
thanks,
greg k-h
-----Original Message----- From: Greg KH gregkh@linuxfoundation.org Sent: Tuesday, November 30, 2021 04:13 To: Limonciello, Mario Mario.Limonciello@amd.com Cc: stable@vger.kernel.org; Deucher, Alexander Alexander.Deucher@amd.com; Tuikov, Luben Luben.Tuikov@amd.com Subject: Re: [PATCH] drm/amdgpu/gfx9: switch to golden tsc registers for renoir+
On Mon, Nov 29, 2021 at 12:25:26PM -0600, Mario Limonciello wrote:
From: Alex Deucher alexander.deucher@amd.com
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 luben.tuikov@amd.com Signed-off-by: Alex Deucher alexander.deucher@amd.com Signed-off-by: Mario Limonciello mario.limonciello@amd.com
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.
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.
linux-stable-mirror@lists.linaro.org