diff options
author | Sunita Nadampalli | 2020-01-23 13:28:52 -0600 |
---|---|---|
committer | Sunita Nadampalli | 2020-01-23 13:30:39 -0600 |
commit | 891c2eee2267eb4b92705ce64531797a0a97b18f (patch) | |
tree | 7758a19838aa0bd2e0146a5616cf3bcb72709d5f | |
parent | 0eba3678300f649e49f03d92d1b624cf0e008008 (diff) | |
download | ti-img-encode-decode-891c2eee2267eb4b92705ce64531797a0a97b18f.tar.gz ti-img-encode-decode-891c2eee2267eb4b92705ce64531797a0a97b18f.tar.xz ti-img-encode-decode-891c2eee2267eb4b92705ce64531797a0a97b18f.zip |
timmlib: encoder: KW fixes for critical and error scenarios
This patch fixes KW critical and error issues from encoder
driver.
Signed-off-by: Sunita Nadampalli <sunitan@ti.com>
-rw-r--r-- | driver/encoder/mtx_fwif.c | 3 | ||||
-rw-r--r-- | driver/encoder/topaz_api.c | 6 | ||||
-rw-r--r-- | timmlib/encoder/mm_enc_create.c | 37 | ||||
-rw-r--r-- | timmlib/encoder/mm_enc_init.c | 31 | ||||
-rw-r--r-- | timmlib/encoder/mm_enc_process.c | 7 |
5 files changed, 49 insertions, 35 deletions
diff --git a/driver/encoder/mtx_fwif.c b/driver/encoder/mtx_fwif.c index 9904519..24f11b6 100644 --- a/driver/encoder/mtx_fwif.c +++ b/driver/encoder/mtx_fwif.c | |||
@@ -819,6 +819,9 @@ int32 mtx_populate_fw_ctx(enum img_codec codec, struct img_fw_context * fw_ctx) | |||
819 | 819 | ||
820 | IMG_DBG_ASSERT(fw_ctx->hw_num_pipes > 0 && fw_ctx->hw_num_pipes <= TOPAZHP_MAX_NUM_PIPES); | 820 | IMG_DBG_ASSERT(fw_ctx->hw_num_pipes > 0 && fw_ctx->hw_num_pipes <= TOPAZHP_MAX_NUM_PIPES); |
821 | 821 | ||
822 | if (fw_ctx->hw_num_pipes <= 0 || fw_ctx->hw_num_pipes > TOPAZHP_MAX_NUM_PIPES) | ||
823 | return IMG_ERROR_INVALID_ID; | ||
824 | |||
822 | for (i = 0; i < fw_ctx->hw_num_pipes; i++) | 825 | for (i = 0; i < fw_ctx->hw_num_pipes; i++) |
823 | fw_ctx->topaz_reg_mem_space_addr[i] = (void *)topaz_mem_space[REG_TOPAZHP_CORE_0 + (4 * i)].cpu_addr; | 826 | fw_ctx->topaz_reg_mem_space_addr[i] = (void *)topaz_mem_space[REG_TOPAZHP_CORE_0 + (4 * i)].cpu_addr; |
824 | 827 | ||
diff --git a/driver/encoder/topaz_api.c b/driver/encoder/topaz_api.c index 354e57e..09d3eb3 100644 --- a/driver/encoder/topaz_api.c +++ b/driver/encoder/topaz_api.c | |||
@@ -1512,6 +1512,9 @@ error_handling: | |||
1512 | } | 1512 | } |
1513 | 1513 | ||
1514 | if (this_package->mtx_info.code_package_fw_buffer) { | 1514 | if (this_package->mtx_info.code_package_fw_buffer) { |
1515 | if (this_package->mtx_info.code_package_fw_buffer->mem_info.dev_virt) | ||
1516 | topaz_mmu_stream_free(str_ctx->mmu_ctx, &this_package->mtx_info.code_package_fw_buffer->mem_info); | ||
1517 | |||
1515 | osa_free(this_package->mtx_info.code_package_fw_buffer); | 1518 | osa_free(this_package->mtx_info.code_package_fw_buffer); |
1516 | this_package->mtx_info.code_package_fw_buffer = NULL; | 1519 | this_package->mtx_info.code_package_fw_buffer = NULL; |
1517 | } | 1520 | } |
@@ -1521,9 +1524,6 @@ error_handling: | |||
1521 | this_package->header_buffer = NULL; | 1524 | this_package->header_buffer = NULL; |
1522 | } | 1525 | } |
1523 | 1526 | ||
1524 | if (this_package->mtx_info.code_package_fw_buffer->mem_info.dev_virt) | ||
1525 | topaz_mmu_stream_free(str_ctx->mmu_ctx, &this_package->mtx_info.code_package_fw_buffer->mem_info); | ||
1526 | |||
1527 | return IMG_ERROR_OUT_OF_MEMORY; | 1527 | return IMG_ERROR_OUT_OF_MEMORY; |
1528 | } | 1528 | } |
1529 | 1529 | ||
diff --git a/timmlib/encoder/mm_enc_create.c b/timmlib/encoder/mm_enc_create.c index 6b9cf02..45af3ea 100644 --- a/timmlib/encoder/mm_enc_create.c +++ b/timmlib/encoder/mm_enc_create.c | |||
@@ -317,9 +317,8 @@ static int32 vxe_enc_s_fmt(struct mm_vxe_enc_fmt *pix_mp, uint32 chId) | |||
317 | 317 | ||
318 | int32_t MM_ENC_BufPrepare(struct mm_buffer *buffer, uint32_t chId) | 318 | int32_t MM_ENC_BufPrepare(struct mm_buffer *buffer, uint32_t chId) |
319 | { | 319 | { |
320 | 320 | struct vxe_enc_ctx *ctx; | |
321 | struct vxe_enc_ctx *ctx = g_MM_ENC_Inst.ch_obj[chId].mm_ctx; | 321 | mm_vxe_buff *mm_buf; |
322 | mm_vxe_buff *mm_buf = g_MM_ENC_Inst.ch_obj[chId].mm_buf; | ||
323 | struct vxe_enc_q_data *queue; | 322 | struct vxe_enc_q_data *queue; |
324 | int32 plane, num_planes, ret = 0; | 323 | int32 plane, num_planes, ret = 0; |
325 | struct vxe_buffer *vxe_buf; | 324 | struct vxe_buffer *vxe_buf; |
@@ -342,6 +341,9 @@ int32_t MM_ENC_BufPrepare(struct mm_buffer *buffer, uint32_t chId) | |||
342 | OSA_PR_ERR("%s buffer->chId is not set correctly, resetting here!!", __func__); | 341 | OSA_PR_ERR("%s buffer->chId is not set correctly, resetting here!!", __func__); |
343 | } | 342 | } |
344 | 343 | ||
344 | ctx = g_MM_ENC_Inst.ch_obj[chId].mm_ctx; | ||
345 | mm_buf = g_MM_ENC_Inst.ch_obj[chId].mm_buf; | ||
346 | |||
345 | vxe_buf = vxe_get_buf(buffer, chId); | 347 | vxe_buf = vxe_get_buf(buffer, chId); |
346 | 348 | ||
347 | if (vxe_buf != NULL) | 349 | if (vxe_buf != NULL) |
@@ -765,21 +767,22 @@ int32_t MM_ENC_Create(mm_vid_create_params *params, uint32_t *ch_Id) | |||
765 | 767 | ||
766 | int32_t MM_ENC_Destroy(uint32_t chId) | 768 | int32_t MM_ENC_Destroy(uint32_t chId) |
767 | { | 769 | { |
768 | 770 | struct vxe_enc_ctx *ctx; | |
769 | struct vxe_enc_ctx *ctx = g_MM_ENC_Inst.ch_obj[chId].mm_ctx; | 771 | struct vxe_dev *vxe; |
770 | struct vxe_dev *vxe = ctx->dev; | 772 | mm_vxe_buff *mm_buf; |
771 | mm_vxe_buff *mm_buf = g_MM_ENC_Inst.ch_obj[chId].mm_buf; | ||
772 | int32 i; | 773 | int32 i; |
773 | 774 | ||
774 | osa_mutex_lock(vxe->mutex); | ||
775 | |||
776 | if (chId >= MAX_NUM_CHANNELS) | 775 | if (chId >= MAX_NUM_CHANNELS) |
777 | { | 776 | { |
778 | osa_mutex_unlock(vxe->mutex); | ||
779 | OSA_PR_ERR("%s Wrong chId passed by App.!!!", __func__); | 777 | OSA_PR_ERR("%s Wrong chId passed by App.!!!", __func__); |
780 | return -OSA_EFAULT; | 778 | return -OSA_EFAULT; |
781 | } | 779 | } |
782 | 780 | ||
781 | ctx = g_MM_ENC_Inst.ch_obj[chId].mm_ctx; | ||
782 | vxe = ctx->dev; | ||
783 | mm_buf = g_MM_ENC_Inst.ch_obj[chId].mm_buf; | ||
784 | |||
785 | osa_mutex_lock(vxe->mutex); | ||
783 | if (ctx->s_fmt_flags & S_FMT_FLAG_STREAM_CREATED) | 786 | if (ctx->s_fmt_flags & S_FMT_FLAG_STREAM_CREATED) |
784 | topaz_stream_destroy(ctx->topaz_str_context); | 787 | topaz_stream_destroy(ctx->topaz_str_context); |
785 | ctx->topaz_str_context = NULL; | 788 | ctx->topaz_str_context = NULL; |
@@ -810,7 +813,7 @@ int32_t MM_ENC_Destroy(uint32_t chId) | |||
810 | 813 | ||
811 | int32_t MM_ENC_StartStreaming(uint32_t chId, mm_buffertype type) | 814 | int32_t MM_ENC_StartStreaming(uint32_t chId, mm_buffertype type) |
812 | { | 815 | { |
813 | struct vxe_enc_ctx *ctx = g_MM_ENC_Inst.ch_obj[chId].mm_ctx; | 816 | struct vxe_enc_ctx *ctx; |
814 | struct vxe_enc_q_data *queue; | 817 | struct vxe_enc_q_data *queue; |
815 | 818 | ||
816 | if (chId >= MAX_NUM_CHANNELS) | 819 | if (chId >= MAX_NUM_CHANNELS) |
@@ -819,15 +822,18 @@ int32_t MM_ENC_StartStreaming(uint32_t chId, mm_buffertype type) | |||
819 | return -OSA_EFAULT; | 822 | return -OSA_EFAULT; |
820 | } | 823 | } |
821 | 824 | ||
825 | ctx = g_MM_ENC_Inst.ch_obj[chId].mm_ctx; | ||
822 | queue = vxe_get_q_data(ctx, type); | 826 | queue = vxe_get_q_data(ctx, type); |
823 | queue->streaming = osa_true; | 827 | |
828 | if (queue) | ||
829 | queue->streaming = osa_true; | ||
824 | 830 | ||
825 | return 0; | 831 | return 0; |
826 | } | 832 | } |
827 | 833 | ||
828 | int32_t MM_ENC_StopStreaming(uint32_t chId, mm_buffertype type) | 834 | int32_t MM_ENC_StopStreaming(uint32_t chId, mm_buffertype type) |
829 | { | 835 | { |
830 | struct vxe_enc_ctx *ctx = g_MM_ENC_Inst.ch_obj[chId].mm_ctx; | 836 | struct vxe_enc_ctx *ctx; |
831 | struct vxe_enc_q_data *queue; | 837 | struct vxe_enc_q_data *queue; |
832 | 838 | ||
833 | if (chId >= MAX_NUM_CHANNELS) | 839 | if (chId >= MAX_NUM_CHANNELS) |
@@ -836,6 +842,8 @@ int32_t MM_ENC_StopStreaming(uint32_t chId, mm_buffertype type) | |||
836 | return -OSA_EFAULT; | 842 | return -OSA_EFAULT; |
837 | } | 843 | } |
838 | 844 | ||
845 | ctx = g_MM_ENC_Inst.ch_obj[chId].mm_ctx; | ||
846 | |||
839 | osa_mutex_lock(ctx->mutex); | 847 | osa_mutex_lock(ctx->mutex); |
840 | if ((! ctx->out_queue.streaming) || (! ctx->cap_queue.streaming)) { | 848 | if ((! ctx->out_queue.streaming) || (! ctx->cap_queue.streaming)) { |
841 | /* Buffers are still in queue for encode, set eos flag */ | 849 | /* Buffers are still in queue for encode, set eos flag */ |
@@ -856,7 +864,8 @@ int32_t MM_ENC_StopStreaming(uint32_t chId, mm_buffertype type) | |||
856 | } | 864 | } |
857 | 865 | ||
858 | queue = vxe_get_q_data(ctx, type); | 866 | queue = vxe_get_q_data(ctx, type); |
859 | queue->streaming = osa_false; | 867 | if (queue) |
868 | queue->streaming = osa_false; | ||
860 | 869 | ||
861 | return 0; | 870 | return 0; |
862 | } | 871 | } |
diff --git a/timmlib/encoder/mm_enc_init.c b/timmlib/encoder/mm_enc_init.c index b83d238..1e9fa59 100644 --- a/timmlib/encoder/mm_enc_init.c +++ b/timmlib/encoder/mm_enc_init.c | |||
@@ -221,7 +221,7 @@ int32 MM_ENC_Init(void) { | |||
221 | ret = img_mem_init(vxe->dev); | 221 | ret = img_mem_init(vxe->dev); |
222 | if (ret) { | 222 | if (ret) { |
223 | OSA_DEV_ERR(vxe->dev, "Failed to initialize memory\n"); | 223 | OSA_DEV_ERR(vxe->dev, "Failed to initialize memory\n"); |
224 | return -OSA_ENOMEM; | 224 | goto exit; |
225 | } | 225 | } |
226 | 226 | ||
227 | INIT_OSA_LIST_HEAD(&vxe->drv_ctx.heaps); | 227 | INIT_OSA_LIST_HEAD(&vxe->drv_ctx.heaps); |
@@ -237,7 +237,7 @@ int32 MM_ENC_Init(void) { | |||
237 | heap = osa_zalloc(sizeof(*heap), OSA_GFP_KERNEL); | 237 | heap = osa_zalloc(sizeof(*heap), OSA_GFP_KERNEL); |
238 | if (!heap) { | 238 | if (!heap) { |
239 | ret = -OSA_ENOMEM; | 239 | ret = -OSA_ENOMEM; |
240 | goto heap_add_failed; | 240 | goto out_heap_added; |
241 | } | 241 | } |
242 | 242 | ||
243 | ret = img_mem_add_heap(&heap_configs[i], &heap->id); | 243 | ret = img_mem_add_heap(&heap_configs[i], &heap->id); |
@@ -245,14 +245,14 @@ int32 MM_ENC_Init(void) { | |||
245 | OSA_DEV_ERR(vxe->dev, "%s: failed to init heap (type %d)!\n", | 245 | OSA_DEV_ERR(vxe->dev, "%s: failed to init heap (type %d)!\n", |
246 | __func__, heap_configs[i].type); | 246 | __func__, heap_configs[i].type); |
247 | osa_free(heap); | 247 | osa_free(heap); |
248 | goto heap_add_failed; | 248 | goto out_heap_added; |
249 | } | 249 | } |
250 | osa_list_add(&heap->list, &vxe->drv_ctx.heaps); | 250 | osa_list_add(&heap->list, &vxe->drv_ctx.heaps); |
251 | 251 | ||
252 | /* Implicitly, first heap is used for internal allocations */ | 252 | /* Implicitly, first heap is used for internal allocations */ |
253 | if (vxe->drv_ctx.internal_heap_id < 0) { | 253 | if (vxe->drv_ctx.internal_heap_id < 0) { |
254 | vxe->drv_ctx.internal_heap_id = heap->id; | 254 | vxe->drv_ctx.internal_heap_id = heap->id; |
255 | OSA_DEV_ERR(vxe->dev, "%s: using heap %d for internal alloc\n", | 255 | OSA_DEV_INFO(vxe->dev, "%s: using heap %d for internal alloc\n", |
256 | __func__, vxe->drv_ctx.internal_heap_id); | 256 | __func__, vxe->drv_ctx.internal_heap_id); |
257 | } | 257 | } |
258 | } | 258 | } |
@@ -263,13 +263,13 @@ int32 MM_ENC_Init(void) { | |||
263 | __func__); | 263 | __func__); |
264 | ret = -OSA_EINVAL; | 264 | ret = -OSA_EINVAL; |
265 | /* Loop registered heaps just for sanity */ | 265 | /* Loop registered heaps just for sanity */ |
266 | goto heap_add_failed; | 266 | goto out_heap_added; |
267 | } | 267 | } |
268 | 268 | ||
269 | ret = vxe_init_mem(vxe); | 269 | ret = vxe_init_mem(vxe); |
270 | if (ret) { | 270 | if (ret) { |
271 | OSA_DEV_ERR(&ctx->dev, "Failed to initialize memory\n"); | 271 | OSA_DEV_ERR(&ctx->dev, "Failed to initialize memory\n"); |
272 | return -OSA_ENOMEM; | 272 | goto out_heap_added; |
273 | } | 273 | } |
274 | 274 | ||
275 | osa_mutex_create(&vxe->mutex); | 275 | osa_mutex_create(&vxe->mutex); |
@@ -282,7 +282,7 @@ int32 MM_ENC_Init(void) { | |||
282 | ret = enc_reg_interrupt(); | 282 | ret = enc_reg_interrupt(); |
283 | if(OSA_STATUS_SOK != ret) | 283 | if(OSA_STATUS_SOK != ret) |
284 | { | 284 | { |
285 | goto exit; | 285 | goto out_free_irq; |
286 | } | 286 | } |
287 | 287 | ||
288 | ctx = osa_zalloc(sizeof(*ctx), OSA_GFP_KERNEL); | 288 | ctx = osa_zalloc(sizeof(*ctx), OSA_GFP_KERNEL); |
@@ -307,7 +307,7 @@ int32 MM_ENC_Init(void) { | |||
307 | osa_idr_init(&vxe->streams); | 307 | osa_idr_init(&vxe->streams); |
308 | if (NULL == vxe->streams) { | 308 | if (NULL == vxe->streams) { |
309 | ret = OSA_ENOMEM; | 309 | ret = OSA_ENOMEM; |
310 | goto topazdd_deinit; | 310 | goto out_topazdd_deinit; |
311 | } | 311 | } |
312 | 312 | ||
313 | ret = init_topaz_core(vxe->topaz_dev_ctx, &vxe->num_pipes, | 313 | ret = init_topaz_core(vxe->topaz_dev_ctx, &vxe->num_pipes, |
@@ -315,7 +315,7 @@ int32 MM_ENC_Init(void) { | |||
315 | vxe_return_resource); | 315 | vxe_return_resource); |
316 | if (ret) { | 316 | if (ret) { |
317 | OSA_DEV_ERR(&ctx->dev, "Failed to initialize topaz core\n"); | 317 | OSA_DEV_ERR(&ctx->dev, "Failed to initialize topaz core\n"); |
318 | goto topaz_core_deinit; | 318 | goto out_topaz_core_deinit; |
319 | } | 319 | } |
320 | 320 | ||
321 | g_MM_ENC_Inst.mm_dev = vxe; | 321 | g_MM_ENC_Inst.mm_dev = vxe; |
@@ -327,19 +327,21 @@ int32 MM_ENC_Init(void) { | |||
327 | 327 | ||
328 | return 0; | 328 | return 0; |
329 | 329 | ||
330 | topaz_core_deinit: | 330 | out_topaz_core_deinit: |
331 | deinit_topaz_core(); | 331 | deinit_topaz_core(); |
332 | 332 | ||
333 | topazdd_deinit: | 333 | out_topazdd_deinit: |
334 | topazdd_deinit(vxe->topaz_dev_ctx); | 334 | topazdd_deinit(vxe->topaz_dev_ctx); |
335 | 335 | ||
336 | out_free_irq: | 336 | out_free_irq: |
337 | osa_free(vxe->ctx); | 337 | osa_free(vxe->ctx); |
338 | osa_mutex_destroy(vxe->mutex); | ||
339 | enc_release_interrupt_resource(); | ||
338 | 340 | ||
339 | out_init: | 341 | out_init: |
340 | vxe_deinit_mem(vxe); | 342 | vxe_deinit_mem(vxe); |
341 | 343 | ||
342 | heap_add_failed: | 344 | out_heap_added: |
343 | while (!osa_list_empty(&vxe->drv_ctx.heaps)) { | 345 | while (!osa_list_empty(&vxe->drv_ctx.heaps)) { |
344 | struct vxe_heap *heap; | 346 | struct vxe_heap *heap; |
345 | 347 | ||
@@ -351,11 +353,8 @@ heap_add_failed: | |||
351 | vxe->drv_ctx.internal_heap_id = VXE_INVALID_ID; | 353 | vxe->drv_ctx.internal_heap_id = VXE_INVALID_ID; |
352 | 354 | ||
353 | exit: | 355 | exit: |
354 | osa_mutex_destroy(vxe->mutex); | ||
355 | enc_release_interrupt_resource(); | ||
356 | osa_free(vxe); | ||
357 | osa_pm_set_module_state_encoder_off(); | 356 | osa_pm_set_module_state_encoder_off(); |
358 | vxe_deinit_mem(vxe); | 357 | osa_free(vxe); |
359 | 358 | ||
360 | return ret; | 359 | return ret; |
361 | } | 360 | } |
diff --git a/timmlib/encoder/mm_enc_process.c b/timmlib/encoder/mm_enc_process.c index 0855d4e..121c85c 100644 --- a/timmlib/encoder/mm_enc_process.c +++ b/timmlib/encoder/mm_enc_process.c | |||
@@ -28,7 +28,7 @@ | |||
28 | int32_t MM_ENC_Process(struct mm_buffer *in_buf, | 28 | int32_t MM_ENC_Process(struct mm_buffer *in_buf, |
29 | struct mm_buffer *out_buf, uint32_t chId) | 29 | struct mm_buffer *out_buf, uint32_t chId) |
30 | { | 30 | { |
31 | struct vxe_enc_ctx *ctx = g_MM_ENC_Inst.ch_obj[chId].mm_ctx; | 31 | struct vxe_enc_ctx *ctx; |
32 | struct vxe_buffer *src_vxeb; | 32 | struct vxe_buffer *src_vxeb; |
33 | struct vxe_buffer *dst_vxeb; | 33 | struct vxe_buffer *dst_vxeb; |
34 | int ret = 0; | 34 | int ret = 0; |
@@ -68,6 +68,8 @@ int32_t MM_ENC_Process(struct mm_buffer *in_buf, | |||
68 | return ret; | 68 | return ret; |
69 | } | 69 | } |
70 | 70 | ||
71 | ctx = g_MM_ENC_Inst.ch_obj[chId].mm_ctx; | ||
72 | |||
71 | osa_mutex_lock(ctx->mutex); | 73 | osa_mutex_lock(ctx->mutex); |
72 | 74 | ||
73 | #ifdef ENABLE_PROFILING | 75 | #ifdef ENABLE_PROFILING |
@@ -147,7 +149,7 @@ int32_t MM_ENC_RegisterCb( | |||
147 | void (*mm_ret_resource)(struct mm_buffer *buf, mm_enc_process_cb cb_type), | 149 | void (*mm_ret_resource)(struct mm_buffer *buf, mm_enc_process_cb cb_type), |
148 | uint32_t chId) | 150 | uint32_t chId) |
149 | { | 151 | { |
150 | struct vxe_enc_ctx *ctx = g_MM_ENC_Inst.ch_obj[chId].mm_ctx; | 152 | struct vxe_enc_ctx *ctx; |
151 | 153 | ||
152 | if (chId >= MAX_NUM_CHANNELS) | 154 | if (chId >= MAX_NUM_CHANNELS) |
153 | { | 155 | { |
@@ -158,6 +160,7 @@ int32_t MM_ENC_RegisterCb( | |||
158 | if(mm_ret_resource == NULL) | 160 | if(mm_ret_resource == NULL) |
159 | return -1; | 161 | return -1; |
160 | 162 | ||
163 | ctx = g_MM_ENC_Inst.ch_obj[chId].mm_ctx; | ||
161 | ctx->mm_return_resource = mm_ret_resource; | 164 | ctx->mm_return_resource = mm_ret_resource; |
162 | return 0; | 165 | return 0; |
163 | 166 | ||