Skip to contentSkip to conversation

drm/amd/pm: validate SMU feature enable message for getting feature enabled mask

PATCH In review Prike Liang 2 participants 2 messages Feb 18, 2022

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

PATCH v2 1/1 drm/amd/pm: validate SMU feature enable message for getting feature enabled mask

There's always miss the SMU feature enabled checked in the NPI phase, so let validate the SMU feature enable message directly rather than add more and more MP1 version check.

---
 .../amd/pm/swsmu/smu11/cyan_skillfish_ppt.c   | 12 ++++-
 .../gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c   | 12 ++++-
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c        | 48 ++++++++-----------
 3 files changed, 43 insertions(+), 29 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c +11 -1
index b3a0f3fb3e65..f1a4a720d426 100644
@@ -552,6 +552,16 @@ static int cyan_skillfish_get_dpm_ultimate_freq(struct smu_context *smu,
 	return 0;
 }
 
+static int cyan_skillfish_get_enabled_mask(struct smu_context *smu,
+					   uint64_t *feature_mask)
+{
+	if (!feature_mask)
+		return -EINVAL;
+	memset(feature_mask, 0xff, sizeof(*feature_mask));
+
+	return 0;
+}
+
 static const struct pptable_funcs cyan_skillfish_ppt_funcs = {
 
 	.check_fw_status = smu_v11_0_check_fw_status,
@@ -562,7 +572,7 @@ static const struct pptable_funcs cyan_skillfish_ppt_funcs = {
 	.fini_smc_tables = smu_v11_0_fini_smc_tables,
 	.read_sensor = cyan_skillfish_read_sensor,
 	.print_clk_levels = cyan_skillfish_print_clk_levels,
-	.get_enabled_mask = smu_cmn_get_enabled_mask,
+	.get_enabled_mask = cyan_skillfish_get_enabled_mask,
 	.is_dpm_running = cyan_skillfish_is_dpm_running,
 	.get_gpu_metrics = cyan_skillfish_get_gpu_metrics,
 	.od_edit_dpm_table = cyan_skillfish_od_edit_dpm_table,
drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c +11 -1
index e99e7b2bf25b..fd6c44ece168 100644
@@ -1366,6 +1366,16 @@ static int renoir_gfx_state_change_set(struct smu_context *smu, uint32_t state)
 	return 0;
 }
 
+static int renoir_get_enabled_mask(struct smu_context *smu,
+				   uint64_t *feature_mask)
+{
+	if (!feature_mask)
+		return -EINVAL;
+	memset(feature_mask, 0xff, sizeof(*feature_mask));
+
+	return 0;
+}
+
 static const struct pptable_funcs renoir_ppt_funcs = {
 	.set_power_state = NULL,
 	.print_clk_levels = renoir_print_clk_levels,
@@ -1390,7 +1400,7 @@ static const struct pptable_funcs renoir_ppt_funcs = {
 	.init_smc_tables = renoir_init_smc_tables,
 	.fini_smc_tables = smu_v12_0_fini_smc_tables,
 	.set_default_dpm_table = smu_v12_0_set_default_dpm_tables,
-	.get_enabled_mask = smu_cmn_get_enabled_mask,
+	.get_enabled_mask = renoir_get_enabled_mask,
 	.feature_is_enabled = smu_cmn_feature_is_enabled,
 	.disable_all_features_with_exception = smu_cmn_disable_all_features_with_exception,
 	.get_dpm_ultimate_freq = renoir_get_dpm_ultimate_freq,
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +21 -27

104 lines not on this page · raw message

Signature · 1 line
2.17.1
maintainer Reviewed-by on v2 1/1
#1 lore raw

[Public]

________________________________
From: amd-gfx <[email protected]> on behalf of Prike Liang <[email protected]>
Sent: Friday, February 18, 2022 2:04 AM
To: [email protected] <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Liang, Prike <[email protected]>; Lazar, Lijo <[email protected]>; Huang, Ray <[email protected]>; Quan, Evan <[email protected]>
Subject: [PATCH v2] drm/amd/pm: validate SMU feature enable message for getting feature enabled mask

There's always miss the SMU feature enabled checked in the NPI phase, so let validate the SMU feature enable message directly rather than add more and more MP1 version check.

---
 .../amd/pm/swsmu/smu11/cyan_skillfish_ppt.c   | 12 ++++-
 .../gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c   | 12 ++++-
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c        | 48 ++++++++-----------
 3 files changed, 43 insertions(+), 29 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c +11 -1
index b3a0f3fb3e65..f1a4a720d426 100644
@@ -552,6 +552,16 @@ static int cyan_skillfish_get_dpm_ultimate_freq(struct smu_context *smu,
         return 0;
 }
 
+static int cyan_skillfish_get_enabled_mask(struct smu_context *smu,
+                                          uint64_t *feature_mask)
+{
+       if (!feature_mask)
+               return -EINVAL;
+       memset(feature_mask, 0xff, sizeof(*feature_mask));
+
+       return 0;
+}
+
 static const struct pptable_funcs cyan_skillfish_ppt_funcs = {
 
         .check_fw_status = smu_v11_0_check_fw_status,
@@ -562,7 +572,7 @@ static const struct pptable_funcs cyan_skillfish_ppt_funcs = {
         .fini_smc_tables = smu_v11_0_fini_smc_tables,
         .read_sensor = cyan_skillfish_read_sensor,
         .print_clk_levels = cyan_skillfish_print_clk_levels,
-       .get_enabled_mask = smu_cmn_get_enabled_mask,
+       .get_enabled_mask = cyan_skillfish_get_enabled_mask,
         .is_dpm_running = cyan_skillfish_is_dpm_running,
         .get_gpu_metrics = cyan_skillfish_get_gpu_metrics,
         .od_edit_dpm_table = cyan_skillfish_od_edit_dpm_table,
drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c +11 -1
index e99e7b2bf25b..fd6c44ece168 100644
@@ -1366,6 +1366,16 @@ static int renoir_gfx_state_change_set(struct smu_context *smu, uint32_t state)
         return 0;
 }
 
+static int renoir_get_enabled_mask(struct smu_context *smu,
+                                  uint64_t *feature_mask)
+{
+       if (!feature_mask)
+               return -EINVAL;
+       memset(feature_mask, 0xff, sizeof(*feature_mask));
+
+       return 0;
+}
+
 static const struct pptable_funcs renoir_ppt_funcs = {
         .set_power_state = NULL,
         .print_clk_levels = renoir_print_clk_levels,
@@ -1390,7 +1400,7 @@ static const struct pptable_funcs renoir_ppt_funcs = {
         .init_smc_tables = renoir_init_smc_tables,
         .fini_smc_tables = smu_v12_0_fini_smc_tables,
         .set_default_dpm_table = smu_v12_0_set_default_dpm_tables,
-       .get_enabled_mask = smu_cmn_get_enabled_mask,
+       .get_enabled_mask = renoir_get_enabled_mask,
         .feature_is_enabled = smu_cmn_feature_is_enabled,
         .disable_all_features_with_exception = smu_cmn_disable_all_features_with_exception,
         .get_dpm_ultimate_freq = renoir_get_dpm_ultimate_freq,
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +21 -27

104 lines not on this page · raw message

--
2.17.1