Message ID | 20230123094300.2816812-1-christianshewitt@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1517339wrn; Mon, 23 Jan 2023 01:49:38 -0800 (PST) X-Google-Smtp-Source: AMrXdXvFtUzL6GQnY/XxyoAjVBJqX58BIZzNVcPKfLhW2PfGztFGJeUy12jdDxrT5pB0khdXU1Bv X-Received: by 2002:a17:907:76ac:b0:857:1e36:3b7b with SMTP id jw12-20020a17090776ac00b008571e363b7bmr24086060ejc.11.1674467377942; Mon, 23 Jan 2023 01:49:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674467377; cv=none; d=google.com; s=arc-20160816; b=yhEyLhRWMdHee3l4zhb1jk+20jEr+xNzo5TBGj4DMN0eGMMJ3cRg+xOfPIbC5KU1jT P4FImngt58LjhnBzW6LS+FVIP0btSBVFO4shRyGoW5Hc2GazyDptv+HbhUEZ828lXkV4 lniSIiHmj69fcTAT1Go9EgwhURZRNti4LA477AGiCUEDxfkKI8WAO3BSK3U+mj1+HezK yD2puWli2aOaGX2MWsDQa9qjDQ1cdKPImy5vwRSt/L/RAmHkE4dQVa+7XTWyk+GQeCSw J4rZ3uzCs5wXaOnypLvnqsGfLmJRC7DHGhs+6oVgxpBoKVrCxGig8+WkZL0TfHNnZDyN B0Mw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=S6BjjeXL8yTJMC0wJlFe+I8I2MsrGeDOh1B+2LIf6wU=; b=cwch6dezhsEdQNbX2SyAUh+S9Dz+YKeHe8UBRLqpLkMPlSWjmj3wEpouyJSTTkCsaD FQAKLnycubvEJqO1OsriPHwoTXYq5GWWBD0akfeygBXI5AjBWs+OdZ0N4uQFbDQ3z+wU I4+XeZLDf44vCsrWYu7ju4QyD6ELmHS6L/1d/DM9puAfK+LdDfTB63nWcISEvSH7o9JP KINo8fSqhwPuHO82oZV74/8rTGjYlrwYq0gGcC/BD4Hst+lG0y5tsNmGdt60u2H6hIPn TpsZ5vbd0aC/+VP3S20nkEdl2XM8bsKxO+zb7pjfHe5XB369KW+vbdHcQohwUlBzxkMS P8pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=agILq6o+; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hb14-20020a170907160e00b00877611b71e1si18108778ejc.622.2023.01.23.01.49.14; Mon, 23 Jan 2023 01:49:37 -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=@gmail.com header.s=20210112 header.b=agILq6o+; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231688AbjAWJnJ (ORCPT <rfc822;forouhar.linux@gmail.com> + 99 others); Mon, 23 Jan 2023 04:43:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230236AbjAWJnI (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 23 Jan 2023 04:43:08 -0500 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10707DBEB; Mon, 23 Jan 2023 01:43:07 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id n7so10187271wrx.5; Mon, 23 Jan 2023 01:43:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=S6BjjeXL8yTJMC0wJlFe+I8I2MsrGeDOh1B+2LIf6wU=; b=agILq6o+GWk4tuFzspZR7fsDXjM2H4OVKJfjyuwFl2UcLwWyZ2gq7A11/LUvn1bsmn cX41gI3USsqEo0h0SFKIGzPQ4sC3hNZ/K08K37HYaJzs6Z3ZhJjVH/uQvO1vLX4IDDHl /g2DEbESv6pj+qqudSDlv6MAt+AlSpUR1KpXm+3FLQe5PpuJEGO3zY9lpIRDMqjKTeFO XotsdfsHHtfNezyDvJY1OHuaoiJRpa0zmozqH+YyBYsujIa4rpPBtflaAaPtoOWR6iFu RzXnWGgaFWcpcV1C48Jrgp7rvQNRLhEOgm3rdbgxY9gO9EJKf00fYME0iYTqR4FnwBNJ ATXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=S6BjjeXL8yTJMC0wJlFe+I8I2MsrGeDOh1B+2LIf6wU=; b=MGZiz1yxpjI1SD6vv5JxOOXxZ+ghR0+F6vbfF0rZOx2Lyrc0anXfClnKcKP0dMIS3b HnrhBBjx1Fo11bcLdkwkNHAsn9t+g5GULHY0ETJVgkB1O8uE83HDONtaq8VlZ9M2A4mB epxAD8W3cQHV059DYmLIx1agXtbhJ4KIbC4xoMhpy/9FzvZTNAlzKVayfeieKW4myP+A 6x9p4IJkQpeIVDxu8Dz0XRdRaLlE9KEtvg1G2bIwlEc8H7uIWXTJOHxLE5JnJwsPEZxs SLivoaVdjBelnfHanc7bjtirCP+Gfg8rOBsqjQJTJp9HIxIUV1LSe/IPLu5pOQc5KZWZ HJZg== X-Gm-Message-State: AFqh2kqNZIk6acdlm8aMqI6m43OwQyWJNq+IIbiQFCGyLshEbnmClsAt zlyVk06wqB1aNye7dvEGF4I= X-Received: by 2002:adf:ce01:0:b0:2bd:e208:1e4c with SMTP id p1-20020adfce01000000b002bde2081e4cmr23690706wrn.11.1674466985537; Mon, 23 Jan 2023 01:43:05 -0800 (PST) Received: from toolbox.. ([87.200.95.144]) by smtp.gmail.com with ESMTPSA id e12-20020adffd0c000000b002bf95821372sm6178158wrr.42.2023.01.23.01.43.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 01:43:05 -0800 (PST) From: Christian Hewitt <christianshewitt@gmail.com> To: Neil Armstrong <neil.armstrong@linaro.org>, Mauro Carvalho Chehab <mchehab@kernel.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Kevin Hilman <khilman@baylibre.com>, Jerome Brunet <jbrunet@baylibre.com>, Martin Blumenstingl <martin.blumenstingl@googlemail.com>, linux-media@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Christian Hewitt <christianshewitt@gmail.com>, Neil Armstrong <narmstrong@baylibre.com> Subject: [PATCH] media: meson: vdec: esparser: check parsing state with hardware write pointer Date: Mon, 23 Jan 2023 09:43:00 +0000 Message-Id: <20230123094300.2816812-1-christianshewitt@gmail.com> X-Mailer: git-send-email 2.34.1 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,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755806305219872347?= X-GMAIL-MSGID: =?utf-8?q?1755806305219872347?= |
Series |
media: meson: vdec: esparser: check parsing state with hardware write pointer
|
|
Commit Message
Christian Hewitt
Jan. 23, 2023, 9:43 a.m. UTC
From: Neil Armstrong <narmstrong@baylibre.com> Also check the hardware write pointer to check if ES Parser has stalled. Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> Signed-off-by: Christian Hewitt <christianshewitt@gmail.com> --- drivers/staging/media/meson/vdec/esparser.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
Comments
On 23/01/2023 10:43, Christian Hewitt wrote: > From: Neil Armstrong <narmstrong@baylibre.com> > > Also check the hardware write pointer to check if ES Parser has stalled. > > Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> > Signed-off-by: Christian Hewitt <christianshewitt@gmail.com> > --- > drivers/staging/media/meson/vdec/esparser.c | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) > > diff --git a/drivers/staging/media/meson/vdec/esparser.c b/drivers/staging/media/meson/vdec/esparser.c > index df5956c6141d..41b705f999b2 100644 > --- a/drivers/staging/media/meson/vdec/esparser.c > +++ b/drivers/staging/media/meson/vdec/esparser.c > @@ -300,6 +300,7 @@ esparser_queue(struct amvdec_session *sess, struct vb2_v4l2_buffer *vbuf) > u32 num_dst_bufs = 0; > u32 offset; > u32 pad_size; > + u32 wp, wp2; > > /* > * When max ref frame is held by VP9, this should be -= 3 to prevent a > @@ -354,15 +355,21 @@ esparser_queue(struct amvdec_session *sess, struct vb2_v4l2_buffer *vbuf) > } > > pad_size = esparser_pad_start_code(core, vb, payload_size); > + wp = amvdec_read_parser(core, PARSER_VIDEO_WP); > ret = esparser_write_data(core, phy, payload_size + pad_size); > + wp2 = amvdec_read_parser(core, PARSER_VIDEO_WP); > > if (ret <= 0) { > - dev_warn(core->dev, "esparser: input parsing error\n"); > - amvdec_remove_ts(sess, vb->timestamp); > - v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR); > amvdec_write_parser(core, PARSER_FETCH_CMD, 0); > > - return 0; > + if (ret < 0 || wp2 == wp) { > + dev_err(core->dev, "esparser: input parsing error ret %d (%x <=> %x)\n", > + ret, wp, wp2); > + amvdec_remove_ts(sess, vb->timestamp); > + v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR); > + > + return 0; > + } > } > > atomic_inc(&sess->esparser_queued_bufs); It's weird, but: Acked-by: Neil Armstrong <neil.armstrong@linaro.org> Thanks Christian for handling those changes Neil
On Mon, Jan 23, 2023 at 09:43:00AM +0000, Christian Hewitt wrote: > From: Neil Armstrong <narmstrong@baylibre.com> > > Also check the hardware write pointer to check if ES Parser has stalled. > Presumably this is something which has happens in real life? Say a user has this hardware and is wondering if this patch fixes their bug, what does this bug look like to them? Please add a Fixes tag. > Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> > Signed-off-by: Christian Hewitt <christianshewitt@gmail.com> > --- > drivers/staging/media/meson/vdec/esparser.c | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) > > diff --git a/drivers/staging/media/meson/vdec/esparser.c b/drivers/staging/media/meson/vdec/esparser.c > index df5956c6141d..41b705f999b2 100644 > --- a/drivers/staging/media/meson/vdec/esparser.c > +++ b/drivers/staging/media/meson/vdec/esparser.c > @@ -300,6 +300,7 @@ esparser_queue(struct amvdec_session *sess, struct vb2_v4l2_buffer *vbuf) > u32 num_dst_bufs = 0; > u32 offset; > u32 pad_size; > + u32 wp, wp2; > > /* > * When max ref frame is held by VP9, this should be -= 3 to prevent a > @@ -354,15 +355,21 @@ esparser_queue(struct amvdec_session *sess, struct vb2_v4l2_buffer *vbuf) > } > > pad_size = esparser_pad_start_code(core, vb, payload_size); > + wp = amvdec_read_parser(core, PARSER_VIDEO_WP); > ret = esparser_write_data(core, phy, payload_size + pad_size); > + wp2 = amvdec_read_parser(core, PARSER_VIDEO_WP); > Why is check not done inside the esparser_write_data() function? It really feels like doing a write where nothing happens should be a bug for both callers... The esparser_write_data() function returns > 0 on success, 0 on timeout (I guess timeout is an error-ish) and negative if the user presses CTR-C. There are no comments to explain the unusual returns. Could we clean this up so it just returns negatives on error and zero on success or if not then let's add a comment explaining what's going on? > if (ret <= 0) { > - dev_warn(core->dev, "esparser: input parsing error\n"); > - amvdec_remove_ts(sess, vb->timestamp); > - v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR); > amvdec_write_parser(core, PARSER_FETCH_CMD, 0); > > - return 0; > + if (ret < 0 || wp2 == wp) { So in this patch if there is a timeout but something was written then that's kind of a success path? regards, dan carpenter > + dev_err(core->dev, "esparser: input parsing error ret %d (%x <=> %x)\n", > + ret, wp, wp2); > + amvdec_remove_ts(sess, vb->timestamp); > + v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR); > + > + return 0; > + } > } > > atomic_inc(&sess->esparser_queued_bufs);
Hi Christian, On 23/01/2023 13:04, Dan Carpenter wrote: > On Mon, Jan 23, 2023 at 09:43:00AM +0000, Christian Hewitt wrote: >> From: Neil Armstrong <narmstrong@baylibre.com> >> >> Also check the hardware write pointer to check if ES Parser has stalled. >> > > Presumably this is something which has happens in real life? Say a user > has this hardware and is wondering if this patch fixes their bug, what > does this bug look like to them? > > Please add a Fixes tag. I'm marking this as Changes Requested in patchwork. Dan has good comments, and in general, if something is 'weird', then it needs to be commented carefully. Regards, Hans > >> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> >> Signed-off-by: Christian Hewitt <christianshewitt@gmail.com> >> --- >> drivers/staging/media/meson/vdec/esparser.c | 15 +++++++++++---- >> 1 file changed, 11 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/staging/media/meson/vdec/esparser.c b/drivers/staging/media/meson/vdec/esparser.c >> index df5956c6141d..41b705f999b2 100644 >> --- a/drivers/staging/media/meson/vdec/esparser.c >> +++ b/drivers/staging/media/meson/vdec/esparser.c >> @@ -300,6 +300,7 @@ esparser_queue(struct amvdec_session *sess, struct vb2_v4l2_buffer *vbuf) >> u32 num_dst_bufs = 0; >> u32 offset; >> u32 pad_size; >> + u32 wp, wp2; >> >> /* >> * When max ref frame is held by VP9, this should be -= 3 to prevent a >> @@ -354,15 +355,21 @@ esparser_queue(struct amvdec_session *sess, struct vb2_v4l2_buffer *vbuf) >> } >> >> pad_size = esparser_pad_start_code(core, vb, payload_size); >> + wp = amvdec_read_parser(core, PARSER_VIDEO_WP); >> ret = esparser_write_data(core, phy, payload_size + pad_size); >> + wp2 = amvdec_read_parser(core, PARSER_VIDEO_WP); >> > > Why is check not done inside the esparser_write_data() function? It > really feels like doing a write where nothing happens should be a bug > for both callers... > > The esparser_write_data() function returns > 0 on success, 0 on timeout > (I guess timeout is an error-ish) and negative if the user presses > CTR-C. There are no comments to explain the unusual returns. Could we > clean this up so it just returns negatives on error and zero on success > or if not then let's add a comment explaining what's going on? > >> if (ret <= 0) { >> - dev_warn(core->dev, "esparser: input parsing error\n"); >> - amvdec_remove_ts(sess, vb->timestamp); >> - v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR); >> amvdec_write_parser(core, PARSER_FETCH_CMD, 0); >> >> - return 0; >> + if (ret < 0 || wp2 == wp) { > > So in this patch if there is a timeout but something was written then > that's kind of a success path? > > regards, > dan carpenter > >> + dev_err(core->dev, "esparser: input parsing error ret %d (%x <=> %x)\n", >> + ret, wp, wp2); >> + amvdec_remove_ts(sess, vb->timestamp); >> + v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR); >> + >> + return 0; >> + } >> } >> >> atomic_inc(&sess->esparser_queued_bufs); >
diff --git a/drivers/staging/media/meson/vdec/esparser.c b/drivers/staging/media/meson/vdec/esparser.c index df5956c6141d..41b705f999b2 100644 --- a/drivers/staging/media/meson/vdec/esparser.c +++ b/drivers/staging/media/meson/vdec/esparser.c @@ -300,6 +300,7 @@ esparser_queue(struct amvdec_session *sess, struct vb2_v4l2_buffer *vbuf) u32 num_dst_bufs = 0; u32 offset; u32 pad_size; + u32 wp, wp2; /* * When max ref frame is held by VP9, this should be -= 3 to prevent a @@ -354,15 +355,21 @@ esparser_queue(struct amvdec_session *sess, struct vb2_v4l2_buffer *vbuf) } pad_size = esparser_pad_start_code(core, vb, payload_size); + wp = amvdec_read_parser(core, PARSER_VIDEO_WP); ret = esparser_write_data(core, phy, payload_size + pad_size); + wp2 = amvdec_read_parser(core, PARSER_VIDEO_WP); if (ret <= 0) { - dev_warn(core->dev, "esparser: input parsing error\n"); - amvdec_remove_ts(sess, vb->timestamp); - v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR); amvdec_write_parser(core, PARSER_FETCH_CMD, 0); - return 0; + if (ret < 0 || wp2 == wp) { + dev_err(core->dev, "esparser: input parsing error ret %d (%x <=> %x)\n", + ret, wp, wp2); + amvdec_remove_ts(sess, vb->timestamp); + v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR); + + return 0; + } } atomic_inc(&sess->esparser_queued_bufs);