Skip to content

Commit 79ef1c9

Browse files
committed
Merge tag 'amd-drm-fixes-6.4-2023-05-18' of https://gitlab.freedesktop.org/agd5f/linux into drm-fixes
amd-drm-fixes-6.4-2023-05-18: amdgpu: - update gfx11 clock counter logic - Fix a race when disabling gfxoff on gfx10/11 for profiling - Raven/Raven2/PCO clock counter fix - Add missing get_vbios_fb_size for GMC 11 - Fix a spurious irq warning in the device remove case - Fix possible power mode mismatch between driver and PMFW - USB4 fix Signed-off-by: Dave Airlie <airlied@redhat.com> From: Alex Deucher <alexdeucher@gmail.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230518174811.3841-1-alexander.deucher@amd.com
2 parents 83ab69c + 6d60022 commit 79ef1c9

File tree

9 files changed

+80
-46
lines changed

9 files changed

+80
-46
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,8 @@ void amdgpu_fence_driver_hw_fini(struct amdgpu_device *adev)
582582
if (r)
583583
amdgpu_fence_driver_force_completion(ring);
584584

585-
if (ring->fence_drv.irq_src)
585+
if (!drm_dev_is_unplugged(adev_to_drm(adev)) &&
586+
ring->fence_drv.irq_src)
586587
amdgpu_irq_put(adev, ring->fence_drv.irq_src,
587588
ring->fence_drv.irq_type);
588589

drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8152,8 +8152,14 @@ static int gfx_v10_0_set_powergating_state(void *handle,
81528152
case IP_VERSION(10, 3, 3):
81538153
case IP_VERSION(10, 3, 6):
81548154
case IP_VERSION(10, 3, 7):
8155+
if (!enable)
8156+
amdgpu_gfx_off_ctrl(adev, false);
8157+
81558158
gfx_v10_cntl_pg(adev, enable);
8156-
amdgpu_gfx_off_ctrl(adev, enable);
8159+
8160+
if (enable)
8161+
amdgpu_gfx_off_ctrl(adev, true);
8162+
81578163
break;
81588164
default:
81598165
break;

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4667,24 +4667,27 @@ static uint64_t gfx_v11_0_get_gpu_clock_counter(struct amdgpu_device *adev)
46674667
uint64_t clock;
46684668
uint64_t clock_counter_lo, clock_counter_hi_pre, clock_counter_hi_after;
46694669

4670-
amdgpu_gfx_off_ctrl(adev, false);
4671-
mutex_lock(&adev->gfx.gpu_clock_mutex);
46724670
if (amdgpu_sriov_vf(adev)) {
4671+
amdgpu_gfx_off_ctrl(adev, false);
4672+
mutex_lock(&adev->gfx.gpu_clock_mutex);
46734673
clock_counter_hi_pre = (uint64_t)RREG32_SOC15(GC, 0, regCP_MES_MTIME_HI);
46744674
clock_counter_lo = (uint64_t)RREG32_SOC15(GC, 0, regCP_MES_MTIME_LO);
46754675
clock_counter_hi_after = (uint64_t)RREG32_SOC15(GC, 0, regCP_MES_MTIME_HI);
46764676
if (clock_counter_hi_pre != clock_counter_hi_after)
46774677
clock_counter_lo = (uint64_t)RREG32_SOC15(GC, 0, regCP_MES_MTIME_LO);
4678+
mutex_unlock(&adev->gfx.gpu_clock_mutex);
4679+
amdgpu_gfx_off_ctrl(adev, true);
46784680
} else {
4681+
preempt_disable();
46794682
clock_counter_hi_pre = (uint64_t)RREG32_SOC15(SMUIO, 0, regGOLDEN_TSC_COUNT_UPPER);
46804683
clock_counter_lo = (uint64_t)RREG32_SOC15(SMUIO, 0, regGOLDEN_TSC_COUNT_LOWER);
46814684
clock_counter_hi_after = (uint64_t)RREG32_SOC15(SMUIO, 0, regGOLDEN_TSC_COUNT_UPPER);
46824685
if (clock_counter_hi_pre != clock_counter_hi_after)
46834686
clock_counter_lo = (uint64_t)RREG32_SOC15(SMUIO, 0, regGOLDEN_TSC_COUNT_LOWER);
4687+
preempt_enable();
46844688
}
46854689
clock = clock_counter_lo | (clock_counter_hi_after << 32ULL);
4686-
mutex_unlock(&adev->gfx.gpu_clock_mutex);
4687-
amdgpu_gfx_off_ctrl(adev, true);
4690+
46884691
return clock;
46894692
}
46904693

@@ -5150,8 +5153,14 @@ static int gfx_v11_0_set_powergating_state(void *handle,
51505153
break;
51515154
case IP_VERSION(11, 0, 1):
51525155
case IP_VERSION(11, 0, 4):
5156+
if (!enable)
5157+
amdgpu_gfx_off_ctrl(adev, false);
5158+
51535159
gfx_v11_cntl_pg(adev, enable);
5154-
amdgpu_gfx_off_ctrl(adev, enable);
5160+
5161+
if (enable)
5162+
amdgpu_gfx_off_ctrl(adev, true);
5163+
51555164
break;
51565165
default:
51575166
break;

drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4003,30 +4003,25 @@ static uint64_t gfx_v9_0_get_gpu_clock_counter(struct amdgpu_device *adev)
40034003
clock = clock_lo | (clock_hi << 32ULL);
40044004
break;
40054005
case IP_VERSION(9, 1, 0):
4006+
case IP_VERSION(9, 2, 2):
40064007
preempt_disable();
4007-
clock_hi = RREG32_SOC15_NO_KIQ(PWR, 0, mmGOLDEN_TSC_COUNT_UPPER_Raven);
4008-
clock_lo = RREG32_SOC15_NO_KIQ(PWR, 0, mmGOLDEN_TSC_COUNT_LOWER_Raven);
4009-
hi_check = RREG32_SOC15_NO_KIQ(PWR, 0, mmGOLDEN_TSC_COUNT_UPPER_Raven);
4010-
/* The PWR TSC clock frequency is 100MHz, which sets 32-bit carry over
4011-
* roughly every 42 seconds.
4012-
*/
4013-
if (hi_check != clock_hi) {
4008+
if (adev->rev_id >= 0x8) {
4009+
clock_hi = RREG32_SOC15_NO_KIQ(PWR, 0, mmGOLDEN_TSC_COUNT_UPPER_Raven2);
4010+
clock_lo = RREG32_SOC15_NO_KIQ(PWR, 0, mmGOLDEN_TSC_COUNT_LOWER_Raven2);
4011+
hi_check = RREG32_SOC15_NO_KIQ(PWR, 0, mmGOLDEN_TSC_COUNT_UPPER_Raven2);
4012+
} else {
4013+
clock_hi = RREG32_SOC15_NO_KIQ(PWR, 0, mmGOLDEN_TSC_COUNT_UPPER_Raven);
40144014
clock_lo = RREG32_SOC15_NO_KIQ(PWR, 0, mmGOLDEN_TSC_COUNT_LOWER_Raven);
4015-
clock_hi = hi_check;
4015+
hi_check = RREG32_SOC15_NO_KIQ(PWR, 0, mmGOLDEN_TSC_COUNT_UPPER_Raven);
40164016
}
4017-
preempt_enable();
4018-
clock = clock_lo | (clock_hi << 32ULL);
4019-
break;
4020-
case IP_VERSION(9, 2, 2):
4021-
preempt_disable();
4022-
clock_hi = RREG32_SOC15_NO_KIQ(PWR, 0, mmGOLDEN_TSC_COUNT_UPPER_Raven2);
4023-
clock_lo = RREG32_SOC15_NO_KIQ(PWR, 0, mmGOLDEN_TSC_COUNT_LOWER_Raven2);
4024-
hi_check = RREG32_SOC15_NO_KIQ(PWR, 0, mmGOLDEN_TSC_COUNT_UPPER_Raven2);
40254017
/* The PWR TSC clock frequency is 100MHz, which sets 32-bit carry over
4026-
* roughly every 42 seconds.
4027-
*/
4018+
* roughly every 42 seconds.
4019+
*/
40284020
if (hi_check != clock_hi) {
4029-
clock_lo = RREG32_SOC15_NO_KIQ(PWR, 0, mmGOLDEN_TSC_COUNT_LOWER_Raven2);
4021+
if (adev->rev_id >= 0x8)
4022+
clock_lo = RREG32_SOC15_NO_KIQ(PWR, 0, mmGOLDEN_TSC_COUNT_LOWER_Raven2);
4023+
else
4024+
clock_lo = RREG32_SOC15_NO_KIQ(PWR, 0, mmGOLDEN_TSC_COUNT_LOWER_Raven);
40304025
clock_hi = hi_check;
40314026
}
40324027
preempt_enable();

drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include "umc_v8_10.h"
3232
#include "athub/athub_3_0_0_sh_mask.h"
3333
#include "athub/athub_3_0_0_offset.h"
34+
#include "dcn/dcn_3_2_0_offset.h"
35+
#include "dcn/dcn_3_2_0_sh_mask.h"
3436
#include "oss/osssys_6_0_0_offset.h"
3537
#include "ivsrcid/vmc/irqsrcs_vmc_1_0.h"
3638
#include "navi10_enum.h"
@@ -546,7 +548,24 @@ static void gmc_v11_0_get_vm_pte(struct amdgpu_device *adev,
546548

547549
static unsigned gmc_v11_0_get_vbios_fb_size(struct amdgpu_device *adev)
548550
{
549-
return 0;
551+
u32 d1vga_control = RREG32_SOC15(DCE, 0, regD1VGA_CONTROL);
552+
unsigned size;
553+
554+
if (REG_GET_FIELD(d1vga_control, D1VGA_CONTROL, D1VGA_MODE_ENABLE)) {
555+
size = AMDGPU_VBIOS_VGA_ALLOCATION;
556+
} else {
557+
u32 viewport;
558+
u32 pitch;
559+
560+
viewport = RREG32_SOC15(DCE, 0, regHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION);
561+
pitch = RREG32_SOC15(DCE, 0, regHUBPREQ0_DCSURF_SURFACE_PITCH);
562+
size = (REG_GET_FIELD(viewport,
563+
HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION, PRI_VIEWPORT_HEIGHT) *
564+
REG_GET_FIELD(pitch, HUBPREQ0_DCSURF_SURFACE_PITCH, PITCH) *
565+
4);
566+
}
567+
568+
return size;
550569
}
551570

552571
static const struct amdgpu_gmc_funcs gmc_v11_0_gmc_funcs = {

drivers/gpu/drm/amd/display/dc/link/link_validation.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,5 +359,8 @@ bool link_validate_dpia_bandwidth(const struct dc_stream_state *stream, const un
359359
link[i] = stream[i].link;
360360
bw_needed[i] = dc_bandwidth_in_kbps_from_timing(&stream[i].timing);
361361
}
362+
363+
ret = dpia_validate_usb4_bw(link, bw_needed, num_streams);
364+
362365
return ret;
363366
}

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,24 @@ static int smu_late_init(void *handle)
733733
return ret;
734734
}
735735

736+
/*
737+
* Explicitly notify PMFW the power mode the system in. Since
738+
* the PMFW may boot the ASIC with a different mode.
739+
* For those supporting ACDC switch via gpio, PMFW will
740+
* handle the switch automatically. Driver involvement
741+
* is unnecessary.
742+
*/
743+
if (!smu->dc_controlled_by_gpio) {
744+
ret = smu_set_power_source(smu,
745+
adev->pm.ac_power ? SMU_POWER_SOURCE_AC :
746+
SMU_POWER_SOURCE_DC);
747+
if (ret) {
748+
dev_err(adev->dev, "Failed to switch to %s mode!\n",
749+
adev->pm.ac_power ? "AC" : "DC");
750+
return ret;
751+
}
752+
}
753+
736754
if ((adev->ip_versions[MP1_HWIP][0] == IP_VERSION(13, 0, 1)) ||
737755
(adev->ip_versions[MP1_HWIP][0] == IP_VERSION(13, 0, 3)))
738756
return 0;

drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3413,26 +3413,8 @@ static int navi10_post_smu_init(struct smu_context *smu)
34133413
return 0;
34143414

34153415
ret = navi10_run_umc_cdr_workaround(smu);
3416-
if (ret) {
3416+
if (ret)
34173417
dev_err(adev->dev, "Failed to apply umc cdr workaround!\n");
3418-
return ret;
3419-
}
3420-
3421-
if (!smu->dc_controlled_by_gpio) {
3422-
/*
3423-
* For Navi1X, manually switch it to AC mode as PMFW
3424-
* may boot it with DC mode.
3425-
*/
3426-
ret = smu_v11_0_set_power_source(smu,
3427-
adev->pm.ac_power ?
3428-
SMU_POWER_SOURCE_AC :
3429-
SMU_POWER_SOURCE_DC);
3430-
if (ret) {
3431-
dev_err(adev->dev, "Failed to switch to %s mode!\n",
3432-
adev->pm.ac_power ? "AC" : "DC");
3433-
return ret;
3434-
}
3435-
}
34363418

34373419
return ret;
34383420
}

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,6 +1770,7 @@ static const struct pptable_funcs smu_v13_0_7_ppt_funcs = {
17701770
.enable_mgpu_fan_boost = smu_v13_0_7_enable_mgpu_fan_boost,
17711771
.get_power_limit = smu_v13_0_7_get_power_limit,
17721772
.set_power_limit = smu_v13_0_set_power_limit,
1773+
.set_power_source = smu_v13_0_set_power_source,
17731774
.get_power_profile_mode = smu_v13_0_7_get_power_profile_mode,
17741775
.set_power_profile_mode = smu_v13_0_7_set_power_profile_mode,
17751776
.set_tool_table_location = smu_v13_0_set_tool_table_location,

0 commit comments

Comments
 (0)