From patchwork Wed Sep 27 15:35:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 145596 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2906212vqu; Wed, 27 Sep 2023 14:19:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH3bqqi8JlXIw6eVjLe/lddCKY/h6a0lyN9vZH97f1cDhROk1vS9qjQkbAijvlY+oYsQFWE X-Received: by 2002:a05:6358:52cf:b0:134:d45b:7dd1 with SMTP id z15-20020a05635852cf00b00134d45b7dd1mr4185049rwz.21.1695849560796; Wed, 27 Sep 2023 14:19:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695849560; cv=none; d=google.com; s=arc-20160816; b=0nikdb3UIBSf6CWhHOE8H4Yf3Ue0IDXTKk+y06CCKUjcmhWXEc7UCfV0OwvL//j2s6 sKa/9etnQhDtxv/FgTzQ7EXQEfGojyWBe58pJP6RqNU9wu+npvuvba+WqlxJ1lx+sDX2 6L8Pa0s/8QMp+3ePfHuQzAdw0XR7vnmtCAjwPfbjiGEbaadYZkvDqaoME2kB8NDIlL0I yY750d0FFeTVS11lTzMztUt6y2s5pkE1pQY/w6iELhmz2LYhXB0D7rR58+XPyMhgkrIK goN2W53I7y0VxDz7O25R4fv66LKPUzQUonvVXpnTpTYgvSvzJuhlhPHvKCfseic3z7tJ ievQ== 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=HABhS4cdEQGKTk6Cu0lGEKNrlKtIe2OIKq1mqTo5c3aAL62AFfB79OeLmJHLI2NqdY ZaG3TIG42zinVrc4RXqkKnFJY3CAmLoCKT5lxby416bbSsoxMy/X3b4/wtQ7VJd7iPp4 epPsaXS5ahrzTWHD05XPIzLKvqcGCTREBVK0hnXHt82CJD71MKBZ8rSrNJVNc2cDp97x 7dpuqE23/Bk+5LEx6xFxLLmmVAA9tKEr+aw/+gKKp4/F9sqts8fLuoyHIwjoS5mRqE08 dzQkJIDuY0bmFsPW7veAdDGkt7AqHgYFWzCSiWa5k5B+7GS/jZ99VX0hszNuumJHfJeY 1qCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="Z9XT//pN"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id x23-20020a631717000000b005648b1d63aasi16982117pgl.553.2023.09.27.14.19.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 14:19:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="Z9XT//pN"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 1CEFF807C6FF; Wed, 27 Sep 2023 08:40:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233069AbjI0Pil (ORCPT + 19 others); Wed, 27 Sep 2023 11:38:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232738AbjI0Pge (ORCPT ); Wed, 27 Sep 2023 11:36:34 -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 28330CCB; Wed, 27 Sep 2023 08:36:32 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:672:46bd:3ec7:6cdf]) (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 949A4660737E; Wed, 27 Sep 2023 16:36:30 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1695828991; bh=KSp/qlyb4qZpMVJTjYq3/CPJYCUJtKhZMjqFSVLO9ao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z9XT//pNSSGX4LBSeOtPtJ2TABK4QPyHBj8m9jujd+0oex5aXQ0zMxDIWGrVPGorv Aobtgq32zoxra+5/8mNmyXZI6FOTEbCKJKE4lkG7ujWT/aZ3Xmb9D1+X7hGthonSNK KqD73NIkD3KNFkMmgT4l4UdAdyLdVRc7DIyzryz5LoWjUs8VWVwywEXD1fCQo2pxj9 J9NXBfBjNx9DeHxEDCZfYa9ajxh0z6SD3GWBPieNnTh3MLCSRUJ9MaLTPy6L1IzuQg EfvBB/dEYI00LXxpKvILsOk8Z1pNqKWt+tPJ/8oms38l4MRWCF5As6rlMNoz34ujTl D7FUba1Aq56sg== 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 v8 47/53] media: cedrus: Stop direct calls to queue num_buffers field Date: Wed, 27 Sep 2023 17:35:52 +0200 Message-Id: <20230927153558.159278-48-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230927153558.159278-1-benjamin.gaignard@collabora.com> References: <20230927153558.159278-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 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 agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Wed, 27 Sep 2023 08:40:10 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778227149075684276 X-GMAIL-MSGID: 1778227149075684276 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,