Skip to content

Commit 75cb377

Browse files
committed
Merge branch 'drm-fixes-5.2' of git://people.freedesktop.org/~agd5f/linux into drm-fixes
- A fix to make VCE resume more reliable - Updates for new raven variants Signed-off-by: Dave Airlie <airlied@redhat.com> From: Alex Deucher <alexdeucher@gmail.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190605182332.4073-1-alexander.deucher@amd.com
2 parents 351212f + 1929059 commit 75cb377

8 files changed

Lines changed: 63 additions & 14 deletions

File tree

‎drivers/gpu/drm/amd/amdgpu/amdgpu_device.c‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,6 +1589,7 @@ static int amdgpu_device_fw_loading(struct amdgpu_device *adev)
15891589
{
15901590
int r = 0;
15911591
int i;
1592+
uint32_t smu_version;
15921593

15931594
if (adev->asic_type >= CHIP_VEGA10) {
15941595
for (i = 0; i < adev->num_ip_blocks; i++) {
@@ -1614,16 +1615,9 @@ static int amdgpu_device_fw_loading(struct amdgpu_device *adev)
16141615
}
16151616
}
16161617
}
1618+
r = amdgpu_pm_load_smu_firmware(adev, &smu_version);
16171619

1618-
if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->load_firmware) {
1619-
r = adev->powerplay.pp_funcs->load_firmware(adev->powerplay.pp_handle);
1620-
if (r) {
1621-
pr_err("firmware loading failed\n");
1622-
return r;
1623-
}
1624-
}
1625-
1626-
return 0;
1620+
return r;
16271621
}
16281622

16291623
/**

‎drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,6 +2490,21 @@ void amdgpu_pm_print_power_states(struct amdgpu_device *adev)
24902490

24912491
}
24922492

2493+
int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev, uint32_t *smu_version)
2494+
{
2495+
int r = -EINVAL;
2496+
2497+
if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->load_firmware) {
2498+
r = adev->powerplay.pp_funcs->load_firmware(adev->powerplay.pp_handle);
2499+
if (r) {
2500+
pr_err("smu firmware loading failed\n");
2501+
return r;
2502+
}
2503+
*smu_version = adev->pm.fw_version;
2504+
}
2505+
return r;
2506+
}
2507+
24932508
int amdgpu_pm_sysfs_init(struct amdgpu_device *adev)
24942509
{
24952510
struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle;

‎drivers/gpu/drm/amd/amdgpu/amdgpu_pm.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ void amdgpu_pm_acpi_event_handler(struct amdgpu_device *adev);
3434
int amdgpu_pm_sysfs_init(struct amdgpu_device *adev);
3535
void amdgpu_pm_sysfs_fini(struct amdgpu_device *adev);
3636
void amdgpu_pm_print_power_states(struct amdgpu_device *adev);
37+
int amdgpu_pm_load_smu_firmware(struct amdgpu_device *adev, uint32_t *smu_version);
3738
void amdgpu_pm_compute_clocks(struct amdgpu_device *adev);
3839
void amdgpu_dpm_thermal_work_handler(struct work_struct *work);
3940
void amdgpu_dpm_enable_uvd(struct amdgpu_device *adev, bool enable);

‎drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ void amdgpu_vce_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 seq,
10721072
int amdgpu_vce_ring_test_ring(struct amdgpu_ring *ring)
10731073
{
10741074
struct amdgpu_device *adev = ring->adev;
1075-
uint32_t rptr = amdgpu_ring_get_rptr(ring);
1075+
uint32_t rptr;
10761076
unsigned i;
10771077
int r, timeout = adev->usec_timeout;
10781078

@@ -1084,6 +1084,8 @@ int amdgpu_vce_ring_test_ring(struct amdgpu_ring *ring)
10841084
if (r)
10851085
return r;
10861086

1087+
rptr = amdgpu_ring_get_rptr(ring);
1088+
10871089
amdgpu_ring_write(ring, VCE_CMD_END);
10881090
amdgpu_ring_commit(ring);
10891091

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "soc15.h"
2929
#include "soc15d.h"
3030
#include "amdgpu_atomfirmware.h"
31+
#include "amdgpu_pm.h"
3132

3233
#include "gc/gc_9_0_offset.h"
3334
#include "gc/gc_9_0_sh_mask.h"
@@ -96,6 +97,7 @@ MODULE_FIRMWARE("amdgpu/raven2_me.bin");
9697
MODULE_FIRMWARE("amdgpu/raven2_mec.bin");
9798
MODULE_FIRMWARE("amdgpu/raven2_mec2.bin");
9899
MODULE_FIRMWARE("amdgpu/raven2_rlc.bin");
100+
MODULE_FIRMWARE("amdgpu/raven_kicker_rlc.bin");
99101

100102
static const struct soc15_reg_golden golden_settings_gc_9_0[] =
101103
{
@@ -588,7 +590,8 @@ static void gfx_v9_0_check_if_need_gfxoff(struct amdgpu_device *adev)
588590
case CHIP_RAVEN:
589591
if (adev->rev_id >= 0x8 || adev->pdev->device == 0x15d8)
590592
break;
591-
if ((adev->gfx.rlc_fw_version < 531) ||
593+
if ((adev->gfx.rlc_fw_version != 106 &&
594+
adev->gfx.rlc_fw_version < 531) ||
592595
(adev->gfx.rlc_fw_version == 53815) ||
593596
(adev->gfx.rlc_feature_version < 1) ||
594597
!adev->gfx.rlc.is_rlc_v2_1)
@@ -612,6 +615,7 @@ static int gfx_v9_0_init_microcode(struct amdgpu_device *adev)
612615
unsigned int i = 0;
613616
uint16_t version_major;
614617
uint16_t version_minor;
618+
uint32_t smu_version;
615619

616620
DRM_DEBUG("\n");
617621

@@ -682,6 +686,12 @@ static int gfx_v9_0_init_microcode(struct amdgpu_device *adev)
682686
(((adev->pdev->revision >= 0xC8) && (adev->pdev->revision <= 0xCF)) ||
683687
((adev->pdev->revision >= 0xD8) && (adev->pdev->revision <= 0xDF))))
684688
snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_rlc_am4.bin", chip_name);
689+
else if (!strcmp(chip_name, "raven") && (amdgpu_pm_load_smu_firmware(adev, &smu_version) == 0) &&
690+
(smu_version >= 0x41e2b))
691+
/**
692+
*SMC is loaded by SBIOS on APU and it's able to get the SMU version directly.
693+
*/
694+
snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_kicker_rlc.bin", chip_name);
685695
else
686696
snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_rlc.bin", chip_name);
687697
err = request_firmware(&adev->gfx.rlc_fw, fw_name, adev->dev);

‎drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ int hwmgr_early_init(struct pp_hwmgr *hwmgr)
9292
hwmgr_set_user_specify_caps(hwmgr);
9393
hwmgr->fan_ctrl_is_in_default_mode = true;
9494
hwmgr_init_workload_prority(hwmgr);
95+
hwmgr->gfxoff_state_changed_by_workload = false;
9596

9697
switch (hwmgr->chip_family) {
9798
case AMDGPU_FAMILY_CI:

‎drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c‎

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,21 +1258,46 @@ static int smu10_get_power_profile_mode(struct pp_hwmgr *hwmgr, char *buf)
12581258
return size;
12591259
}
12601260

1261+
static bool smu10_is_raven1_refresh(struct pp_hwmgr *hwmgr)
1262+
{
1263+
struct amdgpu_device *adev = hwmgr->adev;
1264+
if ((adev->asic_type == CHIP_RAVEN) &&
1265+
(adev->rev_id != 0x15d8) &&
1266+
(hwmgr->smu_version >= 0x41e2b))
1267+
return true;
1268+
else
1269+
return false;
1270+
}
1271+
12611272
static int smu10_set_power_profile_mode(struct pp_hwmgr *hwmgr, long *input, uint32_t size)
12621273
{
12631274
int workload_type = 0;
1275+
int result = 0;
12641276

12651277
if (input[size] > PP_SMC_POWER_PROFILE_COMPUTE) {
12661278
pr_err("Invalid power profile mode %ld\n", input[size]);
12671279
return -EINVAL;
12681280
}
1269-
hwmgr->power_profile_mode = input[size];
1281+
if (hwmgr->power_profile_mode == input[size])
1282+
return 0;
12701283

12711284
/* conv PP_SMC_POWER_PROFILE* to WORKLOAD_PPLIB_*_BIT */
12721285
workload_type =
1273-
conv_power_profile_to_pplib_workload(hwmgr->power_profile_mode);
1274-
smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_ActiveProcessNotify,
1286+
conv_power_profile_to_pplib_workload(input[size]);
1287+
if (workload_type &&
1288+
smu10_is_raven1_refresh(hwmgr) &&
1289+
!hwmgr->gfxoff_state_changed_by_workload) {
1290+
smu10_gfx_off_control(hwmgr, false);
1291+
hwmgr->gfxoff_state_changed_by_workload = true;
1292+
}
1293+
result = smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_ActiveProcessNotify,
12751294
1 << workload_type);
1295+
if (!result)
1296+
hwmgr->power_profile_mode = input[size];
1297+
if (workload_type && hwmgr->gfxoff_state_changed_by_workload) {
1298+
smu10_gfx_off_control(hwmgr, true);
1299+
hwmgr->gfxoff_state_changed_by_workload = false;
1300+
}
12761301

12771302
return 0;
12781303
}

‎drivers/gpu/drm/amd/powerplay/inc/hwmgr.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,7 @@ struct pp_hwmgr {
782782
uint32_t workload_mask;
783783
uint32_t workload_prority[Workload_Policy_Max];
784784
uint32_t workload_setting[Workload_Policy_Max];
785+
bool gfxoff_state_changed_by_workload;
785786
};
786787

787788
int hwmgr_early_init(struct pp_hwmgr *hwmgr);

0 commit comments

Comments
 (0)