26
26
#include <linux/module.h>
27
27
#include <linux/moduleparam.h>
28
28
#include <linux/fs.h>
29
+ #include <linux/cleanup.h>
29
30
30
31
#include <acpi/cppc_acpi.h>
31
32
@@ -127,11 +128,12 @@ static void amd_pstate_ut_check_perf(u32 index)
127
128
u32 highest_perf = 0 , nominal_perf = 0 , lowest_nonlinear_perf = 0 , lowest_perf = 0 ;
128
129
u64 cap1 = 0 ;
129
130
struct cppc_perf_caps cppc_perf ;
130
- struct cpufreq_policy * policy = NULL ;
131
131
struct amd_cpudata * cpudata = NULL ;
132
132
union perf_cached cur_perf ;
133
133
134
134
for_each_possible_cpu (cpu ) {
135
+ struct cpufreq_policy * policy __free (put_cpufreq_policy ) = NULL ;
136
+
135
137
policy = cpufreq_cpu_get (cpu );
136
138
if (!policy )
137
139
break ;
@@ -142,7 +144,7 @@ static void amd_pstate_ut_check_perf(u32 index)
142
144
if (ret ) {
143
145
amd_pstate_ut_cases [index ].result = AMD_PSTATE_UT_RESULT_FAIL ;
144
146
pr_err ("%s cppc_get_perf_caps ret=%d error!\n" , __func__ , ret );
145
- goto skip_test ;
147
+ return ;
146
148
}
147
149
148
150
highest_perf = cppc_perf .highest_perf ;
@@ -154,7 +156,7 @@ static void amd_pstate_ut_check_perf(u32 index)
154
156
if (ret ) {
155
157
amd_pstate_ut_cases [index ].result = AMD_PSTATE_UT_RESULT_FAIL ;
156
158
pr_err ("%s read CPPC_CAP1 ret=%d error!\n" , __func__ , ret );
157
- goto skip_test ;
159
+ return ;
158
160
}
159
161
160
162
highest_perf = AMD_CPPC_HIGHEST_PERF (cap1 );
@@ -167,7 +169,7 @@ static void amd_pstate_ut_check_perf(u32 index)
167
169
if (highest_perf != cur_perf .highest_perf && !cpudata -> hw_prefcore ) {
168
170
pr_err ("%s cpu%d highest=%d %d highest perf doesn't match\n" ,
169
171
__func__ , cpu , highest_perf , cur_perf .highest_perf );
170
- goto skip_test ;
172
+ return ;
171
173
}
172
174
if (nominal_perf != cur_perf .nominal_perf ||
173
175
(lowest_nonlinear_perf != cur_perf .lowest_nonlinear_perf ) ||
@@ -177,7 +179,7 @@ static void amd_pstate_ut_check_perf(u32 index)
177
179
__func__ , cpu , nominal_perf , cur_perf .nominal_perf ,
178
180
lowest_nonlinear_perf , cur_perf .lowest_nonlinear_perf ,
179
181
lowest_perf , cur_perf .lowest_perf );
180
- goto skip_test ;
182
+ return ;
181
183
}
182
184
183
185
if (!((highest_perf >= nominal_perf ) &&
@@ -188,15 +190,11 @@ static void amd_pstate_ut_check_perf(u32 index)
188
190
pr_err ("%s cpu%d highest=%d >= nominal=%d > lowest_nonlinear=%d > lowest=%d > 0, the formula is incorrect!\n" ,
189
191
__func__ , cpu , highest_perf , nominal_perf ,
190
192
lowest_nonlinear_perf , lowest_perf );
191
- goto skip_test ;
193
+ return ;
192
194
}
193
- cpufreq_cpu_put (policy );
194
195
}
195
196
196
197
amd_pstate_ut_cases [index ].result = AMD_PSTATE_UT_RESULT_PASS ;
197
- return ;
198
- skip_test :
199
- cpufreq_cpu_put (policy );
200
198
}
201
199
202
200
/*
@@ -207,10 +205,11 @@ static void amd_pstate_ut_check_perf(u32 index)
207
205
static void amd_pstate_ut_check_freq (u32 index )
208
206
{
209
207
int cpu = 0 ;
210
- struct cpufreq_policy * policy = NULL ;
211
208
struct amd_cpudata * cpudata = NULL ;
212
209
213
210
for_each_possible_cpu (cpu ) {
211
+ struct cpufreq_policy * policy __free (put_cpufreq_policy ) = NULL ;
212
+
214
213
policy = cpufreq_cpu_get (cpu );
215
214
if (!policy )
216
215
break ;
@@ -224,14 +223,14 @@ static void amd_pstate_ut_check_freq(u32 index)
224
223
pr_err ("%s cpu%d max=%d >= nominal=%d > lowest_nonlinear=%d > min=%d > 0, the formula is incorrect!\n" ,
225
224
__func__ , cpu , policy -> cpuinfo .max_freq , cpudata -> nominal_freq ,
226
225
cpudata -> lowest_nonlinear_freq , policy -> cpuinfo .min_freq );
227
- goto skip_test ;
226
+ return ;
228
227
}
229
228
230
229
if (cpudata -> lowest_nonlinear_freq != policy -> min ) {
231
230
amd_pstate_ut_cases [index ].result = AMD_PSTATE_UT_RESULT_FAIL ;
232
231
pr_err ("%s cpu%d cpudata_lowest_nonlinear_freq=%d policy_min=%d, they should be equal!\n" ,
233
232
__func__ , cpu , cpudata -> lowest_nonlinear_freq , policy -> min );
234
- goto skip_test ;
233
+ return ;
235
234
}
236
235
237
236
if (cpudata -> boost_supported ) {
@@ -243,20 +242,16 @@ static void amd_pstate_ut_check_freq(u32 index)
243
242
pr_err ("%s cpu%d policy_max=%d should be equal cpu_max=%d or cpu_nominal=%d !\n" ,
244
243
__func__ , cpu , policy -> max , policy -> cpuinfo .max_freq ,
245
244
cpudata -> nominal_freq );
246
- goto skip_test ;
245
+ return ;
247
246
}
248
247
} else {
249
248
amd_pstate_ut_cases [index ].result = AMD_PSTATE_UT_RESULT_FAIL ;
250
249
pr_err ("%s cpu%d must support boost!\n" , __func__ , cpu );
251
- goto skip_test ;
250
+ return ;
252
251
}
253
- cpufreq_cpu_put (policy );
254
252
}
255
253
256
254
amd_pstate_ut_cases [index ].result = AMD_PSTATE_UT_RESULT_PASS ;
257
- return ;
258
- skip_test :
259
- cpufreq_cpu_put (policy );
260
255
}
261
256
262
257
static int amd_pstate_set_mode (enum amd_pstate_mode mode )
0 commit comments