Skip to content

Commit 6172bad

Browse files
Li Magregkh
authored andcommitted
drm/amd/swsmu: add MALL init support workaround for smu_v14_0_1
[ Upstream commit c223376 ] [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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent deac270 commit 6172bad

5 files changed

Lines changed: 96 additions & 3 deletions

File tree

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,18 @@ static int smu_dpm_set_umsch_mm_enable(struct smu_context *smu,
323323
return ret;
324324
}
325325

326+
static int smu_set_mall_enable(struct smu_context *smu)
327+
{
328+
int ret = 0;
329+
330+
if (!smu->ppt_funcs->set_mall_enable)
331+
return 0;
332+
333+
ret = smu->ppt_funcs->set_mall_enable(smu);
334+
335+
return ret;
336+
}
337+
326338
/**
327339
* smu_dpm_set_power_gate - power gate/ungate the specific IP block
328340
*
@@ -1785,6 +1797,7 @@ static int smu_hw_init(void *handle)
17851797
smu_dpm_set_jpeg_enable(smu, true);
17861798
smu_dpm_set_vpe_enable(smu, true);
17871799
smu_dpm_set_umsch_mm_enable(smu, true);
1800+
smu_set_mall_enable(smu);
17881801
smu_set_gfx_cgpg(smu, true);
17891802
}
17901803

drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,6 +1391,11 @@ struct pptable_funcs {
13911391
*/
13921392
int (*dpm_set_umsch_mm_enable)(struct smu_context *smu, bool enable);
13931393

1394+
/**
1395+
* @set_mall_enable: Init MALL power gating control.
1396+
*/
1397+
int (*set_mall_enable)(struct smu_context *smu);
1398+
13941399
/**
13951400
* @notify_rlc_state: Notify RLC power state to SMU.
13961401
*/

drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v14_0_0_ppsmc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@
106106
#define PPSMC_MSG_DisableLSdma 0x35 ///< Disable LSDMA
107107
#define PPSMC_MSG_SetSoftMaxVpe 0x36 ///<
108108
#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
111111
#define PPSMC_Message_Count 0x3A ///< Total number of PPSMC messages
112112
/** @}*/
113113

drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,9 @@
272272
__SMU_DUMMY_MAP(SetSoftMinVpe), \
273273
__SMU_DUMMY_MAP(GetMetricsVersion), \
274274
__SMU_DUMMY_MAP(EnableUCLKShadow), \
275-
__SMU_DUMMY_MAP(RmaDueToBadPageThreshold),
275+
__SMU_DUMMY_MAP(RmaDueToBadPageThreshold), \
276+
__SMU_DUMMY_MAP(MALLPowerController), \
277+
__SMU_DUMMY_MAP(MALLPowerState),
276278

277279
#undef __SMU_DUMMY_MAP
278280
#define __SMU_DUMMY_MAP(type) SMU_MSG_##type

drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,19 @@
5252
#define mmMP1_SMN_C2PMSG_90 0x029a
5353
#define mmMP1_SMN_C2PMSG_90_BASE_IDX 0
5454

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+
5568
#define FEATURE_MASK(feature) (1ULL << feature)
5669
#define SMC_DPM_FEATURE ( \
5770
FEATURE_MASK(FEATURE_CCLK_DPM_BIT) | \
@@ -66,6 +79,12 @@
6679
FEATURE_MASK(FEATURE_GFX_DPM_BIT) | \
6780
FEATURE_MASK(FEATURE_VPE_DPM_BIT))
6881

82+
enum smu_mall_pg_config {
83+
SMU_MALL_PG_CONFIG_PMFW_CONTROL = 0,
84+
SMU_MALL_PG_CONFIG_DRIVER_CONTROL_ALWAYS_ON = 1,
85+
SMU_MALL_PG_CONFIG_DRIVER_CONTROL_ALWAYS_OFF = 2,
86+
};
87+
6988
static struct cmn2asic_msg_mapping smu_v14_0_0_message_map[SMU_MSG_MAX_COUNT] = {
7089
MSG_MAP(TestMessage, PPSMC_MSG_TestMessage, 1),
7190
MSG_MAP(GetSmuVersion, PPSMC_MSG_GetPmfwVersion, 1),
@@ -113,6 +132,8 @@ static struct cmn2asic_msg_mapping smu_v14_0_0_message_map[SMU_MSG_MAX_COUNT] =
113132
MSG_MAP(PowerDownUmsch, PPSMC_MSG_PowerDownUmsch, 1),
114133
MSG_MAP(SetSoftMaxVpe, PPSMC_MSG_SetSoftMaxVpe, 1),
115134
MSG_MAP(SetSoftMinVpe, PPSMC_MSG_SetSoftMinVpe, 1),
135+
MSG_MAP(MALLPowerController, PPSMC_MSG_MALLPowerController, 1),
136+
MSG_MAP(MALLPowerState, PPSMC_MSG_MALLPowerState, 1),
116137
};
117138

118139
static struct cmn2asic_mapping smu_v14_0_0_feature_mask_map[SMU_FEATURE_COUNT] = {
@@ -1417,6 +1438,57 @@ static int smu_v14_0_common_get_dpm_table(struct smu_context *smu, struct dpm_cl
14171438
return 0;
14181439
}
14191440

1441+
static int smu_v14_0_1_init_mall_power_gating(struct smu_context *smu, enum smu_mall_pg_config pg_config)
1442+
{
1443+
struct amdgpu_device *adev = smu->adev;
1444+
int ret = 0;
1445+
1446+
if (pg_config == SMU_MALL_PG_CONFIG_PMFW_CONTROL) {
1447+
ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_MALLPowerController,
1448+
SMU_MALL_PMFW_CONTROL, NULL);
1449+
if (ret) {
1450+
dev_err(adev->dev, "Init MALL PMFW CONTROL Failure\n");
1451+
return ret;
1452+
}
1453+
} else {
1454+
ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_MALLPowerController,
1455+
SMU_MALL_DRIVER_CONTROL, NULL);
1456+
if (ret) {
1457+
dev_err(adev->dev, "Init MALL Driver CONTROL Failure\n");
1458+
return ret;
1459+
}
1460+
1461+
if (pg_config == SMU_MALL_PG_CONFIG_DRIVER_CONTROL_ALWAYS_ON) {
1462+
ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_MALLPowerState,
1463+
SMU_MALL_EXIT_PG, NULL);
1464+
if (ret) {
1465+
dev_err(adev->dev, "EXIT MALL PG Failure\n");
1466+
return ret;
1467+
}
1468+
} else if (pg_config == SMU_MALL_PG_CONFIG_DRIVER_CONTROL_ALWAYS_OFF) {
1469+
ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_MALLPowerState,
1470+
SMU_MALL_ENTER_PG, NULL);
1471+
if (ret) {
1472+
dev_err(adev->dev, "Enter MALL PG Failure\n");
1473+
return ret;
1474+
}
1475+
}
1476+
}
1477+
1478+
return ret;
1479+
}
1480+
1481+
static int smu_v14_0_common_set_mall_enable(struct smu_context *smu)
1482+
{
1483+
enum smu_mall_pg_config pg_config = SMU_MALL_PG_CONFIG_DEFAULT;
1484+
int ret = 0;
1485+
1486+
if (amdgpu_ip_version(smu->adev, MP1_HWIP, 0) == IP_VERSION(14, 0, 1))
1487+
ret = smu_v14_0_1_init_mall_power_gating(smu, pg_config);
1488+
1489+
return ret;
1490+
}
1491+
14201492
static const struct pptable_funcs smu_v14_0_0_ppt_funcs = {
14211493
.check_fw_status = smu_v14_0_check_fw_status,
14221494
.check_fw_version = smu_v14_0_check_fw_version,
@@ -1448,6 +1520,7 @@ static const struct pptable_funcs smu_v14_0_0_ppt_funcs = {
14481520
.dpm_set_vpe_enable = smu_v14_0_0_set_vpe_enable,
14491521
.dpm_set_umsch_mm_enable = smu_v14_0_0_set_umsch_mm_enable,
14501522
.get_dpm_clock_table = smu_v14_0_common_get_dpm_table,
1523+
.set_mall_enable = smu_v14_0_common_set_mall_enable,
14511524
};
14521525

14531526
static void smu_v14_0_0_set_smu_mailbox_registers(struct smu_context *smu)

0 commit comments

Comments
 (0)