From 78471f1edb87ee59940008915270ce8250d48949 Mon Sep 17 00:00:00 2001 From: Jeonghee Kim Date: Fri, 2 Feb 2018 16:31:36 +0900 Subject: [PATCH] media: mfc: add debugging code - the number of ref/nal-q buffer is added in dump - nal-q lock is moved to nal_q_handle - nal-q info is added in dump - consumed info is added in trace Change-Id: I4fdfbb1da3cff919d737853670a3c5acc05197c6 Signed-off-by: Jeonghee Kim --- .../platform/exynos/mfc/s5p_mfc_data_struct.h | 2 +- .../media/platform/exynos/mfc/s5p_mfc_irq.c | 3 +++ .../media/platform/exynos/mfc/s5p_mfc_nal_q.c | 20 +++++++++++-------- .../platform/exynos/mfc/s5p_mfc_watchdog.c | 12 +++++++++-- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h b/drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h index 3d42385a255f..52115947c6d8 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h @@ -577,7 +577,6 @@ typedef struct _nal_queue_in_handle { struct s5p_mfc_special_buf in_buf; unsigned int in_exe_count; nal_in_queue *nal_q_in_addr; - spinlock_t lock; } nal_queue_in_handle; typedef struct _nal_queue_out_handle { @@ -592,6 +591,7 @@ typedef struct _nal_queue_handle { nal_queue_in_handle *nal_q_in_handle; nal_queue_out_handle *nal_q_out_handle; nal_queue_state nal_q_state; + spinlock_t lock; int nal_q_exception; } nal_queue_handle; diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_irq.c b/drivers/media/platform/exynos/mfc/s5p_mfc_irq.c index b47dd749c3a4..9cb1433b908d 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_irq.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_irq.c @@ -552,6 +552,9 @@ static void mfc_handle_frame_input(struct s5p_mfc_ctx *ctx, unsigned int err) dec->remained_size = src_mb->vb.vb2_buf.planes[0].bytesused - dec->consumed; dec->has_multiframe = 1; + + MFC_TRACE_CTX("** consumed:%ld, remained:%ld, addr:0x%08llx\n", + dec->consumed, dec->remained_size, dec->y_addr_for_pb); /* Do not move src buffer to done_list */ return; } diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_nal_q.c b/drivers/media/platform/exynos/mfc/s5p_mfc_nal_q.c index 99500045ee39..2feab06f4018 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_nal_q.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_nal_q.c @@ -270,7 +270,7 @@ nal_queue_handle *s5p_mfc_nal_q_create(struct s5p_mfc_dev *dev) return NULL; } - spin_lock_init(&nal_q_handle->nal_q_in_handle->lock); + spin_lock_init(&nal_q_handle->lock); nal_q_handle->nal_q_out_handle = mfc_nal_q_create_out_q(dev, nal_q_handle); if (!nal_q_handle->nal_q_out_handle) { @@ -1245,6 +1245,7 @@ static void mfc_nal_q_handle_frame_input(struct s5p_mfc_ctx *ctx, unsigned int e DecoderOutputStr *pOutStr) { struct s5p_mfc_dec *dec = ctx->dec_priv; + struct s5p_mfc_dev *dev = ctx->dev; struct s5p_mfc_buf *src_mb; unsigned int index; int deleted = 0; @@ -1281,6 +1282,9 @@ static void mfc_nal_q_handle_frame_input(struct s5p_mfc_ctx *ctx, unsigned int e dec->remained_size = src_mb->vb.vb2_buf.planes[0].bytesused - dec->consumed; dec->has_multiframe = 1; + + MFC_TRACE_CTX("** consumed:%ld, remained:%ld, addr:0x%08llx\n", + dec->consumed, dec->remained_size, dec->y_addr_for_pb); /* Do not move src buffer to done_list */ return; } @@ -1533,7 +1537,7 @@ int s5p_mfc_nal_q_enqueue_in_buf(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ct return -EINVAL; } - spin_lock_irqsave(&nal_q_in_handle->lock, flags); + spin_lock_irqsave(&nal_q_in_handle->nal_q_handle->lock, flags); input_count = s5p_mfc_get_nal_q_input_count(); input_exe_count = s5p_mfc_get_nal_q_input_exe_count(); @@ -1553,7 +1557,7 @@ int s5p_mfc_nal_q_enqueue_in_buf(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ct if ((input_diff < 0) || (input_diff >= NAL_Q_IN_QUEUE_SIZE)) { mfc_err_dev("NAL Q: No available input slot(%d)\n", input_diff); - spin_unlock_irqrestore(&nal_q_in_handle->lock, flags); + spin_unlock_irqrestore(&nal_q_in_handle->nal_q_handle->lock, flags); return -EINVAL; } @@ -1569,7 +1573,7 @@ int s5p_mfc_nal_q_enqueue_in_buf(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ct if (ret != 0) { mfc_debug(2, "NAL Q: Failed to set input queue\n"); - spin_unlock_irqrestore(&nal_q_in_handle->lock, flags); + spin_unlock_irqrestore(&nal_q_in_handle->nal_q_handle->lock, flags); return ret; } @@ -1587,7 +1591,7 @@ int s5p_mfc_nal_q_enqueue_in_buf(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ct if (input_diff == 0) s5p_mfc_watchdog_start_tick(dev); - spin_unlock_irqrestore(&nal_q_in_handle->lock, flags); + spin_unlock_irqrestore(&nal_q_in_handle->nal_q_handle->lock, flags); MFC_TRACE_CTX("NAL %s in: diff %d count %d exe %d\n", ctx->type == MFCINST_ENCODER ? "ENC" : "DEC", @@ -1621,7 +1625,7 @@ EncoderOutputStr *s5p_mfc_nal_q_dequeue_out_buf(struct s5p_mfc_dev *dev, return pStr; } - spin_lock_irqsave(&nal_q_out_handle->nal_q_handle->nal_q_in_handle->lock, flags); + spin_lock_irqsave(&nal_q_out_handle->nal_q_handle->lock, flags); output_count = s5p_mfc_get_nal_q_output_count(); output_exe_count = nal_q_out_handle->out_exe_count; @@ -1639,7 +1643,7 @@ EncoderOutputStr *s5p_mfc_nal_q_dequeue_out_buf(struct s5p_mfc_dev *dev, mfc_debug(2, "NAL Q: output_diff = %d(out: %d, exe: %d)\n", output_diff, output_count, output_exe_count); if ((output_diff <= 0) || (output_diff > NAL_Q_OUT_QUEUE_SIZE)) { - spin_unlock_irqrestore(&nal_q_out_handle->nal_q_handle->nal_q_in_handle->lock, flags); + spin_unlock_irqrestore(&nal_q_out_handle->nal_q_handle->lock, flags); mfc_debug(2, "NAL Q: No available output slot(%d)\n", output_diff); return pStr; } @@ -1677,7 +1681,7 @@ EncoderOutputStr *s5p_mfc_nal_q_dequeue_out_buf(struct s5p_mfc_dev *dev, s5p_mfc_watchdog_reset_tick(dev); } - spin_unlock_irqrestore(&nal_q_out_handle->nal_q_handle->nal_q_in_handle->lock, flags); + spin_unlock_irqrestore(&nal_q_out_handle->nal_q_handle->lock, flags); MFC_TRACE_CTX("NAL %s out: diff %d count %d exe %d\n", ctx->type == MFCINST_ENCODER ? "ENC" : "DEC", diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_watchdog.c b/drivers/media/platform/exynos/mfc/s5p_mfc_watchdog.c index 8a936b458cd7..c22b9c3fbc4c 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_watchdog.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_watchdog.c @@ -144,6 +144,7 @@ static void mfc_save_logging_sfr(struct s5p_mfc_dev *dev) static void mfc_display_state(struct s5p_mfc_dev *dev) { + nal_queue_handle *nal_q_handle = dev->nal_q_handle; int i; pr_err("-----------dumping MFC device info-----------\n"); @@ -155,16 +156,23 @@ static void mfc_display_state(struct s5p_mfc_dev *dev) dev->hwlock.bits, dev->hwlock.dev, dev->curr_ctx, dev->curr_ctx_is_drm, dev->preempt_ctx, s5p_mfc_get_bits(&dev->work_bits)); + pr_err("NAL-Q state:%d, exception:%d, in_exe_cnt: %d, out_exe_cnt: %d\n", + nal_q_handle->nal_q_state, nal_q_handle->nal_q_exception, + nal_q_handle->nal_q_in_handle->in_exe_count, + nal_q_handle->nal_q_out_handle->out_exe_count); for (i = 0; i < MFC_NUM_CONTEXTS; i++) if (dev->ctx[i]) - pr_err("MFC ctx[%d] %s(%d) state:%d, queue_cnt(src:%d, dst:%d)," - " interrupt(cond:%d, type:%d, err:%d)\n", + pr_err("MFC ctx[%d] %s(%d) state:%d, queue_cnt(src:%d, dst:%d, ref:%d, qsrc:%d, qdst:%d)\n" + " interrupt(cond:%d, type:%d, err:%d)\n", dev->ctx[i]->num, dev->ctx[i]->type == MFCINST_DECODER ? "DEC" : "ENC", dev->ctx[i]->codec_mode, dev->ctx[i]->state, s5p_mfc_get_queue_count(&dev->ctx[i]->buf_queue_lock, &dev->ctx[i]->src_buf_queue), s5p_mfc_get_queue_count(&dev->ctx[i]->buf_queue_lock, &dev->ctx[i]->dst_buf_queue), + s5p_mfc_get_queue_count(&dev->ctx[i]->buf_queue_lock, &dev->ctx[i]->ref_buf_queue), + s5p_mfc_get_queue_count(&dev->ctx[i]->buf_queue_lock, &dev->ctx[i]->src_buf_nal_queue), + s5p_mfc_get_queue_count(&dev->ctx[i]->buf_queue_lock, &dev->ctx[i]->dst_buf_nal_queue), dev->ctx[i]->int_condition, dev->ctx[i]->int_reason, dev->ctx[i]->int_err); } -- 2.20.1