Skip to content

Commit a7bae06

Browse files
Evan Quanalexdeucher
authored andcommitted
drm/amd/powerplay: move more APIs to smu_cmn.c
Considering they are shared by all ASICs. Signed-off-by: Evan Quan <[email protected]> Reviewed-by: Alex Deucher <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent af5ba6d commit a7bae06

File tree

10 files changed

+90
-83
lines changed

10 files changed

+90
-83
lines changed

drivers/gpu/drm/amd/powerplay/amdgpu_smu.c

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -91,43 +91,6 @@ int smu_sys_set_pp_feature_mask(struct smu_context *smu, uint64_t new_mask)
9191
return ret;
9292
}
9393

94-
int smu_get_smc_version(struct smu_context *smu, uint32_t *if_version, uint32_t *smu_version)
95-
{
96-
int ret = 0;
97-
98-
if (!if_version && !smu_version)
99-
return -EINVAL;
100-
101-
if (smu->smc_fw_if_version && smu->smc_fw_version)
102-
{
103-
if (if_version)
104-
*if_version = smu->smc_fw_if_version;
105-
106-
if (smu_version)
107-
*smu_version = smu->smc_fw_version;
108-
109-
return 0;
110-
}
111-
112-
if (if_version) {
113-
ret = smu_send_smc_msg(smu, SMU_MSG_GetDriverIfVersion, if_version);
114-
if (ret)
115-
return ret;
116-
117-
smu->smc_fw_if_version = *if_version;
118-
}
119-
120-
if (smu_version) {
121-
ret = smu_send_smc_msg(smu, SMU_MSG_GetSmuVersion, smu_version);
122-
if (ret)
123-
return ret;
124-
125-
smu->smc_fw_version = *smu_version;
126-
}
127-
128-
return ret;
129-
}
130-
13194
int smu_get_status_gfxoff(struct amdgpu_device *adev, uint32_t *value)
13295
{
13396
int ret = 0;
@@ -184,33 +147,6 @@ int smu_get_dpm_freq_range(struct smu_context *smu,
184147
return ret;
185148
}
186149

187-
bool smu_clk_dpm_is_enabled(struct smu_context *smu, enum smu_clk_type clk_type)
188-
{
189-
enum smu_feature_mask feature_id = 0;
190-
191-
switch (clk_type) {
192-
case SMU_MCLK:
193-
case SMU_UCLK:
194-
feature_id = SMU_FEATURE_DPM_UCLK_BIT;
195-
break;
196-
case SMU_GFXCLK:
197-
case SMU_SCLK:
198-
feature_id = SMU_FEATURE_DPM_GFXCLK_BIT;
199-
break;
200-
case SMU_SOCCLK:
201-
feature_id = SMU_FEATURE_DPM_SOCCLK_BIT;
202-
break;
203-
default:
204-
return true;
205-
}
206-
207-
if(!smu_feature_is_enabled(smu, feature_id)) {
208-
return false;
209-
}
210-
211-
return true;
212-
}
213-
214150
/**
215151
* smu_dpm_set_power_gate - power gate/ungate the specific IP block
216152
*

drivers/gpu/drm/amd/powerplay/arcturus_ppt.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ static int arcturus_force_clk_levels(struct smu_context *smu,
874874
uint32_t smu_version;
875875
int ret = 0;
876876

877-
ret = smu_get_smc_version(smu, NULL, &smu_version);
877+
ret = smu_cmn_get_smc_version(smu, NULL, &smu_version);
878878
if (ret) {
879879
dev_err(smu->adev->dev, "Failed to get smu version!\n");
880880
return ret;
@@ -1191,7 +1191,7 @@ static int arcturus_get_power_profile_mode(struct smu_context *smu,
11911191
if (!buf)
11921192
return -EINVAL;
11931193

1194-
result = smu_get_smc_version(smu, NULL, &smu_version);
1194+
result = smu_cmn_get_smc_version(smu, NULL, &smu_version);
11951195
if (result)
11961196
return result;
11971197

@@ -1278,7 +1278,7 @@ static int arcturus_set_power_profile_mode(struct smu_context *smu,
12781278
return -EINVAL;
12791279
}
12801280

1281-
ret = smu_get_smc_version(smu, NULL, &smu_version);
1281+
ret = smu_cmn_get_smc_version(smu, NULL, &smu_version);
12821282
if (ret)
12831283
return ret;
12841284

@@ -1362,7 +1362,7 @@ static int arcturus_set_performance_level(struct smu_context *smu,
13621362
uint32_t smu_version;
13631363
int ret;
13641364

1365-
ret = smu_get_smc_version(smu, NULL, &smu_version);
1365+
ret = smu_cmn_get_smc_version(smu, NULL, &smu_version);
13661366
if (ret) {
13671367
dev_err(smu->adev->dev, "Failed to get smu version!\n");
13681368
return ret;
@@ -2106,7 +2106,7 @@ static void arcturus_get_unique_id(struct smu_context *smu)
21062106
uint32_t top32 = 0, bottom32 = 0, smu_version;
21072107
uint64_t id;
21082108

2109-
if (smu_get_smc_version(smu, NULL, &smu_version)) {
2109+
if (smu_cmn_get_smc_version(smu, NULL, &smu_version)) {
21102110
dev_warn(adev->dev, "Failed to get smu version, cannot get unique_id or serial_number\n");
21112111
return;
21122112
}
@@ -2147,7 +2147,7 @@ static int arcturus_set_df_cstate(struct smu_context *smu,
21472147
uint32_t smu_version;
21482148
int ret;
21492149

2150-
ret = smu_get_smc_version(smu, NULL, &smu_version);
2150+
ret = smu_cmn_get_smc_version(smu, NULL, &smu_version);
21512151
if (ret) {
21522152
dev_err(smu->adev->dev, "Failed to get smu version!\n");
21532153
return ret;
@@ -2167,7 +2167,7 @@ static int arcturus_allow_xgmi_power_down(struct smu_context *smu, bool en)
21672167
uint32_t smu_version;
21682168
int ret;
21692169

2170-
ret = smu_get_smc_version(smu, NULL, &smu_version);
2170+
ret = smu_cmn_get_smc_version(smu, NULL, &smu_version);
21712171
if (ret) {
21722172
dev_err(smu->adev->dev, "Failed to get smu version!\n");
21732173
return ret;

drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,6 @@ extern int smu_handle_task(struct smu_context *smu,
760760
int smu_switch_power_profile(struct smu_context *smu,
761761
enum PP_SMC_POWER_PROFILE type,
762762
bool en);
763-
int smu_get_smc_version(struct smu_context *smu, uint32_t *if_version, uint32_t *smu_version);
764763
int smu_get_dpm_freq_range(struct smu_context *smu, enum smu_clk_type clk_type,
765764
uint32_t *min, uint32_t *max);
766765
int smu_set_soft_freq_range(struct smu_context *smu, enum smu_clk_type clk_type,
@@ -769,7 +768,6 @@ enum amd_dpm_forced_level smu_get_performance_level(struct smu_context *smu);
769768
int smu_force_performance_level(struct smu_context *smu, enum amd_dpm_forced_level level);
770769
int smu_set_display_count(struct smu_context *smu, uint32_t count);
771770
int smu_set_ac_dc(struct smu_context *smu);
772-
bool smu_clk_dpm_is_enabled(struct smu_context *smu, enum smu_clk_type clk_type);
773771
const char *smu_get_message_name(struct smu_context *smu, enum smu_message_type type);
774772
size_t smu_sys_get_pp_feature_mask(struct smu_context *smu, char *buf);
775773
int smu_sys_set_pp_feature_mask(struct smu_context *smu, uint64_t new_mask);

drivers/gpu/drm/amd/powerplay/navi10_ppt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2216,7 +2216,7 @@ static int navi10_disable_umc_cdr_12gbps_workaround(struct smu_context *smu)
22162216
if (!navi10_need_umc_cdr_12gbps_workaround(smu->adev))
22172217
return 0;
22182218

2219-
ret = smu_get_smc_version(smu, NULL, &smu_version);
2219+
ret = smu_cmn_get_smc_version(smu, NULL, &smu_version);
22202220
if (ret)
22212221
return ret;
22222222

drivers/gpu/drm/amd/powerplay/renoir_ppt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ static int renoir_get_dpm_ultimate_freq(struct smu_context *smu,
255255
uint32_t mclk_mask, soc_mask;
256256
uint32_t clock_limit;
257257

258-
if (!smu_clk_dpm_is_enabled(smu, clk_type)) {
258+
if (!smu_cmn_clk_dpm_is_enabled(smu, clk_type)) {
259259
switch (clk_type) {
260260
case SMU_MCLK:
261261
case SMU_UCLK:

drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1732,7 +1732,7 @@ static bool sienna_cichlid_is_mode1_reset_supported(struct smu_context *smu)
17321732
* SRIOV env will not support SMU mode1 reset
17331733
* PM FW support mode1 reset from 58.26
17341734
*/
1735-
smu_get_smc_version(smu, NULL, &smu_version);
1735+
smu_cmn_get_smc_version(smu, NULL, &smu_version);
17361736
if (amdgpu_sriov_vf(adev) || (smu_version < 0x003a1a00))
17371737
return false;
17381738

drivers/gpu/drm/amd/powerplay/smu_cmn.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,33 @@ int smu_cmn_feature_is_enabled(struct smu_context *smu,
164164
return ret;
165165
}
166166

167+
bool smu_cmn_clk_dpm_is_enabled(struct smu_context *smu,
168+
enum smu_clk_type clk_type)
169+
{
170+
enum smu_feature_mask feature_id = 0;
171+
172+
switch (clk_type) {
173+
case SMU_MCLK:
174+
case SMU_UCLK:
175+
feature_id = SMU_FEATURE_DPM_UCLK_BIT;
176+
break;
177+
case SMU_GFXCLK:
178+
case SMU_SCLK:
179+
feature_id = SMU_FEATURE_DPM_GFXCLK_BIT;
180+
break;
181+
case SMU_SOCCLK:
182+
feature_id = SMU_FEATURE_DPM_SOCCLK_BIT;
183+
break;
184+
default:
185+
return true;
186+
}
187+
188+
if (!smu_cmn_feature_is_enabled(smu, feature_id))
189+
return false;
190+
191+
return true;
192+
}
193+
167194
int smu_cmn_get_enabled_mask(struct smu_context *smu,
168195
uint32_t *feature_mask,
169196
uint32_t num)
@@ -374,3 +401,42 @@ int smu_cmn_disable_all_features_with_exception(struct smu_context *smu,
374401
features_to_disable,
375402
0);
376403
}
404+
405+
int smu_cmn_get_smc_version(struct smu_context *smu,
406+
uint32_t *if_version,
407+
uint32_t *smu_version)
408+
{
409+
int ret = 0;
410+
411+
if (!if_version && !smu_version)
412+
return -EINVAL;
413+
414+
if (smu->smc_fw_if_version && smu->smc_fw_version)
415+
{
416+
if (if_version)
417+
*if_version = smu->smc_fw_if_version;
418+
419+
if (smu_version)
420+
*smu_version = smu->smc_fw_version;
421+
422+
return 0;
423+
}
424+
425+
if (if_version) {
426+
ret = smu_send_smc_msg(smu, SMU_MSG_GetDriverIfVersion, if_version);
427+
if (ret)
428+
return ret;
429+
430+
smu->smc_fw_if_version = *if_version;
431+
}
432+
433+
if (smu_version) {
434+
ret = smu_send_smc_msg(smu, SMU_MSG_GetSmuVersion, smu_version);
435+
if (ret)
436+
return ret;
437+
438+
smu->smc_fw_version = *smu_version;
439+
}
440+
441+
return ret;
442+
}

drivers/gpu/drm/amd/powerplay/smu_cmn.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ int smu_cmn_feature_is_supported(struct smu_context *smu,
3535
int smu_cmn_feature_is_enabled(struct smu_context *smu,
3636
enum smu_feature_mask mask);
3737

38+
bool smu_cmn_clk_dpm_is_enabled(struct smu_context *smu,
39+
enum smu_clk_type clk_type);
40+
3841
int smu_cmn_get_enabled_mask(struct smu_context *smu,
3942
uint32_t *feature_mask,
4043
uint32_t num);
@@ -52,4 +55,8 @@ int smu_cmn_set_pp_feature_mask(struct smu_context *smu,
5255
int smu_cmn_disable_all_features_with_exception(struct smu_context *smu,
5356
enum smu_feature_mask mask);
5457

58+
int smu_cmn_get_smc_version(struct smu_context *smu,
59+
uint32_t *if_version,
60+
uint32_t *smu_version);
61+
5562
#endif

drivers/gpu/drm/amd/powerplay/smu_v11_0.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ int smu_v11_0_check_fw_version(struct smu_context *smu)
289289
uint8_t smu_minor, smu_debug;
290290
int ret = 0;
291291

292-
ret = smu_get_smc_version(smu, &if_version, &smu_version);
292+
ret = smu_cmn_get_smc_version(smu, &if_version, &smu_version);
293293
if (ret)
294294
return ret;
295295

@@ -1679,7 +1679,7 @@ int smu_v11_0_get_dpm_ultimate_freq(struct smu_context *smu, enum smu_clk_type c
16791679
uint32_t param = 0;
16801680
uint32_t clock_limit;
16811681

1682-
if (!smu_clk_dpm_is_enabled(smu, clk_type)) {
1682+
if (!smu_cmn_clk_dpm_is_enabled(smu, clk_type)) {
16831683
switch (clk_type) {
16841684
case SMU_MCLK:
16851685
case SMU_UCLK:
@@ -1740,7 +1740,7 @@ int smu_v11_0_set_soft_freq_limited_range(struct smu_context *smu,
17401740
int ret = 0, clk_id = 0;
17411741
uint32_t param;
17421742

1743-
if (!smu_clk_dpm_is_enabled(smu, clk_type))
1743+
if (!smu_cmn_clk_dpm_is_enabled(smu, clk_type))
17441744
return 0;
17451745

17461746
clk_id = smu_cmn_to_asic_specific_index(smu,
@@ -1786,7 +1786,7 @@ int smu_v11_0_set_hard_freq_limited_range(struct smu_context *smu,
17861786
if (min <= 0 && max <= 0)
17871787
return -EINVAL;
17881788

1789-
if (!smu_clk_dpm_is_enabled(smu, clk_type))
1789+
if (!smu_cmn_clk_dpm_is_enabled(smu, clk_type))
17901790
return 0;
17911791

17921792
clk_id = smu_cmn_to_asic_specific_index(smu,
@@ -1943,7 +1943,7 @@ int smu_v11_0_get_dpm_freq_by_index(struct smu_context *smu,
19431943
if (!value)
19441944
return -EINVAL;
19451945

1946-
if (!smu_clk_dpm_is_enabled(smu, clk_type))
1946+
if (!smu_cmn_clk_dpm_is_enabled(smu, clk_type))
19471947
return 0;
19481948

19491949
clk_id = smu_cmn_to_asic_specific_index(smu,

drivers/gpu/drm/amd/powerplay/smu_v12_0.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ int smu_v12_0_check_fw_version(struct smu_context *smu)
157157
uint8_t smu_minor, smu_debug;
158158
int ret = 0;
159159

160-
ret = smu_get_smc_version(smu, &if_version, &smu_version);
160+
ret = smu_cmn_get_smc_version(smu, &if_version, &smu_version);
161161
if (ret)
162162
return ret;
163163

@@ -305,7 +305,7 @@ int smu_v12_0_set_soft_freq_limited_range(struct smu_context *smu, enum smu_clk_
305305
{
306306
int ret = 0;
307307

308-
if (!smu_clk_dpm_is_enabled(smu, clk_type))
308+
if (!smu_cmn_clk_dpm_is_enabled(smu, clk_type))
309309
return 0;
310310

311311
switch (clk_type) {

0 commit comments

Comments
 (0)