Skip to content

Commit c223376

Browse files
Li Maalexdeucher
authored andcommitted
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>
1 parent f266106 commit c223376

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
@@ -324,6 +324,18 @@ static int smu_dpm_set_umsch_mm_enable(struct smu_context *smu,
324324
return ret;
325325
}
326326

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+
327339
/**
328340
* smu_dpm_set_power_gate - power gate/ungate the specific IP block
329341
*
@@ -1791,6 +1803,7 @@ static int smu_hw_init(void *handle)
17911803
smu_dpm_set_jpeg_enable(smu, true);
17921804
smu_dpm_set_vpe_enable(smu, true);
17931805
smu_dpm_set_umsch_mm_enable(smu, true);
1806+
smu_set_mall_enable(smu);
17941807
smu_set_gfx_cgpg(smu, true);
17951808
}
17961809

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

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

1397+
/**
1398+
* @set_mall_enable: Init MALL power gating control.
1399+
*/
1400+
int (*set_mall_enable)(struct smu_context *smu);
1401+
13971402
/**
13981403
* @notify_rlc_state: Notify RLC power state to SMU.
13991404
*/

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] = {
@@ -1423,6 +1444,57 @@ static int smu_v14_0_common_get_dpm_table(struct smu_context *smu, struct dpm_cl
14231444
return 0;
14241445
}
14251446

1447+
static int smu_v14_0_1_init_mall_power_gating(struct smu_context *smu, enum smu_mall_pg_config pg_config)
1448+
{
1449+
struct amdgpu_device *adev = smu->adev;
1450+
int ret = 0;
1451+
1452+
if (pg_config == SMU_MALL_PG_CONFIG_PMFW_CONTROL) {
1453+
ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_MALLPowerController,
1454+
SMU_MALL_PMFW_CONTROL, NULL);
1455+
if (ret) {
1456+
dev_err(adev->dev, "Init MALL PMFW CONTROL Failure\n");
1457+
return ret;
1458+
}
1459+
} else {
1460+
ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_MALLPowerController,
1461+
SMU_MALL_DRIVER_CONTROL, NULL);
1462+
if (ret) {
1463+
dev_err(adev->dev, "Init MALL Driver CONTROL Failure\n");
1464+
return ret;
1465+
}
1466+
1467+
if (pg_config == SMU_MALL_PG_CONFIG_DRIVER_CONTROL_ALWAYS_ON) {
1468+
ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_MALLPowerState,
1469+
SMU_MALL_EXIT_PG, NULL);
1470+
if (ret) {
1471+
dev_err(adev->dev, "EXIT MALL PG Failure\n");
1472+
return ret;
1473+
}
1474+
} else if (pg_config == SMU_MALL_PG_CONFIG_DRIVER_CONTROL_ALWAYS_OFF) {
1475+
ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_MALLPowerState,
1476+
SMU_MALL_ENTER_PG, NULL);
1477+
if (ret) {
1478+
dev_err(adev->dev, "Enter MALL PG Failure\n");
1479+
return ret;
1480+
}
1481+
}
1482+
}
1483+
1484+
return ret;
1485+
}
1486+
1487+
static int smu_v14_0_common_set_mall_enable(struct smu_context *smu)
1488+
{
1489+
enum smu_mall_pg_config pg_config = SMU_MALL_PG_CONFIG_DEFAULT;
1490+
int ret = 0;
1491+
1492+
if (amdgpu_ip_version(smu->adev, MP1_HWIP, 0) == IP_VERSION(14, 0, 1))
1493+
ret = smu_v14_0_1_init_mall_power_gating(smu, pg_config);
1494+
1495+
return ret;
1496+
}
1497+
14261498
static const struct pptable_funcs smu_v14_0_0_ppt_funcs = {
14271499
.check_fw_status = smu_v14_0_check_fw_status,
14281500
.check_fw_version = smu_v14_0_check_fw_version,
@@ -1454,6 +1526,7 @@ static const struct pptable_funcs smu_v14_0_0_ppt_funcs = {
14541526
.dpm_set_vpe_enable = smu_v14_0_0_set_vpe_enable,
14551527
.dpm_set_umsch_mm_enable = smu_v14_0_0_set_umsch_mm_enable,
14561528
.get_dpm_clock_table = smu_v14_0_common_get_dpm_table,
1529+
.set_mall_enable = smu_v14_0_common_set_mall_enable,
14571530
};
14581531

14591532
static void smu_v14_0_0_set_smu_mailbox_registers(struct smu_context *smu)

0 commit comments

Comments
 (0)