Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amd/swsmu: add MALL init support workaround for smu_v14_0_1

[Why]
SMU firmware has not supported MALL PG.

[How]
Disable MALL PG and make it always on until SMU firmware is ready.

Signed-off-by: Li Ma <li.ma@amd.com>
Reviewed-by: Tim Huang <Tim.Huang@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Li Ma and committed by
Alex Deucher
c223376b f2661062

+96 -3
+13
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
··· 324 324 return ret; 325 325 } 326 326 327 + static int smu_set_mall_enable(struct smu_context *smu) 328 + { 329 + int ret = 0; 330 + 331 + if (!smu->ppt_funcs->set_mall_enable) 332 + return 0; 333 + 334 + ret = smu->ppt_funcs->set_mall_enable(smu); 335 + 336 + return ret; 337 + } 338 + 327 339 /** 328 340 * smu_dpm_set_power_gate - power gate/ungate the specific IP block 329 341 * ··· 1803 1791 smu_dpm_set_jpeg_enable(smu, true); 1804 1792 smu_dpm_set_vpe_enable(smu, true); 1805 1793 smu_dpm_set_umsch_mm_enable(smu, true); 1794 + smu_set_mall_enable(smu); 1806 1795 smu_set_gfx_cgpg(smu, true); 1807 1796 } 1808 1797
+5
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
··· 1395 1395 int (*dpm_set_umsch_mm_enable)(struct smu_context *smu, bool enable); 1396 1396 1397 1397 /** 1398 + * @set_mall_enable: Init MALL power gating control. 1399 + */ 1400 + int (*set_mall_enable)(struct smu_context *smu); 1401 + 1402 + /** 1398 1403 * @notify_rlc_state: Notify RLC power state to SMU. 1399 1404 */ 1400 1405 int (*notify_rlc_state)(struct smu_context *smu, bool en);
+2 -2
drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v14_0_0_ppsmc.h
··· 106 106 #define PPSMC_MSG_DisableLSdma 0x35 ///< Disable LSDMA 107 107 #define PPSMC_MSG_SetSoftMaxVpe 0x36 ///< 108 108 #define PPSMC_MSG_SetSoftMinVpe 0x37 ///< 109 - #define PPSMC_MSG_AllocMALLCache 0x38 ///< Allocating MALL Cache 110 - #define PPSMC_MSG_ReleaseMALLCache 0x39 ///< Releasing MALL Cache 109 + #define PPSMC_MSG_MALLPowerController 0x38 ///< Set MALL control 110 + #define PPSMC_MSG_MALLPowerState 0x39 ///< Enter/Exit MALL PG 111 111 #define PPSMC_Message_Count 0x3A ///< Total number of PPSMC messages 112 112 /** @}*/ 113 113
+3 -1
drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h
··· 272 272 __SMU_DUMMY_MAP(SetSoftMinVpe), \ 273 273 __SMU_DUMMY_MAP(GetMetricsVersion), \ 274 274 __SMU_DUMMY_MAP(EnableUCLKShadow), \ 275 - __SMU_DUMMY_MAP(RmaDueToBadPageThreshold), 275 + __SMU_DUMMY_MAP(RmaDueToBadPageThreshold), \ 276 + __SMU_DUMMY_MAP(MALLPowerController), \ 277 + __SMU_DUMMY_MAP(MALLPowerState), 276 278 277 279 #undef __SMU_DUMMY_MAP 278 280 #define __SMU_DUMMY_MAP(type) SMU_MSG_##type
+73
drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c
··· 52 52 #define mmMP1_SMN_C2PMSG_90 0x029a 53 53 #define mmMP1_SMN_C2PMSG_90_BASE_IDX 0 54 54 55 + /* MALLPowerController message arguments (Defines for the Cache mode control) */ 56 + #define SMU_MALL_PMFW_CONTROL 0 57 + #define SMU_MALL_DRIVER_CONTROL 1 58 + 59 + /* 60 + * MALLPowerState message arguments 61 + * (Defines for the Allocate/Release Cache mode if in driver mode) 62 + */ 63 + #define SMU_MALL_EXIT_PG 0 64 + #define SMU_MALL_ENTER_PG 1 65 + 66 + #define SMU_MALL_PG_CONFIG_DEFAULT SMU_MALL_PG_CONFIG_DRIVER_CONTROL_ALWAYS_ON 67 + 55 68 #define FEATURE_MASK(feature) (1ULL << feature) 56 69 #define SMC_DPM_FEATURE ( \ 57 70 FEATURE_MASK(FEATURE_CCLK_DPM_BIT) | \ ··· 78 65 FEATURE_MASK(FEATURE_IPU_DPM_BIT) | \ 79 66 FEATURE_MASK(FEATURE_GFX_DPM_BIT) | \ 80 67 FEATURE_MASK(FEATURE_VPE_DPM_BIT)) 68 + 69 + enum smu_mall_pg_config { 70 + SMU_MALL_PG_CONFIG_PMFW_CONTROL = 0, 71 + SMU_MALL_PG_CONFIG_DRIVER_CONTROL_ALWAYS_ON = 1, 72 + SMU_MALL_PG_CONFIG_DRIVER_CONTROL_ALWAYS_OFF = 2, 73 + }; 81 74 82 75 static struct cmn2asic_msg_mapping smu_v14_0_0_message_map[SMU_MSG_MAX_COUNT] = { 83 76 MSG_MAP(TestMessage, PPSMC_MSG_TestMessage, 1), ··· 132 113 MSG_MAP(PowerDownUmsch, PPSMC_MSG_PowerDownUmsch, 1), 133 114 MSG_MAP(SetSoftMaxVpe, PPSMC_MSG_SetSoftMaxVpe, 1), 134 115 MSG_MAP(SetSoftMinVpe, PPSMC_MSG_SetSoftMinVpe, 1), 116 + MSG_MAP(MALLPowerController, PPSMC_MSG_MALLPowerController, 1), 117 + MSG_MAP(MALLPowerState, PPSMC_MSG_MALLPowerState, 1), 135 118 }; 136 119 137 120 static struct cmn2asic_mapping smu_v14_0_0_feature_mask_map[SMU_FEATURE_COUNT] = { ··· 1444 1423 return 0; 1445 1424 } 1446 1425 1426 + static int smu_v14_0_1_init_mall_power_gating(struct smu_context *smu, enum smu_mall_pg_config pg_config) 1427 + { 1428 + struct amdgpu_device *adev = smu->adev; 1429 + int ret = 0; 1430 + 1431 + if (pg_config == SMU_MALL_PG_CONFIG_PMFW_CONTROL) { 1432 + ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_MALLPowerController, 1433 + SMU_MALL_PMFW_CONTROL, NULL); 1434 + if (ret) { 1435 + dev_err(adev->dev, "Init MALL PMFW CONTROL Failure\n"); 1436 + return ret; 1437 + } 1438 + } else { 1439 + ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_MALLPowerController, 1440 + SMU_MALL_DRIVER_CONTROL, NULL); 1441 + if (ret) { 1442 + dev_err(adev->dev, "Init MALL Driver CONTROL Failure\n"); 1443 + return ret; 1444 + } 1445 + 1446 + if (pg_config == SMU_MALL_PG_CONFIG_DRIVER_CONTROL_ALWAYS_ON) { 1447 + ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_MALLPowerState, 1448 + SMU_MALL_EXIT_PG, NULL); 1449 + if (ret) { 1450 + dev_err(adev->dev, "EXIT MALL PG Failure\n"); 1451 + return ret; 1452 + } 1453 + } else if (pg_config == SMU_MALL_PG_CONFIG_DRIVER_CONTROL_ALWAYS_OFF) { 1454 + ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_MALLPowerState, 1455 + SMU_MALL_ENTER_PG, NULL); 1456 + if (ret) { 1457 + dev_err(adev->dev, "Enter MALL PG Failure\n"); 1458 + return ret; 1459 + } 1460 + } 1461 + } 1462 + 1463 + return ret; 1464 + } 1465 + 1466 + static int smu_v14_0_common_set_mall_enable(struct smu_context *smu) 1467 + { 1468 + enum smu_mall_pg_config pg_config = SMU_MALL_PG_CONFIG_DEFAULT; 1469 + int ret = 0; 1470 + 1471 + if (amdgpu_ip_version(smu->adev, MP1_HWIP, 0) == IP_VERSION(14, 0, 1)) 1472 + ret = smu_v14_0_1_init_mall_power_gating(smu, pg_config); 1473 + 1474 + return ret; 1475 + } 1476 + 1447 1477 static const struct pptable_funcs smu_v14_0_0_ppt_funcs = { 1448 1478 .check_fw_status = smu_v14_0_check_fw_status, 1449 1479 .check_fw_version = smu_v14_0_check_fw_version, ··· 1526 1454 .dpm_set_vpe_enable = smu_v14_0_0_set_vpe_enable, 1527 1455 .dpm_set_umsch_mm_enable = smu_v14_0_0_set_umsch_mm_enable, 1528 1456 .get_dpm_clock_table = smu_v14_0_common_get_dpm_table, 1457 + .set_mall_enable = smu_v14_0_common_set_mall_enable, 1529 1458 }; 1530 1459 1531 1460 static void smu_v14_0_0_set_smu_mailbox_registers(struct smu_context *smu)