From patchwork Tue Oct 31 16:30:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 160204 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b90f:0:b0:403:3b70:6f57 with SMTP id t15csp364003vqg; Tue, 31 Oct 2023 09:33:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFPtqVLPPg0XrIH/wArWelbhDqmvXmsqbj+yPvMqFjHTNBzyFAm3ltHzlqXRvxKKKrWnsO5 X-Received: by 2002:a17:902:cec3:b0:1cc:5f51:b1ed with SMTP id d3-20020a170902cec300b001cc5f51b1edmr4314787plg.47.1698770025598; Tue, 31 Oct 2023 09:33:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698770025; cv=none; d=google.com; s=arc-20160816; b=naBDbW/FEWbWSgwPQACMg58RxxC5QGyT5ekPx1y0VBvU9Us0ZhMz8tZQVNWbYWKSWZ aIhYJhJ1mhCcJ6Gr9Tc1kRIAg4XX0VNPq5cRCqh0rYkRzdw7TG94NxKS8JemDYG5JI+A WB+OBY9OgjPcSOCZ1snhJqAweXKZkSxISpH+s3bI6z0GCBmpl4N/WG+o5FPo/Ge1yzVk Byn/5y2rgRVeFm9Qdt4DlXscASi/KvV4uO3jLBixgXhFs8S/vu8i1Y7BveXq13anpgSU t3sFkFfeH/IV9XU3E6HJ9rDJofOFlDnCiRrXl2VR1oW01BDsBsOlQRzTuxMcM6FnHuRQ LJlQ== 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=Q+82y3HCRQe8p3qEO/CsxmOcUDerisIraRIWfK/NnGo=; fh=kpy8hnP6Gews7/w8dNjLiYrKq2Pvrz/5/ZgUjYw+mFw=; b=Bt1OQuuZEzLQT6dyt5BP6O8l6cktCyprZz7IgMEPMrPodm8tIiQvnXuSABUoWZPgwz UeEjmNxGQ/zaG/S3Ru6SII/AVNtRJRHl8Tdkt7ozBCdYvcerAE1xsAIkas7XNRNAp06T Xo8qDOavEXFnSeaZPpxZn4VEeIiSUirXWlw+Z00Cs3dpQySrIBMHuNpgsGZNBaKxe7g7 S0gUYefmOcgsZQqOFMhMS6AzDyyCNArLkMlWE+2hkevOOpRYAUdY8cMbjiIy378pWtHE zoDWr+1Ph0LjjwySVzj/DKqyrjINycelfJLvI32ZKNt76B1YFTE2Mw8vn/MWjqK0mLrd WXYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=SL4ZlVSF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id d2-20020a170902cec200b001cc5d28bb2csi1219644plg.151.2023.10.31.09.33.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 09:33:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=SL4ZlVSF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id DF91A804A9E4; Tue, 31 Oct 2023 09:33:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346140AbjJaQdD (ORCPT + 33 others); Tue, 31 Oct 2023 12:33:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345444AbjJaQcR (ORCPT ); Tue, 31 Oct 2023 12:32:17 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28584D58; Tue, 31 Oct 2023 09:31:50 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:c562:2ef4:80c0:92f]) (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 4E6D166073B3; Tue, 31 Oct 2023 16:31:49 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1698769909; bh=i3ojvf+oJl6EVNen5vztp4m8lCDNcxv0WJBCUcNAQzI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SL4ZlVSF4eEjyE3oSGYeLpPJYmytqNoRQYDnz5VZof1/cz8pE1TVnVD5KLEF5Gplk u9p98cCDNqp+cUel7LvuEV/Tx1t5pRy7Qo7gGUJle+Bp+FIxl0Iv7t0QEPuBxWPFDq 8dBPf770Jkpytsp6IGJbAvBZ/WDNMFgU8T370Uh032FI5vbXgQbk3yeujSSWYkXy5i QdHP6Sg+mjGc3U7M7DCb78UHFSXhTVBWdPwq4iCFcM6o4WAPlmSQfhyAQqkkwrHsoO u3WeKwuNldeCvbx/WSjJTsE2O3j/MtDS0fLuGPgLD3+zobTIza3Id1bufClVGlapbO QcuN+Hkm4PtdA== 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 v14 24/56] media: pci: netup_unidvb: Stop direct calls to queue num_buffers field Date: Tue, 31 Oct 2023 17:30:32 +0100 Message-Id: <20231031163104.112469-25-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231031163104.112469-1-benjamin.gaignard@collabora.com> References: <20231031163104.112469-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 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 groat.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 (groat.vger.email [0.0.0.0]); Tue, 31 Oct 2023 09:33:36 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781289478250590338 X-GMAIL-MSGID: 1781289478250590338 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 Reviewed-by: Andrzej Pietrasiewicz --- 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]);