Skip to contentSkip to conversation

drm/amd/powerplay: Fix psm_set_user_performance_state()

PATCH In review Tom St Denis 2 participants 2 messages Sep 5, 2017 – Sep 6, 2017 1 message not in the archive

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

PATCH 1/1 drm/amd/powerplay: Fix psm_set_user_performance_state()

We now pass a pointer to a pointer which seems to be what they meant in the first place. The previous version was modifying a pointer passed by value.

---
 drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c  | 4 ++--
 drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c | 8 ++++----
 drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.h | 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c +2 -2
index 19b6f1148942..d1960c14dd4a 100644
@@ -294,7 +294,7 @@ int hwmgr_handle_task(struct pp_instance *handle, enum amd_pp_task task_id,
 	{
 		enum amd_pm_state_type ps;
 		enum PP_StateUILabel requested_ui_label;
-		struct pp_power_state *requested_ps;
+		struct pp_power_state *requested_ps = NULL;
 
 		if (input == NULL) {
 			ret = -EINVAL;
@@ -303,7 +303,7 @@ int hwmgr_handle_task(struct pp_instance *handle, enum amd_pp_task task_id,
 		ps = *(unsigned long *)input;
 
 		requested_ui_label = power_state_convert(ps);
-		ret = psm_set_user_performance_state(hwmgr, requested_ui_label, requested_ps);
+		ret = psm_set_user_performance_state(hwmgr, requested_ui_label, &requested_ps);
 		if (ret)
 			return ret;
 		ret = psm_adjust_power_state_dynamic(hwmgr, false, requested_ps);
drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c +4 -4
index 7656324957a8..167cdc321db2 100644
@@ -188,19 +188,19 @@ int psm_set_performance_states(struct pp_hwmgr *hwmgr)
 
 int psm_set_user_performance_state(struct pp_hwmgr *hwmgr,
 					enum PP_StateUILabel label_id,
-					struct pp_power_state *state)
+					struct pp_power_state **state)
 {
 	int table_entries;
 	int i;
 
 	table_entries = hwmgr->num_ps;
-	state = hwmgr->ps;
+	*state = hwmgr->ps;
 
 restart_search:
 	for (i = 0; i < table_entries; i++) {
-		if (state->classification.ui_label & label_id)
+		if ((*state)->classification.ui_label & label_id)
 			return 0;
-		state = (struct pp_power_state *)((unsigned long)state + hwmgr->ps_size);
+		*state = (struct pp_power_state *)((uintptr_t)*state + hwmgr->ps_size);
 	}
 
 	switch (label_id) {
drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.h +1 -1
index aa44e60ec1b6..fa1b6825036a 100644
@@ -32,7 +32,7 @@ int psm_set_boot_states(struct pp_hwmgr *hwmgr);
 int psm_set_performance_states(struct pp_hwmgr *hwmgr);
 int psm_set_user_performance_state(struct pp_hwmgr *hwmgr,
 					enum PP_StateUILabel label_id,
-					struct pp_power_state *state);
+					struct pp_power_state **state);
 int psm_adjust_power_state_dynamic(struct pp_hwmgr *hwmgr,
 				bool skip,
 				struct pp_power_state *new_ps);
Signature · 6 lines
2.12.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#2 lore raw
In reply to a message not in the archive

Thanks Tom.

Patch is Reviewed-By: Rex Zhu <[email protected]>

Best Regards
Rex
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Tom St Denis
Sent: Tuesday, September 05, 2017 8:03 PM
To: [email protected]
Cc: StDenis, Tom
Subject: [PATCH] drm/amd/powerplay: Fix psm_set_user_performance_state()

We now pass a pointer to a pointer which seems to be what they meant in the first place. The previous version was modifying a pointer passed by value.

---
 drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c  | 4 ++--  drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c | 8 ++++----  drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.h | 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c +3 -2
index 19b6f1148942..d1960c14dd4a 100644
@@ -294,7 +294,7 @@ int hwmgr_handle_task(struct pp_instance *handle, enum amd_pp_task task_id,
 	{
 		enum amd_pm_state_type ps;
 		enum PP_StateUILabel requested_ui_label;
-		struct pp_power_state *requested_ps;
+		struct pp_power_state *requested_ps = NULL;
 
 		if (input == NULL) {
 			ret = -EINVAL;
@@ -303,7 +303,7 @@ int hwmgr_handle_task(struct pp_instance *handle, enum amd_pp_task task_id,
 		ps = *(unsigned long *)input;
 
 		requested_ui_label = power_state_convert(ps);
-		ret = psm_set_user_performance_state(hwmgr, requested_ui_label, requested_ps);
+		ret = psm_set_user_performance_state(hwmgr, requested_ui_label, 
+&requested_ps);
 		if (ret)
 			return ret;

ret = psm_adjust_power_state_dynamic(hwmgr, false, requested_ps); diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c b/drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c
index 7656324957a8..167cdc321db2 100644

drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c +5 -4
@@ -188,19 +188,19 @@ int psm_set_performance_states(struct pp_hwmgr *hwmgr)
 
 int psm_set_user_performance_state(struct pp_hwmgr *hwmgr,
 					enum PP_StateUILabel label_id,
-					struct pp_power_state *state)
+					struct pp_power_state **state)
 {
 	int table_entries;
 	int i;
 
 	table_entries = hwmgr->num_ps;
-	state = hwmgr->ps;
+	*state = hwmgr->ps;
 
 restart_search:
 	for (i = 0; i < table_entries; i++) {
-		if (state->classification.ui_label & label_id)
+		if ((*state)->classification.ui_label & label_id)
 			return 0;
-		state = (struct pp_power_state *)((unsigned long)state + hwmgr->ps_size);
+		*state = (struct pp_power_state *)((uintptr_t)*state + 
+hwmgr->ps_size);
 	}
 

switch (label_id) {

drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.h +1 -2
index aa44e60ec1b6..fa1b6825036a 100644
@@ -32,7 +32,7 @@ int psm_set_boot_states(struct pp_hwmgr *hwmgr);  int psm_set_performance_states(struct pp_hwmgr *hwmgr);  int psm_set_user_performance_state(struct pp_hwmgr *hwmgr,
 					enum PP_StateUILabel label_id,
-					struct pp_power_state *state);
+					struct pp_power_state **state);
 int psm_adjust_power_state_dynamic(struct pp_hwmgr *hwmgr,
 				bool skip,
 				struct pp_power_state *new_ps);
--

2.12.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