Skip to content

Commit 54f78a7

Browse files
committed
drm/amdgpu: add apu flags (v2)
Add some APU flags to simplify handling of different APU variants. It's easier to understand the special cases if we use names flags rather than checking device ids and silicon revisions. v2: rebase on latest code Acked-by: Evan Quan <[email protected]> Acked-by: Christian König <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent cbd2d08 commit 54f78a7

File tree

15 files changed

+48
-31
lines changed

15 files changed

+48
-31
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,7 @@ struct amdgpu_device {
739739
uint32_t rev_id;
740740
uint32_t external_rev_id;
741741
unsigned long flags;
742+
unsigned long apu_flags;
742743
int usec_timeout;
743744
const struct amdgpu_asic_funcs *asic_funcs;
744745
bool shutdown;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,9 +1567,9 @@ static int amdgpu_device_parse_gpu_info_fw(struct amdgpu_device *adev)
15671567
chip_name = "vega12";
15681568
break;
15691569
case CHIP_RAVEN:
1570-
if (adev->rev_id >= 8)
1570+
if (adev->apu_flags & AMD_APU_IS_RAVEN2)
15711571
chip_name = "raven2";
1572-
else if (adev->pdev->device == 0x15d8)
1572+
else if (adev->apu_flags & AMD_APU_IS_PICASSO)
15731573
chip_name = "picasso";
15741574
else
15751575
chip_name = "raven";

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,8 @@ uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev,
523523
break;
524524
case CHIP_RAVEN:
525525
/* enable S/G on PCO and RV2 */
526-
if (adev->rev_id >= 0x8 || adev->pdev->device == 0x15d8)
526+
if ((adev->apu_flags & AMD_APU_IS_RAVEN2) ||
527+
(adev->apu_flags & AMD_APU_IS_PICASSO))
527528
domain |= AMDGPU_GEM_DOMAIN_GTT;
528529
break;
529530
default:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ static ssize_t amdgpu_set_power_dpm_force_performance_level(struct device *dev,
372372
}
373373

374374
if (adev->asic_type == CHIP_RAVEN) {
375-
if (adev->rev_id < 8) {
375+
if (!(adev->apu_flags & AMD_APU_IS_RAVEN2)) {
376376
if (current_level != AMD_DPM_FORCED_LEVEL_MANUAL && level == AMD_DPM_FORCED_LEVEL_MANUAL)
377377
amdgpu_gfx_off_ctrl(adev, false);
378378
else if (current_level == AMD_DPM_FORCED_LEVEL_MANUAL && level != AMD_DPM_FORCED_LEVEL_MANUAL)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ int amdgpu_vcn_sw_init(struct amdgpu_device *adev)
7070

7171
switch (adev->asic_type) {
7272
case CHIP_RAVEN:
73-
if (adev->rev_id >= 8)
73+
if (adev->apu_flags & AMD_APU_IS_RAVEN2)
7474
fw_name = FIRMWARE_RAVEN2;
75-
else if (adev->pdev->device == 0x15d8)
75+
else if (adev->apu_flags & AMD_APU_IS_PICASSO)
7676
fw_name = FIRMWARE_PICASSO;
7777
else
7878
fw_name = FIRMWARE_RAVEN;

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ static void gfx_v9_0_init_golden_registers(struct amdgpu_device *adev)
959959
case CHIP_RAVEN:
960960
soc15_program_register_sequence(adev, golden_settings_gc_9_1,
961961
ARRAY_SIZE(golden_settings_gc_9_1));
962-
if (adev->rev_id >= 8)
962+
if (adev->apu_flags & AMD_APU_IS_RAVEN2)
963963
soc15_program_register_sequence(adev,
964964
golden_settings_gc_9_1_rv2,
965965
ARRAY_SIZE(golden_settings_gc_9_1_rv2));
@@ -1274,7 +1274,8 @@ static void gfx_v9_0_check_if_need_gfxoff(struct amdgpu_device *adev)
12741274
case CHIP_VEGA20:
12751275
break;
12761276
case CHIP_RAVEN:
1277-
if (!(adev->rev_id >= 0x8 || adev->pdev->device == 0x15d8) &&
1277+
if (!((adev->apu_flags & AMD_APU_IS_RAVEN2) ||
1278+
(adev->apu_flags & AMD_APU_IS_PICASSO)) &&
12781279
((!is_raven_kicker(adev) &&
12791280
adev->gfx.rlc_fw_version < 531) ||
12801281
(adev->gfx.rlc_feature_version < 1) ||
@@ -1617,9 +1618,9 @@ static int gfx_v9_0_init_microcode(struct amdgpu_device *adev)
16171618
chip_name = "vega20";
16181619
break;
16191620
case CHIP_RAVEN:
1620-
if (adev->rev_id >= 8)
1621+
if (adev->apu_flags & AMD_APU_IS_RAVEN2)
16211622
chip_name = "raven2";
1622-
else if (adev->pdev->device == 0x15d8)
1623+
else if (adev->apu_flags & AMD_APU_IS_PICASSO)
16231624
chip_name = "picasso";
16241625
else
16251626
chip_name = "raven";
@@ -2119,7 +2120,7 @@ static int gfx_v9_0_gpu_early_init(struct amdgpu_device *adev)
21192120
adev->gfx.config.sc_prim_fifo_size_backend = 0x100;
21202121
adev->gfx.config.sc_hiz_tile_fifo_size = 0x30;
21212122
adev->gfx.config.sc_earlyz_tile_fifo_size = 0x4C0;
2122-
if (adev->rev_id >= 8)
2123+
if (adev->apu_flags & AMD_APU_IS_RAVEN2)
21232124
gb_addr_config = RAVEN2_GB_ADDR_CONFIG_GOLDEN;
21242125
else
21252126
gb_addr_config = RAVEN_GB_ADDR_CONFIG_GOLDEN;
@@ -2968,8 +2969,7 @@ static void gfx_v9_0_init_pg(struct amdgpu_device *adev)
29682969
*/
29692970
if (adev->gfx.rlc.is_rlc_v2_1) {
29702971
if (adev->asic_type == CHIP_VEGA12 ||
2971-
(adev->asic_type == CHIP_RAVEN &&
2972-
adev->rev_id >= 8))
2972+
(adev->apu_flags & AMD_APU_IS_RAVEN2))
29732973
gfx_v9_1_init_rlc_save_restore_list(adev);
29742974
gfx_v9_0_enable_save_restore_machine(adev);
29752975
}
@@ -6881,7 +6881,7 @@ static void gfx_v9_0_set_gds_init(struct amdgpu_device *adev)
68816881
adev->gds.gds_compute_max_wave_id = 0x27f;
68826882
break;
68836883
case CHIP_RAVEN:
6884-
if (adev->rev_id >= 0x8)
6884+
if (adev->apu_flags & AMD_APU_IS_RAVEN2)
68856885
adev->gds.gds_compute_max_wave_id = 0x77; /* raven2 */
68866886
else
68876887
adev->gds.gds_compute_max_wave_id = 0x15f; /* raven1 */

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static void gfxhub_v1_0_init_system_aperture_regs(struct amdgpu_device *adev)
8080
WREG32_SOC15_RLC(GC, 0, mmMC_VM_SYSTEM_APERTURE_LOW_ADDR,
8181
min(adev->gmc.fb_start, adev->gmc.agp_start) >> 18);
8282

83-
if (adev->asic_type == CHIP_RAVEN && adev->rev_id >= 0x8)
83+
if (adev->apu_flags & AMD_APU_IS_RAVEN2)
8484
/*
8585
* Raven2 has a HW issue that it is unable to use the
8686
* vram which is out of MC_VM_SYSTEM_APERTURE_HIGH_ADDR.

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,8 @@ static bool gmc_v9_0_use_invalidate_semaphore(struct amdgpu_device *adev,
441441
return ((vmhub == AMDGPU_MMHUB_0 ||
442442
vmhub == AMDGPU_MMHUB_1) &&
443443
(!amdgpu_sriov_vf(adev)) &&
444-
(!(adev->asic_type == CHIP_RAVEN &&
445-
adev->rev_id < 0x8 &&
446-
adev->pdev->device == 0x15d8)));
444+
(!(!(adev->apu_flags & AMD_APU_IS_RAVEN2) &&
445+
(adev->apu_flags & AMD_APU_IS_PICASSO))));
447446
}
448447

449448
static bool gmc_v9_0_get_atc_vmid_pasid_mapping_info(struct amdgpu_device *adev,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static void mmhub_v1_0_init_system_aperture_regs(struct amdgpu_device *adev)
9696
WREG32_SOC15(MMHUB, 0, mmMC_VM_SYSTEM_APERTURE_LOW_ADDR,
9797
min(adev->gmc.fb_start, adev->gmc.agp_start) >> 18);
9898

99-
if (adev->asic_type == CHIP_RAVEN && adev->rev_id >= 0x8)
99+
if (adev->apu_flags & AMD_APU_IS_RAVEN2)
100100
/*
101101
* Raven2 has a HW issue that it is unable to use the vram which
102102
* is out of MC_VM_SYSTEM_APERTURE_HIGH_ADDR. So here is the

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ static int psp_v10_0_init_microcode(struct psp_context *psp)
5555

5656
switch (adev->asic_type) {
5757
case CHIP_RAVEN:
58-
if (adev->rev_id >= 0x8)
58+
if (adev->apu_flags & AMD_APU_IS_RAVEN2)
5959
chip_name = "raven2";
60-
else if (adev->pdev->device == 0x15d8)
60+
else if (adev->apu_flags & AMD_APU_IS_PICASSO)
6161
chip_name = "picasso";
6262
else
6363
chip_name = "raven";

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ static void sdma_v4_0_init_golden_registers(struct amdgpu_device *adev)
486486
soc15_program_register_sequence(adev,
487487
golden_settings_sdma_4_1,
488488
ARRAY_SIZE(golden_settings_sdma_4_1));
489-
if (adev->rev_id >= 8)
489+
if (adev->apu_flags & AMD_APU_IS_RAVEN2)
490490
soc15_program_register_sequence(adev,
491491
golden_settings_sdma_rv2,
492492
ARRAY_SIZE(golden_settings_sdma_rv2));
@@ -575,9 +575,9 @@ static int sdma_v4_0_init_microcode(struct amdgpu_device *adev)
575575
chip_name = "vega20";
576576
break;
577577
case CHIP_RAVEN:
578-
if (adev->rev_id >= 8)
578+
if (adev->apu_flags & AMD_APU_IS_RAVEN2)
579579
chip_name = "raven2";
580-
else if (adev->pdev->device == 0x15d8)
580+
else if (adev->apu_flags & AMD_APU_IS_PICASSO)
581581
chip_name = "picasso";
582582
else
583583
chip_name = "raven";

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,8 @@ soc15_asic_reset_method(struct amdgpu_device *adev)
564564
static int soc15_asic_reset(struct amdgpu_device *adev)
565565
{
566566
/* original raven doesn't have full asic reset */
567-
if (adev->pdev->device == 0x15dd && adev->rev_id < 0x8)
567+
if ((adev->apu_flags & AMD_APU_IS_RAVEN) &&
568+
!(adev->apu_flags & AMD_APU_IS_RAVEN2))
568569
return 0;
569570

570571
switch (soc15_asic_reset_method(adev)) {
@@ -1129,16 +1130,23 @@ static int soc15_common_early_init(void *handle)
11291130
break;
11301131
case CHIP_RAVEN:
11311132
adev->asic_funcs = &soc15_asic_funcs;
1133+
if (adev->pdev->device == 0x15dd)
1134+
adev->apu_flags |= AMD_APU_IS_RAVEN;
1135+
if (adev->pdev->device == 0x15d8)
1136+
adev->apu_flags |= AMD_APU_IS_PICASSO;
11321137
if (adev->rev_id >= 0x8)
1138+
adev->apu_flags |= AMD_APU_IS_RAVEN2;
1139+
1140+
if (adev->apu_flags & AMD_APU_IS_RAVEN2)
11331141
adev->external_rev_id = adev->rev_id + 0x79;
1134-
else if (adev->pdev->device == 0x15d8)
1142+
else if (adev->apu_flags & AMD_APU_IS_PICASSO)
11351143
adev->external_rev_id = adev->rev_id + 0x41;
11361144
else if (adev->rev_id == 1)
11371145
adev->external_rev_id = adev->rev_id + 0x20;
11381146
else
11391147
adev->external_rev_id = adev->rev_id + 0x01;
11401148

1141-
if (adev->rev_id >= 0x8) {
1149+
if (adev->apu_flags & AMD_APU_IS_RAVEN2) {
11421150
adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG |
11431151
AMD_CG_SUPPORT_GFX_MGLS |
11441152
AMD_CG_SUPPORT_GFX_CP_LS |
@@ -1156,7 +1164,7 @@ static int soc15_common_early_init(void *handle)
11561164
AMD_CG_SUPPORT_VCN_MGCG;
11571165

11581166
adev->pg_flags = AMD_PG_SUPPORT_SDMA | AMD_PG_SUPPORT_VCN;
1159-
} else if (adev->pdev->device == 0x15d8) {
1167+
} else if (adev->apu_flags & AMD_APU_IS_PICASSO) {
11601168
adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG |
11611169
AMD_CG_SUPPORT_GFX_MGLS |
11621170
AMD_CG_SUPPORT_GFX_CP_LS |
@@ -1222,6 +1230,7 @@ static int soc15_common_early_init(void *handle)
12221230
break;
12231231
case CHIP_RENOIR:
12241232
adev->asic_funcs = &soc15_asic_funcs;
1233+
adev->apu_flags |= AMD_APU_IS_RENOIR;
12251234
adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG |
12261235
AMD_CG_SUPPORT_GFX_MGLS |
12271236
AMD_CG_SUPPORT_GFX_3D_CGCG |

drivers/gpu/drm/amd/include/amd_shared.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ enum amd_chip_flags {
4040
AMD_EXP_HW_SUPPORT = 0x00080000UL,
4141
};
4242

43+
enum amd_apu_flags {
44+
AMD_APU_IS_RAVEN = 0x00000001UL,
45+
AMD_APU_IS_RAVEN2 = 0x00000002UL,
46+
AMD_APU_IS_PICASSO = 0x00000004UL,
47+
AMD_APU_IS_RENOIR = 0x00000008UL,
48+
};
49+
4350
enum amd_ip_block_type {
4451
AMD_IP_BLOCK_TYPE_COMMON,
4552
AMD_IP_BLOCK_TYPE_GMC,

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,8 +1302,7 @@ static int smu10_get_power_profile_mode(struct pp_hwmgr *hwmgr, char *buf)
13021302
static bool smu10_is_raven1_refresh(struct pp_hwmgr *hwmgr)
13031303
{
13041304
struct amdgpu_device *adev = hwmgr->adev;
1305-
if ((adev->asic_type == CHIP_RAVEN) &&
1306-
(adev->rev_id != 0x15d8) &&
1305+
if ((adev->apu_flags & AMD_APU_IS_RAVEN) &&
13071306
(hwmgr->smu_version >= 0x41e2b))
13081307
return true;
13091308
else

drivers/gpu/drm/amd/powerplay/smumgr/smu10_smumgr.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ static int smu10_start_smu(struct pp_hwmgr *hwmgr)
226226
smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetSmuVersion, &hwmgr->smu_version);
227227
adev->pm.fw_version = hwmgr->smu_version >> 8;
228228

229-
if (adev->rev_id < 0x8 && adev->pdev->device != 0x15d8 &&
229+
if (!(adev->apu_flags & AMD_APU_IS_RAVEN2) &&
230+
(adev->apu_flags & AMD_APU_IS_RAVEN) &&
230231
adev->pm.fw_version < 0x1e45)
231232
adev->pm.pp_feature &= ~PP_GFXOFF_MASK;
232233

0 commit comments

Comments
 (0)