From patchwork Mon Nov 28 10:30:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Christophe Trotin X-Patchwork-Id: 9449291 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5F1B860756 for ; Mon, 28 Nov 2016 10:32:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4885D2675C for ; Mon, 28 Nov 2016 10:32:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D81C269DA; Mon, 28 Nov 2016 10:32:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 949492684F for ; Mon, 28 Nov 2016 10:32:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932625AbcK1KcJ (ORCPT ); Mon, 28 Nov 2016 05:32:09 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:42511 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754625AbcK1KbI (ORCPT ); Mon, 28 Nov 2016 05:31:08 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id uASAUhj4029543; Mon, 28 Nov 2016 11:31:06 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-.pphosted.com with ESMTP id 26y0da1b4a-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 28 Nov 2016 11:31:06 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 3D73D38; Mon, 28 Nov 2016 10:31:05 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas23.st.com [10.75.90.46]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 1C970281A; Mon, 28 Nov 2016 10:31:05 +0000 (GMT) Received: from localhost (10.201.23.70) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.294.0; Mon, 28 Nov 2016 11:31:05 +0100 From: Jean-Christophe Trotin To: , Hans Verkuil CC: , Benjamin Gaignard , Yannick Fertre , Hugues Fruchet , Jean-Christophe Trotin Subject: [PATCH v3 1/3] st-hva: encoding summary at instance release Date: Mon, 28 Nov 2016 11:30:52 +0100 Message-ID: <1480329054-30403-2-git-send-email-jean-christophe.trotin@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1480329054-30403-1-git-send-email-jean-christophe.trotin@st.com> References: <1480329054-30403-1-git-send-email-jean-christophe.trotin@st.com> MIME-Version: 1.0 X-Originating-IP: [10.201.23.70] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-11-28_04:, , signatures=0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch prints unconditionnaly a short summary about the encoding operation at each instance closing, for debug purpose: - information about the frame (format, resolution) - information about the stream (format, profile, level, resolution) - number of encoded frames - potential (system, encoding...) errors Signed-off-by: Yannick Fertre Signed-off-by: Jean-Christophe Trotin --- drivers/media/platform/sti/hva/hva-h264.c | 6 ++++ drivers/media/platform/sti/hva/hva-hw.c | 5 ++++ drivers/media/platform/sti/hva/hva-mem.c | 5 +++- drivers/media/platform/sti/hva/hva-v4l2.c | 49 ++++++++++++++++++++++++------- drivers/media/platform/sti/hva/hva.h | 8 +++++ 5 files changed, 62 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/sti/hva/hva-h264.c b/drivers/media/platform/sti/hva/hva-h264.c index 8cc8467..e6f247a 100644 --- a/drivers/media/platform/sti/hva/hva-h264.c +++ b/drivers/media/platform/sti/hva/hva-h264.c @@ -607,6 +607,7 @@ static int hva_h264_prepare_task(struct hva_ctx *pctx, "%s width(%d) or height(%d) exceeds limits (%dx%d)\n", pctx->name, frame_width, frame_height, H264_MAX_SIZE_W, H264_MAX_SIZE_H); + pctx->frame_errors++; return -EINVAL; } @@ -717,6 +718,7 @@ static int hva_h264_prepare_task(struct hva_ctx *pctx, default: dev_err(dev, "%s invalid source pixel format\n", pctx->name); + pctx->frame_errors++; return -EINVAL; } @@ -741,6 +743,7 @@ static int hva_h264_prepare_task(struct hva_ctx *pctx, if (td->framerate_den == 0) { dev_err(dev, "%s invalid framerate\n", pctx->name); + pctx->frame_errors++; return -EINVAL; } @@ -831,6 +834,7 @@ static int hva_h264_prepare_task(struct hva_ctx *pctx, (payload > MAX_SPS_PPS_SIZE)) { dev_err(dev, "%s invalid sps/pps size %d\n", pctx->name, payload); + pctx->frame_errors++; return -EINVAL; } @@ -842,6 +846,7 @@ static int hva_h264_prepare_task(struct hva_ctx *pctx, (u8 *)stream->vaddr, &payload)) { dev_err(dev, "%s fail to get SEI nal\n", pctx->name); + pctx->frame_errors++; return -EINVAL; } @@ -963,6 +968,7 @@ static int hva_h264_open(struct hva_ctx *pctx) err_ctx: devm_kfree(dev, ctx); err: + pctx->sys_errors++; return ret; } diff --git a/drivers/media/platform/sti/hva/hva-hw.c b/drivers/media/platform/sti/hva/hva-hw.c index 68d625b..5104068 100644 --- a/drivers/media/platform/sti/hva/hva-hw.c +++ b/drivers/media/platform/sti/hva/hva-hw.c @@ -470,6 +470,7 @@ int hva_hw_execute_task(struct hva_ctx *ctx, enum hva_hw_cmd_type cmd, if (pm_runtime_get_sync(dev) < 0) { dev_err(dev, "%s failed to get pm_runtime\n", ctx->name); + ctx->sys_errors++; ret = -EFAULT; goto out; } @@ -481,6 +482,7 @@ int hva_hw_execute_task(struct hva_ctx *ctx, enum hva_hw_cmd_type cmd, break; default: dev_dbg(dev, "%s unknown command 0x%x\n", ctx->name, cmd); + ctx->encode_errors++; ret = -EFAULT; goto out; } @@ -511,6 +513,7 @@ int hva_hw_execute_task(struct hva_ctx *ctx, enum hva_hw_cmd_type cmd, msecs_to_jiffies(2000))) { dev_err(dev, "%s %s: time out on completion\n", ctx->name, __func__); + ctx->encode_errors++; ret = -EFAULT; goto out; } @@ -518,6 +521,8 @@ int hva_hw_execute_task(struct hva_ctx *ctx, enum hva_hw_cmd_type cmd, /* get encoding status */ ret = ctx->hw_err ? -EFAULT : 0; + ctx->encode_errors += ctx->hw_err ? 1 : 0; + out: disable_irq(hva->irq_its); disable_irq(hva->irq_err); diff --git a/drivers/media/platform/sti/hva/hva-mem.c b/drivers/media/platform/sti/hva/hva-mem.c index 649f660..821c78e 100644 --- a/drivers/media/platform/sti/hva/hva-mem.c +++ b/drivers/media/platform/sti/hva/hva-mem.c @@ -17,14 +17,17 @@ int hva_mem_alloc(struct hva_ctx *ctx, u32 size, const char *name, void *base; b = devm_kzalloc(dev, sizeof(*b), GFP_KERNEL); - if (!b) + if (!b) { + ctx->sys_errors++; return -ENOMEM; + } base = dma_alloc_attrs(dev, size, &paddr, GFP_KERNEL | GFP_DMA, DMA_ATTR_WRITE_COMBINE); if (!base) { dev_err(dev, "%s %s : dma_alloc_attrs failed for %s (size=%d)\n", ctx->name, __func__, name, size); + ctx->sys_errors++; devm_kfree(dev, b); return -ENOMEM; } diff --git a/drivers/media/platform/sti/hva/hva-v4l2.c b/drivers/media/platform/sti/hva/hva-v4l2.c index 6bf3c858..a13b03c 100644 --- a/drivers/media/platform/sti/hva/hva-v4l2.c +++ b/drivers/media/platform/sti/hva/hva-v4l2.c @@ -226,6 +226,28 @@ static int hva_open_encoder(struct hva_ctx *ctx, u32 streamformat, return ret; } +void hva_dbg_summary(struct hva_ctx *ctx) +{ + struct device *dev = ctx_to_dev(ctx); + struct hva_streaminfo *stream = &ctx->streaminfo; + struct hva_frameinfo *frame = &ctx->frameinfo; + + if (!(ctx->flags & HVA_FLAG_STREAMINFO)) + return; + + dev_info(dev, "%s %4.4s %dx%d > %4.4s %dx%d %s %s: %d frames encoded, %d system errors, %d encoding errors, %d frame errors\n", + ctx->name, + (char *)&frame->pixelformat, + frame->aligned_width, frame->aligned_height, + (char *)&stream->streamformat, + stream->width, stream->height, + stream->profile, stream->level, + ctx->encoded_frames, + ctx->sys_errors, + ctx->encode_errors, + ctx->frame_errors); +} + /* * V4L2 ioctl operations */ @@ -614,19 +636,17 @@ static int hva_s_ctrl(struct v4l2_ctrl *ctrl) break; case V4L2_CID_MPEG_VIDEO_H264_PROFILE: ctx->ctrls.profile = ctrl->val; - if (ctx->flags & HVA_FLAG_STREAMINFO) - snprintf(ctx->streaminfo.profile, - sizeof(ctx->streaminfo.profile), - "%s profile", - v4l2_ctrl_get_menu(ctrl->id)[ctrl->val]); + snprintf(ctx->streaminfo.profile, + sizeof(ctx->streaminfo.profile), + "%s profile", + v4l2_ctrl_get_menu(ctrl->id)[ctrl->val]); break; case V4L2_CID_MPEG_VIDEO_H264_LEVEL: ctx->ctrls.level = ctrl->val; - if (ctx->flags & HVA_FLAG_STREAMINFO) - snprintf(ctx->streaminfo.level, - sizeof(ctx->streaminfo.level), - "level %s", - v4l2_ctrl_get_menu(ctrl->id)[ctrl->val]); + snprintf(ctx->streaminfo.level, + sizeof(ctx->streaminfo.level), + "level %s", + v4l2_ctrl_get_menu(ctrl->id)[ctrl->val]); break; case V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE: ctx->ctrls.entropy_mode = ctrl->val; @@ -812,6 +832,8 @@ static void hva_run_work(struct work_struct *work) dst_buf->field = V4L2_FIELD_NONE; dst_buf->sequence = ctx->stream_num - 1; + ctx->encoded_frames++; + v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_DONE); v4l2_m2m_buf_done(dst_buf, VB2_BUF_STATE_DONE); } @@ -1026,6 +1048,8 @@ static int hva_start_streaming(struct vb2_queue *vq, unsigned int count) v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_QUEUED); } + ctx->sys_errors++; + return ret; } @@ -1150,6 +1174,7 @@ static int hva_open(struct file *file) if (ret) { dev_err(dev, "%s [x:x] failed to setup controls\n", HVA_PREFIX); + ctx->sys_errors++; goto err_fh; } ctx->fh.ctrl_handler = &ctx->ctrl_handler; @@ -1162,6 +1187,7 @@ static int hva_open(struct file *file) ret = PTR_ERR(ctx->fh.m2m_ctx); dev_err(dev, "%s failed to initialize m2m context (%d)\n", HVA_PREFIX, ret); + ctx->sys_errors++; goto err_ctrls; } @@ -1206,6 +1232,9 @@ static int hva_release(struct file *file) hva->nb_of_instances--; } + /* trace a summary of instance before closing (debug purpose) */ + hva_dbg_summary(ctx); + v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); v4l2_ctrl_handler_free(&ctx->ctrl_handler); diff --git a/drivers/media/platform/sti/hva/hva.h b/drivers/media/platform/sti/hva/hva.h index caa5808..1e30abe 100644 --- a/drivers/media/platform/sti/hva/hva.h +++ b/drivers/media/platform/sti/hva/hva.h @@ -182,6 +182,10 @@ struct hva_stream { * @priv: private codec data for this instance, allocated * by encoder @open time * @hw_err: true if hardware error detected + * @encoded_frames: number of encoded frames + * @sys_errors: number of system errors (memory, resource, pm...) + * @encode_errors: number of encoding errors (hw/driver errors) + * @frame_errors: number of frame errors (format, size, header...) */ struct hva_ctx { struct hva_dev *hva_dev; @@ -207,6 +211,10 @@ struct hva_ctx { struct hva_enc *enc; void *priv; bool hw_err; + u32 encoded_frames; + u32 sys_errors; + u32 encode_errors; + u32 frame_errors; }; #define HVA_FLAG_STREAMINFO 0x0001