From patchwork Tue Oct 17 14:47:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 154347 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4189035vqb; Tue, 17 Oct 2023 07:52:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGm4WXCEnhNPRV5S2VvkFgwhHWet47ZEpXYBoNVh1FN8eQ8Lqvw3biBR6UNE0TNWXG9a/Yp X-Received: by 2002:a05:6a00:428e:b0:692:b3d4:e6c3 with SMTP id bx14-20020a056a00428e00b00692b3d4e6c3mr2578801pfb.0.1697554362766; Tue, 17 Oct 2023 07:52:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697554362; cv=none; d=google.com; s=arc-20160816; b=dg7dgKhVE1uugI3HkCe9pF5vapnwJO62O3weBoGeVKDwqq2NLClSnENPHEX7nYNhKd pYuiznkDUKgvNX9E+35zl+DFOzTtFvvDkmK8NP0LeWUEVAqCrkjH+o2o0vMhaLI565Kc k0Ym/Wlbg1cHOFhmhWMK1HHbsqqzMdWOJ4+rKLf2eYs5nPAe0lxaGajP15aXdxWGiCLr 2iEoGjhMywiDIPlGAX/AKe2oFI8RJNh9fHM9VfvCjzofrcmh0eVSn30QTshhttpqT3ry BUxzx74kl6Oh4+RHAEr5K7ARNAOz1kdbcC2UQc0HA270IpRnG4cMnPRJfewOyzzkBV/m KkCg== 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=VtpcJSPmroOpTRPVCvGCij+KtLXQmZCvdRp/u0BzGjs=; fh=aVUrqUP+Ljv+BSkNtX805Xk8KRvk/poCiUhiRUDoQMU=; b=A1RWK5P9fkQyDopcQLMa7leZ6BrxXlEBrSw9uTpDZ44vcRITPXeue2ja8TJ/sdpxqQ SoM3p4eVR1zX+lDqNmTaeR5Gs8MRggagkGjP42qf446GyP7RzgbsFtDQZzzbwMI2VUX7 Z3bzJF2eKlEYP8aFf9RJQBqnVEj2bncvTkTtF36VP2KhidVXbCmZyyFEklJGYn9dIvOZ 8I/Xh3cLuMzBWnJow45jEF/k+Oqeq52rsrHFt/I4UTZOYpb7ybDKjOHLnoiy2qjcydpn jGnWuwKPnTOKnVpte0pRp0i7rOYv6MUnqbBCJxXQessEt6kG6jmr5RZ66B7zX4vkrD4R 2YkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=MENgQd8t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id s9-20020a056a00178900b0068e47f1fc7esi1918325pfg.159.2023.10.17.07.52.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 07:52:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=MENgQd8t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id A1811804437F; Tue, 17 Oct 2023 07:52:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344366AbjJQOun (ORCPT + 20 others); Tue, 17 Oct 2023 10:50:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344204AbjJQOsa (ORCPT ); Tue, 17 Oct 2023 10:48:30 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 953181A2; Tue, 17 Oct 2023 07:48:23 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7205:da49:a7e8:59f8]) (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 BE18C6607395; Tue, 17 Oct 2023 15:48:21 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697554102; bh=wcRkEIBX+FA3i2SS+U6BlI+rlNLiV6MPRs3pxSvNJvM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MENgQd8tUkxq1MPUTpyT2wE948rQ72tRlZZa/gYrGciID1ldXZHClNiJlkhnm2Fu+ 7sExJByQ39h7mfhav3Xj/bxDNsk9LOCwwELNQCWX+eWdgYSD9XpplIxFLYwdvPNaki U0nfE1gglEOl16HoHxyeXDIxy+eFToGUGF52G9Hxz5u62aNpBWAPGJHTZ3laJa1zOs i2KrM8vRC8dk3UhS/GL7MtrJeA3fFnhWtYlmpafotFV01lS+7IdxTatrGWfxnaEmiJ z0vjgHqB6F6LS9FtxYlf/btpFMVz6cjxe3LxqSv4d6nMvvOGeBY59Pu2O12vpjTmmD tVKQ+dzcx3Msw== 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 , Paul Kocialkowski , Maxime Ripard Subject: [PATCH v12 35/56] media: cedrus: Stop direct calls to queue num_buffers field Date: Tue, 17 Oct 2023 16:47:35 +0200 Message-Id: <20231017144756.34719-36-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231017144756.34719-1-benjamin.gaignard@collabora.com> References: <20231017144756.34719-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 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 groat.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 (groat.vger.email [0.0.0.0]); Tue, 17 Oct 2023 07:52:30 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780014763340720325 X-GMAIL-MSGID: 1780014763340720325 Use vb2_get_num_buffers() and queue max_num_buffers field to avoid using queue num_buffer field directly. This allows us to change how the number of buffers is computed in the futur. Signed-off-by: Benjamin Gaignard Acked-by: Paul Kocialkowski CC: Maxime Ripard --- drivers/staging/media/sunxi/cedrus/cedrus_h264.c | 9 +++++++-- drivers/staging/media/sunxi/cedrus/cedrus_h265.c | 9 +++++++-- 2 files changed, 14 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..3e2843ef6cce 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c @@ -653,8 +653,13 @@ 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,