From patchwork Fri Dec 23 19:38:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Dufresne X-Patchwork-Id: 13081084 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B4A9BC4332F for ; Fri, 23 Dec 2022 19:39:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uvbFVEqO7CvrMtK+LVA/GP02x+087jyPbBP7rK60ozk=; b=G9rdXnyje2WJ9W IrC7JO1iIOiCveJKSiEyTswkwcdwan5Gpg/xegypLBu7GwhmTNJ08pkbECzkXFgeuzWoMiH+qRMoU kNLMGcQLSf5cv98FL0xHAxb3R+KhAzkETnF6B2YpG3bFzYLQVCfcEvGib7st4b+t4MWuHkvi8vOpU cIskdutIvFPSMdhup6/+bNOUCwOvs3wlFqyN839zYYqT162IdXXLknH96l2dTe5puxbWa7y/qK0UW XqUq2A2ZOuYsw65+H6vKBt+J9+3NF2azWsf4J1HY1tS8UR4Yg/IAPb7qvzBvO3P+2Kjz6niEsCa/6 UTH3f0DqADLXNf2eWWHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p8nsU-00BbxM-5k; Fri, 23 Dec 2022 19:38:46 +0000 Received: from madras.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e5ab]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p8nsR-00Bbs2-4H for linux-rockchip@lists.infradead.org; Fri, 23 Dec 2022 19:38:45 +0000 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 8DACE6602CDF; Fri, 23 Dec 2022 19:38:37 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1671824318; bh=6GcOabw66VsX84Z/gphQUubf54+X891g3yoPH/UbEEY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IS+eubJThqDCFvet2vxtMhCIIxaTBSisgP3jlJXdfRMboqhzqtAohn3eTY/kHiCGv bhOJc4Q9Mri0cG+gD/pNOY4Ux/uPOz1igJVblO7qQaTrE13MgZsKHWpivf72sL9JxL xXPB9WMSKho3xdK1mYz80zTPVEy1VQFrCt8cn5Vy8/a0MPZ6kgd7M1aqoEAmLlHwjW 4w3r5YbiGgUg65S5lFT7bLJ9XYo9L7F4f+QYPiQ084zj3vbazndqxWfsiWmXQs+sfA ZDzp7FvKvvR0tKNEv5y1m6DEt24Hxrv5VLTq9injYmS+qg6+orM/d//pwNy8lZsU3G rqawE9lwSJHKA== 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 1/4] media: rkvdec: Add an ops to check for decode errors Date: Fri, 23 Dec 2022 14:38:03 -0500 Message-Id: <20221223193807.914935-2-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221223_113843_388881_DA09B0D7 X-CRM114-Status: GOOD ( 12.73 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org This optional internal ops allow each codec to do their own error status checking. The presence of an error is reported using the ERROR buffer state. This patch have no functional changes. Signed-off-by: Nicolas Dufresne --- drivers/staging/media/rkvdec/rkvdec.c | 10 ++++++---- drivers/staging/media/rkvdec/rkvdec.h | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/staging/media/rkvdec/rkvdec.c b/drivers/staging/media/rkvdec/rkvdec.c index 7bab7586918c1..7e76f8b728854 100644 --- a/drivers/staging/media/rkvdec/rkvdec.c +++ b/drivers/staging/media/rkvdec/rkvdec.c @@ -950,6 +950,7 @@ static void rkvdec_v4l2_cleanup(struct rkvdec_dev *rkvdec) static irqreturn_t rkvdec_irq_handler(int irq, void *priv) { struct rkvdec_dev *rkvdec = priv; + struct rkvdec_ctx *ctx; enum vb2_buffer_state state; u32 status; @@ -958,12 +959,13 @@ static irqreturn_t rkvdec_irq_handler(int irq, void *priv) VB2_BUF_STATE_DONE : VB2_BUF_STATE_ERROR; writel(0, rkvdec->regs + RKVDEC_REG_INTERRUPT); - if (cancel_delayed_work(&rkvdec->watchdog_work)) { - struct rkvdec_ctx *ctx; + ctx = v4l2_m2m_get_curr_priv(rkvdec->m2m_dev); - ctx = v4l2_m2m_get_curr_priv(rkvdec->m2m_dev); + if (ctx->coded_fmt_desc->ops->check_error_info) + state = ctx->coded_fmt_desc->ops->check_error_info(ctx); + + if (cancel_delayed_work(&rkvdec->watchdog_work)) rkvdec_job_finish(ctx, state); - } return IRQ_HANDLED; } diff --git a/drivers/staging/media/rkvdec/rkvdec.h b/drivers/staging/media/rkvdec/rkvdec.h index 633335ebb9c49..4ae8e6c6b03c9 100644 --- a/drivers/staging/media/rkvdec/rkvdec.h +++ b/drivers/staging/media/rkvdec/rkvdec.h @@ -73,6 +73,8 @@ struct rkvdec_coded_fmt_ops { struct vb2_v4l2_buffer *dst_buf, enum vb2_buffer_state result); int (*try_ctrl)(struct rkvdec_ctx *ctx, struct v4l2_ctrl *ctrl); + /* called from IRQ handler */ + int (*check_error_info)(struct rkvdec_ctx *ctx); }; struct rkvdec_coded_fmt_desc { 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: 13081086 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A4C2DC3DA79 for ; Fri, 23 Dec 2022 19:39:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qVfg9TkZDioiKaWh+vlPIB/cX/O2uEEdNFH6tbLt3nk=; b=lme+u+wr8qLzeT a3GjI1BiTF1Lpt8jE5wqbQ/jxhAInY3V02HzLw410pIQc/EEjRenHdCAtHtv3bM6mrfHXA5QK9GBO 33XGyHqt865T8Fx3HEtf4jziQEM3K+PcIu1EUwbXLhXnr3eyXHbj6ig2kgUqSzo1JMsLFwk6l87kx YftcZur6XuGqI//IpNYzaRrPgpsz5nwhW8okpur2r5F6shvG3TYN38us5hgU7tNPx3B1PqlcoMGTL AZPIXPgkBU2zhQVAZUoddjoSHraU7d9rkuCtROmbR0NMK6X+GDb5fshN6TSGLo9Pw7T4uR/V9WTVd AxG/bErrn8D3us8C747A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p8nsl-00BcBv-LW; Fri, 23 Dec 2022 19:39:03 +0000 Received: from madras.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e5ab]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p8nsW-00BbyF-UP for linux-rockchip@lists.infradead.org; Fri, 23 Dec 2022 19:38:50 +0000 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221223_113849_152353_E6D52FDD X-CRM114-Status: UNSURE ( 9.59 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.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:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Dufresne X-Patchwork-Id: 13081085 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0DC8AC4167B for ; Fri, 23 Dec 2022 19:39:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UHY10lQXZmj5yyhlj62Ij+KQifvcu+5/TOre9KOZOY8=; b=EIunNfDrLs/IEz Hh8tU24vVQ+7DCqKsnMaYHzfXOnZze2rxXPeG3nbITQx+KZmtkovdp3aOQuCZC51zay3AJuyhaQd+ 9ymjj1+jCjUlocuY7pI33r0Tes0b3o4paXvZ3lR3vOvMPAHSa4CaABxO5vJdOaQ6ZgKM/61QKDQ73 6jy95s1MvpL3OJX6Z0/zFFnxNbAORalUycyBOm3Lz/xAtQePVLizjuqmLWvU1FrLd2glKhWKvGW3L QOEc48Ln8Ffsj8xk6Ol7y6Ae/oFgFh6yqg3UctOhQQnK2+i0gSssBRki/hOPfYWRqj+zVsu9Nb3wf CpJKV2YBHaD6fSZ1TKsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p8nsn-00BcCa-0v; Fri, 23 Dec 2022 19:39:05 +0000 Received: from madras.collabora.co.uk ([46.235.227.172]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p8nsb-00Bc0R-2X for linux-rockchip@lists.infradead.org; Fri, 23 Dec 2022 19:38:55 +0000 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 C02906602CDF; Fri, 23 Dec 2022 19:38:48 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1671824329; bh=TUAr5G3EJwUIxmCfLgOCFNIvuOyhhl3yWtc6GNPry2I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lvcIaKKR/tt7H4Ib7/Uo1TNLUWO/jCNSbZeEk3Vxoh2bBTJl8KGOwpmtZAcWzHOkX jW3Y+vGfSvNWfEr0kBiqF4W34+dDF5PgjHg6zrECJY+toAXdQXUK8U+vWH59Jh5t4m pwNWuQ6GS7XdBo6TLwZYVlzRm5GyIcOpjQ3aYcBL9XgQ1UNq7ejSG9AILoyc3BsU+4 /JsdhbpP9xTC5b61WCfANZC7pu8T2c8ZRjOHFdpbGu4hGm7Y0RMD4u2bkveZlUpQAj 7Q41Nw1Lpy9XaG5cLF9G6wJ/5r3xfY2i/fofZkIn94/w3O8yI1JYBDkpfSIVqUfwZ8 EaVTmMHPYNn/w== 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 3/4] media: rkvdec: Re-enable H.264 error detection Date: Fri, 23 Dec 2022 14:38:05 -0500 Message-Id: <20221223193807.914935-4-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221223_113853_295277_C8B2E450 X-CRM114-Status: GOOD ( 13.34 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org This re-enable H.264 error detection, but using the other error mode. In that mode, the decoder will skip over the error macro-block or slices and complete the decoding. As a side effect, the error status is not set in the interrupt status register, and instead errors are detected per format. Using this mode workaround the issue that the HW get stuck in error state, and allow reporting that some corruption may be present in the buffer to userland. Signed-off-by: Nicolas Dufresne Reviewed-by: Chen-Yu Tsai --- drivers/staging/media/rkvdec/rkvdec-h264.c | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/rkvdec/rkvdec-h264.c b/drivers/staging/media/rkvdec/rkvdec-h264.c index 4fc167b42cf0c..dfe3e235f099a 100644 --- a/drivers/staging/media/rkvdec/rkvdec-h264.c +++ b/drivers/staging/media/rkvdec/rkvdec-h264.c @@ -1162,14 +1162,15 @@ static int rkvdec_h264_run(struct rkvdec_ctx *ctx) schedule_delayed_work(&rkvdec->watchdog_work, msecs_to_jiffies(2000)); - writel(0, rkvdec->regs + RKVDEC_REG_STRMD_ERR_EN); - writel(0, rkvdec->regs + RKVDEC_REG_H264_ERR_E); + writel(0xffffffff, rkvdec->regs + RKVDEC_REG_STRMD_ERR_EN); + writel(0xffffffff, rkvdec->regs + RKVDEC_REG_H264_ERR_E); writel(1, rkvdec->regs + RKVDEC_REG_PREF_LUMA_CACHE_COMMAND); writel(1, rkvdec->regs + RKVDEC_REG_PREF_CHR_CACHE_COMMAND); /* Start decoding! */ writel(RKVDEC_INTERRUPT_DEC_E | RKVDEC_CONFIG_DEC_CLK_GATE_E | - RKVDEC_TIMEOUT_E | RKVDEC_BUF_EMPTY_E, + RKVDEC_TIMEOUT_E | RKVDEC_BUF_EMPTY_E | + RKVDEC_H264ORVP9_ERR_MODE, rkvdec->regs + RKVDEC_REG_INTERRUPT); return 0; @@ -1183,10 +1184,26 @@ static int rkvdec_h264_try_ctrl(struct rkvdec_ctx *ctx, struct v4l2_ctrl *ctrl) return 0; } +static int rkvdec_h264_check_error_info(struct rkvdec_ctx *ctx) +{ + struct rkvdec_dev *rkvdec = ctx->dev; + int err; + + err = readl(rkvdec->regs + RKVDEC_REG_H264_ERRINFO_NUM); + if (err & RKVDEC_STRMD_DECT_ERR_FLAG) { + pr_debug("Decoded picture have %i/%i slices with errors.\n", + RKVDEC_ERR_PKT_NUM(err), RKVDEC_SLICEDEC_NUM(err)); + return VB2_BUF_STATE_ERROR; + } + + return VB2_BUF_STATE_DONE; +} + const struct rkvdec_coded_fmt_ops rkvdec_h264_fmt_ops = { .adjust_fmt = rkvdec_h264_adjust_fmt, .start = rkvdec_h264_start, .stop = rkvdec_h264_stop, .run = rkvdec_h264_run, .try_ctrl = rkvdec_h264_try_ctrl, + .check_error_info = rkvdec_h264_check_error_info, }; 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: 13081087 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7A590C4332F for ; Fri, 23 Dec 2022 19:39:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wwWky5hMCIhiIoVv3fICNYvIW2SXUDSdWt+3u+ARsfM=; b=kteKK787eVc5yq 3JTHnJrmSj139pfTeMKDLOtheBTqLt4yAb3HMQ6LMGF3TtLkuL+N8NU6fOrZ1QK5r4D7LQstDIdQS yEje1AuJm6H9ggFWpDpFskBmSjcoiwbhxkS6VDo0pcXw3gwmPyjhErR3gOdOFk4L2bPkmlimA2apx iyP44zl1H2wJjyZptTDk1sPN8n16SmYQST+MUdYoB6x3rZG01eHwRoPoEG0WIpORQR6o1X249ybQr A9wGeZsDFsppgvq9K4cbpEpgJ3BcOJbIbvl4CVa/WXgXSFqRZHn1dTOKcGM++4pmafXM/bcKyM3WY aAnjennskaiMTM7O2WkA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p8nsn-00BcD9-WA; Fri, 23 Dec 2022 19:39:06 +0000 Received: from madras.collabora.co.uk ([46.235.227.172]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p8nsb-00Bc2L-AC for linux-rockchip@lists.infradead.org; Fri, 23 Dec 2022 19:38:55 +0000 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221223_113853_529066_63379BE6 X-CRM114-Status: GOOD ( 13.51 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.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))