Skip to contentSkip to conversation

Send message to PMFW when SMT changes

PATCH In review Wenyou Yang 2 participants 4 messages Apr 7, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v6 cover Send message to PMFW when SMT changes

When the SMT changes on the fly, send the message to the PMFW to notify the SMT status changed.

Changes in v6
1./ Update last_smt_active only when the return from smu_set_cpu_smt_enable() successfully.
2./ Use smu->adev->pm.fw_version to check smu version, if it is not assigned, get the smu version and assigned it.
3./ Remove the redundant error message print.

Changes in v5
1./ Add a new vangogh_fini_smc_tables() to accommodate the timer fini and smu_v11_0_fini_smc_tables().
2./ Move the version check of SMU version before initializing the timer.

Changes in v4
1./ Since we didn't find a good solution to handle the case that manually offlining all the SMT siblings using /sys/devices/system/cpu/cpu*/online to disable or enable SMT. Come up with a new solution, add a timer to poll the SMT state periodically, if finding that the SMT state is changed, it invokes the interface to notify the PMFW.
2./ Move the generic code to smu_cmn.c.
3./ Add PMFW version check for this feature.

Changes in v3
1./ Because it is only required for Vangogh, move registering notifier to vangogh_ppt.c, then remove the patch 2, and the number of patches decreased to 2.

Changes in v2:
1/. Embed the smt notifer callback into "struct smu_context" structure. 2/. Correct the PPSMC_Message_Count value.
3/. Improve several code styles and others.

Wenyou Yang (2):
drm/amd/pm: Add support to check SMT state periodically drm/amd/pm/vangogh: Send SMT enable message to PMFW

 drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  8 ++++
 .../pm/swsmu/inc/pmfw_if/smu_v11_5_ppsmc.h    |  3 +-
 drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h  |  3 +-
 .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c  | 32 +++++++++++++-
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c        | 44 +++++++++++++++++++
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h        |  5 +++
 6 files changed, 92 insertions(+), 3 deletions(-)
Signature · 1 line
2.39.2
#1 lore raw

PATCH v6 1/2 drm/amd/pm: Add support to check SMT state periodically

Add a timer to poll the SMT state periodically, if the SMT state is changed, invoke the interface to notify the PMFW.

---
 drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  8 ++++
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c        | 44 +++++++++++++++++++
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h        |  5 +++
 3 files changed, 57 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +8 -0
index 09469c750a96..fc571c122e87 100644
@@ -566,6 +566,9 @@ struct smu_context
 
 	struct firmware pptable_firmware;
 
+	bool last_smt_active;
+	struct timer_list smt_timer;
+
 	u32 param_reg;
 	u32 msg_reg;
 	u32 resp_reg;
@@ -1354,6 +1357,11 @@ struct pptable_funcs {
 	 * @init_pptable_microcode: Prepare the pptable microcode to upload via PSP
 	 */
 	int (*init_pptable_microcode)(struct smu_context *smu);
+
+	/**
+	 * @set_cpu_smt_enable: Set the CPU SMT status.
+	 */
+	int (*set_cpu_smt_enable)(struct smu_context *smu, bool smt_enable);
 };
 
 typedef enum {
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +44 -0

53 lines not on this page · raw message

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +5 -0
index d7cd358a53bd..928dd9e30d83 100644
@@ -127,5 +127,10 @@ static inline void smu_cmn_get_sysfs_buf(char **buf, int *offset)
 
 bool smu_cmn_is_audio_func_enabled(struct amdgpu_device *adev);
 
+void smu_smt_timer_init(struct smu_context *smu);
+
 #endif
+
+void smu_smt_timer_fini(struct smu_context *smu);
+
 #endif
Signature · 1 line
2.39.2
#2 lore raw

PATCH v6 2/2 drm/amd/pm/vangogh: Send SMT enable message to PMFW

In reply to Wenyou Yang

When the SMT state is changed on the fly, sent the SMT enable message to the PMFW to notify it that the SMT state changed.

Add the support to send PPSMC_MSG_SetCClkSMTEnable(0x58) message to the PMFW for Vangogh.

---
 .../pm/swsmu/inc/pmfw_if/smu_v11_5_ppsmc.h    |  3 +-
 drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h  |  3 +-
 .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c  | 32 ++++++++++++++++++-
 3 files changed, 35 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v11_5_ppsmc.h +2 -1
index 7471e2df2828..a6bfa1912c42 100644
@@ -111,7 +111,8 @@
 #define PPSMC_MSG_GetGfxOffStatus		       0x50
 #define PPSMC_MSG_GetGfxOffEntryCount		       0x51
 #define PPSMC_MSG_LogGfxOffResidency		       0x52
-#define PPSMC_Message_Count                            0x53
+#define PPSMC_MSG_SetCClkSMTEnable		       0x58
+#define PPSMC_Message_Count                            0x59
 
 //Argument for PPSMC_MSG_GfxDeviceDriverReset
 enum {
drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h +2 -1
index 297b70b9388f..820812d910bf 100644
@@ -245,7 +245,8 @@
 	__SMU_DUMMY_MAP(AllowGpo),	\
 	__SMU_DUMMY_MAP(Mode2Reset),	\
 	__SMU_DUMMY_MAP(RequestI2cTransaction), \
-	__SMU_DUMMY_MAP(GetMetricsTable),
+	__SMU_DUMMY_MAP(GetMetricsTable), \
+	__SMU_DUMMY_MAP(SetCClkSMTEnable),
 
 #undef __SMU_DUMMY_MAP
 #define __SMU_DUMMY_MAP(type)	SMU_MSG_##type
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +31 -1
index 7433dcaa16e0..cda5a8ee2aeb 100644
@@ -141,6 +141,7 @@ static struct cmn2asic_msg_mapping vangogh_message_map[SMU_MSG_MAX_COUNT] = {
 	MSG_MAP(GetGfxOffStatus,		    PPSMC_MSG_GetGfxOffStatus,						0),
 	MSG_MAP(GetGfxOffEntryCount,		    PPSMC_MSG_GetGfxOffEntryCount,					0),
 	MSG_MAP(LogGfxOffResidency,		    PPSMC_MSG_LogGfxOffResidency,					0),
+	MSG_MAP(SetCClkSMTEnable,		    PPSMC_MSG_SetCClkSMTEnable,						0),
 };
 
 static struct cmn2asic_mapping vangogh_feature_mask_map[SMU_FEATURE_COUNT] = {
@@ -460,6 +461,7 @@ static int vangogh_allocate_dpm_context(struct smu_context *smu)
 
 static int vangogh_init_smc_tables(struct smu_context *smu)
 {
+	uint32_t smu_version;
 	int ret = 0;
 
 	ret = vangogh_tables_init(smu);
@@ -477,9 +479,30 @@ static int vangogh_init_smc_tables(struct smu_context *smu)
 	smu->cpu_core_num = 4;
 #endif
 
+	if (!smu->adev->pm.fw_version) {
+		ret = smu_cmn_get_smc_version(smu, NULL, &smu_version);
+		if (ret)
+			return ret;
+
+		smu->adev->pm.fw_version = smu_version;
+	}
+
+	if (smu->adev->pm.fw_version >= 0x063F0600)
+		smu_smt_timer_init(smu);
+
 	return smu_v11_0_init_smc_tables(smu);
 }
 
+static int vangogh_fini_smc_tables(struct smu_context *smu)
+{
+	if (smu->adev->pm.fw_version >= 0x063F0600)
+		smu_smt_timer_fini(smu);
+
+	smu_v11_0_fini_smc_tables(smu);
+
+	return 0;
+}
+
 static int vangogh_dpm_set_vcn_enable(struct smu_context *smu, bool enable)
 {
 	int ret = 0;
@@ -2428,12 +2451,18 @@ static u32 vangogh_get_gfxoff_entrycount(struct smu_context *smu, uint64_t *entr
 	return ret;
 }
 
+static int vangogh_set_cpu_smt_enable(struct smu_context *smu, bool enable)
+{
+	return smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_SetCClkSMTEnable,
+					       enable ? 1 : 0, NULL);
+}
+
 static const struct pptable_funcs vangogh_ppt_funcs = {
 
 	.check_fw_status = smu_v11_0_check_fw_status,
 	.check_fw_version = smu_v11_0_check_fw_version,
 	.init_smc_tables = vangogh_init_smc_tables,
-	.fini_smc_tables = smu_v11_0_fini_smc_tables,
+	.fini_smc_tables = vangogh_fini_smc_tables,
 	.init_power = smu_v11_0_init_power,
 	.fini_power = smu_v11_0_fini_power,
 	.register_irq_handler = smu_v11_0_register_irq_handler,
@@ -2474,6 +2503,7 @@ static const struct pptable_funcs vangogh_ppt_funcs = {
 	.get_power_limit = vangogh_get_power_limit,
 	.set_power_limit = vangogh_set_power_limit,
 	.get_vbios_bootup_values = smu_v11_0_get_vbios_bootup_values,
+	.set_cpu_smt_enable = vangogh_set_cpu_smt_enable,
 };
 
 void vangogh_set_ppt_funcs(struct smu_context *smu)
Signature · 1 line
2.39.2
Reviewed-by on the v6 series
#3 lore raw
In reply to Wenyou Yang
Quoted 39 lines · Wenyou Yang

When the SMT changes on the fly, send the message to the PMFW to notify the SMT status changed.

Changes in v6
1./ Update last_smt_active only when the return from smu_set_cpu_smt_enable() successfully.
2./ Use smu->adev->pm.fw_version to check smu version, if it is not assigned, get the smu version and assigned it.
3./ Remove the redundant error message print.

Changes in v5
1./ Add a new vangogh_fini_smc_tables() to accommodate the timer fini and smu_v11_0_fini_smc_tables().
2./ Move the version check of SMU version before initializing the timer.

Changes in v4
1./ Since we didn't find a good solution to handle the case that manually offlining all the SMT siblings using /sys/devices/system/cpu/cpu*/online to disable or enable SMT. Come up with a new solution, add a timer to poll the SMT state periodically, if finding that the SMT state is changed, it invokes the interface to notify the PMFW.
2./ Move the generic code to smu_cmn.c.
3./ Add PMFW version check for this feature.

Changes in v3
1./ Because it is only required for Vangogh, move registering notifier to vangogh_ppt.c, then remove the patch 2, and the number of patches decreased to 2.

Changes in v2:
1/. Embed the smt notifer callback into "struct smu_context" structure. 2/. Correct the PPSMC_Message_Count value.
3/. Improve several code styles and others.

Wenyou Yang (2):
drm/amd/pm: Add support to check SMT state periodically drm/amd/pm/vangogh: Send SMT enable message to PMFW

Quoted 8 lines
  drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  8 ++++
  .../pm/swsmu/inc/pmfw_if/smu_v11_5_ppsmc.h    |  3 +-
  drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h  |  3 +-
  .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c  | 32 +++++++++++++-
  drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c        | 44 +++++++++++++++++++
  drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h        |  5 +++
  6 files changed, 92 insertions(+), 3 deletions(-)

For series: