From patchwork Thu Nov 9 16:34:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 163500 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp560675vqs; Thu, 9 Nov 2023 08:41:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IGXXa0CpnkzIYedBSqkfBOswuFWum1I7okA62hzPifvqksWI5rxxD60OZkYDBN6ZT3Zl7DX X-Received: by 2002:a05:6a20:a128:b0:171:8e16:ea83 with SMTP id q40-20020a056a20a12800b001718e16ea83mr6012337pzk.29.1699548118098; Thu, 09 Nov 2023 08:41:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699548118; cv=none; d=google.com; s=arc-20160816; b=kTdUf6fdnCFYoEMgg4FSA2HyDuqvOkILdc0OPMrDdC/0lqEmkzHzyVIEZprDDTjFKk eTcpJy1nAlZ3s5H3AX77+NJ4EgNzdqccEGJVk5nZ4XgGERNW0o9DBs8qHdh77k1sM+DC HXxCSPB9rIhyskznxHA1ldYoRbPZ3xLeP4jKA0KJvFMurm/jRnfoQsMLV8mfgd06zCNY 5FHvp5hbIy3tlhx1jUyAbjbI0eD4bhBEFqXsDW+94y4i+agw2icySjWzLzJ9E+Ar4jp7 wOHBemhREqQBR97pet0cwA2fxQq4+a+kpEaGZXoWZb3ybpMGt+ELhFYl2gAbTzZNaV/4 t/LQ== 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=O5UBtk6PsomZ9FDpFhN4paTBZMB0amCzWb/FHWjfUzc=; fh=JL+Nl555XmFc1R/6NyeBBLuKuLHcopqjqJuX6AIGNfQ=; b=w8cKd3h4QCdAapD7R7V1ekwmmBsTlabXs/f/M6QBX20Xa2tkypTJAliqljIvMZdmfT 30/dFCtZr70J/GYDJg29wr/JKVpY+8l7xlZcu0hh881hx41znTtqCOt2z203OZ7+1/u8 8t3//AURX+KVy7bm/Btg0YEW7xwCZWycaVbls4gfPSyvKj0MnmPfRHj1NMdzDfbWNddX c560YxxJZgt5ewlEPvy4Tnj1HeWGB+IWqQqP+5dcPfLqyschesoId+EJmX+CIXBNm/H+ wzDTZDDziIkeu6Aj/8Wb/KmR2CMVxtLTBTh3x3grKphDo0CKlrgt6HEmtThgSnDAPae9 4htw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=J8zKvMIC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id m19-20020a634c53000000b00578bd92e502si6945690pgl.558.2023.11.09.08.41.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 08:41:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=J8zKvMIC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id A87858345999; Thu, 9 Nov 2023 08:39:54 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344806AbjKIQix (ORCPT + 31 others); Thu, 9 Nov 2023 11:38:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344745AbjKIQiQ (ORCPT ); Thu, 9 Nov 2023 11:38:16 -0500 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 70A1F3C14; Thu, 9 Nov 2023 08:38:05 -0800 (PST) Received: from benjamin-XPS-13-9310.. (cola.collaboradmins.com [195.201.22.229]) (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 237096607421; Thu, 9 Nov 2023 16:38:03 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1699547884; bh=vezolw57Im6DRr5UrQGGrzNIzO39/GydEUKahqKBxH8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J8zKvMICI27yvgnvGQIBMWeJupbn/jDMLV0+XnOmfAYNeQVC02XRx9XlBFqnGhDBS Vrt3Wm9WLqkxqrd5mpAohUzAQUJxqNmDkePxQmCsDhQURRY0Ei64QYHpORznzoWU9v sTMFSV1afmOLp1hH0PJSCj9kr9VpcW6SstbNEC01QpHzCzMEPv2duBi0+g1HH0bXSU L0NGhUP+JWrsVHPG7dEkSEMFyIWSYHwuELNO3JO4IdtFpg23HxvBjjzpckLMGf0mOZ QQiNKpnmiHGpd+k0u814JyWbjV4tqxH1nHkj6VDT9XZCA8v6VLDST7DMXSCktNug/g Qb8lFKla65J5g== 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 , Andrzej Pietrasiewicz , Rui Miguel Silva , Laurent Pinchart , Martin Kepplinger Subject: [PATCH v15 28/56] media: nxp: Stop direct calls to queue num_buffers field Date: Thu, 9 Nov 2023 17:34:44 +0100 Message-Id: <20231109163512.179524-29-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231109163512.179524-14-benjamin.gaignard@collabora.com> References: <20231109163512.179524-14-benjamin.gaignard@collabora.com> MIME-Version: 1.0 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 (fry.vger.email [0.0.0.0]); Thu, 09 Nov 2023 08:39:54 -0800 (PST) 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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782105367748982428 X-GMAIL-MSGID: 1782105367748982428 Use vb2_get_num_buffers() to avoid using queue num_buffers field directly. This allows us to change how the number of buffers is computed in the future. Signed-off-by: Benjamin Gaignard Reviewed-by: Andrzej Pietrasiewicz CC: Rui Miguel Silva CC: Laurent Pinchart CC: Martin Kepplinger --- drivers/media/platform/nxp/imx7-media-csi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c index 15049c6aab37..4c467fb82789 100644 --- a/drivers/media/platform/nxp/imx7-media-csi.c +++ b/drivers/media/platform/nxp/imx7-media-csi.c @@ -1245,6 +1245,7 @@ static int imx7_csi_video_queue_setup(struct vb2_queue *vq, struct device *alloc_devs[]) { struct imx7_csi *csi = vb2_get_drv_priv(vq); + unsigned int q_num_bufs = vb2_get_num_buffers(vq); struct v4l2_pix_format *pix = &csi->vdev_fmt; unsigned int count = *nbuffers; @@ -1254,14 +1255,14 @@ static int imx7_csi_video_queue_setup(struct vb2_queue *vq, if (*nplanes) { if (*nplanes != 1 || sizes[0] < pix->sizeimage) return -EINVAL; - count += vq->num_buffers; + count += q_num_bufs; } count = min_t(__u32, IMX7_CSI_VIDEO_MEM_LIMIT / pix->sizeimage, count); if (*nplanes) - *nbuffers = (count < vq->num_buffers) ? 0 : - count - vq->num_buffers; + *nbuffers = (count < q_num_bufs) ? 0 : + count - q_num_bufs; else *nbuffers = count;