From patchwork Thu Oct 19 12:51:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 155521 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp360014vqb; Thu, 19 Oct 2023 05:55:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE/QA7lErZFWgVPg1i97QUj9uYoUpg+Ip3FIDhrAjo3iVuG91rl22ML3A9Nv6TpxK9mIMsY X-Received: by 2002:a05:6358:e816:b0:168:a8c7:632d with SMTP id gi22-20020a056358e81600b00168a8c7632dmr893398rwb.10.1697720133169; Thu, 19 Oct 2023 05:55:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697720133; cv=none; d=google.com; s=arc-20160816; b=JJHA9qvetajXDyBYB53nQGunT51WdYpyAPq0+XWJhweODOcHJcnUw+2kffJj64kare FOVwm9WJ/WfVLAEZ+Ej0aACnFx2UfiRmd+bkEDCpn1YsljKdizIQudnXNLuhjjBzjVV5 smM2lnp+Y4XC5n3eXt6s/VJU3rKsvW+8IpCVRoHc36K8YlsCg/X0h3tU6/IuY+ospYce nGWLu9Zif6IYPB8XNGqa78J50SEIuAFMbVhmJFDIQoZhRjUeG4TQTvgfZy3N4P3wuC3a KoBiIGZgeSxNCIDIWXsWsX+dMPWoDmepUOZ9JhFd1fOSgTC/K1RfSynbwOB8EC2geQ2E nmBA== 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=0a1kRYp57H3SphvzPRCJ+4HpSpBRT10VyUNQ+iboP6E=; fh=kpy8hnP6Gews7/w8dNjLiYrKq2Pvrz/5/ZgUjYw+mFw=; b=C9Oz3LYh4JoS8GZCRaSlZH+sF6faVcymED0JgBMRY1DGLxoXInC5liAlhc3+YfOec0 UQuWnPixeliVWYx1aZh7GtSvpvkkvkhuUMIz25ijnKWaK62dgpOKafvlPN4EJbZAECwv ysHDmtK+TkHFfEeL4wD1TczwRBjV7SKKmArHzOltqsAe7Pnzl+VdtdLEqVPjYshpfS6K 1U+WMwwV5rQoRrR5r9Dl5N+dGj6xi1Id/v0gjafZVPVXqOsqaSuQNmoopM+7WkSsDYRY uXxEiWnBHIP8bzqyJVs/8g0SnX/p3VpOkZHxcYVcjPak/UaLm1W3M+BnKUWzcyAashet LWSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=mPTQB3Cn; 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 w63-20020a638242000000b005852a35aff4si4866161pgd.227.2023.10.19.05.55.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 05:55:33 -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=mPTQB3Cn; 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 2FE7882E875B; Thu, 19 Oct 2023 05:55:16 -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 S1345945AbjJSMyY (ORCPT + 25 others); Thu, 19 Oct 2023 08:54:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345374AbjJSMwr (ORCPT ); Thu, 19 Oct 2023 08:52:47 -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 324B119A; Thu, 19 Oct 2023 05:52:44 -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 95CE16607332; 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=1697719963; bh=uLexcsAscd7+q7L/zlCLSkE5WS81tRYkOSdorkQDUyM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mPTQB3CnNDCl4Omkm2Av5e9XNa/KizUCbBDp3gDOA194OoGaFXlsLJ58YfE36qbgb PFWHp7DTE6e6t6hVqFzrqHG1IycsCitCECtpXA8zderS7bkl5lKSsoOb42MYyajE/R Cz1WCryShqoyMWKY6nk/NNqJQ/RTRsseYoPjFUbLG/XZ43qARXxibtRr79bJV8fD0N eIaW8JnYFlPKmc/RintxidgFHGVMY7Ocwng0AMo+DJSehY+w0e9a3cGGPI+T6NKrlV q8OouEZcwXbgv1cl3iV4/g/VEoOqcYGv8mcZEHcKk2P4IGOwZZVyvgEc7puMyKlefL 9ZPupyYvGaAlw== 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 , Sergey Kozlov , Abylay Ospan Subject: [PATCH v13 23/56] media: pci: cx18: Stop direct calls to queue num_buffers field Date: Thu, 19 Oct 2023 14:51:49 +0200 Message-Id: <20231019125222.21370-24-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:55:17 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780188586709975210 X-GMAIL-MSGID: 1780188586709975210 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: 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)