2 * Copyright 2018 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
25 #include "vega20_inc.h"
26 #include "soc15_common.h"
27 #include "vega20_smumgr.h"
28 #include "vega20_ppsmc.h"
29 #include "smu11_driver_if.h"
30 #include "ppatomctrl.h"
32 #include "smu_ucode_xfer_vi.h"
33 #include "smu7_smumgr.h"
34 #include "vega20_hwmgr.h"
37 #define MP0_Public 0x03800000
38 #define MP0_SRAM 0x03900000
39 #define MP1_Public 0x03b00000
40 #define MP1_SRAM 0x03c00004
43 #define smnMP1_FIRMWARE_FLAGS 0x3010024
44 #define smnMP0_FW_INTF 0x30101c0
45 #define smnMP1_PUB_CTRL 0x3010b14
47 static bool vega20_is_smc_ram_running(struct pp_hwmgr *hwmgr)
49 struct amdgpu_device *adev = hwmgr->adev;
50 uint32_t mp1_fw_flags;
52 mp1_fw_flags = RREG32_PCIE(MP1_Public |
53 (smnMP1_FIRMWARE_FLAGS & 0xffffffff));
55 if ((mp1_fw_flags & MP1_FIRMWARE_FLAGS__INTERRUPTS_ENABLED_MASK) >>
56 MP1_FIRMWARE_FLAGS__INTERRUPTS_ENABLED__SHIFT)
63 * Check if SMC has responded to previous message.
65 * @param smumgr the address of the powerplay hardware manager.
66 * @return TRUE SMC has responded, FALSE otherwise.
68 static uint32_t vega20_wait_for_response(struct pp_hwmgr *hwmgr)
70 struct amdgpu_device *adev = hwmgr->adev;
73 reg = SOC15_REG_OFFSET(MP1, 0, mmMP1_SMN_C2PMSG_90);
75 phm_wait_for_register_unequal(hwmgr, reg,
76 0, MP1_C2PMSG_90__CONTENT_MASK);
78 return RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90);
82 * Send a message to the SMC, and do not wait for its response.
83 * @param smumgr the address of the powerplay hardware manager.
84 * @param msg the message to send.
85 * @return Always return 0.
87 static int vega20_send_msg_to_smc_without_waiting(struct pp_hwmgr *hwmgr,
90 struct amdgpu_device *adev = hwmgr->adev;
92 WREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_66, msg);
98 * Send a message to the SMC, and wait for its response.
99 * @param hwmgr the address of the powerplay hardware manager.
100 * @param msg the message to send.
101 * @return Always return 0.
103 static int vega20_send_msg_to_smc(struct pp_hwmgr *hwmgr, uint16_t msg)
105 struct amdgpu_device *adev = hwmgr->adev;
108 vega20_wait_for_response(hwmgr);
110 WREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90, 0);
112 vega20_send_msg_to_smc_without_waiting(hwmgr, msg);
114 ret = vega20_wait_for_response(hwmgr);
115 if (ret != PPSMC_Result_OK)
116 pr_err("Failed to send message 0x%x, response 0x%x\n", msg, ret);
118 return (ret == PPSMC_Result_OK) ? 0 : -EIO;
122 * Send a message to the SMC with parameter
123 * @param hwmgr: the address of the powerplay hardware manager.
124 * @param msg: the message to send.
125 * @param parameter: the parameter to send
126 * @return Always return 0.
128 static int vega20_send_msg_to_smc_with_parameter(struct pp_hwmgr *hwmgr,
129 uint16_t msg, uint32_t parameter)
131 struct amdgpu_device *adev = hwmgr->adev;
134 vega20_wait_for_response(hwmgr);
136 WREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90, 0);
138 WREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_82, parameter);
140 vega20_send_msg_to_smc_without_waiting(hwmgr, msg);
142 ret = vega20_wait_for_response(hwmgr);
143 if (ret != PPSMC_Result_OK)
144 pr_err("Failed to send message 0x%x, response 0x%x\n", msg, ret);
146 return (ret == PPSMC_Result_OK) ? 0 : -EIO;
149 static uint32_t vega20_get_argument(struct pp_hwmgr *hwmgr)
151 struct amdgpu_device *adev = hwmgr->adev;
153 return RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_82);
157 * Copy table from SMC into driver FB
158 * @param hwmgr the address of the HW manager
159 * @param table_id the driver's table ID to copy from
161 static int vega20_copy_table_from_smc(struct pp_hwmgr *hwmgr,
162 uint8_t *table, int16_t table_id)
164 struct vega20_smumgr *priv =
165 (struct vega20_smumgr *)(hwmgr->smu_backend);
166 struct amdgpu_device *adev = hwmgr->adev;
169 PP_ASSERT_WITH_CODE(table_id < TABLE_COUNT,
170 "Invalid SMU Table ID!", return -EINVAL);
171 PP_ASSERT_WITH_CODE(priv->smu_tables.entry[table_id].version != 0,
172 "Invalid SMU Table version!", return -EINVAL);
173 PP_ASSERT_WITH_CODE(priv->smu_tables.entry[table_id].size != 0,
174 "Invalid SMU Table Length!", return -EINVAL);
176 PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc_with_parameter(hwmgr,
177 PPSMC_MSG_SetDriverDramAddrHigh,
178 upper_32_bits(priv->smu_tables.entry[table_id].mc_addr))) == 0,
179 "[CopyTableFromSMC] Attempt to Set Dram Addr High Failed!",
181 PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc_with_parameter(hwmgr,
182 PPSMC_MSG_SetDriverDramAddrLow,
183 lower_32_bits(priv->smu_tables.entry[table_id].mc_addr))) == 0,
184 "[CopyTableFromSMC] Attempt to Set Dram Addr Low Failed!",
186 PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc_with_parameter(hwmgr,
187 PPSMC_MSG_TransferTableSmu2Dram, table_id)) == 0,
188 "[CopyTableFromSMC] Attempt to Transfer Table From SMU Failed!",
191 /* flush hdp cache */
192 adev->nbio_funcs->hdp_flush(adev, NULL);
194 memcpy(table, priv->smu_tables.entry[table_id].table,
195 priv->smu_tables.entry[table_id].size);
201 * Copy table from Driver FB into SMC
202 * @param hwmgr the address of the HW manager
203 * @param table_id the table to copy from
205 static int vega20_copy_table_to_smc(struct pp_hwmgr *hwmgr,
206 uint8_t *table, int16_t table_id)
208 struct vega20_smumgr *priv =
209 (struct vega20_smumgr *)(hwmgr->smu_backend);
212 PP_ASSERT_WITH_CODE(table_id < TABLE_COUNT,
213 "Invalid SMU Table ID!", return -EINVAL);
214 PP_ASSERT_WITH_CODE(priv->smu_tables.entry[table_id].version != 0,
215 "Invalid SMU Table version!", return -EINVAL);
216 PP_ASSERT_WITH_CODE(priv->smu_tables.entry[table_id].size != 0,
217 "Invalid SMU Table Length!", return -EINVAL);
219 memcpy(priv->smu_tables.entry[table_id].table, table,
220 priv->smu_tables.entry[table_id].size);
222 PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc_with_parameter(hwmgr,
223 PPSMC_MSG_SetDriverDramAddrHigh,
224 upper_32_bits(priv->smu_tables.entry[table_id].mc_addr))) == 0,
225 "[CopyTableToSMC] Attempt to Set Dram Addr High Failed!",
227 PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc_with_parameter(hwmgr,
228 PPSMC_MSG_SetDriverDramAddrLow,
229 lower_32_bits(priv->smu_tables.entry[table_id].mc_addr))) == 0,
230 "[CopyTableToSMC] Attempt to Set Dram Addr Low Failed!",
232 PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc_with_parameter(hwmgr,
233 PPSMC_MSG_TransferTableDram2Smu, table_id)) == 0,
234 "[CopyTableToSMC] Attempt to Transfer Table To SMU Failed!",
240 int vega20_set_activity_monitor_coeff(struct pp_hwmgr *hwmgr,
241 uint8_t *table, uint16_t workload_type)
243 struct vega20_smumgr *priv =
244 (struct vega20_smumgr *)(hwmgr->smu_backend);
247 memcpy(priv->smu_tables.entry[TABLE_ACTIVITY_MONITOR_COEFF].table, table,
248 priv->smu_tables.entry[TABLE_ACTIVITY_MONITOR_COEFF].size);
250 PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc_with_parameter(hwmgr,
251 PPSMC_MSG_SetDriverDramAddrHigh,
252 upper_32_bits(priv->smu_tables.entry[TABLE_ACTIVITY_MONITOR_COEFF].mc_addr))) == 0,
253 "[SetActivityMonitor] Attempt to Set Dram Addr High Failed!",
255 PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc_with_parameter(hwmgr,
256 PPSMC_MSG_SetDriverDramAddrLow,
257 lower_32_bits(priv->smu_tables.entry[TABLE_ACTIVITY_MONITOR_COEFF].mc_addr))) == 0,
258 "[SetActivityMonitor] Attempt to Set Dram Addr Low Failed!",
260 PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc_with_parameter(hwmgr,
261 PPSMC_MSG_TransferTableDram2Smu, TABLE_ACTIVITY_MONITOR_COEFF | (workload_type << 16))) == 0,
262 "[SetActivityMonitor] Attempt to Transfer Table To SMU Failed!",
268 int vega20_get_activity_monitor_coeff(struct pp_hwmgr *hwmgr,
269 uint8_t *table, uint16_t workload_type)
271 struct vega20_smumgr *priv =
272 (struct vega20_smumgr *)(hwmgr->smu_backend);
273 struct amdgpu_device *adev = hwmgr->adev;
276 PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc_with_parameter(hwmgr,
277 PPSMC_MSG_SetDriverDramAddrHigh,
278 upper_32_bits(priv->smu_tables.entry[TABLE_ACTIVITY_MONITOR_COEFF].mc_addr))) == 0,
279 "[GetActivityMonitor] Attempt to Set Dram Addr High Failed!",
281 PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc_with_parameter(hwmgr,
282 PPSMC_MSG_SetDriverDramAddrLow,
283 lower_32_bits(priv->smu_tables.entry[TABLE_ACTIVITY_MONITOR_COEFF].mc_addr))) == 0,
284 "[GetActivityMonitor] Attempt to Set Dram Addr Low Failed!",
286 PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc_with_parameter(hwmgr,
287 PPSMC_MSG_TransferTableSmu2Dram,
288 TABLE_ACTIVITY_MONITOR_COEFF | (workload_type << 16))) == 0,
289 "[GetActivityMonitor] Attempt to Transfer Table From SMU Failed!",
292 /* flush hdp cache */
293 adev->nbio_funcs->hdp_flush(adev, NULL);
295 memcpy(table, priv->smu_tables.entry[TABLE_ACTIVITY_MONITOR_COEFF].table,
296 priv->smu_tables.entry[TABLE_ACTIVITY_MONITOR_COEFF].size);
301 int vega20_enable_smc_features(struct pp_hwmgr *hwmgr,
302 bool enable, uint64_t feature_mask)
304 uint32_t smu_features_low, smu_features_high;
307 smu_features_low = (uint32_t)((feature_mask & SMU_FEATURES_LOW_MASK) >> SMU_FEATURES_LOW_SHIFT);
308 smu_features_high = (uint32_t)((feature_mask & SMU_FEATURES_HIGH_MASK) >> SMU_FEATURES_HIGH_SHIFT);
311 PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc_with_parameter(hwmgr,
312 PPSMC_MSG_EnableSmuFeaturesLow, smu_features_low)) == 0,
313 "[EnableDisableSMCFeatures] Attemp to enable SMU features Low failed!",
315 PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc_with_parameter(hwmgr,
316 PPSMC_MSG_EnableSmuFeaturesHigh, smu_features_high)) == 0,
317 "[EnableDisableSMCFeatures] Attemp to enable SMU features High failed!",
320 PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc_with_parameter(hwmgr,
321 PPSMC_MSG_DisableSmuFeaturesLow, smu_features_low)) == 0,
322 "[EnableDisableSMCFeatures] Attemp to disable SMU features Low failed!",
324 PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc_with_parameter(hwmgr,
325 PPSMC_MSG_DisableSmuFeaturesHigh, smu_features_high)) == 0,
326 "[EnableDisableSMCFeatures] Attemp to disable SMU features High failed!",
333 int vega20_get_enabled_smc_features(struct pp_hwmgr *hwmgr,
334 uint64_t *features_enabled)
336 uint32_t smc_features_low, smc_features_high;
339 if (features_enabled == NULL)
342 PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc(hwmgr,
343 PPSMC_MSG_GetEnabledSmuFeaturesLow)) == 0,
344 "[GetEnabledSMCFeatures] Attemp to get SMU features Low failed!",
346 smc_features_low = vega20_get_argument(hwmgr);
347 PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc(hwmgr,
348 PPSMC_MSG_GetEnabledSmuFeaturesHigh)) == 0,
349 "[GetEnabledSMCFeatures] Attemp to get SMU features High failed!",
351 smc_features_high = vega20_get_argument(hwmgr);
353 *features_enabled = ((((uint64_t)smc_features_low << SMU_FEATURES_LOW_SHIFT) & SMU_FEATURES_LOW_MASK) |
354 (((uint64_t)smc_features_high << SMU_FEATURES_HIGH_SHIFT) & SMU_FEATURES_HIGH_MASK));
359 static int vega20_set_tools_address(struct pp_hwmgr *hwmgr)
361 struct vega20_smumgr *priv =
362 (struct vega20_smumgr *)(hwmgr->smu_backend);
365 if (priv->smu_tables.entry[TABLE_PMSTATUSLOG].mc_addr) {
366 ret = vega20_send_msg_to_smc_with_parameter(hwmgr,
367 PPSMC_MSG_SetToolsDramAddrHigh,
368 upper_32_bits(priv->smu_tables.entry[TABLE_PMSTATUSLOG].mc_addr));
370 ret = vega20_send_msg_to_smc_with_parameter(hwmgr,
371 PPSMC_MSG_SetToolsDramAddrLow,
372 lower_32_bits(priv->smu_tables.entry[TABLE_PMSTATUSLOG].mc_addr));
378 int vega20_set_pptable_driver_address(struct pp_hwmgr *hwmgr)
380 struct vega20_smumgr *priv =
381 (struct vega20_smumgr *)(hwmgr->smu_backend);
384 PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc_with_parameter(hwmgr,
385 PPSMC_MSG_SetDriverDramAddrHigh,
386 upper_32_bits(priv->smu_tables.entry[TABLE_PPTABLE].mc_addr))) == 0,
387 "[SetPPtabeDriverAddress] Attempt to Set Dram Addr High Failed!",
389 PP_ASSERT_WITH_CODE((ret = vega20_send_msg_to_smc_with_parameter(hwmgr,
390 PPSMC_MSG_SetDriverDramAddrLow,
391 lower_32_bits(priv->smu_tables.entry[TABLE_PPTABLE].mc_addr))) == 0,
392 "[SetPPtabeDriverAddress] Attempt to Set Dram Addr Low Failed!",
398 static int vega20_smu_init(struct pp_hwmgr *hwmgr)
400 struct vega20_smumgr *priv;
401 unsigned long tools_size = 0x19000;
404 struct cgs_firmware_info info = {0};
406 ret = cgs_get_firmware_info(hwmgr->device,
407 smu7_convert_fw_type_to_cgs(UCODE_ID_SMU),
409 if (ret || !info.kptr)
412 priv = kzalloc(sizeof(struct vega20_smumgr), GFP_KERNEL);
416 hwmgr->smu_backend = priv;
418 /* allocate space for pptable */
419 ret = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev,
422 AMDGPU_GEM_DOMAIN_VRAM,
423 &priv->smu_tables.entry[TABLE_PPTABLE].handle,
424 &priv->smu_tables.entry[TABLE_PPTABLE].mc_addr,
425 &priv->smu_tables.entry[TABLE_PPTABLE].table);
429 priv->smu_tables.entry[TABLE_PPTABLE].version = 0x01;
430 priv->smu_tables.entry[TABLE_PPTABLE].size = sizeof(PPTable_t);
432 /* allocate space for watermarks table */
433 ret = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev,
434 sizeof(Watermarks_t),
436 AMDGPU_GEM_DOMAIN_VRAM,
437 &priv->smu_tables.entry[TABLE_WATERMARKS].handle,
438 &priv->smu_tables.entry[TABLE_WATERMARKS].mc_addr,
439 &priv->smu_tables.entry[TABLE_WATERMARKS].table);
443 priv->smu_tables.entry[TABLE_WATERMARKS].version = 0x01;
444 priv->smu_tables.entry[TABLE_WATERMARKS].size = sizeof(Watermarks_t);
446 /* allocate space for pmstatuslog table */
447 ret = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev,
450 AMDGPU_GEM_DOMAIN_VRAM,
451 &priv->smu_tables.entry[TABLE_PMSTATUSLOG].handle,
452 &priv->smu_tables.entry[TABLE_PMSTATUSLOG].mc_addr,
453 &priv->smu_tables.entry[TABLE_PMSTATUSLOG].table);
457 priv->smu_tables.entry[TABLE_PMSTATUSLOG].version = 0x01;
458 priv->smu_tables.entry[TABLE_PMSTATUSLOG].size = tools_size;
460 /* allocate space for OverDrive table */
461 ret = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev,
462 sizeof(OverDriveTable_t),
464 AMDGPU_GEM_DOMAIN_VRAM,
465 &priv->smu_tables.entry[TABLE_OVERDRIVE].handle,
466 &priv->smu_tables.entry[TABLE_OVERDRIVE].mc_addr,
467 &priv->smu_tables.entry[TABLE_OVERDRIVE].table);
471 priv->smu_tables.entry[TABLE_OVERDRIVE].version = 0x01;
472 priv->smu_tables.entry[TABLE_OVERDRIVE].size = sizeof(OverDriveTable_t);
474 /* allocate space for SmuMetrics table */
475 ret = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev,
476 sizeof(SmuMetrics_t),
478 AMDGPU_GEM_DOMAIN_VRAM,
479 &priv->smu_tables.entry[TABLE_SMU_METRICS].handle,
480 &priv->smu_tables.entry[TABLE_SMU_METRICS].mc_addr,
481 &priv->smu_tables.entry[TABLE_SMU_METRICS].table);
485 priv->smu_tables.entry[TABLE_SMU_METRICS].version = 0x01;
486 priv->smu_tables.entry[TABLE_SMU_METRICS].size = sizeof(SmuMetrics_t);
488 /* allocate space for ActivityMonitor table */
489 ret = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev,
490 sizeof(DpmActivityMonitorCoeffInt_t),
492 AMDGPU_GEM_DOMAIN_VRAM,
493 &priv->smu_tables.entry[TABLE_ACTIVITY_MONITOR_COEFF].handle,
494 &priv->smu_tables.entry[TABLE_ACTIVITY_MONITOR_COEFF].mc_addr,
495 &priv->smu_tables.entry[TABLE_ACTIVITY_MONITOR_COEFF].table);
499 priv->smu_tables.entry[TABLE_ACTIVITY_MONITOR_COEFF].version = 0x01;
500 priv->smu_tables.entry[TABLE_ACTIVITY_MONITOR_COEFF].size = sizeof(DpmActivityMonitorCoeffInt_t);
505 amdgpu_bo_free_kernel(&priv->smu_tables.entry[TABLE_SMU_METRICS].handle,
506 &priv->smu_tables.entry[TABLE_SMU_METRICS].mc_addr,
507 &priv->smu_tables.entry[TABLE_SMU_METRICS].table);
509 amdgpu_bo_free_kernel(&priv->smu_tables.entry[TABLE_OVERDRIVE].handle,
510 &priv->smu_tables.entry[TABLE_OVERDRIVE].mc_addr,
511 &priv->smu_tables.entry[TABLE_OVERDRIVE].table);
513 amdgpu_bo_free_kernel(&priv->smu_tables.entry[TABLE_PMSTATUSLOG].handle,
514 &priv->smu_tables.entry[TABLE_PMSTATUSLOG].mc_addr,
515 &priv->smu_tables.entry[TABLE_PMSTATUSLOG].table);
517 amdgpu_bo_free_kernel(&priv->smu_tables.entry[TABLE_WATERMARKS].handle,
518 &priv->smu_tables.entry[TABLE_WATERMARKS].mc_addr,
519 &priv->smu_tables.entry[TABLE_WATERMARKS].table);
521 amdgpu_bo_free_kernel(&priv->smu_tables.entry[TABLE_PPTABLE].handle,
522 &priv->smu_tables.entry[TABLE_PPTABLE].mc_addr,
523 &priv->smu_tables.entry[TABLE_PPTABLE].table);
525 kfree(hwmgr->smu_backend);
530 static int vega20_smu_fini(struct pp_hwmgr *hwmgr)
532 struct vega20_smumgr *priv =
533 (struct vega20_smumgr *)(hwmgr->smu_backend);
536 amdgpu_bo_free_kernel(&priv->smu_tables.entry[TABLE_PPTABLE].handle,
537 &priv->smu_tables.entry[TABLE_PPTABLE].mc_addr,
538 &priv->smu_tables.entry[TABLE_PPTABLE].table);
539 amdgpu_bo_free_kernel(&priv->smu_tables.entry[TABLE_WATERMARKS].handle,
540 &priv->smu_tables.entry[TABLE_WATERMARKS].mc_addr,
541 &priv->smu_tables.entry[TABLE_WATERMARKS].table);
542 amdgpu_bo_free_kernel(&priv->smu_tables.entry[TABLE_PMSTATUSLOG].handle,
543 &priv->smu_tables.entry[TABLE_PMSTATUSLOG].mc_addr,
544 &priv->smu_tables.entry[TABLE_PMSTATUSLOG].table);
545 amdgpu_bo_free_kernel(&priv->smu_tables.entry[TABLE_OVERDRIVE].handle,
546 &priv->smu_tables.entry[TABLE_OVERDRIVE].mc_addr,
547 &priv->smu_tables.entry[TABLE_OVERDRIVE].table);
548 amdgpu_bo_free_kernel(&priv->smu_tables.entry[TABLE_SMU_METRICS].handle,
549 &priv->smu_tables.entry[TABLE_SMU_METRICS].mc_addr,
550 &priv->smu_tables.entry[TABLE_SMU_METRICS].table);
551 amdgpu_bo_free_kernel(&priv->smu_tables.entry[TABLE_ACTIVITY_MONITOR_COEFF].handle,
552 &priv->smu_tables.entry[TABLE_ACTIVITY_MONITOR_COEFF].mc_addr,
553 &priv->smu_tables.entry[TABLE_ACTIVITY_MONITOR_COEFF].table);
554 kfree(hwmgr->smu_backend);
555 hwmgr->smu_backend = NULL;
560 static int vega20_start_smu(struct pp_hwmgr *hwmgr)
564 ret = vega20_is_smc_ram_running(hwmgr);
565 PP_ASSERT_WITH_CODE(ret,
566 "[Vega20StartSmu] SMC is not running!",
569 ret = vega20_set_tools_address(hwmgr);
570 PP_ASSERT_WITH_CODE(!ret,
571 "[Vega20StartSmu] Failed to set tools address!",
577 static bool vega20_is_dpm_running(struct pp_hwmgr *hwmgr)
579 uint64_t features_enabled = 0;
581 vega20_get_enabled_smc_features(hwmgr, &features_enabled);
583 if (features_enabled & SMC_DPM_FEATURES)
589 static int vega20_smc_table_manager(struct pp_hwmgr *hwmgr, uint8_t *table,
590 uint16_t table_id, bool rw)
595 ret = vega20_copy_table_from_smc(hwmgr, table, table_id);
597 ret = vega20_copy_table_to_smc(hwmgr, table, table_id);
602 const struct pp_smumgr_func vega20_smu_funcs = {
603 .name = "vega20_smu",
604 .smu_init = &vega20_smu_init,
605 .smu_fini = &vega20_smu_fini,
606 .start_smu = &vega20_start_smu,
607 .request_smu_load_specific_fw = NULL,
608 .send_msg_to_smc = &vega20_send_msg_to_smc,
609 .send_msg_to_smc_with_parameter = &vega20_send_msg_to_smc_with_parameter,
610 .download_pptable_settings = NULL,
611 .upload_pptable_settings = NULL,
612 .is_dpm_running = vega20_is_dpm_running,
613 .get_argument = vega20_get_argument,
614 .smc_table_manager = vega20_smc_table_manager,