From patchwork Thu Nov 9 16:34:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 163501 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp560693vqs; Thu, 9 Nov 2023 08:42:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IF+BujcZtYa0TJ2E7pSW7krhaj37uHhUSiMY3EE6OtuKfFiyqGBDKYW4BJXlXBGiIStgTKw X-Received: by 2002:a17:90b:4a42:b0:280:959d:1d10 with SMTP id lb2-20020a17090b4a4200b00280959d1d10mr2075202pjb.3.1699548119863; Thu, 09 Nov 2023 08:41:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699548119; cv=none; d=google.com; s=arc-20160816; b=h+w2WUa4LISG08l5SNcfKjPwxWkOwGp0oGYXuOMTtXwo0y6+4etpSbfqjevxX9Y2DO xxzcCXFD8nm0g8cjNaxIAXMcQTrm+zhN9TPYQ6x+gvah+jRvD8agsi7cHzRpt2bpE3m7 MqxCicT/W9QLbvTh/FIlWJgAoyo16QPy3+2htoS6X84g6wU9iMCyrK5vGA2foTzvKlzB 3Siq1Crer5kpwTDpNlQAVU1luhQvdWFqoUqWnFuk39GF1KsQnKd7Jq8u7C+hhFQgEb8q kWLUv1dJJSFqXzW2nK2MEaylI7jsOmEHdltaV2yqQQeuJ1pvL1tBk/q6BrY72z5OxfRu K2FQ== 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+y2e+QxXVPnWMFLYZ61kkq3fBSAZukKLQ6sBrBScfI=; fh=UqWT2A2Cqc3qQ4kZuAcLhCrWrkA/OmE96SAhDBhsqbY=; b=NB7epDWQKEYYSMIUjx1SXzQwDdgIuRxPDyn56HvoXZxpzyEHEBAV2Trx8vcKCUc1dh qnOL5onZFe2GNuqO/AM2ltK4CbhipuGvy+KEuhy6rlLVKxzJKs1nWOYRrJlCma7VYF3j RX4mSrP2/YND3abEMitVywCzHzvNs+iEz9Oy+m9ELoB1GrhI28teNePLeFshWM7S1WJc p/Mq7+iO2Xl16vzYwRWVDC0Epx+4qv9e4DVn9RTl3DpJH2rJe3cFH0kagtCjKK2PGLSO fZXaFpSLnDKAdpglkQS2Ttbm68tb62tTAv/oJadY0fgrrTkk8Hi6cTZVMD7PZQsBARgS Zr1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ZtTtaQuY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id q8-20020a17090ad38800b0027e022bd420si1959849pju.77.2023.11.09.08.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 08:41:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ZtTtaQuY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 563B981F1E9D; Thu, 9 Nov 2023 08:40:38 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344626AbjKIQjU (ORCPT + 31 others); Thu, 9 Nov 2023 11:39:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344708AbjKIQig (ORCPT ); Thu, 9 Nov 2023 11:38:36 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69D88387A; Thu, 9 Nov 2023 08:38:12 -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 4D31266076B3; Thu, 9 Nov 2023 16:38:10 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1699547891; bh=roMZqY02Ppm/ZZDxSWLBYnwC9qWY5WYlcRmRF4LgVfc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZtTtaQuYMg7f8j8Goycl1oCr0SsWzOhJcrfUWHhg4oCX8CzMSAE6r/w4Ee76yPefo QZxRjxp4taRfSUVLq+K/6nYBrteXOO1sztNV/YiGewELHy+ZCWKOuY9dIwLBYbRyrv niB062ESQMiuRZRQuEyosTGUvpoIvvmG9gRNTfVa0tVzdLUdRYxgJiOvXhfSETL/Qr pgMb+9+VwFAcVXvhT3Ys4bcObFg+abaLIAeKmZGrBgCWaIH5p+NmgUFJZ0TjFt0QH9 gIs8KxF/Kf2/rJBGckMIHbg8sDA5tJqs2cFbjMibtp7zbD9MQrb3Q+OIQxl+qPyA6X 6sbKjd9+zqnaQ== 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 , Neil Armstrong Subject: [PATCH v15 32/56] media: meson: vdec: Stop direct calls to queue num_buffers field Date: Thu, 9 Nov 2023 17:34:48 +0100 Message-Id: <20231109163512.179524-33-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 (fry.vger.email [0.0.0.0]); Thu, 09 Nov 2023 08:40:38 -0800 (PST) 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 fry.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782105369203066599 X-GMAIL-MSGID: 1782105369203066599 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: Neil Armstrong --- drivers/staging/media/meson/vdec/vdec.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/media/meson/vdec/vdec.c b/drivers/staging/media/meson/vdec/vdec.c index 219185aaa588..1e2369f104c8 100644 --- a/drivers/staging/media/meson/vdec/vdec.c +++ b/drivers/staging/media/meson/vdec/vdec.c @@ -167,22 +167,23 @@ static void process_num_buffers(struct vb2_queue *q, bool is_reqbufs) { const struct amvdec_format *fmt_out = sess->fmt_out; - unsigned int buffers_total = q->num_buffers + *num_buffers; + unsigned int q_num_bufs = vb2_get_num_buffers(q); + unsigned int buffers_total = q_num_bufs + *num_buffers; u32 min_buf_capture = v4l2_ctrl_g_ctrl(sess->ctrl_min_buf_capture); - if (q->num_buffers + *num_buffers < min_buf_capture) - *num_buffers = min_buf_capture - q->num_buffers; + if (q_num_bufs + *num_buffers < min_buf_capture) + *num_buffers = min_buf_capture - q_num_bufs; if (is_reqbufs && buffers_total < fmt_out->min_buffers) - *num_buffers = fmt_out->min_buffers - q->num_buffers; + *num_buffers = fmt_out->min_buffers - q_num_bufs; if (buffers_total > fmt_out->max_buffers) - *num_buffers = fmt_out->max_buffers - q->num_buffers; + *num_buffers = fmt_out->max_buffers - q_num_bufs; /* We need to program the complete CAPTURE buffer list * in registers during start_streaming, and the firmwares * are free to choose any of them to write frames to. As such, * we need all of them to be queued into the driver */ - sess->num_dst_bufs = q->num_buffers + *num_buffers; + sess->num_dst_bufs = q_num_bufs + *num_buffers; q->min_buffers_needed = max(fmt_out->min_buffers, sess->num_dst_bufs); }