@@ -693,30 +693,21 @@ static ssize_t smu_v13_0_12_get_temp_metrics(struct smu_context *smu,
693693 u32 idx , sensors ;
694694 ssize_t size ;
695695
696- if (type == SMU_TEMP_METRIC_BASEBOARD ) {
697- /* Initialize base board temperature metrics */
698- table_id = SMU_DRIVER_TABLE_BASEBOARD_TEMP_METRICS ;
699- baseboard_temp_metrics =
700- (struct amdgpu_baseboard_temp_metrics_v1_0 * )
701- smu_driver_table_ptr (smu , table_id );
702- size = sizeof (* baseboard_temp_metrics );
703- } else {
704- table_id = SMU_DRIVER_TABLE_GPUBOARD_TEMP_METRICS ;
705- gpuboard_temp_metrics =
706- (struct amdgpu_gpuboard_temp_metrics_v1_0 * )
707- smu_driver_table_ptr (smu , table_id );
708- size = sizeof (* baseboard_temp_metrics );
709- }
710-
711696 ret = smu_v13_0_12_get_system_metrics_table (smu );
712697 if (ret )
713698 return ret ;
714699
715700 sys_table = & tables [SMU_TABLE_PMFW_SYSTEM_METRICS ];
716701 metrics = (SystemMetricsTable_t * )sys_table -> cache .buffer ;
717- smu_driver_table_update_cache_time (smu , table_id );
718702
719- if (type == SMU_TEMP_METRIC_GPUBOARD ) {
703+ switch (type ) {
704+ case SMU_TEMP_METRIC_GPUBOARD :
705+ table_id = SMU_DRIVER_TABLE_GPUBOARD_TEMP_METRICS ;
706+ gpuboard_temp_metrics =
707+ (struct amdgpu_gpuboard_temp_metrics_v1_0 * )
708+ smu_driver_table_ptr (smu , table_id );
709+ size = sizeof (* gpuboard_temp_metrics );
710+
720711 gpuboard_temp_metrics -> accumulation_counter = metrics -> AccumulationCounter ;
721712 gpuboard_temp_metrics -> label_version = metrics -> LabelVersion ;
722713 gpuboard_temp_metrics -> node_id = metrics -> NodeIdentifier ;
@@ -743,7 +734,15 @@ static ssize_t smu_v13_0_12_get_temp_metrics(struct smu_context *smu,
743734 idx ++ ;
744735 }
745736 }
746- } else if (type == SMU_TEMP_METRIC_BASEBOARD ) {
737+ memcpy (table , gpuboard_temp_metrics , size );
738+ break ;
739+ case SMU_TEMP_METRIC_BASEBOARD :
740+ table_id = SMU_DRIVER_TABLE_BASEBOARD_TEMP_METRICS ;
741+ baseboard_temp_metrics =
742+ (struct amdgpu_baseboard_temp_metrics_v1_0 * )
743+ smu_driver_table_ptr (smu , table_id );
744+ size = sizeof (* baseboard_temp_metrics );
745+
747746 baseboard_temp_metrics -> accumulation_counter = metrics -> AccumulationCounter ;
748747 baseboard_temp_metrics -> label_version = metrics -> LabelVersion ;
749748 baseboard_temp_metrics -> node_id = metrics -> NodeIdentifier ;
@@ -758,12 +757,12 @@ static ssize_t smu_v13_0_12_get_temp_metrics(struct smu_context *smu,
758757 idx ++ ;
759758 }
760759 }
761- }
762-
763- if (type == SMU_TEMP_METRIC_BASEBOARD )
764760 memcpy (table , baseboard_temp_metrics , size );
765- else
766- memcpy (table , gpuboard_temp_metrics , size );
761+ break ;
762+ default :
763+ return - EINVAL ;
764+ }
765+ smu_driver_table_update_cache_time (smu , table_id );
767766
768767 return size ;
769768}
0 commit comments