From patchwork Mon Oct 2 12:06:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 147565 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1738200vqb; Mon, 2 Oct 2023 16:00:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEj07vTjQjIn16mCrVyRp8OvCewX4ZHbkFWyD8W3umOx3YREB26zT/io2bqlPCIbgcOMpxH X-Received: by 2002:a1f:4a82:0:b0:496:1bc2:ddf with SMTP id x124-20020a1f4a82000000b004961bc20ddfmr10465758vka.8.1696287621645; Mon, 02 Oct 2023 16:00:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696287621; cv=none; d=google.com; s=arc-20160816; b=fHv8CghFjH12khONV7u/SSKTbJ3Bl8AGGzwP772Gak1k7BVFdB0m35PTdnSAxUDssL lQdh1FA4eKRRUStKVaeyqD8MBhAISUpta9gIBYwxvRz31dFqv7ryx4sQzQ9uY46UZaib 5oYANO9rGmJbibjDjiJnBS/k74MMFzG9h2OyH2YyPQgtG3CStGTuYlU3zqdCahYGsuiH HwWRxCv2ezV2EHaamSNx36oMOC2qD8fk3og8Tq6yMmcxk+EyLu0FN5uAH0P8XK0T2klY K8I0WZ97gIToWyf/UNKQCFNmCIRpsgENeHP2g2aJ2kOEqdrtpJGa1Pbp0iF5oicPP/Yz h+Fw== 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=u3nndBmOIa5aTyPdxH8URZ6RNVydaSV8aLaykgwN9r0=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=MQslvpippm5XxgwdEabzL0y+Ghr9SeoOLm+N2s7c1YvhzZz6l+64oYF+MQ8VUygkuJ ykfGrnl3WA9NqKHyBKJ3RCDRj3Ti2WnfV9V2OjZGHmJkl3mj3yIkTgNYS3TGpM9YLQKO 0fLuMrv5uCme+yLpmXyCq7WwxENHQpe6U149pCw9F9C9XslQlIynw132ZBoqj59nK7gY rs5AOBEKbFoL/IAHUbnQcNQ1UFzQ/4QGpW20kDZ3qn2nBsVkwfLBVlbddQTfw3rNzTQj yVmRtn666U0ynQmPtfjcK0LWKfPgoG8/HvWX18rVO3chPEWuYPYI7nqPxo9dTXmT35do 3aNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=TUzURIJg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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. [23.128.96.37]) by mx.google.com with ESMTPS id q5-20020a170902a3c500b001b89613687bsi27640665plb.439.2023.10.02.16.00.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 16:00:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=TUzURIJg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 0E61D813CDB4; Mon, 2 Oct 2023 05:09:28 -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 S237271AbjJBMIz (ORCPT + 18 others); Mon, 2 Oct 2023 08:08:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237162AbjJBMHE (ORCPT ); Mon, 2 Oct 2023 08:07:04 -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 B2F0C1B4; Mon, 2 Oct 2023 05:06:51 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:9537:67ca:c85e:d0ae]) (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 9CE17660738D; Mon, 2 Oct 2023 13:06:49 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696248410; bh=ab3b0OnRgwE0tLcrbw3ezabANr7f3bguMXcLjpsSnBA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TUzURIJgF2X3CiZYQcFBU9DwTk6hOQTEp8ajqLhxSjnJLLik+662uPT1MFD6S5Ycm +KeL402Cz3X9esFjhVCgQW+NDOtg+LIiRTuJZPBj6e4Ck2tPuyJLBFfWso0bcKlhI/ 9u8PvwrI6+MA4sNJTITeRVreIbm8VJLqHUXKFjePse/pCrk+tldbte5FxScZAArVBq KuWgvrd5FN+9pS+Z5JC6udbyWxnJP8M7CnEYL6XxR8lqNiWgQ1A4MnPr/MsB1XuGzr EIzUTuc5JR3C/+YzzmNY4BW107tVWBp4HOGIQBJvqGbxQOOHHWAjCP09mKZwO9+zyF WQFVXzHjMaIrg== 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 v9 47/53] media: cedrus: Stop direct calls to queue num_buffers field Date: Mon, 2 Oct 2023 14:06:11 +0200 Message-Id: <20231002120617.119602-48-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231002120617.119602-1-benjamin.gaignard@collabora.com> References: <20231002120617.119602-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,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]); Mon, 02 Oct 2023 05:09:29 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778686489100227425 X-GMAIL-MSGID: 1778686489100227425 Use vb2_get_num_buffers() and queue max_num_buffers field to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- version 9: - run 'test-media -kmemleak mc' at this point of the series without problems. 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,