Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp1059889rwj; Fri, 23 Dec 2022 11:58:50 -0800 (PST) X-Google-Smtp-Source: AMrXdXuEt8CaGEyJioPgqqFqpTYxVCpPvbfydDKklXMxT2/TTIwkxRlWlv0rcl062Qf2iPZxO/Yz X-Received: by 2002:a05:6402:f05:b0:46f:9a53:fdcc with SMTP id i5-20020a0564020f0500b0046f9a53fdccmr12218244eda.12.1671825530784; Fri, 23 Dec 2022 11:58:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671825530; cv=none; d=google.com; s=arc-20160816; b=vUEQQresegB2xe0t2p1xpeH9bxNJa19off/Nj4IeDIA0EZBPZFT70rSZKbVQ/yhxF1 XUCMaW1VHNRkVCz/1g2jqdtBW9YJjwko9yDxWJPlq2IQrV8byWKi9GMNZaN2k/Ac/T9s w8wWAa/mh0o9Ag9JRPqHYbWBcLLT7GM/cMoL6acH37XzNXRpuSSasfNRSmKt7VtssmFf KW2fPduVn3d7/5J+Go6rUMwBzCwH5zIOEVrdDrDGYmrVx0y32jwyndVpJ74Od8ItVQP+ RnetZHDhBea7U4CFPWpAxxGlvpzqF6nMUSLSFSjYy0LSlm5ppm6AcqXU7KjiNBmxgiiC Qzuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=I1wHl8E4OdsKHbcSUt03uGDM/vuj7K+InjcMYzzxY0I=; b=vAAU61K/lP6MhC+9hKOGI5f1x902IY5ESNliH8s6tLM7m0AK87B62OlzTxUM8TNIA5 4p9zE0BEoOEjrYlplkARIvBhtt+sLuyRI0nzlij8cAr4r5YwEMQF9oHqGqzFzWznLlsA XDo+xsbcn0DiF811T5ETTe6izacid0Gk5VJe4ixmU7no0sH+mng6seNWE8sH/8WK8a8X GQF01IzW5v8ekgRtL3r02mlUZXH2e1UZA8Yd82WPXaur/KlDg6Vmrzi7TxuXHNlHTDzZ Mqn4TR/Rq1sMDfP3IBMhNryNm5oS7SQTyRcEcO4zCa4GTGfIjbBeBUw8QqLXFC2QC5Hl Y4qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=GWTCg0al; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l6-20020a056402254600b0047314387bc6si3700552edb.297.2022.12.23.11.58.36; Fri, 23 Dec 2022 11:58:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=GWTCg0al; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232874AbiLWTjH (ORCPT + 64 others); Fri, 23 Dec 2022 14:39:07 -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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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)) -- 2.38.1