From patchwork Mon Oct 2 12:05:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 147469 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1689725vqb; Mon, 2 Oct 2023 14:04:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH4We2tZmdoKEfQ3STXR50hj6EqvJlkxqyGlnvq3lCkcPnafUHZw/pKUFbUdTFwOp/GErOq X-Received: by 2002:a17:903:248:b0:1c6:636:e40a with SMTP id j8-20020a170903024800b001c60636e40amr13298814plh.14.1696280665598; Mon, 02 Oct 2023 14:04:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696280665; cv=none; d=google.com; s=arc-20160816; b=n2i1Hz7mWo2PUPi+PuwaSnOw5OCO8YxXv3nmU73dRohmVPGkj329Dwiadovk8dRtu3 Bs6MPLfJ9nFisMHYZHg8FQA2esBCSx8cSj/W3jl56I1IzSj0JjMyPU+vrvMu7vsG3V+w BxT/LwHw6l7VKHavvXMI4eKw5M3/A/Wlyaz4ia0P6/LhnRYc8Mg8h7wmuOPmh0w3u0TW we6SB9XuxH0NKNqLxGZKJ8iVVFr8G47FicPsb50ZFyBIU8m2wF5Ru12+g+QttRYEN6pN GQJGZDcYt7EAMymhdYaQWcljzknuGgfjVsqREWazsN+R8gI5K8tWSsmJefpkhWmdKn4x IpXw== 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=APYp0uFJC2Cv/vh8gdm1S+i0NM5yJouihmXqf14V/JE=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=rfQgJyVVG9lvFiJERLyDmFWEJnnT8BqJANRN8UcGi2D6NRyd4Ox3zzFr1/dy/gE67s tiowwDVywobNWngKBBfPx/IDYqPZouF0pa8QQfO6mjCUC324ubgWfe799Mo5mV2BXRMl GTbRM6A/kCyIoOmrUfdm6VdQ0yDO+zRjNB+PtF2wo4q4hmdTkQJH+/zSTo5JUwy+m7oa lsbFoK74AyDwEAx3BKn+1qr1bIZ0HRV7KdnuwsGbIiZkvKclITh2YmN6lncKdz75r7M/ 67rEtrQcbrTQR29reHX9OzgO6qoc2TgnYxHmJsuuvop/BlHOiaD3Tn+49Q8EwQTPK/dY OXkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=I5KklOKm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id s14-20020a170902ea0e00b001c73626a1ffsi12508934plg.412.2023.10.02.14.04.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 14:04:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=I5KklOKm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id E22BF822DA22; Mon, 2 Oct 2023 05:08:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237278AbjJBMIE (ORCPT + 18 others); Mon, 2 Oct 2023 08:08:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237019AbjJBMGv (ORCPT ); Mon, 2 Oct 2023 08:06:51 -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 06D73D7; Mon, 2 Oct 2023 05:06:41 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:9537:67ca:c85e:d0ae]) (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 64E21660735D; Mon, 2 Oct 2023 13:06:39 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696248399; bh=ds3q8wqXSU9KVQQlLH/PuQAEX1eguF3zVlgf4I/w/H0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I5KklOKmAYqfs01UmjuHuRCO2CT7826IiucqUSUtoenKKJClyTm9F+QpyGPT/eHok kWC/acVlpvrHnHBVFo/0OqGkSsRT5d7GGrSD+xXsWz2VslyZimIiz96aR85j04ve9c oa2y1aOoApgBDSlj41f5Em214XY/av0kbDHcMWJUQcbw4OCZfbj3txGSFvQFsYL5Zo jvk/h78eNLT7u7dLBwLMxYUXLH1aHeMueHCcdwfzTa+29yF3XyFEDZybui/SbkOz/u yOUvaGnJNas+D7QtxU1X/kciRGNcf/CPYhPnr4LLIE30/jb4Mcgm2S5eMqO0HJP6oJ YX9bjkzffpZUg== 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 v9 28/53] media: pci: tw68: Stop direct calls to queue num_buffers field Date: Mon, 2 Oct 2023 14:05:52 +0200 Message-Id: <20231002120617.119602-29-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231002120617.119602-1-benjamin.gaignard@collabora.com> References: <20231002120617.119602-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (howler.vger.email [0.0.0.0]); Mon, 02 Oct 2023 05:08:11 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778679194878747975 X-GMAIL-MSGID: 1778679194878747975 Use vb2_get_num_buffers() to avoid using queue num_buffer field directly. Remove tot_bufs < 2 test because min_buffers_needed is already set to 2. Signed-off-by: Benjamin Gaignard --- drivers/media/pci/tw68/tw68-video.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/media/pci/tw68/tw68-video.c b/drivers/media/pci/tw68/tw68-video.c index 773a18702d36..c0a8257b02ca 100644 --- a/drivers/media/pci/tw68/tw68-video.c +++ b/drivers/media/pci/tw68/tw68-video.c @@ -360,13 +360,11 @@ static int tw68_queue_setup(struct vb2_queue *q, unsigned int sizes[], struct device *alloc_devs[]) { struct tw68_dev *dev = vb2_get_drv_priv(q); - unsigned tot_bufs = q->num_buffers + *num_buffers; + unsigned tot_bufs = vb2_get_num_buffers(q) + *num_buffers; unsigned size = (dev->fmt->depth * dev->width * dev->height) >> 3; - if (tot_bufs < 2) - tot_bufs = 2; tot_bufs = tw68_buffer_count(size, tot_bufs); - *num_buffers = tot_bufs - q->num_buffers; + *num_buffers = tot_bufs - vb2_get_num_buffers(q); /* * We allow create_bufs, but only if the sizeimage is >= as the * current sizeimage. The tw68_buffer_count calculation becomes quite