From 33e80d503288811f84312711ecfdd9d4903a3fcb Mon Sep 17 00:00:00 2001 From: Ayoung Sim Date: Mon, 9 Jul 2018 16:09:43 +0900 Subject: [PATCH] [COMMON] media: mfc: DRV4.0: dump the MFC struct Change-Id: I62ef996cb43a334c2aa1a6b7bc138e97448989fd Signed-off-by: Ayoung Sim --- .../platform/exynos/mfc/mfc_data_struct.h | 13 ++- .../media/platform/exynos/mfc/mfc_enc_param.c | 14 ++-- drivers/media/platform/exynos/mfc/mfc_nal_q.c | 5 +- .../media/platform/exynos/mfc/mfc_watchdog.c | 83 +++++++++++++++++-- 4 files changed, 92 insertions(+), 23 deletions(-) diff --git a/drivers/media/platform/exynos/mfc/mfc_data_struct.h b/drivers/media/platform/exynos/mfc/mfc_data_struct.h index 5129566a248a..b82b7e391dc5 100644 --- a/drivers/media/platform/exynos/mfc/mfc_data_struct.h +++ b/drivers/media/platform/exynos/mfc/mfc_data_struct.h @@ -819,8 +819,8 @@ struct mfc_dev { #ifdef CONFIG_EXYNOS_ITMON struct notifier_block itmon_nb; - int itmon_notified; #endif + int itmon_notified; }; /** @@ -1296,10 +1296,8 @@ struct mfc_enc { size_t tmv_buffer_size; unsigned int slice_mode; - union { - unsigned int mb; - unsigned int bits; - } slice_size; + unsigned int slice_size_mb; + unsigned int slice_size_bits; unsigned int in_slice; unsigned int buf_full; @@ -1423,6 +1421,9 @@ struct mfc_ctx { int batch_mode; bool check_dump; + struct vb2_queue vq_src; + struct vb2_queue vq_dst; + /* * new variables should be added above * ============ boundary line ============ @@ -1430,8 +1431,6 @@ struct mfc_ctx { */ /* external structure */ - struct vb2_queue vq_src; - struct vb2_queue vq_dst; struct v4l2_fh fh; /* per buffer controls */ diff --git a/drivers/media/platform/exynos/mfc/mfc_enc_param.c b/drivers/media/platform/exynos/mfc/mfc_enc_param.c index f015c534668a..d4b903c31600 100644 --- a/drivers/media/platform/exynos/mfc/mfc_enc_param.c +++ b/drivers/media/platform/exynos/mfc/mfc_enc_param.c @@ -38,10 +38,10 @@ void mfc_set_slice_mode(struct mfc_ctx *ctx) /* multi-slice MB number or bit size */ if ((enc->slice_mode == V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_MB) || (enc->slice_mode == V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_MAX_MB_ROW)) { - MFC_RAW_WRITEL(enc->slice_size.mb, MFC_REG_E_MSLICE_SIZE_MB); + MFC_RAW_WRITEL(enc->slice_size_mb, MFC_REG_E_MSLICE_SIZE_MB); } else if ((enc->slice_mode == V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_BYTES) || (enc->slice_mode == V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_MAX_FIXED_BYTES)){ - MFC_RAW_WRITEL(enc->slice_size.bits, MFC_REG_E_MSLICE_SIZE_BITS); + MFC_RAW_WRITEL(enc->slice_size_bits, MFC_REG_E_MSLICE_SIZE_BITS); } else { MFC_RAW_WRITEL(0x0, MFC_REG_E_MSLICE_SIZE_MB); MFC_RAW_WRITEL(0x0, MFC_REG_E_MSLICE_SIZE_BITS); @@ -159,15 +159,15 @@ static void __mfc_set_enc_params(struct mfc_ctx *ctx) enc->slice_mode = p->slice_mode; if (p->slice_mode == V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_MB) { - enc->slice_size.mb = p->slice_mb; + enc->slice_size_mb = p->slice_mb; } else if ((p->slice_mode == V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_BYTES) || (p->slice_mode == V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_MAX_FIXED_BYTES)){ - enc->slice_size.bits = p->slice_bit; + enc->slice_size_bits = p->slice_bit; } else if (p->slice_mode == V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_MAX_MB_ROW) { - enc->slice_size.mb = p->slice_mb_row * ((ctx->crop_width + 15) / 16); + enc->slice_size_mb = p->slice_mb_row * ((ctx->crop_width + 15) / 16); } else { - enc->slice_size.mb = 0; - enc->slice_size.bits = 0; + enc->slice_size_mb = 0; + enc->slice_size_bits = 0; } mfc_set_slice_mode(ctx); diff --git a/drivers/media/platform/exynos/mfc/mfc_nal_q.c b/drivers/media/platform/exynos/mfc/mfc_nal_q.c index e742a781448f..691c63cb64fc 100644 --- a/drivers/media/platform/exynos/mfc/mfc_nal_q.c +++ b/drivers/media/platform/exynos/mfc/mfc_nal_q.c @@ -540,10 +540,10 @@ static void __mfc_nal_q_set_slice_mode(struct mfc_ctx *ctx, EncoderInputStr *pIn /* multi-slice MB number or bit size */ if ((enc->slice_mode == V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_MB) || (enc->slice_mode == V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_MAX_MB_ROW)) { - pInStr->MsliceSizeMb = enc->slice_size.mb; + pInStr->MsliceSizeMb = enc->slice_size_mb; } else if ((enc->slice_mode == V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_BYTES) || (enc->slice_mode == V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_MAX_FIXED_BYTES)){ - pInStr->MsliceSizeBits = enc->slice_size.bits; + pInStr->MsliceSizeBits = enc->slice_size_bits; } else { pInStr->MsliceSizeMb = 0; pInStr->MsliceSizeBits = 0; @@ -1641,6 +1641,7 @@ int mfc_nal_q_enqueue_in_buf(struct mfc_dev *dev, struct mfc_ctx *ctx, input_count = mfc_get_nal_q_input_count(); input_exe_count = mfc_get_nal_q_input_exe_count(); + nal_q_in_handle->in_exe_count = input_exe_count; input_diff = input_count - input_exe_count; /* diff --git a/drivers/media/platform/exynos/mfc/mfc_watchdog.c b/drivers/media/platform/exynos/mfc/mfc_watchdog.c index 75b5bd3404c1..88a4d94272ec 100644 --- a/drivers/media/platform/exynos/mfc/mfc_watchdog.c +++ b/drivers/media/platform/exynos/mfc/mfc_watchdog.c @@ -142,20 +142,38 @@ static void __mfc_save_logging_sfr(struct mfc_dev *dev) #endif } +static int __mfc_get_curr_ctx(struct mfc_dev *dev) +{ + nal_queue_handle *nal_q_handle = dev->nal_q_handle; + int index; + + if (nal_q_handle) { + if (nal_q_handle->nal_q_state == NAL_Q_STATE_STARTED) { + index = nal_q_handle->nal_q_in_handle->in_exe_count % NAL_Q_IN_QUEUE_SIZE; + return nal_q_handle->nal_q_in_handle->nal_q_in_addr->entry[index].dec.InstanceId; + } + } + + return dev->curr_ctx; +} + static void __mfc_dump_state(struct mfc_dev *dev) { nal_queue_handle *nal_q_handle = dev->nal_q_handle; - int i; + int i, curr_ctx; pr_err("-----------dumping MFC device info-----------\n"); - pr_err("power:%d, clock:%d, num_inst:%d, num_drm_inst:%d, fw_status:%d\n", + pr_err("power:%d, clock:%d, continue_clock_on:%d, num_inst:%d, num_drm_inst:%d, fw_status:%d\n", mfc_pm_get_pwr_ref_cnt(dev), mfc_pm_get_clk_ref_cnt(dev), - dev->num_inst, dev->num_drm_inst, dev->fw.status); + dev->continue_clock_on, dev->num_inst, dev->num_drm_inst, dev->fw.status); pr_err("hwlock bits:%#lx / dev:%#lx, curr_ctx:%d (is_drm:%d)," " preempt_ctx:%d, work_bits:%#lx\n", dev->hwlock.bits, dev->hwlock.dev, dev->curr_ctx, dev->curr_ctx_is_drm, dev->preempt_ctx, mfc_get_bits(&dev->work_bits)); + pr_err("has 2sysmmu:%d, has hwfc:%d, has mmcache:%d, shutdown:%d, sleep:%d, itmon_notified:%d\n", + dev->has_2sysmmu, dev->has_hwfc, dev->has_mmcache, + dev->shutdown, dev->sleep, dev->itmon_notified); pr_err("options debug_level:%d, debug_mode:%d, mmcache:%d, perf_boost:%d\n", debug_level, dev->pdata->debug_mode, dev->mmcache.is_on_status, perf_boost_mode); pr_err("NAL-Q state:%d, exception:%d, in_exe_cnt: %d, out_exe_cnt: %d\n", @@ -163,12 +181,13 @@ static void __mfc_dump_state(struct mfc_dev *dev) nal_q_handle->nal_q_in_handle->in_exe_count, nal_q_handle->nal_q_out_handle->out_exe_count); + curr_ctx = __mfc_get_curr_ctx(dev); 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, ref:%d, qsrc:%d, qdst:%d)\n" - " interrupt(cond:%d, type:%d, err:%d)\n", + pr_err("MFC ctx[%d] %s(%scodec_type:%d) state:%d, queue_cnt(src:%d, dst:%d, ref:%d, qsrc:%d, qdst:%d), interrupt(cond:%d, type:%d, err:%d)\n", dev->ctx[i]->num, dev->ctx[i]->type == MFCINST_DECODER ? "DEC" : "ENC", + curr_ctx == i ? "curr_ctx! " : "", dev->ctx[i]->codec_mode, dev->ctx[i]->state, mfc_get_queue_count(&dev->ctx[i]->buf_queue_lock, &dev->ctx[i]->src_buf_queue), mfc_get_queue_count(&dev->ctx[i]->buf_queue_lock, &dev->ctx[i]->dst_buf_queue), @@ -197,7 +216,7 @@ void __mfc_dump_buffer_info(struct mfc_dev *dev) { struct mfc_ctx *ctx; - ctx = dev->ctx[dev->curr_ctx]; + ctx = dev->ctx[__mfc_get_curr_ctx(dev)]; if (ctx) { pr_err("-----------dumping MFC buffer info (fault at: %#x)\n", dev->logging_data->fault_addr); @@ -267,10 +286,58 @@ void __mfc_dump_buffer_info(struct mfc_dev *dev) } } +static void __mfc_dump_struct(struct mfc_dev *dev) +{ + struct mfc_ctx *ctx = NULL; + int i, size = 0; + + pr_err("-----------dumping MFC struct info-----------\n"); + ctx = dev->ctx[__mfc_get_curr_ctx(dev)]; + if (!ctx) { + for (i = 0; i < MFC_NUM_CONTEXTS; i++) { + if (dev->ctx[i]) { + ctx = dev->ctx[i]; + break; + } + } + + if (!ctx) { + pr_err("there is no ctx structure for dumpping\n"); + return; + } + pr_err("curr ctx is changed %d -> %d\n", dev->curr_ctx, ctx->num); + } + + /* mfc_platdata */ + size = (unsigned long)&dev->pdata->enc_param_num - (unsigned long)dev->pdata; + print_hex_dump(KERN_ERR, "dump mfc_pdata: ", DUMP_PREFIX_ADDRESS, + 32, 4, dev->pdata, size, false); + + /* mfc_ctx */ + size = (unsigned long)&ctx->fh - (unsigned long)ctx; + print_hex_dump(KERN_ERR, "dump mfc_ctx: ", DUMP_PREFIX_ADDRESS, + 32, 4, ctx, size, false); + + if (ctx->type == MFCINST_DECODER && ctx->dec_priv != NULL) { + /* mfc_dec */ + size = (unsigned long)&ctx->dec_priv->assigned_dpb[0] - (unsigned long)ctx->dec_priv; + print_hex_dump(KERN_ERR, "dump mfc_dec: ", DUMP_PREFIX_ADDRESS, + 32, 4, ctx->dec_priv, size, false); + } else if (ctx->type == MFCINST_ENCODER && ctx->enc_priv != NULL) { + /* mfc_enc */ + size = (unsigned long)&ctx->enc_priv->params - (unsigned long)ctx->enc_priv; + print_hex_dump(KERN_ERR, "dump mfc_enc: ", DUMP_PREFIX_ADDRESS, + 32, 4, ctx->enc_priv, size, false); + print_hex_dump(KERN_ERR, "dump mfc_enc_param: ", DUMP_PREFIX_ADDRESS, + 32, 1, &ctx->enc_priv->params, sizeof(struct mfc_enc_params), false); + } +} + static void __mfc_dump_info_without_regs(struct mfc_dev *dev) { __mfc_dump_state(dev); __mfc_dump_trace(dev); + __mfc_dump_struct(dev); } static void __mfc_dump_info(struct mfc_dev *dev) @@ -279,7 +346,9 @@ static void __mfc_dump_info(struct mfc_dev *dev) __mfc_save_logging_sfr(dev); __mfc_dump_buffer_info(dev); __mfc_dump_regs(dev); - exynos_sysmmu_show_status(dev->device); + /* If there was fault addr, sysmmu info is already printed out */ + if (!dev->logging_data->fault_addr) + exynos_sysmmu_show_status(dev->device); } static void __mfc_dump_info_and_stop_hw(struct mfc_dev *dev) -- 2.20.1