From patchwork Thu Oct 19 12:51:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 155517 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp359696vqb; Thu, 19 Oct 2023 05:54:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFp1hWghPyadBJDAvD/VfEVCgPGsZIS/1jXG7NcUuk7xEXO+3J/AvW1RCL48q/gKH2Dlh85 X-Received: by 2002:a05:6a00:1817:b0:690:fa09:61d3 with SMTP id y23-20020a056a00181700b00690fa0961d3mr2225308pfa.15.1697720090866; Thu, 19 Oct 2023 05:54:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697720090; cv=none; d=google.com; s=arc-20160816; b=NMgeMIyGLPhsiD0Mn339lyjz41yg+M3sUP8AQtQBW8BTIBdmGvOYwtiYc+P3EKRAzB XBe3LWc9oUEhgM+SuVBDk4waNF6jEQe15ASgeSeScqh1CNQjsMlO6PXVTkK/sX6ckv3u GTA6Irr1pshl3G1ZcUE1TgttZVHUyNXd4LpzEhikn3ofzOzV/Jh2gPAjCeHxemKHIlA5 rwVdWD5pKCvXq1edHO6IVfn55U+p+uHRsAf0SZQBDMQzs+uu2iiLShuytTvcsxGjpgIF obsZNJ/wbVj2j6WBJ03xguNFHpjaMV6GeNqsBnrIrKh3rJ+tvueGT1U2TkTPkxtukYiC TEhQ== 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=Ts99oHtPdgNsMvrVJzeWI3ReICZfm5oisnFd3nbTPcA=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=GhTS3QEtKxtJMz0D3caRPkMJlbp4P96ZxvVLvmJr2IiF3URR8CvWyRBna6TrOTc0u6 akhDkAG0ggRA6GS0Lhqky7+b+2CBEQnhqEPb0nnvEwINeHJY032Z9QMjrgXKrpBwSg06 QYe/N5j48VsAHc+xpQsZUNT9SiPBfI/2ZfMHKP49eL+1aU6EBncnX4pwm2vrsG1UV/B4 2qcBxShQaStb+e9To6BGQIKK17j9cJrP54+DLDvpV7fm3NiW4NiFREV+ax5M3jcNOjxQ kv4JDVwjw+mGZD6TASdEW2pW7reIwAPvr9NArDnISnWjg+yWVnRX+SyELlZfZTFCDre0 2+3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Nv4AwtLM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id q1-20020a056a00150100b006be2d9914eesi6606027pfu.118.2023.10.19.05.54.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 05:54:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Nv4AwtLM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 5F24782E8744; Thu, 19 Oct 2023 05:54:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345914AbjJSMyN (ORCPT + 25 others); Thu, 19 Oct 2023 08:54:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345818AbjJSMwr (ORCPT ); Thu, 19 Oct 2023 08:52:47 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA215199; Thu, 19 Oct 2023 05:52:43 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:ccea:1fb5:34eb:239b]) (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 15AEA6607364; Thu, 19 Oct 2023 13:52:42 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697719962; bh=E5t1fwehdK/+tA+H+9HRw8QC5ks/Zk2E0Mm8Cosvu64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nv4AwtLMo+ktvAsLvTwosXAV/XukDHsGhXGvIwQsqSuC8kLRfHhqFpKvx7wPdAYBz tk1j49lyLcZqz5BNX1+GHhj2Tiem2APSkgRkWW+ikaxm+onkGc8nIXCUW6Af5woU3F RRPtB0OADzbQFXMOIY8w4mpcLdbGuAdFGOqVMHJpwRdI0PqmAmKR4sT1IHLX8VPKIP QViC9ns/Lbv668XYXbbEJMUMI0fv9iJOuGPVonQHEjuIULSrgdWYpBmnK7gHYFxuxm NVxe2PHetu7HD2lgipemkoJAkiATJhgT2nx7PVhLCo7P2m/7IxMU+K37uVygqOxn93 T6QbQhqYIatzA== 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 v13 22/56] media: pci: tw686x: Stop direct calls to queue num_buffers field Date: Thu, 19 Oct 2023 14:51:48 +0200 Message-Id: <20231019125222.21370-23-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231019125222.21370-1-benjamin.gaignard@collabora.com> References: <20231019125222.21370-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 morse.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 (morse.vger.email [0.0.0.0]); Thu, 19 Oct 2023 05:54:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780188541906698400 X-GMAIL-MSGID: 1780188541906698400 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 CC: Ezequiel Garcia --- drivers/media/pci/tw686x/tw686x-video.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/pci/tw686x/tw686x-video.c b/drivers/media/pci/tw686x/tw686x-video.c index 3ebf7a2c95f0..6bc6d143d18c 100644 --- a/drivers/media/pci/tw686x/tw686x-video.c +++ b/drivers/media/pci/tw686x/tw686x-video.c @@ -423,6 +423,7 @@ static int tw686x_queue_setup(struct vb2_queue *vq, unsigned int sizes[], struct device *alloc_devs[]) { struct tw686x_video_channel *vc = vb2_get_drv_priv(vq); + unsigned int q_num_bufs = vb2_get_num_buffers(vq); unsigned int szimage = (vc->width * vc->height * vc->format->depth) >> 3; @@ -430,8 +431,8 @@ static int tw686x_queue_setup(struct vb2_queue *vq, * Let's request at least three buffers: two for the * DMA engine and one for userspace. */ - if (vq->num_buffers + *nbuffers < 3) - *nbuffers = 3 - vq->num_buffers; + if (q_num_bufs + *nbuffers < 3) + *nbuffers = 3 - q_num_bufs; if (*nplanes) { if (*nplanes != 1 || sizes[0] < szimage)