drm/amd/pm: check negtive return for table entries
Subsystems (3)
PATCH 18/22 drm/amd/pm: check negtive return for table entries
Function hwmgr->hwmgr_func->get_num_of_pp_table_entries(hwmgr) returns a negative number
--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c +6 -5
@@ -30,9 +30,8 @@ int psm_init_power_state_table(struct pp_hwmgr *hwmgr) {int result;unsigned int i; -unsigned int table_entries;struct pp_power_state *state; -int size; +int size, table_entries;if (hwmgr->hwmgr_func->get_num_of_pp_table_entries ==NULL )return 0 ;
@@ -40,15 +39,17 @@ int psm_init_power_state_table(struct pp_hwmgr *hwmgr)if (hwmgr->hwmgr_func->get_power_state_size ==NULL )return 0 ; - hwmgr->num_ps = table_entries = hwmgr->hwmgr_func->get_num_of_pp_table_entries (hwmgr); + table_entries = hwmgr->hwmgr_func->get_num_of_pp_table_entries (hwmgr); - hwmgr->ps_size = size = hwmgr->hwmgr_func->get_power_state_size (hwmgr) + + size = hwmgr->hwmgr_func->get_power_state_size (hwmgr) +sizeof (struct pp_power_state ); -if (table_entries ==0 || size ==0 ) { +if (table_entries <=0 || size ==0 ) {pr_warn ("Please check whether power state management is supported on this asic\n" );return 0 ; } + hwmgr->num_ps = table_entries; + hwmgr->ps_size = size; hwmgr->ps =kcalloc (table_entries, size,GFP_KERNEL );if (hwmgr->ps ==NULL )
Signature · 1 line
2.25.1
[AMD Official Use Only - AMD Internal Distribution Only]
Hi Jesse,
Quoted 53 lines
-----Original Message-----
From: Jesse Zhang <[email protected]>
Sent: Monday, May 13, 2024 3:34 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Huang, Tim <[email protected]>; Zhang, Jesse(Jie) <[email protected]>; Zhang, Jesse(Jie) <[email protected]>
Subject: [PATCH 18/22] drm/amd/pm: check negtive return for table entriesFunction
hwmgr->hwmgr_func->get_num_of_pp_table_entries(hwmgr)returns a negative numberSigned-off-by Jesse Zhang <[email protected]>Suggested-by Tim Huang <[email protected]>--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c +2
-4@@ -30,9 +30,8 @@ int psm_init_power_state_table(struct pp_hwmgr *hwmgr) {int result;unsigned int i; -unsigned int table_entries;struct pp_power_state *state; -int size; +int size, table_entries;if (hwmgr->hwmgr_func->get_num_of_pp_table_entries ==NULL )return 0 ;@@ -40,15 +39,17 @@ int psm_init_power_state_table(struct pp_hwmgr *hwmgr)if (hwmgr->hwmgr_func->get_power_state_size ==NULL )return 0 ; - hwmgr->num_ps = table_entries = hwmgr->hwmgr_func->get_num_of_pp_table_entries (hwmgr); + table_entries = hwmgr->hwmgr_func->get_num_of_pp_table_entries (hwmgr); - hwmgr->ps_size = size =
hwmgr->hwmgr_func->get_power_state_size(hwmgr)+drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c +2
-1+ size = hwmgr->hwmgr_func->get_power_state_size (hwmgr) +sizeof (struct pp_power_state ); -if (table_entries ==0 || size ==0 ) { +if (table_entries <=0 || size ==0 ) { pr_warn("Please check whether power state management is
Quoted 1 line
supported on this asic\n");
As we return 0 here, we still need to set the hwmgr->num_ps and hwmgr->ps_size to 0 here.
Tim Huang
Quoted 10 lines
return 0; }drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c +2
-1+ hwmgr->num_ps = table_entries; + hwmgr->ps_size = size; hwmgr->ps =kcalloc (table_entries, size,GFP_KERNEL );if (hwmgr->ps ==NULL ) --2.25.1
[AMD Official Use Only - AMD Internal Distribution Only]
Hi Tim,
-----Original Message-----
From: Huang, Tim <[email protected]>
Sent: Monday, May 13, 2024 3:40 PM
To: Zhang, Jesse(Jie) <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Zhang, Jesse(Jie) <[email protected]>; Zhang, Jesse(Jie) <[email protected]>
Subject: RE: [PATCH 18/22] drm/amd/pm: check negtive return for table entries
[AMD Official Use Only - AMD Internal Distribution Only]
Hi Jesse,
Quoted 54 lines
-----Original Message-----
From: Jesse Zhang <[email protected]>
Sent: Monday, May 13, 2024 3:34 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Huang, Tim <[email protected]>; Zhang, Jesse(Jie) <[email protected]>; Zhang, Jesse(Jie) <[email protected]>
Subject: [PATCH 18/22] drm/amd/pm: check negtive return for table entriesFunction
hwmgr->hwmgr_func->get_num_of_pp_table_entries(hwmgr)returns a negative numberSigned-off-by Jesse Zhang <[email protected]>Suggested-by Tim Huang <[email protected]>--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c +2
-4@@ -30,9 +30,8 @@ int psm_init_power_state_table(struct pp_hwmgr *hwmgr) {int result;unsigned int i; -unsigned int table_entries;struct pp_power_state *state; -int size; +int size, table_entries;if (hwmgr->hwmgr_func->get_num_of_pp_table_entries ==NULL )return 0 ;@@ -40,15 +39,17 @@ int psm_init_power_state_table(struct pp_hwmgr *hwmgr)if (hwmgr->hwmgr_func->get_power_state_size ==NULL )return 0 ; - hwmgr->num_ps = table_entries = hwmgr->hwmgr_func->get_num_of_pp_table_entries (hwmgr); + table_entries = hwmgr->hwmgr_func->get_num_of_pp_table_entries (hwmgr); - hwmgr->ps_size = size =
hwmgr->hwmgr_func->get_power_state_size(hwmgr)+drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c +2
-1+ size = hwmgr->hwmgr_func->get_power_state_size (hwmgr) +sizeof (struct pp_power_state ); -if (table_entries ==0 || size ==0 ) { +if (table_entries <=0 || size ==0 ) { pr_warn("Please check whether power state management is
Quoted 1 line
supported on this asic\n");
As we return 0 here, we still need to set the hwmgr->num_ps and hwmgr->ps_size to 0 here. [Zhang, Jesse(Jie)] yes, right. Thanks Tim.
Tim Huang
Quoted 10 lines
return 0; }drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c +2
-1+ hwmgr->num_ps = table_entries; + hwmgr->ps_size = size; hwmgr->ps =kcalloc (table_entries, size,GFP_KERNEL );if (hwmgr->ps ==NULL ) --2.25.1