Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: venus: factor out inst destruction routine

Factor out common instance destruction code into
a common function.

Suggested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>

authored by

Sergey Senozhatsky and committed by
Hans Verkuil
1b3bb4d6 45b1a1b3

+31 -56
+25
drivers/media/platform/qcom/venus/core.c
··· 19 19 #include <linux/pm_domain.h> 20 20 #include <linux/pm_runtime.h> 21 21 #include <media/videobuf2-v4l2.h> 22 + #include <media/v4l2-ctrls.h> 22 23 #include <media/v4l2-mem2mem.h> 23 24 #include <media/v4l2-ioctl.h> 24 25 ··· 502 501 503 502 return ret; 504 503 } 504 + 505 + void venus_close_common(struct venus_inst *inst) 506 + { 507 + /* 508 + * First, remove the inst from the ->instances list, so that 509 + * to_instance() will return NULL. 510 + */ 511 + hfi_session_destroy(inst); 512 + /* 513 + * Second, make sure we don't have IRQ/IRQ-thread currently running 514 + * or pending execution, which would race with the inst destruction. 515 + */ 516 + synchronize_irq(inst->core->irq); 517 + 518 + v4l2_m2m_ctx_release(inst->m2m_ctx); 519 + v4l2_m2m_release(inst->m2m_dev); 520 + v4l2_fh_del(&inst->fh); 521 + v4l2_fh_exit(&inst->fh); 522 + v4l2_ctrl_handler_free(&inst->ctrl_handler); 523 + 524 + mutex_destroy(&inst->lock); 525 + mutex_destroy(&inst->ctx_q_lock); 526 + } 527 + EXPORT_SYMBOL_GPL(venus_close_common); 505 528 506 529 static __maybe_unused int venus_runtime_resume(struct device *dev) 507 530 {
+2
drivers/media/platform/qcom/venus/core.h
··· 568 568 (core)->venus_ver.minor == vminor && 569 569 (core)->venus_ver.rev <= vrev); 570 570 } 571 + 572 + void venus_close_common(struct venus_inst *inst); 571 573 #endif
+2 -22
drivers/media/platform/qcom/venus/vdec.c
··· 1735 1735 err_session_destroy: 1736 1736 hfi_session_destroy(inst); 1737 1737 err_ctrl_deinit: 1738 - vdec_ctrl_deinit(inst); 1738 + v4l2_ctrl_handler_free(&inst->ctrl_handler); 1739 1739 err_free: 1740 1740 kfree(inst); 1741 1741 return ret; ··· 1746 1746 struct venus_inst *inst = to_inst(file); 1747 1747 1748 1748 vdec_pm_get(inst); 1749 - 1750 1749 cancel_work_sync(&inst->delayed_process_work); 1751 - /* 1752 - * First, remove the inst from the ->instances list, so that 1753 - * to_instance() will return NULL. 1754 - */ 1755 - hfi_session_destroy(inst); 1756 - /* 1757 - * Second, make sure we don't have IRQ/IRQ-thread currently running 1758 - * or pending execution, which would race with the inst destruction. 1759 - */ 1760 - synchronize_irq(inst->core->irq); 1761 - 1762 - v4l2_m2m_ctx_release(inst->m2m_ctx); 1763 - v4l2_m2m_release(inst->m2m_dev); 1750 + venus_close_common(inst); 1764 1751 ida_destroy(&inst->dpb_ids); 1765 - v4l2_fh_del(&inst->fh); 1766 - v4l2_fh_exit(&inst->fh); 1767 - vdec_ctrl_deinit(inst); 1768 - 1769 - mutex_destroy(&inst->lock); 1770 - mutex_destroy(&inst->ctx_q_lock); 1771 - 1772 1752 vdec_pm_put(inst, false); 1773 1753 1774 1754 kfree(inst);
-1
drivers/media/platform/qcom/venus/vdec.h
··· 9 9 struct venus_inst; 10 10 11 11 int vdec_ctrl_init(struct venus_inst *inst); 12 - void vdec_ctrl_deinit(struct venus_inst *inst); 13 12 14 13 #endif
-5
drivers/media/platform/qcom/venus/vdec_ctrls.c
··· 187 187 188 188 return 0; 189 189 } 190 - 191 - void vdec_ctrl_deinit(struct venus_inst *inst) 192 - { 193 - v4l2_ctrl_handler_free(&inst->ctrl_handler); 194 - }
+2 -22
drivers/media/platform/qcom/venus/venc.c
··· 1528 1528 err_session_destroy: 1529 1529 hfi_session_destroy(inst); 1530 1530 err_ctrl_deinit: 1531 - venc_ctrl_deinit(inst); 1531 + v4l2_ctrl_handler_free(&inst->ctrl_handler); 1532 1532 err_free: 1533 1533 kfree(inst); 1534 1534 return ret; ··· 1539 1539 struct venus_inst *inst = to_inst(file); 1540 1540 1541 1541 venc_pm_get(inst); 1542 - 1543 - /* 1544 - * First, remove the inst from the ->instances list, so that 1545 - * to_instance() will return NULL. 1546 - */ 1547 - hfi_session_destroy(inst); 1548 - /* 1549 - * Second, make sure we don't have IRQ/IRQ-thread currently running 1550 - * or pending execution, which would race with the inst destruction. 1551 - */ 1552 - synchronize_irq(inst->core->irq); 1553 - 1554 - v4l2_m2m_ctx_release(inst->m2m_ctx); 1555 - v4l2_m2m_release(inst->m2m_dev); 1556 - v4l2_fh_del(&inst->fh); 1557 - v4l2_fh_exit(&inst->fh); 1558 - venc_ctrl_deinit(inst); 1559 - 1542 + venus_close_common(inst); 1560 1543 inst->enc_state = VENUS_ENC_STATE_DEINIT; 1561 - mutex_destroy(&inst->lock); 1562 - mutex_destroy(&inst->ctx_q_lock); 1563 - 1564 1544 venc_pm_put(inst, false); 1565 1545 1566 1546 kfree(inst);
-1
drivers/media/platform/qcom/venus/venc.h
··· 9 9 struct venus_inst; 10 10 11 11 int venc_ctrl_init(struct venus_inst *inst); 12 - void venc_ctrl_deinit(struct venus_inst *inst); 13 12 14 13 #endif
-5
drivers/media/platform/qcom/venus/venc_ctrls.c
··· 733 733 v4l2_ctrl_handler_free(&inst->ctrl_handler); 734 734 return ret; 735 735 } 736 - 737 - void venc_ctrl_deinit(struct venus_inst *inst) 738 - { 739 - v4l2_ctrl_handler_free(&inst->ctrl_handler); 740 - }