From patchwork Fri Dec 23 19:38:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Dufresne X-Patchwork-Id: 636524 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8AF0C4332F for ; Fri, 23 Dec 2022 19:38:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232594AbiLWTi5 (ORCPT ); Fri, 23 Dec 2022 14:38:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232623AbiLWTix (ORCPT ); Fri, 23 Dec 2022 14:38:53 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C07A620F75; Fri, 23 Dec 2022 11:38:48 -0800 (PST) Received: from whitebuilder.lan (192-222-136-102.qc.cable.ebox.net [192.222.136.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: nicolas) by madras.collabora.co.uk (Postfix) with ESMTPSA id 2CA6A6602CE4; Fri, 23 Dec 2022 19:38:46 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1671824327; bh=eBl4+2U4mQQRTAtyInaP2j+zvWYhkSkjm7NFsSgFaXQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QJvWKvQjLgZgCirY7Ajy75zAiBEMylZ1tHA5Dv/UZvan9DxnC2Xe4FPZ3PIxO1K/w F38xN/A6OmP1IEuIsrcNkNDklBhJTfIKvMpcvaaPWtAVGcuiZYPN0qVOPsdkjvmVjo ef3k2PCz9jx2XhcpLMmYFP/cnb3bWRh6C5IQhiDTTC3iXksZZMjAbZT464r+z1f2QA zWWGONfBbyKwzmfv2BSU3FAbG9g3/fpifiw/+69wHfCENqpkR8p70h7vksoCfbvRRw P/GdIpznA4b/OROhL9Wss32R/UHS0hY5eGKa0EYVpkcAkKCFLZv1Bv9xzQpHmb33ub LAvyHe6xEy3Pw== From: Nicolas Dufresne To: Ezequiel Garcia , Mauro Carvalho Chehab , Greg Kroah-Hartman , Boris Brezillon , Hans Verkuil Cc: kernel@collabora.com, Nicolas Dufresne , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/4] media: rkvdec: Fix RKVDEC_ERR_PKT_NUM macro Date: Fri, 23 Dec 2022 14:38:04 -0500 Message-Id: <20221223193807.914935-3-nicolas.dufresne@collabora.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221223193807.914935-1-nicolas.dufresne@collabora.com> References: <20221223193807.914935-1-nicolas.dufresne@collabora.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This information is expressed by bits [29:16], but the actual implementation was reading bits [13:0] and shifting that 16 bits to the left. Fixes: cd33c830448ba ("media: rkvdec: Add the rkvdec driver") Signed-off-by: Nicolas Dufresne --- drivers/staging/media/rkvdec/rkvdec-regs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/rkvdec/rkvdec-regs.h b/drivers/staging/media/rkvdec/rkvdec-regs.h index 15b9bee92016c..14530b81560ed 100644 --- a/drivers/staging/media/rkvdec/rkvdec-regs.h +++ b/drivers/staging/media/rkvdec/rkvdec-regs.h @@ -212,7 +212,7 @@ #define RKVDEC_REG_H264_ERRINFO_NUM 0x130 #define RKVDEC_SLICEDEC_NUM(x) ((x) & 0x3fff) #define RKVDEC_STRMD_DECT_ERR_FLAG BIT(15) -#define RKVDEC_ERR_PKT_NUM(x) (((x) & 0x3fff) << 16) +#define RKVDEC_ERR_PKT_NUM(x) ((x >> 16) & 0x3fff) #define RKVDEC_REG_H264_ERR_E 0x134 #define RKVDEC_H264_ERR_EN_HIGHBITS(x) ((x) & 0x3fffffff) From patchwork Fri Dec 23 19:38:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Dufresne X-Patchwork-Id: 636523 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF620C3DA7A for ; Fri, 23 Dec 2022 19:39:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232608AbiLWTjA (ORCPT ); Fri, 23 Dec 2022 14:39:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232463AbiLWTiz (ORCPT ); Fri, 23 Dec 2022 14:38:55 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FFEB21279; Fri, 23 Dec 2022 11:38:53 -0800 (PST) Received: from whitebuilder.lan (192-222-136-102.qc.cable.ebox.net [192.222.136.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: nicolas) by madras.collabora.co.uk (Postfix) with ESMTPSA id E6C796602CE5; Fri, 23 Dec 2022 19:38:50 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1671824332; bh=fXOPvXl0JOMyURiqQQPd1PF09aMzIcFs5inRLfk9f9o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GWTCg0alf1806OLDZ4WCJibqI95k1TsKq7o1DNvW6mPCYpqhIlu8RIoxRs9XR9f+C OHsHYF+DuO1oNWGBXL2XM3Xmqxai93VGFR63li+19GVTo1S3oLYHKy6duWJ0cmLct0 bNaI/Mw81qug8iC765jeLYwfd1hMFYt5Kx80l/dZpgpA7Wbg5dDeucKaVKVDKz58CM i/olo3EGP90W3KC+j+5UCea8vuF2xy9ubRN0Fq0w/10Tw3gO5d26ktS8DHueVG9AW6 7cH0K7jZnjyR2Hky7fnnwEWux2WpxFZC/AgakvUunSvjMrYP8tvRoEzjtygLHf9ZGN KJFS5wOhCEESw== From: Nicolas Dufresne To: Ezequiel Garcia , Mauro Carvalho Chehab , Greg Kroah-Hartman Cc: kernel@collabora.com, Nicolas Dufresne , linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/4] rkvdec: Improve error handling Date: Fri, 23 Dec 2022 14:38:06 -0500 Message-Id: <20221223193807.914935-5-nicolas.dufresne@collabora.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221223193807.914935-1-nicolas.dufresne@collabora.com> References: <20221223193807.914935-1-nicolas.dufresne@collabora.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org There are two ways decoding errors can occure. In one case, the ready status is not set and nothing has been written into the destination, while in the other case, the buffer is written but may contain a certain amount of errors. In order to differentiate these, we set the payload for the first case to 0. Signed-off-by: Nicolas Dufresne --- drivers/staging/media/rkvdec/rkvdec.c | 31 +++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/drivers/staging/media/rkvdec/rkvdec.c b/drivers/staging/media/rkvdec/rkvdec.c index 7e76f8b728854..11e2bbb20aea1 100644 --- a/drivers/staging/media/rkvdec/rkvdec.c +++ b/drivers/staging/media/rkvdec/rkvdec.c @@ -27,6 +27,9 @@ #include "rkvdec.h" #include "rkvdec-regs.h" +static int debug; +module_param(debug, int, 0644); + static int rkvdec_try_ctrl(struct v4l2_ctrl *ctrl) { struct rkvdec_ctx *ctx = container_of(ctrl->handler, struct rkvdec_ctx, ctrl_hdl); @@ -954,14 +957,34 @@ static irqreturn_t rkvdec_irq_handler(int irq, void *priv) enum vb2_buffer_state state; u32 status; + ctx = v4l2_m2m_get_curr_priv(rkvdec->m2m_dev); status = readl(rkvdec->regs + RKVDEC_REG_INTERRUPT); - state = (status & RKVDEC_RDY_STA) ? - VB2_BUF_STATE_DONE : VB2_BUF_STATE_ERROR; + + if (!(status & RKVDEC_RDY_STA)) { + struct vb2_v4l2_buffer *dst_buf = NULL; + + if (status & RKVDEC_TIMEOUT_STA) + v4l2_dbg(debug, 1, &rkvdec->v4l2_dev, + "Decoder stopped due to an internal timeout."); + else + v4l2_dbg(debug, 1, &rkvdec->v4l2_dev, + "Decoder stopped due to an internal error."); + + /* + * When this happens, the buffer is left unmodified. As it + * contains no meaningful data we mark is as empty. + */ + dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); + vb2_set_plane_payload(&dst_buf->vb2_buf, 0, 0); + state = VB2_BUF_STATE_ERROR; + } else { + state = VB2_BUF_STATE_DONE; + } writel(0, rkvdec->regs + RKVDEC_REG_INTERRUPT); - ctx = v4l2_m2m_get_curr_priv(rkvdec->m2m_dev); - if (ctx->coded_fmt_desc->ops->check_error_info) + if (ctx->coded_fmt_desc->ops->check_error_info && + state == VB2_BUF_STATE_DONE) state = ctx->coded_fmt_desc->ops->check_error_info(ctx); if (cancel_delayed_work(&rkvdec->watchdog_work))