From patchwork Tue Oct 3 08:06:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 147733 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1929882vqb; Tue, 3 Oct 2023 01:11:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFUfNQGA3bHyUK3QzCLSoIjahbPxjZrErCjy4LbidGu3qiFifVmMAxZ4PgASKa7JjOJKZGO X-Received: by 2002:a05:6a00:1825:b0:68e:2c3a:8775 with SMTP id y37-20020a056a00182500b0068e2c3a8775mr15000167pfa.33.1696320698025; Tue, 03 Oct 2023 01:11:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320698; cv=none; d=google.com; s=arc-20160816; b=Gdwlm9PkTWXSauRV1cXIzH53Tu4W21rLjZiA0GV+qJn5yEcJWSHeQMaIOslFuw02Uf pkQfnDvYPoW6X9oO6HdUvrrvexTw86cU6io8BCsPL6rsnj3xkKavczUMZUmp2AKozZBj H/NvYb8sQhdE5VSJR1OdqY896fo9C9dNmwV35VuObAvKf07GLYOkIf0HxCPLKpwJRLvB buVLOzcph1dt81Pnn5gJud0T+x5AINP6bICbvceh2MfK1WONnQHc1fF/KA4XETwn5i98 VgcKCaUNstbH+XCb7/m+M54rrJ/sqLj9lM6inwGB3XOIYhj0yHmOcRA2AGjSLK+ttveV nT3Q== 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=VX8R6FNAbkZWYkueMBme92XT1wQcqt/mdQigvZGLeSI=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=xXikuZcAR6DiiKKfrhSXBLekixnp4GQBntOYfLYdrkniRm8vzp2B52ty+2llhcX4I3 W3p6Qufd5FYUojE1BWm+f92pXnaOTgQzgtqZGNHpaN+7McEn9yqSuLBXYzrVmbqNr9Fc UStrg3QdSivFQhqTk3xbfWaP/0mTz3DwQViGQFTzJibQdSSOBn8qtfbG1dBM6yifEqXl 62VItw/eYNisjily4iHjA6U0CanBTH4EM/sxWJbIBZCIFNDIXmy0qBR58DcCBu4YLvMC OUitEAb07xCLoBTSt1Ay783297tLTALjxFB2qXfj6ruiF4A+fh0FAEnVvsXspPydlWG0 I2BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=CeGOACJ6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id bk13-20020a056a02028d00b005859b1b34f7si926925pgb.862.2023.10.03.01.11.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:11:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=CeGOACJ6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 786958153D09; Tue, 3 Oct 2023 01:11:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239610AbjJCIKr (ORCPT + 18 others); Tue, 3 Oct 2023 04:10:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239350AbjJCIIB (ORCPT ); Tue, 3 Oct 2023 04:08:01 -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 832F91BF; Tue, 3 Oct 2023 01:07:39 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 63D8766072E6; Tue, 3 Oct 2023 09:07:37 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320457; bh=KSp/qlyb4qZpMVJTjYq3/CPJYCUJtKhZMjqFSVLO9ao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CeGOACJ68l3iNAs2qo3ldowsagtp3cQicupSSWr2Ye9NBptxqIknD2Qdj3nGICTHo zI+phreMwrpQh7Z+RsgOBSHdtVZkmmOxxSvHyqiYk5Tbd5acFCMXOEtjGYo2XNOu3B 3Px116X5jpfboXh1CZ/Lt5DDtj3vbnIPexTdgbPDyfusBRT4zwzbisHdUvwVQVLdor EDF5oGHdxdyF4+QdbWesfHWXG5e9xfyyJSfdqPHdm7olxMGFEB6pPPywRmlPImlfaY zsfDzeWuUQ3sNsy3btmCxLSOLe4fz7KwOBT+dhMF7zUqVQWSBVGQU8f9wckW7Ad0Em x4B54q5F8Q4VQ== From: Benjamin Gaignard 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 Subject: [PATCH v10 47/54] media: cedrus: Stop direct calls to queue num_buffers field Date: Tue, 3 Oct 2023 10:06:56 +0200 Message-Id: <20231003080704.43911-48-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:11:20 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721172252898683 X-GMAIL-MSGID: 1778721172252898683 Use vb2_get_num_buffers() and queue max_num_buffers field to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- 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..88061310f815 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 < vq->max_num_buffers; 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..b8b66d0d951e 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 < vq->max_num_buffers; 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,