Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/amd/pm: Use macro to initialize metrics table

Helps to keep a build time check about usage of right datatype and
avoids maintenance as new versions get added.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Yang Wang <kevinyang.wang@amd.com>
Reviewed-by: Asad Kamal <asad.kamal@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Lijo Lazar and committed by
Alex Deucher
1327d8f4 2ed4fd99

+12 -69
-67
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c
··· 1051 1051 false); 1052 1052 } 1053 1053 1054 - void smu_cmn_init_soft_gpu_metrics(void *table, uint8_t frev, uint8_t crev) 1055 - { 1056 - struct metrics_table_header *header = (struct metrics_table_header *)table; 1057 - uint16_t structure_size; 1058 - 1059 - #define METRICS_VERSION(a, b) ((a << 16) | b) 1060 - 1061 - switch (METRICS_VERSION(frev, crev)) { 1062 - case METRICS_VERSION(1, 0): 1063 - structure_size = sizeof(struct gpu_metrics_v1_0); 1064 - break; 1065 - case METRICS_VERSION(1, 1): 1066 - structure_size = sizeof(struct gpu_metrics_v1_1); 1067 - break; 1068 - case METRICS_VERSION(1, 2): 1069 - structure_size = sizeof(struct gpu_metrics_v1_2); 1070 - break; 1071 - case METRICS_VERSION(1, 3): 1072 - structure_size = sizeof(struct gpu_metrics_v1_3); 1073 - break; 1074 - case METRICS_VERSION(1, 4): 1075 - structure_size = sizeof(struct gpu_metrics_v1_4); 1076 - break; 1077 - case METRICS_VERSION(1, 5): 1078 - structure_size = sizeof(struct gpu_metrics_v1_5); 1079 - break; 1080 - case METRICS_VERSION(1, 6): 1081 - structure_size = sizeof(struct gpu_metrics_v1_6); 1082 - break; 1083 - case METRICS_VERSION(1, 7): 1084 - structure_size = sizeof(struct gpu_metrics_v1_7); 1085 - break; 1086 - case METRICS_VERSION(1, 8): 1087 - structure_size = sizeof(struct gpu_metrics_v1_8); 1088 - break; 1089 - case METRICS_VERSION(2, 0): 1090 - structure_size = sizeof(struct gpu_metrics_v2_0); 1091 - break; 1092 - case METRICS_VERSION(2, 1): 1093 - structure_size = sizeof(struct gpu_metrics_v2_1); 1094 - break; 1095 - case METRICS_VERSION(2, 2): 1096 - structure_size = sizeof(struct gpu_metrics_v2_2); 1097 - break; 1098 - case METRICS_VERSION(2, 3): 1099 - structure_size = sizeof(struct gpu_metrics_v2_3); 1100 - break; 1101 - case METRICS_VERSION(2, 4): 1102 - structure_size = sizeof(struct gpu_metrics_v2_4); 1103 - break; 1104 - case METRICS_VERSION(3, 0): 1105 - structure_size = sizeof(struct gpu_metrics_v3_0); 1106 - break; 1107 - default: 1108 - return; 1109 - } 1110 - 1111 - #undef METRICS_VERSION 1112 - 1113 - memset(header, 0xFF, structure_size); 1114 - 1115 - header->format_revision = frev; 1116 - header->content_revision = crev; 1117 - header->structure_size = structure_size; 1118 - 1119 - } 1120 - 1121 1054 int smu_cmn_set_mp1_state(struct smu_context *smu, 1122 1055 enum pp_mp1_state mp1_state) 1123 1056 {
+12 -2
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h
··· 40 40 #define SMU_IH_INTERRUPT_CONTEXT_ID_FAN_ABNORMAL 0x8 41 41 #define SMU_IH_INTERRUPT_CONTEXT_ID_FAN_RECOVERY 0x9 42 42 43 + #define smu_cmn_init_soft_gpu_metrics(ptr, frev, crev) \ 44 + do { \ 45 + typecheck(struct gpu_metrics_v##frev##_##crev, \ 46 + typeof(*(ptr))); \ 47 + struct metrics_table_header *header = \ 48 + (struct metrics_table_header *)(ptr); \ 49 + memset(header, 0xFF, sizeof(*(ptr))); \ 50 + header->format_revision = frev; \ 51 + header->content_revision = crev; \ 52 + header->structure_size = sizeof(*(ptr)); \ 53 + } while (0) 54 + 43 55 extern const int link_speed[]; 44 56 45 57 /* Helper to Convert from PCIE Gen 1/2/3/4/5/6 to 0.1 GT/s speed units */ ··· 136 124 bool bypass_cache); 137 125 138 126 int smu_cmn_get_combo_pptable(struct smu_context *smu); 139 - 140 - void smu_cmn_init_soft_gpu_metrics(void *table, uint8_t frev, uint8_t crev); 141 127 142 128 int smu_cmn_set_mp1_state(struct smu_context *smu, 143 129 enum pp_mp1_state mp1_state);