Skip to content

Commit 91f2b7d

Browse files
Mansur Alisha Shaikmchehab
Mansur Alisha Shaik
authored andcommitted
media: venus: avoid calling core_clk_setrate() concurrently during concurrent video sessions
In existing implementation, core_clk_setrate() is getting called concurrently in concurrent video sessions. Before the previous call to core_clk_setrate returns, new call to core_clk_setrate is invoked from another video session running concurrently. This results in latest calculated frequency being set (higher/lower) instead of actual frequency required for that video session. It also results in stability crashes mention below. These resources are specific to video core, hence keeping under core lock would ensure that they are estimated for all running video sessions and called once for the video core. Crash logs: [ 1.900089] WARNING: CPU: 4 PID: 1 at drivers/opp/debugfs.c:33 opp_debug_remove_one+0x2c/0x48 [ 1.908493] Modules linked in: [ 1.911524] CPU: 4 PID: 1 Comm: swapper/0 Not tainted 5.10.67 Freescale#35 f8edb8c30cf2dd6838495dd9ef9be47af7f5f60c [ 1.921036] Hardware name: Qualcomm Technologies, Inc. sc7280 IDP SKU2 platform (DT) [ 1.928673] pstate: 60800009 (nZCv daif -PAN +UAO -TCO BTYPE=--) [ 1.934608] pc : opp_debug_remove_one+0x2c/0x48 [ 1.939080] lr : opp_debug_remove_one+0x2c/0x48 [ 1.943560] sp : ffffffc011d7b7f0 [ 1.946836] pmr_save: 000000e0 [ 1.949854] x29: ffffffc011d7b7f0 x28: ffffffc010733bbc [ 1.955104] x27: ffffffc010733ba8 x26: ffffff8083cedd00 [ 1.960355] x25: 0000000000000001 x24: 0000000000000000 [ 1.965603] x23: ffffff8083cc2878 x22: ffffff8083ceb900 [ 1.970852] x21: ffffff8083ceb910 x20: ffffff8083cc2800 [ 1.976101] x19: ffffff8083ceb900 x18: 00000000ffff0a10 [ 1.981352] x17: ffffff80837a5620 x16: 00000000000000ec [ 1.986601] x15: ffffffc010519ad4 x14: 0000000000000003 [ 1.991849] x13: 0000000000000004 x12: 0000000000000001 [ 1.997100] x11: c0000000ffffdfff x10: 00000000ffffffff [ 2.002348] x9 : d2627c580300dc00 x8 : d2627c580300dc00 [ 2.007596] x7 : 0720072007200720 x6 : ffffff80802ecf00 [ 2.012845] x5 : 0000000000190004 x4 : 0000000000000000 [ 2.018094] x3 : ffffffc011d7b478 x2 : ffffffc011d7b480 [ 2.023343] x1 : 00000000ffffdfff x0 : 0000000000000017 [ 2.028594] Call trace: [ 2.031022] opp_debug_remove_one+0x2c/0x48 [ 2.035160] dev_pm_opp_put+0x94/0xb0 [ 2.038780] _opp_remove_all+0x7c/0xc8 [ 2.042486] _opp_remove_all_static+0x54/0x7c [ 2.046796] dev_pm_opp_remove_table+0x74/0x98 [ 2.051183] devm_pm_opp_of_table_release+0x18/0x24 [ 2.056001] devm_action_release+0x1c/0x28 [ 2.060053] release_nodes+0x23c/0x2b8 [ 2.063760] devres_release_group+0xcc/0xd0 [ 2.067900] component_bind+0xac/0x168 [ 2.071608] component_bind_all+0x98/0x124 [ 2.075664] msm_drm_bind+0x1e8/0x678 [ 2.079287] try_to_bring_up_master+0x60/0x134 [ 2.083674] component_master_add_with_match+0xd8/0x120 [ 2.088834] msm_pdev_probe+0x20c/0x2a0 [ 2.092629] platform_drv_probe+0x9c/0xbc [ 2.096598] really_probe+0x11c/0x46c [ 2.100217] driver_probe_device+0x8c/0xf0 [ 2.104270] device_driver_attach+0x54/0x78 [ 2.108407] __driver_attach+0x48/0x148 [ 2.112201] bus_for_each_dev+0x88/0xd4 [ 2.115998] driver_attach+0x2c/0x38 [ 2.119534] bus_add_driver+0x10c/0x200 [ 2.123330] driver_register+0x6c/0x104 [ 2.127122] __platform_driver_register+0x4c/0x58 [ 2.131767] msm_drm_register+0x6c/0x70 [ 2.135560] do_one_initcall+0x64/0x23c [ 2.139357] do_initcall_level+0xac/0x15c [ 2.143321] do_initcalls+0x5c/0x9c [ 2.146778] do_basic_setup+0x2c/0x38 [ 2.150401] kernel_init_freeable+0xf8/0x15c [ 2.154622] kernel_init+0x1c/0x11c [ 2.158079] ret_from_fork+0x10/0x30 [ 2.161615] ---[ end trace a2cc45a0f784b212 ]--- [ 2.166272] Removing OPP: 300000000 Signed-off-by: Mansur Alisha Shaik <[email protected]> Signed-off-by: Stanimir Varbanov <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent b1f9bb8 commit 91f2b7d

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

drivers/media/platform/qcom/venus/pm_helpers.c

+14-14
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,12 @@ static u32 load_per_type(struct venus_core *core, u32 session_type)
163163
struct venus_inst *inst = NULL;
164164
u32 mbs_per_sec = 0;
165165

166-
mutex_lock(&core->lock);
167166
list_for_each_entry(inst, &core->instances, list) {
168167
if (inst->session_type != session_type)
169168
continue;
170169

171170
mbs_per_sec += load_per_instance(inst);
172171
}
173-
mutex_unlock(&core->lock);
174172

175173
return mbs_per_sec;
176174
}
@@ -219,14 +217,12 @@ static int load_scale_bw(struct venus_core *core)
219217
struct venus_inst *inst = NULL;
220218
u32 mbs_per_sec, avg, peak, total_avg = 0, total_peak = 0;
221219

222-
mutex_lock(&core->lock);
223220
list_for_each_entry(inst, &core->instances, list) {
224221
mbs_per_sec = load_per_instance(inst);
225222
mbs_to_bw(inst, mbs_per_sec, &avg, &peak);
226223
total_avg += avg;
227224
total_peak += peak;
228225
}
229-
mutex_unlock(&core->lock);
230226

231227
/*
232228
* keep minimum bandwidth vote for "video-mem" path,
@@ -253,8 +249,9 @@ static int load_scale_v1(struct venus_inst *inst)
253249
struct device *dev = core->dev;
254250
u32 mbs_per_sec;
255251
unsigned int i;
256-
int ret;
252+
int ret = 0;
257253

254+
mutex_lock(&core->lock);
258255
mbs_per_sec = load_per_type(core, VIDC_SESSION_TYPE_ENC) +
259256
load_per_type(core, VIDC_SESSION_TYPE_DEC);
260257

@@ -279,17 +276,19 @@ static int load_scale_v1(struct venus_inst *inst)
279276
if (ret) {
280277
dev_err(dev, "failed to set clock rate %lu (%d)\n",
281278
freq, ret);
282-
return ret;
279+
goto exit;
283280
}
284281

285282
ret = load_scale_bw(core);
286283
if (ret) {
287284
dev_err(dev, "failed to set bandwidth (%d)\n",
288285
ret);
289-
return ret;
286+
goto exit;
290287
}
291288

292-
return 0;
289+
exit:
290+
mutex_unlock(&core->lock);
291+
return ret;
293292
}
294293

295294
static int core_get_v1(struct venus_core *core)
@@ -1116,13 +1115,13 @@ static int load_scale_v4(struct venus_inst *inst)
11161115
struct device *dev = core->dev;
11171116
unsigned long freq = 0, freq_core1 = 0, freq_core2 = 0;
11181117
unsigned long filled_len = 0;
1119-
int i, ret;
1118+
int i, ret = 0;
11201119

11211120
for (i = 0; i < inst->num_input_bufs; i++)
11221121
filled_len = max(filled_len, inst->payloads[i]);
11231122

11241123
if (inst->session_type == VIDC_SESSION_TYPE_DEC && !filled_len)
1125-
return 0;
1124+
return ret;
11261125

11271126
freq = calculate_inst_freq(inst, filled_len);
11281127
inst->clk_data.freq = freq;
@@ -1138,7 +1137,6 @@ static int load_scale_v4(struct venus_inst *inst)
11381137
freq_core2 += inst->clk_data.freq;
11391138
}
11401139
}
1141-
mutex_unlock(&core->lock);
11421140

11431141
freq = max(freq_core1, freq_core2);
11441142

@@ -1163,17 +1161,19 @@ static int load_scale_v4(struct venus_inst *inst)
11631161
if (ret) {
11641162
dev_err(dev, "failed to set clock rate %lu (%d)\n",
11651163
freq, ret);
1166-
return ret;
1164+
goto exit;
11671165
}
11681166

11691167
ret = load_scale_bw(core);
11701168
if (ret) {
11711169
dev_err(dev, "failed to set bandwidth (%d)\n",
11721170
ret);
1173-
return ret;
1171+
goto exit;
11741172
}
11751173

1176-
return 0;
1174+
exit:
1175+
mutex_unlock(&core->lock);
1176+
return ret;
11771177
}
11781178

11791179
static const struct venus_pm_ops pm_ops_v4 = {

0 commit comments

Comments
 (0)