Message ID | 20231012114642.19040-42-benjamin.gaignard@collabora.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1166556vqb; Thu, 12 Oct 2023 04:51:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGJJ+otbf/WjtPCLY9RYXDaA+md1ua7tVw4dfaO1BCUNNiSjr+PnIdwm/7/eQuOb31okDPA X-Received: by 2002:a17:902:dac8:b0:1bf:1a9e:85f7 with SMTP id q8-20020a170902dac800b001bf1a9e85f7mr27100121plx.1.1697111479391; Thu, 12 Oct 2023 04:51:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111479; cv=none; d=google.com; s=arc-20160816; b=ZdQoJf/exzXFoofYjQIyZyZTVrYr25GsDYkhJzqn6jdCod2A2H3/6R986Tph+WEkgc 9B6KXXkMExDLh2pvfNuwyrzMWF67DJvjm8rKiMMzPa/QaljdaTMUVRALZ7+Y1NLgnb7E cLYmM/+y8oqrMEyCMdv50HoXD6A5CuzzVpcwQ18UxXMZ8nlISr2QHTXkHJngobLDaRVh 4XYndgflSni9jIZnSKhHV7eSgUOoQRY8pQewaw9yttMzMg9FLrwMPxB9LsRAZ9Tjql+q +PPrcY7pl88HNEUSaMOzQiJiwDjFuoyg/+dXJEQCC9HkIu5HSKCHzrPlZe8ekx+rw/os 3WvA== 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=362WKbueytuHEGcwCkpvyPQdlAvKGzTlZTHPMJDeEK0=; fh=XOQPNehgv2/6iNwDVzIYzJa3sauUpivvTAZ7odRKM4M=; b=lWooesvFDZPhR2iO6DlPx1+g6pjRogI0BZgvfxQqnC4n9eASB0tiU6in273zQN73Vx 7uaDvglLGLtHyulma9+PgBxfNYEbz+PqbpHGS/Nm0PhjsvK/uF/gR/i3L+ug6a9gfsyT H310LBrN/Ay8qnfkWhDG+wE77AshJsQpAH6SLys5p6P+mIX1X8yJ4OiMj/d9CBMjbaXM k7mZveJO6zVMS69FYt7dUaBZcsGD9h5ln2d1Az+d4MU3fe5EcIgpwkIhryWaAp03kOJJ bedv8EevxCnQiI1gJeELA+nndi+sOQjK0IyBTdzF1XjTLv5Fyk9O/AyNsEzIQmufApww 2GPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=hUw3QnNY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id i18-20020a17090332d200b001c35cccca33si2149279plr.448.2023.10.12.04.51.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:51:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=hUw3QnNY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 5908D83741F0; Thu, 12 Oct 2023 04:50:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343857AbjJLLtn (ORCPT <rfc822;rua109.linux@gmail.com> + 19 others); Thu, 12 Oct 2023 07:49:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378958AbjJLLrd (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 12 Oct 2023 07:47:33 -0400 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 ED766C4; Thu, 12 Oct 2023 04:47:12 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id 3B5AF660739E; Thu, 12 Oct 2023 12:47:11 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111231; bh=jcGjQtwVZXm/63GKjgXKs2SZ3PMRIqgDfC2W6RW1MBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hUw3QnNYwlyaE6Ckbn5bcMVNybTrPj/hvxoTs5pGfX4Izeh0pkb2QsbUu7Z00U1p8 STjuKlaZDCUmdVgjAvhvRznkEjFw7H9wyQntvY1DRS5PoFX+dcnNmhxMGOTwp3vVJO n0Of2tqIBcemUrFFVI48DiTCV4GWOhaDaw5B/X/cdvpS0D+heq3d7J8KCtkOQXnyQ1 Zpzej9wBc9pRO1+IcVcTsEStnucuC4XzCaQk8NEztBe2Q0ERVYTy2zgI1tSFk7kSNh iVBni6QZL+lAampGQ5FHe8K/+VR2irTZeC7ss110pUnWh06FP0Zvld+5wFYPvmkcLV 5SMLdxzTHP0JQ== From: Benjamin Gaignard <benjamin.gaignard@collabora.com> To: mchehab@kernel.org, tfiga@chromium.org, m.szyprowski@samsung.com, ming.qian@nxp.com, ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de, gregkh@linuxfoundation.org, hverkuil-cisco@xs4all.nl, nicolas.dufresne@collabora.com Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-staging@lists.linux.dev, kernel@collabora.com, Benjamin Gaignard <benjamin.gaignard@collabora.com>, Maxime Ripard <mripard@kernel.org>, Paul Kocialkowski <paul.kocialkowski@bootlin.com> Subject: [PATCH v11 41/56] media: cedrus: Stop direct calls to queue num_buffers field Date: Thu, 12 Oct 2023 13:46:27 +0200 Message-Id: <20231012114642.19040-42-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:50:17 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550366644130747 X-GMAIL-MSGID: 1779550366644130747 |
Series |
Add DELETE_BUF ioctl
|
|
Commit Message
Benjamin Gaignard
Oct. 12, 2023, 11:46 a.m. UTC
Use vb2_get_num_buffers() and queue max_num_buffers field
to avoid using queue num_buffer field directly.
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
CC: Maxime Ripard <mripard@kernel.org>
CC: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
drivers/staging/media/sunxi/cedrus/cedrus_h264.c | 8 ++++++--
drivers/staging/media/sunxi/cedrus/cedrus_h265.c | 9 +++++++--
2 files changed, 13 insertions(+), 4 deletions(-)
Comments
Hi Benjamin, On Thu 12 Oct 23, 13:46, Benjamin Gaignard wrote: > Use vb2_get_num_buffers() and queue max_num_buffers field > to avoid using queue num_buffer field directly. Thanks for the patch, this is indeed a nice cleanup and safer usage. Maybe the commit message needs to reflect why this change is welcome, not just what is being changed. > Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com> > CC: Maxime Ripard <mripard@kernel.org> > CC: Paul Kocialkowski <paul.kocialkowski@bootlin.com> > --- > drivers/staging/media/sunxi/cedrus/cedrus_h264.c | 8 ++++++-- > drivers/staging/media/sunxi/cedrus/cedrus_h265.c | 9 +++++++-- > 2 files changed, 13 insertions(+), 4 deletions(-) > > diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c > index dfb401df138a..95e490532a87 100644 > --- a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c > +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c > @@ -653,8 +653,12 @@ static void cedrus_h264_stop(struct cedrus_ctx *ctx) > > vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); > > - for (i = 0; i < vq->num_buffers; i++) { > - buf = vb2_to_cedrus_buffer(vb2_get_buffer(vq, i)); > + for (i = 0; i < vb2_get_num_buffers(vq); i++) { > + struct vb2_buffer *vb = vb2_get_buffer(vq, i); > + > + if (!vb) > + continue; Please add a newline here to be consistent with the other block being changed. With this change and the commit log reworked, you can consider this: Acked-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com> Thanks! Paul > + buf = vb2_to_cedrus_buffer(vb); > > if (buf->codec.h264.mv_col_buf_size > 0) { > dma_free_attrs(dev->dev, > diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c > index fc9297232456..52e94c8f2f01 100644 > --- a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c > +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c > @@ -869,8 +869,13 @@ static void cedrus_h265_stop(struct cedrus_ctx *ctx) > > vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); > > - for (i = 0; i < vq->num_buffers; i++) { > - buf = vb2_to_cedrus_buffer(vb2_get_buffer(vq, i)); > + for (i = 0; i < vb2_get_num_buffers(vq); i++) { > + struct vb2_buffer *vb = vb2_get_buffer(vq, i); > + > + if (!vb) > + continue; > + > + buf = vb2_to_cedrus_buffer(vb); > > if (buf->codec.h265.mv_col_buf_size > 0) { > dma_free_attrs(dev->dev, > -- > 2.39.2 >
Le 17/10/2023 à 10:54, Paul Kocialkowski a écrit : > Hi Benjamin, > > On Thu 12 Oct 23, 13:46, Benjamin Gaignard wrote: >> Use vb2_get_num_buffers() and queue max_num_buffers field >> to avoid using queue num_buffer field directly. > Thanks for the patch, this is indeed a nice cleanup and safer usage. > Maybe the commit message needs to reflect why this change is welcome, > not just what is being changed. I will add this comment in the commit message: This allows us to change how the number of buffers is computed in the futur. > >> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com> >> CC: Maxime Ripard <mripard@kernel.org> >> CC: Paul Kocialkowski <paul.kocialkowski@bootlin.com> >> --- >> drivers/staging/media/sunxi/cedrus/cedrus_h264.c | 8 ++++++-- >> drivers/staging/media/sunxi/cedrus/cedrus_h265.c | 9 +++++++-- >> 2 files changed, 13 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c >> index dfb401df138a..95e490532a87 100644 >> --- a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c >> +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c >> @@ -653,8 +653,12 @@ static void cedrus_h264_stop(struct cedrus_ctx *ctx) >> >> vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); >> >> - for (i = 0; i < vq->num_buffers; i++) { >> - buf = vb2_to_cedrus_buffer(vb2_get_buffer(vq, i)); >> + for (i = 0; i < vb2_get_num_buffers(vq); i++) { >> + struct vb2_buffer *vb = vb2_get_buffer(vq, i); >> + >> + if (!vb) >> + continue; > Please add a newline here to be consistent with the other block being changed. > > With this change and the commit log reworked, you can consider this: > Acked-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com> That will be done for the next version. Thanks, Benjamin > > Thanks! > > Paul > >> + buf = vb2_to_cedrus_buffer(vb); >> >> if (buf->codec.h264.mv_col_buf_size > 0) { >> dma_free_attrs(dev->dev, >> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c >> index fc9297232456..52e94c8f2f01 100644 >> --- a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c >> +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c >> @@ -869,8 +869,13 @@ static void cedrus_h265_stop(struct cedrus_ctx *ctx) >> >> vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); >> >> - for (i = 0; i < vq->num_buffers; i++) { >> - buf = vb2_to_cedrus_buffer(vb2_get_buffer(vq, i)); >> + for (i = 0; i < vb2_get_num_buffers(vq); i++) { >> + struct vb2_buffer *vb = vb2_get_buffer(vq, i); >> + >> + if (!vb) >> + continue; >> + >> + buf = vb2_to_cedrus_buffer(vb); >> >> if (buf->codec.h265.mv_col_buf_size > 0) { >> dma_free_attrs(dev->dev, >> -- >> 2.39.2 >>
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c index dfb401df138a..95e490532a87 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c @@ -653,8 +653,12 @@ static void cedrus_h264_stop(struct cedrus_ctx *ctx) vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); - for (i = 0; i < vq->num_buffers; i++) { - buf = vb2_to_cedrus_buffer(vb2_get_buffer(vq, i)); + for (i = 0; i < vb2_get_num_buffers(vq); i++) { + struct vb2_buffer *vb = vb2_get_buffer(vq, i); + + if (!vb) + continue; + buf = vb2_to_cedrus_buffer(vb); if (buf->codec.h264.mv_col_buf_size > 0) { dma_free_attrs(dev->dev, diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c index fc9297232456..52e94c8f2f01 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c @@ -869,8 +869,13 @@ static void cedrus_h265_stop(struct cedrus_ctx *ctx) vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); - for (i = 0; i < vq->num_buffers; i++) { - buf = vb2_to_cedrus_buffer(vb2_get_buffer(vq, i)); + for (i = 0; i < vb2_get_num_buffers(vq); i++) { + struct vb2_buffer *vb = vb2_get_buffer(vq, i); + + if (!vb) + continue; + + buf = vb2_to_cedrus_buffer(vb); if (buf->codec.h265.mv_col_buf_size > 0) { dma_free_attrs(dev->dev,