hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/video/rockchip/mpp/mpp_vepu2.c
....@@ -314,43 +314,40 @@
314314
315315 static void *vepu_prepare(struct mpp_dev *mpp, struct mpp_task *mpp_task)
316316 {
317
- struct mpp_taskqueue *queue = mpp->queue;
318317 struct vepu_dev *enc = to_vepu_dev(mpp);
319318 struct vepu_ccu *ccu = enc->ccu;
320319 unsigned long core_idle;
321320 unsigned long flags;
322
- u32 core_id_max;
323321 s32 core_id;
324322 u32 i;
325323
326324 spin_lock_irqsave(&ccu->lock, flags);
327325
328
- core_idle = queue->core_idle;
329
- core_id_max = queue->core_id_max;
326
+ core_idle = ccu->core_idle;
330327
331
- for (i = 0; i <= core_id_max; i++) {
332
- struct mpp_dev *mpp = queue->cores[i];
328
+ for (i = 0; i < ccu->core_num; i++) {
329
+ struct mpp_dev *mpp = ccu->cores[i];
333330
334331 if (mpp && mpp->disable)
335
- clear_bit(i, &core_idle);
332
+ clear_bit(mpp->core_id, &core_idle);
336333 }
337334
338
- core_id = find_first_bit(&ccu->core_idle, ccu->core_num);
339
- core_id = array_index_nospec(core_id, MPP_MAX_CORE_NUM);
340
- if (core_id >= core_id_max + 1 || !queue->cores[core_id]) {
335
+ core_id = find_first_bit(&core_idle, ccu->core_num);
336
+ if (core_id >= ARRAY_SIZE(ccu->cores)) {
341337 mpp_task = NULL;
342338 mpp_dbg_core("core %d all busy %lx\n", core_id, ccu->core_idle);
343
- } else {
344
- unsigned long core_idle = ccu->core_idle;
345
-
346
- clear_bit(core_id, &ccu->core_idle);
347
- mpp_task->mpp = ccu->cores[core_id];
348
- mpp_task->core_id = core_id;
349
-
350
- mpp_dbg_core("core cnt %d core %d set idle %lx -> %lx\n",
351
- ccu->core_num, core_id, core_idle, ccu->core_idle);
339
+ goto done;
352340 }
353341
342
+ core_id = array_index_nospec(core_id, MPP_MAX_CORE_NUM);
343
+ clear_bit(core_id, &ccu->core_idle);
344
+ mpp_task->mpp = ccu->cores[core_id];
345
+ mpp_task->core_id = core_id;
346
+
347
+ mpp_dbg_core("core cnt %d core %d set idle %lx -> %lx\n",
348
+ ccu->core_num, core_id, core_idle, ccu->core_idle);
349
+
350
+done:
354351 spin_unlock_irqrestore(&ccu->lock, flags);
355352
356353 return mpp_task;
....@@ -1050,7 +1047,8 @@
10501047 ccu_info = ccu->main_core->iommu_info;
10511048 cur_info = enc->mpp.iommu_info;
10521049
1053
- cur_info->domain = ccu_info->domain;
1050
+ if (cur_info)
1051
+ cur_info->domain = ccu_info->domain;
10541052 mpp_iommu_attach(cur_info);
10551053 }
10561054 enc->ccu = ccu;