[AMD Official Use Only - AMD Internal Distribution Only] Hi Jesse, > -----Original Message----- > From: Zhang, Jesse(Jie) <Jesse.Zhang@xxxxxxx> > Sent: Monday, May 13, 2024 10:19 AM > To: Zhang, Jesse(Jie) <Jesse.Zhang@xxxxxxx>; > amd-gfx@xxxxxxxxxxxxxxxxxxxxx > Cc: Deucher, Alexander <Alexander.Deucher@xxxxxxx>; Koenig, Christian > <Christian.Koenig@xxxxxxx>; Huang, Tim <Tim.Huang@xxxxxxx> > Subject: RE: [PATCH 18/22] drm/amd/pm: check negtive return for table > entries > > [AMD Official Use Only - AMD Internal Distribution Only] > > Ping ... > > -----Original Message----- > From: Jesse Zhang <jesse.zhang@xxxxxxx> > Sent: Friday, May 10, 2024 10:51 AM > To: amd-gfx@xxxxxxxxxxxxxxxxxxxxx > Cc: Deucher, Alexander <Alexander.Deucher@xxxxxxx>; Koenig, Christian > <Christian.Koenig@xxxxxxx>; Huang, Tim <Tim.Huang@xxxxxxx>; Zhang, > Jesse(Jie) <Jesse.Zhang@xxxxxxx>; Zhang, Jesse(Jie) > <Jesse.Zhang@xxxxxxx> > Subject: [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 > > Signed-off-by: Jesse Zhang <Jesse.Zhang@xxxxxxx> > --- > drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c > b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c > index f4bd8e9357e2..4433ec4e9cf2 100644 > --- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c > +++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/pp_psm.c > @@ -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; > @@ -45,7 +44,7 @@ int psm_init_power_state_table(struct pp_hwmgr > *hwmgr) > hwmgr->ps_size = 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; > } We should need to check this before set the hwmgr->num_ps and hwmgr->ps_size, otherwise we may have incorrect hwmgr->num_ps if meet the condition table_entries < 0. Tim Huang > -- > 2.25.1 >