media: mfc: add debugging code
authorJeonghee Kim <jhhhh.kim@samsung.com>
Fri, 2 Feb 2018 07:31:36 +0000 (16:31 +0900)
committerSunyoung Kang <sy0816.kang@samsung.com>
Tue, 29 May 2018 06:59:18 +0000 (15:59 +0900)
- 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 <jhhhh.kim@samsung.com>
drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h
drivers/media/platform/exynos/mfc/s5p_mfc_irq.c
drivers/media/platform/exynos/mfc/s5p_mfc_nal_q.c
drivers/media/platform/exynos/mfc/s5p_mfc_watchdog.c

index 3d42385a255f15e90f1bd4c700e8f4cbf2084c3c..52115947c6d88fd22d81779c0869da751c718cc1 100644 (file)
@@ -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;
 
index b47dd749c3a44f3e582821ffaab09164055db09a..9cb1433b908d5b11c769c509b2bcbdd66bb00570 100644 (file)
@@ -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;
        }
index 99500045ee39b680d929dd5b58bc97a6595d10af..2feab06f40187685e895d15f555e9290520e1ace 100644 (file)
@@ -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",
index 8a936b458cd7be07107ac84c6fe3a656f3b04e91..c22b9c3fbc4c6bc261bbe9e15c91b456f583f706 100644 (file)
@@ -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);
 }