From patchwork Thu Nov 9 16:34:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 163481 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp558814vqs; Thu, 9 Nov 2023 08:38:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IHKhEvZMb20LDF8ziuwTLPCQbzSwphM6XCa39hrtTOu/YYqJoZeLxdwJ5VmFRs026t7Jf3d X-Received: by 2002:a17:902:daca:b0:1cc:51b8:8102 with SMTP id q10-20020a170902daca00b001cc51b88102mr4961601plx.2.1699547922944; Thu, 09 Nov 2023 08:38:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699547922; cv=none; d=google.com; s=arc-20160816; b=mSgEqXxZ58yQDQ4eBTYmsu/FCQwc0E2qMyMfpEUBIwzvK+Z/Tmf8WYLkNsPHStqdDu 8bchTFu7y+96e6winHofPlxKwXQljRnspBmJzOoTLBVMa/lPGBEYTpDS3h7Sp85OUnUC 9AYqc4HbxT+QfQkCpW3X9f9c/ibaf58BTGHPVeky9r9qZWT4e/skCmP3NN1jEoNb1X1x WdzmOjZhH+HQd9Zii1QV4FGtt2MLyuh3CFCkSr9+b4MkE90arZCcwSYquhyTr1/eEV39 iCCcd3xkejYh0krpGSRmkK/omCRttM14GboJmNZUWou08CXS5Iw4HOgiRUmpRY6RRMSe NGpQ== 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=PmIMnOfILCxriX70Tb6wIjQsM4GacgsmC+gwTyziq9E=; fh=1+Y+XiJFuzIIWP0UKd+9JoZ03pQoHzbiMFq4VIKv7s4=; b=O5YfAL2scA57m4UW5oOkoh7D186s9bCNMwIV1Rb1C50b15MKSFsd1IVVmgXo9RKrNb pON2rQNzCAg26SSYG9HN7efh4fGSPryWWELsDQtiFKxXOGQlhbpU3n3fYlqRmJW9A0Vf v2zYn7F8MCS2kdVxNx8L4MG/ZE8Xjje5ZN6qGdXZTIis30s/f+7VD3CoMneXNSuJbM3g ycdsOKfg1DEDHqiXEAV3idtLJAp0BnfIJ8bJyANDwoDVJk6coM/cD/uHm89S5D0H6u9g WokbOerAhlvCNV07ijqFdiFBFKCm4Ubj2rkrO03qp8gMO8Zv0G0PMQPHZMvmKbjG8UJt j9TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=afCqqPbL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id q3-20020a17090311c300b001c46467a211si5479115plh.193.2023.11.09.08.38.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 08:38:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=afCqqPbL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id AC95683DC995; Thu, 9 Nov 2023 08:38:41 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344519AbjKIQig (ORCPT + 31 others); Thu, 9 Nov 2023 11:38:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344438AbjKIQiM (ORCPT ); Thu, 9 Nov 2023 11:38:12 -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 0FD7D3874; Thu, 9 Nov 2023 08:37:58 -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 C6D3F66076A5; Thu, 9 Nov 2023 16:37:55 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1699547876; bh=ioad4eznaxnOj9zTodU1qDxSmo+Iro3wnE43clfkbec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=afCqqPbLxw1RmnTEI7Fk0EfHjqj338bem/6+TU25259xJwuqVjyxqZQ4EaKxXCmID rQoo2GtCmYbWU54VXPyAhiyehc7DC8TxGdS1PQTmLV6WFw1kolM8BYDYwVj3oGvG8O Dt2Hf2K7ObMY7B3OBUp/l/NRdl5lJGk63yLzdR2jbWtoF/bJ6evmJEYvu4QrDQOIV1 rRBQhs3QcAXGFLr+ypZF3Z0EQ41g+YZ7cUmSoH7UeoBi0/+6r1I8hX8rR1o4GwIkdb yuW6GX62sHjocz4AbcA/wBnMicUfk1p4C/kExkRUk5Dd8j9GEsd5CZgIREl3GyIIvY AV7Hr1ztTSUtQ== 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 24/56] media: pci: netup_unidvb: Stop direct calls to queue num_buffers field Date: Thu, 9 Nov 2023 17:34:40 +0100 Message-Id: <20231109163512.179524-25-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 (snail.vger.email [0.0.0.0]); Thu, 09 Nov 2023 08:38:41 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782105162625361356 X-GMAIL-MSGID: 1782105162625361356 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/netup_unidvb/netup_unidvb_core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c index d85bfbb77a25..557985ba25db 100644 --- a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c +++ b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c @@ -293,12 +293,13 @@ static int netup_unidvb_queue_setup(struct vb2_queue *vq, struct device *alloc_devs[]) { struct netup_dma *dma = vb2_get_drv_priv(vq); + unsigned int q_num_bufs = vb2_get_num_buffers(vq); dev_dbg(&dma->ndev->pci_dev->dev, "%s()\n", __func__); *nplanes = 1; - if (vq->num_buffers + *nbuffers < VIDEO_MAX_FRAME) - *nbuffers = VIDEO_MAX_FRAME - vq->num_buffers; + if (q_num_bufs + *nbuffers < VIDEO_MAX_FRAME) + *nbuffers = VIDEO_MAX_FRAME - q_num_bufs; sizes[0] = PAGE_ALIGN(NETUP_DMA_PACKETS_COUNT * 188); dev_dbg(&dma->ndev->pci_dev->dev, "%s() nbuffers=%d sizes[0]=%d\n", __func__, *nbuffers, sizes[0]);