From patchwork Thu Nov 9 16:34:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 13451364 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 82397C4167B for ; Thu, 9 Nov 2023 16:39:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=akeXNOpIx/aK7lzX7y2qKSAN5J5q69dDasWFhy/cyS8=; b=3V33J4WR5lZcwB KQr/1ElEP28vthUeFsV6G763rhTNS7TiJ5RDRNBXhUQSGo6gOBokjZvl4cbi30b/BwPz9Wb6PBbLt Ce1L/aiYWa7OrXCzKBFRLzdAaldfaHgyBKFfrZ2T4tXGYlQPBErgCwOvbcS1y3LQOR+LWoC7ESkx4 Go1oOtD8VFVBGUfkspWUPGdJnYvnA/CowFbVtV5fUtRA/0jWH5eon7RHQNe3MAZCvHUpJmYRc0YBw wTu8tnNBG4ovAHAuUYLdEU6QTfJQz4OWkCaOjBxooo85y0+ZEX5BSNVFysgR1zXs1cFcvMjFuwZ09 nbScc897ov50CbguHFgg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r183Q-006mGg-2u; Thu, 09 Nov 2023 16:38:52 +0000 Received: from madras.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e5ab]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r182W-006lDX-17; Thu, 09 Nov 2023 16:37:59 +0000 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 00F566607421; Thu, 9 Nov 2023 16:37:53 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1699547875; bh=+Hqk/nxCcDyN1NZIvRoKMHSzkbjjWG5EbAmHVA6LLfM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VvoS9CUyCC7fwQzbtIRQaG+szawARH4k2FwfMxPjgDNnPZt6B1RUJf8Zw1V7d2bUk IQGN2WS5yI3u9i5nAQq7A/6IFKX/zvYEsuayqbQ+JMWJBfdlMNhh550mSlgazuutsu nZbSMQWZJIv+Z5Af+jVfXZwSeoJhKwP+GWeqW2CnNmhsum1C4cffCXiii5CSN6jdK7 r7O7v8F1WYvhxONDsLsVbM8wvjq8dC8VShyOTe6cVn9WeWZm8juTZccynZC1yxjp0k AyxNny4UtgDpVOovxBczZLp3X3u1zPuWNW6NIr3D/2Zc98FDsquwlwsSXrRaCM+oZ6 xWQD9j8Y49s4A== 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 , Sergey Kozlov , Abylay Ospan Subject: [PATCH v15 23/56] media: pci: cx18: Stop direct calls to queue num_buffers field Date: Thu, 9 Nov 2023 17:34:39 +0100 Message-Id: <20231109163512.179524-24-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231109_083756_547923_1BE79995 X-CRM114-Status: GOOD ( 12.56 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org 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: Sergey Kozlov CC: Abylay Ospan --- drivers/media/pci/cx18/cx18-streams.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/pci/cx18/cx18-streams.c b/drivers/media/pci/cx18/cx18-streams.c index 597472754c4c..cfbc4a907802 100644 --- a/drivers/media/pci/cx18/cx18-streams.c +++ b/drivers/media/pci/cx18/cx18-streams.c @@ -104,6 +104,7 @@ static int cx18_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers, unsigned int *nplanes, unsigned int sizes[], struct device *alloc_devs[]) { + unsigned int q_num_bufs = vb2_get_num_buffers(vq); struct cx18_stream *s = vb2_get_drv_priv(vq); struct cx18 *cx = s->cx; unsigned int szimage; @@ -121,8 +122,8 @@ static int cx18_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)