From patchwork Thu Sep 14 13:32:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139627 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp404053vqi; Thu, 14 Sep 2023 07:52:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG/1fj66QMT87XPfZ0ykUP0qGRLrlEGeqBGpF78h4RM/S/nFZzPtMWaHBPmzCFFnltfXaWU X-Received: by 2002:a05:6a20:54a1:b0:155:2c91:f8e5 with SMTP id i33-20020a056a2054a100b001552c91f8e5mr6239757pzk.14.1694703157703; Thu, 14 Sep 2023 07:52:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694703157; cv=none; d=google.com; s=arc-20160816; b=Wcgjf/1edmxkgbFeOJvklmtp7mujGOXUu03CmPATr8uR2e48B4SmlaUZkIPr77UtGq t2Tv4q7yVZBQ9NitVi5/NxeE+B2kwhB9JGR7C0NeCfIlkUsyhMp9Wmcn0qDsF4g9fAKB iOvtmV8CJ/P6AYDOsSdDR5HB25FRhK7pjRvyaolJV8MhmVeFp1ABjVq+aAim6clJh8wx U5XSFuICo6O87HBbi33j/HOzjbZab4pxmgZ1hOIMKGY7kD+TnV0xBV8rKkkAZg1OlfMi GTBLMKKPlDjqWhLUuG8W/nqsr/4e+RLH3dgUSSmtrcYxLKdiAea7UBUfugxXUIs97KJP DsRQ== 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=1be88CI2RuhWrOGMD26vIYNo9it5Gul2OJz2q+CAvS4=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=sCaTOJCJ4kI6Mh6lv0KTaNxkgoMCGk+D6B5wigdJ0npn98O8L3AAEVUnNGSPEoisSE HS3w7/968NrquJBRvsyE8Jmlbu07EAE1gRWF4MX2fbYSwUsUgZw45EtD1sxwX52NbHMe tod5ci32kf9oXZeypKHa/DyK0M5AwZQciqDxw9brSk3iAk3OkgY5TDNswetkPz2bC1Ew l2aYaQCqmrtSXarFvKIxd0FGvSTfmv7YD19Y+QaJaBYMWFkFycyijMZLEUyUt8ABRgL/ aVHywlOgG+u+YGsGXz9RESIi6brzgYMYAWeVo8E4DUrFuAHOdXWv7+cxxoziZsk9mEO6 rDuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=aSyp7ffu; 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 bx39-20020a056a02052700b005703b492a23si1816111pgb.308.2023.09.14.07.52.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 07:52:37 -0700 (PDT) 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=aSyp7ffu; 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 ADEDC8381E68; Thu, 14 Sep 2023 06:33:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239039AbjINNdj (ORCPT + 35 others); Thu, 14 Sep 2023 09:33:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230174AbjINNdh (ORCPT ); Thu, 14 Sep 2023 09:33:37 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CCF11FC0; Thu, 14 Sep 2023 06:33:33 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 9993F660734C; Thu, 14 Sep 2023 14:33:31 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698412; bh=+eRsvnpNumq6bQf88LlWZR7Lny7uqYBNBiPKeHOjtOs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aSyp7ffubuNGkWb5eWQFg+eXWjYVUNooVpYC/nK0PtWo3aDnYbC4wrVxLTimb72Tl YbjeDlDt10JlG0HL7pr1oRCiK5NXQf2LB6EYt1cAcqy1aYaCMKKWuaGa9B09B8wC0n zC+GhyPII95M+/TAA6VoBiJBDJhvETgIcvFwYXQ4DhyLgimlxBiavxHHJdbNh/FI6o PGGJDDdUf7+2YpCCUyLTqDuzQ/Kt+vBVpVfffjdxGcdDMvCTTOncE6jLOjUlc22BjI JlW6oiKwMcXQkSGNZwDvqIT6T3pkCnleWWYex4bCEEZnLgJ83XhWmUJZwjqkMOHzdB 5/zbTa0w3ffwA== 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 v7 01/49] media: videobuf2: Rework offset 'cookie' encoding pattern Date: Thu, 14 Sep 2023 15:32:35 +0200 Message-Id: <20230914133323.198857-2-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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, 14 Sep 2023 06:33:51 -0700 (PDT) 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 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: 1777025057886219313 X-GMAIL-MSGID: 1777025057886219313 Change how offset 'cookie' field value is computed to make possible to use more buffers (up to 0x7fff) With this encoding pattern we know the maximum number that a queue could store so we can check ing at queue init time. It also make easier and faster to find buffer and plane from using the offset field. Signed-off-by: Benjamin Gaignard --- .../media/common/videobuf2/videobuf2-core.c | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index cf6727d9c81f..cf3b9f5b69b7 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -31,6 +31,10 @@ #include +#define PLANE_INDEX_SHIFT (PAGE_SHIFT + 3) +#define PLANE_INDEX_MASK 0x7 +#define BUFFER_INDEX_MASK 0x7fff + static int debug; module_param(debug, int, 0644); @@ -358,21 +362,23 @@ static void __setup_offsets(struct vb2_buffer *vb) unsigned int plane; unsigned long off = 0; - if (vb->index) { - struct vb2_buffer *prev = q->bufs[vb->index - 1]; - struct vb2_plane *p = &prev->planes[prev->num_planes - 1]; - - off = PAGE_ALIGN(p->m.offset + p->length); - } + /* + * Offsets cookies value have the following constraints: + * - a buffer could have up to 8 planes. + * - v4l2 mem2mem use bit 30 to distinguish between source and destination buffers. + * - must be page aligned + * That led to this bit mapping: + * |30 |29 15|14 12|11 0| + * |DST_QUEUE_OFF_BASE|buffer index|plane index| 0 | + * where there is 15 bits to store buffer index. + */ + off = vb->index << (PLANE_INDEX_SHIFT); for (plane = 0; plane < vb->num_planes; ++plane) { - vb->planes[plane].m.offset = off; + vb->planes[plane].m.offset = off + (plane << PAGE_SHIFT); dprintk(q, 3, "buffer %d, plane %d offset 0x%08lx\n", vb->index, plane, off); - - off += vb->planes[plane].length; - off = PAGE_ALIGN(off); } } @@ -2209,21 +2215,15 @@ static int __find_plane_by_offset(struct vb2_queue *q, unsigned long off, return -EBUSY; } - /* - * Go over all buffers and their planes, comparing the given offset - * with an offset assigned to each plane. If a match is found, - * return its buffer and plane numbers. - */ - for (buffer = 0; buffer < q->num_buffers; ++buffer) { - vb = q->bufs[buffer]; + /* Get buffer and plane from the offset */ + buffer = (off >> PLANE_INDEX_SHIFT) & BUFFER_INDEX_MASK; + plane = (off >> PAGE_SHIFT) & PLANE_INDEX_MASK; - for (plane = 0; plane < vb->num_planes; ++plane) { - if (vb->planes[plane].m.offset == off) { - *_buffer = buffer; - *_plane = plane; - return 0; - } - } + vb = q->bufs[buffer]; + if (vb->planes[plane].m.offset == off) { + *_buffer = buffer; + *_plane = plane; + return 0; } return -EINVAL; From patchwork Thu Sep 14 13:32:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139851 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp635511vqi; Thu, 14 Sep 2023 14:27:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHtvsQVHOPNT0LUsX52tPf1KqlRyDiM4t88FXK94EnNyggV3tU41szyOS6CoVJdPt7tbV/S X-Received: by 2002:a17:902:e5c7:b0:1c1:ee26:2337 with SMTP id u7-20020a170902e5c700b001c1ee262337mr8057629plf.59.1694726870108; Thu, 14 Sep 2023 14:27:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694726870; cv=none; d=google.com; s=arc-20160816; b=Lx2Bg2vucdW0ot9C7TUFlvEMqEzpx9fBfcdjkwerL12ijkZEi6M7/09p0KyuJQYWY6 q72ej0nm+Rw1LLRvz1St13OpRtWaL2K6Nt8lFbv8OTcbEiXrSUFXwdoVVKlVNd4CHOER yH5ItVgufQWlSZf/5R6mhBtcj6+4HEHUhv30mf6pFEHecCAwKedpKObavnZVgnB2CjmF zYJOc3jin+Me256+mXiQwE+Fmf3bHJPcqmMp2G95lFWLNuAH5fgsX8JSM/ZEyAlJ+2EV PuE14ldrvJqdWLLQLF7bDQ6goiSNS859X3pdZ06aR9BDOizI6XA2qBaszTQBvvE8YzJ9 dRJQ== 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=KPkS+M6IgW6hKxp12Ew7E3jLLNWwGuqC5A4CccgdqSg=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=w4iloXQQGBtGfb8B1RM7lKaf/wUp6G4jueKz7INxoYu2s9a24nDj/2E/AckxozzjPV kl+8YTFrxBNlBQxygakdl1DJ4tNq0Wab5+VWiP2b+9CEAJoYUH22gioXypxfmAiWfOHd 0yW7dqnXBrpH+Xg1pARIUETJM4Nnn5can1LSAlBhvFFA4vn6/X9AaEtbW1qXOGs7C6rT jPirklNaOJrnKhgvF9Tr/iUv4oxcMhWbzPnoO8x6SG6r4jT9F3lfo7isQLW/y5fiJMhF k8e6pR0FR7020PeuYXUPKvB12ngh2zQZkGUsro2/tVnwR+LpORVxPeJFykynuNTwN3+m ToWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=AuvJq6LC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id z1-20020a170903018100b001bb9c731a41si2345857plg.623.2023.09.14.14.27.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 14:27:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=AuvJq6LC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 6782A8211490; Thu, 14 Sep 2023 06:34:06 -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 S239074AbjINNdl (ORCPT + 35 others); Thu, 14 Sep 2023 09:33:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237766AbjINNdi (ORCPT ); Thu, 14 Sep 2023 09:33:38 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C52751BF8; Thu, 14 Sep 2023 06:33:33 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 275EA660734D; Thu, 14 Sep 2023 14:33:32 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698412; bh=vLoWqr47TwOs1W2O/2hbr7Z04WYV94izNAnUlnx4n1U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AuvJq6LC1pQYeAaZvyb0AVzp6pX9e26QrthP7Tv39E7s97ssh7hrz95u7afxAdhjz BJX1o2yaxKntWICdJhTc/IMi3qi9Q1tUiiSlmLCUwcjf1W9FRCWxT0QsoDzybofyof uANPP7cD3h1ev5p3AVx3dD8sR1acPAOUKsj4NhvKV3GPTIkrh1Df0IR0G/8UxR/Qxd rRkHy/WaI6wfRxE6WQgCMNF0LQlc5hwWi0jbUDIPKeCpPvJhwzm6LY8X60hWxQk6zD SqPwOA2a950Rux6G27ch5DeOrc7km5dKtO8K1cvn2KbpSiVf9F0NI7nYO0Bqp5mZ7/ JC3gCr+hTLV8A== 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 v7 02/49] media: videobuf2: Stop spamming kernel log with all queue counter Date: Thu, 14 Sep 2023 15:32:36 +0200 Message-Id: <20230914133323.198857-3-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (morse.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:34:06 -0700 (PDT) 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777049922676493872 X-GMAIL-MSGID: 1777049922676493872 Only report unbalanced queue counters do avoid spamming kernel log with useless information. Signed-off-by: Benjamin Gaignard --- .../media/common/videobuf2/videobuf2-core.c | 77 +++++++++++-------- 1 file changed, 43 insertions(+), 34 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index cf3b9f5b69b7..bedd827c0d9a 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -529,24 +529,25 @@ static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) #ifdef CONFIG_VIDEO_ADV_DEBUG /* * Check that all the calls were balances during the life-time of this - * queue. If not (or if the debug level is 1 or up), then dump the - * counters to the kernel log. + * queue. If not then dump the counters to the kernel log. */ if (q->num_buffers) { bool unbalanced = q->cnt_start_streaming != q->cnt_stop_streaming || q->cnt_prepare_streaming != q->cnt_unprepare_streaming || q->cnt_wait_prepare != q->cnt_wait_finish; - if (unbalanced || debug) { - pr_info("counters for queue %p:%s\n", q, - unbalanced ? " UNBALANCED!" : ""); - pr_info(" setup: %u start_streaming: %u stop_streaming: %u\n", - q->cnt_queue_setup, q->cnt_start_streaming, - q->cnt_stop_streaming); - pr_info(" prepare_streaming: %u unprepare_streaming: %u\n", - q->cnt_prepare_streaming, q->cnt_unprepare_streaming); - pr_info(" wait_prepare: %u wait_finish: %u\n", - q->cnt_wait_prepare, q->cnt_wait_finish); + if (unbalanced) { + pr_info("unbalanced counters for queue %p:\n", q); + if (q->cnt_start_streaming != q->cnt_stop_streaming) + pr_info(" setup: %u start_streaming: %u stop_streaming: %u\n", + q->cnt_queue_setup, q->cnt_start_streaming, + q->cnt_stop_streaming); + if (q->cnt_prepare_streaming != q->cnt_unprepare_streaming) + pr_info(" prepare_streaming: %u unprepare_streaming: %u\n", + q->cnt_prepare_streaming, q->cnt_unprepare_streaming); + if (q->cnt_wait_prepare != q->cnt_wait_finish) + pr_info(" wait_prepare: %u wait_finish: %u\n", + q->cnt_wait_prepare, q->cnt_wait_finish); } q->cnt_queue_setup = 0; q->cnt_wait_prepare = 0; @@ -567,29 +568,37 @@ static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) vb->cnt_buf_prepare != vb->cnt_buf_finish || vb->cnt_buf_init != vb->cnt_buf_cleanup; - if (unbalanced || debug) { - pr_info(" counters for queue %p, buffer %d:%s\n", - q, buffer, unbalanced ? " UNBALANCED!" : ""); - pr_info(" buf_init: %u buf_cleanup: %u buf_prepare: %u buf_finish: %u\n", - vb->cnt_buf_init, vb->cnt_buf_cleanup, - vb->cnt_buf_prepare, vb->cnt_buf_finish); - pr_info(" buf_out_validate: %u buf_queue: %u buf_done: %u buf_request_complete: %u\n", - vb->cnt_buf_out_validate, vb->cnt_buf_queue, - vb->cnt_buf_done, vb->cnt_buf_request_complete); - pr_info(" alloc: %u put: %u prepare: %u finish: %u mmap: %u\n", - vb->cnt_mem_alloc, vb->cnt_mem_put, - vb->cnt_mem_prepare, vb->cnt_mem_finish, - vb->cnt_mem_mmap); - pr_info(" get_userptr: %u put_userptr: %u\n", - vb->cnt_mem_get_userptr, vb->cnt_mem_put_userptr); - pr_info(" attach_dmabuf: %u detach_dmabuf: %u map_dmabuf: %u unmap_dmabuf: %u\n", - vb->cnt_mem_attach_dmabuf, vb->cnt_mem_detach_dmabuf, - vb->cnt_mem_map_dmabuf, vb->cnt_mem_unmap_dmabuf); - pr_info(" get_dmabuf: %u num_users: %u vaddr: %u cookie: %u\n", + if (unbalanced) { + pr_info("unbalanced counters for queue %p:, buffer %d\n", + q, buffer); + if (vb->cnt_buf_init != vb->cnt_buf_cleanup) + pr_info(" buf_init: %u buf_cleanup: %u\n", + vb->cnt_buf_init, vb->cnt_buf_cleanup); + if (vb->cnt_buf_prepare != vb->cnt_buf_finish) + pr_info(" buf_prepare: %u buf_finish: %u\n", + vb->cnt_buf_prepare, vb->cnt_buf_finish); + if (vb->cnt_buf_queue != vb->cnt_buf_done) + pr_info(" buf_out_validate: %u buf_queue: %u buf_done: %u buf_request_complete: %u\n", + vb->cnt_buf_out_validate, vb->cnt_buf_queue, + vb->cnt_buf_done, vb->cnt_buf_request_complete); + if (vb->cnt_mem_alloc != vb->cnt_mem_put) + pr_info(" alloc: %u put: %u\n", + vb->cnt_mem_alloc, vb->cnt_mem_put); + if (vb->cnt_mem_prepare != vb->cnt_mem_finish) + pr_info(" prepare: %u finish: %u\n", + vb->cnt_mem_prepare, vb->cnt_mem_finish); + if (vb->cnt_mem_get_userptr != vb->cnt_mem_put_userptr) + pr_info(" get_userptr: %u put_userptr: %u\n", + vb->cnt_mem_get_userptr, vb->cnt_mem_put_userptr); + if (vb->cnt_mem_attach_dmabuf != vb->cnt_mem_detach_dmabuf) + pr_info(" attach_dmabuf: %u detach_dmabuf: %u\n", + vb->cnt_mem_attach_dmabuf, vb->cnt_mem_detach_dmabuf); + if (vb->cnt_mem_map_dmabuf != vb->cnt_mem_unmap_dmabuf) + pr_info(" map_dmabuf: %u unmap_dmabuf: %u\n", + vb->cnt_mem_map_dmabuf, vb->cnt_mem_unmap_dmabuf); + pr_info(" get_dmabuf: %u num_users: %u\n", vb->cnt_mem_get_dmabuf, - vb->cnt_mem_num_users, - vb->cnt_mem_vaddr, - vb->cnt_mem_cookie); + vb->cnt_mem_num_users); } } #endif From patchwork Thu Sep 14 13:32:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139807 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp585136vqi; Thu, 14 Sep 2023 12:45:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEC3dt4t2qqBd+jbeSQxvs2UbiJa+2N9NY6R9iiijr+wMc5X+qQBMEl1lD/FD8n3ElvpDVw X-Received: by 2002:a05:6358:4323:b0:142:fd2b:da2e with SMTP id r35-20020a056358432300b00142fd2bda2emr1329991rwc.31.1694720733258; Thu, 14 Sep 2023 12:45:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694720733; cv=none; d=google.com; s=arc-20160816; b=jxQyj43S989sxxnzv9hHvovLdC6N/pdP65ly9pG/xwf9xqhVQYiHFQdJBCSf+1o/dS ArFwg9oT8nJ2w4CIpYGB6SDis+Q5lgagJPZvCiMW4FI+8XriUfh1xS9RGGAgk3vLUskx xCmyda7YiAhengBcHQhdUNlDZ78TrxQomjJyEPua1XqpnGbLgHBbUd9WUgdUfLLTL7xB 5CvgzcJC18wlVet1LBnjSQVLflmIweV2AmsmgJvxzJhW8JQL7lbCUtqKELK1/Az0G3uU 1k9eOHx33Vh3fyksKlZMh0m/tyQGxcc8f1h14xwJ3xvx5ba1giy2uRKpiF7zn5AcEeFw Vr3A== 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=dG1xQHzBYO0D2Wnlfgy6WTZEoZ5dFqbTqZzReNJkJqQ=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=fwpPfqRV5Q0M+GrDqBWXscm9bfg80ArWxB7MkUKAZvU2P+/HinIrAuK9hSPWSmXJ+t WSj1FQbkw6SCbe58mCmztKZC6xb/4XksXjiHjWu3RW2N097RkDnuVHprn43dCv7qSojF 6xT89st81iyEVUb4Fi+1L3a4MNoXSoIJ0DDJoO6+U5DiAD9Siwl25mfpxGIaTy5Ezp99 SUS7LT6zYRsllixbMoJDMml3pVEZIJ/s1fSTGsNeqZ3G5MYskeYCrEHXNvEalEdbyCQP NuLHPk0gX67dOGVtKPzLoyiOV9SFgcfUsrWYdavCuBh7Vy73m/EV9SvNP8L4a2WzoiXK cNGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=KMvgCnej; 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 t17-20020a63d251000000b00573f8a5337esi2028473pgi.461.2023.09.14.12.45.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 12:45:33 -0700 (PDT) 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=KMvgCnej; 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 C9ACD834F741; Thu, 14 Sep 2023 06:34:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239100AbjINNdo (ORCPT + 35 others); Thu, 14 Sep 2023 09:33:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238993AbjINNdi (ORCPT ); Thu, 14 Sep 2023 09:33:38 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FA261FC0; Thu, 14 Sep 2023 06:33:34 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 A6F05660734E; Thu, 14 Sep 2023 14:33:32 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698413; bh=EpFgbhDUnMMeXI9r0f9hD84Y41WHjCMZ64TZX2CDeks=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KMvgCnejrmDNkJvdeZxF2yAQx3hIW6x1pFeAj8+xE7tFRADQp8vr2DKbamuYzuMvH F1AeLzLydtRhrlGV4H6bJsX1j/LVA6YxUwFWwmi+tk6GdVTfFid16tXEvIGfDJFYor bYGa5B6uG7rb4/WZGJTWYMYjJD4h36HbYVLe4q1GU/yO2iyHf44d/jgPN6nsyoJEfs MRB8nIH/fsYj/QoilB826O5VhAhBRViUvgTsPtDwG8S+5WBjEJqW5MY0/QeN4vjF+s rMGr2F+66lqhhmUR0qMb2td+yJJJ6t1oSBgzfhrsmYclOJVeNzePagFKbnFPvmGHSI YnYAH1nhH+xPA== 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 v7 03/49] media: videobuf2: Use vb2_buffer instead of index Date: Thu, 14 Sep 2023 15:32:37 +0200 Message-Id: <20230914133323.198857-4-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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, 14 Sep 2023 06:34:07 -0700 (PDT) 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 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: 1777043487899421513 X-GMAIL-MSGID: 1777043487899421513 Directly use vb2_buffer pointer instead of index inside queue array. Signed-off-by: Benjamin Gaignard --- .../media/common/videobuf2/videobuf2-core.c | 40 ++++++------------- .../media/common/videobuf2/videobuf2-v4l2.c | 30 ++++++++++++-- drivers/media/dvb-core/dvb_vb2.c | 6 +-- include/media/videobuf2-core.h | 16 ++++---- 4 files changed, 49 insertions(+), 43 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index bedd827c0d9a..5f31b99e3f03 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -649,9 +649,9 @@ static bool __buffers_in_use(struct vb2_queue *q) return false; } -void vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb) +void vb2_core_querybuf(struct vb2_queue *q, struct vb2_buffer *vb, void *pb) { - call_void_bufop(q, fill_user_buffer, q->bufs[index], pb); + call_void_bufop(q, fill_user_buffer, vb, pb); } EXPORT_SYMBOL_GPL(vb2_core_querybuf); @@ -1485,9 +1485,6 @@ static void vb2_req_unprepare(struct media_request_object *obj) WARN_ON(!vb->req_obj.req); } -int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb, - struct media_request *req); - static void vb2_req_queue(struct media_request_object *obj) { struct vb2_buffer *vb = container_of(obj, struct vb2_buffer, req_obj); @@ -1502,7 +1499,7 @@ static void vb2_req_queue(struct media_request_object *obj) * set. We just ignore that, and expect this will be caught the * next time vb2_req_prepare() is called. */ - err = vb2_core_qbuf(vb->vb2_queue, vb->index, NULL, NULL); + err = vb2_core_qbuf(vb->vb2_queue, vb, NULL, NULL); WARN_ON_ONCE(err && err != -EIO); mutex_unlock(vb->vb2_queue->lock); } @@ -1557,12 +1554,10 @@ unsigned int vb2_request_buffer_cnt(struct media_request *req) } EXPORT_SYMBOL_GPL(vb2_request_buffer_cnt); -int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb) +int vb2_core_prepare_buf(struct vb2_queue *q, struct vb2_buffer *vb, void *pb) { - struct vb2_buffer *vb; int ret; - vb = q->bufs[index]; if (vb->state != VB2_BUF_STATE_DEQUEUED) { dprintk(q, 1, "invalid buffer state %s\n", vb2_state_name(vb->state)); @@ -1649,10 +1644,9 @@ static int vb2_start_streaming(struct vb2_queue *q) return ret; } -int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb, +int vb2_core_qbuf(struct vb2_queue *q, struct vb2_buffer *vb, void *pb, struct media_request *req) { - struct vb2_buffer *vb; enum vb2_buffer_state orig_state; int ret; @@ -1661,8 +1655,6 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb, return -EIO; } - vb = q->bufs[index]; - if (!req && vb->state != VB2_BUF_STATE_IN_REQUEST && q->requires_requests) { dprintk(q, 1, "qbuf requires a request\n"); @@ -2239,9 +2231,8 @@ static int __find_plane_by_offset(struct vb2_queue *q, unsigned long off, } int vb2_core_expbuf(struct vb2_queue *q, int *fd, unsigned int type, - unsigned int index, unsigned int plane, unsigned int flags) + struct vb2_buffer *vb, unsigned int plane, unsigned int flags) { - struct vb2_buffer *vb = NULL; struct vb2_plane *vb_plane; int ret; struct dma_buf *dbuf; @@ -2266,13 +2257,6 @@ int vb2_core_expbuf(struct vb2_queue *q, int *fd, unsigned int type, return -EINVAL; } - if (index >= q->num_buffers) { - dprintk(q, 1, "buffer index out of range\n"); - return -EINVAL; - } - - vb = q->bufs[index]; - if (plane >= vb->num_planes) { dprintk(q, 1, "buffer plane out of range\n"); return -EINVAL; @@ -2291,20 +2275,20 @@ int vb2_core_expbuf(struct vb2_queue *q, int *fd, unsigned int type, flags & O_ACCMODE); if (IS_ERR_OR_NULL(dbuf)) { dprintk(q, 1, "failed to export buffer %d, plane %d\n", - index, plane); + vb->index, plane); return -EINVAL; } ret = dma_buf_fd(dbuf, flags & ~O_ACCMODE); if (ret < 0) { dprintk(q, 3, "buffer %d, plane %d failed to export (%d)\n", - index, plane, ret); + vb->index, plane, ret); dma_buf_put(dbuf); return ret; } dprintk(q, 3, "buffer %d, plane %d exported as %d descriptor\n", - index, plane, ret); + vb->index, plane, ret); *fd = ret; return 0; @@ -2713,7 +2697,7 @@ static int __vb2_init_fileio(struct vb2_queue *q, int read) * Queue all buffers. */ for (i = 0; i < q->num_buffers; i++) { - ret = vb2_core_qbuf(q, i, NULL, NULL); + ret = vb2_core_qbuf(q, q->bufs[i], NULL, NULL); if (ret) goto err_reqbufs; fileio->bufs[i].queued = 1; @@ -2898,7 +2882,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ if (copy_timestamp) b->timestamp = ktime_get_ns(); - ret = vb2_core_qbuf(q, index, NULL, NULL); + ret = vb2_core_qbuf(q, b, NULL, NULL); dprintk(q, 5, "vb2_dbuf result: %d\n", ret); if (ret) return ret; @@ -3001,7 +2985,7 @@ static int vb2_thread(void *data) if (copy_timestamp) vb->timestamp = ktime_get_ns(); if (!threadio->stop) - ret = vb2_core_qbuf(q, vb->index, NULL, NULL); + ret = vb2_core_qbuf(q, vb, NULL, NULL); call_void_qop(q, wait_prepare, q); if (ret || threadio->stop) break; diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index c7a54d82a55e..697c8a9f98cd 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -667,7 +667,7 @@ int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b) vb = q->bufs[b->index]; ret = __verify_planes_array(vb, b); if (!ret) - vb2_core_querybuf(q, b->index, b); + vb2_core_querybuf(q, vb, b); return ret; } EXPORT_SYMBOL(vb2_querybuf); @@ -723,6 +723,7 @@ EXPORT_SYMBOL_GPL(vb2_reqbufs); int vb2_prepare_buf(struct vb2_queue *q, struct media_device *mdev, struct v4l2_buffer *b) { + struct vb2_buffer *vb; int ret; if (vb2_fileio_is_active(q)) { @@ -733,9 +734,15 @@ int vb2_prepare_buf(struct vb2_queue *q, struct media_device *mdev, if (b->flags & V4L2_BUF_FLAG_REQUEST_FD) return -EINVAL; + if (b->index >= q->num_buffers) { + dprintk(q, 1, "buffer index out of range\n"); + return -EINVAL; + } + vb = q->bufs[b->index]; + ret = vb2_queue_or_prepare_buf(q, mdev, b, true, NULL); - return ret ? ret : vb2_core_prepare_buf(q, b->index, b); + return ret ? ret : vb2_core_prepare_buf(q, vb, b); } EXPORT_SYMBOL_GPL(vb2_prepare_buf); @@ -803,6 +810,7 @@ int vb2_qbuf(struct vb2_queue *q, struct media_device *mdev, struct v4l2_buffer *b) { struct media_request *req = NULL; + struct vb2_buffer *vb; int ret; if (vb2_fileio_is_active(q)) { @@ -810,10 +818,16 @@ int vb2_qbuf(struct vb2_queue *q, struct media_device *mdev, return -EBUSY; } + if (b->index >= q->num_buffers) { + dprintk(q, 1, "buffer index out of range\n"); + return -EINVAL; + } + vb = q->bufs[b->index]; + ret = vb2_queue_or_prepare_buf(q, mdev, b, false, &req); if (ret) return ret; - ret = vb2_core_qbuf(q, b->index, b, req); + ret = vb2_core_qbuf(q, vb, b, req); if (req) media_request_put(req); return ret; @@ -873,7 +887,15 @@ EXPORT_SYMBOL_GPL(vb2_streamoff); int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb) { - return vb2_core_expbuf(q, &eb->fd, eb->type, eb->index, + struct vb2_buffer *vb; + + if (eb->index >= q->num_buffers) { + dprintk(q, 1, "buffer index out of range\n"); + return -EINVAL; + } + vb = q->bufs[eb->index]; + + return vb2_core_expbuf(q, &eb->fd, eb->type, vb, eb->plane, eb->flags); } EXPORT_SYMBOL_GPL(vb2_expbuf); diff --git a/drivers/media/dvb-core/dvb_vb2.c b/drivers/media/dvb-core/dvb_vb2.c index 909df82fed33..b322ef179f05 100644 --- a/drivers/media/dvb-core/dvb_vb2.c +++ b/drivers/media/dvb-core/dvb_vb2.c @@ -360,7 +360,7 @@ int dvb_vb2_querybuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b) dprintk(1, "[%s] buffer index out of range\n", ctx->name); return -EINVAL; } - vb2_core_querybuf(&ctx->vb_q, b->index, b); + vb2_core_querybuf(&ctx->vb_q, q->bufs[b->index], b); dprintk(3, "[%s] index=%d\n", ctx->name, b->index); return 0; } @@ -370,7 +370,7 @@ int dvb_vb2_expbuf(struct dvb_vb2_ctx *ctx, struct dmx_exportbuffer *exp) struct vb2_queue *q = &ctx->vb_q; int ret; - ret = vb2_core_expbuf(&ctx->vb_q, &exp->fd, q->type, exp->index, + ret = vb2_core_expbuf(&ctx->vb_q, &exp->fd, q->type, q->bufs[exp->index], 0, exp->flags); if (ret) { dprintk(1, "[%s] index=%d errno=%d\n", ctx->name, @@ -391,7 +391,7 @@ int dvb_vb2_qbuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b) dprintk(1, "[%s] buffer index out of range\n", ctx->name); return -EINVAL; } - ret = vb2_core_qbuf(&ctx->vb_q, b->index, b, NULL); + ret = vb2_core_qbuf(&ctx->vb_q, q->bufs[b->index], b, NULL); if (ret) { dprintk(1, "[%s] index=%d errno=%d\n", ctx->name, b->index, ret); diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 4b6a9d2ea372..cd3ff1cd759d 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -747,7 +747,7 @@ int vb2_wait_for_all_buffers(struct vb2_queue *q); /** * vb2_core_querybuf() - query video buffer information. * @q: pointer to &struct vb2_queue with videobuf2 queue. - * @index: id number of the buffer. + * @vb: pointer to struct &vb2_buffer. * @pb: buffer struct passed from userspace. * * Videobuf2 core helper to implement VIDIOC_QUERYBUF() operation. It is called @@ -759,7 +759,7 @@ int vb2_wait_for_all_buffers(struct vb2_queue *q); * * Return: returns zero on success; an error code otherwise. */ -void vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb); +void vb2_core_querybuf(struct vb2_queue *q, struct vb2_buffer *vb, void *pb); /** * vb2_core_reqbufs() - Initiate streaming. @@ -823,7 +823,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, * vb2_core_prepare_buf() - Pass ownership of a buffer from userspace * to the kernel. * @q: pointer to &struct vb2_queue with videobuf2 queue. - * @index: id number of the buffer. + * @vb: pointer to struct &vb2_buffer. * @pb: buffer structure passed from userspace to * &v4l2_ioctl_ops->vidioc_prepare_buf handler in driver. * @@ -839,13 +839,13 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, * * Return: returns zero on success; an error code otherwise. */ -int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb); +int vb2_core_prepare_buf(struct vb2_queue *q, struct vb2_buffer *vb, void *pb); /** * vb2_core_qbuf() - Queue a buffer from userspace * * @q: pointer to &struct vb2_queue with videobuf2 queue. - * @index: id number of the buffer + * @vb: pointer to struct &vb2_buffer. * @pb: buffer structure passed from userspace to * v4l2_ioctl_ops->vidioc_qbuf handler in driver * @req: pointer to &struct media_request, may be NULL. @@ -867,7 +867,7 @@ int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb); * * Return: returns zero on success; an error code otherwise. */ -int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb, +int vb2_core_qbuf(struct vb2_queue *q, struct vb2_buffer *vb, void *pb, struct media_request *req); /** @@ -931,7 +931,7 @@ int vb2_core_streamoff(struct vb2_queue *q, unsigned int type); * @fd: pointer to the file descriptor associated with DMABUF * (set by driver). * @type: buffer type. - * @index: id number of the buffer. + * @vb: pointer to struct &vb2_buffer. * @plane: index of the plane to be exported, 0 for single plane queues * @flags: file flags for newly created file, as defined at * include/uapi/asm-generic/fcntl.h. @@ -945,7 +945,7 @@ int vb2_core_streamoff(struct vb2_queue *q, unsigned int type); * Return: returns zero on success; an error code otherwise. */ int vb2_core_expbuf(struct vb2_queue *q, int *fd, unsigned int type, - unsigned int index, unsigned int plane, unsigned int flags); + struct vb2_buffer *vb, unsigned int plane, unsigned int flags); /** * vb2_core_queue_init() - initialize a videobuf2 queue From patchwork Thu Sep 14 13:32:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139855 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp639318vqi; Thu, 14 Sep 2023 14:35:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG8FtSA00VT5GG7YiOmEwcovTYpQte22yNxw/5aae0NJpGCcr31mWFFbi16Likpq2wNj3KY X-Received: by 2002:a17:902:74c6:b0:1c3:6724:db6f with SMTP id f6-20020a17090274c600b001c36724db6fmr6199083plt.29.1694727357767; Thu, 14 Sep 2023 14:35:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694727357; cv=none; d=google.com; s=arc-20160816; b=vgmDCCdlNCrgyiDkSGtigMm/xrgTV9Yrp19NZ+EWd9ENg4iQk1vKBNAleeC5yfK1D4 BsgZuYwHVTby2JT1Cvtv60n8jBCX4snBrMU/RPZ7X1XLYJh9KXFnLcg7Bh5YtMmy6A9U O9J7tWy033twraJcOXgung+t/XMVm4ah8W6T0n+JY94TIvkTSAdTZQapFrTbWUEv3HjJ 9kcSTmeJBnXCGUneR0DahTNVkBPa/JW3Jxro60b36nDmWQMknNahPwmQ+C+jes2WxwSL E7f+Ch4Gc7pP/NNpD2wDrkkLSltJNxTfjZS0A6yYbuN14vDzLnrI3jt0B5qxqol/M7LO nYqA== 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=mp1KeUwXEPeyi7FaB/qpZlqFp0j0IcgZ40cl1bA/YGw=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=VOIC189wAybb/pyiUCck9WePo2psWGVfeb/bTYL4MXV3wq0mezfT3BACby3e6fctVf 53CIFM6mLLHE7ML+LZESqeaT3kt7dfXdEYM2APz4J2TeD0uTZOQkj8BV8+LpjFy5aP5K UOvbkPlMbuH8nQ63KZiJz0Vj9TF/HURrjawlU7OojY2a2613AxP9b+QqSpP5L/M67Jlr OOwotYtgncCboHo/1Zq34CUf4eGXjUe5h/XdYoGXFWZGEahAq8X5wiAq8TFzO0Q2f6PF QV0V1Yhe5sgrvRDtqnKK9KlP61YCkXpRcLpRboi8uHrJU3JPusqPXEConO4sLDGr/wsN Lnzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=S3NYcmVU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id a12-20020a17090a8c0c00b00263638bb354si4485705pjo.93.2023.09.14.14.35.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 14:35:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=S3NYcmVU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 DDE6A821148A; Thu, 14 Sep 2023 06:34:05 -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 S239088AbjINNdn (ORCPT + 35 others); Thu, 14 Sep 2023 09:33:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239008AbjINNdj (ORCPT ); Thu, 14 Sep 2023 09:33:39 -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 E233F1BF8; Thu, 14 Sep 2023 06:33:34 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 4FC55660734F; Thu, 14 Sep 2023 14:33:33 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698413; bh=swS7yYiqBxggjIra2XX2pXDY4PPq3f683TK0rKa6DhQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S3NYcmVUT/668LAIWTgK5i5tWEyxhjosr4VuCzSWSR89CBBmduMkbxehmFdODUu3Y vbNJ31v+IzyyZCmKcT/yK8z3b7BnZDDbzFcORQsFgOqx+3moz3mV2otVE3TWQk9Nh8 qFPkSkNm/ESDmsHnQE9TY6kfW1FmnoCtZmtnmals7qGlc9w1aGYFISc9YrpwJgD0UC eBfF2oYlnxdM+IRU9H3zCnA88N7Fq4Pu4AUytP24NYNtXFT8bDNROKnG/X5lTZm4+X hZCKFFCjPXH6+Vu7biaWGiWFit336I5sw2dijDy4GWQAAspAHn4+X/3xozOO1hK1CA FxxL0BQuqv/Cg== 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 v7 04/49] media: amphion: Use vb2_get_buffer() instead of directly access to buffers array Date: Thu, 14 Sep 2023 15:32:38 +0200 Message-Id: <20230914133323.198857-5-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (morse.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:34:06 -0700 (PDT) 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777050433746647552 X-GMAIL-MSGID: 1777050433746647552 Use vb2_get_buffer() instead of directly access to vb2_buffer buffer array. This could allow to change the type bufs[] field of vb2_buffer structure if needed. After each call to vb2_get_buffer() we need to be sure that we get a valid pointer so check the return value of all of them. Signed-off-by: Benjamin Gaignard --- drivers/media/platform/amphion/vpu_dbg.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/amphion/vpu_dbg.c b/drivers/media/platform/amphion/vpu_dbg.c index 982c2c777484..a462d6fe4ea9 100644 --- a/drivers/media/platform/amphion/vpu_dbg.c +++ b/drivers/media/platform/amphion/vpu_dbg.c @@ -140,11 +140,18 @@ static int vpu_dbg_instance(struct seq_file *s, void *data) vq = v4l2_m2m_get_src_vq(inst->fh.m2m_ctx); for (i = 0; i < vq->num_buffers; i++) { - struct vb2_buffer *vb = vq->bufs[i]; - struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + struct vb2_buffer *vb; + struct vb2_v4l2_buffer *vbuf; + + vb = vb2_get_buffer(vq, i); + if (!vb) + continue; if (vb->state == VB2_BUF_STATE_DEQUEUED) continue; + + vbuf = to_vb2_v4l2_buffer(vb); + num = scnprintf(str, sizeof(str), "output [%2d] state = %10s, %8s\n", i, vb2_stat_name[vb->state], @@ -155,11 +162,18 @@ static int vpu_dbg_instance(struct seq_file *s, void *data) vq = v4l2_m2m_get_dst_vq(inst->fh.m2m_ctx); for (i = 0; i < vq->num_buffers; i++) { - struct vb2_buffer *vb = vq->bufs[i]; - struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + struct vb2_buffer *vb; + struct vb2_v4l2_buffer *vbuf; + + vb = vb2_get_buffer(vq, i); + if (!vb) + continue; if (vb->state == VB2_BUF_STATE_DEQUEUED) continue; + + vbuf = to_vb2_v4l2_buffer(vb); + num = scnprintf(str, sizeof(str), "capture[%2d] state = %10s, %8s\n", i, vb2_stat_name[vb->state], From patchwork Thu Sep 14 13:32:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139593 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp354877vqi; Thu, 14 Sep 2023 06:38:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF77i15acG3qyLshIQLzluK257y9mN60ixteCamJ+eDjyFBGavRobQH4K37bdifeGV74wjh X-Received: by 2002:a17:903:4294:b0:1bb:dc48:644a with SMTP id ju20-20020a170903429400b001bbdc48644amr5293123plb.49.1694698698700; Thu, 14 Sep 2023 06:38:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694698698; cv=none; d=google.com; s=arc-20160816; b=TiCrDF+aZ4ADGvTovFaNCXIwAAuvV70oXNImkpJlEt0pYVrqzdvC7ToVYY1HGud57g PUp7i87/kJIV7ugl15h2zCH2UPdNVf/hbwbiVHZ/kRMyKTVrX6L5eXdmv5N5AsizpzrB nK7uev6sgbBYItrwmm35F/kzG0CSu+qiCEOoWBpjoxIwDwmns5pBaLEKPEmIP0I3gfWx ArkKBMR1PtXBX/QVMj905g67beFwvEfU+Lb05wwS9QX7Xnm2HCwW/S6n2xeEEaivYzSN AonXvhaXPKVEMHx45nTB0t8ZiJWwMF1dKGKo/OByDN6gdS3V9P4oIyxwfVrJjRMY6FBx lN5A== 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=oBL/HMfLMgRXgAfT5u02bM2jjV/dQdfSyWlpf+BZYVc=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=wVhyU0Yo8Nu4x5eS3cNVplJCKdMdNJkRB3QqOhTur+ftGznIVZdf8GUvbNSs4++wz+ RIFosjBZMBftE5pkETD/Kr5IbKDQ5luLsAbi8le2F7OlAcPNELHCiXZScbB7e6GeFNEI OIHml9TxBcTSfkkMHpMqBLPOpEwHNhQvTFfk5Z4Gdw8yM0nr7urB9jJUxP9Mvn38V1tQ B5IT1+O1UlAfd3iddmeAPa+kpK9WeUe3SeaM6NxEHTjTaHXJM26FQY34eGYQBsdyfb2D DgvuvzOgbeSS6xZpidT2tZS6MQ1JLHdI++vwSFbXqDm2rTBEE0utsmQPcR/Po8rhcOve mteA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=fXFkwMr5; 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 s17-20020a17090302d100b001bb0ba81053si1706401plk.50.2023.09.14.06.38.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 06:38:18 -0700 (PDT) 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=fXFkwMr5; 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 3BDFB80A2386; Thu, 14 Sep 2023 06:34:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239061AbjINNdr (ORCPT + 35 others); Thu, 14 Sep 2023 09:33:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239022AbjINNdj (ORCPT ); Thu, 14 Sep 2023 09:33:39 -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 615CB1FC0; Thu, 14 Sep 2023 06:33:35 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 CEC4E6607352; Thu, 14 Sep 2023 14:33:33 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698414; bh=xgQ59ci0u36Sg6Kfk6W/knjQu2QF8jMpnRAVGSPYz3E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fXFkwMr58pl3kD2w2eazXiEVaY7bh84f8fTUEWWcFm6cCqDY+NSc7hG1r0DeF6miz pHYzFvsDbkSYNCm/xiCiJRXzC97mFpmyvwa+L3PQp1WMW4KKJT83cfXK8G6UkMSaby A3nqQvqr0PzdYG6SsQDnF41oZRMoCbi0V915JyNVzNlQnZC5BVNSQlsoC6bQNvlVxA EftWfHSXVZ65cL2KxeGPnd8D/GyqyRKpJX1C/gBZKZ5idmeIclqHJz/7hrnVe51qAv KZvlJl/GS7fEeC6aOAooDYoaXzCNDEgPJFrVufQy43TwseFRQuERNAuut8dukGwG9i qs9CFTrFBSAqg== 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 v7 05/49] media: mediatek: jpeg: Use vb2_get_buffer() instead of directly access to buffers array Date: Thu, 14 Sep 2023 15:32:39 +0200 Message-Id: <20230914133323.198857-6-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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, 14 Sep 2023 06:34:29 -0700 (PDT) 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 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: 1777020382539485048 X-GMAIL-MSGID: 1777020382539485048 Use vb2_get_buffer() instead of directly access to vb2_buffer buffer array. This could allow to change the type bufs[] field of vb2_buffer structure if needed. After each call to vb2_get_buffer() we need to be sure that we get a valid pointer so check the return value of all of them. Signed-off-by: Benjamin Gaignard --- drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c index 7194f88edc0f..73a063b1569b 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c @@ -598,12 +598,11 @@ static int mtk_jpeg_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf) goto end; vq = v4l2_m2m_get_vq(fh->m2m_ctx, buf->type); - if (buf->index >= vq->num_buffers) { - dev_err(ctx->jpeg->dev, "buffer index out of range\n"); + vb = vb2_get_buffer(vq, buf->index); + if (!vb) { + dev_err(ctx->jpeg->dev, "buffer not found\n"); return -EINVAL; } - - vb = vq->bufs[buf->index]; jpeg_src_buf = mtk_jpeg_vb2_to_srcbuf(vb); jpeg_src_buf->bs_size = buf->m.planes[0].bytesused; From patchwork Thu Sep 14 13:32: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: 139715 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp497862vqi; Thu, 14 Sep 2023 10:11:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHlVJhxjXsmGAYbcm++XWU3mZSr0S7rhiUAHJOMtUnTI1uOwYMuzRQJb9iacs/9c8kkgAlz X-Received: by 2002:a17:90b:198:b0:274:8eda:4cbb with SMTP id t24-20020a17090b019800b002748eda4cbbmr513209pjs.45.1694711492144; Thu, 14 Sep 2023 10:11:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694711492; cv=none; d=google.com; s=arc-20160816; b=Iv5QDWRxq7X3PCslxvANTUQDl+HMsAQUQJ0/tjUqUlJ+KOR41RtYb//hzDZRPSnNLG YK9Wr7YSEYqKpD7VodPQWzFILj1x5VU5OzWfTjw048E7/Eu9mPhTQILGYUE0UyT/nYzB P8Gs9Ct6ZvoOuicSj5XBpf5fhmrhTDUfjvY3WzqefLw+HzHVdh9JMGcW+VOBjEM/DJTE dF2BI0iPIARQ77Gnh+OjuZQVWklgeLnxkM07yT/0w1sltSDwdXQTu+Nm3BSCJ/IhRntF 4UktsA+G2UBhyyscwvOnpmmwSFE0VXmkay1HDEz2FDUyHSfMmCkkPcIbGBVXx0BnUky6 8p/Q== 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=rxTytmhcaGqQ6TxTLxs63nIblD5Z31IleixuR2BXvZs=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=mPjCQXv83B7jXTa+lOeBnqwtukvuQ/TpOTjF8j4fvdLzru9HLIYqh1SwDCoqqffrz3 1HyR94T2khFV8sez2MRIA+YRplkGnMyNxzlzCPZoTIrrZp5l3mVuwztLlkxV19CDigBC 47joempq7zydAmzeEOAk5yAfInfKhRgWUgK69fqJTt2fadb/rfaQeSW3UblKGzOifn5n 7xVVqXqio3Wjdil+EpSrxOtA1p6G8pb7cRu0OUzX6d56q/MQ1x+5y2wgjttkuj4+jx9t Pd2ciyk/7MtmlDqiMTbbGR1TdZwrtUkXVc1VjpdhRqLpnABlNQoSH1EGaoT0FqWalz12 lMgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="XN/Q+/iA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id nn7-20020a17090b38c700b00262f798b614si2083665pjb.51.2023.09.14.10.11.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 10:11:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="XN/Q+/iA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id C0EDF817C8BD; Thu, 14 Sep 2023 06:34:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239192AbjINNdv (ORCPT + 35 others); Thu, 14 Sep 2023 09:33:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239048AbjINNdk (ORCPT ); Thu, 14 Sep 2023 09:33:40 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D27BA1BF8; Thu, 14 Sep 2023 06:33:35 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 59CAF6607353; Thu, 14 Sep 2023 14:33:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698414; bh=AbX8Bj09PnboIxD2raU5YodRf5hnpL4JGOUWd895O1I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XN/Q+/iALI6AW7uPf90PA2TdnOCcG33rAlL1rqHy233ECFSiPczeq4v0XzrewUgd6 GqcbSEV0LgKkVae73L03deGPPLq6/msINwJr0vurc3+INW+cjYi+mkj6HYPwR4QqPo lgnB5Q6GJITzVz6M93QwB6TgMVKQDvFWMzDbH2oBo9ZDtvK4cvciLgtBPRyJ2wdd9B bAzQATMxvjgsZB/1kzvGJsUeLGFZpkz/WNQZY2Cdau7i1ueOhD5LDcl0AMatccSEac 5lTUXdDQVmS7mmUAtJFnr5JpawkIFkTkviEZfBAtHdGKxn2piY/FaE9UMW8FOx/X0+ qGS1RTRASbXSQ== 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 v7 06/49] media: mediatek: vdec: Use vb2_get_buffer() instead of directly access to buffers array Date: Thu, 14 Sep 2023 15:32:40 +0200 Message-Id: <20230914133323.198857-7-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (lipwig.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:34:12 -0700 (PDT) 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777033797886948084 X-GMAIL-MSGID: 1777033797886948084 Use vb2_get_buffer() instead of directly access to vb2_buffer buffer array. This could allow to change the type bufs[] field of vb2_buffer structure if needed. After each call to vb2_get_buffer() we need to be sure that we get a valid pointer so check the return value of all of them. Signed-off-by: Benjamin Gaignard --- .../platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c index e393e3e668f8..3d2ae0e1b5b6 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c @@ -1696,7 +1696,7 @@ static int vdec_vp9_slice_setup_core_buffer(struct vdec_vp9_slice_instance *inst /* update internal buffer's width/height */ for (i = 0; i < vq->num_buffers; i++) { - if (vb == vq->bufs[i]) { + if (vb == vb2_get_buffer(vq, i)) { instance->dpb[i].width = w; instance->dpb[i].height = h; break; From patchwork Thu Sep 14 13:32:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139886 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp676337vqi; Thu, 14 Sep 2023 16:02:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGl/7lbhXesSNketW3NVXBG5UXJXM0dxhXD8T+jL5dnTM9pQfzrHRdB65KjFw6vTJ1N7/Pq X-Received: by 2002:a05:6a21:7983:b0:14a:7701:56df with SMTP id bh3-20020a056a21798300b0014a770156dfmr163881pzc.21.1694732572982; Thu, 14 Sep 2023 16:02:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694732572; cv=none; d=google.com; s=arc-20160816; b=ENzGSbUUUFI0n5JgjITh2IhGDbCKAp+C/n2Ph2eE895NkkqN1aws9fAqYdi1fP5gcq WXFxmvDXWU/GCBRABJXfT4bKWz+qeIz0Y+4SuAIae1aINAnxMYkOhuGXNAg1qcjVG08h 6kd1vvBkjFG5N4c1ot/Xcqp0l9G8NbPMNWJBV7616RxLSqKc+j+KNGsvQmzonvMaP97D 4tAGTVZ2G5hTgvUAM/u6NmWlLU+r42Umjq+i5/oBRhym+z+KvlrmCwfS14hrUBa0ytrp Fyq3wRoBhog+4TyBoHZbFMcmkDZfNWJwup3uTSZO13GJKtlE21iY/6tyVQd6a9uihpU+ gtcw== 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=GhnSqOiSmfX2a0e2tL7vBTe/pZHQ5iui/RY1FADwjgE=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=GEBFi7EYa2beukTHqXALnKFmw0jEKKUCTKQuke71FwopzYCMpcGNMTwRhZ6J2J1qhf 6z+anEc5Or2qRdr+9gBTHQ5clOaROVqXYIXbC5l7TjRBkElzGluK0VmcW5MXPtiTkO8K 4Xlmlq5Vxg9YTW1/o/gNyPpINOQTwLdtlTTmBE9PgxbeIwCbI2cuIX5NgQuSQo/7VhOX 57aJLydQne+IZfDS3AySe21SO/9QP+RW0FUXogslSncC6XTaJdk9q5VVgBnG7rFf7kUK yrqk1tnBrNyidQLZSCIVKzWSOdG3VxRnDrvAAAPqxVJiPUrAiphpPx6hpahD42sqzdsk DaZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=YBKyrFSx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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. [23.128.96.34]) by mx.google.com with ESMTPS id dc5-20020a056a0035c500b0069023afd0d1si2241605pfb.329.2023.09.14.16.02.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 16:02:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=YBKyrFSx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 D140883E8FD9; Thu, 14 Sep 2023 06:34:04 -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 S239208AbjINNdx (ORCPT + 35 others); Thu, 14 Sep 2023 09:33:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239052AbjINNdk (ORCPT ); Thu, 14 Sep 2023 09:33:40 -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 620061FC0; Thu, 14 Sep 2023 06:33:36 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 D61D56607355; Thu, 14 Sep 2023 14:33:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698415; bh=iZqd1w+9hJa+OQD7BuHGMyLxr+up+MZt6k1cr275d/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YBKyrFSx5bL9zrE3+6VE9UoNa6a/2EJcx9kGRCOy32Z7Tk5r/DL0ScHoaO+15m5om N3rNbLa3LJTej/+SCRGhoNXiyiU1YiLJslsY4DKCRXNkTxrLLplPbTqmchMGtMDRxR q6ZVBm+UXjnzSvx1PsV5VMB9+xq0i012Mxl3b9jb39a2e0KQ+p+OrJ7Q9uCl8zBFJW 9alTy9FMYas1CjZb3DLQJ06R+SLjPCU12THGyJl5MqIYAfXmnkO+8u3Hj2acXQzbHV fco8OlfKWtLh+L+nT+ohqLGOQQfdwRAd0HxvgnREI6AwPfGBVum0a8mvtL2WH6UG/1 PlZooX4ru6Xvg== 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 v7 07/49] media: sti: hva: Use vb2_get_buffer() instead of directly access to buffers array Date: Thu, 14 Sep 2023 15:32:41 +0200 Message-Id: <20230914133323.198857-8-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (howler.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:34:04 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777055902594478447 X-GMAIL-MSGID: 1777055902594478447 Use vb2_get_buffer() instead of directly access to vb2_buffer buffer array. This could allow to change the type bufs[] field of vb2_buffer structure if needed. After each call to vb2_get_buffer() we need to be sure that we get a valid pointer so check the return value of all of them. Signed-off-by: Benjamin Gaignard --- drivers/media/platform/st/sti/hva/hva-v4l2.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/media/platform/st/sti/hva/hva-v4l2.c b/drivers/media/platform/st/sti/hva/hva-v4l2.c index 3a848ca32a0e..326be09bdb55 100644 --- a/drivers/media/platform/st/sti/hva/hva-v4l2.c +++ b/drivers/media/platform/st/sti/hva/hva-v4l2.c @@ -577,6 +577,10 @@ static int hva_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf) } vb2_buf = vb2_get_buffer(vq, buf->index); + if (!vb2_buf) { + dev_dbg(dev, "%s buffer index %d not found\n", ctx->name, buf->index); + return -EINVAL; + } stream = to_hva_stream(to_vb2_v4l2_buffer(vb2_buf)); stream->bytesused = buf->bytesused; } From patchwork Thu Sep 14 13:32:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139929 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp706307vqi; Thu, 14 Sep 2023 17:11:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFpFgdgZeRe+01HRNc0/30MzGEdTgNlJzC2JF+kZTI/AD9yvz6PrLiLyTB9tX82mOxTC8i0 X-Received: by 2002:a17:902:e841:b0:1c1:f5a6:bdfa with SMTP id t1-20020a170902e84100b001c1f5a6bdfamr182316plg.7.1694736716040; Thu, 14 Sep 2023 17:11:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694736716; cv=none; d=google.com; s=arc-20160816; b=ww4XhbWWQtrxsnV6f/DezeTdnIQk7QtcR9ywpfh8+EZtYsPaTTYoMJT/kcfTYnbRj/ +S1q4z/mAgM0qrgQM/r9SebEwTgJOvUkW0sEQkfHUj6hnWeefK2EV5d6WIBfB0u2CgEu iRot6d95RkW3XO/E4rUo4TNNXtQQCrZx5MjPmjQlDjxcVWZWmglUA07eSM5582r72CD9 +zFq9avxE3zoUbE8DJok6w1aP0GOBDeymgQgNQRYV948kxFfRcV1M6RtJaUTl2nunhKB r/o9k7RcUbuATtBZgLZ45ESPTBMRacPydcY+g9Bu7J8j2JkNXQYKMMGNjzt7WqmRCEML teDQ== 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=U2gW/Q+RNn3ntItDX+hvmZgS358f/BD2tGGafv55qEw=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=j3vXSvEUfg8DcWtxo1Edre1+1wRdU08D2XczFjp7B2BU5DfmkGfoCml7e017B6vnN4 BJhPkSOcqtEVnwEjiOZpRUtIjFP/3UXs7pD6X+F63kU4I0ujDwBW3fBjWTOlDjtjdBnO eoSYX0JRvyqLeg+Gbju0HcTTln/N43JtYubQlBafv1Hi9Gi0yIyYYc2cAQ4GKaW2hhX9 ZjDJKQcJKiAdUK3Nr1vkbF5LFGEks+w75lt5HRfoIcwNGXLnhewBAb7L7P1NbfN3UQef BCKFSXHYfoxzpABPvqF4ET1rIzRb/0Ik1HAd8e6ljIH+cfC+PDRaP1hYSfZN10l39PcP 2y4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="SDSzY/Tw"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id d18-20020a170903231200b001b9e9b21249si2656455plh.649.2023.09.14.17.11.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 17:11:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="SDSzY/Tw"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 9404181A6E66; Thu, 14 Sep 2023 06:34:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239257AbjINNd5 (ORCPT + 35 others); Thu, 14 Sep 2023 09:33:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239065AbjINNdk (ORCPT ); Thu, 14 Sep 2023 09:33:40 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4DB11FD5; Thu, 14 Sep 2023 06:33:36 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 5D2FE6607358; Thu, 14 Sep 2023 14:33:35 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698415; bh=Osy0YWOEVUvzSOYoJm+JBXSigMNkmpw77qpRTwkivks=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SDSzY/TwRn4hjbZQQ8bWA6bcK8mXL3C87PQzzQUb/JwUM/y4+aAzMW3YoEWJXVOcl Aq6a+39QRO1ModNJw7jOTRL+eehodGl2VjPUWKOn95HyaNN3G5208QS6wNPJI2BCKO geJrLl58MRUIb2HfT+U9XnfeOcZxXqiZRhtZ+yehb9+i+XQDd8AXxEIlmVR11YheSP 7Vf9MZY+YbFww48huT3wDz7xgFSCS9KH07RlSGtwDkkz1ygDqEsVdmojH+pI+jg7Tw A+T4eAzI1Ccc5Kru15mlAo0XK2w4dnK1IK1UlMNg6Z3Sjv+o3GbzO78396TbxNmhoI YrM4knVZIB21g== 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 v7 08/49] media: visl: Use vb2_get_buffer() instead of directly access to buffers array Date: Thu, 14 Sep 2023 15:32:42 +0200 Message-Id: <20230914133323.198857-9-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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, 14 Sep 2023 06:34:06 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777060246773157233 X-GMAIL-MSGID: 1777060246773157233 Use vb2_get_buffer() instead of directly access to vb2_buffer buffer array. This could allow to change the type bufs[] field of vb2_buffer structure if needed. After each call to vb2_get_buffer() we need to be sure that we get a valid pointer so check the return value of all of them. Signed-off-by: Benjamin Gaignard --- drivers/media/test-drivers/visl/visl-dec.c | 28 ++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/drivers/media/test-drivers/visl/visl-dec.c b/drivers/media/test-drivers/visl/visl-dec.c index 318d675e5668..ba20ea998d19 100644 --- a/drivers/media/test-drivers/visl/visl-dec.c +++ b/drivers/media/test-drivers/visl/visl-dec.c @@ -290,13 +290,20 @@ static void visl_tpg_fill(struct visl_ctx *ctx, struct visl_run *run) for (i = 0; i < out_q->num_buffers; i++) { char entry[] = "index: %u, state: %s, request_fd: %d, "; u32 old_len = len; - char *q_status = visl_get_vb2_state(out_q->bufs[i]->state); + struct vb2_buffer *vb2; + char *q_status; + + vb2 = vb2_get_buffer(out_q, i); + if (!vb2) + continue; + + q_status = visl_get_vb2_state(vb2->state); len += scnprintf(&buf[len], TPG_STR_BUF_SZ - len, entry, i, q_status, - to_vb2_v4l2_buffer(out_q->bufs[i])->request_fd); + to_vb2_v4l2_buffer(vb2)->request_fd); - len += visl_fill_bytesused(to_vb2_v4l2_buffer(out_q->bufs[i]), + len += visl_fill_bytesused(to_vb2_v4l2_buffer(vb2), &buf[len], TPG_STR_BUF_SZ - len); @@ -342,13 +349,20 @@ static void visl_tpg_fill(struct visl_ctx *ctx, struct visl_run *run) len = 0; for (i = 0; i < cap_q->num_buffers; i++) { u32 old_len = len; - char *q_status = visl_get_vb2_state(cap_q->bufs[i]->state); + struct vb2_buffer *vb2; + char *q_status; + + vb2 = vb2_get_buffer(cap_q, i); + if (!vb2) + continue; + + q_status = visl_get_vb2_state(vb2->state); len += scnprintf(&buf[len], TPG_STR_BUF_SZ - len, "index: %u, status: %s, timestamp: %llu, is_held: %d", - cap_q->bufs[i]->index, q_status, - cap_q->bufs[i]->timestamp, - to_vb2_v4l2_buffer(cap_q->bufs[i])->is_held); + vb2->index, q_status, + vb2->timestamp, + to_vb2_v4l2_buffer(vb2)->is_held); tpg_gen_text(&ctx->tpg, basep, line++ * line_height, 16, &buf[old_len]); frame_dprintk(ctx->dev, run->dst->sequence, "%s", &buf[old_len]); From patchwork Thu Sep 14 13:32:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139754 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp521013vqi; Thu, 14 Sep 2023 10:52:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEv/PN5rQajDLomOj59vrtHLzS6YtVlmpjYHt3zW+AETC9fRmbGgWapu+cUWnlefgYhofkV X-Received: by 2002:a17:902:968f:b0:1bb:c64f:9a5e with SMTP id n15-20020a170902968f00b001bbc64f9a5emr5932094plp.5.1694713936829; Thu, 14 Sep 2023 10:52:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694713936; cv=none; d=google.com; s=arc-20160816; b=TJUpDoP2hDyTeHRDLxrTVFQc4fX1L+OYzwdDeD15HH2GvfsNfPNYWCRwlkYQ0tkLzs K/Vffir+EI8LMzmE6M+aQsDJDzH/1sXCYXhdwoCnoH3WjqdcW5FGii9BWGV5/y/ALc00 2EFsYc/wzMHgAcMyIumCWmlOo9eIqxRZgROIVWIw6NTt/BE9sdi2aOTNDmqMBwMuT5Kq 7xy1iZiqdmUIg0p57egWFeavpwym1rX4xwCZv9ezn4BuX3dUv/HzLi4UESKjFesr3jPL P3rCCyVy25LSYlffUZM94xM2SVsvBxaj5xgVyvbTDfE+05olZcy8tdqBwK0yc/Fdz5GS LfPg== 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=etuGB0ig+YfwOMH5DMoCx2e3o/bVGJDuPKqvOV4n+KA=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=bZhRiogShNZbPgSpd3IL1AOK+/BU1jnKZLhOPGeawHHNroNBWVwWdoBI9A5QgxqmYj ol07cK+7bk3p7E35cq73/g3gwv2dbXvz9KHr6o+PlRsCU2sbNx9cZYBljVIgEMomVJvg ur19K7CoUY98zrxkpvixukGEnK6ARvIe2h7w+XgUJ91rI8yA2UFbZnXOaS/uXqfEK2OY hOJw8l04aKoKbETVF/w3ZDSoKoM50KtJ3W+v6Wx1b47r29GLTh0usPPlyzmeZUREhPpk fAvb5TYmpfngp32tOYAg7k3L7XswGvNtUVAZC1wydDTAIy/wZLB5hV5eJIe6Lfrzx8Ul os/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="IhAr/pB+"; 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 kf16-20020a17090305d000b001bf4ea978c8si1891704plb.324.2023.09.14.10.52.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 10:52:16 -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="IhAr/pB+"; 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 EC1C18241E3B; Thu, 14 Sep 2023 06:34:37 -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 S239289AbjINNeA (ORCPT + 35 others); Thu, 14 Sep 2023 09:34:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239071AbjINNdl (ORCPT ); Thu, 14 Sep 2023 09:33:41 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 585C51FD8; Thu, 14 Sep 2023 06:33:37 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 D70C6660735D; Thu, 14 Sep 2023 14:33:35 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698416; bh=X/zFB6sk39TwCWXEBFU3kr1spD6NOhpHJy3eiUrcvDA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IhAr/pB+7jbK98HaC+CDXBPJxwbrA0EolyLkR2rr5/dJT27A0JoXzfwYFPiOShKHt 8HCev71j27Y1iYDhKVPj+CQloPTiEuUjz1v4iwwqXUwdngyRpcuZMBOk/nLqQLOb9N fVLnOf+Yx+D2DhJWroHcWEz8HDJbiMyjaIf0/sLaQB8liN4SPnoIdRF65dP/8Gupfv oXsJyZgLktFfPZZ/eNruXdL8vOSjLdS1XhnShSbcLfqv1Boli2/LvJ4MQTbqGDD0XS ebcWjbkSBmXSy/HXcwWu8If/ImAn9g1XyyhIkfwyUTFv6dPP896hNr+fKpjoVFsFeo r04qqUCp/56Mw== 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 v7 09/49] media: atomisp: Use vb2_get_buffer() instead of directly access to buffers array Date: Thu, 14 Sep 2023 15:32:43 +0200 Message-Id: <20230914133323.198857-10-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (morse.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:34:38 -0700 (PDT) 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777036360742984580 X-GMAIL-MSGID: 1777036360742984580 Use vb2_get_buffer() instead of directly access to vb2_buffer buffer array. This could allow to change the type bufs[] field of vb2_buffer structure if needed. After each call to vb2_get_buffer() we need to be sure that we get a valid pointer so check the return value of all of them. Signed-off-by: Benjamin Gaignard --- drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c index d2174156573a..4b65c69fa60d 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -1061,7 +1061,7 @@ static int atomisp_dqbuf_wrapper(struct file *file, void *fh, struct v4l2_buffer if (ret) return ret; - vb = pipe->vb_queue.bufs[buf->index]; + vb = vb2_get_buffer(&pipe->vb_queue, buf->index); frame = vb_to_frame(vb); buf->reserved = asd->frame_status[buf->index]; From patchwork Thu Sep 14 13:32:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 140078 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp775009vqi; Thu, 14 Sep 2023 20:19:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFBmJUKIKHLF95kTjnK1R4msaR3VNG09fi3yb1KpmVlc+m7H8dMiqxcQnJkVfxAKGU5uJ99 X-Received: by 2002:a05:6a20:4410:b0:132:79da:385a with SMTP id ce16-20020a056a20441000b0013279da385amr704439pzb.23.1694747978182; Thu, 14 Sep 2023 20:19:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694747978; cv=none; d=google.com; s=arc-20160816; b=RUztleG19Nqjbh/9nN5TMEsiHqrzyzAOPEr8J8c33MmOUZx+9SvyJ1w+kUYxQmBTuM NDYOPVEXCfXATALUL4G6JxM8Cp4M+fFuq3nSSx/jgqmjGuYcJdgkq41dBmOgiFyOWad6 WXoEs/Q1UXWyhjLu3unFVMG55KUaPQ+qSFroHoKNnue8nYziCMctaUVcPPyMpQV4iQFT dkj5+Sn+xfCD5Pc8tA4TAF5uGjdo7o7ff2fUbxXVYPzgNCQBveKxR4Hi7WNkgd4024bB bLg0K4eiOuS8g/QE+QlhUDV3GCmcb9dL64vaB772Ig/gJBxxRF2FyOIGdPEVGB7icvdL dYwA== 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=aDL5gETzUiP0VzZZCijO3U9Zzi9a1aLBhnH2wBWpEGU=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=XMVpXZEYLlV+9Xlps0bicWIy2QiA+AVLjb2gLLMamjlciDV7w0DBdxjw5GoKPn6W0r YeP1DKtY3n8xjt+49+G9h2DuFyCrfqgsQbGhJdXaX91es0yVL8hrKShL7m6EDGPQVWjq tjTcx0mroyuLLhvf7d0ybsjky1ZzZwHCUEmzIqB/SQRMls7rjisu2Hi4DIkG1TaK6yuO 023kln8gXwjFoAXne7dFyxO3zrsoSoDlDmVVu/XUP48Xw+CJ8RDJBIwqr/+vo/TlZPsD 1rRziv6JHk+/0kqY5F6HsI+OhixeeBsDpCknjcYde15CxdLecPkUDQO8I27Cmpc/CwVG mPnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=DVXFgKrI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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. [23.128.96.34]) by mx.google.com with ESMTPS id kn5-20020a170903078500b001bd9d6e8319si2513519plb.145.2023.09.14.20.19.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 20:19:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=DVXFgKrI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 3549E834A9C3; Thu, 14 Sep 2023 06:34:16 -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 S239283AbjINNeG (ORCPT + 35 others); Thu, 14 Sep 2023 09:34:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239112AbjINNdp (ORCPT ); Thu, 14 Sep 2023 09:33:45 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D586F1FDE; Thu, 14 Sep 2023 06:33:37 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 5CA61660735F; Thu, 14 Sep 2023 14:33:36 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698416; bh=EMKVWITArl2PHuWHDFd/NcTii9pr6T7GjKNa1Tuop1w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DVXFgKrI+9K9uGdzuWfxGGsdYSnRQ1qbifrJfbEj3lrerimhXlTOVIKOuytIYx9PY AGH4nx1RPdSG0xAoFtGwFp/vFwSe8exbn71U3AjzndwVDCrzX5giNylwLQ4RMjTW5T PyyKs0MeCmERkiq41Lq7GEA3lT39e7DuLctysxcv0dR6PprXIdeszX71vJKACjcI+Q ww5pHWo3brb6QfsFIYrdeRUDjBn+DQE/Kyj425uIVxyYm8Pu84BlmvpcBGeudvQS6u nVlkxaG7dp3/wfTZMSuyqyJlwH1tBwJIwFWfQIAQa+1UkmCKWmzmJF6gCIIugr8YuP zQuwJMAEIwnbA== 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 v7 10/49] media: dvb-core: Use vb2_get_buffer() instead of directly access to buffers array Date: Thu, 14 Sep 2023 15:32:44 +0200 Message-Id: <20230914133323.198857-11-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (howler.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:34:16 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777072056011251732 X-GMAIL-MSGID: 1777072056011251732 Use vb2_get_buffer() instead of directly access to vb2_buffer buffer array. This could allow to change the type bufs[] field of vb2_buffer structure if needed. After each call to vb2_get_buffer() we need to be sure that we get a valid pointer so check the return value of all of them. Signed-off-by: Benjamin Gaignard --- drivers/media/dvb-core/dvb_vb2.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/media/dvb-core/dvb_vb2.c b/drivers/media/dvb-core/dvb_vb2.c index b322ef179f05..3a966fdf814c 100644 --- a/drivers/media/dvb-core/dvb_vb2.c +++ b/drivers/media/dvb-core/dvb_vb2.c @@ -355,12 +355,13 @@ int dvb_vb2_reqbufs(struct dvb_vb2_ctx *ctx, struct dmx_requestbuffers *req) int dvb_vb2_querybuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b) { struct vb2_queue *q = &ctx->vb_q; + struct vb2_buffer *vb2 = vb2_get_buffer(q, b->index); - if (b->index >= q->num_buffers) { - dprintk(1, "[%s] buffer index out of range\n", ctx->name); + if (!vb2) { + dprintk(1, "[%s] invalid buffer index\n", ctx->name); return -EINVAL; } - vb2_core_querybuf(&ctx->vb_q, q->bufs[b->index], b); + vb2_core_querybuf(&ctx->vb_q, vb2, b); dprintk(3, "[%s] index=%d\n", ctx->name, b->index); return 0; } @@ -385,13 +386,14 @@ int dvb_vb2_expbuf(struct dvb_vb2_ctx *ctx, struct dmx_exportbuffer *exp) int dvb_vb2_qbuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b) { struct vb2_queue *q = &ctx->vb_q; + struct vb2_buffer *vb2 = vb2_get_buffer(q, b->index); int ret; - if (b->index >= q->num_buffers) { - dprintk(1, "[%s] buffer index out of range\n", ctx->name); + if (!vb2) { + dprintk(1, "[%s] invalid buffer index\n", ctx->name); return -EINVAL; } - ret = vb2_core_qbuf(&ctx->vb_q, q->bufs[b->index], b, NULL); + ret = vb2_core_qbuf(&ctx->vb_q, vb2, b, NULL); if (ret) { dprintk(1, "[%s] index=%d errno=%d\n", ctx->name, b->index, ret); From patchwork Thu Sep 14 13:32:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139843 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp630357vqi; Thu, 14 Sep 2023 14:15:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG1FPuOpjqjo7fTI18HCut58MZwBKR7n4IKIzcaGFdn3+4cg09f3tLD5QdHwPJj80GQfyK8 X-Received: by 2002:a05:6358:6f86:b0:134:c650:cc0a with SMTP id s6-20020a0563586f8600b00134c650cc0amr5795902rwn.15.1694726154648; Thu, 14 Sep 2023 14:15:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694726154; cv=none; d=google.com; s=arc-20160816; b=HS/IvmKHwflJexEW4fNs2Vpjha6mPUmPe2VizWCuayIQvZHcwCka7Nn6ZJ9dA5BLZI muMWMx3qr+MRNaRAv5VMtjRlvZ7w1A+bkKDF5dvYTIDYcTQB7va2GeiXoDS/Fnvt6CyV LAdK52epZJ6H8spBZx+tRQIdMsVasUvfgqwseyzYkJvlu9tLe5wZG2zdqFLQcx0q2e7L vrz0pchU1ySR5wyjhoVW+hhcpnKlnH/1vd6xMS54wy3LIW91pHSkR9Kqn0mpJSUQ+D81 qmiXUs9CojBqRxWv+qLbqvgrqnlvV0hmhsmCzkhSBshaqIhHL17ZYbV+I3jrti+iGt0J o86g== 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=Fvp4TI/W6LIp9XN7LxOQRyXTJn3JWHN1YeYOLbR4F9w=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=NDxSB/b7c7U6ySr4RcVGDUnPkkjrrQJ+yQ4fig/iBZno7AnT3YJlF7dRIdiOo9O2IP ifDPNEoMPr+A2o4OQiTsrslLl7WQlOo8eoTCPOOPHa6AI68S2T/x3TL4tJKmE5U7gslF aBmips9dMSrzoNAMMby8MArFtMc0w96G46Cm56dAqhHVXVKz45siUsfo2JKfBwAv7y5O ztuY+c890pHMZHhuYyF0tyx1XT/9SWLJxrbGafLKSj1tp2LRBWO+Peid3r1Dh++4GiSG au9A9nFvoJF0JJFQ9s+0UYBr+gmo8R7tyu3qR2TYp3F94pE3CWXdrmVb5khJ3hpNGjXb TGxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Pc3Dcz7i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id x64-20020a636343000000b00574057d7c0esi2116667pgb.511.2023.09.14.14.15.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 14:15:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Pc3Dcz7i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id C3BE482600AC; Thu, 14 Sep 2023 06:34:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239126AbjINNeD (ORCPT + 35 others); Thu, 14 Sep 2023 09:34:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239130AbjINNdr (ORCPT ); Thu, 14 Sep 2023 09:33: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 655751FDF; Thu, 14 Sep 2023 06:33:38 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 D672F6607364; Thu, 14 Sep 2023 14:33:36 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698417; bh=FEqvkdnoWV11uHayO+KAKtNRmHqCO04FEKfLYvlk9HQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pc3Dcz7iv8klkEA/aLlwaMBBW+vhs1BNqGqg1u0pveAlNiXmI7Vi7u1K+JtGXBlk/ nn/NrnhYjfwNI+pqkbeeAy8rNyqQTwQLDNviz1wlkwZXUU1joawcBoDPWYt1mAoj3j 1fyE0uiF/G0z0hsGUim0/EjO8wNaZacQjQTMYl7WXWOK0T7+3NGB7kvG0wKRxGrLiZ DnVBc2tGt+SO9hp3mNE6gTq/8/Goopzxp5exkC7YaUYFO925KHRCZ/p9yzIHzC6YqD 4GfFTm9nSOLERbMn7wc/9yTgcC9ZAMl13kiwcvMGflQwAQg6V98/hfDqaYT+kOWBo3 ws2ueKNLjSQzA== 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 v7 11/49] media: videobuf2: Access vb2_queue bufs array through helper functions Date: Thu, 14 Sep 2023 15:32:45 +0200 Message-Id: <20230914133323.198857-12-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (lipwig.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:34:45 -0700 (PDT) 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777049171997330599 X-GMAIL-MSGID: 1777049171997330599 This patch adds 2 helpers functions to add and remove vb2 buffers from a queue. With these 2 and vb2_get_buffer(), bufs field of struct vb2_queue becomes like a private member of the structure. After each call to vb2_get_buffer() we need to be sure that we get a valid pointer so check the return value of all of them. Signed-off-by: Benjamin Gaignard --- .../media/common/videobuf2/videobuf2-core.c | 177 ++++++++++++++---- .../media/common/videobuf2/videobuf2-v4l2.c | 49 +++-- 2 files changed, 172 insertions(+), 54 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 5f31b99e3f03..afe76577acc1 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -403,6 +403,37 @@ static void init_buffer_cache_hints(struct vb2_queue *q, struct vb2_buffer *vb) vb->skip_cache_sync_on_finish = 1; } +/** + * vb2_queue_add_buffer() - add a buffer to a queue + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @vb: pointer to &struct vb2_buffer to be added to the queue. + * @index: index where add vb2_buffer in the queue + */ +static bool vb2_queue_add_buffer(struct vb2_queue *q, struct vb2_buffer *vb, unsigned int index) +{ + if (index < VB2_MAX_FRAME && !q->bufs[index]) { + q->bufs[index] = vb; + vb->index = index; + vb->vb2_queue = q; + return true; + } + + return false; +} + +/** + * vb2_queue_remove_buffer() - remove a buffer from a queue + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @vb: pointer to &struct vb2_buffer to be removed from the queue. + */ +static void vb2_queue_remove_buffer(struct vb2_queue *q, struct vb2_buffer *vb) +{ + if (vb->index < VB2_MAX_FRAME) { + q->bufs[vb->index] = NULL; + vb->vb2_queue = NULL; + } +} + /* * __vb2_queue_alloc() - allocate vb2 buffer structures and (for MMAP type) * video buffer memory for all buffers/planes on the queue and initializes the @@ -431,9 +462,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory, } vb->state = VB2_BUF_STATE_DEQUEUED; - vb->vb2_queue = q; vb->num_planes = num_planes; - vb->index = q->num_buffers + buffer; vb->type = q->type; vb->memory = memory; init_buffer_cache_hints(q, vb); @@ -443,7 +472,11 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory, } call_void_bufop(q, init_buffer, vb); - q->bufs[vb->index] = vb; + if (!vb2_queue_add_buffer(q, vb, q->num_buffers + buffer)) { + dprintk(q, 1, "failed adding buffer %d to queue\n", buffer); + kfree(vb); + break; + } /* Allocate video buffer memory for the MMAP type */ if (memory == VB2_MEMORY_MMAP) { @@ -451,7 +484,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory, if (ret) { dprintk(q, 1, "failed allocating memory for buffer %d\n", buffer); - q->bufs[vb->index] = NULL; + vb2_queue_remove_buffer(q, vb); kfree(vb); break; } @@ -466,7 +499,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory, dprintk(q, 1, "buffer %d %p initialization failed\n", buffer, vb); __vb2_buf_mem_free(vb); - q->bufs[vb->index] = NULL; + vb2_queue_remove_buffer(q, vb); kfree(vb); break; } @@ -489,7 +522,7 @@ static void __vb2_free_mem(struct vb2_queue *q, unsigned int buffers) for (buffer = q->num_buffers - buffers; buffer < q->num_buffers; ++buffer) { - vb = q->bufs[buffer]; + vb = vb2_get_buffer(q, buffer); if (!vb) continue; @@ -517,7 +550,7 @@ static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) /* Call driver-provided cleanup function for each buffer, if provided */ for (buffer = q->num_buffers - buffers; buffer < q->num_buffers; ++buffer) { - struct vb2_buffer *vb = q->bufs[buffer]; + struct vb2_buffer *vb = vb2_get_buffer(q, buffer); if (vb && vb->planes[0].mem_priv) call_void_vb_qop(vb, buf_cleanup, vb); @@ -558,15 +591,20 @@ static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) q->cnt_unprepare_streaming = 0; } for (buffer = 0; buffer < q->num_buffers; ++buffer) { - struct vb2_buffer *vb = q->bufs[buffer]; - bool unbalanced = vb->cnt_mem_alloc != vb->cnt_mem_put || - vb->cnt_mem_prepare != vb->cnt_mem_finish || - vb->cnt_mem_get_userptr != vb->cnt_mem_put_userptr || - vb->cnt_mem_attach_dmabuf != vb->cnt_mem_detach_dmabuf || - vb->cnt_mem_map_dmabuf != vb->cnt_mem_unmap_dmabuf || - vb->cnt_buf_queue != vb->cnt_buf_done || - vb->cnt_buf_prepare != vb->cnt_buf_finish || - vb->cnt_buf_init != vb->cnt_buf_cleanup; + struct vb2_buffer *vb = vb2_get_buffer(q, buffer); + bool unbalanced; + + if (!vb) + continue; + + unbalanced = vb->cnt_mem_alloc != vb->cnt_mem_put || + vb->cnt_mem_prepare != vb->cnt_mem_finish || + vb->cnt_mem_get_userptr != vb->cnt_mem_put_userptr || + vb->cnt_mem_attach_dmabuf != vb->cnt_mem_detach_dmabuf || + vb->cnt_mem_map_dmabuf != vb->cnt_mem_unmap_dmabuf || + vb->cnt_buf_queue != vb->cnt_buf_done || + vb->cnt_buf_prepare != vb->cnt_buf_finish || + vb->cnt_buf_init != vb->cnt_buf_cleanup; if (unbalanced) { pr_info("unbalanced counters for queue %p:, buffer %d\n", @@ -606,8 +644,13 @@ static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) /* Free vb2 buffers */ for (buffer = q->num_buffers - buffers; buffer < q->num_buffers; ++buffer) { - kfree(q->bufs[buffer]); - q->bufs[buffer] = NULL; + struct vb2_buffer *vb = vb2_get_buffer(q, buffer); + + if (!vb) + continue; + + vb2_queue_remove_buffer(q, vb); + kfree(vb); } q->num_buffers -= buffers; @@ -643,7 +686,12 @@ static bool __buffers_in_use(struct vb2_queue *q) { unsigned int buffer; for (buffer = 0; buffer < q->num_buffers; ++buffer) { - if (vb2_buffer_in_use(q, q->bufs[buffer])) + struct vb2_buffer *vb = vb2_get_buffer(q, buffer); + + if (!vb) + continue; + + if (vb2_buffer_in_use(q, vb)) return true; } return false; @@ -1628,7 +1676,11 @@ static int vb2_start_streaming(struct vb2_queue *q) * correctly return them to vb2. */ for (i = 0; i < q->num_buffers; ++i) { - vb = q->bufs[i]; + vb = vb2_get_buffer(q, i); + + if (!vb) + continue; + if (vb->state == VB2_BUF_STATE_ACTIVE) vb2_buffer_done(vb, VB2_BUF_STATE_QUEUED); } @@ -2029,12 +2081,18 @@ static void __vb2_queue_cancel(struct vb2_queue *q) * to vb2 in stop_streaming(). */ if (WARN_ON(atomic_read(&q->owned_by_drv_count))) { - for (i = 0; i < q->num_buffers; ++i) - if (q->bufs[i]->state == VB2_BUF_STATE_ACTIVE) { + for (i = 0; i < q->num_buffers; ++i) { + struct vb2_buffer *vb = vb2_get_buffer(q, i); + + if (!vb) + continue; + + if (vb->state == VB2_BUF_STATE_ACTIVE) { pr_warn("driver bug: stop_streaming operation is leaving buf %p in active state\n", - q->bufs[i]); - vb2_buffer_done(q->bufs[i], VB2_BUF_STATE_ERROR); + vb); + vb2_buffer_done(vb, VB2_BUF_STATE_ERROR); } + } /* Must be zero now */ WARN_ON(atomic_read(&q->owned_by_drv_count)); } @@ -2068,9 +2126,14 @@ static void __vb2_queue_cancel(struct vb2_queue *q) * be changed, so we can't move the buf_finish() to __vb2_dqbuf(). */ for (i = 0; i < q->num_buffers; ++i) { - struct vb2_buffer *vb = q->bufs[i]; - struct media_request *req = vb->req_obj.req; + struct vb2_buffer *vb; + struct media_request *req; + + vb = vb2_get_buffer(q, i); + if (!vb) + continue; + req = vb->req_obj.req; /* * If a request is associated with this buffer, then * call buf_request_cancel() to give the driver to complete() @@ -2220,7 +2283,10 @@ static int __find_plane_by_offset(struct vb2_queue *q, unsigned long off, buffer = (off >> PLANE_INDEX_SHIFT) & BUFFER_INDEX_MASK; plane = (off >> PAGE_SHIFT) & PLANE_INDEX_MASK; - vb = q->bufs[buffer]; + vb = vb2_get_buffer(q, buffer); + if (!vb) + return -EINVAL; + if (vb->planes[plane].m.offset == off) { *_buffer = buffer; *_plane = plane; @@ -2332,7 +2398,13 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma) if (ret) goto unlock; - vb = q->bufs[buffer]; + vb = vb2_get_buffer(q, buffer); + + if (!vb) { + dprintk(q, 1, "can't find the requested buffer\n"); + ret = -EINVAL; + goto unlock; + } /* * MMAP requires page_aligned buffers. @@ -2389,7 +2461,12 @@ unsigned long vb2_get_unmapped_area(struct vb2_queue *q, if (ret) goto unlock; - vb = q->bufs[buffer]; + vb = vb2_get_buffer(q, buffer); + if (!vb) { + dprintk(q, 1, "can't find the requested buffer\n"); + ret = -EINVAL; + goto unlock; + } vaddr = vb2_plane_vaddr(vb, plane); mutex_unlock(&q->mmap_lock); @@ -2618,6 +2695,7 @@ struct vb2_fileio_data { static int __vb2_init_fileio(struct vb2_queue *q, int read) { struct vb2_fileio_data *fileio; + struct vb2_buffer *vb; int i, ret; unsigned int count = 0; @@ -2668,11 +2746,18 @@ static int __vb2_init_fileio(struct vb2_queue *q, int read) if (ret) goto err_kfree; + /* + * Userspace can never add or delete buffers later, so there + * will never be holes. It is safe to assume that vb2_get_buffer(q, 0) + * will always return a valid vb pointer + */ + vb = vb2_get_buffer(q, 0); + /* * Check if plane_count is correct * (multiplane buffers are not supported). */ - if (q->bufs[0]->num_planes != 1) { + if (vb->num_planes != 1) { ret = -EBUSY; goto err_reqbufs; } @@ -2681,12 +2766,17 @@ static int __vb2_init_fileio(struct vb2_queue *q, int read) * Get kernel address of each buffer. */ for (i = 0; i < q->num_buffers; i++) { - fileio->bufs[i].vaddr = vb2_plane_vaddr(q->bufs[i], 0); + vb = vb2_get_buffer(q, i); + + if (!vb) + continue; + + fileio->bufs[i].vaddr = vb2_plane_vaddr(vb, 0); if (fileio->bufs[i].vaddr == NULL) { ret = -EINVAL; goto err_reqbufs; } - fileio->bufs[i].size = vb2_plane_size(q->bufs[i], 0); + fileio->bufs[i].size = vb2_plane_size(vb, 0); } /* @@ -2814,15 +2904,18 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ fileio->cur_index = index; buf = &fileio->bufs[index]; - b = q->bufs[index]; + b = vb2_get_buffer(q, index); + + if (!b) + return -EINVAL; /* * Get number of bytes filled by the driver */ buf->pos = 0; buf->queued = 0; - buf->size = read ? vb2_get_plane_payload(q->bufs[index], 0) - : vb2_plane_size(q->bufs[index], 0); + buf->size = read ? vb2_get_plane_payload(b, 0) + : vb2_plane_size(b, 0); /* Compensate for data_offset on read in the multiplanar case. */ if (is_multiplanar && read && b->planes[0].data_offset < buf->size) { @@ -2865,8 +2958,12 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ * Queue next buffer if required. */ if (buf->pos == buf->size || (!read && fileio->write_immediately)) { - struct vb2_buffer *b = q->bufs[index]; + struct vb2_buffer *b = vb2_get_buffer(q, index); + if (!b) { + dprintk(q, 1, "can't find the requested buffer\n"); + return -EINVAL; + } /* * Check if this is the last buffer to read. */ @@ -2892,7 +2989,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ */ buf->pos = 0; buf->queued = 1; - buf->size = vb2_plane_size(q->bufs[index], 0); + buf->size = vb2_plane_size(b, 0); fileio->q_count += 1; /* * If we are queuing up buffers for the first time, then @@ -2963,7 +3060,9 @@ static int vb2_thread(void *data) * Call vb2_dqbuf to get buffer back. */ if (prequeue) { - vb = q->bufs[index++]; + vb = vb2_get_buffer(q, index++); + if (!vb) + continue; prequeue--; } else { call_void_qop(q, wait_finish, q); @@ -2972,7 +3071,7 @@ static int vb2_thread(void *data) call_void_qop(q, wait_prepare, q); dprintk(q, 5, "file io: vb2_dqbuf result: %d\n", ret); if (!ret) - vb = q->bufs[index]; + vb = vb2_get_buffer(q, index); } if (ret || threadio->stop) break; diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index 697c8a9f98cd..f460cac560f6 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -383,8 +383,8 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct media_device *md return -EINVAL; } - if (q->bufs[b->index] == NULL) { - /* Should never happen */ + vb = vb2_get_buffer(q, b->index); + if (!vb) { dprintk(q, 1, "%s: buffer is NULL\n", opname); return -EINVAL; } @@ -394,7 +394,6 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct media_device *md return -EINVAL; } - vb = q->bufs[b->index]; vbuf = to_vb2_v4l2_buffer(vb); ret = __verify_planes_array(vb, b); if (ret) @@ -628,11 +627,22 @@ static const struct vb2_buf_ops v4l2_buf_ops = { struct vb2_buffer *vb2_find_buffer(struct vb2_queue *q, u64 timestamp) { unsigned int i; + struct vb2_buffer *vb2; - for (i = 0; i < q->num_buffers; i++) - if (q->bufs[i]->copied_timestamp && - q->bufs[i]->timestamp == timestamp) - return vb2_get_buffer(q, i); + /* + * This loop doesn't scale if there is a really large number of buffers. + * Maybe something more efficient will be needed in this case. + */ + for (i = 0; i < q->num_buffers; i++) { + vb2 = vb2_get_buffer(q, i); + + if (!vb2) + continue; + + if (vb2->copied_timestamp && + vb2->timestamp == timestamp) + return vb2; + } return NULL; } EXPORT_SYMBOL_GPL(vb2_find_buffer); @@ -660,11 +670,12 @@ int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b) return -EINVAL; } - if (b->index >= q->num_buffers) { - dprintk(q, 1, "buffer index out of range\n"); + vb = vb2_get_buffer(q, b->index); + if (!vb) { + dprintk(q, 1, "can't find the requested buffer\n"); return -EINVAL; } - vb = q->bufs[b->index]; + ret = __verify_planes_array(vb, b); if (!ret) vb2_core_querybuf(q, vb, b); @@ -734,11 +745,11 @@ int vb2_prepare_buf(struct vb2_queue *q, struct media_device *mdev, if (b->flags & V4L2_BUF_FLAG_REQUEST_FD) return -EINVAL; - if (b->index >= q->num_buffers) { - dprintk(q, 1, "buffer index out of range\n"); + vb = vb2_get_buffer(q, b->index); + if (!vb) { + dprintk(q, 1, "can't find the requested buffer\n"); return -EINVAL; } - vb = q->bufs[b->index]; ret = vb2_queue_or_prepare_buf(q, mdev, b, true, NULL); @@ -822,7 +833,11 @@ int vb2_qbuf(struct vb2_queue *q, struct media_device *mdev, dprintk(q, 1, "buffer index out of range\n"); return -EINVAL; } - vb = q->bufs[b->index]; + vb = vb2_get_buffer(q, b->index); + if (!vb) { + dprintk(q, 1, "can't find the requested buffer\n"); + return -EINVAL; + } ret = vb2_queue_or_prepare_buf(q, mdev, b, false, &req); if (ret) @@ -893,7 +908,11 @@ int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb) dprintk(q, 1, "buffer index out of range\n"); return -EINVAL; } - vb = q->bufs[eb->index]; + vb = vb2_get_buffer(q, eb->index); + if (!vb) { + dprintk(q, 1, "can't find the requested buffer\n"); + return -EINVAL; + } return vb2_core_expbuf(q, &eb->fd, eb->type, vb, eb->plane, eb->flags); From patchwork Thu Sep 14 13:32:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139885 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp676153vqi; Thu, 14 Sep 2023 16:02:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGCWZQPodUbOcxfAYapdtN8n400cQXk105v+lU5cK1XDlH8mQUVrEImCDRRaSOjhyKeBVKz X-Received: by 2002:a05:6a20:13d0:b0:137:7198:af9b with SMTP id ho16-20020a056a2013d000b001377198af9bmr127460pzc.56.1694732556751; Thu, 14 Sep 2023 16:02:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694732556; cv=none; d=google.com; s=arc-20160816; b=e1janOnFvRMXPXhHQOvTpy7PC6o9JGybgYxOu4296kkKZLyOUo0ZisOsP/jQqbJ6tH JO5wMRd381xWG5nt+iZkmKdwF6a7AiIkTNYsQhd1+4EMofYh9+iuFqs7iE6eDzyo9HBo dNcVmU93cBhbMHzODYUyPwdY1LggFhJoo2ok9+F1j9SdHL9UT3pJjJmPN04FXGevsuef YJ/+nTL1IM+YN37y63Cp7Gq2am901SqavUBJOY+InIMw+I5iuhkcSdvcj9svt0x8cvLW MEAQM4UHqXvC0B81w5vXdqCRaiXSZZvvXlhRfPCmkHTsZXHG7iNO520vjl8k/rbAkyU8 gR3Q== 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=ZT6qpEIWTsFbh9WlxSnIhuZFGBr6DbFddhHhWu0eaq0=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=AqI0/m7ELEGEgo7o+RlAS66M3Rs4KkEkZtf9QNN+iayjJu/+y7WTi6T1e7Lj/9VxVE aEO5wDUyClqanKPpWJb1E57rw2x54J2wU1OKYOQ5yxg0LTpLA27770sNAboKFnvKX+Vd Qv5orzCRIyn5Pw3J6Do98cdysP1mjJYh8cEWahMfuathTnEo8IbGjzjk1zpVJueSrSNS l9HQKMMo18f/06kUT/rtTrYucruPtwHeh9WhJ+q3brGYNj9Vi9duahdTYsvuOMm64U3I gTXwpp9RlWyeo8mc30eI2IDVLXYcr8fLadpHpkjmXoVM3Llp+Sp3rukNvLRhK3OUzRCc nOHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=BkSQDKxJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id bv9-20020a056a00414900b00690228b1d45si2262935pfb.342.2023.09.14.16.02.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 16:02:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=BkSQDKxJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 C024181CC868; Thu, 14 Sep 2023 06:34:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239253AbjINNeJ (ORCPT + 35 others); Thu, 14 Sep 2023 09:34:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239147AbjINNdr (ORCPT ); Thu, 14 Sep 2023 09:33:47 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE26D1FE1; Thu, 14 Sep 2023 06:33:38 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 612806607365; Thu, 14 Sep 2023 14:33:37 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698417; bh=h2BeQ/NsbyEyCup+psJf2BQPK31aCDVGYIe1zsQ/Ukk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BkSQDKxJG9PHx15MgEGbhvOhxGON2OX+XrIsfFLfmVHIQXRmAtX7C4+ObDqVTJ4NP fuYnRhdYpFUEzaRxavWzKe/MTH/oYmejP7qYPmUCkPIVBg3u3dmn/v+cMtlXfpdWxv iujzhY7/Jtb4Kv5Em3V+MChHN1zK8UNQ2iZTY0ySybOzg11WIlF83hFaO9zkHI3CZb 2v78ToQRMQRFJ00eTdYFbnJFCaYYBe3H6RZJLiRcdX7zPznLTqpMX1iph6ST3pQ2Ao JmeBykpk0I1C4vLbh86E1irHwchpS87Q7vLnzEj/+TZLlji7BCVqqjD+vzKr/JumjD mOaJWI+aEQWNw== 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 v7 12/49] media: videobuf2: Be more flexible on the number of queue stored buffers Date: Thu, 14 Sep 2023 15:32:46 +0200 Message-Id: <20230914133323.198857-13-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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, 14 Sep 2023 06:34:18 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777055885196705683 X-GMAIL-MSGID: 1777055885196705683 Add 'max_allowed_buffers' field in vb2_queue struct to let drivers decide how many buffers could be stored in a queue. This request 'bufs' array to be allocated at queue init time and freed when releasing the queue. By default VB2_MAX_FRAME remains the limit. Signed-off-by: Benjamin Gaignard Signed-off-by: Hans Verkuil Signed-off-by: Hans Verkuil --- .../media/common/videobuf2/videobuf2-core.c | 40 ++++++++++++++----- .../media/common/videobuf2/videobuf2-v4l2.c | 4 +- include/media/videobuf2-core.h | 4 +- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index afe76577acc1..ee4df7c68397 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -411,7 +411,7 @@ static void init_buffer_cache_hints(struct vb2_queue *q, struct vb2_buffer *vb) */ static bool vb2_queue_add_buffer(struct vb2_queue *q, struct vb2_buffer *vb, unsigned int index) { - if (index < VB2_MAX_FRAME && !q->bufs[index]) { + if (index < q->max_allowed_buffers && !q->bufs[index]) { q->bufs[index] = vb; vb->index = index; vb->vb2_queue = q; @@ -428,7 +428,7 @@ static bool vb2_queue_add_buffer(struct vb2_queue *q, struct vb2_buffer *vb, uns */ static void vb2_queue_remove_buffer(struct vb2_queue *q, struct vb2_buffer *vb) { - if (vb->index < VB2_MAX_FRAME) { + if (vb->index < q->max_allowed_buffers) { q->bufs[vb->index] = NULL; vb->vb2_queue = NULL; } @@ -449,9 +449,9 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory, struct vb2_buffer *vb; int ret; - /* Ensure that q->num_buffers+num_buffers is below VB2_MAX_FRAME */ + /* Ensure that q->num_buffers+num_buffers is below q->max_allowed_buffers */ num_buffers = min_t(unsigned int, num_buffers, - VB2_MAX_FRAME - q->num_buffers); + q->max_allowed_buffers - q->num_buffers); for (buffer = 0; buffer < num_buffers; ++buffer) { /* Allocate vb2 buffer structures */ @@ -814,7 +814,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, unsigned plane_sizes[VB2_MAX_PLANES] = { }; bool non_coherent_mem = flags & V4L2_MEMORY_FLAG_NON_COHERENT; unsigned int i; - int ret; + int ret = 0; if (q->streaming) { dprintk(q, 1, "streaming active\n"); @@ -858,17 +858,23 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, /* * Make sure the requested values and current defaults are sane. */ - WARN_ON(q->min_buffers_needed > VB2_MAX_FRAME); + WARN_ON(q->min_buffers_needed > q->max_allowed_buffers); num_buffers = max_t(unsigned int, *count, q->min_buffers_needed); - num_buffers = min_t(unsigned int, num_buffers, VB2_MAX_FRAME); + num_buffers = min_t(unsigned int, num_buffers, q->max_allowed_buffers); memset(q->alloc_devs, 0, sizeof(q->alloc_devs)); /* * Set this now to ensure that drivers see the correct q->memory value * in the queue_setup op. */ mutex_lock(&q->mmap_lock); + if (!q->bufs) + q->bufs = kcalloc(q->max_allowed_buffers, sizeof(*q->bufs), GFP_KERNEL); + if (!q->bufs) + ret = -ENOMEM; q->memory = memory; mutex_unlock(&q->mmap_lock); + if (ret) + return ret; set_queue_coherency(q, non_coherent_mem); /* @@ -974,9 +980,9 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, unsigned plane_sizes[VB2_MAX_PLANES] = { }; bool non_coherent_mem = flags & V4L2_MEMORY_FLAG_NON_COHERENT; bool no_previous_buffers = !q->num_buffers; - int ret; + int ret = 0; - if (q->num_buffers == VB2_MAX_FRAME) { + if (q->num_buffers == q->max_allowed_buffers) { dprintk(q, 1, "maximum number of buffers already allocated\n"); return -ENOBUFS; } @@ -993,7 +999,13 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, */ mutex_lock(&q->mmap_lock); q->memory = memory; + if (!q->bufs) + q->bufs = kcalloc(q->max_allowed_buffers, sizeof(*q->bufs), GFP_KERNEL); + if (!q->bufs) + ret = -ENOMEM; mutex_unlock(&q->mmap_lock); + if (ret) + return ret; q->waiting_for_buffers = !q->is_output; set_queue_coherency(q, non_coherent_mem); } else { @@ -1005,7 +1017,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, return -EINVAL; } - num_buffers = min(*count, VB2_MAX_FRAME - q->num_buffers); + num_buffers = min(*count, q->max_allowed_buffers - q->num_buffers); if (requested_planes && requested_sizes) { num_planes = requested_planes; @@ -2515,6 +2527,12 @@ int vb2_core_queue_init(struct vb2_queue *q) q->memory = VB2_MEMORY_UNKNOWN; + if (!q->max_allowed_buffers) + q->max_allowed_buffers = VB2_MAX_FRAME; + + /* The maximum is limited by offset cookie encoding pattern */ + q->max_allowed_buffers = min_t(unsigned int, q->max_allowed_buffers, BUFFER_INDEX_MASK + 1); + if (q->buf_struct_size == 0) q->buf_struct_size = sizeof(struct vb2_buffer); @@ -2539,6 +2557,8 @@ void vb2_core_queue_release(struct vb2_queue *q) __vb2_queue_cancel(q); mutex_lock(&q->mmap_lock); __vb2_queue_free(q, q->num_buffers); + kfree(q->bufs); + q->bufs = NULL; mutex_unlock(&q->mmap_lock); } EXPORT_SYMBOL_GPL(vb2_core_queue_release); diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index f460cac560f6..87c2d5916960 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -1156,7 +1156,7 @@ int _vb2_fop_release(struct file *file, struct mutex *lock) if (lock) mutex_lock(lock); - if (file->private_data == vdev->queue->owner) { + if (!vdev->queue->owner || file->private_data == vdev->queue->owner) { vb2_queue_release(vdev->queue); vdev->queue->owner = NULL; } @@ -1284,7 +1284,7 @@ void vb2_video_unregister_device(struct video_device *vdev) */ get_device(&vdev->dev); video_unregister_device(vdev); - if (vdev->queue && vdev->queue->owner) { + if (vdev->queue) { struct mutex *lock = vdev->queue->lock ? vdev->queue->lock : vdev->lock; diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index cd3ff1cd759d..97153c69583f 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -558,6 +558,7 @@ struct vb2_buf_ops { * @dma_dir: DMA mapping direction. * @bufs: videobuf2 buffer structures * @num_buffers: number of allocated/used buffers + * @max_allowed_buffers: upper limit of number of allocated/used buffers * @queued_list: list of buffers currently queued from userspace * @queued_count: number of buffers queued and ready for streaming. * @owned_by_drv_count: number of buffers owned by the driver @@ -619,8 +620,9 @@ struct vb2_queue { struct mutex mmap_lock; unsigned int memory; enum dma_data_direction dma_dir; - struct vb2_buffer *bufs[VB2_MAX_FRAME]; + struct vb2_buffer **bufs; unsigned int num_buffers; + unsigned int max_allowed_buffers; struct list_head queued_list; unsigned int queued_count; From patchwork Thu Sep 14 13:32:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139718 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp503617vqi; Thu, 14 Sep 2023 10:19:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEr3e7cZDu8xlc4ZSfZBQRcGC3cWxxqnuqXRdOCTPmrDKHGQP9bUCTZ64m/Zdp5T2/sSLzr X-Received: by 2002:a05:6a21:7895:b0:14c:c393:6af with SMTP id bf21-20020a056a21789500b0014cc39306afmr6876116pzc.0.1694711997596; Thu, 14 Sep 2023 10:19:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694711997; cv=none; d=google.com; s=arc-20160816; b=MlLNLQVkJzV8oo3GprLL21y4Un4ZgC4R3Y43WdtLTP2sDgNLbaZ9mHuAKoq7cxyOoh 8qn/A5q1j32FGCV6MPKIy0OB+wsJe7HDkZCnfxGaFMT/ghQrjEusc3F7GMHC//2Ene00 OuBDeGjwrIesaEWSSY2W8IRY94OzzeDOtGglnv//P9yv85AutBw5j3sj9sje8dnuPVIi GuePUt0wpC/DGU4RKVgcdQ5oXLFQzx/3RTJwqf7UxMgaKjjkphw0S50G5lVRnqXiDmyR FdbY7XA+OYzqEO2TXcRdPDJRXCoxGr99c/Lk7zKIgP9AsbY3d8kaCekBTt/xQ5foeH9k 8bcA== 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=hU4U/ya/Ghwk4ttuTZxAJ6KeHIrW4xdBl93mkNmhaoE=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=hpeqWStsCPdvpw67h5yDvRvy8io4xVbcS96OZnJTQpaUEVQwoHVr8NZhOCpTSCsJXp VfO5N8mYAC/DBmTmZ713un59R8/5IZevOz/oiifxFVrxQFJB0Z7uDMus4AUBP1GCLqHO yh2ZoMWvoOw1/8twq3sLIPrkNDmpaDdrwQyl2U9nBPPe0ixkeSt1AEGb3FwKboaKuFhC IqDXAajm9J8twFkC+GfSfGI4GO871PeLOXXDUNmmb8qxKq5panyWNREB0scvtpsI592D eEDh52Q6+UBaWbeBFmo8cWSTIJQuwXneTsaxASc8piCohoXzNUdsXfmQVR+n+QCqHTMI MyLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=JDL4k3LY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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. [23.128.96.34]) by mx.google.com with ESMTPS id h192-20020a636cc9000000b0056ae965c538si1823547pgc.55.2023.09.14.10.19.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 10:19:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=JDL4k3LY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 8BA8E84EBE22; Thu, 14 Sep 2023 06:34:25 -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 S239215AbjINNeM (ORCPT + 35 others); Thu, 14 Sep 2023 09:34:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239167AbjINNds (ORCPT ); Thu, 14 Sep 2023 09:33:48 -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 62AED1FE5; Thu, 14 Sep 2023 06:33:39 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 E4E266607368; Thu, 14 Sep 2023 14:33:37 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698418; bh=Wle9dqOqtE6Ngu/V1SgSMthhf7eaexlar0GwhzoB7nI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JDL4k3LYmy/1q61V9lvgRlSt5QE0PV3WlFNablvY/AVXaRoDNYA6XXOrHzJX/mNyG eqcsEzm9UKW11zzw72eZ+A365oBhO3GaMe0m0h/bcNp5OAyNvrYsiFrLKJ0rGLYUTg roEZYBFaESKrLEx+LoshPo5/N21VLMc4TB2rLI8smBjQha/SpOYTZAG2Q+5QyvM+2/ sdE5zIAYGuFuppWDpjwyVWaACeV4getr4STV2Kbxh5XkSg3krEOvqxaQGslNpreO+0 j8tA0FDMDkFzNDu+MGmrhX8Io6hdStV/exZm3s+79PMR0iKBezeGm5GsUzN/eSTZsd /qa+v4mxmQISA== 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 v7 13/49] media: verisilicon: Refactor postprocessor to store more buffers Date: Thu, 14 Sep 2023 15:32:47 +0200 Message-Id: <20230914133323.198857-14-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (howler.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:34:25 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777034327473951776 X-GMAIL-MSGID: 1777034327473951776 Since vb2 queue can store than VB2_MAX_FRAME buffers postprocessor buffer storage must be capable to store more buffers too. Change static dec_q array to allocated array to be capable to store up to queue 'max_allowed_buffers'. Keep allocating queue 'num_buffers' at queue setup time but also allows to allocate postprocessors buffers on the fly. Signed-off-by: Benjamin Gaignard --- drivers/media/platform/verisilicon/hantro.h | 7 +- .../media/platform/verisilicon/hantro_drv.c | 4 +- .../media/platform/verisilicon/hantro_hw.h | 4 +- .../platform/verisilicon/hantro_postproc.c | 93 +++++++++++++++---- .../media/platform/verisilicon/hantro_v4l2.c | 2 +- 5 files changed, 85 insertions(+), 25 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro.h b/drivers/media/platform/verisilicon/hantro.h index 77aee9489516..0948b04a9f8d 100644 --- a/drivers/media/platform/verisilicon/hantro.h +++ b/drivers/media/platform/verisilicon/hantro.h @@ -469,11 +469,14 @@ hantro_get_dst_buf(struct hantro_ctx *ctx) bool hantro_needs_postproc(const struct hantro_ctx *ctx, const struct hantro_fmt *fmt); +dma_addr_t +hantro_postproc_get_dec_buf_addr(struct hantro_ctx *ctx, int index); + static inline dma_addr_t hantro_get_dec_buf_addr(struct hantro_ctx *ctx, struct vb2_buffer *vb) { if (hantro_needs_postproc(ctx, ctx->vpu_dst_fmt)) - return ctx->postproc.dec_q[vb->index].dma; + return hantro_postproc_get_dec_buf_addr(ctx, vb->index); return vb2_dma_contig_plane_dma_addr(vb, 0); } @@ -485,8 +488,8 @@ vb2_to_hantro_decoded_buf(struct vb2_buffer *buf) void hantro_postproc_disable(struct hantro_ctx *ctx); void hantro_postproc_enable(struct hantro_ctx *ctx); +int hantro_postproc_init(struct hantro_ctx *ctx); void hantro_postproc_free(struct hantro_ctx *ctx); -int hantro_postproc_alloc(struct hantro_ctx *ctx); int hanto_postproc_enum_framesizes(struct hantro_ctx *ctx, struct v4l2_frmsizeenum *fsize); diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c index 423fc85d79ee..18f56edee3fc 100644 --- a/drivers/media/platform/verisilicon/hantro_drv.c +++ b/drivers/media/platform/verisilicon/hantro_drv.c @@ -234,8 +234,10 @@ queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq) * The Kernel needs access to the JPEG destination buffer for the * JPEG encoder to fill in the JPEG headers. */ - if (!ctx->is_encoder) + if (!ctx->is_encoder) { dst_vq->dma_attrs |= DMA_ATTR_NO_KERNEL_MAPPING; + dst_vq->max_allowed_buffers = MAX_POSTPROC_BUFFERS; + } dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; dst_vq->io_modes = VB2_MMAP | VB2_DMABUF; diff --git a/drivers/media/platform/verisilicon/hantro_hw.h b/drivers/media/platform/verisilicon/hantro_hw.h index 7f33f7b07ce4..292a76ef643e 100644 --- a/drivers/media/platform/verisilicon/hantro_hw.h +++ b/drivers/media/platform/verisilicon/hantro_hw.h @@ -40,6 +40,8 @@ #define AV1_MAX_FRAME_BUF_COUNT (V4L2_AV1_TOTAL_REFS_PER_FRAME + 1) +#define MAX_POSTPROC_BUFFERS 64 + struct hantro_dev; struct hantro_ctx; struct hantro_buf; @@ -336,7 +338,7 @@ struct hantro_av1_dec_hw_ctx { * @dec_q: References buffers, in decoder format. */ struct hantro_postproc_ctx { - struct hantro_aux_buf dec_q[VB2_MAX_FRAME]; + struct hantro_aux_buf dec_q[MAX_POSTPROC_BUFFERS]; }; /** diff --git a/drivers/media/platform/verisilicon/hantro_postproc.c b/drivers/media/platform/verisilicon/hantro_postproc.c index 0224ff68ab3f..e624cd98f41b 100644 --- a/drivers/media/platform/verisilicon/hantro_postproc.c +++ b/drivers/media/platform/verisilicon/hantro_postproc.c @@ -177,9 +177,11 @@ static int hantro_postproc_g2_enum_framesizes(struct hantro_ctx *ctx, void hantro_postproc_free(struct hantro_ctx *ctx) { struct hantro_dev *vpu = ctx->dev; + struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; + struct vb2_queue *queue = &m2m_ctx->cap_q_ctx.q; unsigned int i; - for (i = 0; i < VB2_MAX_FRAME; ++i) { + for (i = 0; i < queue->max_allowed_buffers; ++i) { struct hantro_aux_buf *priv = &ctx->postproc.dec_q[i]; if (priv->cpu) { @@ -190,20 +192,17 @@ void hantro_postproc_free(struct hantro_ctx *ctx) } } -int hantro_postproc_alloc(struct hantro_ctx *ctx) +static unsigned int hantro_postproc_buffer_size(struct hantro_ctx *ctx) { - struct hantro_dev *vpu = ctx->dev; - struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; - struct vb2_queue *cap_queue = &m2m_ctx->cap_q_ctx.q; - unsigned int num_buffers = cap_queue->num_buffers; struct v4l2_pix_format_mplane pix_mp; const struct hantro_fmt *fmt; - unsigned int i, buf_size; + unsigned int buf_size; /* this should always pick native format */ fmt = hantro_get_default_fmt(ctx, false, ctx->bit_depth, HANTRO_AUTO_POSTPROC); if (!fmt) - return -EINVAL; + return 0; + v4l2_fill_pixfmt_mp(&pix_mp, fmt->fourcc, ctx->src_fmt.width, ctx->src_fmt.height); @@ -221,23 +220,77 @@ int hantro_postproc_alloc(struct hantro_ctx *ctx) buf_size += hantro_av1_mv_size(pix_mp.width, pix_mp.height); - for (i = 0; i < num_buffers; ++i) { - struct hantro_aux_buf *priv = &ctx->postproc.dec_q[i]; + return buf_size; +} + +static int hantro_postproc_alloc(struct hantro_ctx *ctx, int index) +{ + struct hantro_dev *vpu = ctx->dev; + struct hantro_aux_buf *priv = &ctx->postproc.dec_q[index]; + unsigned int buf_size = hantro_postproc_buffer_size(ctx); + + if (!buf_size) + return -EINVAL; + + /* + * The buffers on this queue are meant as intermediate + * buffers for the decoder, so no mapping is needed. + */ + priv->attrs = DMA_ATTR_NO_KERNEL_MAPPING; + priv->cpu = dma_alloc_attrs(vpu->dev, buf_size, &priv->dma, + GFP_KERNEL, priv->attrs); + if (!priv->cpu) + return -ENOMEM; + priv->size = buf_size; + + return 0; +} - /* - * The buffers on this queue are meant as intermediate - * buffers for the decoder, so no mapping is needed. - */ - priv->attrs = DMA_ATTR_NO_KERNEL_MAPPING; - priv->cpu = dma_alloc_attrs(vpu->dev, buf_size, &priv->dma, - GFP_KERNEL, priv->attrs); - if (!priv->cpu) - return -ENOMEM; - priv->size = buf_size; +int hantro_postproc_init(struct hantro_ctx *ctx) +{ + struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; + struct vb2_queue *cap_queue = &m2m_ctx->cap_q_ctx.q; + unsigned int num_buffers = cap_queue->num_buffers; + unsigned int i; + int ret; + + for (i = 0; i < num_buffers; i++) { + ret = hantro_postproc_alloc(ctx, i); + if (ret) + return ret; } + return 0; } +dma_addr_t +hantro_postproc_get_dec_buf_addr(struct hantro_ctx *ctx, int index) +{ + struct hantro_aux_buf *priv = &ctx->postproc.dec_q[index]; + unsigned int buf_size = hantro_postproc_buffer_size(ctx); + struct hantro_dev *vpu = ctx->dev; + int ret; + + if (priv->size < buf_size && priv->cpu) { + /* buffer is too small, release it */ + dma_free_attrs(vpu->dev, priv->size, priv->cpu, + priv->dma, priv->attrs); + priv->cpu = NULL; + } + + if (!priv->cpu) { + /* buffer not already allocated, try getting a new one */ + ret = hantro_postproc_alloc(ctx, index); + if (ret) + return 0; + } + + if (!priv->cpu) + return 0; + + return priv->dma; +} + static void hantro_postproc_g1_disable(struct hantro_ctx *ctx) { struct hantro_dev *vpu = ctx->dev; diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/media/platform/verisilicon/hantro_v4l2.c index b3ae037a50f6..f0d8b165abcd 100644 --- a/drivers/media/platform/verisilicon/hantro_v4l2.c +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c @@ -933,7 +933,7 @@ static int hantro_start_streaming(struct vb2_queue *q, unsigned int count) } if (hantro_needs_postproc(ctx, ctx->vpu_dst_fmt)) { - ret = hantro_postproc_alloc(ctx); + ret = hantro_postproc_init(ctx); if (ret) goto err_codec_exit; } From patchwork Thu Sep 14 13:32: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: 139591 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp353194vqi; Thu, 14 Sep 2023 06:35:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEX9B0IYHd+24x+xMkVe8g8bDqLX/NNCemyEb359blTr8YA5yUC3uUY2IlCGWm+uvUKtHig X-Received: by 2002:a17:902:d34b:b0:1bb:a7bc:37a4 with SMTP id l11-20020a170902d34b00b001bba7bc37a4mr5440378plk.24.1694698543231; Thu, 14 Sep 2023 06:35:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694698543; cv=none; d=google.com; s=arc-20160816; b=id1XFfVn+aVPt1r6xGTHHmXdxX1L4cKcO4Q8lGZvMh61qqtoOTXFWJ7JyAH4Nzm3TE CFhGhP/fbSYQG35izt6KhOJ1384AgK7JZS3IoQv7NSuddp/fLhHvDFj0B9vjvcYvZ72g HT9i1bz/1+u59W9ShzyWM3XXjEeohnQQqlCR9410/pHl3ChmIRWrUhoUJeB9L9TBKrQG fKAF9ITLYjkHh/+XP2RebtsHCTnWvN9/YxL31Qk20+/ojzYNB0fK3C3NFRqX0frxpO+P ebE7tBcFfo0Os3kQ8ppVYp7y8+0B1V+Bflrq26vWvrmvMaeBQuuk/glUnyJnWyY+mY6/ mj5g== 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=5L3/AyXWBMargXezPo0FB+C5lfGWk8bpjOj4Q1JKDYg=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=LQvuty2VnvgqlC5uhPWpzc+QIebkMPUJIWoR3PkYksOiEI+Ka3UxSTXXZG6JcByBGE pr5zud05OFP+a9vzygzunXdxBoNPAXl6BaoasRpMCW3bPWanbVrIL1QYDMccE2/RP5GU UZOa53OlaTQEpMvWbt3USLF4f+NDkU8IcdjhXhkrpjseBAXKenuvK6LJMKuzmLl9sE+/ xs5Rn393bxFKQBDRP8OnwfiM38T8wWnlvFeAqKymDFPGsqM8j5gh3HbtOwdU+e34zJSI JWBvDUgMBiFL9WUPnutxC8HVkJCrgmhfhCwpUUJXmHs9UBujPPPKR4945Uh+1KazeelA hvfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=lxrnhma7; 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 kl16-20020a170903075000b001bb7b3e607dsi1633218plb.21.2023.09.14.06.35.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 06:35:43 -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=lxrnhma7; 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 8DB6B8076E68; Thu, 14 Sep 2023 06:34:33 -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 S239028AbjINNeR (ORCPT + 35 others); Thu, 14 Sep 2023 09:34:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239205AbjINNdx (ORCPT ); Thu, 14 Sep 2023 09:33:53 -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 08D8C1FE6; Thu, 14 Sep 2023 06:33:39 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 668DB6607369; Thu, 14 Sep 2023 14:33:38 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698418; bh=gAzQ/SGzIm4inZNC+PXcs+p3IPzDsrNiBUGyKW1mkfg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lxrnhma7i8Ls0SAgQGTQPC1BsiJemQAXaFNVnm6fXZ5GrBZo+K8vxtcjrtDiBx2QJ MM65w1/9WJ/gapuK+evfRQHEKwoMZNfRdb+rY3lIJBElI6S11/dc1UqudAAZO4CWg+ JSqnntZBc32UlhipMCto22SL+A6FZe5P3a4fn+D6PjTP/jTzAsaLYhnVXriSOyJB0e DLWhCY8a3+RF9fU9LoN4XXaY6mXC66MjlpdfPN8C42xhazrb9IB+NP2GwmoyUsunDC pvay/ga8Wo1R3ZEQc5YiEeEdj5gOTeCLtiYYOlAdJpCvx4rjVwPyQvAjAbij1eIhsz FoAAWVA6CoAfQ== 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 v7 14/49] media: verisilicon: Store chroma and motion vectors offset Date: Thu, 14 Sep 2023 15:32:48 +0200 Message-Id: <20230914133323.198857-15-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (groat.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:34:33 -0700 (PDT) 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777020219624386923 X-GMAIL-MSGID: 1777020219624386923 Store computed values of chroma and motion vectors offset because they depends on width and height values which change if the resolution change. Signed-off-by: Benjamin Gaignard --- drivers/media/platform/verisilicon/hantro.h | 2 ++ drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro.h b/drivers/media/platform/verisilicon/hantro.h index 0948b04a9f8d..6f5eb975d0e3 100644 --- a/drivers/media/platform/verisilicon/hantro.h +++ b/drivers/media/platform/verisilicon/hantro.h @@ -328,6 +328,8 @@ struct hantro_vp9_decoded_buffer_info { /* Info needed when the decoded frame serves as a reference frame. */ unsigned short width; unsigned short height; + size_t chroma_offset; + size_t mv_offset; u32 bit_depth : 4; }; diff --git a/drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c b/drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c index 6fc4b555517f..6db1c32fce4d 100644 --- a/drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c +++ b/drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c @@ -158,9 +158,11 @@ static void config_output(struct hantro_ctx *ctx, chroma_addr = luma_addr + chroma_offset(ctx, dec_params); hantro_write_addr(ctx->dev, G2_OUT_CHROMA_ADDR, chroma_addr); + dst->vp9.chroma_offset = chroma_offset(ctx, dec_params); mv_addr = luma_addr + mv_offset(ctx, dec_params); hantro_write_addr(ctx->dev, G2_OUT_MV_ADDR, mv_addr); + dst->vp9.mv_offset = mv_offset(ctx, dec_params); } struct hantro_vp9_ref_reg { @@ -195,7 +197,7 @@ static void config_ref(struct hantro_ctx *ctx, luma_addr = hantro_get_dec_buf_addr(ctx, &buf->base.vb.vb2_buf); hantro_write_addr(ctx->dev, ref_reg->y_base, luma_addr); - chroma_addr = luma_addr + chroma_offset(ctx, dec_params); + chroma_addr = luma_addr + buf->vp9.chroma_offset; hantro_write_addr(ctx->dev, ref_reg->c_base, chroma_addr); } @@ -238,7 +240,7 @@ static void config_ref_registers(struct hantro_ctx *ctx, config_ref(ctx, dst, &ref_regs[2], dec_params, dec_params->alt_frame_ts); mv_addr = hantro_get_dec_buf_addr(ctx, &mv_ref->base.vb.vb2_buf) + - mv_offset(ctx, dec_params); + mv_ref->vp9.mv_offset; hantro_write_addr(ctx->dev, G2_REF_MV_ADDR(0), mv_addr); hantro_reg_write(ctx->dev, &vp9_last_sign_bias, From patchwork Thu Sep 14 13:32: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: 140179 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp864010vqi; Fri, 15 Sep 2023 00:21:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGOEY+ZnoEvIAy0oEk2+TtldUsBCahPj83tsA0pqRkcMigaQZMedcuVohiYKE1rQqluTTBq X-Received: by 2002:a17:903:1103:b0:1b9:e241:ad26 with SMTP id n3-20020a170903110300b001b9e241ad26mr1190188plh.9.1694762514628; Fri, 15 Sep 2023 00:21:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694762514; cv=none; d=google.com; s=arc-20160816; b=a3vsgEb4hIfUVG6nAXB23isbsID9LbzCL43sj7yag01cijVzbL+Crj8Fy4IH6k3vAx xYIWnSpafkZIGmkkRTuj8X12M3zSVXl4EaUQUadEXbssmow2kw67aHI6KnCN/XEYU1VN F3dqa0cozMMnYHpFNvzEaq0Fz8xzNVnhX816jRMh1j6D3rd/+Pq0iGib9MIBeOJunmGu acT0++mPPKRQVrR9WCXVoO0NRmxVeei/TkbBzXy/hFKVF+4SpW+OHVGS18lDgqqc6Q7M DCfwe1VCe6p0dfwqIrtkHLdezkNYKGG41zFi2KuZpEBoNFaHJCj/lot0WfpvipXWpfYd pVXQ== 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=HkqIHwE/r1uwsEs78ypgy8bMOh4izrOAeqpphIKik8A=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=lNOhCJuMq/SAU/7sBEdi+ugAgyv6mwFGom8j4iCXLKzbC2227805bcAZWFS5UMt3RA JO2FIoXqxq8dvaTt7L8iruQMI1fBbUIWhknuPemw8DAp+YGRHkApZwv6Nj4kmZQeXLIk UN+R9lWc4rt5Mb8KOqlwJ47inQ18pVdTkBYIAHkBA4ttGKspEN2s7dQMjjFUdAR5t5tw hprqS8aSxf8Om9YVH3LjG4aboAZ5a2wH6s8CUBO7/2EKdUmvCWk7kc2IvMVZhRh5MUPM OQmMfT5xNyOxyjwgoua9/yqowbijvhCtHeIyOeTpd5MHchPZfbz6zyiZulUJED58+ZNZ Hw8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=MjJN8QGk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id y15-20020a17090322cf00b001b9fb999147si3206143plg.89.2023.09.15.00.21.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 00:21:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=MjJN8QGk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 EAE9681D4776; Thu, 14 Sep 2023 06:34:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239497AbjINNeS (ORCPT + 35 others); Thu, 14 Sep 2023 09:34:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239214AbjINNdx (ORCPT ); Thu, 14 Sep 2023 09:33:53 -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 71B691FEB; Thu, 14 Sep 2023 06:33:40 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 E3ED4660736C; Thu, 14 Sep 2023 14:33:38 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698419; bh=G1d7K+QU+qOmdvGntI5BZm0vkE40HwEf9qtRlxyqy2Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MjJN8QGkFKCFBxID7yfEh5Tj8KR6qdmdF3h0uWLO8YELpklzLNmPLzk7wcHuAqhSb oUgJMl/9OyrtS6mX2T3xx+4csZt3eq2ifoRw7eN3gxmj2SG2LMDqH4L51b8x4wIHJY /QLgFyNB8nAh8LvernTRnqWrDT3Tl1ajAlyNUCqgPP4uEWEjpNYi8zehya5Dsl/Vwl kpJjsGRc+AwdwHSaqssEiuG7K7mela9ADGew6VqRLY/XMmxxOb/oT/Z3G919mh+3be B0m8zGYy4DOdXKm9rCgEN9jrkmHwFqwBv81fG/cbcEe+YsFGMN1J+rnhinZxwa2Lrb FtEDubDtgJaqQ== 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 v7 15/49] media: verisilicon: g2: Use common helpers to compute chroma and mv offsets Date: Thu, 14 Sep 2023 15:32:49 +0200 Message-Id: <20230914133323.198857-16-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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, 14 Sep 2023 06:34:30 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777087298687430006 X-GMAIL-MSGID: 1777087298687430006 HEVC and VP9 are running on the same hardware and share the same chroma and motion vectors offset constraint. Create common helpers functions for these computation. Source and destination buffer height may not be the same because alignment constraint are different so use destination height to compute chroma offset because we target this buffer as hardware output. To be able to use the helpers in both VP9 HEVC code remove dec_params and use context->bit_depth instead. Signed-off-by: Benjamin Gaignard --- .../media/platform/verisilicon/hantro_g2.c | 14 ++++++++++ .../platform/verisilicon/hantro_g2_hevc_dec.c | 18 ++----------- .../platform/verisilicon/hantro_g2_vp9_dec.c | 26 +++---------------- .../media/platform/verisilicon/hantro_hw.h | 3 +++ 4 files changed, 23 insertions(+), 38 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_g2.c b/drivers/media/platform/verisilicon/hantro_g2.c index ee5f14c5f8f2..b880a6849d58 100644 --- a/drivers/media/platform/verisilicon/hantro_g2.c +++ b/drivers/media/platform/verisilicon/hantro_g2.c @@ -8,6 +8,8 @@ #include "hantro_hw.h" #include "hantro_g2_regs.h" +#define G2_ALIGN 16 + void hantro_g2_check_idle(struct hantro_dev *vpu) { int i; @@ -42,3 +44,15 @@ irqreturn_t hantro_g2_irq(int irq, void *dev_id) return IRQ_HANDLED; } + +size_t hantro_g2_chroma_offset(struct hantro_ctx *ctx) +{ + return ctx->dst_fmt.width * ctx->dst_fmt.height * ctx->bit_depth / 8; +} + +size_t hantro_g2_motion_vectors_offset(struct hantro_ctx *ctx) +{ + size_t cr_offset = hantro_g2_chroma_offset(ctx); + + return ALIGN((cr_offset * 3) / 2, G2_ALIGN); +} diff --git a/drivers/media/platform/verisilicon/hantro_g2_hevc_dec.c b/drivers/media/platform/verisilicon/hantro_g2_hevc_dec.c index a9d4ac84a8d8..d3f8c33eb16c 100644 --- a/drivers/media/platform/verisilicon/hantro_g2_hevc_dec.c +++ b/drivers/media/platform/verisilicon/hantro_g2_hevc_dec.c @@ -8,20 +8,6 @@ #include "hantro_hw.h" #include "hantro_g2_regs.h" -#define G2_ALIGN 16 - -static size_t hantro_hevc_chroma_offset(struct hantro_ctx *ctx) -{ - return ctx->dst_fmt.width * ctx->dst_fmt.height * ctx->bit_depth / 8; -} - -static size_t hantro_hevc_motion_vectors_offset(struct hantro_ctx *ctx) -{ - size_t cr_offset = hantro_hevc_chroma_offset(ctx); - - return ALIGN((cr_offset * 3) / 2, G2_ALIGN); -} - static void prepare_tile_info_buffer(struct hantro_ctx *ctx) { struct hantro_dev *vpu = ctx->dev; @@ -384,8 +370,8 @@ static int set_ref(struct hantro_ctx *ctx) struct hantro_dev *vpu = ctx->dev; struct vb2_v4l2_buffer *vb2_dst; struct hantro_decoded_buffer *dst; - size_t cr_offset = hantro_hevc_chroma_offset(ctx); - size_t mv_offset = hantro_hevc_motion_vectors_offset(ctx); + size_t cr_offset = hantro_g2_chroma_offset(ctx); + size_t mv_offset = hantro_g2_motion_vectors_offset(ctx); u32 max_ref_frames; u16 dpb_longterm_e; static const struct hantro_reg cur_poc[] = { diff --git a/drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c b/drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c index 6db1c32fce4d..342e543dee4c 100644 --- a/drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c +++ b/drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c @@ -16,8 +16,6 @@ #include "hantro_vp9.h" #include "hantro_g2_regs.h" -#define G2_ALIGN 16 - enum hantro_ref_frames { INTRA_FRAME = 0, LAST_FRAME = 1, @@ -90,22 +88,6 @@ static int start_prepare_run(struct hantro_ctx *ctx, const struct v4l2_ctrl_vp9_ return 0; } -static size_t chroma_offset(const struct hantro_ctx *ctx, - const struct v4l2_ctrl_vp9_frame *dec_params) -{ - int bytes_per_pixel = dec_params->bit_depth == 8 ? 1 : 2; - - return ctx->src_fmt.width * ctx->src_fmt.height * bytes_per_pixel; -} - -static size_t mv_offset(const struct hantro_ctx *ctx, - const struct v4l2_ctrl_vp9_frame *dec_params) -{ - size_t cr_offset = chroma_offset(ctx, dec_params); - - return ALIGN((cr_offset * 3) / 2, G2_ALIGN); -} - static struct hantro_decoded_buffer * get_ref_buf(struct hantro_ctx *ctx, struct vb2_v4l2_buffer *dst, u64 timestamp) { @@ -156,13 +138,13 @@ static void config_output(struct hantro_ctx *ctx, luma_addr = hantro_get_dec_buf_addr(ctx, &dst->base.vb.vb2_buf); hantro_write_addr(ctx->dev, G2_OUT_LUMA_ADDR, luma_addr); - chroma_addr = luma_addr + chroma_offset(ctx, dec_params); + chroma_addr = luma_addr + hantro_g2_chroma_offset(ctx); hantro_write_addr(ctx->dev, G2_OUT_CHROMA_ADDR, chroma_addr); - dst->vp9.chroma_offset = chroma_offset(ctx, dec_params); + dst->vp9.chroma_offset = hantro_g2_chroma_offset(ctx); - mv_addr = luma_addr + mv_offset(ctx, dec_params); + mv_addr = luma_addr + hantro_g2_motion_vectors_offset(ctx); hantro_write_addr(ctx->dev, G2_OUT_MV_ADDR, mv_addr); - dst->vp9.mv_offset = mv_offset(ctx, dec_params); + dst->vp9.mv_offset = hantro_g2_motion_vectors_offset(ctx); } struct hantro_vp9_ref_reg { diff --git a/drivers/media/platform/verisilicon/hantro_hw.h b/drivers/media/platform/verisilicon/hantro_hw.h index 292a76ef643e..9aec8a79acdc 100644 --- a/drivers/media/platform/verisilicon/hantro_hw.h +++ b/drivers/media/platform/verisilicon/hantro_hw.h @@ -521,6 +521,9 @@ hantro_av1_mv_size(unsigned int width, unsigned int height) return ALIGN(num_sbs * 384, 16) * 2 + 512; } +size_t hantro_g2_chroma_offset(struct hantro_ctx *ctx); +size_t hantro_g2_motion_vectors_offset(struct hantro_ctx *ctx); + int hantro_g1_mpeg2_dec_run(struct hantro_ctx *ctx); int rockchip_vpu2_mpeg2_dec_run(struct hantro_ctx *ctx); void hantro_mpeg2_dec_copy_qtable(u8 *qtable, From patchwork Thu Sep 14 13:32:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139697 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp481555vqi; Thu, 14 Sep 2023 09:45:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHg2v06vPXDKZAikHmvGzkFC+NJjyckcvg2lSYFimTOqKXBOo5IZhQjKVDmZ+LM5Hlj/BXP X-Received: by 2002:a05:6a21:78a5:b0:148:656b:9a1f with SMTP id bf37-20020a056a2178a500b00148656b9a1fmr7257357pzc.20.1694709948837; Thu, 14 Sep 2023 09:45:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694709948; cv=none; d=google.com; s=arc-20160816; b=f3QXsKO4lzIcfAFQnwdXWpPFH9N9VtQexDtSWtj9EPb/hVC4uiTeAGPjq2w3m3UgzY Tlf1AgHNvNW8blKVHckvxM3qKvZtr5xfFFbGYwFV9DhWa4LAcQiMjpIu0ToYvZal+2wI LghyKVrso3Q2E5SDmcHUxBv7iihQo5sbjUm4e7KJULtIwNRf5DC036UdcP2Q7yVFQlAy Gb0GgytT3IsXl0SjN11/lS+tw+iwu1ZV6htEB2Ju++URn7nd/AYZxJmgBhPTRKFohI8F SQ+BhZ8Z4LUpRtXxN3oMfUV/5TT/WF+iYEt0BMyt9AcKHwsY6MS71Sqae2VuBvXxPbWZ wSsw== 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=+motrr8z22DTdb1iWQP1XzvpLQL/6rTJbpaD47ZsBhs=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=VwUTB1s6LFDbs44Eu7rRZGnUEjGoFyG/fb9437JODYRGdJeFYDyUzUlsJJJjE56Pdi GVhU4IxV7ar8aHPpUjpTyqRy+a3LGBgz5fW+bCWZl+DcHFA+XNHCaBmG8bE/gRwx+k2m F7Ip9cx7IsdrZNTzxekM9/jOa8H7vD+HiBYiT4CGxlNkfLGWJwuTuVrRfSWMRKELUtn7 zfS/v7/jQ4Te5tzWEDbf7EULKyw+T0uq1t7TIvub5h6ndTGjjqWwliOezbmK8/QdgzXI a3AQXTw7I+a/MgKghHgDYBqBaThjT6GDt7KUisN6ekiKnzeUPOQf+ZlJjIKni+BAjWlo 32CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="JzNs/qqs"; 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 ct24-20020a056a000f9800b0068fb4842092si1864400pfb.183.2023.09.14.09.45.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 09:45:48 -0700 (PDT) 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="JzNs/qqs"; 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 7C0AA823CA21; Thu, 14 Sep 2023 06:35:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239510AbjINNeU (ORCPT + 35 others); Thu, 14 Sep 2023 09:34:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239217AbjINNdx (ORCPT ); Thu, 14 Sep 2023 09:33:53 -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 0187C1FEC; Thu, 14 Sep 2023 06:33:41 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 741D26607356; Thu, 14 Sep 2023 14:33:39 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698419; bh=jUystvUPhotVsWFQwzoEvrV6ekQradIDM/On3bu5eyU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JzNs/qqsuOQni5rFNh5FnwVhEdW6UACA0W7zv6lpXOMRQg1Zjd1cRRAJpq34lYOc3 HBwKx3EUT+Bku/VNGm5d7cI3oyJ2ymko6e5D+6mQYlsoALF715+ubY8rEz9dDvu6uI I4Kp0rZeMokBVw7fljsaXntHXQSXmvwVqKvcLhkMRk9J7PMtkCqd8x1ue/wiiWwjIn TKIVhVLQozr7frLJfPYZJyvVkG+mao4mrnKv4hmzhotqb+dRKrArJiTe5FAS0nDveN x9oVlJ1k4DtFsJV4VCLA4SWpRxqhTKKTZA+jp1fiE7aNYwj+TwYIDsMzlERoLEjZwG o6qPTSg3GjcQA== 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 v7 16/49] media: verisilicon: postproc: Fix down scale test Date: Thu, 14 Sep 2023 15:32:50 +0200 Message-Id: <20230914133323.198857-17-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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, 14 Sep 2023 06:35:33 -0700 (PDT) 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 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: 1777032179319917260 X-GMAIL-MSGID: 1777032179319917260 Do not allow down scaling if the source buffer resolution is smaller than destination one. Signed-off-by: Benjamin Gaignard Fixes: fbb6c848dd89 ("media: destage Hantro VPU driver") --- drivers/media/platform/verisilicon/hantro_postproc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/verisilicon/hantro_postproc.c b/drivers/media/platform/verisilicon/hantro_postproc.c index e624cd98f41b..77d8ecfbe12f 100644 --- a/drivers/media/platform/verisilicon/hantro_postproc.c +++ b/drivers/media/platform/verisilicon/hantro_postproc.c @@ -107,7 +107,7 @@ static void hantro_postproc_g1_enable(struct hantro_ctx *ctx) static int down_scale_factor(struct hantro_ctx *ctx) { - if (ctx->src_fmt.width == ctx->dst_fmt.width) + if (ctx->src_fmt.width <= ctx->dst_fmt.width) return 0; return DIV_ROUND_CLOSEST(ctx->src_fmt.width, ctx->dst_fmt.width); From patchwork Thu Sep 14 13:32:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139646 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp432581vqi; Thu, 14 Sep 2023 08:31:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG1n2ibRzZjD+mL5GEbxP28KwzEHpzQ53NfWogBQgxcPyR8cXK/CYUwpXRm87MPSoDvfpI4 X-Received: by 2002:a17:903:22c7:b0:1c3:4073:bf80 with SMTP id y7-20020a17090322c700b001c34073bf80mr6539797plg.0.1694705477092; Thu, 14 Sep 2023 08:31:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694705477; cv=none; d=google.com; s=arc-20160816; b=wO8ZAip3i4f4eGgWrXaloloXEt6fQkA3kbBMyWPnjEiloJOy7pgWaFvrmpsdSdybqA s2CVntJtLxKxFGjcHoXfP+u7kil80WsGnOuwiBLReTuXMBP/nLxzbNSqAlxOtVQGjx3T Jajl8RCUv2f9eCjEDWKQj75aKhrAFlx1fqSfdcGdKkJ1gqYt+72sX/HSBAnapKOA1I2u TruXf7O4r1OV9Jo8EJnsK7j1Du0xe846xjHc04pOBQU3DFhuFWP/k28+yqKErKATPYsV tRn+s7nWIuF3k9NQBgb/xHmeLm1abni9CcJGBJlXIuZS6TVb0xApHgCVwRqzfCzJLz4n Z5MA== 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=HeFU4iirMD/C8zAnnLuvVsqExwwX9oyU662qIGcGqiA=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=ePs46dLM7ZRTibX6R65k4hxZdIg5GBHgbPupT1VJE4pU/5NYCAAAY2z4AYLF/cScfS K3wcFz2yNbuzzFUuzCQMlO8xVale5GCdJqJGJ40dxBhDG2i85uAZChTAzRg5na8UI93p PR2JRcD9xKu4gURYOSHH1WAlLeLDrGWolmiQ6VuCuO4JgwEO3tB/S8jdqIPWspDCO2do hYvYzzlCZ7nbaNlPjQ9jJWz6FnM83nIBjuyBdLfvULSb4P2oIrlAAmC2gQfDK8/OZKLe NW4IVnvbqKNXM/xWWbod/RHxOFSXTZFowJ3XXpCkBWy624ciB6hl59ttt5Cb83Rv5iEb x4fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=G4xnHH0K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id s10-20020a65584a000000b0057777451a5csi1718359pgr.374.2023.09.14.08.31.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 08:31:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=G4xnHH0K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 192B481E64B7; Thu, 14 Sep 2023 06:34:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239530AbjINNe0 (ORCPT + 35 others); Thu, 14 Sep 2023 09:34:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239216AbjINNdx (ORCPT ); Thu, 14 Sep 2023 09:33:53 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A0FD1FEE; Thu, 14 Sep 2023 06:33:41 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 0044F660736E; Thu, 14 Sep 2023 14:33:39 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698420; bh=WDraZOgWi0izES0K9FdWnGrtWWF6tf7zOBBP/EoWBNg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G4xnHH0KcQzrC++tnJyG3so3XikK6AMopnyr12kJ1wAl7ovGny4ZMEhuefe8pv1tH 4DdUp/W7t5x3xMd+04fSvwy9n8XsNYY+dt0PnD/c8Y2QDnAC0nHQCguxOz9ZvDgZlK 3xjag9k+Y6F6gST25smLN5FawKJk6JX5CSqJt124SX2S9xCgNlE8jxnXKJf0HYey7q TlazMshotZRaBXptW8QO+fqiJw4dTFH60pdgdtlQLLMjBat/nTHqLs8nnHcdFakSh/ gxf6fVrWpSVksVC3jYOcDCSHfT96Nj2MNctttv9owfpV/YwmJ+4FU3Qml9jSWMZ012 Tcq5AJnNGkAyQ== 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 v7 17/49] media: verisilicon: vp9: Allow to change resolution while streaming Date: Thu, 14 Sep 2023 15:32:51 +0200 Message-Id: <20230914133323.198857-18-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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, 14 Sep 2023 06:34:34 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777027489923522989 X-GMAIL-MSGID: 1777027489923522989 Remove all checks that prohibit to set a new format while streaming. This allow to change dynamically the resolution if the pixel format remains the same. Signed-off-by: Benjamin Gaignard --- .../media/platform/verisilicon/hantro_v4l2.c | 24 +++---------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/media/platform/verisilicon/hantro_v4l2.c index f0d8b165abcd..27a1e77cca38 100644 --- a/drivers/media/platform/verisilicon/hantro_v4l2.c +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c @@ -514,25 +514,14 @@ static int hantro_set_fmt_out(struct hantro_ctx *ctx, return ret; if (!ctx->is_encoder) { - struct vb2_queue *peer_vq; - /* * In order to support dynamic resolution change, * the decoder admits a resolution change, as long - * as the pixelformat remains. Can't be done if streaming. - */ - if (vb2_is_streaming(vq) || (vb2_is_busy(vq) && - pix_mp->pixelformat != ctx->src_fmt.pixelformat)) - return -EBUSY; - /* - * Since format change on the OUTPUT queue will reset - * the CAPTURE queue, we can't allow doing so - * when the CAPTURE queue has buffers allocated. + * as the pixelformat remains. */ - peer_vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, - V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); - if (vb2_is_busy(peer_vq)) + if (vb2_is_streaming(vq) && pix_mp->pixelformat != ctx->src_fmt.pixelformat) { return -EBUSY; + } } else { /* * The encoder doesn't admit a format change if @@ -577,15 +566,8 @@ static int hantro_set_fmt_out(struct hantro_ctx *ctx, static int hantro_set_fmt_cap(struct hantro_ctx *ctx, struct v4l2_pix_format_mplane *pix_mp) { - struct vb2_queue *vq; int ret; - /* Change not allowed if queue is busy. */ - vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, - V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); - if (vb2_is_busy(vq)) - return -EBUSY; - if (ctx->is_encoder) { struct vb2_queue *peer_vq; From patchwork Thu Sep 14 13:32: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: 139692 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp477582vqi; Thu, 14 Sep 2023 09:38:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH0OyKhqpl5OvSZjqVRqQZHh8rutAIxQEBz5kDPUB9QUj0XOVE96Nv3OtPIJHXZqKJnl30/ X-Received: by 2002:a05:6a20:2451:b0:158:1ade:8661 with SMTP id t17-20020a056a20245100b001581ade8661mr5217854pzc.18.1694709526251; Thu, 14 Sep 2023 09:38:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694709526; cv=none; d=google.com; s=arc-20160816; b=yptBzWoUgxQtDKsvea4B8o6fvFfMqO4r3r0DOxq2kG6wTZ0c0bBy9uGz7TG68/naFt ewSun5A8RCEJZFZpzrlmPXOodNXAMVYPcLt1xZjACfH+FW0ESFHjDYFHbskGD2qwzzaC 7RnOKzufbBlJUcoqvIWFH60Ax/WNbrnbbdRBpamdWm2NJ1OJICTd90FODW//xp0YHlf9 P+P4wGoWOXQYkUopoJZULbNgk+LdD9azzPs8a1KgSRYby+2VqZdIvUiYkSBm8Du6GQAr 3f2il/zRHEz7Bx/PghrQJpcznaMJ5q1h2GkvhOyVdXt267oaoq0nq7kJoLXyVuLgQ8NW 2hqw== 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=trr6491blVoX824BIpm3hJQQxxk/3K9MVWaQdjKCKgA=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=ffp9KtO+ngkkrpJU8L6SxB8lcQKpyX6X8SAoxwAIKJmWeSA8WC2UTcqy45GVGD4XE3 vBmACKADmP6P0Kbf3NUEeNg/eLwtEMMvKXf/hkSTu+aUZyd34lXD8H3eip+jYr1XtJVc mmaCEmhCP23PiLk/pAbqUjFPhZgnSwMGo3AdjnOoouVx8CPNpEEvFaw8d8LT1phij041 pMYXvEKznjN1NyReMn7pCatK5qkYQXIWMtfQrAX3MjvWRNu5Ugeku9Fl7O3r71HIGDoG Z+VRxhGuDnsNaBROgw1mLKkZe6/izNH7oAyXy9TTV4/CDFuX8+AANTQ5H/HE8I6xfTn3 KJ/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=jEyKLGVx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id ei52-20020a056a0080f400b0068fdb060072si1808965pfb.341.2023.09.14.09.38.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 09:38:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=jEyKLGVx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id A1BC9807614B; Thu, 14 Sep 2023 06:36:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239516AbjINNeY (ORCPT + 35 others); Thu, 14 Sep 2023 09:34:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239222AbjINNdy (ORCPT ); Thu, 14 Sep 2023 09:33:54 -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 0F68D1BF8; Thu, 14 Sep 2023 06:33:42 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 81ACF660734B; Thu, 14 Sep 2023 14:33:40 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698420; bh=orO42HgJZVmG5GsbDRr5p5aAYmAqR4f3jKdoimxCmR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jEyKLGVxdNGIKeLMpz746kqo6Ve+WUl2NaNIpmLz08Xw4NXo6f3Gc+8JDHzt45sC2 BxamcwujM4l70xCIk0N+RjcA65h0NI4FnWqOfvPckyIa/R1SjIh63Xy8JkCtBmE6Tu tU9B8pJSm6Zvp/xCBnWU6IGAeUCRisISM8Xm57/PKT2jCAkgJEQBYAqoGqwVDKM1th EgcCyrb4S5gGIgS3P1306A7+0y6a03yUgJDstwdbiiD5DxZpwfNAQ8+Q+BLo6Z3acQ +VWLGLVn7lS+vvmwKPDhFceFJ9UjZeioznviCP+ph00kMU2B/MBXVeSgJnjAVw4YWV GQc8A6hsuyc4Q== 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 v7 18/49] media: Remove duplicated index vs q->num_buffers check Date: Thu, 14 Sep 2023 15:32:52 +0200 Message-Id: <20230914133323.198857-19-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (pete.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:36:01 -0700 (PDT) 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777031736433981430 X-GMAIL-MSGID: 1777031736433981430 vb2_get_buffer() already check if the requested index is valid. Stop duplicating this kind of check everywhere. Signed-off-by: Benjamin Gaignard --- drivers/media/common/videobuf2/videobuf2-core.c | 8 ++++++++ drivers/media/common/videobuf2/videobuf2-v4l2.c | 13 ------------- include/media/videobuf2-core.h | 8 +------- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index ee4df7c68397..2add7a6795e7 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -660,6 +660,14 @@ static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) } } +struct vb2_buffer *vb2_get_buffer(struct vb2_queue *q, unsigned int index) +{ + if (index < q->num_buffers) + return q->bufs[index]; + return NULL; +} +EXPORT_SYMBOL_GPL(vb2_get_buffer); + bool vb2_buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb) { unsigned int plane; diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index 87c2d5916960..f10b70d8e66a 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -378,11 +378,6 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct media_device *md return -EINVAL; } - if (b->index >= q->num_buffers) { - dprintk(q, 1, "%s: buffer index out of range\n", opname); - return -EINVAL; - } - vb = vb2_get_buffer(q, b->index); if (!vb) { dprintk(q, 1, "%s: buffer is NULL\n", opname); @@ -829,10 +824,6 @@ int vb2_qbuf(struct vb2_queue *q, struct media_device *mdev, return -EBUSY; } - if (b->index >= q->num_buffers) { - dprintk(q, 1, "buffer index out of range\n"); - return -EINVAL; - } vb = vb2_get_buffer(q, b->index); if (!vb) { dprintk(q, 1, "can't find the requested buffer\n"); @@ -904,10 +895,6 @@ int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb) { struct vb2_buffer *vb; - if (eb->index >= q->num_buffers) { - dprintk(q, 1, "buffer index out of range\n"); - return -EINVAL; - } vb = vb2_get_buffer(q, eb->index); if (!vb) { dprintk(q, 1, "can't find the requested buffer\n"); diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 97153c69583f..25ca395616a7 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -1238,13 +1238,7 @@ static inline void vb2_clear_last_buffer_dequeued(struct vb2_queue *q) * operation, so the buffer lifetime should be taken into * consideration. */ -static inline struct vb2_buffer *vb2_get_buffer(struct vb2_queue *q, - unsigned int index) -{ - if (index < q->num_buffers) - return q->bufs[index]; - return NULL; -} +struct vb2_buffer *vb2_get_buffer(struct vb2_queue *q, unsigned int index); /* * The following functions are not part of the vb2 core API, but are useful From patchwork Thu Sep 14 13:32:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139801 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp575122vqi; Thu, 14 Sep 2023 12:27:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHCIaPx6Z4zMswX7oPfD0hM9Tp/g8gc44xELYzKEkG7VP0OFqin/Ey2BKWXmKYv186Fnu+q X-Received: by 2002:a17:90a:5908:b0:26f:4685:5b6c with SMTP id k8-20020a17090a590800b0026f46855b6cmr3880008pji.19.1694719629038; Thu, 14 Sep 2023 12:27:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694719629; cv=none; d=google.com; s=arc-20160816; b=nsLoGqUeHtfdTCPa5bDs59dAoMmHn1O5ALLcDbeA0jgTxVzEYtEIwRz5qEXme4DXyr RX0CJ+mCyo/aaDaBx7LlWIvGJMo549Mjd4dqH+Ck/E7bkkjPXlcMxrxP+xJ12fXAtzmI EW3SqHphTxXG9kXWHvLN0Op8KK0HIhckUVvgRv19gxli+aCMGt2k6FGsq3iNlc0XRjQm AKbam+3IIrDtxwyMg63CULnjrn5uHKJ7LdL0az5pduqIjW+POgwTht/2gP203blvjFEG W+Yo8DL2Uinq7KHzo7IFWKkXWk10OANPYR/o/48wfpi8GBBf4fo0X2Xdg+4M5K2o++6R j+nw== 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=dWKguaSsDnPZ6H7CtHJJ9aIZr3kmG6tkzWLEqwr1BA8=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=TWnYCdMzd44Vu79s/qcFp/S8kvjxSTxNRiPp/cHtxPQVNXBYUeU1fPBk/+BTm0LG59 brU8f2r1a9c8uI7nFp2XHVak6B7uTRrZhNJf9bOdNHM2kkuOov7Wwzb7q+MPWunXLW9r oK4aGBSfCdmoeXbSoJomxmDgkaDutejMFrHl9FMLVpgfxK06r5hRyVIV1u6MGNL2Ohg7 tuf1KoQB/CNsydRdc/vsEaMBEjONh5K9u46JyVPK+6br5OBiu13qut+NpCpyydQe0vOj gn3v8hi7Oye5FPTxuBq/iA871yQEubBwYYU1ohwmWS2mVPAE1m60nDYxnYlLOlR47LL2 Q80Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Rg9QR21I; 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 gw2-20020a17090b0a4200b0027496c60f08si80923pjb.123.2023.09.14.12.27.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 12:27:09 -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=Rg9QR21I; 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 B83158523B7E; Thu, 14 Sep 2023 06:34:37 -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 S239542AbjINNe1 (ORCPT + 35 others); Thu, 14 Sep 2023 09:34:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239146AbjINNdy (ORCPT ); Thu, 14 Sep 2023 09:33:54 -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 8BD631FF3; Thu, 14 Sep 2023 06:33:42 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 0C8776607351; Thu, 14 Sep 2023 14:33:41 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698421; bh=enV9pDhcp1Z0UVfIfyTNJ0WIR0t4rBIWrJ083Dj0cuc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rg9QR21IbwDz459/FHLHTuQq3SRTy9DBiqYaIqfI5AlY8HdTtoojyAUFSDFHongx2 cBR918meFXwS8+auBnjkhjNiOEDa3N+sgreI/oUXMaBhC3JGWrzEMsqg8MrRaH7hP0 2UgVjrA9vjEywQe8kyC5LZk6GhVT8ApOAVGRoiSm6kvSLmQCOx5qhbmLcJonKBzWr3 NggznkCZJWDy4D3er912KF4zXjLmTyx60j7jRHpfFe5go53QpxUdz4dSJ6jw29nBS8 yuWoFQZlNeXZnR71zf98szGjSmtQ+1FTZjXlHldZsXYF4bzyS7b6CvonnKIraI7vej z2cL2wQrglq1Q== 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 v7 19/49] media: core: Add helper to get queue number of buffers Date: Thu, 14 Sep 2023 15:32:53 +0200 Message-Id: <20230914133323.198857-20-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (howler.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:34:37 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777042329997085785 X-GMAIL-MSGID: 1777042329997085785 In the future a side effect of introducing DELETE_BUFS ioctl is the create of 'holes' (i.e. unused buffers) in bufs arrays. To know which entries of the bufs arrays are used a bitmap will be added in struct vb2_queue. That will also mean that the number of buffers will be computed given the number of bit set in this bitmap. To smoothly allow this evolution all drives must stop using directly num_buffers field from struct vb2_queue. Let do it in 4 steps: - Introduce vb2_get_num_buffers() helper - Rework how create_bufs first buffer index is computed - Rework all drivers to remove direct calls to queue num_buffers - Replace num_buffers by a bitmap. Signed-off-by: Benjamin Gaignard --- .../media/common/videobuf2/videobuf2-core.c | 110 ++++++++++-------- .../media/common/videobuf2/videobuf2-v4l2.c | 2 +- include/media/videobuf2-core.h | 6 + 3 files changed, 70 insertions(+), 48 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 2add7a6795e7..70b6b8f8c390 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -517,12 +517,12 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory, */ static void __vb2_free_mem(struct vb2_queue *q, unsigned int buffers) { - unsigned int buffer; + unsigned int buffer = 0; + long i = q->max_allowed_buffers; struct vb2_buffer *vb; - for (buffer = q->num_buffers - buffers; buffer < q->num_buffers; - ++buffer) { - vb = vb2_get_buffer(q, buffer); + for (i = q->max_allowed_buffers; i >= 0 && buffer < buffers; i--) { + vb = vb2_get_buffer(q, i); if (!vb) continue; @@ -533,6 +533,7 @@ static void __vb2_free_mem(struct vb2_queue *q, unsigned int buffers) __vb2_buf_dmabuf_put(vb); else __vb2_buf_userptr_put(vb); + buffer++; } } @@ -544,16 +545,20 @@ static void __vb2_free_mem(struct vb2_queue *q, unsigned int buffers) static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) { unsigned int buffer; + long i = q->max_allowed_buffers; lockdep_assert_held(&q->mmap_lock); /* Call driver-provided cleanup function for each buffer, if provided */ - for (buffer = q->num_buffers - buffers; buffer < q->num_buffers; - ++buffer) { - struct vb2_buffer *vb = vb2_get_buffer(q, buffer); + for (i = q->max_allowed_buffers, buffer = 0; i >= 0 && buffer < buffers; i--) { + struct vb2_buffer *vb = vb2_get_buffer(q, i); - if (vb && vb->planes[0].mem_priv) + if (!vb) + continue; + if (vb->planes[0].mem_priv) { call_void_vb_qop(vb, buf_cleanup, vb); + buffer++; + } } /* Release video buffer memory */ @@ -564,7 +569,7 @@ static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) * Check that all the calls were balances during the life-time of this * queue. If not then dump the counters to the kernel log. */ - if (q->num_buffers) { + if (vb2_get_num_buffers(q)) { bool unbalanced = q->cnt_start_streaming != q->cnt_stop_streaming || q->cnt_prepare_streaming != q->cnt_unprepare_streaming || q->cnt_wait_prepare != q->cnt_wait_finish; @@ -590,7 +595,7 @@ static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) q->cnt_stop_streaming = 0; q->cnt_unprepare_streaming = 0; } - for (buffer = 0; buffer < q->num_buffers; ++buffer) { + for (buffer = 0; buffer < q->max_allowed_buffers; buffer++) { struct vb2_buffer *vb = vb2_get_buffer(q, buffer); bool unbalanced; @@ -642,8 +647,7 @@ static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) #endif /* Free vb2 buffers */ - for (buffer = q->num_buffers - buffers; buffer < q->num_buffers; - ++buffer) { + for (i = q->max_allowed_buffers, buffer = 0; i > 0 && buffer < buffers; i--) { struct vb2_buffer *vb = vb2_get_buffer(q, buffer); if (!vb) @@ -651,10 +655,10 @@ static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) vb2_queue_remove_buffer(q, vb); kfree(vb); + buffer++; } - q->num_buffers -= buffers; - if (!q->num_buffers) { + if (!vb2_get_num_buffers(q)) { q->memory = VB2_MEMORY_UNKNOWN; INIT_LIST_HEAD(&q->queued_list); } @@ -668,6 +672,12 @@ struct vb2_buffer *vb2_get_buffer(struct vb2_queue *q, unsigned int index) } EXPORT_SYMBOL_GPL(vb2_get_buffer); +unsigned int vb2_get_num_buffers(struct vb2_queue *q) +{ + return q->num_buffers; +} +EXPORT_SYMBOL_GPL(vb2_get_num_buffers); + bool vb2_buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb) { unsigned int plane; @@ -693,7 +703,7 @@ EXPORT_SYMBOL(vb2_buffer_in_use); static bool __buffers_in_use(struct vb2_queue *q) { unsigned int buffer; - for (buffer = 0; buffer < q->num_buffers; ++buffer) { + for (buffer = 0; buffer < q->max_allowed_buffers; ++buffer) { struct vb2_buffer *vb = vb2_get_buffer(q, buffer); if (!vb) @@ -819,6 +829,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, unsigned int flags, unsigned int *count) { unsigned int num_buffers, allocated_buffers, num_planes = 0; + unsigned int q_num_bufs = vb2_get_num_buffers(q); unsigned plane_sizes[VB2_MAX_PLANES] = { }; bool non_coherent_mem = flags & V4L2_MEMORY_FLAG_NON_COHERENT; unsigned int i; @@ -834,7 +845,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, return -EBUSY; } - if (*count == 0 || q->num_buffers != 0 || + if (*count == 0 || q_num_bufs != 0 || (q->memory != VB2_MEMORY_UNKNOWN && q->memory != memory) || !verify_coherency_flags(q, non_coherent_mem)) { /* @@ -852,7 +863,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, * queued without ever calling STREAMON. */ __vb2_queue_cancel(q); - __vb2_queue_free(q, q->num_buffers); + __vb2_queue_free(q, q_num_bufs); mutex_unlock(&q->mmap_lock); /* @@ -953,7 +964,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, if (ret < 0) { /* * Note: __vb2_queue_free() will subtract 'allocated_buffers' - * from q->num_buffers and it will reset q->memory to + * from already queued buffers and it will reset q->memory to * VB2_MEMORY_UNKNOWN. */ __vb2_queue_free(q, allocated_buffers); @@ -987,10 +998,11 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, unsigned int num_planes = 0, num_buffers, allocated_buffers; unsigned plane_sizes[VB2_MAX_PLANES] = { }; bool non_coherent_mem = flags & V4L2_MEMORY_FLAG_NON_COHERENT; - bool no_previous_buffers = !q->num_buffers; + unsigned int q_num_bufs = vb2_get_num_buffers(q); + bool no_previous_buffers = !q_num_bufs; int ret = 0; - if (q->num_buffers == q->max_allowed_buffers) { + if (q_num_bufs == q->max_allowed_buffers) { dprintk(q, 1, "maximum number of buffers already allocated\n"); return -ENOBUFS; } @@ -1025,7 +1037,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, return -EINVAL; } - num_buffers = min(*count, q->max_allowed_buffers - q->num_buffers); + num_buffers = min(*count, q->max_allowed_buffers - q_num_bufs); if (requested_planes && requested_sizes) { num_planes = requested_planes; @@ -1057,7 +1069,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, num_buffers = allocated_buffers; /* - * q->num_buffers contains the total number of buffers, that the + * num_buffers contains the total number of buffers, that the * queue driver has set up */ ret = call_qop(q, queue_setup, q, &num_buffers, @@ -1078,7 +1090,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, if (ret < 0) { /* * Note: __vb2_queue_free() will subtract 'allocated_buffers' - * from q->num_buffers and it will reset q->memory to + * from already queued buffers and it will reset q->memory to * VB2_MEMORY_UNKNOWN. */ __vb2_queue_free(q, allocated_buffers); @@ -1695,7 +1707,7 @@ static int vb2_start_streaming(struct vb2_queue *q) * Forcefully reclaim buffers if the driver did not * correctly return them to vb2. */ - for (i = 0; i < q->num_buffers; ++i) { + for (i = 0; i < q->max_allowed_buffers; ++i) { vb = vb2_get_buffer(q, i); if (!vb) @@ -2101,9 +2113,8 @@ static void __vb2_queue_cancel(struct vb2_queue *q) * to vb2 in stop_streaming(). */ if (WARN_ON(atomic_read(&q->owned_by_drv_count))) { - for (i = 0; i < q->num_buffers; ++i) { + for (i = 0; i < q->max_allowed_buffers; i++) { struct vb2_buffer *vb = vb2_get_buffer(q, i); - if (!vb) continue; @@ -2145,10 +2156,9 @@ static void __vb2_queue_cancel(struct vb2_queue *q) * call to __fill_user_buffer() after buf_finish(). That order can't * be changed, so we can't move the buf_finish() to __vb2_dqbuf(). */ - for (i = 0; i < q->num_buffers; ++i) { + for (i = 0; i < q->max_allowed_buffers; i++) { struct vb2_buffer *vb; struct media_request *req; - vb = vb2_get_buffer(q, i); if (!vb) continue; @@ -2193,6 +2203,7 @@ static void __vb2_queue_cancel(struct vb2_queue *q) int vb2_core_streamon(struct vb2_queue *q, unsigned int type) { + unsigned int q_num_bufs = vb2_get_num_buffers(q); int ret; if (type != q->type) { @@ -2205,12 +2216,12 @@ int vb2_core_streamon(struct vb2_queue *q, unsigned int type) return 0; } - if (!q->num_buffers) { + if (!q_num_bufs) { dprintk(q, 1, "no buffers have been allocated\n"); return -EINVAL; } - if (q->num_buffers < q->min_buffers_needed) { + if (q_num_bufs < q->min_buffers_needed) { dprintk(q, 1, "need at least %u allocated buffers\n", q->min_buffers_needed); return -EINVAL; @@ -2564,7 +2575,7 @@ void vb2_core_queue_release(struct vb2_queue *q) __vb2_cleanup_fileio(q); __vb2_queue_cancel(q); mutex_lock(&q->mmap_lock); - __vb2_queue_free(q, q->num_buffers); + __vb2_queue_free(q, q->max_allowed_buffers); kfree(q->bufs); q->bufs = NULL; mutex_unlock(&q->mmap_lock); @@ -2595,7 +2606,7 @@ __poll_t vb2_core_poll(struct vb2_queue *q, struct file *file, /* * Start file I/O emulator only if streaming API has not been used yet. */ - if (q->num_buffers == 0 && !vb2_fileio_is_active(q)) { + if (vb2_get_num_buffers(q) == 0 && !vb2_fileio_is_active(q)) { if (!q->is_output && (q->io_modes & VB2_READ) && (req_events & (EPOLLIN | EPOLLRDNORM))) { if (__vb2_init_fileio(q, 1)) @@ -2633,7 +2644,7 @@ __poll_t vb2_core_poll(struct vb2_queue *q, struct file *file, * For output streams you can call write() as long as there are fewer * buffers queued than there are buffers available. */ - if (q->is_output && q->fileio && q->queued_count < q->num_buffers) + if (q->is_output && q->fileio && q->queued_count < vb2_get_num_buffers(q)) return EPOLLOUT | EPOLLWRNORM; if (list_empty(&q->done_list)) { @@ -2682,8 +2693,8 @@ struct vb2_fileio_buf { * struct vb2_fileio_data - queue context used by file io emulator * * @cur_index: the index of the buffer currently being read from or - * written to. If equal to q->num_buffers then a new buffer - * must be dequeued. + * written to. If equal to number of already queues buffers + * then a new buffer must be dequeued. * @initial_index: in the read() case all buffers are queued up immediately * in __vb2_init_fileio() and __vb2_perform_fileio() just cycles * buffers. However, in the write() case no buffers are initially @@ -2693,7 +2704,7 @@ struct vb2_fileio_buf { * buffers. This means that initially __vb2_perform_fileio() * needs to know what buffer index to use when it is queuing up * the buffers for the first time. That initial index is stored - * in this field. Once it is equal to q->num_buffers all + * in this field. Once it is equal to num_buffers all * available buffers have been queued and __vb2_perform_fileio() * should start the normal dequeue/queue cycle. * @@ -2743,7 +2754,7 @@ static int __vb2_init_fileio(struct vb2_queue *q, int read) /* * Check if streaming api has not been already activated. */ - if (q->streaming || q->num_buffers > 0) + if (q->streaming || vb2_get_num_buffers(q) > 0) return -EBUSY; /* @@ -2793,7 +2804,7 @@ static int __vb2_init_fileio(struct vb2_queue *q, int read) /* * Get kernel address of each buffer. */ - for (i = 0; i < q->num_buffers; i++) { + for (i = 0; i < q->max_allowed_buffers; i++) { vb = vb2_get_buffer(q, i); if (!vb) @@ -2814,18 +2825,23 @@ static int __vb2_init_fileio(struct vb2_queue *q, int read) /* * Queue all buffers. */ - for (i = 0; i < q->num_buffers; i++) { - ret = vb2_core_qbuf(q, q->bufs[i], NULL, NULL); + for (i = 0; i < q->max_allowed_buffers; i++) { + struct vb2_buffer *vb2 = vb2_get_buffer(q, i); + + if (!vb2) + continue; + + ret = vb2_core_qbuf(q, vb2, NULL, NULL); if (ret) goto err_reqbufs; fileio->bufs[i].queued = 1; } /* * All buffers have been queued, so mark that by setting - * initial_index to q->num_buffers + * initial_index to num_buffers */ - fileio->initial_index = q->num_buffers; - fileio->cur_index = q->num_buffers; + fileio->initial_index = vb2_get_num_buffers(q); + fileio->cur_index = fileio->initial_index; } /* @@ -3023,12 +3039,12 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ * If we are queuing up buffers for the first time, then * increase initial_index by one. */ - if (fileio->initial_index < q->num_buffers) + if (fileio->initial_index < vb2_get_num_buffers(q)) fileio->initial_index++; /* * The next buffer to use is either a buffer that's going to be - * queued for the first time (initial_index < q->num_buffers) - * or it is equal to q->num_buffers, meaning that the next + * queued for the first time (initial_index < num_buffers) + * or it is equal to num_buffers, meaning that the next * time we need to dequeue a buffer since we've now queued up * all the 'first time' buffers. */ @@ -3075,7 +3091,7 @@ static int vb2_thread(void *data) int ret = 0; if (q->is_output) { - prequeue = q->num_buffers; + prequeue = vb2_get_num_buffers(q); copy_timestamp = q->copy_timestamp; } diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index f10b70d8e66a..3eb707abc26b 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -628,7 +628,7 @@ struct vb2_buffer *vb2_find_buffer(struct vb2_queue *q, u64 timestamp) * This loop doesn't scale if there is a really large number of buffers. * Maybe something more efficient will be needed in this case. */ - for (i = 0; i < q->num_buffers; i++) { + for (i = 0; i < q->max_allowed_buffers; i++) { vb2 = vb2_get_buffer(q, i); if (!vb2) diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 25ca395616a7..1ecaf4b5a76f 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -1240,6 +1240,12 @@ static inline void vb2_clear_last_buffer_dequeued(struct vb2_queue *q) */ struct vb2_buffer *vb2_get_buffer(struct vb2_queue *q, unsigned int index); +/** + * vb2_get_num_buffers() - get the number of buffer in a queue + * @q: pointer to &struct vb2_queue with videobuf2 queue. + */ +unsigned int vb2_get_num_buffers(struct vb2_queue *q); + /* * The following functions are not part of the vb2 core API, but are useful * functions for videobuf2-*. From patchwork Thu Sep 14 13:32:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 140657 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1289004vqi; Fri, 15 Sep 2023 13:03:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFD++zkbQIyIYU5/yla+II9YWCkQKwjusAfCJiUUi/9YuF3Ngg7w5+isLEcIKgo6KF67fia X-Received: by 2002:a05:6a20:938a:b0:154:d3ac:2076 with SMTP id x10-20020a056a20938a00b00154d3ac2076mr3094535pzh.40.1694808186194; Fri, 15 Sep 2023 13:03:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694808186; cv=none; d=google.com; s=arc-20160816; b=bCHtJbkfN8sw8lTThUrGb29b1cYAGMmjihG0LqEtvOfSNnlaoTNy3Vca5mxUwvr+H1 wum9VT3vNR27qElDXs4tOqAlVnsXOyKUFRjZ7NMcwdWFxtayZZp/1w1guYnvKgCdTcXr FJORWgvsKDy0ziwPFgyDqxJ/zv6G2zOHfZDN0ULygoY5kDk9khkueIqs7J84geiPvZAK 3x1ImbcVpkqihsUdahBLrKz9PrzdT64RerNvbmeO9vuFYS1X8uksNwSqRVd9MVI8dyYn hzriG1UBD0T6947LqfLFQNPgbaB27Xl92ct9RuSa8AoqPIVRXbmGxBqruuKQypFSX4H6 cK4Q== 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=cW3CZ4EMZFdcIArMc1UZzyl1xzRDswQCZFSYn76zF9Y=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=NhzYmZ86VkXDKZBQQ1e3cWqjbW6N+ek9L8EqU5tDzJs4gsf7/3Dxi8llkwNCu/vlaj ZRgOIkwg2oRImEQTnvHeQqFOEXKmBMemhJp6g91l0OIspJ/07l7utnrk0XLsjFCdTAEf Bm6n55gICfhYGn4d05IzNS+wWJbS4KQ7N9f7qDsUqiwUpfaxVlbbUPvihfF4bLzN19UA 4H8oQ6BbZYVqRwDLF0JsIKXc/azFeGgB5fYn8qNtPR4J8wHs4bJobPBO7IorwWdtEuOt EFai+fiGig4n7uo8JgDouM/WWS/+uNzFMb0pSb5KO0j1Ga0XPZ9mGEu7vddwpgIU4EBd Pmgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=GdQnQbJu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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. [23.128.96.34]) by mx.google.com with ESMTPS id br14-20020a056a00440e00b0068e4debbe12si3662614pfb.371.2023.09.15.13.03.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 13:03:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=GdQnQbJu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 729B185A0DC4; Thu, 14 Sep 2023 06:34:43 -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 S239346AbjINNef (ORCPT + 35 others); Thu, 14 Sep 2023 09:34:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239238AbjINNdy (ORCPT ); Thu, 14 Sep 2023 09:33:54 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12FD81FF5; Thu, 14 Sep 2023 06:33:43 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 8B135660734C; Thu, 14 Sep 2023 14:33:41 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698421; bh=7x867ZfqHQqhXPyNmSFRaDH8opre7DuC4FUIzZAO/WQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GdQnQbJuWVL1ew4PeNCcLGkhPZK9/H2LQMr1qPcDacu9i/3VHU1wCWs21j/GHeMiy /30zHx5qfcqxNwmwU93gGkXcsNu8SljEr+ayUCh9VS4e7msEX1iD0+awolPLJc1cRZ Sn7jFb8xJG5/zaOsZ3oXNEFyd7dha/uMCUWU3YGVhTp71S1Vi3Qgsu/XVkWMwT6OyW 33luLO0aUPEzgoLPs74rFGBwKVe+a5/WnN5iBPLpUZMPqSRNuOcuNqAmCKsTfgdRtj XOmapZYKN4t8XDc9rv04HC3J8R03b9D1Y7vLBoBc26FBqJxwOWpKx7ikhuMeefi8z7 K0C+uhIblKgpA== 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 v7 20/49] media: core: Rework how create_buf index returned value is computed Date: Thu, 14 Sep 2023 15:32:54 +0200 Message-Id: <20230914133323.198857-21-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (howler.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:34:43 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777135188748756155 X-GMAIL-MSGID: 1777135188748756155 When DELETE_BUFS will be introduced holes could created in bufs array. To be able to reuse these unused indices reworking how create->index is set is mandatory. Let __vb2_queue_alloc() decide which first index is correct and forward this to the caller. Signed-off-by: Benjamin Gaignard --- .../media/common/videobuf2/videobuf2-core.c | 24 +++++++++++++------ .../media/common/videobuf2/videobuf2-v4l2.c | 17 +++++++------ include/media/videobuf2-core.h | 4 +++- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 70b6b8f8c390..a4c2fae8705d 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -443,15 +443,24 @@ static void vb2_queue_remove_buffer(struct vb2_queue *q, struct vb2_buffer *vb) */ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory, unsigned int num_buffers, unsigned int num_planes, - const unsigned plane_sizes[VB2_MAX_PLANES]) + const unsigned plane_sizes[VB2_MAX_PLANES], + unsigned int *first) { unsigned int buffer, plane; struct vb2_buffer *vb; + unsigned long first_index; int ret; /* Ensure that q->num_buffers+num_buffers is below q->max_allowed_buffers */ num_buffers = min_t(unsigned int, num_buffers, - q->max_allowed_buffers - q->num_buffers); + q->max_allowed_buffers - vb2_get_num_buffers(q)); + + first_index = vb2_get_num_buffers(q); + + if (first_index >= q->max_allowed_buffers) + return 0; + + *first = first_index; for (buffer = 0; buffer < num_buffers; ++buffer) { /* Allocate vb2 buffer structures */ @@ -472,7 +481,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory, } call_void_bufop(q, init_buffer, vb); - if (!vb2_queue_add_buffer(q, vb, q->num_buffers + buffer)) { + if (!vb2_queue_add_buffer(q, vb, first_index++)) { dprintk(q, 1, "failed adding buffer %d to queue\n", buffer); kfree(vb); break; @@ -832,7 +841,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, unsigned int q_num_bufs = vb2_get_num_buffers(q); unsigned plane_sizes[VB2_MAX_PLANES] = { }; bool non_coherent_mem = flags & V4L2_MEMORY_FLAG_NON_COHERENT; - unsigned int i; + unsigned int i, first; int ret = 0; if (q->streaming) { @@ -919,7 +928,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, /* Finally, allocate buffers and video memory */ allocated_buffers = - __vb2_queue_alloc(q, memory, num_buffers, num_planes, plane_sizes); + __vb2_queue_alloc(q, memory, num_buffers, num_planes, plane_sizes, &first); if (allocated_buffers == 0) { dprintk(q, 1, "memory allocation failed\n"); ret = -ENOMEM; @@ -993,7 +1002,8 @@ EXPORT_SYMBOL_GPL(vb2_core_reqbufs); int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, unsigned int flags, unsigned int *count, unsigned int requested_planes, - const unsigned int requested_sizes[]) + const unsigned int requested_sizes[], + unsigned int *first) { unsigned int num_planes = 0, num_buffers, allocated_buffers; unsigned plane_sizes[VB2_MAX_PLANES] = { }; @@ -1055,7 +1065,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, /* Finally, allocate buffers and video memory */ allocated_buffers = __vb2_queue_alloc(q, memory, num_buffers, - num_planes, plane_sizes); + num_planes, plane_sizes, first); if (allocated_buffers == 0) { dprintk(q, 1, "memory allocation failed\n"); ret = -ENOMEM; diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index 3eb707abc26b..a88abcea2921 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -762,7 +762,6 @@ int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create) fill_buf_caps(q, &create->capabilities); validate_memory_flags(q, create->memory, &create->flags); - create->index = q->num_buffers; if (create->count == 0) return ret != -EBUSY ? ret : 0; @@ -804,11 +803,16 @@ int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create) for (i = 0; i < requested_planes; i++) if (requested_sizes[i] == 0) return -EINVAL; - return ret ? ret : vb2_core_create_bufs(q, create->memory, - create->flags, - &create->count, - requested_planes, - requested_sizes); + if (ret) + return ret; + + ret = vb2_core_create_bufs(q, create->memory, + create->flags, + &create->count, + requested_planes, + requested_sizes, + &create->index); + return ret; } EXPORT_SYMBOL_GPL(vb2_create_bufs); @@ -1036,7 +1040,6 @@ int vb2_ioctl_create_bufs(struct file *file, void *priv, int res = vb2_verify_memory_type(vdev->queue, p->memory, p->format.type); - p->index = vdev->queue->num_buffers; fill_buf_caps(vdev->queue, &p->capabilities); validate_memory_flags(vdev->queue, p->memory, &p->flags); /* diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 1ecaf4b5a76f..19c93d8eb7c8 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -803,6 +803,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, * @count: requested buffer count. * @requested_planes: number of planes requested. * @requested_sizes: array with the size of the planes. + * @first: index of the first created buffer * * Videobuf2 core helper to implement VIDIOC_CREATE_BUFS() operation. It is * called internally by VB2 by an API-specific handler, like @@ -819,7 +820,8 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, unsigned int flags, unsigned int *count, unsigned int requested_planes, - const unsigned int requested_sizes[]); + const unsigned int requested_sizes[], + unsigned int *first); /** * vb2_core_prepare_buf() - Pass ownership of a buffer from userspace From patchwork Thu Sep 14 13:32:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 140135 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp802423vqi; Thu, 14 Sep 2023 21:39:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGXnbv1wtHuNsxt1R/OrNgVfMoZQGZCq5twN+0l/zWYcXIedlt3Y+YJ/YD2DesXEx/i7G6A X-Received: by 2002:a17:902:6b0a:b0:1c1:e5f7:a743 with SMTP id o10-20020a1709026b0a00b001c1e5f7a743mr586457plk.55.1694752793122; Thu, 14 Sep 2023 21:39:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694752793; cv=none; d=google.com; s=arc-20160816; b=U7LjG0z3cJ7Cc2c5InKtiM2gR74cuDyvxVqkso76z1l88eApstdynvFsUNoj0Trt3T NN1wXrK4TRV0kmSx13mZxPSFT8xfS69s8pOJxKnS9Q5ZVZ26g9RQiaAaWh1x/wv9/kdJ FnzvKDgoeHFFCX/D6bztj4kQoIhjT594ZYTPX/t/gF+yUV8n44NfSI0imQ5TAhzJC0C8 pjaNfA7PBRXsnP7tUSJJnzwIJO+X4v5Zzv49uvRIyUYqzUdXO/+wG3YRvq/CAiKJUo+6 rV3c6NEzJLK4YIozkYfYjN3IHpSGijbJG4j1kWTkkrjjfmakSHNn5FIUnMiSjs+PsHao pegw== 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=sY9RP+fPDz1MSqs1Rmax9/Eu2YBR7RvRLW2qBjv36o8=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=gSiBQUTMaOuyiIvxWMyH39zkYeDrlKmzqLFCc+vZ2U2Ha4l8hp7yhqeZlRNrPFGvsz 5Ns1UdH3AphwRIvQy3JOQldkH55OkuSMXqtlTSZgLqQ+NubRJs/P2X/TSOrqSkRsDWqM VIhWuz73i3xSXfW1vg8KsNYY+SxJpIoUqSXP5Jxclpo51zP6PwpFzJa68jH5XUdZVdMI vbTXsUpArHPddx1OKC1qZK/JRm1wkTaWT9ZXuR+zljFSLNeA83hvpQEwcEWA12LzN9R4 6W/GXCz+PJIw3ZEx2EBRC0HkFWlc1HVsYRfo0WbnmzGWIKEJ1g4v3V0vzKWGPN168TPE z/NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=lkLIjEy2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id k7-20020a170902c40700b001b3c63eba76si2876826plk.492.2023.09.14.21.39.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 21:39:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=lkLIjEy2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 EE67B81E7266; Thu, 14 Sep 2023 06:34:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239322AbjINNea (ORCPT + 35 others); Thu, 14 Sep 2023 09:34:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239263AbjINNd7 (ORCPT ); Thu, 14 Sep 2023 09:33:59 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93A091FC2; Thu, 14 Sep 2023 06:33:43 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 16B99660734D; Thu, 14 Sep 2023 14:33:42 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698422; bh=aeJc8Jxcb8/QbECmV25qK+8LTdH51/KXmWUpXuI4BR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lkLIjEy2vX3bpMH3buUT4cdpI7iRafMZckCzgDYWsix0SUPgu3Jc8uxt7LyFI/4FN zpki5QpXi/wJpp4RUvpkfSVJu5j5QMl9lueRCWkn/VlXfac6kiOCt7yUj64gPTODZT wLnIU5q+RBlJRH1uQh6RLh72Vm8WEFetXbdxsvY8gvnFTTU5bOJtuptiAXMpAD0/ru /wCR2yEG4NgHtL1iG2hqtlUo2K8JiZWp44XQ1+u1dnWMSHHAqdXA1LWFaD77pz9f7r gvMSAwli3PdGl/6EYHWc2QbbHdDP6st86TBiJddI7gFfvzgLJuG4osJSS8ICQPqXUU 3sQ+c6hN6G+BA== 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 v7 21/49] media: dvb: Stop direct calls to queue num_buffers field Date: Thu, 14 Sep 2023 15:32:55 +0200 Message-Id: <20230914133323.198857-22-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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, 14 Sep 2023 06:34:36 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777077104858048000 X-GMAIL-MSGID: 1777077104858048000 Use vb2_get_num_buffers() to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- drivers/media/dvb-core/dvb_vb2.c | 1 - drivers/media/dvb-frontends/rtl2832_sdr.c | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/dvb-core/dvb_vb2.c b/drivers/media/dvb-core/dvb_vb2.c index 3a966fdf814c..a731b755a0b9 100644 --- a/drivers/media/dvb-core/dvb_vb2.c +++ b/drivers/media/dvb-core/dvb_vb2.c @@ -177,7 +177,6 @@ int dvb_vb2_init(struct dvb_vb2_ctx *ctx, const char *name, int nonblocking) q->ops = &dvb_vb2_qops; q->mem_ops = &vb2_vmalloc_memops; q->buf_ops = &dvb_vb2_buf_ops; - q->num_buffers = 0; ret = vb2_core_queue_init(q); if (ret) { ctx->state = DVB_VB2_STATE_NONE; diff --git a/drivers/media/dvb-frontends/rtl2832_sdr.c b/drivers/media/dvb-frontends/rtl2832_sdr.c index 02c619e51641..023db6e793f8 100644 --- a/drivers/media/dvb-frontends/rtl2832_sdr.c +++ b/drivers/media/dvb-frontends/rtl2832_sdr.c @@ -439,12 +439,13 @@ static int rtl2832_sdr_queue_setup(struct vb2_queue *vq, { struct rtl2832_sdr_dev *dev = vb2_get_drv_priv(vq); struct platform_device *pdev = dev->pdev; + unsigned int q_num_bufs = vb2_get_num_buffers(vq); dev_dbg(&pdev->dev, "nbuffers=%d\n", *nbuffers); /* Need at least 8 buffers */ - if (vq->num_buffers + *nbuffers < 8) - *nbuffers = 8 - vq->num_buffers; + if (q_num_bufs + *nbuffers < 8) + *nbuffers = 8 - q_num_bufs; *nplanes = 1; sizes[0] = PAGE_ALIGN(dev->buffersize); dev_dbg(&pdev->dev, "nbuffers=%d sizes[0]=%d\n", *nbuffers, sizes[0]); From patchwork Thu Sep 14 13:32:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 140033 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp762483vqi; Thu, 14 Sep 2023 19:44:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE8qWzk0ifFD3d3jGv3keDf0XNo/HQ1jPw0iwbrSxrdM4vtC4Y192cYJH5PoSNM0zHDOoEZ X-Received: by 2002:a17:90b:3b4b:b0:26d:355a:47e3 with SMTP id ot11-20020a17090b3b4b00b0026d355a47e3mr298163pjb.38.1694745846117; Thu, 14 Sep 2023 19:44:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694745846; cv=none; d=google.com; s=arc-20160816; b=Nrge4loTjT/qW9FZTE+zZyxrTRxjaJQEMMXP1H0LGngSKiKRRL25J6wIBAu/dSbEqY CFSoy12To9KHjRhlogxqZ1Y1C1QNj8uisJpS34FMRaq18A3J5Uoz/txw6ZbppZawubXC IFkEKxXuFp5MSz4WPMhndlVlco6fo8I6GM+YDWTtK0BGxbGN2gYGG01EgmLAKtSWGvDU nJ6+SnGQ1b+35bquhKuQjrm3Qbn+hzE7G9vrrQaOaB0iDb2ZYeGET/rApq8PpGI5u0oM xhtPPhZnL5tTBEypYxjraLjLxQZBH4SoaUzpY0hLqd/7eZO0Vp4DIOEwHDNI21Nej9no 9U4w== 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=lQ9dXAKW0tlc7bFOMFkmzr0Ker99sDGq/isfBpik07I=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=wGeLiSWqLDwL8qNiwoHPNK+Vw+1vffIa0i/RQ5SBdS0vZgzXeYOh3oiLOx9PHaS+lr nUzpUDbb4LeNBCW5GZCnHvZ29y64R50uPMU5Ggf1VW4jUCVU3rprwGNmRqd0r7g7/nBB MuXid2dYG3oU+1NFGx7nE+6maAQ2TpZcrYLR8cqHq+4jHECW4vQzXvloWO4wVJwW4MFP vfPDEUTDkm8v7qYffgyLNgC/teRTYfjdy5CrjrPAFGM6yZ1j+JSriVKGSlYQx5ny2fSQ J44ZfYXMwQkZZVT8+LsdGAy97CkEoyT5sDJ1031Lzp2IBBdpmzSzkdtcKlMHiL2uFy5d BoLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=oFsDgzTc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id mr1-20020a17090b238100b0026d15dd670dsi172310pjb.0.2023.09.14.19.44.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 19:44:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=oFsDgzTc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 CC4D48076E57; Thu, 14 Sep 2023 06:34:58 -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 S239636AbjINNec (ORCPT + 35 others); Thu, 14 Sep 2023 09:34:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239277AbjINNd7 (ORCPT ); Thu, 14 Sep 2023 09:33:59 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C3401FFD; Thu, 14 Sep 2023 06:33:44 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 9577B6607377; Thu, 14 Sep 2023 14:33:42 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698423; bh=N8F0TVW71sKqYIUdg2i7jHGXNNiGuYTWU5qjY+j8Vz4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oFsDgzTcyrpxAlQlpxQ/2P4j2Ix+qcXNOxuNIVTdX9cEOU+1AnhgoyFAZ0JP9REkC Q/fUx+vRTrNK0B5SGzPHltRe+aGb05x/P1VLmP196NpE4zMd5ivunjMB3JiKPIfpA7 ic1mCSv88L0jXh2UPG+oa497ijOIHDnmES/OdCKiI1Zasm7r4Zp2XQaJyY9MOXxpwO Zh24HgChuFlwTu+pHvKEEtFlJOx8adD7d+6aB3ueY4OTlpLgP/R+QqSXsHtpYDeTgc pIWUvnhR1K3jSDqGfAsdOaAiZJyqksjDbycmJPq0yYAWHWMloYhfbkZDkhHGgbvqet nD03lIDSkdM0g== 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 v7 22/49] media: i2c: Stop direct calls to queue num_buffers field Date: Thu, 14 Sep 2023 15:32:56 +0200 Message-Id: <20230914133323.198857-23-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (groat.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:34:58 -0700 (PDT) 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777069820434862234 X-GMAIL-MSGID: 1777069820434862234 Use vb2_get_num_buffers() to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- drivers/media/i2c/video-i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/video-i2c.c b/drivers/media/i2c/video-i2c.c index 537ebd9fa8d7..60d3e2f35afe 100644 --- a/drivers/media/i2c/video-i2c.c +++ b/drivers/media/i2c/video-i2c.c @@ -406,7 +406,7 @@ static int queue_setup(struct vb2_queue *vq, struct video_i2c_data *data = vb2_get_drv_priv(vq); unsigned int size = data->chip->buffer_size; - if (vq->num_buffers + *nbuffers < 2) + if (vb2_get_num_buffers(vq) + *nbuffers < 2) *nbuffers = 2; if (*nplanes) From patchwork Thu Sep 14 13:32:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 140573 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1211351vqi; Fri, 15 Sep 2023 10:33:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEMr54rqGCsWynG/qghvw+O03l9zshvYZ0PO6e9d5kTg3Y1tbH1QhsWLP1LRDg9NdFu7vAC X-Received: by 2002:a17:90b:1a90:b0:274:6839:6a8c with SMTP id ng16-20020a17090b1a9000b0027468396a8cmr2215880pjb.6.1694799215596; Fri, 15 Sep 2023 10:33:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694799215; cv=none; d=google.com; s=arc-20160816; b=OO0fAnhT9LRfbOP1vrVJ+lXJvK0hDjFBQWShyGzHMwufAQWMWWucqBn/LHSh2KJD+I qPzxEYSHva3TRkyCz/DaLws2CdWJ5Aj/4fpZOqz8D/ovxPTdpRGyVm2jeRzmM0ZcpjrX 79QYe7MOoOJW5j86WQmHTUp8p39Wy0AqmwBA3m/qO5GNVaC7I7RcceNhowaA5NJ8R831 4XZ/AgNYt7O+xaeIsWr7nBGmU3otWlcpX+LSJNigr+dM8dXSqmCunOrbtBb8s8kbx9pc ovy0Zjosk2mNputWVLolvVqHvSHfajpY3yA17w6E9vHjR76C56pYqcqz0mL9/pmkXjXK hUCQ== 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=S3HpcoTOv+qfBg+xfI1cbb4POrBPGZsbIU6W8kNHClY=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=Z2rFIrLFu0WyVWreCyFsvuJFp4eOexCAYkQVX5WtYRb24zSe6+QoQDR3C+X0qe1UbH kLm7B3597ekd0sH0EHq9G1m1v1VkZr1lAo3rSO3ssMZ+SG9YR1ACpF3dyzJMJ2IUhraF k0iMtyfxFy0gL87S+NzELzbC3UNO1skBUttR8lu+gsRJGybFcr9CT8f+VMDESJu3MvuY mzyZVe0Nk/ds4hg3kHgiCLRoKPl/lzsZumidUWWtoaZPhITR13itTbsPbVTFt7ZhKnpB iu+zGogdjLEhmVJEzyMGMuSra9myRmiSSR6wj02/EArySCZItEwn8K2mbq0Wi1P6mPh/ Nrjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=BRJKAYVX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id ng8-20020a17090b1a8800b0025eeb3cc4b2si3944930pjb.9.2023.09.15.10.33.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 10:33:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=BRJKAYVX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 514628213F1D; Thu, 14 Sep 2023 06:34:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239684AbjINNeh (ORCPT + 35 others); Thu, 14 Sep 2023 09:34:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239071AbjINNeC (ORCPT ); Thu, 14 Sep 2023 09:34:02 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 193882105; Thu, 14 Sep 2023 06:33:45 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 2BA32660734E; Thu, 14 Sep 2023 14:33:43 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698423; bh=336tMZ/RUJb+ZhMa2C9VNJt3Yyz+CPMiBOLJjWSuFw8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BRJKAYVXwhZNav2giBo3pXHUXbWZNnNn/esMnZZ2OStWYOMBWFldVyUj23jt/lmcx e5OD6YiVeO6dogFLYdEpRVfL68cYZxjBf4UunxHYT6Z5OMFEi40sl/LW8uJfsn4pQa 9i9CW0zfd+Gmr263fTeoi8z1PNRz9Hcznee662yWyritIFcleHr60lxGjsQlLryRwv SBrXXl7CjYX+FbLzW4/TIYhye/FRpmihwZDDAQIDEGvTa2IRfYFGDN7TiwordjsM3W HuQJKfcJPxkLlrUjPVoaVLdP0l660gp2RixoKoKgPlK2y0i/dPy6kDQB3aoq0v2Vih 8+dDET6Tb9gug== 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 v7 23/49] media: pci: cx18: Stop direct calls to queue num_buffers field Date: Thu, 14 Sep 2023 15:32:57 +0200 Message-Id: <20230914133323.198857-24-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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, 14 Sep 2023 06:34:43 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777125782048019412 X-GMAIL-MSGID: 1777125782048019412 Use vb2_get_num_buffers() to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- 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..a7a7e006b3be 100644 --- a/drivers/media/pci/cx18/cx18-streams.c +++ b/drivers/media/pci/cx18/cx18-streams.c @@ -105,6 +105,7 @@ static int cx18_queue_setup(struct vb2_queue *vq, unsigned int sizes[], struct device *alloc_devs[]) { struct cx18_stream *s = vb2_get_drv_priv(vq); + unsigned int q_num_bufs = vb2_get_num_buffers(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) From patchwork Thu Sep 14 13:32:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139599 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp359671vqi; Thu, 14 Sep 2023 06:46:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHEgdrU3dQap3Ldo+pbkRYIbwevIa5icDXNgDucKlCqQQvrZSY10fy2cYA+i1tTdo0r+08k X-Received: by 2002:a05:6a20:430f:b0:157:76c5:8f3e with SMTP id h15-20020a056a20430f00b0015776c58f3emr5870862pzk.45.1694699193640; Thu, 14 Sep 2023 06:46:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694699193; cv=none; d=google.com; s=arc-20160816; b=Tdrkaxl03pTNECrMLh3kW9GvqE+FfrVdP5GBsWgU+YtnX2BbhzOrU4sQrwUuRm3RkV uHt5IDsMrVLZ2pOVAEfkqOkSrun4Ex+gmro6ul62qIbeX1N9Je0W2KL7ayn42sqJoxt3 LeKsHYIauMx6BoDbxArJ70KDPj0HPmvkUngeg/AUAnwvAH3diBQEr0LV9pHG6LG3bchV 0va+BfLm1yViaJnLm7eQmY9uMVNqlyRg0dNk7h8QpTo0e+7SDgkQoLcJgqimBtWrR6lW VTzXkzs8DJv0HF4/NdPGpd6FlaRItxVwTjwefh0J5pceIwzuMjuB8d+CDft61hutcLQQ z9BQ== 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=kRY1Y8UmuB3bOAVn1DjviZOqkQmeQ20ZSWWBbzh2Ejc=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=sRwXz4w733witF6s3rcob/mFmG3H84DS7PPOPYZybiSt36nEQLqWhqUPH/pK76Tsi8 n1SgmLqqd6AdouviBUNU7I2TjtFnzX3bwq1gJd9wFWySUvWZecPWRoV8rQrFf3bwUzIe Or4zVtCOfEE6Pz1vlVFxuaQbg6IKwBkaFzXDfb03eyA6TArJUe9AqAeckUPj0rqOrM+U PzdobP0u0usdiJvmnTDQH0GxmsQJ1sjS1cJ/jsfxs45AR+y+jCKd14NaXZDxQ2HCiyC/ mr5re+he+aLQdvPEBOb4OHXhxW7J9Y82lKCS94+jaKJK5FxkWJoGx0VdQD2UAyf/5RhJ 4HuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=HGrzjpCp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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. [23.128.96.34]) by mx.google.com with ESMTPS id a1-20020a170902ecc100b001b8a70d11e4si1827122plh.529.2023.09.14.06.46.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 06:46:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=HGrzjpCp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 3846085A0DFC; Thu, 14 Sep 2023 06:34:44 -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 S239694AbjINNej (ORCPT + 35 others); Thu, 14 Sep 2023 09:34:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239212AbjINNeC (ORCPT ); Thu, 14 Sep 2023 09:34:02 -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 3AB152108; Thu, 14 Sep 2023 06:33:45 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 A9FD66607378; Thu, 14 Sep 2023 14:33:43 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698424; bh=BcQqOPN9BFM33EPpszUjysR3LWc4nekHpVvypyNeDb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HGrzjpCpmFxjKl+xk12MOrY+MAGIB4u3LD8uzE5j+yG7VVUQIygb4veFQ1xCJm2qN 7N6Tamio7lxOVD8pfP3gE5v7dD/QnlDk4KY8kejzl3Uo1uBCYl5lQO1D2EKwZ2ub9Y LsMZl7uTJvHisiPba1wwyGF1/Bm040tvPT+fpBf9l94FVfVavC3Prnf5TqF+dz3FVR VhZTziEGD29c1Z47nVHkMzJHfNDvohrqsrqkAelEfBTjRWeqbZFDfPxR6z5eo4TYlL n8okpZR62/R9k08yiq/rRBS/x7JdONAbNeIjEb2VEESBf0BXjS9Ww6GjCSrbAIh8DC ROYWEhkR+lq+w== 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 v7 24/49] media: pci: dt3155: Stop direct calls to queue num_buffers field Date: Thu, 14 Sep 2023 15:32:58 +0200 Message-Id: <20230914133323.198857-25-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (howler.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:34:44 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777020901469415358 X-GMAIL-MSGID: 1777020901469415358 Use vb2_get_num_buffers() to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- drivers/media/pci/dt3155/dt3155.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/pci/dt3155/dt3155.c b/drivers/media/pci/dt3155/dt3155.c index 548156b199cc..d3abb0e093c1 100644 --- a/drivers/media/pci/dt3155/dt3155.c +++ b/drivers/media/pci/dt3155/dt3155.c @@ -126,10 +126,11 @@ dt3155_queue_setup(struct vb2_queue *vq, { struct dt3155_priv *pd = vb2_get_drv_priv(vq); + unsigned int q_num_bufs = vb2_get_num_buffers(vq); unsigned size = pd->width * pd->height; - if (vq->num_buffers + *nbuffers < 2) - *nbuffers = 2 - vq->num_buffers; + if (q_num_bufs + *nbuffers < 2) + *nbuffers = 2 - q_num_bufs; if (*num_planes) return sizes[0] < size ? -EINVAL : 0; *num_planes = 1; From patchwork Thu Sep 14 13:32:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139834 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp619105vqi; Thu, 14 Sep 2023 13:53:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG0v8w9TYsDz9nb8bzrWPsPkSykypk8POZEk/A0XUYcoNJWofn7K//Mb7CoBgCVTk9yzR5J X-Received: by 2002:a05:6a20:9388:b0:137:23f1:4281 with SMTP id x8-20020a056a20938800b0013723f14281mr7615204pzh.12.1694724826608; Thu, 14 Sep 2023 13:53:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694724826; cv=none; d=google.com; s=arc-20160816; b=Skg6aFb+6nhOMk8wACcnrvM+eUgdl/FXFvj1/tgwjSPqIWU15Nvuz6/4a1JmBC0Jew ow3bfeou+qTAxGTV+u34TPH8C+NZ87IB6uY5fMJXjCKWetHULSK7W/v/rI0VW/Aln3Sx Rs8tL7y/El8xcV826LJ659YV8U7cKB90GVQIhr7LHwm10zKxXK12OE8rDE+rJW0EHrEq aSMqZWyM/buqSd7Z1eBMI3BzWS/nIVZ0EiEtxPCnU3gT+OoU6C+ANGD72Uno4hZxrVEh eB8QWEl64Fq0cT6j3uCchT8cRglEQLgV6jhTuq+SlN8Gygk8Vpi1cWvjCXrcFIl7H/p5 ONFw== 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=qtQrheDOTB5W1kECh5xWol0Np4SwhxAT7DqMouSjQ20=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=XQMgp8oWfbucFUpfx+pGcSJa3HM0uGgJna6N3rPaOf+NVajomx8evxFYcROWLlGGdF hM7b1szGzik/1vKjF1agTovNOTrCXJn2k4U7Y52TD3lqIvwoq250L6BImQlSy2yYZXaG B4epALkIL1O2JbT2d+saLc2SzXIMb2mkcCW0hM6AaFInmk39I2n4obN+l9Co+yy33taf /qzrkKPyzzQgdqIVMW3lvaxX3G2+Hsn9Py2bUVMA/HqKc8dlj8Ix7BSR1hLo9jNqLVqZ LoeVYgS5D142BdpgF4qAs7SYw+rt+invltsYl9IvE4YFbp9NwNMrD1z6wZThegst1duW WHBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=JslCudCi; 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 q30-20020a63f95e000000b00569362d6cebsi2092971pgk.2.2023.09.14.13.53.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 13:53:46 -0700 (PDT) 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=JslCudCi; 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 7FA04821A179; Thu, 14 Sep 2023 06:34:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239702AbjINNel (ORCPT + 35 others); Thu, 14 Sep 2023 09:34:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239305AbjINNeC (ORCPT ); Thu, 14 Sep 2023 09:34:02 -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 C1710210C; Thu, 14 Sep 2023 06:33:45 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 355306607379; Thu, 14 Sep 2023 14:33:44 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698424; bh=m3sR68fD7RFMhs/9CpLuKCWbk5tpTajBvxLhqEExuTU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JslCudCijCNZbjg/QccsFInVeRarUdHdzzatKGlmYaf2IlaBwMKxs+ayDH1t3kGZ7 8N3M3Iq/vri4mZUXr13lAJH5HNrsKw0pVHZ4/Ho34xTL1/fYQzN1Vz3FQ2I+iF5oCo tpxZOIcNjhRWRTT0+kwqrU7JE6cTY+loFqBLoypTd5N4gTm6ho5uGWom0Mp443EfRq Kg9N2qfXsGs03r64YM8NvyfLuTrd4Gun5VoWf2r1M5gP3Ca2XdzKjIgDfTSFpl70n8 WshJE0HQfwhFN3QuyeVxKAAcUHFLRRl/NI1rCyRJkG5jomtFeUJkRG7n/Kzu8P7+qX TjSROgV9SWezQ== 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 v7 25/49] media: pci: netup_unidvb: Stop direct calls to queue num_buffers field Date: Thu, 14 Sep 2023 15:32:59 +0200 Message-Id: <20230914133323.198857-26-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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, 14 Sep 2023 06:34:44 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777047779367155779 X-GMAIL-MSGID: 1777047779367155779 Use vb2_get_num_buffers() to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- 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]); From patchwork Thu Sep 14 13:33:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139611 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp377421vqi; Thu, 14 Sep 2023 07:12:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGQ1/14Ucn0U0dWWwjuJldhTml2Phm7mBRT1wzpFeDf8wNKNAHoe2qKl4dPe4LSksY461/I X-Received: by 2002:a05:6359:d0a:b0:139:840a:d357 with SMTP id gp10-20020a0563590d0a00b00139840ad357mr4820897rwb.1.1694700727355; Thu, 14 Sep 2023 07:12:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694700727; cv=none; d=google.com; s=arc-20160816; b=x/1p6OXfa0Rbn+gySFZgXvQcvRhDGDBqtPaR2xvTdIqQiM9l5dHUNACQrz0+jkEsVN Ev8g0d2ewpXJY5TehhHKvadKxw6NrCUFWtcJCNHx7F4xDs6ak7JgQfPrHgbxhX1Jo/8f 27MdmD1ch+9a78NKZ9kAfn0jhFuuGCwf38MBnJmdPtsKLMlqtXz/XdrMl4q3lDVjrIUp zMsGDr/SYM7l2dUjNgxscmDHULBB21hmAHIulAeAHPiDWZu3xGi7YlfuTbD0cGam8dGq iy3rvX4kFkWLRo3ZMOaEuhAz4qOUIjJ8NbXW+FznY3fafMZ6UPedFVKeD9+nnU2+icCr 8vbg== 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=X4wPFySt/lU5j9AkoHLhqGTEN8n0F3jcw+kxHilaaRg=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=Lhw57S7bH7KFsT9P9G3w4kn7SlmV13uM2+ThBsFkFHAHnMX34S0JvkSjz3TH0ZQklp aijhIxRU8Q0nNf3fSEZ4fSknQOWZ4R8vLTj+82UzRpKQkC5jXDhILFIGS2QNuqc8E3sr oFj8/oZCYTXQ9S87y5WgIoiINry3Bxc/WCzekT+UCD6ydSBy9vSGYt3AI9VMQ6P1dbNr VwUPS4QHA7ONeDdNUGHpDcOGG0jRl3hdTdXFrHyVFZg0Ryv87YOgUQNOpeMtqB7YAmKt wwrIGNhCRzW1FZdwkXCCfWyYFUuntfnQi4p4RnWyl4b5r+E+24xis0P73xWNC14mNIJY fQEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=n56v+JXL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id a5-20020a655c85000000b0057755d654f4si1589575pgt.628.2023.09.14.07.12.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 07:12:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=n56v+JXL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 3E57A81CDE0F; Thu, 14 Sep 2023 06:35:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239714AbjINNem (ORCPT + 35 others); Thu, 14 Sep 2023 09:34:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239315AbjINNeC (ORCPT ); Thu, 14 Sep 2023 09:34:02 -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 3C7292113; Thu, 14 Sep 2023 06:33:46 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 B5919660735E; Thu, 14 Sep 2023 14:33:44 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698425; bh=KMPzPsH6nYT59+TnmiRbCQNg0tV3gkCBNX7OoLfQWFs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n56v+JXLtBEX5Ogmuyno+QnMPo5soqucOknczK2gLaEl+yd79iAC9D4AfHRPTuCtO xJjcxBuOKoffcBTTB/85iFW4CM3ZupfZWkGVp8bY3SFygB09E8Y1unNCk4h+pS9Iu0 vyOdJBUGC4Q7MzqUWh/iZ/7o4z1oAHrWMSVCp9Q0V3P4FRpez6BozS2DmFJbvul8rd fNREY8IB7VzHqsoDVnqKZG5lSqJUrVlAZATDS95qjxvmV38m8ta87C4yEswKcFl3Pv 5X6SuUwtiu5chNbf4E6jak2yXfwTOxInmyl3V4EIi8XXeQVQWM5JOY73JkTBe7muQ4 IU+RWTcCp80Nw== 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 v7 26/49] media: pci: tw68: Stop direct calls to queue num_buffers field Date: Thu, 14 Sep 2023 15:33:00 +0200 Message-Id: <20230914133323.198857-27-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (lipwig.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:35:57 -0700 (PDT) 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777022510286336967 X-GMAIL-MSGID: 1777022510286336967 Use vb2_get_num_buffers() to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- drivers/media/pci/tw68/tw68-video.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/pci/tw68/tw68-video.c b/drivers/media/pci/tw68/tw68-video.c index 773a18702d36..35296c226019 100644 --- a/drivers/media/pci/tw68/tw68-video.c +++ b/drivers/media/pci/tw68/tw68-video.c @@ -360,13 +360,13 @@ 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 From patchwork Thu Sep 14 13:33:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139846 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp634524vqi; Thu, 14 Sep 2023 14:25:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGNs4OZNbXybzesPfHVF/zdAnVtOFaO/AotZhFzgklwE7Asv9Lb9P4SdAmpqKkQYhfc/2Be X-Received: by 2002:a17:903:11cf:b0:1c3:3363:8aea with SMTP id q15-20020a17090311cf00b001c333638aeamr7925462plh.61.1694726735200; Thu, 14 Sep 2023 14:25:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694726735; cv=none; d=google.com; s=arc-20160816; b=TVwmq7WL+cC3xgn/WH12gLQjTur6smnVSJ5lp3yL5nmAXUWV/sUZJx6Dd+hjJdfTvY QbEX/joCaKfSADOS2F1KTL3e4UFEt84R7Wgj0t+C3mnjfpY0xyXITTcTxTdgIjMwp3T6 Qjt680XXPGc/cWO4DYKskyi9zDC929ljEv/JADkpJSIwqbMqcdm0wv4F/YSGj/tLa9Us +msTpWX+VJPiNsmW96ZNO3aoif01Zv4DYaha2iiuf2O48bMUfp4nZoNVurVeWHyQMMJR bCHaIR4KQKbHTUFft9OloxYWJKd6B+q9ntIAc04fHiSTS9v/3szEgTnNSXrWzMg/leTv nzdw== 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=1HzoHUvVGp9ghcj+K/m/xcGH6bZqCgEuhp8DTUadv54=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=ZQOv7K9DgZEOjlfS50qHPVk/oQM47kPW6OoRWoOP+N+jNcZxywNFKCKkk8qsIo1NeZ cT8Fl340hakal4z3OxBStIZ+RL9MFQyT+nCkpYlRzmWVwT+Jio9TmhRndUTcoVfQN+e9 CcIqjjbUFDb+AKgXWG8E6z3EMNCsPbp/4oirzNxzEKK1ODThiGJ2bRuirQDM9jNpLa2K wY6K8jarerEvNgoqvqXV5suvxXBhM6GPwHAOePzHWF4YrliEv+1MgGrwpFSDUVC04qJi RPwjOCWreaFMbuGAlzZdasL1xzfv9shOMnpuRRCcGDY62S8YaRLL4BfZTOQajR4kjkzk cqlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="nEP/V+iu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id k2-20020a170902c40200b001b8921fbd87si2634620plk.490.2023.09.14.14.25.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 14:25:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="nEP/V+iu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 95DE78099CF0; Thu, 14 Sep 2023 06:36:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239345AbjINNep (ORCPT + 35 others); Thu, 14 Sep 2023 09:34:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239336AbjINNeD (ORCPT ); Thu, 14 Sep 2023 09:34:03 -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 C3A942116; Thu, 14 Sep 2023 06:33:46 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 3C6BB6607352; Thu, 14 Sep 2023 14:33:45 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698425; bh=tAy3PWxSfQVkJIZXcTG5de+gZEZpPM2JZfwPqhWBibI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nEP/V+iuUOYi2MTo66Frdk0Pt2cXkpb1dzgT0U/dICA49ehjlCHAL7XpJzJMUcER/ rRD9qTOr7d8zx9+87VOeV47F+p2+Mh2xAp0QYnU2P6Tzjxz3HzCKIn8IXhs3MD6u8A Zk8FuXkREfZYyZBGgnIIjQg9hggy1s4IobL5sPVr8VY05PSd4HLGewUJ+T7iMvh56+ AUyiqobkuW3713EX0SXbTziy7FZpI4k5OEEweycYS4kJIlLscF6xv+oab1j0J7Mxt6 9/7+O8+4LiS34ChguqJkCN8U4ZIvLGTr39lzr/c7vFNv9JAXTi4XVxUaSH4ezG3uaP 7pXpfUBhFGyhg== 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 v7 27/49] media: pci: tw686x: Stop direct calls to queue num_buffers field Date: Thu, 14 Sep 2023 15:33:01 +0200 Message-Id: <20230914133323.198857-28-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (agentk.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:36:10 -0700 (PDT) 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777049780725242035 X-GMAIL-MSGID: 1777049780725242035 Use vb2_get_num_buffers() to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- drivers/media/pci/tw686x/tw686x-video.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/pci/tw686x/tw686x-video.c b/drivers/media/pci/tw686x/tw686x-video.c index 3ebf7a2c95f0..6bc6d143d18c 100644 --- a/drivers/media/pci/tw686x/tw686x-video.c +++ b/drivers/media/pci/tw686x/tw686x-video.c @@ -423,6 +423,7 @@ static int tw686x_queue_setup(struct vb2_queue *vq, unsigned int sizes[], struct device *alloc_devs[]) { struct tw686x_video_channel *vc = vb2_get_drv_priv(vq); + unsigned int q_num_bufs = vb2_get_num_buffers(vq); unsigned int szimage = (vc->width * vc->height * vc->format->depth) >> 3; @@ -430,8 +431,8 @@ static int tw686x_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) From patchwork Thu Sep 14 13:33:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139665 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp455975vqi; Thu, 14 Sep 2023 09:07:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHRgIdGN9QKYifkAwKNmqt7kg13XDZ8W8+3kw7r6QSnfq7guzu6wigTgjhq1vivkxBqSyqk X-Received: by 2002:a17:90a:db41:b0:271:df08:6024 with SMTP id u1-20020a17090adb4100b00271df086024mr5953456pjx.17.1694707619946; Thu, 14 Sep 2023 09:06:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694707619; cv=none; d=google.com; s=arc-20160816; b=s8eM+BGKwbhtTTTpl0ftILzoBXn5xqyJDZ0FcSzaA/vLaJzhOVJy9PFVSdXevamtg3 2uUQf5sYh1cCnfBun//iBcKWPU+NO3b7NiAS/WkUysnlZb02BIceZmd7EUC8zz8KoMgN 9UiS0JtsFM3Rtj9eCQcAVQj2eGiVkDpBMea9pR3Xz7Guv8vhkeEIbV6TMMjdoBXW0QZs wScm+VOLTSUs6t5JZXUSnmgpVKq5KbvchK+PpeaTZuothfFvjqNVNrJo8dMSlsffyM17 JPpCvZlOjzxt0tuVz8To0/36SRSIk7BwBpjrX1L8SudPTdBlXLvd2b36d/UgSaWUC6hL 6iag== 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=FQ5F4xfO7mIkMqtItWWZDGjXEjnB/2LPnEMxgf06HOQ=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=U8jFuDm09EnWiv3B+jDh8njGSzQyK7u1nlYiNGvFGVmWgU3zXryHCNqxWK0rOfQ8+I 2Mz5d6Ps1ClTPQl5Zc2k9xcKp/AKkLaXN+urN6635H1uWhY3JGG0Aff8DcOgjHb1Kp95 M4f1zei38ky0sdbPzTDf3logUMBpncEgqPE7YUwTfMlqqg8fbmrvakfB1k3IvgMy4C6p U4a6V/ac4BsPsJR4g94iPRlqg4Zr/0LdS2kpbkIHEkY/poc4DHtHpn5gv3fjh2cyT1dg KgN91tOtQ8iHNu7J89jkizIna8oUFnzPkpwfGME4llnZQamK8Mn4t+s9EHr6sdJjxOEv d39A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=YvjvRTk2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id p2-20020a17090a2d8200b0026d4adee541si4010153pjd.150.2023.09.14.09.06.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 09:06:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=YvjvRTk2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id EB08E81BFA99; Thu, 14 Sep 2023 06:35:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239147AbjINNet (ORCPT + 35 others); Thu, 14 Sep 2023 09:34:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239229AbjINNeD (ORCPT ); Thu, 14 Sep 2023 09:34:03 -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 4CBD1211E; Thu, 14 Sep 2023 06:33:47 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 BADF56607354; Thu, 14 Sep 2023 14:33:45 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698426; bh=r/+dARFgLlqIYPCNsTNg9ylalWpmLzdptnRKI8OWLEk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YvjvRTk2FQuuuUs3HNGiHLDrwCbLyrYMWAL9JKval+qun6XwuAj6wgBBBfYt4IfYc xbmXCiUoxGZ4dVyag8AP0dCKYveSLx8N/9qEJjjg7/AK+32irfARE5BXXCdaPQ8C5q eGm/YqgIEkTHpr2n7umROLKbceFmejEHZwmhe+YMQAbkP64MrVDmu7NcqXZqiiff9W gVkhsgGZ27DQpJjT0kvrPuk/Hz8Gqd2Apyrf407pV8PK+uLskqE/XxU8YrO4ActwJl Rgku5Vrd3E+aZf9DjbXETUSohr6bM123BAC87DsXQcitdM/BcaI8PjCHJvYVe/Z4+1 7FpdiNtI5tZ0w== 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 v7 28/49] media: amphion: Stop direct calls to queue num_buffers field Date: Thu, 14 Sep 2023 15:33:02 +0200 Message-Id: <20230914133323.198857-29-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (lipwig.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:36:00 -0700 (PDT) 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777029737709003681 X-GMAIL-MSGID: 1777029737709003681 Use vb2_get_num_buffers() to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- drivers/media/platform/amphion/vpu_dbg.c | 8 ++++---- drivers/media/platform/amphion/vpu_v4l2.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/amphion/vpu_dbg.c b/drivers/media/platform/amphion/vpu_dbg.c index a462d6fe4ea9..61530ef92ff0 100644 --- a/drivers/media/platform/amphion/vpu_dbg.c +++ b/drivers/media/platform/amphion/vpu_dbg.c @@ -87,7 +87,7 @@ static int vpu_dbg_instance(struct seq_file *s, void *data) num = scnprintf(str, sizeof(str), "output (%2d, %2d): fmt = %c%c%c%c %d x %d, %d;", vb2_is_streaming(vq), - vq->num_buffers, + vb2_get_num_buffers(vq), inst->out_format.pixfmt, inst->out_format.pixfmt >> 8, inst->out_format.pixfmt >> 16, @@ -111,7 +111,7 @@ static int vpu_dbg_instance(struct seq_file *s, void *data) num = scnprintf(str, sizeof(str), "capture(%2d, %2d): fmt = %c%c%c%c %d x %d, %d;", vb2_is_streaming(vq), - vq->num_buffers, + vb2_get_num_buffers(vq), inst->cap_format.pixfmt, inst->cap_format.pixfmt >> 8, inst->cap_format.pixfmt >> 16, @@ -139,7 +139,7 @@ static int vpu_dbg_instance(struct seq_file *s, void *data) return 0; vq = v4l2_m2m_get_src_vq(inst->fh.m2m_ctx); - for (i = 0; i < vq->num_buffers; i++) { + for (i = 0; i < vq->max_allowed_buffers; i++) { struct vb2_buffer *vb; struct vb2_v4l2_buffer *vbuf; @@ -161,7 +161,7 @@ static int vpu_dbg_instance(struct seq_file *s, void *data) } vq = v4l2_m2m_get_dst_vq(inst->fh.m2m_ctx); - for (i = 0; i < vq->num_buffers; i++) { + for (i = 0; i < vq->max_allowed_buffers; i++) { struct vb2_buffer *vb; struct vb2_v4l2_buffer *vbuf; diff --git a/drivers/media/platform/amphion/vpu_v4l2.c b/drivers/media/platform/amphion/vpu_v4l2.c index 0f6e4c666440..87afb4a18d5d 100644 --- a/drivers/media/platform/amphion/vpu_v4l2.c +++ b/drivers/media/platform/amphion/vpu_v4l2.c @@ -439,7 +439,7 @@ int vpu_get_num_buffers(struct vpu_inst *inst, u32 type) else q = v4l2_m2m_get_dst_vq(inst->fh.m2m_ctx); - return q->num_buffers; + return vb2_get_num_buffers(q); } static void vpu_m2m_device_run(void *priv) @@ -587,7 +587,7 @@ static int vpu_vb2_start_streaming(struct vb2_queue *q, unsigned int count) fmt->sizeimage[0], fmt->bytesperline[0], fmt->sizeimage[1], fmt->bytesperline[1], fmt->sizeimage[2], fmt->bytesperline[2], - q->num_buffers); + vb2_get_num_buffers(q)); vb2_clear_last_buffer_dequeued(q); ret = call_vop(inst, start, q->type); if (ret) From patchwork Thu Sep 14 13:33:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139821 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp606143vqi; Thu, 14 Sep 2023 13:25:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF9nym2+p4e6h7UV6xlL/pbBGatKEMWxJ3jx7zFVHd4vIYS9awbBJruT+7R/MUFvWKlGLDG X-Received: by 2002:a05:6a00:1c92:b0:68b:fc76:7dea with SMTP id y18-20020a056a001c9200b0068bfc767deamr4019164pfw.12.1694723130570; Thu, 14 Sep 2023 13:25:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694723130; cv=none; d=google.com; s=arc-20160816; b=ZQ1+jEKbg+mANG/dx8moLMHknt+VWiAWcEIlmH0cfi25upwCDE/xvDYeAoqFZYDfXG 1B4bNCIgRzbmONns+CnTM0psCitsB6YSepK8docsGTtSiWiAHUChVKEkCjj7Hwly48t0 ZHgilQdfspmNVhSmGGrD+jEP4MxVDP7xJ7iY8xxALafycy0+l23J1LGwJGaxb0XRqnkr QJoGUMkIwDSGGzOg5VpuLzezN3MAanHIlcrDzNZc8tdNXSyfc+CrrRRccz/quuLSGasV eiVU3yVSjIkVgF1RmGlp68E1jG2kBrUnYbvzu8iCIQ8d8N5A4TWiCgNadxD0mxffGt+0 4Qhg== 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=KnK9e8ZFi3pebVdrAjDVtxSA0qCAi/hA6TDylmv0g/A=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=enfm7ktFd0TDsi8AvrtUnzpQcnOm1/daBcrb3gug3gFt27ronYaGpaDyaG2QdWne65 32KIG4luHG6WnQXiRpCbFn/VwdkY5lUDy+Mm2/6JX3tf1ZPW+mNvJv1ElDSm6Hr0EO82 1I8eRfK8ulegltSsicvhJiD9+fpiYjoCU4x+o16IkFe8LPXNi3u/mZiWhW4S/eQyupP7 IBtjJETJE56Ko3rW9W5xV7HkiyqShU+6M+kuCzeyrIYzThIx+GX6OFC4lMMQ9oYl/A/m 7cwWDNo+SBhbUS1JIsyEj3OUC8PZHbppeiKNExQgNalyBkqvnJOWHcSF6UrMX8P1MKPo jy4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=nhuItNLe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id dc3-20020a056a0035c300b0068be042fe24si2081293pfb.356.2023.09.14.13.25.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 13:25:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=nhuItNLe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 7ED2A81BFAA4; Thu, 14 Sep 2023 06:36:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239472AbjINNev (ORCPT + 35 others); Thu, 14 Sep 2023 09:34:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239402AbjINNeI (ORCPT ); Thu, 14 Sep 2023 09:34:08 -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 536AC2129; Thu, 14 Sep 2023 06:33:47 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 43469660737D; Thu, 14 Sep 2023 14:33:46 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698426; bh=vej0xyoaRLN25qHgld1P1pTyfPCEtxO7zlLcrG23sig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nhuItNLeE/eHshL9NqkSa3ui7vNLCle4BfyDm9HwWNOf8qU6fu9ZHVbz+qM7AUO2+ hjtFv2xfyIYnj36Jr5UkggkUfKEpG+u+CpDaGy+jvdb5cRM8cdW/BFr1DmyBh8ykgZ A+onhe5XfI6fnEPoYo5B4XEKGDou1F9nCi2P0ZGTG2IJYyGu7BSjmOQmM+Q8TVGRfd ZvmgpyITYotiJO2Okdgp887wYJBeNEufXuTVMaC3wUFk7JbYR2wLd5IiKKWEStrlUP DD5WHQhVEn3UcvTuhg0gqOU/EBFU9gDBrKKgVfQ7duL809XOFrYLLYdikpK+LbTCkE Td8EeFZsBaUjg== 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 v7 29/49] media: coda: Stop direct calls to queue num_buffers field Date: Thu, 14 Sep 2023 15:33:03 +0200 Message-Id: <20230914133323.198857-30-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (lipwig.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:36:13 -0700 (PDT) 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777046001524742296 X-GMAIL-MSGID: 1777046001524742296 Use vb2_get_num_buffers() to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- drivers/media/platform/chips-media/coda-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/chips-media/coda-common.c b/drivers/media/platform/chips-media/coda-common.c index cc4892129aaf..f1d85758f6dd 100644 --- a/drivers/media/platform/chips-media/coda-common.c +++ b/drivers/media/platform/chips-media/coda-common.c @@ -794,7 +794,7 @@ static int coda_s_fmt(struct coda_ctx *ctx, struct v4l2_format *f, if (vb2_is_busy(vq)) { v4l2_err(&ctx->dev->v4l2_dev, "%s: %s queue busy: %d\n", - __func__, v4l2_type_names[f->type], vq->num_buffers); + __func__, v4l2_type_names[f->type], vb2_get_num_buffers(vq)); return -EBUSY; } From patchwork Thu Sep 14 13:33:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139647 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp440794vqi; Thu, 14 Sep 2023 08:44:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFIe+Scs9WzDVIpG5ugw7Lg4W806FG4GbTBUdlTraNnQdJ+Z88eEl4W8jBC/Lp29f2kkpmu X-Received: by 2002:a92:d986:0:b0:349:4e1f:e9a0 with SMTP id r6-20020a92d986000000b003494e1fe9a0mr5529971iln.2.1694706240367; Thu, 14 Sep 2023 08:44:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694706240; cv=none; d=google.com; s=arc-20160816; b=or8nYKedXwtiXPapUQuTW/Dcu9sVzcPQy7F5pzuwRy2aa2AFKhJDlkp8nQGiNoR7PA tUO8Vc7ENPC7laC/jVBcNSmRVxgZUPBPbnnX3p58lELLp71f/WSVGVmU6J8EzQeLrYVi QLuQbU4DkWiQOEpPhKAZXaMoodSVbG2AnO5C/ZtjD1Stb6TQed1EpGQMzzrI+qtsRdaq WhASpQlPTIHllRMqJZi6pwG0Kw9jjxV215IXDVgiXWI/rH6WG+PkXmmR7SnbTCpjOl0V fM9EJxva95iYh6fJswYDS5WNvM0gMce35qcHvjWzNTEd+19Py9vfkzQn/VDblKFksRdO ArpQ== 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=jV6i3xIP4hGxH8EXvLuds7UKlCHHz8u2pXx32VH8m+k=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=xRmXI+LRvHBh9dxLQPRnTQQp5hN3jZpATbEw/BJW6yzrhjjlsq09ReQCEuwiUXYTDz WIsMuwo9Pq2LTj0x4v3SDJLK/8Roo0Q6ky5BfzqD/SAM+HM6B5JxmarNeBcI/nG2WsiU PlOU7tCQYuiz6Vjn+Id5jZSs956HqSC7Xp8ljJsjStenqDH5eXQjQHDliwNwq9zpKnhY BoJwNIU/1Aq4PsiclAzbPJX6sCp5p5Lua1UjRmEWoys081nke5OzHb4XMR+EFVjGHrK0 YvSZnAgHpcjN1JhtA9PULw0F8h4RKReuDgr7i30Ax/ucS4lyWX1OkTvV5CfY/tbFH+Be 2vZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=HpCcDjwI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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. [23.128.96.34]) by mx.google.com with ESMTPS id ca20-20020a056a02069400b0055be9526b7fsi1993849pgb.416.2023.09.14.08.43.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 08:44:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=HpCcDjwI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 6767A8705EB3; Thu, 14 Sep 2023 06:35:08 -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 S239864AbjINNey (ORCPT + 35 others); Thu, 14 Sep 2023 09:34:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239296AbjINNeI (ORCPT ); Thu, 14 Sep 2023 09:34:08 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 667ED212C; Thu, 14 Sep 2023 06:33:48 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 C8FBF660737E; Thu, 14 Sep 2023 14:33:46 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698427; bh=cxYwkj/F6kj42Kfzns0GGyq/E2dEjF9Je+84qllCmIY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HpCcDjwIzbu/CFpkbHzElKPkqKLgrYNOoIw0sHPR+JiGA/xYLs71WQOC1eJ1pPVFx Ae20c+bd06EakvdwkNEm0rciFoLMRdX7qE9vKLHHhtAXhN3zERt8K0oJZU1CD9RKwM R5EaqiY4AefrXlaYthIIS9w4VWVAI8g7GuNGLM6/b4bwQ1Pb/mh0cyt8BqvD03WE7A Xdoyfmq+KrpIZ2LyYgdW6M95sa6/tklcHf2ugKxMG9jzqKxIjiXgMJAso4EbnBKlvf 4y3vTKB1f8NsRAdNKLMucjH0GX1cJazDjz8jCRbaEDTMKdar2s0FQVIZmn+YEhcidV yjpJz2EwdszbQ== 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 v7 30/49] media: mediatek: vcodec: Stop direct calls to queue num_buffers field Date: Thu, 14 Sep 2023 15:33:04 +0200 Message-Id: <20230914133323.198857-31-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (howler.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:35:08 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777028290566922041 X-GMAIL-MSGID: 1777028290566922041 Use vb2_get_num_buffers() to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- .../platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 2 +- drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c index 3d2ae0e1b5b6..a04003d20b1d 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c @@ -1695,7 +1695,7 @@ static int vdec_vp9_slice_setup_core_buffer(struct vdec_vp9_slice_instance *inst return -EINVAL; /* update internal buffer's width/height */ - for (i = 0; i < vq->num_buffers; i++) { + for (i = 0; i < VB2_MAX_FRAME; i++) { if (vb == vb2_get_buffer(vq, i)) { instance->dpb[i].width = w; instance->dpb[i].height = h; diff --git a/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.c b/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.c index 04948d3eb011..ff183c9142a3 100644 --- a/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.c +++ b/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.c @@ -923,7 +923,7 @@ static int vb2ops_venc_start_streaming(struct vb2_queue *q, unsigned int count) mtk_v4l2_venc_err(ctx, "pm_runtime_put fail %d", pm_ret); err_start_stream: - for (i = 0; i < q->num_buffers; ++i) { + for (i = 0; i < q->max_allowed_buffers; ++i) { struct vb2_buffer *buf = vb2_get_buffer(q, i); /* From patchwork Thu Sep 14 13:33:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139605 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp365773vqi; Thu, 14 Sep 2023 06:58:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG+IYE3FcUKUaa67YJd2G/aF/F0OTPPbZaCsCor518Q8CUSq4zn3lSBxMoT8vqemoIZTF5S X-Received: by 2002:a05:6358:2512:b0:142:efb8:5295 with SMTP id m18-20020a056358251200b00142efb85295mr1926680rwb.19.1694699882080; Thu, 14 Sep 2023 06:58:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694699882; cv=none; d=google.com; s=arc-20160816; b=J5p7sn8A4PoRAOD/3syZkywWlKMOLv2zXOfjGLXVKzqsIMcPRNqdxdgllq6VtDAh7b jh5b7U8M0Swz5H65CBYynXtby/yi24JByGA/6EfUY0/81IVjfutae1RyywE+Jv7hoYDh t0U3LcIVPJqBoS0wj3eUp1853Xzr42Jr10xGON75rmqdDo/sb8riYHenm4Tg41GFMLvf OdRQwj8bXEGRic46UZZ4xJU/5JXFxVhFLg4nR/qHDP1o4CeSWUKF/b1e3/REZZf3fUhT 7yPhjRB1rkx+oqlG9eDXVbVcfG+UTt0Ly3Zk+aCNqBWtfdsi5lvet2a7AT3taZ83JeOJ go1A== 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=oTtmKjE7vQhNKhTumrx56oub9WvRubSN6lcnNjeiil4=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=fekf+GVvpzpP2WqXvCSBwSN6hXLVjYq8XKJyy1Q5OsvIHWKiLUhns92Co9iyBNHRQT HmCUVCW1P2mNrJdraMP8nshlN5dK1H2SuAxaPp9El8RE7pIY0FOzg4TVeLBc9NPWSzOt 21l2Hh6hlUsiqTFqbVOm/Wj2aaKHhdbW42LO0mnXFl1zEirkJk+vjuoIFNwHn1qpkcxQ ORF0bck2faiBVTAyKGnhCxw+3Et0f1ptPYRpfW8GvOL9cPhFekdP+H8k8W9fmUfOvgkK YQSt4tD9Ki2V/gVSY+jgpV3U6mkqSkJopT/1yXE+5lEn/XyYYpjFe+CcaiWSNDif6rSo qHNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="BW/4Li6K"; 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 az1-20020a056a02004100b0057745d87b53si1515917pgb.686.2023.09.14.06.58.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 06:58:02 -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="BW/4Li6K"; 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 2E3698705EAE; Thu, 14 Sep 2023 06:35:07 -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 S239877AbjINNe5 (ORCPT + 35 others); Thu, 14 Sep 2023 09:34:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239444AbjINNeL (ORCPT ); Thu, 14 Sep 2023 09:34:11 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02F662137; Thu, 14 Sep 2023 06:33:48 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 553316607382; Thu, 14 Sep 2023 14:33:47 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698427; bh=cXivZNqToe41YcZuXIOZnOz7dFiXtOZiRZUwxPYGOCA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BW/4Li6K5XG6+3vbXDnIR7ChVsl6ZXW8TLElpv89AbHI8KTYjXFsrimfikBDy3zpD 5yeVs584mxICnpxmqLwLwpDIlut30f3mPncqh1kmfrMch623WJsC0kxkJkCkhQUsI1 l2xPjcNq/AQsUJKsz62nZwvcK9WUJfRVElhEI4BS3dCRzTxJtt9dzb3wCP1UDPInax I8NPTG3IZ9ZAXYa7ukFtL19FCGjYbh6Z8Acdkxvi5wmEkzQbtcucrmE3J2E+NALG1H vzxl3c6XqyR4qOAjjgUgoqNg5hReh+N4/lV4sqBQICAWvk/ZxFzub6griqozOykHD/ V76u5/javVwJQ== 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 v7 31/49] media: nxp: Stop direct calls to queue num_buffers field Date: Thu, 14 Sep 2023 15:33:05 +0200 Message-Id: <20230914133323.198857-32-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (howler.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:35:07 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777021623516260375 X-GMAIL-MSGID: 1777021623516260375 Use vb2_get_num_buffers() to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- drivers/media/platform/nxp/imx7-media-csi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c index 15049c6aab37..4c467fb82789 100644 --- a/drivers/media/platform/nxp/imx7-media-csi.c +++ b/drivers/media/platform/nxp/imx7-media-csi.c @@ -1245,6 +1245,7 @@ static int imx7_csi_video_queue_setup(struct vb2_queue *vq, struct device *alloc_devs[]) { struct imx7_csi *csi = vb2_get_drv_priv(vq); + unsigned int q_num_bufs = vb2_get_num_buffers(vq); struct v4l2_pix_format *pix = &csi->vdev_fmt; unsigned int count = *nbuffers; @@ -1254,14 +1255,14 @@ static int imx7_csi_video_queue_setup(struct vb2_queue *vq, if (*nplanes) { if (*nplanes != 1 || sizes[0] < pix->sizeimage) return -EINVAL; - count += vq->num_buffers; + count += q_num_bufs; } count = min_t(__u32, IMX7_CSI_VIDEO_MEM_LIMIT / pix->sizeimage, count); if (*nplanes) - *nbuffers = (count < vq->num_buffers) ? 0 : - count - vq->num_buffers; + *nbuffers = (count < q_num_bufs) ? 0 : + count - q_num_bufs; else *nbuffers = count; From patchwork Thu Sep 14 13:33:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139604 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp364922vqi; Thu, 14 Sep 2023 06:56:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFDkATZ8RO995zwrVIN2iNJuWabkXJcwuTMpqIUug7wC7G7mFHtx51oVlPlxUOu18Ib2wmn X-Received: by 2002:aa7:88c8:0:b0:68e:3f55:73d with SMTP id k8-20020aa788c8000000b0068e3f55073dmr7165520pff.10.1694699776329; Thu, 14 Sep 2023 06:56:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694699776; cv=none; d=google.com; s=arc-20160816; b=eMSNEA1WiibPR/Fo0nHzNbCJdrrcP1ip2VPAhDXq4Mt7kjILjhUXwFoQ8Q67jF/VlP lUPnfp1cHlW1UTdO6Srm94430ark/tjKl07IPo2kb1NeSU6JLWqU/WhTwSaCqJpYriwZ bUzGFETHMnsPzE1rkBg4Dl8qCXWDJl8sNzcY/Wqz/P7IY+mydRhUDeImdc3DoIIlwTZ0 TDW7aDYBS8y5dP7Ufah/C0ZI0n4M2LZvkkcSKVKzbpmN7dT1Lldatwc/IDlXZ8ZaX0Mt Jiu034Kk65OeBmnf8culbvrAb9rMJpcDWRa/XsRrAg/mcBe8g3vq0c2Orh5D1S7jQcl/ py9Q== 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=EOLwZeOQyt9Z2OpMXoM+CKH/9zJiFeP4flDrP3qjOLw=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=QzAeFrm3jUlqrjxA48D8rVMg23iFU1F5TVGV5zESo0ihnnGid+dnj7ev+XbCpO2GK5 TBg3jibGi2GWAgG3CVcLxnoIAViJ98uI1J2/6XqXzFWVilrl8yaZcmqXYaWdYfmO6+MQ +tzZ+vyXfK1xCtcTmMrhzSbuznSCA0NfJHN6Sasrr8qitN/WH9d1MRN6eimev7HLBNcW /ZkygZB2QVOBxWxORZNz+TuChV6WcBXt4mAeQnE/fIKfHLQDfe4pn2R7gPXPTHzGHG2o NVKU3Tw8GZc/FhphEOJKBAJRlGu0x1/X08VdwZ83fVA4p3kiDm9jpF03Ggavv6Ex6ljA 6aNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=nsLr5+8m; 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 p16-20020a056a000b5000b0068a55b8e380si1738308pfo.230.2023.09.14.06.56.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 06:56:16 -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=nsLr5+8m; 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 01D3888D6A05; Thu, 14 Sep 2023 06:35:17 -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 S239307AbjINNfB (ORCPT + 35 others); Thu, 14 Sep 2023 09:35:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239475AbjINNeM (ORCPT ); Thu, 14 Sep 2023 09:34:12 -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 9FD532689; Thu, 14 Sep 2023 06:33:49 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 D66786607383; Thu, 14 Sep 2023 14:33:47 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698428; bh=NPGIQWBbvKHkPrDtzyz0rTHCYJ8HXTuAbKhvtuCEFls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nsLr5+8mLvfOrgpNrxeRPFIZBpS7RDRjBEkq2keyOtri/Y8m9Doex7VZ08sCyT4AS uvsYBd/LNNaNa9EPqNFUhrdzadnCHcDCg3IbX2B1H3WguvsspTanWkkz4ISydPd6CK d6EdGU0B6m+RJd1TeOpfeIP1Hmm2K55LkjG1rYXZIpIG4SP765J3hsLDdCll8bzCJK BGhgRsPlI0FHlHuTn9EWaOD4Z9WZAwhXeHS5cLhEtQbwIVuLxKvubCRxJqOnHsJmS6 Li5AvmHOLLYsA/qf9VW7iszfL3vITXQdk+V/QKvqbo6oyyPqGrY4WVZv5AsmJbzFHZ Vdbln3Or/evjA== 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 v7 32/49] media: renesas: Stop direct calls to queue num_buffers field Date: Thu, 14 Sep 2023 15:33:06 +0200 Message-Id: <20230914133323.198857-33-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (howler.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:35:17 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777021512445951386 X-GMAIL-MSGID: 1777021512445951386 Use vb2_get_num_buffers() to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- drivers/media/platform/renesas/rcar_drif.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/renesas/rcar_drif.c b/drivers/media/platform/renesas/rcar_drif.c index 163a4ba61c17..020845689ed3 100644 --- a/drivers/media/platform/renesas/rcar_drif.c +++ b/drivers/media/platform/renesas/rcar_drif.c @@ -424,10 +424,11 @@ static int rcar_drif_queue_setup(struct vb2_queue *vq, unsigned int sizes[], struct device *alloc_devs[]) { struct rcar_drif_sdr *sdr = vb2_get_drv_priv(vq); + unsigned int q_num_buffers = vb2_get_num_buffers(vq); /* Need at least 16 buffers */ - if (vq->num_buffers + *num_buffers < 16) - *num_buffers = 16 - vq->num_buffers; + if (q_num_buffers + *num_buffers < 16) + *num_buffers = 16 - q_num_buffers; *num_planes = 1; sizes[0] = PAGE_ALIGN(sdr->fmt->buffersize); From patchwork Thu Sep 14 13:33:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139597 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp359184vqi; Thu, 14 Sep 2023 06:45:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE7dBDu1YNBNUkJuqwIbYn/llBlkdYNaffgrT5h7A5SQA+E8oyEfmHE+Vh29FZzQM4nra0m X-Received: by 2002:a17:902:e748:b0:1bb:8e13:deba with SMTP id p8-20020a170902e74800b001bb8e13debamr6003691plf.11.1694699145613; Thu, 14 Sep 2023 06:45:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694699145; cv=none; d=google.com; s=arc-20160816; b=d/XLo0xBYoQjpN9jMt6H8xawebZDGpQOGN34sNldeIkHVTuS5DCHFyTiamd0f73F9v 0sRJzP8Fis2Vrvd+Kz3O2wImjvdGInWBjXBMAD0nzZc9kOsFahZ7jf9umB2NDjwzGhpg WgBp47Bs8efqBdrpmmnNTIy0cO8lp5C8f1mZ5ASpfZdTBrTI2dY9WGSp4mB1nssaiOjZ IErwXi9+76GB5kNqRRCx5jJ98+kYAQk04H/UqFi0WoW9RYfuZaF01b0eJcHGDtP7Hm6x ZncqhU1w/Us0svuhzXpoBxZlhlItWhmq9id1736d9si5uW1lWiVhItvUzLbjTTukmY0M VzPg== 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=YuTUXwwrjQhGjkZuYgcK/Bhhrcrd12yf6DwoX1wzW74=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=QdLRk7TDlI4bWMYrxh75K77C1+jNPfxnGC7O9k+AhuDezASJ10a6Z5U94hcUs8Q1di gEJfhhy3EH85epMkQ51y8ELkmzPaKij/eJov5htP7TiBMt5x/gNxr8xKcrCIPktX807O WRsPKRF4tojcpwFZBSARwVb4Oz/GMUnh+0x6xHUD0EHaHqPJR0RXWRl67vMTYHrB/zut riwj6eLelt//qRrjzqU+hTRXi80vsfpRyg/I7cUWtEACYmhd9Bsp3vU//a7sBG7tHZMS fRcH+nOC72/yfxv8EPYdb/cMgunV3uM6CPFWYgxR75dehEI3+oTDekq0CAzUZDCCCc9P EgNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=DaoUlmXC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id b13-20020a170903228d00b001bbad3b063bsi1822469plh.345.2023.09.14.06.45.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 06:45:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=DaoUlmXC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id EDC8581DC600; Thu, 14 Sep 2023 06:36:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239613AbjINNfE (ORCPT + 35 others); Thu, 14 Sep 2023 09:35:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239567AbjINNe3 (ORCPT ); Thu, 14 Sep 2023 09:34:29 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9F53268F; Thu, 14 Sep 2023 06:33:49 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 5F0C16607384; Thu, 14 Sep 2023 14:33:48 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698428; bh=5agb5+731PbAsmHV0HkXiz/yWnDWBOST3c/elC0GOlM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DaoUlmXCrWVmNSTPHSiU0Kze4b4dAxEsiAESC1T1RfI/N0JSuqIQOAC/pOIRJqpy4 IbiKdjzHMO2qLKCSGrfwliIrQojFUKgG/R/Z1Y8pDeP6+bXkNYoQMnC9Z+Z/rJbhyh ph1SM0l0l8VshDQXmDv920KdJUit/rNECupZfAv3ipHMW2mHAJZK2iQe9A78H0W+z5 U9e+q85xg3sPaR4acMAVSHtDAB2q2JzFEMfNO7e7bHQSMKz5rZa9qW8iLkDBflDnLd K1VEIXpGL0dy6JQifII9yJzBQQ3XK/ZRpK3MU+1qOSgK9QLT7h7/zBDb0jjd+91lC/ UOgkav/mWZIrQ== 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 v7 33/49] media: sti: hva: Stop direct calls to queue num_buffers field Date: Thu, 14 Sep 2023 15:33:07 +0200 Message-Id: <20230914133323.198857-34-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (lipwig.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:36:01 -0700 (PDT) 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777020850917967271 X-GMAIL-MSGID: 1777020850917967271 Use vb2_get_num_buffers() to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- drivers/media/platform/st/sti/hva/hva-v4l2.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/media/platform/st/sti/hva/hva-v4l2.c b/drivers/media/platform/st/sti/hva/hva-v4l2.c index 326be09bdb55..cfe83e9dc01b 100644 --- a/drivers/media/platform/st/sti/hva/hva-v4l2.c +++ b/drivers/media/platform/st/sti/hva/hva-v4l2.c @@ -569,13 +569,6 @@ static int hva_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf) struct vb2_buffer *vb2_buf; vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, buf->type); - - if (buf->index >= vq->num_buffers) { - dev_dbg(dev, "%s buffer index %d out of range (%d)\n", - ctx->name, buf->index, vq->num_buffers); - return -EINVAL; - } - vb2_buf = vb2_get_buffer(vq, buf->index); if (!vb2_buf) { dev_dbg(dev, "%s buffer index %d not found\n", ctx->name, buf->index); From patchwork Thu Sep 14 13:33:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 140441 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1064219vqi; Fri, 15 Sep 2023 06:57:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHXsIhvbFPxROw4hCmwWkaLX5IDY59eusyIR8CxiwhtveotpQkDYaf6M8RrG2gzxUO86whW X-Received: by 2002:a05:6a20:12c4:b0:133:38cb:2b93 with SMTP id v4-20020a056a2012c400b0013338cb2b93mr2242194pzg.9.1694786258521; Fri, 15 Sep 2023 06:57:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694786258; cv=none; d=google.com; s=arc-20160816; b=fLkZ22oTJeC5oG3HduKNR7E+/+dJr4JzphF66tUlKUdOWRVGnCj6gC0lSyAX15vGUK /EbqfbolXkRAzkK0ZqhKrHsEuo9wZS2bjNPujukXAl2zrI4PT5Gc/hCXnvt8JGS0JIFf VEXPUk+lmHHmzEbgCzMq0y54ES8fl80SdlzQanqQEmbH8UGsYdb1Y9Cv65emkVkaf5GQ oaWhZUPISL5Eq+dKNfsGJ+jqNkvYYl5IQaEEAKlmFxdT7P2bMfiGy6EQEEsXTab320hx 73QSTB+APybzNGmyamEA7nyHa4rkpBvRabFXWk9UJNSuWu7DIU3qH2uZOa+Br1OjtX7n ZQrA== 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=gi3AVTofL4Sa3yATdEji1aHdu4KChoTVSEyU4SIluIw=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=0Tj9neihreCKU9a60IYUurMRUr0sm4BYrfH0OV4/eoMzdwnxuvTG06QbKAxYlsdI3s hP35jLiusHwbJPGHJAgYqMrPL3Jn6pq88dp0Wu/njwn3BJJ8cPKUIMJ8hflmleU/ia3V BoJbVLNPlOhtitIM6Hb/FfX9lCJ+EZ7OTF64lVIGL0jlaH/YIzbNK2jwhY2zY1INV31b fIXVAwt/K1AuMpbhzTx/FuAsYuajYC0ATB8v3lfqr5jL6SEVrP5r1mjWKezC2XfBSvAT CwZVfVUxnCnLNO4CgknqOQOW5KgyPeJnAvWXzf/U8EQ/hZskUo947bwiOcW1j8GXt+nc VwZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=DgFMJRRy; 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 x71-20020a63864a000000b00577521a5503si3272601pgd.475.2023.09.15.06.57.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 06:57:38 -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=DgFMJRRy; 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 EBD838766ABE; Thu, 14 Sep 2023 06:35:22 -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 S239350AbjINNfL (ORCPT + 35 others); Thu, 14 Sep 2023 09:35:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239631AbjINNec (ORCPT ); Thu, 14 Sep 2023 09:34:32 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FDA426A0; Thu, 14 Sep 2023 06:33:50 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 DDDFF6607357; Thu, 14 Sep 2023 14:33:48 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698429; bh=cbszs7jBOfbla1DDC74zl4poj/pPrdoEU2YTt7/fzAM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DgFMJRRyh60YBJZYxpe41d4iSCnr68fszfWc/Os4u8ajsF8XC9AFXRT6EhvbKtZXS zzKQ/uWBBQNX+NBxbagk5DA93roP6dIuPwnB4gFD3VHsI/lGtVNDTVmt+aBm4F0ERx ljulfrXW5Y7dPXtgO2n4k9+i7Ko1FY2c7zeqqMoMKi56WuIUIqrKelv9pyWvv9CUpv RCv8E4sD3F5X6MHv/K4mZ2Tu9xoycyQkpldbJReHwq99RJ3Q46OvnVyCn5EijXUDtW 7XGXVNdiTBed00u9xyuSurvwIOCOoIE3uNBH75UpAN38S8PFj+uQ1S7jJvDWFpfDKH XgjvCiOHdFbIg== 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 v7 34/49] media: ti: Stop direct calls to queue num_buffers field Date: Thu, 14 Sep 2023 15:33:08 +0200 Message-Id: <20230914133323.198857-35-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (howler.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:35:23 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777112195871814714 X-GMAIL-MSGID: 1777112195871814714 Use vb2_get_num_buffers() to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- drivers/media/platform/ti/am437x/am437x-vpfe.c | 5 +++-- drivers/media/platform/ti/cal/cal-video.c | 5 +++-- drivers/media/platform/ti/davinci/vpif_capture.c | 5 +++-- drivers/media/platform/ti/davinci/vpif_display.c | 5 +++-- drivers/media/platform/ti/omap/omap_vout.c | 5 +++-- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/ti/am437x/am437x-vpfe.c b/drivers/media/platform/ti/am437x/am437x-vpfe.c index 63092013d476..3b1e5dfecdbc 100644 --- a/drivers/media/platform/ti/am437x/am437x-vpfe.c +++ b/drivers/media/platform/ti/am437x/am437x-vpfe.c @@ -1774,10 +1774,11 @@ static int vpfe_queue_setup(struct vb2_queue *vq, unsigned int sizes[], struct device *alloc_devs[]) { struct vpfe_device *vpfe = vb2_get_drv_priv(vq); + unsigned int q_num_bufs = vb2_get_num_buffers(vq); unsigned size = vpfe->fmt.fmt.pix.sizeimage; - 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 (sizes[0] < size) diff --git a/drivers/media/platform/ti/cal/cal-video.c b/drivers/media/platform/ti/cal/cal-video.c index a8abcd0fee17..5dfe40ca47fc 100644 --- a/drivers/media/platform/ti/cal/cal-video.c +++ b/drivers/media/platform/ti/cal/cal-video.c @@ -602,10 +602,11 @@ static int cal_queue_setup(struct vb2_queue *vq, unsigned int sizes[], struct device *alloc_devs[]) { struct cal_ctx *ctx = vb2_get_drv_priv(vq); + unsigned int q_num_bufs = vb2_get_num_buffers(vq); unsigned int size = ctx->v_fmt.fmt.pix.sizeimage; - 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 (sizes[0] < size) diff --git a/drivers/media/platform/ti/davinci/vpif_capture.c b/drivers/media/platform/ti/davinci/vpif_capture.c index 99fae8830c41..fc42b4bc37e6 100644 --- a/drivers/media/platform/ti/davinci/vpif_capture.c +++ b/drivers/media/platform/ti/davinci/vpif_capture.c @@ -113,6 +113,7 @@ static int vpif_buffer_queue_setup(struct vb2_queue *vq, struct channel_obj *ch = vb2_get_drv_priv(vq); struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; unsigned size = common->fmt.fmt.pix.sizeimage; + unsigned int q_num_bufs = vb2_get_num_buffers(vq); vpif_dbg(2, debug, "vpif_buffer_setup\n"); @@ -122,8 +123,8 @@ static int vpif_buffer_queue_setup(struct vb2_queue *vq, size = sizes[0]; } - if (vq->num_buffers + *nbuffers < 3) - *nbuffers = 3 - vq->num_buffers; + if (q_num_bufs + *nbuffers < 3) + *nbuffers = 3 - q_num_bufs; *nplanes = 1; sizes[0] = size; diff --git a/drivers/media/platform/ti/davinci/vpif_display.c b/drivers/media/platform/ti/davinci/vpif_display.c index f8ec2991c667..9dbab1003c1d 100644 --- a/drivers/media/platform/ti/davinci/vpif_display.c +++ b/drivers/media/platform/ti/davinci/vpif_display.c @@ -115,6 +115,7 @@ static int vpif_buffer_queue_setup(struct vb2_queue *vq, struct channel_obj *ch = vb2_get_drv_priv(vq); struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; unsigned size = common->fmt.fmt.pix.sizeimage; + unsigned int q_num_bufs = vb2_get_num_buffers(vq); if (*nplanes) { if (sizes[0] < size) @@ -122,8 +123,8 @@ static int vpif_buffer_queue_setup(struct vb2_queue *vq, size = sizes[0]; } - if (vq->num_buffers + *nbuffers < 3) - *nbuffers = 3 - vq->num_buffers; + if (q_num_bufs + *nbuffers < 3) + *nbuffers = 3 - q_num_bufs; *nplanes = 1; sizes[0] = size; diff --git a/drivers/media/platform/ti/omap/omap_vout.c b/drivers/media/platform/ti/omap/omap_vout.c index 4143274089c3..72ce903717d3 100644 --- a/drivers/media/platform/ti/omap/omap_vout.c +++ b/drivers/media/platform/ti/omap/omap_vout.c @@ -944,10 +944,11 @@ static int omap_vout_vb2_queue_setup(struct vb2_queue *vq, struct device *alloc_devs[]) { struct omap_vout_device *vout = vb2_get_drv_priv(vq); + unsigned int q_num_bufs = vb2_get_num_buffers(vq); int size = vout->pix.sizeimage; - if (is_rotation_enabled(vout) && vq->num_buffers + *nbufs > VRFB_NUM_BUFS) { - *nbufs = VRFB_NUM_BUFS - vq->num_buffers; + if (is_rotation_enabled(vout) && q_num_bufs + *nbufs > VRFB_NUM_BUFS) { + *nbufs = VRFB_NUM_BUFS - q_num_bufs; if (*nbufs == 0) return -EINVAL; } From patchwork Thu Sep 14 13:33:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139768 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp547716vqi; Thu, 14 Sep 2023 11:37:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGEC1FiYgWUar38GWYrBqebwyI8pK2x/ETt2gWcxIvBwa29FbdKg7Be6oDJl4HyfQtC1AKe X-Received: by 2002:a05:6358:429e:b0:134:f070:d6b8 with SMTP id s30-20020a056358429e00b00134f070d6b8mr6922360rwc.4.1694716664498; Thu, 14 Sep 2023 11:37:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694716664; cv=none; d=google.com; s=arc-20160816; b=m2ylr2vfuyd6FVd01xVquty1hfPPw+K40GVr/Qm/ItYP/hKC/sWtTmCRkLy4i9k0M7 yAtn13+wIRyoAcrTC0w1xAQJ6HQHjRZhh+a10FDe7lGyxK6iYl+jpEJOXLk0Z4u7app1 KudyfEnm+pu33jC1Milpi25YdmbygGOY8WEXD+sUh69g68swnM0E4rplsgd7cWu5QA+u dbfEffFXPKx9nxAws25xDjjNk/JwheLgQeLq9ABWqbxYPcypfkcZD0H4SKkCx+VKiGJB 92mDh8coSG+V85h/KOOH/EFRkc6ud+ATj0qCwkAEDxNCtfWfwWoSddBUtTDeZvZ7Ydhx Jflw== 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=qzNrOqHsDWVtu/+m5mo+jpifKlOXBV0CR6JVjceXOZQ=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=Odqh2MqxYp+S9NkUqfcy4xC/Q3ontBL0zmPFeHtsYxj4U3BWZFM/E7XvI6wWbl22L8 7COkFUbV82BPS63REew8SRPowSjKp9c/i5BW96XPDzqn4HzYqOBzqJzvGaldJS88WjJl xuj/j36zV0JLww8NZd0XSWGlLmqbFBAjA/vLnB47rvr0XDYV3fVnVMBQDXhwZPqzGcB5 f8IVTNcypDUTS+P9uS0lM6FJG/iPhGmXa3Hjl1pYAopTFcq0a8nkkA+T00vxll/hKzZL k9Htfu7qQPKfafdXK+bKpwXBkZAmA+druVnj8VKVqhTId6nSlHmQmzAYAx7j4G/pzekZ YNwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=KMc3c3PZ; 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 w62-20020a638241000000b00573fdd098a7si1892846pgd.471.2023.09.14.11.37.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 11:37:44 -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=KMc3c3PZ; 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 3CC3088D6A2A; Thu, 14 Sep 2023 06:35:31 -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 S239983AbjINNfN (ORCPT + 35 others); Thu, 14 Sep 2023 09:35:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239348AbjINNeg (ORCPT ); Thu, 14 Sep 2023 09:34:36 -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 0982326AB; Thu, 14 Sep 2023 06:33:50 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 672906607358; Thu, 14 Sep 2023 14:33:49 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698429; bh=JMZx2uxA26BNI9i9E6OsCtWtCLTgVI42g2rsSFOFa8g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KMc3c3PZVLGDx78559nwmGzDHbm4s0tkKoSi47P9LzcBhzTYs2YRA165nqs1fGqzq dfHzyavdk5PrKZDz/P2YvJW2CbDp5+8+mH7Pe4hZIjuWkqhOQJc/iQ/zRjJSzDReHv IfIxknHFPLUfmDJtf85EWqFbXHsRdsIJgBwwkYEfwSNRxXdjgMgq3PjyXLqPzqAXKE d7qmMSO4fTKRZaKIDf7HX2MOVR/SongSzbQfe2J+lblpTnefsrmk0RdeTMzIkw/MTf op1DvFfCc246LfgbpGRiMzRHGUSDnbmbS5pR8WLXWHpLb8n91Q0P/jBheuzQVjjEXl zEc5T1pYE8gVA== 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 v7 35/49] media: verisilicon: Stop direct calls to queue num_buffers field Date: Thu, 14 Sep 2023 15:33:09 +0200 Message-Id: <20230914133323.198857-36-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (howler.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:35:31 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777039221022831025 X-GMAIL-MSGID: 1777039221022831025 Use vb2_get_num_buffers() to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- drivers/media/platform/verisilicon/hantro_postproc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/verisilicon/hantro_postproc.c b/drivers/media/platform/verisilicon/hantro_postproc.c index 77d8ecfbe12f..a242eedf9cf5 100644 --- a/drivers/media/platform/verisilicon/hantro_postproc.c +++ b/drivers/media/platform/verisilicon/hantro_postproc.c @@ -250,7 +250,7 @@ int hantro_postproc_init(struct hantro_ctx *ctx) { struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; struct vb2_queue *cap_queue = &m2m_ctx->cap_q_ctx.q; - unsigned int num_buffers = cap_queue->num_buffers; + unsigned int num_buffers = vb2_get_num_buffers(cap_queue); unsigned int i; int ret; From patchwork Thu Sep 14 13:33:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 140390 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp995291vqi; Fri, 15 Sep 2023 05:11:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFnCd95DfCuRZyjs+3S8IpcZq8LbjrVl45qm/VhXZaE+kWWNS80lL4VL1/Q9aEUnwVLQ7I1 X-Received: by 2002:a05:6a00:4803:b0:68f:c8b3:3077 with SMTP id di3-20020a056a00480300b0068fc8b33077mr1511951pfb.1.1694779887396; Fri, 15 Sep 2023 05:11:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694779887; cv=none; d=google.com; s=arc-20160816; b=lOMT6WE0SUksibLYeJukgLR76Pj0tUy8KgsPjAlgsP4LYwEpsiDbkWXn3qnD2zRvTX x0sxB61ChJEB61xPiKpaTJgaJdmuErRCpXygM//jWjAktKQFRPGRV9jdbm6o174SKkVu ++GiK3ov4lwdV7ZpSamGSD2jUqm6CV+uje9CDi4a6Mm95LlPXH1GCRTRM2M493isEf7q Y8zmuz5mkLoBsHO1QNJ6pQDEzk3NVK6Ilwgo91uEgYlURQE1owzmQBySpovpUX9/uXFn DhAD3ZlNrdbkmn5yPgUdi+CwSJcFnF+ShGkSQ2QTX22FiIjR2IJj4iCYeM2JobeBSP6D ontg== 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=iF40VzfJHaLHw/QV9mjH0hddCA238p/DMOjmbmNhpV4=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=mzDTZaCzwydzSFvhumjTR7rKW20gWR4u4NnpBRlthOfM67ZZy8gyLEmjSE9jFC4RLf Qk2Cdz05Jy1m4YMf7eXlXfhEQMN21Ro8jIKCUddV+dqffaznOWLW1yIGH50q9TVNTo+d fJLqJG0evFqJIiZp+j1Uu5OA/v/S1TarIzbuQWLmWw71iRts17OaqOBdaOhBZamrDQEW ipSNfrAbqg3EuHIGZIeHwFPNGZYnLG+Batx/s1IGjM6rDI8hE0QNuO4g4kUkbjE6E1kd eZt1sVARe+UQc0HctcqWW0zEvOCPREbcFgiR5ssMJbwuZyu8bPapow5YMByjMRaJQrjm ZzeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=BKySdgRi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id a15-20020a65640f000000b00573fa4cfe44si3238927pgv.170.2023.09.15.05.11.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 05:11:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=BKySdgRi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 F3EF6802D533; Thu, 14 Sep 2023 06:35:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239297AbjINNfR (ORCPT + 35 others); Thu, 14 Sep 2023 09:35:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239351AbjINNeg (ORCPT ); Thu, 14 Sep 2023 09:34:36 -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 8302026AF; Thu, 14 Sep 2023 06:33:51 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 EE0286607386; Thu, 14 Sep 2023 14:33:49 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698430; bh=nAdhAei2sfdOufKeuwN9pMJSVWrRttlIbrMwNBf4Ulw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BKySdgRiV7Rtv6yJBJSbPB3yWzTqU/dLrmop5DiHyTqbnHXKZ3Tg+pWc/oZH5NB03 4cq3NUgpucVFv92GlIAYxlt0CsP3l67r560U7Ws3ABm/5CV5ki23B+yNIf0k7HTCcJ lfzapOsPKTpHyARGYeWjiJ+EHPgyVI5JZjBOWuoqYGvQG+RyPRCVd4DEK/I3hmPmSM SCOEOf3SF/77PLkooMe/nAQpF5MLr8Rl1sB1cuFsy7A0/X85XFqXQxaQvq87mjNMkD NmgouqIMcypWfglS42aF5dizH3pIOOCi8Otbr1Y4Lu9dcg+jn/WVlo8wk1WoEPn0MK CXLySE6DAVLUg== 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 v7 36/49] media: test-drivers: Stop direct calls to queue num_buffers field Date: Thu, 14 Sep 2023 15:33:10 +0200 Message-Id: <20230914133323.198857-37-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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, 14 Sep 2023 06:35:36 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777105515094307449 X-GMAIL-MSGID: 1777105515094307449 Use vb2_get_num_buffers() to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- drivers/media/test-drivers/visl/visl-dec.c | 4 ++-- drivers/media/test-drivers/vivid/vivid-meta-cap.c | 5 +++-- drivers/media/test-drivers/vivid/vivid-meta-out.c | 5 +++-- drivers/media/test-drivers/vivid/vivid-touch-cap.c | 5 +++-- drivers/media/test-drivers/vivid/vivid-vbi-cap.c | 5 +++-- drivers/media/test-drivers/vivid/vivid-vbi-out.c | 5 +++-- drivers/media/test-drivers/vivid/vivid-vid-cap.c | 5 +++-- drivers/media/test-drivers/vivid/vivid-vid-out.c | 5 +++-- 8 files changed, 23 insertions(+), 16 deletions(-) diff --git a/drivers/media/test-drivers/visl/visl-dec.c b/drivers/media/test-drivers/visl/visl-dec.c index ba20ea998d19..81da5dcf890a 100644 --- a/drivers/media/test-drivers/visl/visl-dec.c +++ b/drivers/media/test-drivers/visl/visl-dec.c @@ -287,7 +287,7 @@ static void visl_tpg_fill(struct visl_ctx *ctx, struct visl_run *run) frame_dprintk(ctx->dev, run->dst->sequence, "%s\n", buf); len = 0; - for (i = 0; i < out_q->num_buffers; i++) { + for (i = 0; i < out_q->max_allowed_buffers; i++) { char entry[] = "index: %u, state: %s, request_fd: %d, "; u32 old_len = len; struct vb2_buffer *vb2; @@ -347,7 +347,7 @@ static void visl_tpg_fill(struct visl_ctx *ctx, struct visl_run *run) frame_dprintk(ctx->dev, run->dst->sequence, "%s\n", buf); len = 0; - for (i = 0; i < cap_q->num_buffers; i++) { + for (i = 0; i < cap_q->max_allowed_buffers; i++) { u32 old_len = len; struct vb2_buffer *vb2; char *q_status; diff --git a/drivers/media/test-drivers/vivid/vivid-meta-cap.c b/drivers/media/test-drivers/vivid/vivid-meta-cap.c index 780f96860a6d..646b1c6a936f 100644 --- a/drivers/media/test-drivers/vivid/vivid-meta-cap.c +++ b/drivers/media/test-drivers/vivid/vivid-meta-cap.c @@ -18,6 +18,7 @@ static int meta_cap_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers, struct device *alloc_devs[]) { struct vivid_dev *dev = vb2_get_drv_priv(vq); + unsigned int q_num_bufs = vb2_get_num_buffers(vq); unsigned int size = sizeof(struct vivid_uvc_meta_buf); if (!vivid_is_webcam(dev)) @@ -30,8 +31,8 @@ static int meta_cap_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers, sizes[0] = size; } - if (vq->num_buffers + *nbuffers < 2) - *nbuffers = 2 - vq->num_buffers; + if (q_num_bufs + *nbuffers < 2) + *nbuffers = 2 - q_num_bufs; *nplanes = 1; return 0; diff --git a/drivers/media/test-drivers/vivid/vivid-meta-out.c b/drivers/media/test-drivers/vivid/vivid-meta-out.c index 95835b52b58f..4a569a6e58be 100644 --- a/drivers/media/test-drivers/vivid/vivid-meta-out.c +++ b/drivers/media/test-drivers/vivid/vivid-meta-out.c @@ -18,6 +18,7 @@ static int meta_out_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers, struct device *alloc_devs[]) { struct vivid_dev *dev = vb2_get_drv_priv(vq); + unsigned int q_num_bufs = vb2_get_num_buffers(vq); unsigned int size = sizeof(struct vivid_meta_out_buf); if (!vivid_is_webcam(dev)) @@ -30,8 +31,8 @@ static int meta_out_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers, sizes[0] = size; } - if (vq->num_buffers + *nbuffers < 2) - *nbuffers = 2 - vq->num_buffers; + if (q_num_bufs + *nbuffers < 2) + *nbuffers = 2 - q_num_bufs; *nplanes = 1; return 0; diff --git a/drivers/media/test-drivers/vivid/vivid-touch-cap.c b/drivers/media/test-drivers/vivid/vivid-touch-cap.c index c7f6e23df51e..4b3c6ea0afde 100644 --- a/drivers/media/test-drivers/vivid/vivid-touch-cap.c +++ b/drivers/media/test-drivers/vivid/vivid-touch-cap.c @@ -13,6 +13,7 @@ static int touch_cap_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers, struct device *alloc_devs[]) { struct vivid_dev *dev = vb2_get_drv_priv(vq); + unsigned int q_num_bufs = vb2_get_num_buffers(vq); struct v4l2_pix_format *f = &dev->tch_format; unsigned int size = f->sizeimage; @@ -23,8 +24,8 @@ static int touch_cap_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers, sizes[0] = size; } - if (vq->num_buffers + *nbuffers < 2) - *nbuffers = 2 - vq->num_buffers; + if (q_num_bufs + *nbuffers < 2) + *nbuffers = 2 - q_num_bufs; *nplanes = 1; return 0; diff --git a/drivers/media/test-drivers/vivid/vivid-vbi-cap.c b/drivers/media/test-drivers/vivid/vivid-vbi-cap.c index b65b02eeeb97..fcd7f40385e9 100644 --- a/drivers/media/test-drivers/vivid/vivid-vbi-cap.c +++ b/drivers/media/test-drivers/vivid/vivid-vbi-cap.c @@ -124,6 +124,7 @@ static int vbi_cap_queue_setup(struct vb2_queue *vq, unsigned sizes[], struct device *alloc_devs[]) { struct vivid_dev *dev = vb2_get_drv_priv(vq); + unsigned int q_num_bufs = vb2_get_num_buffers(vq); bool is_60hz = dev->std_cap[dev->input] & V4L2_STD_525_60; unsigned size = vq->type == V4L2_BUF_TYPE_SLICED_VBI_CAPTURE ? 36 * sizeof(struct v4l2_sliced_vbi_data) : @@ -134,8 +135,8 @@ static int vbi_cap_queue_setup(struct vb2_queue *vq, sizes[0] = size; - if (vq->num_buffers + *nbuffers < 2) - *nbuffers = 2 - vq->num_buffers; + if (q_num_bufs + *nbuffers < 2) + *nbuffers = 2 - q_num_bufs; *nplanes = 1; return 0; diff --git a/drivers/media/test-drivers/vivid/vivid-vbi-out.c b/drivers/media/test-drivers/vivid/vivid-vbi-out.c index cd56476902a2..8f0da5d88bcc 100644 --- a/drivers/media/test-drivers/vivid/vivid-vbi-out.c +++ b/drivers/media/test-drivers/vivid/vivid-vbi-out.c @@ -20,6 +20,7 @@ static int vbi_out_queue_setup(struct vb2_queue *vq, unsigned sizes[], struct device *alloc_devs[]) { struct vivid_dev *dev = vb2_get_drv_priv(vq); + unsigned int q_num_bufs = vb2_get_num_buffers(vq); bool is_60hz = dev->std_out & V4L2_STD_525_60; unsigned size = vq->type == V4L2_BUF_TYPE_SLICED_VBI_OUTPUT ? 36 * sizeof(struct v4l2_sliced_vbi_data) : @@ -30,8 +31,8 @@ static int vbi_out_queue_setup(struct vb2_queue *vq, sizes[0] = size; - if (vq->num_buffers + *nbuffers < 2) - *nbuffers = 2 - vq->num_buffers; + if (q_num_bufs + *nbuffers < 2) + *nbuffers = 2 - q_num_bufs; *nplanes = 1; return 0; diff --git a/drivers/media/test-drivers/vivid/vivid-vid-cap.c b/drivers/media/test-drivers/vivid/vivid-vid-cap.c index 3a06df35a2d7..0cc7602b9fb2 100644 --- a/drivers/media/test-drivers/vivid/vivid-vid-cap.c +++ b/drivers/media/test-drivers/vivid/vivid-vid-cap.c @@ -77,6 +77,7 @@ static int vid_cap_queue_setup(struct vb2_queue *vq, unsigned sizes[], struct device *alloc_devs[]) { struct vivid_dev *dev = vb2_get_drv_priv(vq); + unsigned int q_num_bufs = vb2_get_num_buffers(vq); unsigned buffers = tpg_g_buffers(&dev->tpg); unsigned h = dev->fmt_cap_rect.height; unsigned p; @@ -117,8 +118,8 @@ static int vid_cap_queue_setup(struct vb2_queue *vq, dev->fmt_cap->data_offset[p]; } - if (vq->num_buffers + *nbuffers < 2) - *nbuffers = 2 - vq->num_buffers; + if (q_num_bufs + *nbuffers < 2) + *nbuffers = 2 - q_num_bufs; *nplanes = buffers; diff --git a/drivers/media/test-drivers/vivid/vivid-vid-out.c b/drivers/media/test-drivers/vivid/vivid-vid-out.c index 184a6df2c29f..25578f55a060 100644 --- a/drivers/media/test-drivers/vivid/vivid-vid-out.c +++ b/drivers/media/test-drivers/vivid/vivid-vid-out.c @@ -25,6 +25,7 @@ static int vid_out_queue_setup(struct vb2_queue *vq, unsigned sizes[], struct device *alloc_devs[]) { struct vivid_dev *dev = vb2_get_drv_priv(vq); + unsigned int q_num_bufs = vb2_get_num_buffers(vq); const struct vivid_fmt *vfmt = dev->fmt_out; unsigned planes = vfmt->buffers; unsigned h = dev->fmt_out_rect.height; @@ -73,8 +74,8 @@ static int vid_out_queue_setup(struct vb2_queue *vq, vfmt->data_offset[p] : size; } - if (vq->num_buffers + *nbuffers < 2) - *nbuffers = 2 - vq->num_buffers; + if (q_num_bufs + *nbuffers < 2) + *nbuffers = 2 - q_num_bufs; *nplanes = planes; From patchwork Thu Sep 14 13:33:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139713 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp497601vqi; Thu, 14 Sep 2023 10:11:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8mizCWtJbzJ5+3zttRNRE9diZZck2RJYKOHY9vmNXtanlC+O4Ov0XjtXoT9ZMQL3mkTST X-Received: by 2002:a05:6e02:1a6b:b0:34f:7e36:5f8b with SMTP id w11-20020a056e021a6b00b0034f7e365f8bmr7593921ilv.25.1694711473093; Thu, 14 Sep 2023 10:11:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694711473; cv=none; d=google.com; s=arc-20160816; b=SeWcgQQiJ3aoQiq7Gu22eBq5CMfZN3DxMpdOwR+inz+dWpdvJD+virZpB1i6Vmm96y x5EPxn0ZsEGv8Enr3qNM3pISXtR5T5xfH6u159c88XyyBh2xqTuZIh/wCrbDvBY4k+cP 1pygh7hZape4rBp7s/Gje/0mX4YGMcqNhZ/tEkT7lc32w7sEbbXd32HtwlpzyrxAd3ii 1VhEGqRK4xJ2lWriU33XOuPWMkloWDrkZKXRGm5mlMbGNE1saUtktBwbmXZlleAyPmK4 eWUxDhSFEHk2IkO2/fHBQ4UWkq2JCUTpna2fobQd6mZRdUigpY8kluUFkyX3cEoAeAKJ 8SkA== 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=P7XtX/sqfuIkG3FCCUjhem5eiV5Jj3Kq1GFr/mKplDA=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=M+6zyVsc45+XZx6jXLIlx5R/t50h92Kfp8hvwG1h+VgfC+y4eIGEY661kExOxNKcvv XCfBPQD356nJauZ86giGiAUvpNrJs7DRXMduyr85lUnHHLLEkVXKvQjZoJIvt7pfxh8Y tuFFjls5UP2E4W8YHvdtHjvM6776SHjcicKQflP+6G22Im1IqEpR66ou4GY6OgxsaRvZ F1mSrFdzApiurO7DWqlyrWFJGRbO9j5+SIjr+dOqj8nH7f09D9TK8J7O5URD3o7bmwSe qs/pM/amn3Oyp4k8IcxEKZZ53Gp6miNslWt+V2YqdfwS0tNRQAkxoKQXQjCa2BmtyxsU 86JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=NyhJ2dwt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id n125-20020a632783000000b0057762236e02si1908961pgn.149.2023.09.14.10.11.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 10:11:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=NyhJ2dwt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 A8C0E80FFDA0; Thu, 14 Sep 2023 06:35:58 -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 S239756AbjINNfW (ORCPT + 35 others); Thu, 14 Sep 2023 09:35:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239667AbjINNeh (ORCPT ); Thu, 14 Sep 2023 09:34:37 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DC2626B9; Thu, 14 Sep 2023 06:33:51 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 7C979660738C; Thu, 14 Sep 2023 14:33:50 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698430; bh=qmWuuxIVaok5VOxLNiFLwq+P2WJDPc3grn0IjW7G8J4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NyhJ2dwtPDfal3GMOCQlY4W+pMVniX4P7qIMMF2pK5OTiWXQXvoNHek/ChDKkrmpE tusvef3OC6i+UUb5ZwxTMrrzLxp3qiPcUN0NVdy6atRpaKm376uwRMwlO1NKwsPND2 GZw7MoUDZe9LMrutMBUBRq3tTA6NQThZ4mynhxaJyJWHpirnQ7/VheDKXdUfC9rcyE rgd/MMe+25F9DYK57rnlmNOLCN+0RkhbK/ELmAdQ+SAHxGOkS9sCQFzcxPhdF/MvSn KTDjfMqBcc+M57wKPUWxiyU35uVlabRPlaD505PVFEI/5QqnctZkt0piy+vPOdnCdG n4JHeDZlhgzLQ== 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 v7 37/49] media: usb: airspy: Stop direct calls to queue num_buffers field Date: Thu, 14 Sep 2023 15:33:11 +0200 Message-Id: <20230914133323.198857-38-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (morse.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:35:58 -0700 (PDT) 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777033777199201716 X-GMAIL-MSGID: 1777033777199201716 Use vb2_get_num_buffers() to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- drivers/media/usb/airspy/airspy.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/airspy/airspy.c b/drivers/media/usb/airspy/airspy.c index 462eb8423506..e24e655fb1db 100644 --- a/drivers/media/usb/airspy/airspy.c +++ b/drivers/media/usb/airspy/airspy.c @@ -482,12 +482,13 @@ static int airspy_queue_setup(struct vb2_queue *vq, unsigned int *nplanes, unsigned int sizes[], struct device *alloc_devs[]) { struct airspy *s = vb2_get_drv_priv(vq); + unsigned int q_num_bufs = vb2_get_num_buffers(vq); dev_dbg(s->dev, "nbuffers=%d\n", *nbuffers); /* Need at least 8 buffers */ - if (vq->num_buffers + *nbuffers < 8) - *nbuffers = 8 - vq->num_buffers; + if (q_num_bufs + *nbuffers < 8) + *nbuffers = 8 - q_num_bufs; *nplanes = 1; sizes[0] = PAGE_ALIGN(s->buffersize); From patchwork Thu Sep 14 13:33:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139749 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp515649vqi; Thu, 14 Sep 2023 10:41:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEU1HP+C8W29lEeBik3KoTbS9HbKMbLrEwUmlErfU9tguyyb/OZ2qjRYZq57tNUZYmxTCU2 X-Received: by 2002:a17:90a:1283:b0:268:38a7:842e with SMTP id g3-20020a17090a128300b0026838a7842emr5555758pja.2.1694713301886; Thu, 14 Sep 2023 10:41:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694713301; cv=none; d=google.com; s=arc-20160816; b=j/PNZyhyW4kBI2xbrfpV+5yNVc0cJhVtOnz95dnI4HL8lZFgDB4fHExmYa04ipL5td jbm4HI+/erTexnRD7sbXk/SchNVjEkLSGrxXUjUxjFX8E454TK7FSv37WqYfAMC7bB6c HGhqSDTHbsZYNjXyM4Ux5Z4kG3hP7x4o9rTaa17o4DyODh3Tsg/EhXzLIHLlldX38LOV CZ43e/bb7W5N+QATXSBpgcpJ/fjE6xC15wf7w4zYEI1XtFT+eKCRyK9AQF9AlQTQvzAn ua8vH4Xo8tURtSdFPLmFGkqVfZl/qJ8HGVdfInVEGoPX/8KihGPcl3VYx2I/ScnIU1// RkKA== 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=ZAqRgpKDVDV3j3Lx0EUgt4DwJaMvzdnnmZd2h1bN62c=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=AaNb2aUeoLzSRTflnqGt9X8Qfg9LeoEM5GHapmbwJfo2O4IR0x7U2f06o72B6mDYgi oTT6m1EheYLaz3KznNp6oeXqBe9wE8Fc/nPxipKFtYF6NAauRq1zHXOHDNz95fL5Mnng vnloGhcbj4ztvIn/SiXwfnajsi9ZqSpRmoy0VFSizbPXO7KAxwOSJ4q529e/YG2KfEUp ld4kawRaYjXcMyR569BzgJMqS7M6wLk6ZwlTp47oQk/d17c859Fru3YxmHLyqn2fus9H worDcqMy+o2SVIZ4PEUV8NKP1Lhrlg5fdhM9EYdV9wDi40gBkcjScTi+enD42EtdsWV7 YU0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=CGtACEWk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id b2-20020a17090a6ac200b0027359ccdfeasi4058531pjm.122.2023.09.14.10.41.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 10:41:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=CGtACEWk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 9775E826E69B; Thu, 14 Sep 2023 06:36:35 -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 S239623AbjINNfS (ORCPT + 35 others); Thu, 14 Sep 2023 09:35:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239724AbjINNem (ORCPT ); Thu, 14 Sep 2023 09:34:42 -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 C40272707; Thu, 14 Sep 2023 06:33:52 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 04702660737C; Thu, 14 Sep 2023 14:33:51 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698431; bh=B011NIBIJAGyFwZSTyw+k80RuXUocSH7ODG0b+1sZBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CGtACEWkKQesYSAvkU0BWg6izVBOghL10PsjDrmnT4bDx02gde3v5hddxApJoyq32 7G8nHpvClGZ+VNVUN9eVKGJo6xFkU88LpJI4XEcXXLTc3rKb5zhZQQtbZNb0UcMwax X7VrZFyfglSFeKhixLrtjSQJT7ECGOiY/dyjfjkWPf568Jq67boXyCCvGbx3lbMRt8 8YN2yTLj2AmwOiPi9Yp1KqRPoXfFZDeB2yPxMuHFioVcrml+Sgx4XPCtaHe0Vgpf/z Ut3l7gKG7BiA6mArC8WFrgjNaW5cvOpnxhJPcHYYNYeGsE7Ve4tDHgQRyOktWeGIjW skYKe4axRbNFA== 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 v7 38/49] media: usb: cx231xx: Stop direct calls to queue num_buffers field Date: Thu, 14 Sep 2023 15:33:12 +0200 Message-Id: <20230914133323.198857-39-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (morse.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:36:35 -0700 (PDT) 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777035695023777406 X-GMAIL-MSGID: 1777035695023777406 Use vb2_get_num_buffers() to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- drivers/media/usb/cx231xx/cx231xx-417.c | 5 +++-- drivers/media/usb/cx231xx/cx231xx-video.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c b/drivers/media/usb/cx231xx/cx231xx-417.c index c5e21785fafe..9ec0b7e355e2 100644 --- a/drivers/media/usb/cx231xx/cx231xx-417.c +++ b/drivers/media/usb/cx231xx/cx231xx-417.c @@ -1218,13 +1218,14 @@ static int queue_setup(struct vb2_queue *vq, unsigned int sizes[], struct device *alloc_devs[]) { struct cx231xx *dev = vb2_get_drv_priv(vq); + unsigned int q_num_bufs = vb2_get_num_buffers(vq); unsigned int size = mpeglinesize * mpeglines; dev->ts1.ts_packet_size = mpeglinesize; dev->ts1.ts_packet_count = mpeglines; - if (vq->num_buffers + *nbuffers < CX231XX_MIN_BUF) - *nbuffers = CX231XX_MIN_BUF - vq->num_buffers; + if (q_num_bufs + *nbuffers < CX231XX_MIN_BUF) + *nbuffers = CX231XX_MIN_BUF - q_num_bufs; if (*nplanes) return sizes[0] < size ? -EINVAL : 0; diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c index e23b8ccd79d4..c8eb4222319d 100644 --- a/drivers/media/usb/cx231xx/cx231xx-video.c +++ b/drivers/media/usb/cx231xx/cx231xx-video.c @@ -714,11 +714,12 @@ static int queue_setup(struct vb2_queue *vq, unsigned int sizes[], struct device *alloc_devs[]) { struct cx231xx *dev = vb2_get_drv_priv(vq); + unsigned int q_num_bufs = vb2_get_num_buffers(vq); dev->size = (dev->width * dev->height * dev->format->depth + 7) >> 3; - if (vq->num_buffers + *nbuffers < CX231XX_MIN_BUF) - *nbuffers = CX231XX_MIN_BUF - vq->num_buffers; + if (q_num_bufs + *nbuffers < CX231XX_MIN_BUF) + *nbuffers = CX231XX_MIN_BUF - q_num_bufs; if (*nplanes) return sizes[0] < dev->size ? -EINVAL : 0; From patchwork Thu Sep 14 13:33:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 140137 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp804226vqi; Thu, 14 Sep 2023 21:45:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEMjikuWbf+IKQqaZu4kkcKQYU/0RUJ47ULyi6sUvtQF9TEGhk/lN08jYeAvaqtTtgos0sU X-Received: by 2002:a05:6359:588:b0:142:d3dc:d3f3 with SMTP id ee8-20020a056359058800b00142d3dcd3f3mr710186rwb.0.1694753122923; Thu, 14 Sep 2023 21:45:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694753122; cv=none; d=google.com; s=arc-20160816; b=QFwijrKDK+YqT30v6lulk5zxJZDtTRZUpQ0J1WDF0QwUGf9qlVRbm4dZlLwTpQgWq7 48OW/yOOUvM6gjbHJjYaC/k0VUzws14ON+4MuiBNKVXmkfBgQSjmQABvlw2T0SICG8CP GSBQqmpmcwo+gHDKXJOfB6jT952+NAjbOJHtb6k6K7RX6bRLrnSL2mOZGix/6TJSmD8J 6K+L903sE32c7uYP9uc/pbZb/b4I9ddWT7exrC8vTHFPaX6wVtrLgIhw+qVAusry7R/p uULhWt1Lz4bxweS4Xk6cOKx/NCV9CHhj3XOaZqC58RG/dfh1bCjscwxhveovfOhYVeg8 07FQ== 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=WfkYHk/trVkAjRfanFzeHGLwCwhCkoy3XYc/vqt+hgI=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=ZSP3i/BeiNSUvVEObs9p6gnaiS++iJTGGSbhfp6kq51dC0rwzoZdBWvoz/Mrtpy5E4 uYBx2+s0+u0OcZqiklZV4wHdoq3o8t9xEvcCJ0Jm8zYstvT0syt0gTQtrRChNiJNfdP3 jpSJKmXb0hsFPiBkeOXWACmfZDEgUfN+hAm8rE9VMqh325W/lA3/8H47FM52p89G1YT0 Mt/rWg4m4xUr/AW2esGjlbW4SCClNJdtugLMWAXTGtlRmZjZWVoifjWaZQhRCuoY3d5a DzuozIe1JDKgW3dkv95E+ZZ/o9abJoHitciX3s7ASavjJlXd6DdRRuTBc9bwiL2ri5/g q8Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=FtrDiCcT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id e5-20020a656785000000b0057766b996f7si2568633pgr.824.2023.09.14.21.45.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 21:45:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=FtrDiCcT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 B137D82F4090; Thu, 14 Sep 2023 06:35:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240000AbjINNf2 (ORCPT + 35 others); Thu, 14 Sep 2023 09:35:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239412AbjINNes (ORCPT ); Thu, 14 Sep 2023 09:34:48 -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 1A5C32713; Thu, 14 Sep 2023 06:33:53 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 84CF3660738F; Thu, 14 Sep 2023 14:33:51 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698431; bh=jspqya66/sOJC0Q2CfHFiQMFqhK2LjIJM71tuArTZQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FtrDiCcTc86G8WNqSS69XZsMirB/zhQO0FMh1ndMQqet0ySMzvbnp6ZMe9LwCMmjC rsCNvhVjgbWEaH9oFqRRpfRtLJr9qsGMZUsKFtGLzMnDO7R7morG2c4e67lznT+lmr zhZ/EvgX3pDFC0ZsZ6MfebySFZNPp6YlHWQY0CZu+8K0v0M3L8GTnWLtjkzRRq4/P/ WqeBftrKoHcqEJ5G9JvmfgBtzISw9SVEOjnnlkmVRM+fVyx4XQMNHVNHL+52nZtpDz 6W/miDgFF3JRzviElCG6KYvy4nerjl4SVMzkNWBcl5Grj4BfC08OMselt208df+7Nv mn+7+f4l/k6lQ== 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 v7 39/49] media: usb: hackrf: Stop direct calls to queue num_buffers field Date: Thu, 14 Sep 2023 15:33:13 +0200 Message-Id: <20230914133323.198857-40-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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, 14 Sep 2023 06:35:37 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777077450825348198 X-GMAIL-MSGID: 1777077450825348198 Use vb2_get_num_buffers() to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- drivers/media/usb/hackrf/hackrf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/hackrf/hackrf.c b/drivers/media/usb/hackrf/hackrf.c index 3e535be2c520..9c0ecd5f056c 100644 --- a/drivers/media/usb/hackrf/hackrf.c +++ b/drivers/media/usb/hackrf/hackrf.c @@ -753,12 +753,13 @@ static int hackrf_queue_setup(struct vb2_queue *vq, unsigned int *nplanes, unsigned int sizes[], struct device *alloc_devs[]) { struct hackrf_dev *dev = vb2_get_drv_priv(vq); + unsigned int q_num_bufs = vb2_get_num_buffers(vq); dev_dbg(dev->dev, "nbuffers=%d\n", *nbuffers); /* Need at least 8 buffers */ - if (vq->num_buffers + *nbuffers < 8) - *nbuffers = 8 - vq->num_buffers; + if (q_num_bufs + *nbuffers < 8) + *nbuffers = 8 - q_num_bufs; *nplanes = 1; sizes[0] = PAGE_ALIGN(dev->buffersize); From patchwork Thu Sep 14 13:33:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139890 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp681034vqi; Thu, 14 Sep 2023 16:11:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGaFcMkNJ8myUK87YvL9h94k+R+NxzvzRV8reXVaJU7uTLrnKmTpjSy3cInPZsVgIEtYW2w X-Received: by 2002:a05:6a21:6d8d:b0:159:c3d5:40bc with SMTP id wl13-20020a056a216d8d00b00159c3d540bcmr276133pzb.1.1694733101050; Thu, 14 Sep 2023 16:11:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694733101; cv=none; d=google.com; s=arc-20160816; b=Z3GwYcksmWluzTwyWDh5W/yIyNnwM/r6chlXq8soG53K5A6ZQHGkHH6/3iyiwOF+71 6SABO0H6azz4/QYobSDLrth5PKOOelhWG7Ml98FMzxdeUs12ICjtW68HvcXOH8P8wf+H Xq6RCfYdeZZwT8/2hiJPpqzveBvafPIoTMFha6jhd82kvAg2d1N6u1Q399qzJo2jp6vK GzTHqiWlxaOc8EZZ9Apw8eW/ugMHexFCL5Ke4yPIFx+JQAIyC3tQrW0fkcQmq56ZoU16 ieyWAg9twa4He91DMmQ+kjBqr3ZthsQwx3jah8W+3DU8cjTmpkuKyfVYrS3mXqP9U2AT ghcg== 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=quVGyklw9qjYlLNKcyjosW0fq/RVVduGZ4UbV730Ido=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=ByfNhDYKiOCHDKc0ZOqv8yjlFh1hKiyRGb+NelDy0gcRAnQEutURsRxboj4B7y6UEr Z9hS3E8tO6M7rIp4H2tnakF60RRr8xvb4YpMCFgZHeXdddU3DqVLnt7uIhGKFHMg1fdH le1rgU9x1YkI5rOxqDQRHsZ4SzBr5+U/AhFLZRG0HZiWeu7v+QB5lF8T11E/qLLPDUo6 AgXbOXBEcYAQWsPeBzSvKjEUSxlk2tMGRnA6uWVEUkCd1iPX1EsicluD+4SyQarEpuF+ +M0HDahRMyZePzvy2EBAZIdXoYMOUDNXl4OsKt+ylZNhS2x6j53KW5mVmMFpJnQkxo+j chdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=hIrpjdHH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id n15-20020a170902d2cf00b001c3bd544f9fsi2506628plc.523.2023.09.14.16.11.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 16:11:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=hIrpjdHH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 3317582F4E2A; Thu, 14 Sep 2023 06:35:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240017AbjINNfi (ORCPT + 35 others); Thu, 14 Sep 2023 09:35:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239851AbjINNeu (ORCPT ); Thu, 14 Sep 2023 09:34:50 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4990272D; Thu, 14 Sep 2023 06:33:53 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 0D7676607350; Thu, 14 Sep 2023 14:33:52 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698432; bh=8QdmTHdgoaFCZ92hWXIEL9hOaDrX90tCZOqZYUq2PdQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hIrpjdHHkd8DCsezUS6Db1t2mu//j9qGKSeanMJQE79X+olRQO4KTQpC5RaEVpaXZ fuztA6tGqvwzZ1PtMQJtqVn2jR+bbTJlozFixJYdu64lOLpfm86pNS0Htz0Spop+Oh Wd1Wevs9N5g1gGaXwynNkHxF6L1jjDQwlDyEa/bRvVS/GpyU3vGcaZXPNLG8YMeiEu 5/hrxlneaY3Pi+0si5lcj1NKHcHZuEhgQhhOdftaYznfEim3yrOBNLzUa5vLyhLISI 8jYt914ufA6p3QiSz+BypCIRLDedkOW6MUxydy9ude1UD5XADaX26eJ8LV+b3sRizY n1nNnWMdKdXeA== 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 v7 40/49] media: usb: usbtv: Stop direct calls to queue num_buffers field Date: Thu, 14 Sep 2023 15:33:14 +0200 Message-Id: <20230914133323.198857-41-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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, 14 Sep 2023 06:35:45 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777056455813121138 X-GMAIL-MSGID: 1777056455813121138 Use vb2_get_num_buffers() to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- drivers/media/usb/usbtv/usbtv-video.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/usbtv/usbtv-video.c b/drivers/media/usb/usbtv/usbtv-video.c index 1e30e05953dc..41704d45c65c 100644 --- a/drivers/media/usb/usbtv/usbtv-video.c +++ b/drivers/media/usb/usbtv/usbtv-video.c @@ -725,10 +725,11 @@ static int usbtv_queue_setup(struct vb2_queue *vq, unsigned int *nplanes, unsigned int sizes[], struct device *alloc_devs[]) { struct usbtv *usbtv = vb2_get_drv_priv(vq); + unsigned int q_num_bufs = vb2_get_num_buffers(vq); unsigned size = USBTV_CHUNK * usbtv->n_chunks * 2 * sizeof(u32); - if (vq->num_buffers + *nbuffers < 2) - *nbuffers = 2 - vq->num_buffers; + if (q_num_bufs + *nbuffers < 2) + *nbuffers = 2 - q_num_bufs; if (*nplanes) return sizes[0] < size ? -EINVAL : 0; *nplanes = 1; From patchwork Thu Sep 14 13:33:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139640 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp421381vqi; Thu, 14 Sep 2023 08:14:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHxq/uoIZK1d3Ea46rKKPpoab1K2lGjZrekrGGcnYBORuOpn9GXqMDDQqiAHU1N+jiQYJmj X-Received: by 2002:a05:6a00:1784:b0:68f:cc67:e709 with SMTP id s4-20020a056a00178400b0068fcc67e709mr4044194pfg.16.1694704471496; Thu, 14 Sep 2023 08:14:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694704471; cv=none; d=google.com; s=arc-20160816; b=yvgUrAwn5yjwYPpQrYJUHbvS8iI781VOa7e0+v67htSxX/yPMXlHnH2MZraHoMY4U8 Qoxx8UCXZ7hKWj5D56U9Mi/r2hBWlCELsO3oHHl59Z7b1kBrrUaRNSxdg+VCgxU7ygvE D+t6DF3dr9vjIzImiJE0OHLJmpOXp8Bo/ntlt8chvCSvRCuKxpQmg6jXcH+TwOQj/8Pu sMbl36x/KHZtL5TYTozSQNI6iWRS2gsZ36Ga653HMg0C0BjvLubZYUoobFa2/0qL4VyJ x/02Nv0aj2lu0asn1H6I1IwPp9HnE4wTOPsve3SQDjuJpU/djqv6IKw6urYJr70xkoN5 +xeQ== 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=5R/PgQ9e5CNPNqndSb4rIVp3OPzOtN9sFynvrYOHk1Q=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=MMJndvIY5XJBP4aaMrXm5epe2LMVNWEK4uDTsLSBwqd1OrKMA8z8N4fTUiISellAJA Jmyq2zC+M2J6UBARtnlqTHtJiugzA8WDv2ARAfgjnklBbeW1c8wiVE1Bz9+Kfn2sbvqr oh6b+QWxv+VRKScnT3EaSwe7eVJHA5T4OYxNZ1yT1ntXmRy97H9NnCYn/cYRkCxPOS+A NQIPya3Cn16MLRkGh0Y4mIGuBOImk9JoCc7z5RJyC66DZsl/F65FqOTzp0494ENGW13H Pw1Ut+QF39k8cgTp2txoW1GplAAXDqlGv980/ozoZuo2vDjz04AW//On595JZEddlB01 J76A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="BF/oWSSz"; 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 k3-20020a6568c3000000b0056f8fdb4430si1740113pgt.893.2023.09.14.08.14.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 08:14:31 -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="BF/oWSSz"; 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 D90F482372C4; Thu, 14 Sep 2023 06:37:07 -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 S239919AbjINNfl (ORCPT + 35 others); Thu, 14 Sep 2023 09:35:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239311AbjINNe5 (ORCPT ); Thu, 14 Sep 2023 09:34:57 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A508273F; Thu, 14 Sep 2023 06:33:54 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 8C248660735A; Thu, 14 Sep 2023 14:33:52 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698433; bh=g+cKvL+57Ge4BbEO/J6pfXbFnIiiN4vCjyxapf5D6Zg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BF/oWSSzruSq2mPoOs3pLdafwHgIDEVGPUJAogmZ2Pn3jq91kpmFLkc/leTdV6CLe o0YQeVWi8i3MmUFknNMB/4F09BncPnnh+uzR2+i7peezooDR61j9s1VYvwzoQmsAoU 4HxpCDwVjGIhhTt2lygHGUfa8XRvnbGokkOk8XddVXNmqYNJp7UOrLHCIbejmme0Dz 15oxHz7rGTwk65MLth9ocO39WL1t2xF1Cxpj3vnZO6kCAd0aCYIysAtSyfbEaGG0ii 2WkUXpAmARnf3OGLeiiQSXI5rlMTkSqDxy4WXS0kmH1PwX6wTgTAEB+QQZqEH1wEOe txQgTb8VXbQ6w== 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 v7 41/49] media: atomisp: Stop direct calls to queue num_buffers field Date: Thu, 14 Sep 2023 15:33:15 +0200 Message-Id: <20230914133323.198857-42-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (groat.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:37:07 -0700 (PDT) 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777026435521965574 X-GMAIL-MSGID: 1777026435521965574 Use vb2_get_num_buffers() to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c index 4b65c69fa60d..48f9745421a9 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -1030,7 +1030,7 @@ static int atomisp_qbuf_wrapper(struct file *file, void *fh, struct v4l2_buffer struct atomisp_device *isp = video_get_drvdata(vdev); struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev); - if (buf->index >= vdev->queue->num_buffers) + if (buf->index >= vb2_get_num_buffers(vdev->queue)) return -EINVAL; if (buf->reserved2 & ATOMISP_BUFFER_HAS_PER_FRAME_SETTING) { From patchwork Thu Sep 14 13:33:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139803 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp580500vqi; Thu, 14 Sep 2023 12:36:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFWHycPNcCuaQeGhx2RShwtZQH2TaLO15VfgYOJF2yIe8TBeUK+QpeQuR+28xX3fSmRd1fD X-Received: by 2002:a05:6a00:2d9e:b0:68f:bbc3:df44 with SMTP id fb30-20020a056a002d9e00b0068fbbc3df44mr7435300pfb.0.1694720209843; Thu, 14 Sep 2023 12:36:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694720209; cv=none; d=google.com; s=arc-20160816; b=VmrqjEWrJtHp96CqJP8Di72mZLKZKzbkbPLgKVBnvtPuAeZF83FY/US1qja+ZrmFUW tJ4oesQ5doeqqAR2LDH6kdASORiTFJ5EGkeac1+0Fsu6zTi2gZ3hY2coiQ6U8OsCTKUZ WnXipRHidbGEaRIDU2DPApi4EWglkm/ceBpOuMDd8HlLfiGMqMLarGnucx9QCNVGRlOK VzwvWa46Mb32dz0UzeXcxOy9WFV7s8H9aOKB8ADGr407WivGAiC9zBCcE8oXQgk4iWqN nBs9amdjbXpPZH4qRs1MNF/hsSO70HnSREDH5Z4lv5/t2XJabRz/JbVRlVETvSmik5kk Pn/Q== 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=R5I14gZ8ZV2beKG5h7D5LMBNMyFJY4vcK66dciAEppY=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=aErVSp3NyBqLBtkyJD2MpDjbgnt0RRobAzROgpJ6IRcFji9y9BdWgreY6FFhzgNDAx cf9zI5ZyPJJbzAARJAxUSjRkO16kFW6JwehgZb59jt79Iq9FcPLjGXaSNU/IuylAEZ89 7X6e7ZIhNdTtd3ZQNS18wN6Spok6fIAZuWSmctE/SiarD65Kr3gNQ2uQ2T94orYeHstX U/pwkqeH9PgoV5lGgEGAlaXtJWM5DXDn8A9mgju/bQz7K2DaxLHXi5I/if5gF0t5Ihzo BqCkbQfr1Op6+A3Y8u67ayD+Hb4HxrNlyzfNSP5ubSvTKQ8BMYN+T/r1eriVEZ3hCRlY ZjlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=eWvZTK2a; 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 ay26-20020a056a00301a00b0068a55cc9a10si2061006pfb.381.2023.09.14.12.36.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 12:36:49 -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=eWvZTK2a; 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 B64C580E4FC0; Thu, 14 Sep 2023 06:36:07 -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 S239302AbjINNfm (ORCPT + 35 others); Thu, 14 Sep 2023 09:35:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239912AbjINNfA (ORCPT ); Thu, 14 Sep 2023 09:35:00 -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 E2D192D46; Thu, 14 Sep 2023 06:33:54 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 1ACA66607393; Thu, 14 Sep 2023 14:33:53 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698433; bh=1yOSfZ9zOJdZRwLwPAMdW6zHS4PIxiSGQkrNrnzD9t8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eWvZTK2amSzpVpq8ZFpot/0uWStFAjTJ7f+V847lmGPS215Rf+yO9QYPKO9vKFQuc S9ipLbYMNFYdeKqNpB2X4x2LrASQMR9lZW3n01IbkkOYQRxUYLhFX1gS/ReLT+tXMo 78lscaZDs1HkBh8wflnmMc0qEjDWP730gmvCiBed16h1PHb6qgdeAXT5I86QF58V0U Xg+VOaPOnHZ98itUCPGQtBw7qTYvrOXLwezu37SdqEP6F6nlCr8XZEO8af50mE19Nx S3haDqIwuCyxT5B7LRJR7Ln3iYHhhxWAsg3C7hiOTT6nRGfvkDjJ6jKjanbg5FByUn AHraGykhh/h6Q== 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 v7 42/49] media: imx: Stop direct calls to queue num_buffers field Date: Thu, 14 Sep 2023 15:33:16 +0200 Message-Id: <20230914133323.198857-43-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (morse.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:36:07 -0700 (PDT) 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777042938823152878 X-GMAIL-MSGID: 1777042938823152878 Use vb2_get_num_buffers() to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- drivers/staging/media/imx/imx-media-capture.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-capture.c b/drivers/staging/media/imx/imx-media-capture.c index 4846078315ff..ce02199e7b1b 100644 --- a/drivers/staging/media/imx/imx-media-capture.c +++ b/drivers/staging/media/imx/imx-media-capture.c @@ -605,6 +605,7 @@ static int capture_queue_setup(struct vb2_queue *vq, { struct capture_priv *priv = vb2_get_drv_priv(vq); struct v4l2_pix_format *pix = &priv->vdev.fmt; + unsigned int q_num_bufs = vb2_get_num_buffers(vq); unsigned int count = *nbuffers; if (vq->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) @@ -613,14 +614,14 @@ static int capture_queue_setup(struct vb2_queue *vq, if (*nplanes) { if (*nplanes != 1 || sizes[0] < pix->sizeimage) return -EINVAL; - count += vq->num_buffers; + count += q_num_bufs; } count = min_t(__u32, VID_MEM_LIMIT / pix->sizeimage, count); if (*nplanes) - *nbuffers = (count < vq->num_buffers) ? 0 : - count - vq->num_buffers; + *nbuffers = (count < q_num_bufs) ? 0 : + count - q_num_bufs; else *nbuffers = count; From patchwork Thu Sep 14 13:33:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139891 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp681048vqi; Thu, 14 Sep 2023 16:11:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF34yR7oU7xyFguAP3AyWFYoW3qLfnJVKUcjAqv3+qiv2o2keqURzTaFqxR46l3txaZd1Xk X-Received: by 2002:a17:902:f68f:b0:1c0:bf60:ba4f with SMTP id l15-20020a170902f68f00b001c0bf60ba4fmr12664plg.4.1694733102411; Thu, 14 Sep 2023 16:11:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694733102; cv=none; d=google.com; s=arc-20160816; b=TqewwgNOKnVPplOBSV+ddTjPpXgUYtN+yf3s3kNNsapPDM6UnZe4JSE9iKke4PJk5x Vxi9B2UIY4fjYX/+88NMAnykq25Hpoj7gh1GFEdhbb9LXerHQRWFJcigyGztFCYJL+uj ttQ2Mg20h4uPyXeRd8iFANw5Fd/mINeI4M+U3P6Rw1r1dqSyG1SZvaG4y2irBO15vNdp 5rF0k9YlJZ7oUh7+QPBQokygIGgJGFaxD0VaIAQHtt8oV+oZRGBcu9ptObKLomK99W6q TgzUlj4Yr3z5mv3BUG9AfQgcUKRcPnTZpXsZBJfL8fs4J2KpwQNvriclwg1IUWchmJ6E sbeA== 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=tmQ8B48fS653lsNUZPmdnMwdIC6Yd6jLqjKhmYRUJKw=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=EVwbwlteEmB8JtfJRjNaHq1EDfmua2I284rI3v2K04Kkw6WbRpr9KnWZ0618FNu6Yu L8HORr3eQKtG9/QD/K3MjViiIk8xD6GJoJtN2k6nLPkLRxFHyWiVkeGJAqUnM5nhWRkF 7JokqA2/xK5ktWz9iff6HVtmojggIw/CRzHCEy0rZ9QREx0OIDjrQcBpJ3RX3aT3ihH8 YlOdrXKowbs15P/IFUIHFosmbdUJjBofbADefE5qlXRvHuo6dG6bFRj3YcKNtKYKxCxP Q4h6q43sG+cVgn8YUhY9qdMwvON4bQchorRj5hapT3HGLgtc4xEfcz/DXNgGXtfviHrH IH1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=eX9HPb3F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id h7-20020a170902b94700b001bbfbe6bf3esi2159155pls.504.2023.09.14.16.11.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 16:11:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=eX9HPb3F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 322E982F7F80; Thu, 14 Sep 2023 06:35:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240076AbjINNfo (ORCPT + 35 others); Thu, 14 Sep 2023 09:35:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239594AbjINNfA (ORCPT ); Thu, 14 Sep 2023 09:35:00 -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 280FA2D4F; Thu, 14 Sep 2023 06:33:55 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 A69746607394; Thu, 14 Sep 2023 14:33:53 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698434; bh=qUxQMObFxpiy3pFolAat/Lsgv4wZ2hZHcdle7SRl8Pw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eX9HPb3F0XG0gWIqEzdqo1JuCQk+1T5cSP5loYaPm2hT3jBZ4pf1li6gLpqSo5LAm BlwGFyX3ssHkT1LNdS858TgUdf7Lj6vRz5qWet4kfA2XqtPD4GDHlwejGuNN//FPlM etgV1owR/w4SyjHd3eSsf4Dab3lrPTGat9OZCFs6J9WWAZ+XXVXuI+FCMmWh8we3eU hdwqMxk5k/sDDBmthNK5ADpwGcIzkuOav0X4YWogslj5ukliigIfgy5ICXLz5wBdct 5evWbWUGrEv0IL8bdW4pD8Z3GOZ6cYuRzwAHYxn3J5jkIukKI8hhdnA+sbr25kDMW2 7kEBNEOLNMQ4A== 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 v7 43/49] media: meson: vdec: Stop direct calls to queue num_buffers field Date: Thu, 14 Sep 2023 15:33:17 +0200 Message-Id: <20230914133323.198857-44-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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, 14 Sep 2023 06:35:55 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777056457586125933 X-GMAIL-MSGID: 1777056457586125933 Use vb2_get_num_buffers() to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- 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); } From patchwork Thu Sep 14 13:33:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139998 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp750584vqi; Thu, 14 Sep 2023 19:09:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH6W4s6fLeiAm9+viYJnkJ9uCig1YBZm4yCnWkEOc7IDmGYoY2kOax0o5do68v+7jehAD4p X-Received: by 2002:a17:903:41c6:b0:1bc:4415:3c1 with SMTP id u6-20020a17090341c600b001bc441503c1mr4746121ple.7.1694743758908; Thu, 14 Sep 2023 19:09:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694743758; cv=none; d=google.com; s=arc-20160816; b=e+v5Zmz5eGN3Ut9JsKZoGioYLHdTcQA9mWFrz7OFBeKWcacK9ZWJBORP7rMsmrL3Vs 4BvKRp8wdhe2GtXuvjGJzPCQuiLRxJD+2CwEiMuHSl3BPr3lFZAZ8RKHVMMy3+C/96hi MPNryR83ZHw84xONy3YcoFYYude6KMcvMYZHkA6gEK3w3fp4+PUhG0cXu6j8yVtOhDMW 9blir2j0dFhb1TnIBHoZ9w8e/30nXg++Zo5/3xHEadoO9WkeSshtlcYnIGwWqywO/EWg d6qfrZJDEK78Ug4/x/B1pUQ4keYFrZcF8ggh3+HZQE6eW+PhSPJo2m5FDLSLPh9Z1DKi 6Jig== 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=JTqy2pC04+lk+/eoSQ19afzHN9WljXx7c9EzRlHGO24=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=rk6sopFMh3Xa8f7tijxLWyQQwpYDmYhrewOn2t3ndG2rpPba3EFnTKaaEjyPTRtUZA p3Rl9jS+On9LMS5Kj4D9fB/zmJ3zB6WcgOj1Znwa2SzWMBBocZVSP2qYkZoH/fW1n1ss SZB0gIqtZbAh/BI5vYZmNneZpEIRzuza5FktJ0wxplb0CfBTrdufnZbmDIldrdC4Q1IO n2f18f4+Yfy4OOQPSi+3YKZZyKr+AmxjOIbJtS5TGniwtY3ermHWB+5ezYF81FobrCwu 0LmlFJBWYM+DbnK6uZidB9WWmxg3FadYlAUFzQll8qb3S+glDgIGB/cVQuD7PTzHwMLU +0hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=EN1kyPC5; 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 d26-20020a63735a000000b0057745d87b4csi2375209pgn.526.2023.09.14.19.09.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 19:09:18 -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=EN1kyPC5; 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 4566E8523B72; Thu, 14 Sep 2023 06:35:59 -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 S240094AbjINNfv (ORCPT + 35 others); Thu, 14 Sep 2023 09:35:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239567AbjINNfJ (ORCPT ); Thu, 14 Sep 2023 09:35:09 -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 AAC1D1FE5; Thu, 14 Sep 2023 06:33:55 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 2AD386607397; Thu, 14 Sep 2023 14:33:54 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698434; bh=yoC4Zwhq5KTur5ZjSqFZrMNs6UvSbNFXWhR9MCqzlE0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EN1kyPC5ZKZ0JvmFCHlIc1mglG9qMNrLetcPCcD67N4xE1hTklCKDCBTvVfTSBYtU 4VNAqqLMDJojsiDBr9PfSg4Kt/L5wOkzMHIp7Usvkg/OS+8DY4qa1pvR2N7afmXPyC NPow5YjSKRGIxTyvDgTgfOMCCa1zzZFqt6bl9BATFAck5lp7Bimj7Aas9Pf+8xC0Tq 3NLcbDX6LdHM4Xmh6JOa78HIpfZYGLmJWaZHRQGjuXwOpDpMKaH5y5+d9U+DCk+m8K 9ABes+Pt0cxXhdedx+kGDyyVz/RVHpy946pJKhtX/sNhAZUv13kdwss33nLLep2094 cH5Qa5D0y4jKg== 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 v7 44/49] media: cedrus: Stop direct calls to queue num_buffers field Date: Thu, 14 Sep 2023 15:33:18 +0200 Message-Id: <20230914133323.198857-45-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (howler.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:35:59 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777067632094675199 X-GMAIL-MSGID: 1777067632094675199 Use vb2_get_num_buffers() to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- drivers/staging/media/sunxi/cedrus/cedrus_h264.c | 4 +++- drivers/staging/media/sunxi/cedrus/cedrus_h265.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c index dfb401df138a..bbe5802ea861 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c @@ -649,11 +649,13 @@ static void cedrus_h264_stop(struct cedrus_ctx *ctx) struct cedrus_dev *dev = ctx->dev; struct cedrus_buffer *buf; struct vb2_queue *vq; + unsigned int q_num_bufs; unsigned int i; vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); + q_num_bufs = vb2_get_num_buffers(vq); - for (i = 0; i < vq->num_buffers; i++) { + for (i = 0; i < q_num_bufs; i++) { buf = vb2_to_cedrus_buffer(vb2_get_buffer(vq, i)); if (buf->codec.h264.mv_col_buf_size > 0) { diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c index fc9297232456..533a38316686 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c @@ -865,11 +865,13 @@ static void cedrus_h265_stop(struct cedrus_ctx *ctx) struct cedrus_dev *dev = ctx->dev; struct cedrus_buffer *buf; struct vb2_queue *vq; + unsigned int q_num_bufs; unsigned int i; vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); + q_num_bufs = vb2_get_num_buffers(vq); - for (i = 0; i < vq->num_buffers; i++) { + for (i = 0; i < q_num_bufs; i++) { buf = vb2_to_cedrus_buffer(vb2_get_buffer(vq, i)); if (buf->codec.h265.mv_col_buf_size > 0) { From patchwork Thu Sep 14 13:33:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139888 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp679773vqi; Thu, 14 Sep 2023 16:09:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHdiDoSGt04E2EuH8waf6lpvJ63GhTWnCOsInmnteik87xeT+HB5eRsJkibUM9HulHgos95 X-Received: by 2002:a17:90a:ce02:b0:274:84a2:f0d8 with SMTP id f2-20020a17090ace0200b0027484a2f0d8mr2166391pju.25.1694732945502; Thu, 14 Sep 2023 16:09:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694732945; cv=none; d=google.com; s=arc-20160816; b=Zfdm0CKq/BtHiG0lDczbfxPl4gzmNHmCQYWti6MiAru9n5iFjckWfnmraHUUysqBF9 G5syPaX4g8UZpNIpGFWYFCzVGiLxDld3jg5X4/WlpU67+6ozqNvbXRFquM3QI8pqtZ48 ty4H0s+2vmttJgjpP+hCvN3rHLrNPW+9uQ7fr023n3JydLTE8HJ46nLvBNIUi/ZivkGq elBqUoWVm0nzBe8zkFoRKQvGxl/bXw5t5HyvAHSE8gvjD87KVsiprjfbW/FuLAk2G/rn HeKMU7qVpKJjvbjZLbP1WMOS7X3ghD0zm0w/3Ox0dmE2KJbJMt+hElrxJAWNbr/KhdQE 9Ngg== 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=k11rY4v5tKVMV48U1QEyQgBu5ElbdMJjfVtNvvCoJwQ=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=C71G+tJrREiPvPl3JINH2lGx/fuLIplIE4mndC64xjQnGRYbsicDZLMc74n7sVXV1t z1t0jpSYagr+wRNof/vtH/8kdIQe45/kSDnyz88+6RyzXOHXj8bCki525STqUfKu+KdB s1PcntgXaji0/B3txyNFvs5WLJDqAQsaRJ574q5TM/S1FpZ1X5Iku2jbDJQNvghoU6oc AsE7BITcuOMtlipYco2E1aHaKECTkqqQzDq1bTLLnmClrdqROqnpiK60YHUgpH6nC+9S 3dZn652ZangQsZoJwJEev9Nv7ziIMrcOboRkOansu2VcTpArcPgkig0XSJyfjvbSkLxr A5nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="X/J7xY9X"; 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 gn2-20020a17090ac78200b0024e47fae466si2227705pjb.180.2023.09.14.16.09.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 16:09:05 -0700 (PDT) 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="X/J7xY9X"; 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 CB38B82F7F90; Thu, 14 Sep 2023 06:36:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240129AbjINNfy (ORCPT + 35 others); Thu, 14 Sep 2023 09:35:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239926AbjINNfK (ORCPT ); Thu, 14 Sep 2023 09:35:10 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 627852D57; Thu, 14 Sep 2023 06:33:56 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 A8A7A6607398; Thu, 14 Sep 2023 14:33:54 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698435; bh=6w/8aQcwRb0w/vjS1KTd+aWlNyxDUhgB4lU/p3jbJ9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X/J7xY9XFtUzhePX/nxzqelDrY7C3199sZPVEtASrxAt8dNsTE5TkuGnSASkKCscO m52XzpY9A8Pz3lzh0VzR/D3MsZ/nHJgPn08ITNuPiyPjm9YLt0pOAcCgZChghDNajT ABS0bhgGXhp/bczlcWT+piKbrGReVRrOJk3qQIkGtmcjHqz28Mh7lIlY4kqiHo2TMZ UkWCbAMRcIVySD190UiPIilQ5w9rHxWApXORLD3R2sbNyctSDahbiy2WBqpirAA/bI dArcV5QRWh+AasTeZYSjdIvrjJj7sbXhM33axiYbLzo5MXJF0NU+GAsnWuFIeLQ68u tKNbEus1atCmg== 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 v7 45/49] media: core: Add bitmap manage bufs array entries Date: Thu, 14 Sep 2023 15:33:19 +0200 Message-Id: <20230914133323.198857-46-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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, 14 Sep 2023 06:36:01 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777056293329178043 X-GMAIL-MSGID: 1777056293329178043 Add a bitmap field to know which of bufs array entries are used or not. Remove no more used num_buffers field from queue structure. Use bitmap_find_next_zero_area() to find the first possible range when creating new buffers to fill the gaps. Signed-off-by: Benjamin Gaignard --- .../media/common/videobuf2/videobuf2-core.c | 55 +++++++++++++++---- include/media/videobuf2-core.h | 9 ++- 2 files changed, 51 insertions(+), 13 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index a4c2fae8705d..c5d4a388331b 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -411,10 +411,11 @@ static void init_buffer_cache_hints(struct vb2_queue *q, struct vb2_buffer *vb) */ static bool vb2_queue_add_buffer(struct vb2_queue *q, struct vb2_buffer *vb, unsigned int index) { - if (index < q->max_allowed_buffers && !q->bufs[index]) { + if (index < q->max_allowed_buffers && !test_bit(index, q->bufs_map)) { q->bufs[index] = vb; vb->index = index; vb->vb2_queue = q; + set_bit(index, q->bufs_map); return true; } @@ -428,9 +429,10 @@ static bool vb2_queue_add_buffer(struct vb2_queue *q, struct vb2_buffer *vb, uns */ static void vb2_queue_remove_buffer(struct vb2_queue *q, struct vb2_buffer *vb) { - if (vb->index < q->max_allowed_buffers) { + if (vb->index < q->max_allowed_buffers && test_bit(vb->index, q->bufs_map)) { q->bufs[vb->index] = NULL; vb->vb2_queue = NULL; + clear_bit(vb->index, q->bufs_map); } } @@ -451,11 +453,12 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory, unsigned long first_index; int ret; - /* Ensure that q->num_buffers+num_buffers is below q->max_allowed_buffers */ + /* Ensure that the number of already queue + num_buffers is below q->max_allowed_buffers */ num_buffers = min_t(unsigned int, num_buffers, q->max_allowed_buffers - vb2_get_num_buffers(q)); - first_index = vb2_get_num_buffers(q); + first_index = bitmap_find_next_zero_area(q->bufs_map, q->max_allowed_buffers, + 0, num_buffers, 0); if (first_index >= q->max_allowed_buffers) return 0; @@ -675,7 +678,13 @@ static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) struct vb2_buffer *vb2_get_buffer(struct vb2_queue *q, unsigned int index) { - if (index < q->num_buffers) + if (!q->bufs_map || !q->bufs) + return NULL; + + if (index >= q->max_allowed_buffers) + return NULL; + + if (test_bit(index, q->bufs_map)) return q->bufs[index]; return NULL; } @@ -683,7 +692,10 @@ EXPORT_SYMBOL_GPL(vb2_get_buffer); unsigned int vb2_get_num_buffers(struct vb2_queue *q) { - return q->num_buffers; + if (!q->bufs_map) + return 0; + + return bitmap_weight(q->bufs_map, q->max_allowed_buffers); } EXPORT_SYMBOL_GPL(vb2_get_num_buffers); @@ -899,6 +911,14 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, q->bufs = kcalloc(q->max_allowed_buffers, sizeof(*q->bufs), GFP_KERNEL); if (!q->bufs) ret = -ENOMEM; + + if (!q->bufs_map) + q->bufs_map = bitmap_zalloc(q->max_allowed_buffers, GFP_KERNEL); + if (!q->bufs_map) { + ret = -ENOMEM; + kfree(q->bufs); + q->bufs = NULL; + } q->memory = memory; mutex_unlock(&q->mmap_lock); if (ret) @@ -968,7 +988,6 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, } mutex_lock(&q->mmap_lock); - q->num_buffers = allocated_buffers; if (ret < 0) { /* @@ -995,6 +1014,10 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, mutex_lock(&q->mmap_lock); q->memory = VB2_MEMORY_UNKNOWN; mutex_unlock(&q->mmap_lock); + kfree(q->bufs); + q->bufs = NULL; + bitmap_free(q->bufs_map); + q->bufs_map = NULL; return ret; } EXPORT_SYMBOL_GPL(vb2_core_reqbufs); @@ -1031,9 +1054,19 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, q->memory = memory; if (!q->bufs) q->bufs = kcalloc(q->max_allowed_buffers, sizeof(*q->bufs), GFP_KERNEL); - if (!q->bufs) + if (!q->bufs) { + ret = -ENOMEM; + goto unlock; + } + if (!q->bufs_map) + q->bufs_map = bitmap_zalloc(q->max_allowed_buffers, GFP_KERNEL); + if (!q->bufs_map) { ret = -ENOMEM; + kfree(q->bufs); + q->bufs = NULL; + } mutex_unlock(&q->mmap_lock); +unlock: if (ret) return ret; q->waiting_for_buffers = !q->is_output; @@ -1095,7 +1128,6 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, } mutex_lock(&q->mmap_lock); - q->num_buffers += allocated_buffers; if (ret < 0) { /* @@ -2588,6 +2620,9 @@ void vb2_core_queue_release(struct vb2_queue *q) __vb2_queue_free(q, q->max_allowed_buffers); kfree(q->bufs); q->bufs = NULL; + bitmap_free(q->bufs_map); + q->bufs_map = NULL; + mutex_unlock(&q->mmap_lock); } EXPORT_SYMBOL_GPL(vb2_core_queue_release); @@ -2944,7 +2979,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ * Check if we need to dequeue the buffer. */ index = fileio->cur_index; - if (index >= q->num_buffers) { + if (!test_bit(index, q->bufs_map)) { struct vb2_buffer *b; /* diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 19c93d8eb7c8..734437236cc4 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -557,7 +557,7 @@ struct vb2_buf_ops { * @memory: current memory type used * @dma_dir: DMA mapping direction. * @bufs: videobuf2 buffer structures - * @num_buffers: number of allocated/used buffers + * @bufs_map: bitmap to manage bufs entries. * @max_allowed_buffers: upper limit of number of allocated/used buffers * @queued_list: list of buffers currently queued from userspace * @queued_count: number of buffers queued and ready for streaming. @@ -621,7 +621,7 @@ struct vb2_queue { unsigned int memory; enum dma_data_direction dma_dir; struct vb2_buffer **bufs; - unsigned int num_buffers; + unsigned long *bufs_map; unsigned int max_allowed_buffers; struct list_head queued_list; @@ -1151,7 +1151,10 @@ static inline bool vb2_fileio_is_active(struct vb2_queue *q) */ static inline bool vb2_is_busy(struct vb2_queue *q) { - return (q->num_buffers > 0); + if (!q->bufs_map) + return false; + + return (bitmap_weight(q->bufs_map, q->max_allowed_buffers) > 0); } /** From patchwork Thu Sep 14 13:33:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139784 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp555339vqi; Thu, 14 Sep 2023 11:52:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH7p81xas5IdfbSWKer8351uXO+PbyRRRyU3wCcZilQlo5DPmqhu9Yn/9saQuEukY3z77aC X-Received: by 2002:a05:6358:f484:b0:13f:e3eb:53a6 with SMTP id ku4-20020a056358f48400b0013fe3eb53a6mr4980890rwb.30.1694717552304; Thu, 14 Sep 2023 11:52:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694717552; cv=none; d=google.com; s=arc-20160816; b=Wi/VrSROvMRiny35CqvX9DQrOo+6B6U6mJmv6yEeHZL/HyjXp7S6e0d88zjY1T2y4P uMz3WlANncoCZaVxWuhgwUvp/66Sd/1QRSGf4u5bKQoAlGuVT+TIIqVrFJboKm/7JuyS 8AlfTUqGhs2oYs9YkHQzQZju/N2mUBHZFHLEHvKUYw/o9uNe6JmVEyPq5gMHYX2Tcy6i JkBIUeux+gYZJttxk4gxUv+Mmn4fR58gnPXX7rIrurJj5HwxeRjvufK/mlYVNpx1XyEP gbN2cPyabopCfGvMjpXjvGNKUkpSpJrp4a0gVWzsZL3Y3Q0Uz7fjLWdzjfRAhyAehjX8 UTNA== 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=MTUra0tlY/ay54IiK0T3ERwOy3egD+NX8ib2AgUUHFs=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=bOvg5xN+XhlHgPWc6kxRRbSBwnG1feTxtNi8Ygsbj/4vZm+G9V21VUjnPSHwRpSOz4 7BBcueOOTmgmH9SznUtozsd8h0+eAQas26B8/V0GN/+upk6Bt0js3nFjt5GtyIq7qXn7 KOl8FGO5uj8UM3Ghvc0I667CottNHYQJtixhfemkriyZArNADcrxhIGPqDmPcvLbkQcn tahVn338GwyAYbn0wUeRCTLTDYOQ8RSOQHTbBjb0uV9F2su036Tne6khPuZ5SkQIzHAj uD69ERtxbB134LdDcneKuDvsw1KuSbxKx1l3HAb64qZjxBpMaqbCZ5Wiuu/94TTwYETd zwpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=oEps24M4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id b3-20020a655cc3000000b005653f748afcsi1867204pgt.729.2023.09.14.11.52.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 11:52:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=oEps24M4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 CBDE680D6AFF; Thu, 14 Sep 2023 06:37:41 -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 S239857AbjINNf5 (ORCPT + 35 others); Thu, 14 Sep 2023 09:35:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239267AbjINNfM (ORCPT ); Thu, 14 Sep 2023 09:35:12 -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 AD03D2D62; Thu, 14 Sep 2023 06:33:56 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 30932660739B; Thu, 14 Sep 2023 14:33:55 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698435; bh=toYAovS+izT0LEoEizCbJtlr0mGm+eGtkX0GLil3vcc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oEps24M4VrGEsZjj534OIRuhGa5nrooJPEDbMc2XfeODZD/Snnj5GHpYmTeNJT9l+ CnU62Cjhug0VYXFFocoTcbn5nVVz7hP+auojoUhN8d0sz0+dt5wdAcgRJyGvIHOZxs vCeZB7SShgrnW4lDf+dTiEik1PFHIThDnbFZMxPLLIB2BZR8K5+bOvZb955q3xuhx9 56BPeGqp7XnfORhXvIKRsrY76WVS7I/k5Hdjk17tOl2cmfSRKgNs76OfI3XYNjMm4l xW6l0KS/HNEnfRoinzNpPeeTS9gcgrE2+B1lCiEu9EB4NTrO28oamIIUFNRIEB88yP ZS19F/X5nC2aA== 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 v7 46/49] media: core: Free range of buffers Date: Thu, 14 Sep 2023 15:33:20 +0200 Message-Id: <20230914133323.198857-47-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (groat.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:37:41 -0700 (PDT) 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777040152186784827 X-GMAIL-MSGID: 1777040152186784827 Improve __vb2_queue_free() and __vb2_free_mem() to free range of buffers and not only the last few buffers. Intoduce starting index to be flexible on range and change the loops according to this parameters. Signed-off-by: Benjamin Gaignard --- .../media/common/videobuf2/videobuf2-core.c | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index c5d4a388331b..88cdf4dcb07c 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -527,13 +527,12 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory, /* * __vb2_free_mem() - release all video buffer memory for a given queue */ -static void __vb2_free_mem(struct vb2_queue *q, unsigned int buffers) +static void __vb2_free_mem(struct vb2_queue *q, unsigned int start, unsigned int count) { - unsigned int buffer = 0; - long i = q->max_allowed_buffers; + unsigned int i, buffer = 0; struct vb2_buffer *vb; - for (i = q->max_allowed_buffers; i >= 0 && buffer < buffers; i--) { + for (i = start; i < q->max_allowed_buffers && buffer < count; i++) { vb = vb2_get_buffer(q, i); if (!vb) continue; @@ -550,19 +549,18 @@ static void __vb2_free_mem(struct vb2_queue *q, unsigned int buffers) } /* - * __vb2_queue_free() - free buffers at the end of the queue - video memory and + * __vb2_queue_free() - free count buffers from start index of the queue - video memory and * related information, if no buffers are left return the queue to an * uninitialized state. Might be called even if the queue has already been freed. */ -static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) +static void __vb2_queue_free(struct vb2_queue *q, unsigned int start, unsigned int count) { - unsigned int buffer; - long i = q->max_allowed_buffers; + unsigned int i, buffer; lockdep_assert_held(&q->mmap_lock); /* Call driver-provided cleanup function for each buffer, if provided */ - for (i = q->max_allowed_buffers, buffer = 0; i >= 0 && buffer < buffers; i--) { + for (i = start, buffer = 0; i < q->max_allowed_buffers && buffer < count; i++) { struct vb2_buffer *vb = vb2_get_buffer(q, i); if (!vb) @@ -574,7 +572,7 @@ static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) } /* Release video buffer memory */ - __vb2_free_mem(q, buffers); + __vb2_free_mem(q, start, count); #ifdef CONFIG_VIDEO_ADV_DEBUG /* @@ -659,8 +657,8 @@ static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) #endif /* Free vb2 buffers */ - for (i = q->max_allowed_buffers, buffer = 0; i > 0 && buffer < buffers; i--) { - struct vb2_buffer *vb = vb2_get_buffer(q, buffer); + for (i = start, buffer = 0; i < q->max_allowed_buffers && buffer < count; i++) { + struct vb2_buffer *vb = vb2_get_buffer(q, i); if (!vb) continue; @@ -884,7 +882,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, * queued without ever calling STREAMON. */ __vb2_queue_cancel(q); - __vb2_queue_free(q, q_num_bufs); + __vb2_queue_free(q, 0, q_num_bufs); mutex_unlock(&q->mmap_lock); /* @@ -995,7 +993,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, * from already queued buffers and it will reset q->memory to * VB2_MEMORY_UNKNOWN. */ - __vb2_queue_free(q, allocated_buffers); + __vb2_queue_free(q, 0, allocated_buffers); mutex_unlock(&q->mmap_lock); return ret; } @@ -1135,7 +1133,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, * from already queued buffers and it will reset q->memory to * VB2_MEMORY_UNKNOWN. */ - __vb2_queue_free(q, allocated_buffers); + __vb2_queue_free(q, 0, allocated_buffers); mutex_unlock(&q->mmap_lock); return -ENOMEM; } @@ -2617,7 +2615,7 @@ void vb2_core_queue_release(struct vb2_queue *q) __vb2_cleanup_fileio(q); __vb2_queue_cancel(q); mutex_lock(&q->mmap_lock); - __vb2_queue_free(q, q->max_allowed_buffers); + __vb2_queue_free(q, 0, q->max_allowed_buffers); kfree(q->bufs); q->bufs = NULL; bitmap_free(q->bufs_map); From patchwork Thu Sep 14 13:33:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139764 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp539633vqi; Thu, 14 Sep 2023 11:23:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IErY1Alxa1ilpp/ZsZ68ic5AvO4ov6jhSm4q3QL2yufVeOOSARzA+XOgDC9K/ugDwp5Gm6k X-Received: by 2002:a05:6358:5e01:b0:130:faea:a81f with SMTP id q1-20020a0563585e0100b00130faeaa81fmr5386001rwn.28.1694715792328; Thu, 14 Sep 2023 11:23:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694715792; cv=none; d=google.com; s=arc-20160816; b=s+IQGFmXqt9VyEq3BFbOlUf+pdKmIconIGwfuyRs8Yyeknvqo7SLbDrlyS7iJUjtLm VKVn3sdIAqz2gPz119TZ/3GpwdUkXVQt/z9hXdXeVi8jDFDpoXZOPTXKN5vHICDhIkLM QKfjx6fLa/IgYKVH44Ub/LoZhUmnTNwSS/K0WsXk6v1p13foHSvrfxatQ/99oOkzNd1Q joxhfs8wSuN+vkNKndzf9V68Pg1kb7oKbGEBvW6E4gcbof1tTOLPl0rHjrYyZ7tk1wyr LohycXmFk5yLF9ZahI6g9vyRVLWNKC7XFnGS1n7aD9LDbr1l+x7t9bOUPCPhlUC/G85i q2xg== 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=zJJyoSzah3Y5Jbg9izplEmIVnQxtDCPDbhb3lbKCFco=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=K8MzQjOrrIyQKylbryVNr07u6Aauha8KhnD+Pj9G31/BvKUAqMq41+2cfKuN4i9FQV Z2xabgtxFa8ijUuNWkeWl4EHcT3ciFPgHFsSnRRDqFwjupJw9fS+kNPqbSuL0GxNo1jN CVvdZeJ0YZAeWQRs7aitW1WIeAtv+lx89cX6AwKN4w0jcU1u/gHW75jhjEr45iez81cR qE+cE713zMzvykSRuSudQ7TEWwoErw1LB0blSQ5wrbW60TjJmGvvBrXVtWw9A8I/N0+s +/J3j661WiboIIkTuwNzg1v86dLgDz41NyT9OVoKzzg5+wojzNromRtvomIO6RUD5+sL vtrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="Z/leQTUA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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. [23.128.96.34]) by mx.google.com with ESMTPS id bv190-20020a632ec7000000b00565f611a1f8si1774013pgb.263.2023.09.14.11.23.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 11:23:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="Z/leQTUA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 3E96A852D278; Thu, 14 Sep 2023 06:36:08 -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 S240146AbjINNgE (ORCPT + 35 others); Thu, 14 Sep 2023 09:36:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239963AbjINNfM (ORCPT ); Thu, 14 Sep 2023 09:35:12 -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 30BF82D69; Thu, 14 Sep 2023 06:33:57 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 AACCA660735D; Thu, 14 Sep 2023 14:33:55 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698436; bh=gPrIyjnUT+nQb+IvVyPK1EavXZZpbvW0PvMK9ZcNc9k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z/leQTUAOnH6hWm6e/frQ4tKi0fUrwr0Ig6F48F1etkgRWffBiCvfYvGIhBncn7wy 4dfbn8RA4vMJ4JL8a0thZqF9M0MaHmxNrcDWQWPzTQjuH7e1/V3LEVBFTzAbY9gM/Z stytCLF7yzbatohryVJdN7nd5cfrI5vnElW18ObZCPZLTH1mEWucaFb883mqT7dVXd lOeLFXXfQrQuHFJhIA9v0dPT2n80akNbnppVYgTQpSiehxXO34GbHkcnX2QYXhs0D+ TsnOlx64R4AJs9si7uzJhGqG4pNRH4dJPSCqtnaqUaAWsypsIuvlep9GXXAZqxuiYW YYn9dud3H0mSw== 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 v7 47/49] media: v4l2: Add DELETE_BUFS ioctl Date: Thu, 14 Sep 2023 15:33:21 +0200 Message-Id: <20230914133323.198857-48-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (howler.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:36:08 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777038306456584669 X-GMAIL-MSGID: 1777038306456584669 VIDIOC_DELETE_BUFS ioctl allows to delete buffers from a queue. The number of buffers to delete in given by count field of struct v4l2_delete_buffers and the range start at the index specified in the same structure. Signed-off-by: Benjamin Gaignard --- .../userspace-api/media/v4l/user-func.rst | 1 + .../media/v4l/vidioc-delete-bufs.rst | 77 +++++++++++++++++++ .../media/common/videobuf2/videobuf2-core.c | 30 ++++++++ .../media/common/videobuf2/videobuf2-v4l2.c | 20 ++++- drivers/media/v4l2-core/v4l2-dev.c | 1 + drivers/media/v4l2-core/v4l2-ioctl.c | 17 ++++ include/media/v4l2-ioctl.h | 4 + include/media/videobuf2-core.h | 10 +++ include/media/videobuf2-v4l2.h | 13 ++++ include/uapi/linux/videodev2.h | 16 ++++ 10 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 Documentation/userspace-api/media/v4l/vidioc-delete-bufs.rst diff --git a/Documentation/userspace-api/media/v4l/user-func.rst b/Documentation/userspace-api/media/v4l/user-func.rst index 15ff0bf7bbe6..3fd567695477 100644 --- a/Documentation/userspace-api/media/v4l/user-func.rst +++ b/Documentation/userspace-api/media/v4l/user-func.rst @@ -17,6 +17,7 @@ Function Reference vidioc-dbg-g-chip-info vidioc-dbg-g-register vidioc-decoder-cmd + vidioc-delete-bufs vidioc-dqevent vidioc-dv-timings-cap vidioc-encoder-cmd diff --git a/Documentation/userspace-api/media/v4l/vidioc-delete-bufs.rst b/Documentation/userspace-api/media/v4l/vidioc-delete-bufs.rst new file mode 100644 index 000000000000..99cd03ee298c --- /dev/null +++ b/Documentation/userspace-api/media/v4l/vidioc-delete-bufs.rst @@ -0,0 +1,77 @@ +.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later +.. c:namespace:: V4L + +.. _VIDIOC_DELETE_BUFS: + +************************ +ioctl VIDIOC_DELETE_BUFS +************************ + +Name +==== + +VIDIOC_DELETE_BUFS - Deletes buffers from a queue + +Synopsis +======== + +.. c:macro:: VIDIOC_DELETE_BUFs + +``int ioctl(int fd, VIDIOC_DELETE_BUFs, struct v4l2_delete_buffers *argp)`` + +Arguments +========= + +``fd`` + File descriptor returned by :c:func:`open()`. + +``argp`` + Pointer to struct :c:type:`v4l2_delete_buffers`. + +Description +=========== + +Applications can optionally call the :ref:`VIDIOC_DELETE_BUFS` ioctl to +delete buffers from a queue. + +.. c:type:: v4l2_delete_buffers + +.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}| + +.. flat-table:: struct v4l2_delete_buffers + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - __u32 + - ``index`` + - The starting buffer index to delete. + * - __u32 + - ``count`` + - The number of buffers to be deleted with indices 'index' until 'index + count - 1'. + All buffers in this range must be valid and in DEQUEUED state. + In error case errno is set to ``EINVAL`` error code and index returns the index of + the invalid buffer. + If count and index are set to 0 :ref:`VIDIOC_DELETE_BUFS` will return 0. + * - __u32 + - ``type`` + - Type of the stream or buffers, this is the same as the struct + :c:type:`v4l2_format` ``type`` field. See + :c:type:`v4l2_buf_type` for valid values. + * - __u32 + - ``reserved``\ [13] + - A place holder for future extensions. Drivers and applications + must set the array to zero. + +Return Value +============ + +On success 0 is returned, on error -1 and the ``errno`` variable is set +appropriately. The generic error codes are described at the +:ref:`Generic Error Codes ` chapter. + +EBUSY + File I/O is in progress. + +EINVAL + The buffer ``index`` doesn't exist in the queue. diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 88cdf4dcb07c..465c2d7fccfa 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -1701,6 +1701,36 @@ int vb2_core_prepare_buf(struct vb2_queue *q, struct vb2_buffer *vb, void *pb) } EXPORT_SYMBOL_GPL(vb2_core_prepare_buf); +int vb2_core_delete_bufs(struct vb2_queue *q, unsigned int start, unsigned int count) +{ + unsigned int i, ret = 0; + + if (start == 0 && count == 0) + return 0; + + mutex_lock(&q->mmap_lock); + + for (i = start; i < start + count && i < q->max_allowed_buffers; i++) { + struct vb2_buffer *vb = vb2_get_buffer(q, i); + + if (!vb) { + ret = -EINVAL; + goto unlock; + } + if (vb->state != VB2_BUF_STATE_DEQUEUED) { + ret = -EINVAL; + goto unlock; + } + } + __vb2_queue_free(q, start, count); + dprintk(q, 2, "buffers deleted\n"); + +unlock: + mutex_unlock(&q->mmap_lock); + return ret; +} +EXPORT_SYMBOL_GPL(vb2_core_delete_bufs); + /* * vb2_start_streaming() - Attempt to start streaming. * @q: videobuf2 queue diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index a88abcea2921..9f90f01e5414 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -380,7 +380,7 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct media_device *md vb = vb2_get_buffer(q, b->index); if (!vb) { - dprintk(q, 1, "%s: buffer is NULL\n", opname); + dprintk(q, 1, "%s: buffer %u was deleted\n", opname, b->index); return -EINVAL; } @@ -752,6 +752,12 @@ int vb2_prepare_buf(struct vb2_queue *q, struct media_device *mdev, } EXPORT_SYMBOL_GPL(vb2_prepare_buf); +int vb2_delete_bufs(struct vb2_queue *q, struct v4l2_delete_buffers *d) +{ + return vb2_core_delete_bufs(q, d->index, d->count); +} +EXPORT_SYMBOL_GPL(vb2_delete_bufs); + int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create) { unsigned requested_planes = 1; @@ -1010,6 +1016,18 @@ EXPORT_SYMBOL_GPL(vb2_poll); /* vb2 ioctl helpers */ +int vb2_ioctl_delete_bufs(struct file *file, void *priv, + struct v4l2_delete_buffers *p) +{ + struct video_device *vdev = video_devdata(file); + + if (vb2_queue_is_busy(vdev->queue, file)) + return -EBUSY; + + return vb2_delete_bufs(vdev->queue, p); +} +EXPORT_SYMBOL_GPL(vb2_ioctl_delete_bufs); + int vb2_ioctl_reqbufs(struct file *file, void *priv, struct v4l2_requestbuffers *p) { diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c index f81279492682..215654fd6581 100644 --- a/drivers/media/v4l2-core/v4l2-dev.c +++ b/drivers/media/v4l2-core/v4l2-dev.c @@ -720,6 +720,7 @@ static void determine_valid_ioctls(struct video_device *vdev) SET_VALID_IOCTL(ops, VIDIOC_PREPARE_BUF, vidioc_prepare_buf); SET_VALID_IOCTL(ops, VIDIOC_STREAMON, vidioc_streamon); SET_VALID_IOCTL(ops, VIDIOC_STREAMOFF, vidioc_streamoff); + SET_VALID_IOCTL(ops, VIDIOC_DELETE_BUFS, vidioc_delete_bufs); } if (is_vid || is_vbi || is_meta) { diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index f4d9d6279094..46710228ecc8 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -489,6 +489,13 @@ static void v4l_print_create_buffers(const void *arg, bool write_only) v4l_print_format(&p->format, write_only); } +static void v4l_print_delete_buffers(const void *arg, bool write_only) +{ + const struct v4l2_delete_buffers *p = arg; + + pr_cont("index=%u, count=%u\n", p->index, p->count); +} + static void v4l_print_streamparm(const void *arg, bool write_only) { const struct v4l2_streamparm *p = arg; @@ -2160,6 +2167,15 @@ static int v4l_prepare_buf(const struct v4l2_ioctl_ops *ops, return ret ? ret : ops->vidioc_prepare_buf(file, fh, b); } +static int v4l_delete_bufs(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *arg) +{ + struct v4l2_delete_buffers *delete = arg; + int ret = check_fmt(file, delete->type); + + return ret ? ret : ops->vidioc_delete_bufs(file, fh, delete); +} + static int v4l_g_parm(const struct v4l2_ioctl_ops *ops, struct file *file, void *fh, void *arg) { @@ -2909,6 +2925,7 @@ static const struct v4l2_ioctl_info v4l2_ioctls[] = { IOCTL_INFO(VIDIOC_ENUM_FREQ_BANDS, v4l_enum_freq_bands, v4l_print_freq_band, 0), IOCTL_INFO(VIDIOC_DBG_G_CHIP_INFO, v4l_dbg_g_chip_info, v4l_print_dbg_chip_info, INFO_FL_CLEAR(v4l2_dbg_chip_info, match)), IOCTL_INFO(VIDIOC_QUERY_EXT_CTRL, v4l_query_ext_ctrl, v4l_print_query_ext_ctrl, INFO_FL_CTRL | INFO_FL_CLEAR(v4l2_query_ext_ctrl, id)), + IOCTL_INFO(VIDIOC_DELETE_BUFS, v4l_delete_bufs, v4l_print_delete_buffers, INFO_FL_PRIO | INFO_FL_QUEUE | INFO_FL_CLEAR(v4l2_delete_buffers, type)), }; #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls) diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h index edb733f21604..55afbde54211 100644 --- a/include/media/v4l2-ioctl.h +++ b/include/media/v4l2-ioctl.h @@ -163,6 +163,8 @@ struct v4l2_fh; * :ref:`VIDIOC_CREATE_BUFS ` ioctl * @vidioc_prepare_buf: pointer to the function that implements * :ref:`VIDIOC_PREPARE_BUF ` ioctl + * @vidioc_delete_bufs: pointer to the function that implements + * :ref:`VIDIOC_DELETE_BUFS ` ioctl * @vidioc_overlay: pointer to the function that implements * :ref:`VIDIOC_OVERLAY ` ioctl * @vidioc_g_fbuf: pointer to the function that implements @@ -422,6 +424,8 @@ struct v4l2_ioctl_ops { struct v4l2_create_buffers *b); int (*vidioc_prepare_buf)(struct file *file, void *fh, struct v4l2_buffer *b); + int (*vidioc_delete_bufs)(struct file *file, void *fh, + struct v4l2_delete_buffers *d); int (*vidioc_overlay)(struct file *file, void *fh, unsigned int i); int (*vidioc_g_fbuf)(struct file *file, void *fh, diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 734437236cc4..9b3dd96017c2 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -845,6 +845,16 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, */ int vb2_core_prepare_buf(struct vb2_queue *q, struct vb2_buffer *vb, void *pb); +/** + * vb2_core_delete_bufs() - + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @start: first index of the range of buffers to delete. + * @count: number of buffers to delete. + * + * Return: returns zero on success; an error code otherwise. + */ +int vb2_core_delete_bufs(struct vb2_queue *q, unsigned int start, unsigned int count); + /** * vb2_core_qbuf() - Queue a buffer from userspace * diff --git a/include/media/videobuf2-v4l2.h b/include/media/videobuf2-v4l2.h index 5a845887850b..79cea8459f52 100644 --- a/include/media/videobuf2-v4l2.h +++ b/include/media/videobuf2-v4l2.h @@ -118,6 +118,17 @@ int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create); */ int vb2_prepare_buf(struct vb2_queue *q, struct media_device *mdev, struct v4l2_buffer *b); +/** + * vb2_delete_bufs() - Delete buffers from the queue + * + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @d: delete parameter, passed from userspace to + * &v4l2_ioctl_ops->vidioc_delete_bufs handler in driver + * + * The return values from this function are intended to be directly returned + * from &v4l2_ioctl_ops->vidioc_delete_bufs handler in driver. + */ +int vb2_delete_bufs(struct vb2_queue *q, struct v4l2_delete_buffers *d); /** * vb2_qbuf() - Queue a buffer from userspace @@ -334,6 +345,8 @@ int vb2_ioctl_streamon(struct file *file, void *priv, enum v4l2_buf_type i); int vb2_ioctl_streamoff(struct file *file, void *priv, enum v4l2_buf_type i); int vb2_ioctl_expbuf(struct file *file, void *priv, struct v4l2_exportbuffer *p); +int vb2_ioctl_delete_bufs(struct file *file, void *priv, + struct v4l2_delete_buffers *p); /* struct v4l2_file_operations helpers */ diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 78260e5d9985..9cc7f570d995 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -2616,6 +2616,20 @@ struct v4l2_create_buffers { __u32 reserved[6]; }; +/** + * struct v4l2_delete_buffers - VIDIOC_DELETE_BUFS argument + * @index: the first buffer to be deleted + * @count: number of buffers to delete + * @type: enum v4l2_buf_type + * @reserved: future extensions + */ +struct v4l2_delete_buffers { + __u32 index; + __u32 count; + __u32 type; + __u32 reserved[13]; +}; + /* * I O C T L C O D E S F O R V I D E O D E V I C E S * @@ -2715,6 +2729,8 @@ struct v4l2_create_buffers { #define VIDIOC_DBG_G_CHIP_INFO _IOWR('V', 102, struct v4l2_dbg_chip_info) #define VIDIOC_QUERY_EXT_CTRL _IOWR('V', 103, struct v4l2_query_ext_ctrl) +#define VIDIOC_DELETE_BUFS _IOWR('V', 104, struct v4l2_delete_buffers) + /* Reminder: when adding new ioctls please add support for them to drivers/media/v4l2-core/v4l2-compat-ioctl32.c as well! */ From patchwork Thu Sep 14 13:33:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139911 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp693821vqi; Thu, 14 Sep 2023 16:43:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGYXyxMSvnV8+j2t4tdt3u0giHbsQ/jDv1hBpvNqkeZ01gAlbzW8uQEifJY/2Z9W6l/7HAM X-Received: by 2002:a17:90a:5aa5:b0:26d:40ec:3cf3 with SMTP id n34-20020a17090a5aa500b0026d40ec3cf3mr39268pji.0.1694734991929; Thu, 14 Sep 2023 16:43:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694734991; cv=none; d=google.com; s=arc-20160816; b=0Q5J0EnKrMeaa2guhswwjHYY9HOFnDa3tR2iQ1x+9t/Kql43/I8m4u3/EMQxGif3Ey /MKZQI7szjdb8yTMlgatJOFfIy+BPYNTSHLASmxGev6sfiOYAG9g45ZF0M3vJ1V7+/gL bCyZR3y2b108fJ7ToODW1Tx/gw1/J6iLMDY8uc4YTKS3WWJ7PMkxRVMWRS369va6L9VH QhGuuqysjUoJLxDbrbuSkk8xIsyr7iCSwvBkmeFkYN3DqJZDrZ2lcMWmLDy5uqEGwSu/ ZmwyLZRWXO0+hqjyUDwlpqinnLraKVj8DaTydMLPCbOrBIi9tbGl4r8Pt8sEVilsDXZn matA== 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=c65cPWzb/rGUIDWBxTTNQVYghy/Q4FEJyDB3E6oc0aI=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=J4+nIEUNktH/55eYLE8/PIbtnrWUxwgI6baHDYJe7S+KX7pPdxvwFcovazVQRQU/a5 IBkqGR8eywvdb2SEgq8JhmHzSm+Uza767SbR9tQVb5n7aJsNDcLiuHg0xTr7naURyTl7 SyFUJvg/SxmlfXki/QhbC3Fqu4d0TLUL7xFBTZsO9UiUkzpBz5quhL1uxR2UXCd/2HeQ lU+95m8bWojEPM0msBNxGs3BQF2ESEes2/JhtUdbweUVwloKdCMtelLLE1yEdw/aZsL2 CVwfVW8ftNr3apd592l67D18adSOba7Ib4Oh0NcSLOM/txJIahMN8x6gDxMrLfaHfc8t H+tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="S/frdpA8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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. [23.128.96.34]) by mx.google.com with ESMTPS id j21-20020a17090aeb1500b00262ef440ed4si4342196pjz.27.2023.09.14.16.43.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 16:43:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="S/frdpA8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 B4207853A936; Thu, 14 Sep 2023 06:36:25 -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 S240002AbjINNgH (ORCPT + 35 others); Thu, 14 Sep 2023 09:36:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239982AbjINNfN (ORCPT ); Thu, 14 Sep 2023 09:35:13 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAB9D2D77; Thu, 14 Sep 2023 06:33:57 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 30B6D660739D; Thu, 14 Sep 2023 14:33:56 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698436; bh=pnW19QGFHas/i7g4P9JRpTYH72fRU9HVTUZzFWqPek8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S/frdpA8eHkZ0lhsb6OXaBYpSmudN8EVRpzSoC5DCuaFoMu4vkWO3UO30WMap3lhx vlEIkg5EeJSc9xDMj78nC6kh+Bz3nHL3yjq0zCFAGiBEZSiSNP45IPDu39o7jbFWKh cCgy2t7vPOG96yTnB8sFbtJZs+HBoXtBq2XHU6/yEz0YtWDZnf39nwO2K/3kivxSSO W0TsANhosjjYHQ4+UyY2ytP1yKW71yRysB6IyV2TI7rvP9ilbajOUDDPXC1h+wv7Az /yDh4VvFsUr5vS8fSpUdwarVm7GMvygsYN+4kstLKwMLqxL7wgiy4sxp3XCr5p7tLo XFnuUK7BmSP5Q== 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 v7 48/49] media: v4l2: Add mem2mem helpers for DELETE_BUFS ioctl Date: Thu, 14 Sep 2023 15:33:22 +0200 Message-Id: <20230914133323.198857-49-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (howler.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:36:25 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777058439229782025 X-GMAIL-MSGID: 1777058439229782025 Create v4l2-mem2mem helpers for VIDIOC_DELETE_BUFS ioctl. Signed-off-by: Benjamin Gaignard --- .../media/platform/verisilicon/hantro_v4l2.c | 1 + drivers/media/test-drivers/vim2m.c | 1 + drivers/media/v4l2-core/v4l2-mem2mem.c | 20 +++++++++++++++++++ include/media/v4l2-mem2mem.h | 12 +++++++++++ 4 files changed, 34 insertions(+) diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/media/platform/verisilicon/hantro_v4l2.c index 27a1e77cca38..0fd1c2fc78c8 100644 --- a/drivers/media/platform/verisilicon/hantro_v4l2.c +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c @@ -756,6 +756,7 @@ const struct v4l2_ioctl_ops hantro_ioctl_ops = { .vidioc_dqbuf = v4l2_m2m_ioctl_dqbuf, .vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf, .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs, + .vidioc_delete_bufs = v4l2_m2m_ioctl_delete_bufs, .vidioc_expbuf = v4l2_m2m_ioctl_expbuf, .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, diff --git a/drivers/media/test-drivers/vim2m.c b/drivers/media/test-drivers/vim2m.c index 3e3b424b4860..10bd8c92e340 100644 --- a/drivers/media/test-drivers/vim2m.c +++ b/drivers/media/test-drivers/vim2m.c @@ -960,6 +960,7 @@ static const struct v4l2_ioctl_ops vim2m_ioctl_ops = { .vidioc_dqbuf = v4l2_m2m_ioctl_dqbuf, .vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf, .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs, + .vidioc_delete_bufs = v4l2_m2m_ioctl_delete_bufs, .vidioc_expbuf = v4l2_m2m_ioctl_expbuf, .vidioc_streamon = v4l2_m2m_ioctl_streamon, diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c index 0cc30397fbad..d1d59943680f 100644 --- a/drivers/media/v4l2-core/v4l2-mem2mem.c +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c @@ -831,6 +831,17 @@ int v4l2_m2m_prepare_buf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, } EXPORT_SYMBOL_GPL(v4l2_m2m_prepare_buf); +int v4l2_m2m_delete_bufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, + struct v4l2_delete_buffers *d) +{ + struct vb2_queue *vq; + + vq = v4l2_m2m_get_vq(m2m_ctx, d->type); + + return vb2_delete_bufs(vq, d); +} +EXPORT_SYMBOL_GPL(v4l2_m2m_delete_bufs); + int v4l2_m2m_create_bufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, struct v4l2_create_buffers *create) { @@ -1377,6 +1388,15 @@ int v4l2_m2m_ioctl_create_bufs(struct file *file, void *priv, } EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_create_bufs); +int v4l2_m2m_ioctl_delete_bufs(struct file *file, void *priv, + struct v4l2_delete_buffers *d) +{ + struct v4l2_fh *fh = file->private_data; + + return v4l2_m2m_delete_bufs(file, fh->m2m_ctx, d); +} +EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_delete_bufs); + int v4l2_m2m_ioctl_querybuf(struct file *file, void *priv, struct v4l2_buffer *buf) { diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h index d6c8eb2b5201..161f85c42dc8 100644 --- a/include/media/v4l2-mem2mem.h +++ b/include/media/v4l2-mem2mem.h @@ -381,6 +381,16 @@ int v4l2_m2m_dqbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, int v4l2_m2m_prepare_buf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, struct v4l2_buffer *buf); +/** + * v4l2_m2m_delete_bufs() - delete buffers from the queue + * + * @file: pointer to struct &file + * @m2m_ctx: m2m context assigned to the instance given by struct &v4l2_m2m_ctx + * @d: pointer to struct &v4l2_delete_buffers + */ +int v4l2_m2m_delete_bufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, + struct v4l2_delete_buffers *d); + /** * v4l2_m2m_create_bufs() - create a source or destination buffer, depending * on the type @@ -860,6 +870,8 @@ int v4l2_m2m_ioctl_reqbufs(struct file *file, void *priv, struct v4l2_requestbuffers *rb); int v4l2_m2m_ioctl_create_bufs(struct file *file, void *fh, struct v4l2_create_buffers *create); +int v4l2_m2m_ioctl_delete_bufs(struct file *file, void *priv, + struct v4l2_delete_buffers *d); int v4l2_m2m_ioctl_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf); int v4l2_m2m_ioctl_expbuf(struct file *file, void *fh, From patchwork Thu Sep 14 13:33:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 139686 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp468927vqi; Thu, 14 Sep 2023 09:25:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFmEWqt7Zdt2kfezjaJJpl6EMcEpBCDnx+3cF+W4t4kFJqA18LQdfp/0g/eGkYdLZ2WYOI1 X-Received: by 2002:a17:903:22c2:b0:1c0:a5c9:e072 with SMTP id y2-20020a17090322c200b001c0a5c9e072mr6898173plg.11.1694708715398; Thu, 14 Sep 2023 09:25:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694708715; cv=none; d=google.com; s=arc-20160816; b=BJf1Ks4XUuibpow9s0EYq/h0GRDEgR8QcLxqVuLbt0Clyh7WKiJ3KZ/X12AjgkioiD DmKTFovipRx3AoDAzZXS0GIVVoarb6cpxb4OxE1sFKLgDlqUK1sZhP7DsowmbJvk0Sg1 cP42Uyb/hOV92t4xBxZP4s4aRnrkNKZzMyrCVI2rGdkX/g/ELbMOV7y+mdPTL+Aju/6d 83JlkeY6/9KB5opVE55IrO0sJoCRaTJHvLNt52SiKizGx25LhXHhYu77upxDBlO44U6R RZo3RW3S4Z+h/PTu5CoFURN3QKxoVed/WqayZGKnpup+Seu4g1FMrgEjqBg6H40npMJL YZRQ== 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=1n4BilA85n8hK9jytaRvNBsyEkzoJLPWbdOFjn9Jf3k=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=cWGMt05AJRafoZbh8A+tBG0YzUkYARKHFIgOwUl9c7Kz6wKH89xERggKXTRrzCZm7y eegmyoUK+Hmn5BYvcqEewJpkwmr9zgiXsfbrlgVyVegs/+R9AkpqU+2tEQlVLyqWV2BW 4k7ogGdMLq/keeat5iyIxoeOTGEooorhwMp+TB8mO/G93C6QnnEf/3VI9hA0UfwW8NT8 KoiwmlXuSnrJD7AmNoPFvjOFyiqs3ily90Klycgv8NUAheC90ax5Oko1a1ebecokB2zV EXOzn9ibarjttHzkq8SHROfHqf3PNT/QA6w++GF6DJLJnwUO7+b+pIvjRfKZsIfL/S+f a2tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="SL+vKn/u"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id kp3-20020a170903280300b001c0eefc0dfesi1883120plb.130.2023.09.14.09.25.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 09:25:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="SL+vKn/u"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 8FF2581BFA87; Thu, 14 Sep 2023 06:36:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239733AbjINNgL (ORCPT + 35 others); Thu, 14 Sep 2023 09:36:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239721AbjINNfQ (ORCPT ); Thu, 14 Sep 2023 09:35:16 -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 3E6C130C1; Thu, 14 Sep 2023 06:33:58 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:36f2:37bd:ccbb:373f]) (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 ADAC16607363; Thu, 14 Sep 2023 14:33:56 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694698437; bh=e/0oW+YFaFeImADlNG8EUeKcdUibwENtTNcAqKB0P6A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SL+vKn/uv+bwLgADFoLmvyiqfe7/Lo7rBKOrF3RpVfp8gVqlFIgwHnnlBT1svUSxM PsqGrTbXR5ewRPNj+tlt0w6nzkBWLldeaLmQtuHqb7bjpSrsmaqw797Fo7RcpeZZu6 E5S1TZU1JlWmB3t5A5CESCWvBDmgMGUVXdQjnn4IIO1mAwAT2Z9ZLvfDN1oWt34LUl IYL1iHAeSuYkZNMzNlVPN8uHOTIsiovx8LnTA9EdFQmA6oXqFqDV3IjnkLfuPY6yaJ NSi1oVparCg69fZ86IB2ARG345RQeyqglO8Jj0sgkLOm7NUdHVUPqlh2+bp5AcLTQu b+2Y4U/qNMblg== 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 v7 49/49] media: test-drivers: Use helper for DELETE_BUFS ioctl Date: Thu, 14 Sep 2023 15:33:23 +0200 Message-Id: <20230914133323.198857-50-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914133323.198857-1-benjamin.gaignard@collabora.com> References: <20230914133323.198857-1-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 (lipwig.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:36:44 -0700 (PDT) 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777030885814027243 X-GMAIL-MSGID: 1777030885814027243 Allow test drivers to use DELETE_BUFS by adding vb2_ioctl_delete_bufs() helper. Signed-off-by: Benjamin Gaignard --- drivers/media/test-drivers/vicodec/vicodec-core.c | 1 + drivers/media/test-drivers/vimc/vimc-capture.c | 1 + drivers/media/test-drivers/visl/visl-video.c | 1 + drivers/media/test-drivers/vivid/vivid-core.c | 1 + 4 files changed, 4 insertions(+) diff --git a/drivers/media/test-drivers/vicodec/vicodec-core.c b/drivers/media/test-drivers/vicodec/vicodec-core.c index 6f0e20df74e9..64bb0d3372f0 100644 --- a/drivers/media/test-drivers/vicodec/vicodec-core.c +++ b/drivers/media/test-drivers/vicodec/vicodec-core.c @@ -1339,6 +1339,7 @@ static const struct v4l2_ioctl_ops vicodec_ioctl_ops = { .vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf, .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs, .vidioc_expbuf = v4l2_m2m_ioctl_expbuf, + .vidioc_delete_bufs = v4l2_m2m_ioctl_delete_bufs, .vidioc_streamon = v4l2_m2m_ioctl_streamon, .vidioc_streamoff = v4l2_m2m_ioctl_streamoff, diff --git a/drivers/media/test-drivers/vimc/vimc-capture.c b/drivers/media/test-drivers/vimc/vimc-capture.c index aa944270e716..66e76b645346 100644 --- a/drivers/media/test-drivers/vimc/vimc-capture.c +++ b/drivers/media/test-drivers/vimc/vimc-capture.c @@ -221,6 +221,7 @@ static const struct v4l2_ioctl_ops vimc_capture_ioctl_ops = { .vidioc_expbuf = vb2_ioctl_expbuf, .vidioc_streamon = vb2_ioctl_streamon, .vidioc_streamoff = vb2_ioctl_streamoff, + .vidioc_delete_bufs = vb2_ioctl_delete_bufs, }; static void vimc_capture_return_all_buffers(struct vimc_capture_device *vcapture, diff --git a/drivers/media/test-drivers/visl/visl-video.c b/drivers/media/test-drivers/visl/visl-video.c index 7cac6a6456eb..2fb5ff4a4987 100644 --- a/drivers/media/test-drivers/visl/visl-video.c +++ b/drivers/media/test-drivers/visl/visl-video.c @@ -521,6 +521,7 @@ const struct v4l2_ioctl_ops visl_ioctl_ops = { .vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf, .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs, .vidioc_expbuf = v4l2_m2m_ioctl_expbuf, + .vidioc_delete_bufs = v4l2_m2m_ioctl_delete_bufs, .vidioc_streamon = v4l2_m2m_ioctl_streamon, .vidioc_streamoff = v4l2_m2m_ioctl_streamoff, diff --git a/drivers/media/test-drivers/vivid/vivid-core.c b/drivers/media/test-drivers/vivid/vivid-core.c index e95bdccfc18e..43a7594e7c5b 100644 --- a/drivers/media/test-drivers/vivid/vivid-core.c +++ b/drivers/media/test-drivers/vivid/vivid-core.c @@ -769,6 +769,7 @@ static const struct v4l2_ioctl_ops vivid_ioctl_ops = { .vidioc_expbuf = vb2_ioctl_expbuf, .vidioc_streamon = vb2_ioctl_streamon, .vidioc_streamoff = vb2_ioctl_streamoff, + .vidioc_delete_bufs = vb2_ioctl_delete_bufs, .vidioc_enum_input = vivid_enum_input, .vidioc_g_input = vivid_g_input,