Skip to contentSkip to conversation

drm/amd/powerplay: optimization function of smu_update_table

PATCH In review Wang, Kevin(Yang) 3 participants 6 messages Apr 8, 2019 – Apr 9, 2019 3 messages not in the archive

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

PATCH 1/2 drm/amd/powerplay: optimization function of smu_update_table

in fact, the firmware need 2 parameter: 1.table_id, 2.XferArg so change the function interface to match the firmware code

---
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c     | 7 +++++--
 drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 5 ++++-
 2 files changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +5 -2
index 7e8c74da6a74..c058c784180e 100644
@@ -97,16 +97,19 @@ int smu_common_read_sensor(struct smu_context *smu, enum amd_pp_sensors sensor,
 	return ret;
 }
 
-int smu_update_table(struct smu_context *smu, uint32_t table_id,
+int smu_update_table_with_arg(struct smu_context *smu, uint16_t table_id, uint16_t exarg,
 		     void *table_data, bool drv2smu)
 {
 	struct smu_table_context *smu_table = &smu->smu_table;
 	struct smu_table *table = NULL;
 	int ret = 0;
+	uint32_t table_index;
 
 	if (!table_data || table_id >= smu_table->table_count)
 		return -EINVAL;
 
+	table_index = (exarg << 16) | table_id;
+
 	table = &smu_table->tables[table_id];
 
 	if (drv2smu)
@@ -123,7 +126,7 @@ int smu_update_table(struct smu_context *smu, uint32_t table_id,
 	ret = smu_send_smc_msg_with_param(smu, drv2smu ?
 					  SMU_MSG_TransferTableDram2Smu :
 					  SMU_MSG_TransferTableSmu2Dram,
-					  table_id);
+					  table_index);
 	if (ret)
 		return ret;
 
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +4 -1
index 2083139533e9..c146b5e884f8 100644
@@ -745,8 +745,11 @@ extern int smu_feature_set_enabled(struct smu_context *smu, int feature_id, bool
 extern int smu_feature_is_supported(struct smu_context *smu, int feature_id);
 extern int smu_feature_set_supported(struct smu_context *smu, int feature_id, bool enable);
 
-int smu_update_table(struct smu_context *smu, uint32_t table_id,
+int smu_update_table_with_arg(struct smu_context *smu, uint16_t table_id, uint16_t exarg,
 		     void *table_data, bool drv2smu);
+#define smu_update_table(smu, table_id, table_data, drv2smu) \
+	smu_update_table_with_arg((smu), (table_id), 0, (table_data), (drv2smu))
+
 bool is_support_sw_smu(struct amdgpu_device *adev);
 int smu_reset(struct smu_context *smu);
 int smu_common_read_sensor(struct smu_context *smu, enum amd_pp_sensors sensor,
Signature · 6 lines
2.21.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

PATCH 2/2 drm/amd/powerplay: simplify the code of [get|set]_activity_monitor_coeff

use smu_update_table_with_arg to replace old code logic

---
 .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h    |  6 --
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c     | 75 ++-----------------
 2 files changed, 7 insertions(+), 74 deletions(-)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +0 -6
index c146b5e884f8..26a7d2c7f4fa 100644
@@ -524,12 +524,6 @@ struct smu_funcs
 					       struct dm_pp_wm_sets_with_clock_ranges_soc15 *clock_ranges);
 	int (*set_od8_default_settings)(struct smu_context *smu,
 					bool initialize);
-	int (*get_activity_monitor_coeff)(struct smu_context *smu,
-				      uint8_t *table,
-				      uint16_t workload_type);
-	int (*set_activity_monitor_coeff)(struct smu_context *smu,
-				      uint8_t *table,
-				      uint16_t workload_type);
 	int (*conv_power_profile_to_pplib_workload)(int power_profile);
 	int (*get_power_profile_mode)(struct smu_context *smu, char *buf);
 	int (*set_power_profile_mode)(struct smu_context *smu, long *input, uint32_t size);
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +7 -68

111 lines not on this page · raw message

Signature · 6 lines
2.21.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

RE: [PATCH 2/2] drm/amd/powerplay: simplify the code of [get|set]_activity_monitor_coeff

Comment inline

Quoted 171 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Wang, Kevin(Yang)
Sent: Monday, April 08, 2019 4:43 PM
To: [email protected]
Cc: Huang, Ray <[email protected]>; Feng, Kenneth <[email protected]>; Wang, Kevin(Yang) <[email protected]>
Subject: [PATCH 2/2] drm/amd/powerplay: simplify the code of [get|set]_activity_monitor_coeff

use smu_update_table_with_arg to replace old code logic

---
 .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h    |  6 --
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c     | 75 ++-----------------
 2 files changed, 7 insertions(+), 74 deletions(-)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +0 -6
index c146b5e884f8..26a7d2c7f4fa 100644
@@ -524,12 +524,6 @@ struct smu_funcs
 					       struct
 dm_pp_wm_sets_with_clock_ranges_soc15 *clock_ranges);
 	int (*set_od8_default_settings)(struct smu_context *smu,
 					bool initialize);
-	int (*get_activity_monitor_coeff)(struct smu_context *smu,
-				      uint8_t *table,
-				      uint16_t workload_type);
-	int (*set_activity_monitor_coeff)(struct smu_context *smu,
-				      uint8_t *table,
-				      uint16_t workload_type);
 	int (*conv_power_profile_to_pplib_workload)(int power_profile);
 	int (*get_power_profile_mode)(struct smu_context *smu, char

*buf);
int (*set_power_profile_mode)(struct smu_context *smu, long
*input, uint32_t size); diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
index 0e4b4b88af24..435cb606d7eb 100644

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -7
@@ -1460,62 +1460,6 @@ static int
 smu_v11_0_set_od8_default_settings(struct smu_context *smu,
 	return 0;
 }
 
-static int smu_v11_0_set_activity_monitor_coeff(struct smu_context *smu,
-				      uint8_t *table, uint16_t workload_type)
-{
-	int ret = 0;
-	memcpy(smu-
 >smu_table.tables[TABLE_ACTIVITY_MONITOR_COEFF].cpu_addr,
-	       table, smu-
 >smu_table.tables[TABLE_ACTIVITY_MONITOR_COEFF].size);
-	ret = smu_send_smc_msg_with_param(smu,

SMU_MSG_SetDriverDramAddrHigh,

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -1
-					  upper_32_bits(smu-
Quoted 1 line

smu_table.tables[TABLE_ACTIVITY_MONITOR_COEFF].mc_address));

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -2
-	if (ret) {
-		pr_err("[%s] Attempt to Set Dram Addr High Failed!",

__func__);

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -3
-		return ret;
-	}
-	ret = smu_send_smc_msg_with_param(smu,

SMU_MSG_SetDriverDramAddrLow,

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -1
-					  lower_32_bits(smu-
Quoted 1 line

smu_table.tables[TABLE_ACTIVITY_MONITOR_COEFF].mc_address));

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -2
-	if (ret) {
-		pr_err("[%s] Attempt to Set Dram Addr Low Failed!",

__func__);

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -3
-		return ret;
-	}
-	ret = smu_send_smc_msg_with_param(smu,

SMU_MSG_TransferTableSmu2Dram,

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -1
-					  TABLE_ACTIVITY_MONITOR_COEFF

| (workload_type << 16));

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -2
-	if (ret) {
-		pr_err("[%s] Attempt to Transfer Table From SMU Failed!",

__func__);

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -11
-		return ret;
-	}
-
-	return ret;
-}
-
-static int smu_v11_0_get_activity_monitor_coeff(struct smu_context *smu,
-				      uint8_t *table, uint16_t workload_type)
-{
-	int ret = 0;
-	ret = smu_send_smc_msg_with_param(smu,

SMU_MSG_SetDriverDramAddrHigh,

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -1
-					  upper_32_bits(smu-
Quoted 1 line

smu_table.tables[TABLE_ACTIVITY_MONITOR_COEFF].mc_address));

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -2
-	if (ret) {
-		pr_err("[%s] Attempt to Set Dram Addr High Failed!",

__func__);

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -4
-		return ret;
-	}
-
-	ret = smu_send_smc_msg_with_param(smu,

SMU_MSG_SetDriverDramAddrLow,

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -1
-					  lower_32_bits(smu-
Quoted 1 line

smu_table.tables[TABLE_ACTIVITY_MONITOR_COEFF].mc_address));

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -2
-	if (ret) {
-		pr_err("[%s] Attempt to Set Dram Addr Low Failed!",

__func__);

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -4
-		return ret;
-	}
-
-	ret = smu_send_smc_msg_with_param(smu,

SMU_MSG_TransferTableSmu2Dram,

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -1
-					  TABLE_ACTIVITY_MONITOR_COEFF

| (workload_type << 16));

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -2
-	if (ret) {
-		pr_err("[%s] Attempt to Transfer Table From SMU Failed!",

__func__);

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -6
-		return ret;
-	}
-
-	return ret;
-}
-
 static int smu_v11_0_conv_power_profile_to_pplib_workload(int

power_profile) {

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -0
 	int pplib_workload = 0;
@@ -1584,9 +1528,8 @@ static int
 smu_v11_0_get_power_profile_mode(struct smu_context *smu, char *buf)
 	for (i = 0; i <= PP_SMC_POWER_PROFILE_CUSTOM; i++) {
 		/* conv PP_SMC_POWER_PROFILE* to

WORKLOAD_PPLIB_*_BIT */
workload_type =
smu_v11_0_conv_power_profile_to_pplib_workload(i);

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -2
-		result = smu_v11_0_get_activity_monitor_coeff(smu,
-							      (uint8_t

*)(&activity_monitor),

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +1 -1
-							      workload_type);
+		result = smu_update_table_with_arg(smu,

TABLE_ACTIVITY_MONITOR_COEFF,

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +1 -0
+						   workload_type,

&activity_monitor, false);

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -0
 		if (result) {
 			pr_err("[%s] Failed to get activity monitor!",

__func__);

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +1 -1
 			return result;
@@ -1658,7 +1601,7 @@ static int
 smu_v11_0_get_power_profile_mode(struct smu_context *smu, char *buf)
 static int smu_v11_0_set_power_profile_mode(struct smu_context *smu,
 long *input, uint32_t size)  {
 	DpmActivityMonitorCoeffInt_t activity_monitor;
-	int workload_type, ret = 0;
+	int workload_type = 0, ret = 0;
 
 	smu->power_profile_mode = input[size];
@@ -1668,9 +1611,8 @@ static int

smu_v11_0_set_power_profile_mode(struct smu_context *smu, long *input

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -0
 	}
 
 	if (smu->power_profile_mode ==

PP_SMC_POWER_PROFILE_CUSTOM) {

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -2
-		ret = smu_v11_0_get_activity_monitor_coeff(smu,
-							   (uint8_t

*)(&activity_monitor),
-
WORKLOAD_PPLIB_CUSTOM_BIT);

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +1 -0
+		ret = smu_update_table_with_arg(smu,

TABLE_ACTIVITY_MONITOR_COEFF,

drivers/gpu/drm/amd/powerplay/smu_v11_0.c

Quoted 1 line
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +1 -0
+						workload_type,

[Quan, Evan] workload_type seems not initialzed as WORKLOAD_PPLIB_CUSTOM_BIT before use. Can you confirm that?

Quoted 39 lines

&activity_monitor, false);

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -0
 		if (ret) {
 			pr_err("[%s] Failed to get activity monitor!",

__func__);

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -0
 			return ret;
@@ -1723,9 +1665,8 @@ static int

smu_v11_0_set_power_profile_mode(struct smu_context *smu, long *input

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -2
 			break;
 		}
 
-		ret = smu_v11_0_set_activity_monitor_coeff(smu,
-							   (uint8_t

*)(&activity_monitor),
-
WORKLOAD_PPLIB_CUSTOM_BIT);

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +1 -0
+		ret = smu_update_table_with_arg(smu,

TABLE_ACTIVITY_MONITOR_COEFF,
+

	WORKLOAD_PPLIB_COMPUTE_BIT, &activity_monitor, true);
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -0
 		if (ret) {
 			pr_err("[%s] Failed to set activity monitor!",

__func__);

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -2
 			return ret;
@@ -1994,8 +1935,6 @@ static const struct smu_funcs smu_v11_0_funcs = {
 	.get_sclk = smu_v11_0_dpm_get_sclk,
 	.get_mclk = smu_v11_0_dpm_get_mclk,
 	.set_od8_default_settings = smu_v11_0_set_od8_default_settings,
-	.get_activity_monitor_coeff =
 smu_v11_0_get_activity_monitor_coeff,
-	.set_activity_monitor_coeff =
 smu_v11_0_set_activity_monitor_coeff,
 	.conv_power_profile_to_pplib_workload =

smu_v11_0_conv_power_profile_to_pplib_workload,

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -1
 	.get_power_profile_mode = smu_v11_0_get_power_profile_mode,
 	.set_power_profile_mode = smu_v11_0_set_power_profile_mode,
--

2.21.0

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): MN2PR12MB3344E5BC17ADD1689F4AEFCAE42D0-rweVpJHSKToDMgCC8P//[email protected]

#6 lore raw

Re: [PATCH 2/2] drm/amd/powerplay: simplify the code of [get|set]_activity_monitor_coeff

@Quan, Evan<mailto:[email protected]>

I remake a new patch v2 to fix it, please help me review it.

Thanks.

Best Regards,
Kevin

________________________________
From: Quan, Evan
Sent: Tuesday, April 9, 2019 9:33:06 AM
To: Wang, Kevin(Yang); [email protected]
Cc: Huang, Ray; Feng, Kenneth; Wang, Kevin(Yang)
Subject: RE: [PATCH 2/2] drm/amd/powerplay: simplify the code of [get|set]_activity_monitor_coeff

Comment inline

Quoted 166 lines

-----Original Message-----
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> On Behalf Of Wang, Kevin(Yang)
Sent: Monday, April 08, 2019 4:43 PM
To: [email protected]
Cc: Huang, Ray <[email protected]>; Feng, Kenneth <[email protected]>; Wang, Kevin(Yang) <[email protected]>
Subject: [PATCH 2/2] drm/amd/powerplay: simplify the code of [get|set]_activity_monitor_coeff

use smu_update_table_with_arg to replace old code logic

---
 .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h    |  6 --
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c     | 75 ++-----------------
 2 files changed, 7 insertions(+), 74 deletions(-)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +0 -6
index c146b5e884f8..26a7d2c7f4fa 100644
@@ -524,12 +524,6 @@ struct smu_funcs
                                              struct
 dm_pp_wm_sets_with_clock_ranges_soc15 *clock_ranges);
       int (*set_od8_default_settings)(struct smu_context *smu,
                                       bool initialize);
-     int (*get_activity_monitor_coeff)(struct smu_context *smu,
-                                   uint8_t *table,
-                                   uint16_t workload_type);
-     int (*set_activity_monitor_coeff)(struct smu_context *smu,
-                                   uint8_t *table,
-                                   uint16_t workload_type);
       int (*conv_power_profile_to_pplib_workload)(int power_profile);
       int (*get_power_profile_mode)(struct smu_context *smu, char

*buf);
int (*set_power_profile_mode)(struct smu_context *smu, long
*input, uint32_t size); diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
index 0e4b4b88af24..435cb606d7eb 100644

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -7
@@ -1460,62 +1460,6 @@ static int
 smu_v11_0_set_od8_default_settings(struct smu_context *smu,
       return 0;
 }
 
-static int smu_v11_0_set_activity_monitor_coeff(struct smu_context *smu,
-                                   uint8_t *table, uint16_t workload_type)
-{
-     int ret = 0;
-     memcpy(smu-
 >smu_table.tables[TABLE_ACTIVITY_MONITOR_COEFF].cpu_addr,
-            table, smu-
 >smu_table.tables[TABLE_ACTIVITY_MONITOR_COEFF].size);
-     ret = smu_send_smc_msg_with_param(smu,

SMU_MSG_SetDriverDramAddrHigh,
- upper_32_bits(smu-

Quoted 1 line

smu_table.tables[TABLE_ACTIVITY_MONITOR_COEFF].mc_address));

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -2
-     if (ret) {
-             pr_err("[%s] Attempt to Set Dram Addr High Failed!",

__func__);

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -3
-             return ret;
-     }
-     ret = smu_send_smc_msg_with_param(smu,

SMU_MSG_SetDriverDramAddrLow,
- lower_32_bits(smu-

Quoted 1 line

smu_table.tables[TABLE_ACTIVITY_MONITOR_COEFF].mc_address));

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -2
-     if (ret) {
-             pr_err("[%s] Attempt to Set Dram Addr Low Failed!",

__func__);

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -3
-             return ret;
-     }
-     ret = smu_send_smc_msg_with_param(smu,

SMU_MSG_TransferTableSmu2Dram,
- TABLE_ACTIVITY_MONITOR_COEFF
| (workload_type << 16));

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -2
-     if (ret) {
-             pr_err("[%s] Attempt to Transfer Table From SMU Failed!",

__func__);

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -11
-             return ret;
-     }
-
-     return ret;
-}
-
-static int smu_v11_0_get_activity_monitor_coeff(struct smu_context *smu,
-                                   uint8_t *table, uint16_t workload_type)
-{
-     int ret = 0;
-     ret = smu_send_smc_msg_with_param(smu,

SMU_MSG_SetDriverDramAddrHigh,
- upper_32_bits(smu-

Quoted 1 line

smu_table.tables[TABLE_ACTIVITY_MONITOR_COEFF].mc_address));

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -2
-     if (ret) {
-             pr_err("[%s] Attempt to Set Dram Addr High Failed!",

__func__);

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -4
-             return ret;
-     }
-
-     ret = smu_send_smc_msg_with_param(smu,

SMU_MSG_SetDriverDramAddrLow,
- lower_32_bits(smu-

Quoted 1 line

smu_table.tables[TABLE_ACTIVITY_MONITOR_COEFF].mc_address));

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -2
-     if (ret) {
-             pr_err("[%s] Attempt to Set Dram Addr Low Failed!",

__func__);

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -4
-             return ret;
-     }
-
-     ret = smu_send_smc_msg_with_param(smu,

SMU_MSG_TransferTableSmu2Dram,
- TABLE_ACTIVITY_MONITOR_COEFF
| (workload_type << 16));

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -2
-     if (ret) {
-             pr_err("[%s] Attempt to Transfer Table From SMU Failed!",

__func__);

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -6
-             return ret;
-     }
-
-     return ret;
-}
-
 static int smu_v11_0_conv_power_profile_to_pplib_workload(int
power_profile)  {
       int pplib_workload = 0;
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -0
@@ -1584,9 +1528,8 @@ static int
 smu_v11_0_get_power_profile_mode(struct smu_context *smu, char *buf)
       for (i = 0; i <= PP_SMC_POWER_PROFILE_CUSTOM; i++) {
               /* conv PP_SMC_POWER_PROFILE* to

WORKLOAD_PPLIB_*_BIT */
workload_type =
smu_v11_0_conv_power_profile_to_pplib_workload(i);

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -2
-             result = smu_v11_0_get_activity_monitor_coeff(smu,
-                                                           (uint8_t

*)(&activity_monitor),

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +1 -1
-                                                           workload_type);
+             result = smu_update_table_with_arg(smu,

TABLE_ACTIVITY_MONITOR_COEFF,
+ workload_type,
&activity_monitor, false);
if (result) {
pr_err("[%s] Failed to get activity monitor!",

__func__);
                       return result;
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +1 -1
@@ -1658,7 +1601,7 @@ static int
 smu_v11_0_get_power_profile_mode(struct smu_context *smu, char *buf)
 static int smu_v11_0_set_power_profile_mode(struct smu_context *smu,
 long *input, uint32_t size)  {
       DpmActivityMonitorCoeffInt_t activity_monitor;
-     int workload_type, ret = 0;
+     int workload_type = 0, ret = 0;
 
       smu->power_profile_mode = input[size];
@@ -1668,9 +1611,8 @@ static int

smu_v11_0_set_power_profile_mode(struct smu_context *smu, long *input

       }

       if (smu->power_profile_mode ==

PP_SMC_POWER_PROFILE_CUSTOM) {

drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -2
-             ret = smu_v11_0_get_activity_monitor_coeff(smu,
-                                                        (uint8_t
Quoted 6 lines

*)(&activity_monitor),
-
WORKLOAD_PPLIB_CUSTOM_BIT);
+ ret = smu_update_table_with_arg(smu,
TABLE_ACTIVITY_MONITOR_COEFF,
+ workload_type,

[Quan, Evan] workload_type seems not initialzed as WORKLOAD_PPLIB_CUSTOM_BIT before use. Can you confirm that?

Quoted 36 lines

&activity_monitor, false);
if (ret) {
pr_err("[%s] Failed to get activity monitor!",

__func__);
                       return ret;
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -0
@@ -1723,9 +1665,8 @@ static int

smu_v11_0_set_power_profile_mode(struct smu_context *smu, long *input

                       break;
               }
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -2
-             ret = smu_v11_0_set_activity_monitor_coeff(smu,
-                                                        (uint8_t

*)(&activity_monitor),
-
WORKLOAD_PPLIB_CUSTOM_BIT);
+ ret = smu_update_table_with_arg(smu,
TABLE_ACTIVITY_MONITOR_COEFF,
+

       WORKLOAD_PPLIB_COMPUTE_BIT, &activity_monitor, true);
               if (ret) {
                       pr_err("[%s] Failed to set activity monitor!",
__func__);
                       return ret;
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -2
@@ -1994,8 +1935,6 @@ static const struct smu_funcs smu_v11_0_funcs = {
       .get_sclk = smu_v11_0_dpm_get_sclk,
       .get_mclk = smu_v11_0_dpm_get_mclk,
       .set_od8_default_settings = smu_v11_0_set_od8_default_settings,
-     .get_activity_monitor_coeff =
 smu_v11_0_get_activity_monitor_coeff,
-     .set_activity_monitor_coeff =
 smu_v11_0_set_activity_monitor_coeff,
       .conv_power_profile_to_pplib_workload =

smu_v11_0_conv_power_profile_to_pplib_workload,

       .get_power_profile_mode = smu_v11_0_get_power_profile_mode,
       .set_power_profile_mode = smu_v11_0_set_power_profile_mode,
Quoted 7 lines

--
2.21.0

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reviewed-by Evan Quan
#7 lore raw
In reply to a message not in the archive
Quoted 85 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Wang, Kevin(Yang)
Sent: Monday, April 08, 2019 4:43 PM
To: [email protected]
Cc: Huang, Ray <[email protected]>; Feng, Kenneth <[email protected]>; Wang, Kevin(Yang) <[email protected]>
Subject: [PATCH 1/2] drm/amd/powerplay: optimization function of smu_update_table

in fact, the firmware need 2 parameter: 1.table_id, 2.XferArg so change the function interface to match the firmware code

---
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c     | 7 +++++--
 drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 5 ++++-
 2 files changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +5 -1
index 7e8c74da6a74..c058c784180e 100644
@@ -97,16 +97,19 @@ int smu_common_read_sensor(struct smu_context
 *smu, enum amd_pp_sensors sensor,
 	return ret;
 }
 
-int smu_update_table(struct smu_context *smu, uint32_t table_id,
+int smu_update_table_with_arg(struct smu_context *smu, uint16_t
+table_id, uint16_t exarg,
 		     void *table_data, bool drv2smu)
 {
 	struct smu_table_context *smu_table = &smu->smu_table;
 	struct smu_table *table = NULL;
 	int ret = 0;
+	uint32_t table_index;
 
 	if (!table_data || table_id >= smu_table->table_count)
 		return -EINVAL;
 
+	table_index = (exarg << 16) | table_id;
+
 	table = &smu_table->tables[table_id];
 
 	if (drv2smu)
@@ -123,7 +126,7 @@ int smu_update_table(struct smu_context *smu,
 uint32_t table_id,
 	ret = smu_send_smc_msg_with_param(smu, drv2smu ?
 

SMU_MSG_TransferTableDram2Smu :

SMU_MSG_TransferTableSmu2Dram,

drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +1 -1
-					  table_id);
+					  table_index);
 	if (ret)
 		return ret;
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +0 -0
index 2083139533e9..c146b5e884f8 100644
@@ -745,8 +745,11 @@ extern int smu_feature_set_enabled(struct

smu_context *smu, int feature_id, bool extern int smu_feature_is_supported(struct smu_context *smu, int feature_id); extern int smu_feature_set_supported(struct smu_context *smu, int feature_id, bool enable);

drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +6 -1
-int smu_update_table(struct smu_context *smu, uint32_t table_id,
+int smu_update_table_with_arg(struct smu_context *smu, uint16_t
+table_id, uint16_t exarg,
 		     void *table_data, bool drv2smu);
+#define smu_update_table(smu, table_id, table_data, drv2smu) \
+	smu_update_table_with_arg((smu), (table_id), 0, (table_data),
+(drv2smu))
+
 bool is_support_sw_smu(struct amdgpu_device *adev);  int

smu_reset(struct smu_context *smu); int smu_common_read_sensor(struct smu_context *smu, enum amd_pp_sensors sensor,
--
2.21.0

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#8 lore raw
In reply to a message not in the archive
Quoted 10 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Wang, Kevin(Yang)
Sent: Monday, April 08, 2019 4:43 PM
To: [email protected]
Cc: Huang, Ray <[email protected]>; Feng, Kenneth <[email protected]>; Wang, Kevin(Yang) <[email protected]>
Subject: [PATCH 1/2] drm/amd/powerplay: optimization function of smu_update_table

Quoted 4 lines

in fact, the firmware need 2 parameter: 1.table_id, 2.XferArg so change the function interface to match the firmware code

Series are Reviewed-by: Huang Rui <[email protected]>

Quoted 71 lines
---
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c     | 7 +++++--
 drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 5 ++++-
 2 files changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +5 -1
index 7e8c74da6a74..c058c784180e 100644
@@ -97,16 +97,19 @@ int smu_common_read_sensor(struct smu_context
 *smu, enum amd_pp_sensors sensor,
 	return ret;
 }
 
-int smu_update_table(struct smu_context *smu, uint32_t table_id,
+int smu_update_table_with_arg(struct smu_context *smu, uint16_t
+table_id, uint16_t exarg,
 		     void *table_data, bool drv2smu)
 {
 	struct smu_table_context *smu_table = &smu->smu_table;
 	struct smu_table *table = NULL;
 	int ret = 0;
+	uint32_t table_index;
 
 	if (!table_data || table_id >= smu_table->table_count)
 		return -EINVAL;
 
+	table_index = (exarg << 16) | table_id;
+
 	table = &smu_table->tables[table_id];
 
 	if (drv2smu)
@@ -123,7 +126,7 @@ int smu_update_table(struct smu_context *smu,
 uint32_t table_id,
 	ret = smu_send_smc_msg_with_param(smu, drv2smu ?
 

SMU_MSG_TransferTableDram2Smu :

SMU_MSG_TransferTableSmu2Dram,

drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +1 -1
-					  table_id);
+					  table_index);
 	if (ret)
 		return ret;
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +0 -0
index 2083139533e9..c146b5e884f8 100644
@@ -745,8 +745,11 @@ extern int smu_feature_set_enabled(struct

smu_context *smu, int feature_id, bool extern int smu_feature_is_supported(struct smu_context *smu, int feature_id); extern int smu_feature_set_supported(struct smu_context *smu, int feature_id, bool enable);

drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +6 -1
-int smu_update_table(struct smu_context *smu, uint32_t table_id,
+int smu_update_table_with_arg(struct smu_context *smu, uint16_t
+table_id, uint16_t exarg,
 		     void *table_data, bool drv2smu);
+#define smu_update_table(smu, table_id, table_data, drv2smu) \
+	smu_update_table_with_arg((smu), (table_id), 0, (table_data),
+(drv2smu))
+
 bool is_support_sw_smu(struct amdgpu_device *adev);  int

smu_reset(struct smu_context *smu); int smu_common_read_sensor(struct smu_context *smu, enum amd_pp_sensors sensor,
--
2.21.0

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx