@@ -163,14 +163,12 @@ static u32 load_per_type(struct venus_core *core, u32 session_type)
163
163
struct venus_inst * inst = NULL ;
164
164
u32 mbs_per_sec = 0 ;
165
165
166
- mutex_lock (& core -> lock );
167
166
list_for_each_entry (inst , & core -> instances , list ) {
168
167
if (inst -> session_type != session_type )
169
168
continue ;
170
169
171
170
mbs_per_sec += load_per_instance (inst );
172
171
}
173
- mutex_unlock (& core -> lock );
174
172
175
173
return mbs_per_sec ;
176
174
}
@@ -219,14 +217,12 @@ static int load_scale_bw(struct venus_core *core)
219
217
struct venus_inst * inst = NULL ;
220
218
u32 mbs_per_sec , avg , peak , total_avg = 0 , total_peak = 0 ;
221
219
222
- mutex_lock (& core -> lock );
223
220
list_for_each_entry (inst , & core -> instances , list ) {
224
221
mbs_per_sec = load_per_instance (inst );
225
222
mbs_to_bw (inst , mbs_per_sec , & avg , & peak );
226
223
total_avg += avg ;
227
224
total_peak += peak ;
228
225
}
229
- mutex_unlock (& core -> lock );
230
226
231
227
/*
232
228
* keep minimum bandwidth vote for "video-mem" path,
@@ -253,8 +249,9 @@ static int load_scale_v1(struct venus_inst *inst)
253
249
struct device * dev = core -> dev ;
254
250
u32 mbs_per_sec ;
255
251
unsigned int i ;
256
- int ret ;
252
+ int ret = 0 ;
257
253
254
+ mutex_lock (& core -> lock );
258
255
mbs_per_sec = load_per_type (core , VIDC_SESSION_TYPE_ENC ) +
259
256
load_per_type (core , VIDC_SESSION_TYPE_DEC );
260
257
@@ -279,17 +276,19 @@ static int load_scale_v1(struct venus_inst *inst)
279
276
if (ret ) {
280
277
dev_err (dev , "failed to set clock rate %lu (%d)\n" ,
281
278
freq , ret );
282
- return ret ;
279
+ goto exit ;
283
280
}
284
281
285
282
ret = load_scale_bw (core );
286
283
if (ret ) {
287
284
dev_err (dev , "failed to set bandwidth (%d)\n" ,
288
285
ret );
289
- return ret ;
286
+ goto exit ;
290
287
}
291
288
292
- return 0 ;
289
+ exit :
290
+ mutex_unlock (& core -> lock );
291
+ return ret ;
293
292
}
294
293
295
294
static int core_get_v1 (struct venus_core * core )
@@ -1116,13 +1115,13 @@ static int load_scale_v4(struct venus_inst *inst)
1116
1115
struct device * dev = core -> dev ;
1117
1116
unsigned long freq = 0 , freq_core1 = 0 , freq_core2 = 0 ;
1118
1117
unsigned long filled_len = 0 ;
1119
- int i , ret ;
1118
+ int i , ret = 0 ;
1120
1119
1121
1120
for (i = 0 ; i < inst -> num_input_bufs ; i ++ )
1122
1121
filled_len = max (filled_len , inst -> payloads [i ]);
1123
1122
1124
1123
if (inst -> session_type == VIDC_SESSION_TYPE_DEC && !filled_len )
1125
- return 0 ;
1124
+ return ret ;
1126
1125
1127
1126
freq = calculate_inst_freq (inst , filled_len );
1128
1127
inst -> clk_data .freq = freq ;
@@ -1138,7 +1137,6 @@ static int load_scale_v4(struct venus_inst *inst)
1138
1137
freq_core2 += inst -> clk_data .freq ;
1139
1138
}
1140
1139
}
1141
- mutex_unlock (& core -> lock );
1142
1140
1143
1141
freq = max (freq_core1 , freq_core2 );
1144
1142
@@ -1163,17 +1161,19 @@ static int load_scale_v4(struct venus_inst *inst)
1163
1161
if (ret ) {
1164
1162
dev_err (dev , "failed to set clock rate %lu (%d)\n" ,
1165
1163
freq , ret );
1166
- return ret ;
1164
+ goto exit ;
1167
1165
}
1168
1166
1169
1167
ret = load_scale_bw (core );
1170
1168
if (ret ) {
1171
1169
dev_err (dev , "failed to set bandwidth (%d)\n" ,
1172
1170
ret );
1173
- return ret ;
1171
+ goto exit ;
1174
1172
}
1175
1173
1176
- return 0 ;
1174
+ exit :
1175
+ mutex_unlock (& core -> lock );
1176
+ return ret ;
1177
1177
}
1178
1178
1179
1179
static const struct venus_pm_ops pm_ops_v4 = {
0 commit comments