From patchwork Tue Oct 3 08:06: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: 147696 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1928223vqb; Tue, 3 Oct 2023 01:07:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGIYpllmqn6XEz3zfprLtWlk2BBgX8ZVkKPeqn9sDVIWT/QwDnMTfXKdAbGaKIjo+6TyPUb X-Received: by 2002:a05:6a21:7783:b0:15d:b243:6131 with SMTP id bd3-20020a056a21778300b0015db2436131mr15565705pzc.44.1696320467229; Tue, 03 Oct 2023 01:07:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320467; cv=none; d=google.com; s=arc-20160816; b=JMBSJRGiKUp4h6fkJ9a8wacWZVCtOnV8KRRzFAQ5B3EAxibYFlWuYRwvJJGeWdnedx P+eUiJwPtc9kL563o7hMmcMduUHLxLJgWBfDI78CAJAkeez4lc798IrbXjLCMA97Ti4P KB7LOKZm3nw21QnA1nr9SXFFJxZpssxhFHSdTDWt8v2d7WNJ0Qxp0Mov1wq6XY76F7R5 xOpYtA9YW7rPPWiGyyg9Jf756Yodzk+xtrLBdQQWNsYKiKW0kzZdLJk1dDX8SPUWo0uP ITnOgpcxch+DELZFb9AbxPA6pKYfR4W/xGoeLB0lhERvLKlW7XmnzpK22xBZBfLAYUSE +aeg== 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=JqICkKxp7twyb99+JQYLQnnWjdxLYsEYA0jlYnOtWp4=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=LFRQk5D3fCcWvLm3JIMHyvc/52h8jGxGn3Yjo3LNcqt2+WAnZ59IOzecEcdXKz2Da1 eCf77yqx7VsArIdGl4GJNBOnBPj+uk95M9n1vbfdBZ/U2+RKIqd9clZwhVPXGWTOa8uP ftX5dT9jvOEvBn6yGzpcQlQppgQF60RA62DkVjWNqDzrOPs7+6Y27MubtU4Xj3yOhmsP QMgtO0bWThlfRoBcDckuhrDnu2Z0e9HjeK0eH3Wszxv2lfUAgGPIoY9gDgtWKFGRHRc+ ZMtC0KAQY4R2Zw529GWxlE8bekPU18BKG45dddgu2ViUQPeOAg4KsJbBHywCy0bTXkhm u0XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=U32ioNXF; 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 kp14-20020a170903280e00b001c5da8b630fsi847422plb.421.2023.10.03.01.07.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:07:47 -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=U32ioNXF; 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 BDF6A8226AC6; Tue, 3 Oct 2023 01:07:45 -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 S239381AbjJCIHb (ORCPT + 18 others); Tue, 3 Oct 2023 04:07:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239232AbjJCIHV (ORCPT ); Tue, 3 Oct 2023 04:07:21 -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 8886ABB; Tue, 3 Oct 2023 01:07:15 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 624626607314; Tue, 3 Oct 2023 09:07:13 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320433; bh=iaY5c9hnLGM9FgrNcUT9lH4BfnmbtAjScVjFG5kZCis=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U32ioNXFphjGSPZdVwpd0lLjfDTrjtM6596sviypo1SXXukFqqingEOxnPZ5QAkx9 FN7moKADdfch34xO/K6Psjwe9Z4IZU+keR5sxck8rZwuqOXIr+ZXoEARaJD9+8wuD1 R7NC3Y1da3nVNVQHlQ+7TpJCUUUkz2Zfaai5T8mIEbEKxPaql8PG3VXdLDBhLQdWo8 U0gBdu/lAf3Q3wuJRyu/+NOCxlmOS0NnehG8LNUenMGfUz/omx17wl43vfMZxUsceE UjFxDWl+TLn1CbIB6FRLIS2Okq3C8h5KGy9uX7cK5AwstpVMcFMilVfpyx/MMU6She Sd7OtUGnz2Bqw== 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 v10 01/54] media: videobuf2: Rework offset 'cookie' encoding pattern Date: Tue, 3 Oct 2023 10:06:10 +0200 Message-Id: <20231003080704.43911-2-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:07:45 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778720930048222323 X-GMAIL-MSGID: 1778720930048222323 Change how offset 'cookie' field value is computed to make possible to use more buffers. The maximum number of buffers depends of PAGE_SHIFT value and can go up to 0x7fff when PAGE_SHIFT = 12. With this encoding pattern we know the maximum number that a queue could store so we can check it at queue init time. It also make easier and faster to find buffer and plane from using the offset field. Change __find_plane_by_offset() prototype to return the video buffer itself rather than it index. Signed-off-by: Benjamin Gaignard --- changes in version 10: - Make BUFFER_INDEX_MASK definition more readable. - Correct typo. .../media/common/videobuf2/videobuf2-core.c | 72 +++++++++---------- 1 file changed, 33 insertions(+), 39 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 27aee92f3eea..5591ac830668 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -31,6 +31,11 @@ #include +#define PLANE_INDEX_SHIFT (PAGE_SHIFT + 3) +#define PLANE_INDEX_MASK 0x7 +#define MAX_BUFFER_INDEX BIT_MASK(30 - PLANE_INDEX_SHIFT) +#define BUFFER_INDEX_MASK (MAX_BUFFER_INDEX - 1) + static int debug; module_param(debug, int, 0644); @@ -358,21 +363,24 @@ 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 can have up to 8 planes. + * - v4l2 mem2mem uses bit 30 to distinguish between source and destination buffers. + * - must be page aligned + * That led to this bit mapping when PAGE_SHIFT = 12: + * |30 |29 15|14 12|11 0| + * |DST_QUEUE_OFF_BASE|buffer index|plane index| 0 | + * where there are 15 bits to store the buffer index. + * Depending on PAGE_SHIFT value we can have fewer bits to store the 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); } } @@ -2185,13 +2193,12 @@ int vb2_core_streamoff(struct vb2_queue *q, unsigned int type) EXPORT_SYMBOL_GPL(vb2_core_streamoff); /* - * __find_plane_by_offset() - find plane associated with the given offset off + * __find_plane_by_offset() - find video buffer and plane associated with the given offset off */ static int __find_plane_by_offset(struct vb2_queue *q, unsigned long off, - unsigned int *_buffer, unsigned int *_plane) + struct vb2_buffer **vb, unsigned int *plane) { - struct vb2_buffer *vb; - unsigned int buffer, plane; + unsigned int buffer; /* * Sanity checks to ensure the lock is held, MEMORY_MMAP is @@ -2209,24 +2216,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; - } - } - } + if (buffer >= q->num_buffers || *plane >= q->bufs[buffer]->num_planes) + return -EINVAL; - return -EINVAL; + *vb = q->bufs[buffer]; + return 0; } int vb2_core_expbuf(struct vb2_queue *q, int *fd, unsigned int type, @@ -2306,7 +2304,7 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma) { unsigned long off = vma->vm_pgoff << PAGE_SHIFT; struct vb2_buffer *vb; - unsigned int buffer = 0, plane = 0; + unsigned int plane = 0; int ret; unsigned long length; @@ -2335,12 +2333,10 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma) * Find the plane corresponding to the offset passed by userspace. This * will return an error if not MEMORY_MMAP or file I/O is in progress. */ - ret = __find_plane_by_offset(q, off, &buffer, &plane); + ret = __find_plane_by_offset(q, off, &vb, &plane); if (ret) goto unlock; - vb = q->bufs[buffer]; - /* * MMAP requires page_aligned buffers. * The buffer length was page_aligned at __vb2_buf_mem_alloc(), @@ -2368,7 +2364,7 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma) if (ret) return ret; - dprintk(q, 3, "buffer %d, plane %d successfully mapped\n", buffer, plane); + dprintk(q, 3, "buffer %u, plane %d successfully mapped\n", vb->index, plane); return 0; } EXPORT_SYMBOL_GPL(vb2_mmap); @@ -2382,7 +2378,7 @@ unsigned long vb2_get_unmapped_area(struct vb2_queue *q, { unsigned long off = pgoff << PAGE_SHIFT; struct vb2_buffer *vb; - unsigned int buffer, plane; + unsigned int plane; void *vaddr; int ret; @@ -2392,12 +2388,10 @@ unsigned long vb2_get_unmapped_area(struct vb2_queue *q, * Find the plane corresponding to the offset passed by userspace. This * will return an error if not MEMORY_MMAP or file I/O is in progress. */ - ret = __find_plane_by_offset(q, off, &buffer, &plane); + ret = __find_plane_by_offset(q, off, &vb, &plane); if (ret) goto unlock; - vb = q->bufs[buffer]; - vaddr = vb2_plane_vaddr(vb, plane); mutex_unlock(&q->mmap_lock); return vaddr ? (unsigned long)vaddr : -EINVAL; From patchwork Tue Oct 3 08:06: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: 147713 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1928766vqb; Tue, 3 Oct 2023 01:08:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHwAp27hegyt293+zcVPGdaMh016s6b1cS3dJs7YljGtonp2jGayRCUkL1zvY6Dwi8dGXvV X-Received: by 2002:a17:902:e74b:b0:1c7:7e00:8075 with SMTP id p11-20020a170902e74b00b001c77e008075mr2464039plf.66.1696320536363; Tue, 03 Oct 2023 01:08:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320536; cv=none; d=google.com; s=arc-20160816; b=ckt7SDDZkFwU3DPYxMQa6d7vdJXJuIlB/RYWiP+nu0lwhzOBTb+pLbPb8+STtDZjmd dzsnsjWZPFWdG/LM1mqO+CutLQVBLs8AHYmzANo37wR70a97wUwXoo0sdOztIcGr/RvI Q8gMjL6BPOrhzTXbpN+wJYNh8Dxl8gB9bGLpTB9NdgNkycBg3ilYCvt4DM2I4JEsjX33 8DqDQLj4Yaa5JnHrFYh3rr2cQWnlo/W+gpjS1jMHfzpiPv5T06VDuwZw5ZlKFDZT/0k4 hv6YspsGR6QqV94+OqcypakxuZ3tP6mwvLTmB1oqLV/awT7IebKTp2iDQVKw2L3mdHKB owng== 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=vc68zaBws+qPLnkY0w+oHpjzuGRruZDJHRamfFmuUHA=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=ZraPdv0yF0yM+Ca9j5fKsXf9PVhvImwEIc70Q1E5oGxy7PXgLLlx5l8Irxa+TccoAp uu66wrRkmffidr2rpW0PlcaYowLaI6JJKwWitOBBISVI0L/SZQNBoShM3GFC6qaYl7hw YFpwjpOj+DFsmRv/GFd1imj7OA3FL1QmOjaZYuVQVmn4Otn/sw+ThSwJXOKWaydpGPU9 +FNFPzFAQSOBlToFoZfq9daE4j+R2033k7S2B/d5krgEF/3JdjB5pwi0hwZryy+1fKhy L0ELAQZPQCoZsxGmxqKrPROqbLR79KhwpZgIRZgMekEB9ieQvGniE1EiYiSQPS/P6iGi QH6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Lclpt0hU; 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 m12-20020a170902e40c00b001c754e83e06si864880ple.164.2023.10.03.01.08.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:08:56 -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=Lclpt0hU; 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 0FF47812281D; Tue, 3 Oct 2023 01:08:37 -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 S239432AbjJCIHg (ORCPT + 18 others); Tue, 3 Oct 2023 04:07:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231144AbjJCIHV (ORCPT ); Tue, 3 Oct 2023 04:07:21 -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 94CB8C4; Tue, 3 Oct 2023 01:07:15 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 E0E2266072B6; Tue, 3 Oct 2023 09:07:13 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320434; bh=kxbSHANw0y9s2YTYbL/OOYKK4JfvgPsqYw/KEGppJRY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lclpt0hUgQGbW4SVFMGB3M/mFW1t1aXRFDu3FtrzDvRLRO2U1/70iQgY61j5kMmVt w/WTammQojtu4QUsSMjBARlK/CXMzr6XePrZ+Lb2FjivHxVYugAYtOLKeYJB8ppbVq Vt1m3M1OeOg8vlabbMhFz8nIjqeSLgIKYCo/M+GA1orabSYZClivw/2vtEFu1T25Gt pI60g4uC3GtuWfvi4TNyzHk7laf+VCpCUrZjKS4sBKpjXsJQGCAI8XH79XnELA9Dkb Z8poQUcP7qWPgKDMhdI6eVxpOQV1wqKtTAS7X2ZAzPJU6/onNJr+f99NT3Vytl994/ TDWjaHOIKFaiQ== 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 v10 02/54] media: videobuf2: Stop spamming kernel log with all queue counter Date: Tue, 3 Oct 2023 10:06:11 +0200 Message-Id: <20231003080704.43911-3-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:08:37 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721002650388025 X-GMAIL-MSGID: 1778721002650388025 Only report unbalanced queue counters do avoid spamming kernel log with useless information. Signed-off-by: Benjamin Gaignard --- .../media/common/videobuf2/videobuf2-core.c | 79 +++++++++++-------- 1 file changed, 44 insertions(+), 35 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 5591ac830668..c44264de97a7 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -530,25 +530,26 @@ 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. + * Check that all the calls were balanced during the life-time of this + * 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; @@ -569,29 +570,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 Tue Oct 3 08:06: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: 147697 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1928271vqb; Tue, 3 Oct 2023 01:07:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG9DSPUL7uz7Vz+i9wB8F0OqmZKrEv4eNXZb1pHlwv46v5IB2Csv2yS2ROOPcjf5jkGNL9V X-Received: by 2002:a05:6a20:1451:b0:153:63b9:8bf9 with SMTP id a17-20020a056a20145100b0015363b98bf9mr16908095pzi.0.1696320473382; Tue, 03 Oct 2023 01:07:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320473; cv=none; d=google.com; s=arc-20160816; b=VngeRChe93J8JS+hk3favY2afycPQm2wkokExvzQT9UT9WltuABfAokkbX/jllGYwa MCLk6jGJt1Cz+NkDVaxQDTO1jpbKmtEtCTbkZSo/RF8cSVmimD89zYwsu2fuqbcURyPK +dVzcZnkP8WYeEmEJx8f5OgRG4NgAz13NAtTVTybxmrUGr3SI/bpHMqbJkpe5rN66zZ5 ocu2rLRirYgYO+heu+rCUO4xsNp7K0mLZqonvWJ2OwczVelJBuDn9X15qt5bYGCq2Krf 5XOQEPTcIc21JjnrELrYQpQar7Ra4rpk72s+8Mj7eNl2+3x7wShOGi0aoWphh11M1Ecs yYsQ== 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=xcaYDyQaWEtzaj4+4GLilFicTpP9FpEWuusNmdmq47E=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=p3hkx5ymZIJOcR1U1BOClTuYi0XxkS9xZPR1E0t5bCmOyLJnPBUNs/IrKQk1jsVseC cw0FO8HsoP/iJnWx6H+bAV7glmx4NsdiAYJ2r25s8XRKd4qM86EPvpZE+LMd+Da4/x+t tNPIDYfGDpjE63xgbju8Eyn+B9TemHA5Q1WtzHc4uxUQY8fWAofI3x8Nua5jlSTJrgdw ihX7CChs7IbaSZdjN2YM4vt3mICmAt851G3zrYwnEp0z/bNRlFzYa5PNbuB0MhNT/qP/ fh9NmOdcEAhhwBzb9tmsc5U/Ks2/t/n4hwBC0TRgXbsNEQ3SUuWK4vkkEZDMaHng+Bp/ /LVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="nGQov/9t"; 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 z25-20020a056a001d9900b0068fce4338bdsi980249pfw.62.2023.10.03.01.07.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:07:53 -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="nGQov/9t"; 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 A3D7D8227786; Tue, 3 Oct 2023 01:07:51 -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 S239516AbjJCIHk (ORCPT + 18 others); Tue, 3 Oct 2023 04:07:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239261AbjJCIHV (ORCPT ); Tue, 3 Oct 2023 04:07:21 -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 43B68DA; Tue, 3 Oct 2023 01:07:16 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 6BA9D66072E6; Tue, 3 Oct 2023 09:07:14 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320434; bh=9zZQNmh21PWwX8nd7laSkLetY4Sdd3SGPB233U+jWLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nGQov/9t6e38tkeTozDUjC9n24fZIH34YKlLnFsQfPZhu2ZX/DDWtXiV8YjlFxnxf 5VXvtfRAwK6fxWlDgfAyR83uexHKccIA7rB06JYc6+Nqh25CHR4J4kZ32pTmTGiKPa SjH4mifhCU0YZi/74F1w1lKEtvwlCO9xXDwyP/LTMdbmVFHSWb7TmxAXT2wgdvern0 SwPIa5xgynLklNPlbRhBABXR7Lmw8fH9eRug6Ks1if2jRu5qvitWk6XpQ8KW6a4y0M iTDx3C+tz8UoVuNF4r0s6/mUUivFDsepP8jGyclRTE2PHvbHfb9mOCYwaxjDNh3QOK Wx9YrzpL0cDKw== 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 v10 03/54] media: videobuf2: Use vb2_buffer instead of index Date: Tue, 3 Oct 2023 10:06:12 +0200 Message-Id: <20231003080704.43911-4-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:07:51 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778720936845795808 X-GMAIL-MSGID: 1778720936845795808 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 c44264de97a7..f3ff26b66bd4 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -651,9 +651,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); @@ -1487,9 +1487,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); @@ -1504,7 +1501,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); } @@ -1559,12 +1556,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)); @@ -1651,10 +1646,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; @@ -1663,8 +1657,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"); @@ -2237,9 +2229,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; @@ -2264,13 +2255,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; @@ -2289,20 +2273,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; @@ -2707,7 +2691,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; @@ -2892,7 +2876,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_qbuf result: %d\n", ret); if (ret) return ret; @@ -2995,7 +2979,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 Tue Oct 3 08:06: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: 147701 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1928330vqb; Tue, 3 Oct 2023 01:08:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEtsI6YiOJ3zM5goHxxnNpy0cpx7OKvnqA63o1Z0vBvnhj4G/8RlHptemG1F4BVe2yKWz0i X-Received: by 2002:a05:620a:846:b0:775:92ac:a3dc with SMTP id u6-20020a05620a084600b0077592aca3dcmr10516338qku.46.1696320480820; Tue, 03 Oct 2023 01:08:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320480; cv=none; d=google.com; s=arc-20160816; b=nONll8EhNW9vYXu0EZhzC68g4hlQ1FpFXPW2hwVGXSnb9FvCm8wlE91+HPG2k68c3f tGXXperFdJUaxjCACwR+4hflV6RFoEOds131tfegNTH/gW6U5vaSmXfUjurSY8kWjSXw khT5ML5gRycwsLAdDliPUHQ2fsJ6BCWVwDubW1iJrjXr05/2M3jXqJ133gtmUmw6TuFc NwTdWdLtWDfjQC7KwWAn6vr2Igxe6jWxi2Q/mrqUwFWRupT10i/Sk8RPklPHth//5Ad3 WRqkqSutwARu55AYpUojdN799HBPQQYItL14DWcnwivkbqkE5tAEEI7OGKPvHH6iXqrT dweQ== 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=MbycK5KuwNQjSlT1Uc0jQzNAPA1kdnZJnhrz5Qpd31LYRMcDoO01rv/t8wTR9a4i44 q39LXAGrSv+EqbHRRQnD412MLKHM5DJ11ONg36vwDjdo3rIBuBEFYJO1DTQJeQk3vwzE bL4GzD1bDHAiXFL7OhYEyGWdt5W6xcBGM0pTbBI1aRrrdqkBITZVFgwY8Kz2uebaTWpA imBMnjV4ypPWNApKOJe7PSJ6jJzGwx9xmxg26fZ6NvccJDufHVAzUKmCb55fxuROFEK/ VV9SU+8iJ1olmgFuHqix9Ta2OQlv1eomZ2mdjfFId9wsAHmugx5NFvwBkQXXmTxA5LNz iJkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Ezn1xtT+; 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 l133-20020a633e8b000000b0057942bfab4dsi907199pga.395.2023.10.03.01.08.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:08:00 -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=Ezn1xtT+; 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 8DC248026446; Tue, 3 Oct 2023 01:07: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 S239251AbjJCIHW (ORCPT + 18 others); Tue, 3 Oct 2023 04:07:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239221AbjJCIHV (ORCPT ); Tue, 3 Oct 2023 04:07:21 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3918A3; Tue, 3 Oct 2023 01:07:16 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 EAA9D6607312; Tue, 3 Oct 2023 09:07:14 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320435; bh=swS7yYiqBxggjIra2XX2pXDY4PPq3f683TK0rKa6DhQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ezn1xtT+nlzICJXTJx0uIND417DHUexBcDMUO5TS9LDKREqcHxr8Xee69W2Sm/u6o /rZ99CxtG+OfUsPXWhQOWJQ8PiG4zPh9K0HMSCcDjA9F31381g1z824Fari2skT9gQ NMWd3qCCUYUo6+RY27YNTrvVdhY3Q9gxA0PQSZ0puXvirg0cphkoRodaZ1e5K1x4Ea N3dR3LLnXMOsmxeipfww9imDST3qN/YzNCVdXaOkIlA/VeK/gAe9z/W1YLVxEej3oL K1LG/2Awtmpr/0zOn6wyd+8fOh2UCkcwDc81rKq9mqIQ6mbr5DAGqY5VRt5KFSKIeR Igb/JtZfZaBkg== 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 v10 04/54] media: amphion: Use vb2_get_buffer() instead of directly access to buffers array Date: Tue, 3 Oct 2023 10:06:13 +0200 Message-Id: <20231003080704.43911-5-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:07:45 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778720944727292047 X-GMAIL-MSGID: 1778720944727292047 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 Tue Oct 3 08:06: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: 147707 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1928551vqb; Tue, 3 Oct 2023 01:08:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1PtT/OotHtYtm9gQFebIt29MO8xlEGFdn2W1vgLnolg2pCOswaG2qJ0wmhWSrxxAfB1Lj X-Received: by 2002:a9d:62c8:0:b0:6bc:de95:a639 with SMTP id z8-20020a9d62c8000000b006bcde95a639mr15034642otk.16.1696320509291; Tue, 03 Oct 2023 01:08:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320509; cv=none; d=google.com; s=arc-20160816; b=U9GkHxYJ9Nkd7LCcNS9XbQODV3OMGdDSPypgmYd34WNZWW7vm0AL5Y6xbTfiEe4vJD 2Z3PlpmCWyhh2Ax4JuluPMlmYFOiVZSZCHnkpMng8sbi3348QvzmDudxEfouDrzQ8HFR K6uyp3THAgyjeB/0+Ykoj27TvAcOiycDP9UG+6uw/a2D6Q+HJ28xwRxMJcfMO8B6VZvh +UauxevUEZvAW/yFiReFF0Ar+2rOA2mFepw6fIkpmuYzVAwmYJCm57hl57DYObjafPc7 /faRyvbfnUQwl5itXZaBTrqWkG+AKj7596dFJwjO1qULT6lUL1YjV5GE05TuWJoo9u5N bLOg== 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=iXpO/bf/07zASv/l5IGzIYnUJXPeholVXqdvdJos3H67xHF7fG/zmLur/wtHCVN49r uq1gnYl+eDf872/+l+2KW/36HtCev9N04DjKGJIleHelETo6o+01oUlfxFT1JQMOPT4j wuRZGY9qHbmIolApQ4ZCH/crdIJQCWj44O/KR6OB9ItiQ3/Jaepxn/rnulXJrrgdZN0+ Ub8RKC9aRgjc5+UFDqoRC6DTdBprPLhFQUiz0tWRxz7jxDoJemTQ++akT+PCOPICAU6U 8wCUEOH6XAuDxB2DC6c4KmWVY0hMzFwW9lJ0+pE9mxJU3pMCDD1boG1x6LejVFKsDp6e XKYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="MqR/337q"; 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 bk13-20020a056a02028d00b005789db12724si939612pgb.353.2023.10.03.01.08.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:08:29 -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="MqR/337q"; 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 8F135823CC72; Tue, 3 Oct 2023 01:08:28 -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 S239715AbjJCIIY (ORCPT + 18 others); Tue, 3 Oct 2023 04:08:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239297AbjJCIHX (ORCPT ); Tue, 3 Oct 2023 04:07:23 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C136A1; Tue, 3 Oct 2023 01:07:20 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 716F56607318; Tue, 3 Oct 2023 09:07:15 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320435; bh=xgQ59ci0u36Sg6Kfk6W/knjQu2QF8jMpnRAVGSPYz3E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MqR/337qaBaeM2xhBO323b7fASbEIQFNsiApNazHjton1vaqccRdDupCKmzcUXXHY 101y9VY4UxDD0kieue9DEHiAOY7JrerIONfrrlvFgVailtnPPiF1SGI+2v2ZvFpTH/ 8i5XWifha+0WvS/W0yCcozLOu9rc4HCm21u+N2lKO0MFBTMSM+uEKe9v3+8h0vTwU9 YWwxiZDLvH8ONHPq/9/RSymA6dAVZTgT1esecZR/OqrYiPv/yuIHPVS/rAg0zyJJlh 1wcYJ/Bfz6Vyt+aLH0LtqRIAIuToGkgncwpz0WoZdFru62Btey30yp9DCtweBS2FwM zeBHIYhKjZ46A== 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 v10 05/54] media: mediatek: jpeg: Use vb2_get_buffer() instead of directly access to buffers array Date: Tue, 3 Oct 2023 10:06:14 +0200 Message-Id: <20231003080704.43911-6-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:08:28 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778720974298983352 X-GMAIL-MSGID: 1778720974298983352 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 Tue Oct 3 08:06: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: 147698 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1928276vqb; Tue, 3 Oct 2023 01:07:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFZTvCZ2CSGa5n7t9/bcr5HKeTMHZGo36zV0KxaNgDm7Z2s435BG+SnkC5y2bu5Yx8OYK2P X-Received: by 2002:a05:6a20:1044:b0:15d:ddeb:4a7e with SMTP id gt4-20020a056a20104400b0015dddeb4a7emr13337502pzc.49.1696320473531; Tue, 03 Oct 2023 01:07:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320473; cv=none; d=google.com; s=arc-20160816; b=NAfMMGMeF7T5UPHnTtszZpYvdgpLgBWGqmqrewihnHU2BOUuGEaGpuUgxHi1kxX9Sr evb/HTzze7M+FAt+OZbPU005R6R3Zu5lQOs7JBy42gRjmFkfXojlAyCLu35Wa4LmGMWv ixnorjgXmFy7GaGmkgNHli9vewA7Uc6wYb/KxQ5CULvmxKE2YlELFi2AqceDudx0+J0n qEuYnGLK/GSR/gHr5AoQcYlzAWOlDmVWDfMjlI2PwrW0JYImNB1DZ8KIyfdHyYpRwbz+ BbUN82LnAzu8azgLdTulV/uLaDuvUTPcJyvGtzTexMhRU3oQmNHHU7j+E8hQ12OlW8NS qP2w== 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=s+kMPwU0Ob0ztoTAttuAaSUVI1oC9UCyetrTZTEeb8w=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=jLlfmMWb/wVCJleK8KMHb50YKsTVWF6t/2k1PZUEi4deIByDmllCfVO5vGJoBC79Iy GkGJBYhbhj6eFg8iT/yH78ou7Ce2edsNuIqn+K9CB6VFXj5BoDx5wp1f7PmQHqKpepar 2hLgstbUTCDgA/c/HoN9R3TYDFSFm3GQYg1zJj7zLAbpeQ3A2wZTtocz467IzB53CYxD xIIeamlDZ8Nq8y2VvRkRCVfjA4JZwKjGeu1ovCP2gsZR8MKaOvuSsubE4YnSBh45SI17 An2w4yjDTJHg6SBhwooTyumYpEjHi7fMYUXmeJudyC8p6LWyLN/QS2L8Cvko97fBmRGt bD0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Hu9hnDwW; 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 cw23-20020a056a00451700b006906a716917si944028pfb.398.2023.10.03.01.07.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:07:53 -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=Hu9hnDwW; 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 B115F8227783; Tue, 3 Oct 2023 01:07:52 -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 S239407AbjJCIHo (ORCPT + 18 others); Tue, 3 Oct 2023 04:07:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239307AbjJCIHX (ORCPT ); Tue, 3 Oct 2023 04:07:23 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51345B4; Tue, 3 Oct 2023 01:07:20 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 EF994660731B; Tue, 3 Oct 2023 09:07:15 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320436; bh=MAfzqnBElYsriZOe56F+JFfMksB0FEVAHWT7iRLKeFk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hu9hnDwWa3LgG1MmRZ4kExxD3sCgCOT6w1kdLJtauCr6h5M/r8h2i9nIZxEMWq3Zh ixrqo5Y2Xyx2UbvflIeBBCU5WAjIDcstXx3oW/Imwn357J1hBvTAF+fh6SzifeF1FV JXwOUZfz8GxohIEUpi+e1Oc37hK+KB1Q36tE542mlUmmL1OlDdaw0jLVir0BZHcajN dVyM2PL8fFWqKbctO5VBkbPyfJewPStIQ8qEtOby7hj8FPc5W3e0uCbwd6rhLG1mOf rbu1/o71sNRRz+bwtURolirHpmIsJfP09cKd1TxqvBafEiDKAvQbe9rbdQ4DWCz71H Aj3tF7mPCTkHg== 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 v10 06/54] media: mediatek: vdec: Remove useless loop Date: Tue, 3 Oct 2023 10:06:15 +0200 Message-Id: <20231003080704.43911-7-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:07:52 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778720936400074007 X-GMAIL-MSGID: 1778720936400074007 Simplify code by removing useless loop by using video buffer index. Signed-off-by: Benjamin Gaignard --- .../mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 9 ++------- 1 file changed, 2 insertions(+), 7 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 e393e3e668f8..69d37b93bd35 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,13 +1695,8 @@ 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++) { - if (vb == vq->bufs[i]) { - instance->dpb[i].width = w; - instance->dpb[i].height = h; - break; - } - } + instance->dpb[vb->index].width = w; + instance->dpb[vb->index].height = h; /* * get buffer's width/height from instance From patchwork Tue Oct 3 08:06: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: 147706 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1928509vqb; Tue, 3 Oct 2023 01:08:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFbzT79+YE57GFfsAzky2fnpr80hlGUfLZvGBH2GRJl1O8fEzXJ51BUYT6DgjK2SkIfSq8A X-Received: by 2002:a17:90a:7bcf:b0:274:8951:b5ed with SMTP id d15-20020a17090a7bcf00b002748951b5edmr3109891pjl.20.1696320504336; Tue, 03 Oct 2023 01:08:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320504; cv=none; d=google.com; s=arc-20160816; b=YaEO7jqhQOpMfCHHKnwOOtt9eMXkowi8nPNI0klpukNN1qUbpithSyvGAjYyB3GwGB 9Vx3Sa2H0IOU6+SrUzT0yZh8tqpfIERCkj3kz4fVICBP4SJh7ekyCB4X90lUFMCdamnG yw2zpBFSaEWm5QNksAR0Axnq/5gIVomerBWp9zjJPyd45SXEAnqp8Dkx/Sc82gtdsfGA 4FQ0+jJeP+mHTb1fd06LCTvyZv69M/V/MtoV4CVtGvccnuvRMocEuHUtWWwW/MgHcVKB EDVeEmbTFjc0rCi+mrYhGD0vIYWW0pTjb318oiOCoFYVB2PlU59GcamLrLeTnEip7JBA zxaw== 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=oHNryKbCJeblfYmngcGtoYS+YQQ+1KvLxsjalykbByU=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=Fkg/W1xX2c7EdS2dWr6BsDNlEyo/eJ/tcWiEUAo7MEbgyInMN9wzOiNSrPZCrkeFKd tYzxs6H0KZQqJ1ulQhc6FBsg8qagjYF5hfzD+6JwXq9I2yjDa+p9gVzcr4Ge39ei1/f5 aNbVokV+wC7jydZ0DJb+xAQl6egbkGJTXFM3zMtBqzrGUEgMPTawHj6YOK1mxw5CNybE 7a0rP9eeWmtOgEjpQXRk2oSWoCgfINV7NfWZRsUMHF5/3LqMDhRbz9tvpfk0rDq6N95l 2ezIJMeTjncbajF5ChrTddBjikdI1talmXh2P5LVdD9tIqcp9UNzJv5L5OHTknq3hpX4 2JGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=BSEfBTA5; 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 gp19-20020a17090adf1300b00277751629e4si850999pjb.121.2023.10.03.01.08.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:08:24 -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=BSEfBTA5; 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 B25CC8227783; Tue, 3 Oct 2023 01:08:23 -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 S239675AbjJCIIT (ORCPT + 18 others); Tue, 3 Oct 2023 04:08:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239316AbjJCIHY (ORCPT ); Tue, 3 Oct 2023 04:07:24 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C99FBF; Tue, 3 Oct 2023 01:07:20 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 7C58E660731D; Tue, 3 Oct 2023 09:07:16 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320436; bh=dORnTzB2rXmsaHgnhN9KRI5xHQJEBU6mRdZelnGjotA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BSEfBTA5Hdnv9NBFBNyAyqI/purU07ob4LXwE+mG3TccYJznfRorGX1tFhGAHauhh 1ceA/+57ED7z/Tpm83Q6VvnzFnz/IDGRmKkWfYZhOAoi5pfUtPVUl/afKNe3xuEJO7 EDNcqDGJOqRmCFVEW2O0QH6XefoWgUiNcWmxxqWwtbevvt319kFacWuJiBTzYEC4xV HxhGLgEqPg/CLdi+wFInEmKJ0hBBkMgI1lnm/l1vf+4aR8G5iK2mwuQ9C7RG9o+ElS bRg4L061Wr88t0cmGLB6btO7jhhut0ePiKM+uG1vz9P4FQuVNtFC2FkqTD3cl7ea06 lMWQr3OVX3uqA== 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 v10 07/54] media: sti: hva: Use vb2_get_buffer() instead of directly access to buffers array Date: Tue, 3 Oct 2023 10:06:16 +0200 Message-Id: <20231003080704.43911-8-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:08:23 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778720969168228884 X-GMAIL-MSGID: 1778720969168228884 Use vb2_get_buffer() instead of directly access to vb2_buffer buffer array. 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. Remove index range test since it is done by vb2_get_buffer(). Signed-off-by: Benjamin Gaignard --- drivers/media/platform/st/sti/hva/hva-v4l2.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/st/sti/hva/hva-v4l2.c b/drivers/media/platform/st/sti/hva/hva-v4l2.c index 3a848ca32a0e..cfe83e9dc01b 100644 --- a/drivers/media/platform/st/sti/hva/hva-v4l2.c +++ b/drivers/media/platform/st/sti/hva/hva-v4l2.c @@ -569,14 +569,11 @@ 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); + 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; } - - vb2_buf = vb2_get_buffer(vq, buf->index); stream = to_hva_stream(to_vb2_v4l2_buffer(vb2_buf)); stream->bytesused = buf->bytesused; } From patchwork Tue Oct 3 08:06: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: 147708 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1928575vqb; Tue, 3 Oct 2023 01:08:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFBPeer6GYvT1ffY2wGq3+B26XEnEWDltm7VCTHu/lHzW5iQk4vbUkJqJud/gCKyG6RMY0F X-Received: by 2002:a05:6e02:c6c:b0:351:5b29:8a5a with SMTP id f12-20020a056e020c6c00b003515b298a5amr13382417ilj.27.1696320513370; Tue, 03 Oct 2023 01:08:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320513; cv=none; d=google.com; s=arc-20160816; b=HNhcOIlbMrhHvVBXP7iqnOIA2frxIM1UtgQZLsUEDUIgTjx9TI2pnPhnwdSHLhlXBM 86RDAuRi34TyoCHYmdCmEYuokNYs2xnltaCGugdY2Ho8lrSYv0eiNWKu384HtZrr9g9Y ZFdh7axFeJiGtA7BTwdoNyRbuCJ3sBMqwcAapbnRhHS40NHug92QhXjxV8eBweCXv6Kb m+kMRsnoPqYDR5IfT0SYXYveG5/8OX+EGTHG8FC8HsUaauTm3WN2P1K9G6oHcvvPsscA lZOjY27+kkfQl62osDveOZnsoD0fK5hAsR/O2tmQXw0jp/8asHq3JWF18SmSKXz1ynkw yS7Q== 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=tNJK4aFVmXaNptaKpUrYRgTY5MDOKMinQHIwe04l5Dz103sFQJGNAn/ogtx9S4OlUW uIeXUvGpRY8f2Jtg3GvOikzkLT2eZgYcCvZes6dOBAIl01+G2z9P32pvOqCyS0gXxWLN JmbnrufKilE8XaiN5StG3UbVKX30BJKO/RhNxhz9RsZgi4O5mTBl4OR0nLfbJC+/kQzE yesxYPnf/xiCXcUBlbzx7nSOyPXsvRC7FuBXwIp9R1Jin5ZLF6ifQPv3hDbwXZAKpbkX ADuyC1y/rianh0eFUKB7EO4CF5Mt+mJ2e+4j+2a9vsD/7HJBRldI/2ECHyM9ycZsUFMw wx3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=EbF87OCF; 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 s190-20020a6377c7000000b00578b9757214si858143pgc.163.2023.10.03.01.08.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:08: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=EbF87OCF; 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 69727823FAD7; Tue, 3 Oct 2023 01:08:32 -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 S239583AbjJCII1 (ORCPT + 18 others); Tue, 3 Oct 2023 04:08:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239296AbjJCIHX (ORCPT ); Tue, 3 Oct 2023 04:07:23 -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 5BC22B7; Tue, 3 Oct 2023 01:07:20 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 04B03660731F; Tue, 3 Oct 2023 09:07:17 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320437; bh=Osy0YWOEVUvzSOYoJm+JBXSigMNkmpw77qpRTwkivks=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EbF87OCFiLweOCAVwYBz906D2Uuqqjyo1DaU4a83x1EgCNBTYwy5gZz9qo/htsYON W57dG31ES6IEu4tSZHfFb2XrTxlW38GP3G/vPqnFbMkXZPpOthCVmo4UcsY+HqevuC dm4P7YGzMmwqEw8gqDlZ40AY8yKwG6QTTPTRNsVv2QcFmRoT2KrRTQWQNcNXkp2D0V a95zAmahJKLdZppmq/5VCdP+DbCun9fGwTOaMkoGgQj/1MJHe60hkIUHSHsnZCHMBz MgwUPaqqq5RY4WfMKuf6cT4xxrEF3bniL7aoLIFftCLx5OVDfk909v3YieueYFM85I BkCd9Mdtfi+Sw== 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 v10 08/54] media: visl: Use vb2_get_buffer() instead of directly access to buffers array Date: Tue, 3 Oct 2023 10:06:17 +0200 Message-Id: <20231003080704.43911-9-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:08:32 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778720978673930587 X-GMAIL-MSGID: 1778720978673930587 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 Tue Oct 3 08:06: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: 147700 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1928329vqb; Tue, 3 Oct 2023 01:08:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFpgfoGhGg1ysuN+NC9XEjnTjIxOmfVomC4K25Me+EN357uw5A1XhJ7FeUQHmqHa0C2Otop X-Received: by 2002:a05:6871:547:b0:1d0:d78b:982e with SMTP id t7-20020a056871054700b001d0d78b982emr15009835oal.35.1696320480700; Tue, 03 Oct 2023 01:08:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320480; cv=none; d=google.com; s=arc-20160816; b=CaJ0CqFlEdwe+rAgg6Qra5OG7Su1Lhr+aJHd0AalXuAJTBX+rkoYRdykc9uYxA/NhZ aK2kbwWX8SAfj15RPPiV+oO+wBMAqr0BBEtJvnuNBgXiU6JgL+vrnVOVsCIfl+HmP1rU e1SXOUrTS7xJPk8EAy8yQMIeS7zjRjKvr0ljl69o9HOVS+ezuNWf6b4gbLy+HSshx7fY I9QiiY9lpPGYn2Kb1JG/PcSg4xKy38R52MiEzxp17px6Wyw+sPPz1bHYB0KJYc2R5hLA bNVa5q5bNEVF1qWG53mLZgKgEaG+Ipbr9pCEjgC+4zm0o2+gzTGWW8FQQKrq4vsjT1/k sokg== 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=41wyfH+6JJ8bdIPBZvzyH+ExM5FAEGEfOXpR+dp8PPk=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=hG5ncexwj+rM/KDKn5YPFl374wEmAHkZDQeTwa7A4Sl1zb0h4FX7pZ42RDwxBKzK1s CjotRkYDswUyPdfkKHYvks1lTDQAV6Q3cuyr0Z590aFD0mwWrTqzwmGVr2NAImUjmVov BxLlsRK0lc9FlVVkvniT8JiE9OBYKlZIlFy9nwcptHpIB+Hvy7spZl9TPqnHJMDjLfZ9 A9mVEcM3pftdrrD74O+D/PcqIJjI2NBF5dO/acuaKkqme/rSxuUI8C/aFx2goN4hznSv fcpaO2qsqMOSY8bFmKXGECLpJCstwcpHczLVfGulR/VkvVL0sQuxZO/DdDTzcbFJYdjz YCcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=bfMBxNmQ; 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 u20-20020a634714000000b00573f9d916fbsi925170pga.784.2023.10.03.01.08.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:08: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=bfMBxNmQ; 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 BF1D3822D57F; Tue, 3 Oct 2023 01:07: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 S239436AbjJCIHy (ORCPT + 18 others); Tue, 3 Oct 2023 04:07:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239313AbjJCIHY (ORCPT ); Tue, 3 Oct 2023 04:07:24 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C033BB; Tue, 3 Oct 2023 01:07:20 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 7DD226607315; Tue, 3 Oct 2023 09:07:17 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320437; bh=lxr0Gn1eT8GmzPfVYaERIxRZ/4SLOSpn22Xqwjv89JA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bfMBxNmQOSyZLmJsd2pJhfT0OT5tEOcOGdNYTs+KvVlTm4a1ominUw8ZvAhRkpcEX R7YxbXFXcyRRBlhZ0eCPID5GkmL9bjPj1KeUKN4F90oohghpnNP76FUtFyPXjkaVGe DtciHu+AtGSOcfoUfjTlJIpObLwhZ7HHMFpGUm0qPJFM1CKBMA3yWAokiyGApAKOeY jIglKQ7snsbRMl4STQdAUDkol/nfE14uJBePET84O4B0AO0/jLT0lQE581vIkcoimP AH6+vUfgf3+j33NNDyOV8uWcBg4yzXVxmxjn0MKFTCz83zED1VZRQZLwPvy43xXqip UP6lPf7KX112w== 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 v10 09/54] media: atomisp: Use vb2_get_buffer() instead of directly access to buffers array Date: Tue, 3 Oct 2023 10:06:18 +0200 Message-Id: <20231003080704.43911-10-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:07:59 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778720944375669306 X-GMAIL-MSGID: 1778720944375669306 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. No need to check the result of vb2_get_buffer, vb2_ioctl_dqbuf() already checked that it is valid. 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 a8e4779d007f..a8a964b2f1a8 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -1059,7 +1059,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 Tue Oct 3 08:06: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: 147699 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1928287vqb; Tue, 3 Oct 2023 01:07:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG2NaccCZHlkIHRx1kb7UUkCWXQP6Oc1HfwUdzIL1IZuvusIkj2oCQirD5AK/kVwVRviDvW X-Received: by 2002:a17:90a:ca90:b0:26d:355a:47e3 with SMTP id y16-20020a17090aca9000b0026d355a47e3mr11230328pjt.38.1696320475160; Tue, 03 Oct 2023 01:07:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320475; cv=none; d=google.com; s=arc-20160816; b=CCogO+Ka71bI3X4FH6ydXjP1Ym5UupLV8MKUshLRzXLiC5Dhcqs6K7Z815rGpMC/PY 4F300VIsw3WdaDeIoHwG34yaI0kWoeYR33id6IFQ61DvPWI0NugND4Kf0pBnVA6X55OR CbR0EZEshgKX6w9LkY8S0PnVY/wWtvvNBNXtkQznsT+ct002ARf9lK/Uot34UIEOb/QC sbg7o3tT45BCFEZfd/MbkLn+gL5EwdYlIGltEXP8hcd7YoRBndE7j7LMCP+2oRiyiytP /20ht9+hNdiL5Ns6OTZgGt1ywIH5gRw5EaA1vWNsARevCnh0m51c3uiJiqI4dEJ9nT4o s67w== 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=gGQ480U+9z0FDZNiILQtrh4N7g7JIse33SCZm38L1wmSqOqijf3B3z4mZG1zrbjPer 0rKD3lw2eK39xYZHj/q6H+EorvJx/Pz462Q+ZKbtOAyrkyHoqhgWl89hicklPgM256nh FE88CusdoiQ7BI7U0zdGeGsVtmFwwwKsjepGVVC6vPjXlKCkcCA1VrD19HNIj/LuCsjL ETSNzIlZeBF+EfIrjdvsbOPN0I5XrSIC02ME9X6Ldwoq30oQykEBHB55bBWcWQ3oZyPB zlQ7i4s8KIAVyGTCXSsxkXp1vhNx10FlNIzHGSwUot3k2ZvSUk9/vGxW9brPIXNKAP0E ZamA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=hmoMadL0; 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 p24-20020a17090ad31800b0027748734bb9si9334172pju.148.2023.10.03.01.07.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:07:55 -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=hmoMadL0; 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 6204282265F2; Tue, 3 Oct 2023 01:07:54 -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 S239476AbjJCIHt (ORCPT + 18 others); Tue, 3 Oct 2023 04:07:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239314AbjJCIHY (ORCPT ); Tue, 3 Oct 2023 04:07:24 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BBBCAD; Tue, 3 Oct 2023 01:07:20 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 0815F6607327; Tue, 3 Oct 2023 09:07:18 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320438; bh=EMKVWITArl2PHuWHDFd/NcTii9pr6T7GjKNa1Tuop1w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hmoMadL0VYQ4SO1f0mqwTSSJuVhOVa2F5V8ainkhDJ3Gc15tRKgEgwBrP4dNbh2Oe OYtpscwSB22G53d8eFo6E0/gChSHp+pidlJ1RtOqTfWPL7ndL5jAYAina3hdZQP4nF aI9+96EtZ3QpaPVfoRhYzYUlPlK+3CGxXLCUumgXMd51oVd9pNYCBXNRgtm3xv+8QN NZTEMBiholN7iWq1tzLqAurHwgADyErv2n4FGGOUWhJ7nMMS7+bDhKarpKFNyKnH7F UI6Ik7wX17W9PRbD8acaTOqUkjqQWqpA+ji0IT13tXUy/gosNDqNpuV9W65Sh+gjAU jArFZr9pvW8Ig== 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 v10 10/54] media: dvb-core: Use vb2_get_buffer() instead of directly access to buffers array Date: Tue, 3 Oct 2023 10:06:19 +0200 Message-Id: <20231003080704.43911-11-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:07:54 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778720938213609705 X-GMAIL-MSGID: 1778720938213609705 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 Tue Oct 3 08:06: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: 147704 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1928461vqb; Tue, 3 Oct 2023 01:08:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHj9F6PbqzZeLCIcTl6K3ldLoMcDMkPv6l8V4n91TkuvTEO97lA07Ui6cktt/v6jtzWnsw5 X-Received: by 2002:a17:902:f2d1:b0:1c5:ecfc:2650 with SMTP id h17-20020a170902f2d100b001c5ecfc2650mr2473007plc.14.1696320497188; Tue, 03 Oct 2023 01:08:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320497; cv=none; d=google.com; s=arc-20160816; b=e/06dBF+BFwfJEgiz0qWAVsGMjyXZRqml8zx08+MMeGQbjbV0Y6nl4I6ZKT/K1hv8k zg5R+g5sS8CIK3GI5y6RJcxf8gw/nnPDQz8lpam3R9XRhQ8EMvFV4cFc8Isn7Ds+Gre5 R5PqIetSyqrbZKL697JVoPfmunBqPg49rDWsGR8yY2En5lCec0CtBK9OhmYLLStRrZ51 8JIze/y9bUJ/mzijDAPN2S+SnxVd1cI0NNiphcccobK3sZYRx3YC4AKy9wlnR1zrpySB 1nH1mKG8So3JGBYZkR133x5gbsUB9XWVF6yhwJovik5lRtB5LrVeDxe292DNWPFdXnUl 8U4g== 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=7AeyM9XvjS0cefua2+O2ShRxravzeuaq0DMDL84zupQ=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=F7X84rN8yUeftLnalQWhcPn90D6mwVWR/SjLvGSxrx6E/Gd/7BXjIxyfHnkgMplO3x fFOlRYqrUSS8J0tuJQre8oJvdSKB4sOud3VIHYguIPD8i+fieE1s8acaug/G3GUEWyu4 N40CvqiUSsnPbIloWU0oTkWC3f6BJYGFEBIOpIqPjsKQtv5cOqDpRvzY3YHYgY57zNIp 9kmtB50KZLQcvKC4xTdq3kGES7eZMk/WKkcH0IQP91/80ronE0lHxvnrkdWn6qPz4FAT vzhUfPLTMRg/UyM5EDw0WtyWzj1Ft7aiGhBSjr/z+gF7FnwxvRwdshuo418dzVbTmz5z DXwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=g+K4qBZM; 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 ik7-20020a170902ab0700b001c631664c4bsi893217plb.200.2023.10.03.01.08.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:08:17 -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=g+K4qBZM; 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 4A83981444F0; Tue, 3 Oct 2023 01:08:16 -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 S239529AbjJCIIJ (ORCPT + 18 others); Tue, 3 Oct 2023 04:08:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239318AbjJCIHZ (ORCPT ); Tue, 3 Oct 2023 04:07:25 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68631C4; Tue, 3 Oct 2023 01:07:20 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 8860D6607328; Tue, 3 Oct 2023 09:07:18 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320438; bh=ae8sJ6Duy+q0MBFf+Ra1B/rOkrMVbY1h7jDoicoGFN0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g+K4qBZMLSt6ETXeAfobs5VB4ftfBqAB+AmlRGhjKZ2xSJh7E/GRxwAllEiwbB3K4 X7e59QWnu51CbGCOD4t+2Lj+ghCVDNZVCBv213dM9yRaOm1PGrlKx/1fESumHnrn/J CI7/xipkNbJZ1xLGSBew/2pp309BSlbf1OQNYpZo/s5K2dULrbtU8IpKYJ6P2dG1AM vhtkAbMJv51YTFyU74vwJUEKluOrKTACUX6xa0cJd/cVzDGqqM8LhBi8iwmvjjO4CW aZhOcQvkbZq+rUOlQDQLn/Dfc74GrqEuSpsvI+k6SP1CrIaYYVSq0AO8/3RKANkbC1 fb3tC9YD820dg== 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 v10 11/54] media: videobuf2: Access vb2_queue bufs array through helper functions Date: Tue, 3 Oct 2023 10:06:20 +0200 Message-Id: <20231003080704.43911-12-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:08:16 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778720961700107864 X-GMAIL-MSGID: 1778720961700107864 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 | 151 +++++++++++++----- .../media/common/videobuf2/videobuf2-v4l2.c | 51 ++++-- 2 files changed, 146 insertions(+), 56 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index f3ff26b66bd4..d23ee4b86cc0 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -405,6 +405,31 @@ 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 void vb2_queue_add_buffer(struct vb2_queue *q, struct vb2_buffer *vb, unsigned int index) +{ + WARN_ON(index >= VB2_MAX_FRAME || q->bufs[index]); + + q->bufs[index] = vb; + vb->index = index; + vb->vb2_queue = q; +} + +/** + * vb2_queue_remove_buffer() - remove a buffer from a queue + * @vb: pointer to &struct vb2_buffer to be removed from the queue. + */ +static void vb2_queue_remove_buffer(struct vb2_buffer *vb) +{ + vb->vb2_queue->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 @@ -433,9 +458,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,9 +466,9 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory, vb->planes[plane].length = plane_sizes[plane]; vb->planes[plane].min_length = plane_sizes[plane]; } - call_void_bufop(q, init_buffer, vb); - q->bufs[vb->index] = vb; + vb2_queue_add_buffer(q, vb, q->num_buffers + buffer); + call_void_bufop(q, init_buffer, vb); /* Allocate video buffer memory for the MMAP type */ if (memory == VB2_MEMORY_MMAP) { @@ -453,7 +476,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(vb); kfree(vb); break; } @@ -468,7 +491,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(vb); kfree(vb); break; } @@ -491,7 +514,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; @@ -519,7 +542,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); @@ -560,15 +583,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", @@ -608,8 +636,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(vb); + kfree(vb); } q->num_buffers -= buffers; @@ -645,7 +678,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; @@ -1630,7 +1668,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); } @@ -2031,12 +2073,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) { - 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); + 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 buffer %u in active state\n", + vb->index); + vb2_buffer_done(vb, VB2_BUF_STATE_ERROR); } + } /* Must be zero now */ WARN_ON(atomic_read(&q->owned_by_drv_count)); } @@ -2070,9 +2118,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() @@ -2221,10 +2274,12 @@ 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; - if (buffer >= q->num_buffers || *plane >= q->bufs[buffer]->num_planes) + *vb = vb2_get_buffer(q, buffer); + if (!*vb) + return -EINVAL; + if (*plane >= (*vb)->num_planes) return -EINVAL; - *vb = q->bufs[buffer]; return 0; } @@ -2612,6 +2667,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; @@ -2662,11 +2718,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; } @@ -2675,12 +2738,15 @@ 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); + WARN_ON_ONCE(!vb); + + 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); } /* @@ -2808,15 +2874,17 @@ 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 can never be NULL when using fileio. */ + b = vb2_get_buffer(q, index); /* * 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) { @@ -2859,7 +2927,8 @@ 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]; + /* b can never be NULL when using fileio. */ + struct vb2_buffer *b = vb2_get_buffer(q, index); /* * Check if this is the last buffer to read. @@ -2886,7 +2955,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 @@ -2957,7 +3026,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); @@ -2966,7 +3037,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..3395e702ad1f 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -383,9 +383,9 @@ 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 */ - dprintk(q, 1, "%s: buffer is NULL\n", opname); + vb = vb2_get_buffer(q, b->index); + if (!vb) { + dprintk(q, 1, "%s: buffer %u is NULL\n", opname, b->index); 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 %u\n", b->index); 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 %u\n", b->index); 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 %u\n", b->index); + 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 %u\n", eb->index); + return -EINVAL; + } return vb2_core_expbuf(q, &eb->fd, eb->type, vb, eb->plane, eb->flags); From patchwork Tue Oct 3 08:06: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: 147702 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1928352vqb; Tue, 3 Oct 2023 01:08:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHLAHXe983YBmmHEyHWkBKcpkU39Qe5W2u0yVhJt3hrrLeYu8Srz0GLmURcdmzTKoOvMYED X-Received: by 2002:a17:902:ea8d:b0:1c5:64aa:b97a with SMTP id x13-20020a170902ea8d00b001c564aab97amr12608080plb.38.1696320484332; Tue, 03 Oct 2023 01:08:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320484; cv=none; d=google.com; s=arc-20160816; b=RSRXDc0/1yjf+FB0derbcW3OHnQ/bXRVcrp03VhqxggmuHIDEsCSfsfBumjHLeQi4T 3E4YAlvfb+F29v/UmWqymqWuZnb61WyCFs+VlaiYQnmBj+oiI4gTYB+a6+iiCIbkQCBb ZjNcS4rZfo4+lQ0rnYeLRnTNa9VeusKkcibcn9jfF0K+jlAuYcrclA5TfLACCxWrSb1Q gRVrWP5eQMZgbiQVpmgZo6wYZ8hGelofSUljFxlVjkVeD0/u7E67ow4nareQPy5heQ1K h30wdgoAkhKVzaQle0tVHxVkR/NrNDikNuG4Ig/KPP0ui/HJrlhTJWm46DOYcCao8KS/ SfuQ== 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=I5+jpd1ZQBYePpWj29iMlxWouqcdnlG6oJxsBwaO9Hc=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=rBzjELkNNMeBRdw3Q29MYjYsUT2aCx0M36CJiF8cSIMJwc8LFWKdzSY35IbcwkWAUO Z9o/3LxWbp42uR1APxSeihylnRPq1F+btRiUOjw8OYS7CvMCD9aqnVo2SEcCgEdCKnjn V/6zmMfo8zNTUTrgoixYZOzRec0RyTayUUoFMvS7P9YoJBNeZm+3YKTjp0/Za1CvZzjf dJAQdf6ZEjELSiI9akmcxvvuV1fE/NddOBb6aMrb7d+jscB1KGPWHBis9b2gUGDcl0J0 CQycFaWy/RQy1NdvaIWQrCrRibByPZ92WnU7CTn9B68mEv0S8U/Cat+Ql9VtDh8WTJ86 f3zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=SlolRjrG; 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 h11-20020a170902680b00b001c77674ea97si846208plk.423.2023.10.03.01.08.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:08:04 -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=SlolRjrG; 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 680FF81444F9; Tue, 3 Oct 2023 01:08:03 -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 S239586AbjJCIH6 (ORCPT + 18 others); Tue, 3 Oct 2023 04:07:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239325AbjJCIHY (ORCPT ); Tue, 3 Oct 2023 04:07:24 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8C73B0; Tue, 3 Oct 2023 01:07:20 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 16BF46607332; Tue, 3 Oct 2023 09:07:19 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320439; bh=G8knIPo83zGnCq6daz/QCUSlTh5ZQNn2reYpJKWrvh0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SlolRjrGL92H321lhwSsF0zGAgJXlLTvOgWMVQUuRz6aKG59sDWgrGizgJilvq9gp ZlSc6JhP7cy6JX/mSBA2JzYKABHJI164sH5IlDwtcxrN1IzNQCCF1uTzQn5Aa0riXb G7bMgmAKDj2riq0SDkm3jJ5U3FyOF03ffP5jbzCsQyvsKU014nhlwY8Wkp5yWyCNQB nvfv1cUeG32tXiXG8yInCKF3ly8KnKbpWyNZsjxI9RvkysaLjzJBmfI7osDZ+cz/it LLwBzbjhK8lpJKBMgz+s5OKyGEof/xogp6XLudQCP/EPLQRL4TBK0WoeFCZUzz4IJc BrbToCkZUB/FA== 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 v10 12/54] media: videobuf2: Be more flexible on the number of queue stored buffers Date: Tue, 3 Oct 2023 10:06:21 +0200 Message-Id: <20231003080704.43911-13-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:08:03 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778720948104305646 X-GMAIL-MSGID: 1778720948104305646 Add 'max_num_buffers' field in vb2_queue struct to let drivers decide how many buffers could be stored in a queue. This require '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 | 41 +++++++++++++++---- .../media/common/videobuf2/videobuf2-v4l2.c | 4 +- include/media/videobuf2-core.h | 4 +- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index d23ee4b86cc0..c0104f824577 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -413,7 +413,7 @@ static void init_buffer_cache_hints(struct vb2_queue *q, struct vb2_buffer *vb) */ static void vb2_queue_add_buffer(struct vb2_queue *q, struct vb2_buffer *vb, unsigned int index) { - WARN_ON(index >= VB2_MAX_FRAME || q->bufs[index]); + WARN_ON(index >= q->max_num_buffers || q->bufs[index]); q->bufs[index] = vb; vb->index = index; @@ -445,9 +445,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 the number of already queue + num_buffers is below q->max_num_buffers */ num_buffers = min_t(unsigned int, num_buffers, - VB2_MAX_FRAME - q->num_buffers); + q->max_num_buffers - q->num_buffers); for (buffer = 0; buffer < num_buffers; ++buffer) { /* Allocate vb2 buffer structures */ @@ -806,7 +806,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"); @@ -850,17 +850,22 @@ 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); 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_num_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_num_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); /* @@ -966,9 +971,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_num_buffers) { dprintk(q, 1, "maximum number of buffers already allocated\n"); return -ENOBUFS; } @@ -985,7 +990,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_num_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 { @@ -997,7 +1008,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_num_buffers - q->num_buffers); if (requested_planes && requested_sizes) { num_planes = requested_planes; @@ -2456,6 +2467,12 @@ int vb2_core_queue_init(struct vb2_queue *q) /* * Sanity check */ + if (!q->max_num_buffers) + q->max_num_buffers = VB2_MAX_FRAME; + + /* The maximum is limited by offset cookie encoding pattern */ + q->max_num_buffers = min_t(unsigned int, q->max_num_buffers, MAX_BUFFER_INDEX); + if (WARN_ON(!q) || WARN_ON(!q->ops) || WARN_ON(!q->mem_ops) || @@ -2465,6 +2482,10 @@ int vb2_core_queue_init(struct vb2_queue *q) WARN_ON(!q->ops->buf_queue)) return -EINVAL; + if (WARN_ON(q->max_num_buffers > MAX_BUFFER_INDEX) || + WARN_ON(q->min_buffers_needed > q->max_num_buffers)) + return -EINVAL; + if (WARN_ON(q->requires_requests && !q->supports_requests)) return -EINVAL; @@ -2511,6 +2532,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 3395e702ad1f..278ea1107b01 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..1d6d68e8a711 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_num_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_num_buffers; struct list_head queued_list; unsigned int queued_count; From patchwork Tue Oct 3 08:06: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: 147703 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1928442vqb; Tue, 3 Oct 2023 01:08:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHnR8498qSUd/8eMkRqywYipWcGY1ZH0uFyT82oX4HXZHdsBEUCE4yPtPv724Q8piacA7M5 X-Received: by 2002:a17:902:c18d:b0:1c5:ce3c:c391 with SMTP id d13-20020a170902c18d00b001c5ce3cc391mr11945296pld.12.1696320493513; Tue, 03 Oct 2023 01:08:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320493; cv=none; d=google.com; s=arc-20160816; b=qF/kyvTx/ZYkf3FqJvzsI6OAsgKiLSMfH0tSsEmqXiLeSMBASSckyMNdk8gzc105Uw BtkdMUfB3znMuRlyU7yugiwecZuSXhWKanqksI5JycmdYrgwRXbVoOogPYWPHTCostR+ uYLLHR5GD9j09nh/wWImezCOLZZtAX6590vidEcFXUo1O8Xlx4RPji5kJIlaA7M9XFne DjRIZdIPxAoKmcyS6wnZRcFLQxYX+VA5A6nX1kxoFlsfUyhfyIJmSX4Ta4ITmDmDHY4i RULHUQzJhEwte+FwOHfM3KOUZXioocSRLBvCQiCJJk9E9AIONhrGWIdvZjiH1qatGygj fu0w== 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=AxXkhquK9X99Bg0HymQftcu40tKfN4das0q6LBx9La8=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=Ghw8pwNj1f7q9bZp9mRxaL4yNmc9XKCizwaFd0mIEC8YDGU9QkGkFbggLVQm6p2CPE hwpIdLLvfXJ72XmG/igmVgWoWmRQeXTAkJNiMdH6abC5LZx2mxKfzbPbUSPo0h3qk/uX 8ilKoni0OVy526GAIEZDCU/fK4SoFkiACP66cGPUEOFwhRaWAxeUGybodMB2x2VGxTXP XeZi7+sukV8y4GQJXESFU/TllkD20o6sXRz5CqnLAz9F+7zhga3TQGyajp7HL9V5ny3c Fj6PwCkLzKl6tNLKXJnvbJZt1ES2GyBoNvzKEYIKq3sy/uGMOB6gmuaOlqEZjNaf9n/X c4Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=YGUrJoMj; 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 cp5-20020a170902e78500b001c5bab14164si875916plb.60.2023.10.03.01.08.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:08:13 -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=YGUrJoMj; 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 E291D822DA38; Tue, 3 Oct 2023 01:08:12 -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 S239422AbjJCIIE (ORCPT + 18 others); Tue, 3 Oct 2023 04:08:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239227AbjJCIHY (ORCPT ); Tue, 3 Oct 2023 04:07:24 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 349BEC9; Tue, 3 Oct 2023 01:07:21 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 98CB56607334; Tue, 3 Oct 2023 09:07:19 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320440; bh=/bjHUQb3wkrPemzjvmSsPOO77sbgrz1yCjwGO4gVBg8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YGUrJoMjRzUgTMwPXfWWl2BW1MDRgMDv/eYb5C7D+6ag68WdTyeAQL5c94unb2wzl lQrwmu8GxIVPumXmUwobF6HtdbIkqzNasDDoEx4Eh+oEd6cwALx8y+xRnOOLQRpFW/ 99xTCkBgxlPQ8BYIB3/GJ/MpLD3z/dKdDdpaaaEmkeEypfyAxJ/EyBKyrQQJY/inL+ 5rTjrZYN4lHkXyYHNvDZ09xAB+x4uItQDe09MA7WUk5jBEQygioPJauUpHC4HPsQU7 OZ+zupjNT6yCdH/hd7fWGVo6Qq1zOgFqW6j0NvpqZoL4lltd0NtUnlrTl8g9e9cDK+ QSb78M755IwYg== 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 v10 13/54] media: Report the maximum possible number of buffers for the queue Date: Tue, 3 Oct 2023 10:06:22 +0200 Message-Id: <20231003080704.43911-14-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:08:12 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778720957577302513 X-GMAIL-MSGID: 1778720957577302513 Use one of the struct v4l2_create_buffers reserved bytes to report the maximum possible number of buffers for the queue. V4l2 framework set V4L2_BUF_CAP_SUPPORTS_SET_MAX_BUFS flags in queue capabilities so userland can know when the field is valid. Signed-off-by: Benjamin Gaignard --- .../userspace-api/media/v4l/vidioc-create-bufs.rst | 8 ++++++-- Documentation/userspace-api/media/v4l/vidioc-reqbufs.rst | 1 + drivers/media/common/videobuf2/videobuf2-v4l2.c | 4 ++++ drivers/media/v4l2-core/v4l2-ioctl.c | 4 ++-- include/uapi/linux/videodev2.h | 7 ++++++- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Documentation/userspace-api/media/v4l/vidioc-create-bufs.rst b/Documentation/userspace-api/media/v4l/vidioc-create-bufs.rst index a048a9f6b7b6..1a46549e7462 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-create-bufs.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-create-bufs.rst @@ -116,9 +116,13 @@ than the number requested. - ``flags`` - Specifies additional buffer management attributes. See :ref:`memory-flags`. - * - __u32 - - ``reserved``\ [6] + - ``max_buffers`` + - If V4L2_BUF_CAP_SUPPORTS_SET_MAX_BUFS capability flag is set + this field indicate the maximum possible number of buffers + for this queue. + * - __u32 + - ``reserved``\ [5] - A place holder for future extensions. Drivers and applications must set the array to zero. diff --git a/Documentation/userspace-api/media/v4l/vidioc-reqbufs.rst b/Documentation/userspace-api/media/v4l/vidioc-reqbufs.rst index 099fa6695167..0395187e1a5a 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-reqbufs.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-reqbufs.rst @@ -120,6 +120,7 @@ aborting or finishing any DMA in progress, an implicit .. _V4L2-BUF-CAP-SUPPORTS-ORPHANED-BUFS: .. _V4L2-BUF-CAP-SUPPORTS-M2M-HOLD-CAPTURE-BUF: .. _V4L2-BUF-CAP-SUPPORTS-MMAP-CACHE-HINTS: +.. _V4L2-BUF-CAP-SUPPORTS-SET-MAX-BUFS: .. raw:: latex diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index 278ea1107b01..42da0adc052a 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -686,6 +686,7 @@ EXPORT_SYMBOL(vb2_querybuf); static void fill_buf_caps(struct vb2_queue *q, u32 *caps) { *caps = V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS; + *caps |= V4L2_BUF_CAP_SUPPORTS_SET_MAX_BUFS; if (q->io_modes & VB2_MMAP) *caps |= V4L2_BUF_CAP_SUPPORTS_MMAP; if (q->io_modes & VB2_USERPTR) @@ -767,7 +768,10 @@ 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->max_buffers = q->max_num_buffers; create->index = q->num_buffers; + if (create->count == 0) return ret != -EBUSY ? ret : 0; diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 9b1de54ce379..da355355a869 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -483,9 +483,9 @@ static void v4l_print_create_buffers(const void *arg, bool write_only) { const struct v4l2_create_buffers *p = arg; - pr_cont("index=%d, count=%d, memory=%s, capabilities=0x%08x, ", + pr_cont("index=%d, count=%d, memory=%s, capabilities=0x%08x, max buffers=%u", p->index, p->count, prt_names(p->memory, v4l2_memory_names), - p->capabilities); + p->capabilities, p->max_buffers); v4l_print_format(&p->format, write_only); } diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index c3d4e490ce7c..ef1402537395 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -1035,6 +1035,7 @@ struct v4l2_requestbuffers { #define V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS (1 << 4) #define V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF (1 << 5) #define V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS (1 << 6) +#define V4L2_BUF_CAP_SUPPORTS_SET_MAX_BUFS (1 << 7) /** * struct v4l2_plane - plane info for multi-planar buffers @@ -2605,6 +2606,9 @@ struct v4l2_dbg_chip_info { * @flags: additional buffer management attributes (ignored unless the * queue has V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS capability * and configured for MMAP streaming I/O). + * @max_buffers: if V4L2_BUF_CAP_SUPPORTS_SET_MAX_BUFS capability flag is set + * this field indicate the maximum possible number of buffers + * for this queue. * @reserved: future extensions */ struct v4l2_create_buffers { @@ -2614,7 +2618,8 @@ struct v4l2_create_buffers { struct v4l2_format format; __u32 capabilities; __u32 flags; - __u32 reserved[6]; + __u32 max_buffers; + __u32 reserved[5]; }; /* From patchwork Tue Oct 3 08:06: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: 147705 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1928472vqb; Tue, 3 Oct 2023 01:08:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFdt7CrR0hVGA0dhFhFBqhsoVMawdBcoHE2lLFTTu4fAexBMqIsitDX8xDQgstdMbOThW8U X-Received: by 2002:a05:6358:904c:b0:143:21e8:11f2 with SMTP id f12-20020a056358904c00b0014321e811f2mr15708030rwf.11.1696320499818; Tue, 03 Oct 2023 01:08:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320499; cv=none; d=google.com; s=arc-20160816; b=TU8w0rYeL56GU8xFoTOUnQgIhA65oF1T54y9XYXTNhuykm0qYOPztzVTX6Sm5Z+J+Q keoxYduXJomj1QgJye0XUOM4ZsxiSUjIiie0n63fO9hozlfmoBRK/i1WrZQybUw2pHJx JtjHgdXwSO9fcB+MjkmpnC/h4fz2jppwJJtjwUOuCtUP3/UAguqMPb8cCqXh5EuPdLRP SULIpXSDQXcBPhe057Bl1MMJ5kipCxCZlB3DzOS4GNuCt0dixbUm4uqzxNIBKPm0wigY BAh/sy4xPcFpuv2cym+RLZ/47lRfTGtJxpUvbEdKjsdwSK7+SfkG+rZEo94xr1p3XtnO suFQ== 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=bmkWQDiNlgdYuDb+J1sav4B84VrqfEYCbpv/jslFdrc=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=KbGB1PYPjNaHfCkW0DVMui89aC4WAeD+3CIUHbebKSu10rOo23OznSste52C4qxHCy RFY6iS3qkR7bAVirMOHI/up9bEoZN0oBYCaD9pcOfz/k0y2BiynF5A/tddOWv+X2+XMs iDvSHs3f/Fqp9WL/gxF0EXwcdH2fEQMz8H6F6bsXDHqphTLysdjkF9EUTu6QTwboZ8Zu Xx04biwhhxhUyFCST2yulEEa+25CJznu5j7hK5naD/QsEgRRI69gCpKEZiqMbq3I03st fJB6xFi4DfFKO3FxLi61TkSQeAHPd2HM9gutvy65+oR/VMltrTcy4QK4k8wzozivR2hx 6d0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=CtLRpn1N; 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 j184-20020a638bc1000000b005775e2a7951si910158pge.345.2023.10.03.01.08.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:08:19 -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=CtLRpn1N; 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 EE95081444E1; Tue, 3 Oct 2023 01:08: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 S239501AbjJCIIO (ORCPT + 18 others); Tue, 3 Oct 2023 04:08:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239335AbjJCIHZ (ORCPT ); Tue, 3 Oct 2023 04:07:25 -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 AD053D7; Tue, 3 Oct 2023 01:07:21 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 24038660733F; Tue, 3 Oct 2023 09:07:20 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320440; bh=MaJc8KF/Sr+P2A1rELzeazrdtI+Dtx39Ekc9mMARKkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CtLRpn1N2WQGcS+FYDvKO+ZColUenPBEF/XKlYO4s+7vr7/MHs03eUvGXOC0VTI+o WV/xfmez/HNWZbORXaV+0ipr7mjWFXqJSM7Z9KyGkE9nAAwCpRhKAWv0HgRYOejGcU 3VmvLad2+H1DLI2B07W+rl8YBJUuIvTQ3N/4kTlCFNSgzya1rmHsAMVYFv0kWPmRim B2IMAydKbsHL/MeIOGPY8DEIKU4iJ1C7mCtvMTHGTLvjGFdakeEFaOsJd2DAs/1BBu +GavRdNxgV7QVbeG0nkW86ZJUcaJTvLQcRhKAFOpiQEtha6zpCLHM3nf2hUZa9NvZg g42XEkD8MNF1Q== 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 v10 14/54] media: test-drivers: vivid: Increase max supported buffers for capture queues Date: Tue, 3 Oct 2023 10:06:23 +0200 Message-Id: <20231003080704.43911-15-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:08:19 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778720964310212428 X-GMAIL-MSGID: 1778720964310212428 Change the maximum number of buffers of some capture queues in order to test max_num_buffers field. Allow to allocate up to: - 64 buffers for video capture queue. - 1024 buffers for sdr capture queue. - 32768 buffers for vbi capture queue. Signed-off-by: Benjamin Gaignard --- drivers/media/test-drivers/vivid/vivid-core.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/media/test-drivers/vivid/vivid-core.c b/drivers/media/test-drivers/vivid/vivid-core.c index 394c9f81ea72..b5656330578d 100644 --- a/drivers/media/test-drivers/vivid/vivid-core.c +++ b/drivers/media/test-drivers/vivid/vivid-core.c @@ -876,6 +876,13 @@ static int vivid_create_queue(struct vivid_dev *dev, q->type = buf_type; q->io_modes = VB2_MMAP | VB2_DMABUF; q->io_modes |= V4L2_TYPE_IS_OUTPUT(buf_type) ? VB2_WRITE : VB2_READ; + if (buf_type == V4L2_BUF_TYPE_VIDEO_CAPTURE) + q->max_num_buffers = 64; + if (buf_type == V4L2_BUF_TYPE_SDR_CAPTURE) + q->max_num_buffers = 1024; + if (buf_type == V4L2_BUF_TYPE_VBI_CAPTURE) + q->max_num_buffers = 32768; + if (allocators[dev->inst] != 1) q->io_modes |= VB2_USERPTR; q->drv_priv = dev; From patchwork Tue Oct 3 08:06:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 147709 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1928608vqb; Tue, 3 Oct 2023 01:08:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGw3iYHSAo6aWvTK6DXtIQPe7mDaJBlMaNvN8az4Ds19Az5RhHA4YtY7oZ1MvXkKsCw8T8c X-Received: by 2002:a17:902:ea0a:b0:1bb:598a:14e5 with SMTP id s10-20020a170902ea0a00b001bb598a14e5mr17636977plg.43.1696320517139; Tue, 03 Oct 2023 01:08:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320517; cv=none; d=google.com; s=arc-20160816; b=D+FlV9jirmMaPbXYOf6QYClmBlKqAtuJOebPvlnwna9/Vt517L+PhnUzFCMQkXrej9 Y7cgt2IBHvfQIrdtBJrzenli4oqs4oXKFA1LZdlDNNiH6u4QJSOgqL5G+Tr6LMVpiRwW xbpVpmXogsTxP6jI9mTV/G1MHW/7kB32cbt8i1nMNmX/nNA/ox/1bxYkneTNbTeVyirB 60CBl7okwNVnjwhz6FS6nGkKWqHK+E9mHVcjPSRAyWD1EwNI+Ah8L65aZ55jutZYbyFz q2vKllXb1QqrGvBx/SiHBu73pmBIx5Z5sq+wBwf+B95FMNRWvzW6JjV2z/gUdzEb3okP to7Q== 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=cUa/TY+Am8ySB21RfaC1a0J9/53VTglM2vrOBadwXyE=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=F8GIhwvTbOKTgbYp00775YYrMvgX2hSO86lcNn19kIFHYrmlUByja/XEzKYhjdWAkU QJvKuBjz/5mucwWWoWJxG0XLYcdn/oQqyCy15AnKDTV6Lod/rH/l9OddJp87e98sEBdQ 4/qtzbn1dVivBcksRwAkc3jSORhS2BTy7dhhyAkAPkDmOAjV6ZDxQiMqd06b9EQJn5sQ XPcDWDTqqXQrMbvik1poNiObPpsCkNGHsMzuNQKk6gYk1J5xu6NsFKwBi6+FLBQs2R7F ncsGAXUTfCCvtTakjG/qUnA3FA9aBkaLQ06R+4/a+1M6T21YvMyEZTMzOsr6WAW2R/NS 6DUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ibOVzPFn; 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 h9-20020a170902f54900b001bc8a9f5e52si996510plf.135.2023.10.03.01.08.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:08:37 -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=ibOVzPFn; 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 5BAD1822C631; Tue, 3 Oct 2023 01:08:36 -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 S239725AbjJCIIb (ORCPT + 18 others); Tue, 3 Oct 2023 04:08:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239339AbjJCIH0 (ORCPT ); Tue, 3 Oct 2023 04:07:26 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0687AC; Tue, 3 Oct 2023 01:07:22 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 A37C66607347; Tue, 3 Oct 2023 09:07:20 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320441; bh=/rw+5kiG9NH9F1WJEwdp/d4z1jjMgH/1J5yw8ccESj4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ibOVzPFnCu7xS/9VbCrqUZQdqEyRNLCo9wX+6ddUTppdLjfpg5JKUxT6rr0aDAUr9 m9IYbLplc/jzC98cdRjFvKP5HNI9jV5ZJwKM3LkfLaM2iuZW8Mf3f95Xcz+6R+RkMU Xu8735Q1UKCApDr4/vKGlv/cloc96s962UMgxTFXrNKsMorbwhnfAR34enCL35CP83 RyLa9tW1notemgbUD3pImo7hzkMvUboOTABmmVXg0IBMFnPrb60Fu41mJhYiTGfgkW 15luS1mU2lYcY8cs4fhg+/iuy7eW5O2c+yPlk8AzX5qq6VPwVqjfEF4pv4/AG6TZfp AZ5/M1gpdzfEw== 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 v10 15/54] media: test-drivers: vicodec: Increase max supported capture queue buffers Date: Tue, 3 Oct 2023 10:06:24 +0200 Message-Id: <20231003080704.43911-16-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:08:36 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778720982585905217 X-GMAIL-MSGID: 1778720982585905217 Allow to allocated up to 64 buffers on capture queue. Signed-off-by: Benjamin Gaignard --- drivers/media/test-drivers/vicodec/vicodec-core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/test-drivers/vicodec/vicodec-core.c b/drivers/media/test-drivers/vicodec/vicodec-core.c index 6f0e20df74e9..69cbe2c094e1 100644 --- a/drivers/media/test-drivers/vicodec/vicodec-core.c +++ b/drivers/media/test-drivers/vicodec/vicodec-core.c @@ -1718,6 +1718,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : V4L2_BUF_TYPE_VIDEO_CAPTURE); dst_vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF; + dst_vq->max_num_buffers = 64; dst_vq->drv_priv = ctx; dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); dst_vq->ops = &vicodec_qops; From patchwork Tue Oct 3 08:06:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 147729 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1929616vqb; Tue, 3 Oct 2023 01:10:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFWo4QdIkOafj8ANlAdeo2mDiaT/hK1G1wAdTxmaD0xwYm/RWgVFnwmqTZfWaCLkqlI+hWK X-Received: by 2002:a17:902:e545:b0:1c0:ad3c:c723 with SMTP id n5-20020a170902e54500b001c0ad3cc723mr13088807plf.10.1696320656710; Tue, 03 Oct 2023 01:10:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320656; cv=none; d=google.com; s=arc-20160816; b=z8WtspiMGmmL1kXq1dnpcITg2F1EAxassZn5HJSRVRPbZn0mCxKfoAMNViKsQJc4TK HBIfccmQ/clOFFKSAi8xlKttayZug6ZsdJC8Hgq0qjCZSI0mMasqHmfR62ZsK3LADfW2 G9iaTLnuh9EgqH8J5mr1b7LULsgQkY91Y4bjJBpScdWsY2nqJLDb0XvIRqjaMsDP4Bo9 mEMvalErW7VdPA+L68iwC+6H6/ez7gP9GXkGI0EnU/FlR8NR+Bt8Hlt+1U1obPt0He4/ jVykZEsyAqrXZu3UHserD5K0GpkOd4GQkNikDbCMtL3AwswigI3lix1NYM9E8Ba0/WuF mKhg== 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=Gr+w2pMU0vmIfgZBcVae6hzRWKnuSfsgOb9/W6egrbs=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=f7mrSBAkfP/E6bTGupP4U4a2ssZ25KUP1dWnw8oPY+yBkiyDmlfoJauDi8dnZZk5aR ShiAOeGMnYoPmUGKCBRbHxEknEsALjul39GATTDftdSPvzgOxvEl2WqHuEqnCHDkER1h yDwLDtBqRrJYpgwpu0HJDSk9pLhK0olGhnzS+F8glk/BTEhxrd1m2AlX2WMUiQIsoaCu cJTc7AhD0CEF3E7ZFEmZH7RdQCBLYGgE4FJXw16ofBXTia3bdEX/M/kR5+ypaLUoRJmW hdEHtHzvaYUY6dpUQE4zIJYehkBqcQH6z74CxqD4WXPipSH4exLi4fPntZl4+wRW5zEm AxpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=R+EK6Lma; 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 z5-20020a1709027e8500b001bd9e2b4b46si788336pla.601.2023.10.03.01.10.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:10:56 -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=R+EK6Lma; 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 388A980226A8; Tue, 3 Oct 2023 01:10:34 -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 S231314AbjJCIJ4 (ORCPT + 18 others); Tue, 3 Oct 2023 04:09:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239323AbjJCIH0 (ORCPT ); Tue, 3 Oct 2023 04:07:26 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1AC5AD; Tue, 3 Oct 2023 01:07:22 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 37E4E6607348; Tue, 3 Oct 2023 09:07:21 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320441; bh=VTuP28ZsO2FreEfJi907EJ7zG8cx8X1mGFIxnktiwb8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R+EK6LmaI8PM34NNfhXQ6FOyZz/TfwbqoQczCw+cJHhJPalmnk0AY4XGdfbXMtBM0 suOZgFrOs04U/ZAVTcUcktby7FqmJcBEPhgYfUhYbFgR50nf0Th52pl4kroaAmhjuu /xbH43e7OB+IaorGgGXm0qT1A+xb1LWmqfOtrq8zY1C5XmLgx1ZZkEnylhicdiUDoV WO3buixrRHSqQxPSldzSf9291f42aJ9tAWSMX4OllI63iOV3ImokZgjQ/614GkfMhj knoS4vM2S6XbLveGUVsYFVHBK9YpejZFM8o0OH2/jgmrglgz+28GFqS20XXfRI6xX4 PdKS7XmNKV8DQ== 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 v10 16/54] media: verisilicon: Refactor postprocessor to store more buffers Date: Tue, 3 Oct 2023 10:06:25 +0200 Message-Id: <20231003080704.43911-17-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:10:34 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721128923068945 X-GMAIL-MSGID: 1778721128923068945 Since vb2 queue can store more than VB2_MAX_FRAME buffers, the 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_num_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 a9fa05ac56a9..7f5b82eb6649 100644 --- a/drivers/media/platform/verisilicon/hantro_drv.c +++ b/drivers/media/platform/verisilicon/hantro_drv.c @@ -235,8 +235,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_num_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 64d6fb852ae9..7aa45d0fd291 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_num_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 Tue Oct 3 08:06:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 147710 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1928642vqb; Tue, 3 Oct 2023 01:08:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGJWdT51/olTPEh8cvV6jl+fLssBi7z591UIaj4k87mmsf9ocCa4ubuxLDqj1dsjJeoS+LP X-Received: by 2002:a1f:d686:0:b0:49a:5b11:1996 with SMTP id n128-20020a1fd686000000b0049a5b111996mr9674605vkg.6.1696320521760; Tue, 03 Oct 2023 01:08:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320521; cv=none; d=google.com; s=arc-20160816; b=hBtqqOxeZNkSfjj4zWEz2H/Ocrfmr1X04ox2MNTJ/p7h0oFDRR6ZPUPnSiPUzXgZyl lDYrOjPyoBdUzgjRsN8/lIeFOw1OnJ6mAQmlOS7KR4FqdiPMhbYIP5ogwR4Mmqdw9Z7u Gu5/yG8L8OPX2cswmS+HRbXL/ozsPYds8xTDnWafnBd7SwsdB47M046RXMxdUpSzh7GJ 6XMtk8ITveV4duO6KHBTeqkI9FI5SQyUd8BFfKdv/qDP/NvAeIc0yh70zzRNjtxO0kiC TnpaFdIPLoTEaILtlHqpFwRRHE1rPk33ysaxlYWqucZ7BTad6PrLZn1ijK+01nAAuc1Y 5mJQ== 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=gaMzKELc3/Xz3pOFESwGTZwQSasESy4Z+f+z61LC7nnGjhJIY8CAOKyHgjROC9D2MM Jb5LadE/K4PBGgb2pNy2s2r10nzTdzjKYUVYRTyZ21tjIrGEy+zKQbsnasjxkwX6saPk YouIqdlKTCfFU7Xdxz41R2ojTrh0/TPrJts6MT3b2KO0MS2bHMJZJXgLEmWThcZBeUX2 d+eKYjlWzqcocx962AC6m4fg3VxMpfsBvM+aOH3Z3Ej6fI+d0t//zkyVFQqhweM22cwN 88yazDUVw54JLtYmT1ZyXcIyc/ufEJ8Pv8gHk1NOfNFUBL7YyhH2p4KhardmOiumOkk9 vI/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=MkZcPdKx; 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 fz15-20020a17090b024f00b002791e9b60f9si887711pjb.48.2023.10.03.01.08.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:08:41 -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=MkZcPdKx; 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 F3C6C8243BEC; Tue, 3 Oct 2023 01:08:40 -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 S239731AbjJCIIh (ORCPT + 18 others); Tue, 3 Oct 2023 04:08:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239340AbjJCIH0 (ORCPT ); Tue, 3 Oct 2023 04:07:26 -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 54280AF; Tue, 3 Oct 2023 01:07:23 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 B6C1C660734B; Tue, 3 Oct 2023 09:07:21 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320442; bh=gAzQ/SGzIm4inZNC+PXcs+p3IPzDsrNiBUGyKW1mkfg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MkZcPdKxJNbSQMyuawxZq0pen7PzCIhOzMS19sWs/Zs+lyP0BnmOrsw65Jt+E8MuH 2VRtBuflK0zQGU+o8Ex+KDlwT2j3gKKFY2Y1xGyGmsScGXrqfbSHesl1jlX+A6xZxv lMxTEGrXDWQRfEfP19Dvd+/8Ke1IKqEuNQ3Y3MaZ3KlZSMWqsLQdPAWXdx0ddKGT/y YO4knrV070zJW3q7AVcIUuQuOtVhvq+H8H91oTaBjFm8+AnRCaE/NtTBqSRwH7O/pX JdU7SD9CZeThFnpS68jl2hIov7HE75gaOk5CMLnRrAcODOthgfO21/qjyNGGBdjvJa mDcXToMnEubIQ== 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 v10 17/54] media: verisilicon: Store chroma and motion vectors offset Date: Tue, 3 Oct 2023 10:06:26 +0200 Message-Id: <20231003080704.43911-18-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:08:41 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778720986958045686 X-GMAIL-MSGID: 1778720986958045686 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 Tue Oct 3 08:06:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 147723 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1929184vqb; Tue, 3 Oct 2023 01:09:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHsKEfoDAO01Y5Td0ofNf+HCgkSzm/iFy8io+SXWugrJWfwQnkr3HV6UM52QXrlyM1vgcTb X-Received: by 2002:a05:6358:7245:b0:13f:2833:bf41 with SMTP id i5-20020a056358724500b0013f2833bf41mr15185608rwa.23.1696320597323; Tue, 03 Oct 2023 01:09:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320597; cv=none; d=google.com; s=arc-20160816; b=QX46WM4JSLOpgr+gyoifLZHRnoPCHg2UaV45c/UxD8mAa9Nj1ynv7W1G3niQpbSKFy EOlpMNMCkwhXpqgg1dCGaMccRX4en3FhHmkrgJfo+UQjVTGkDbLSGBsbngU5JgOStUlk dY1gqKb3/+724rKeFOp2WwyZadVPlyFXxdVxVze9sFcQxF1+EWo7A0YC7qlbw2K50zyd KzdwcB5UvfKT+TVSNl+Qe9dwO9izu3ypRJ+ERiK8MGl8jHPb+MIVzM2JXAGNvDj11LBG CNningQxwzpcsBGP/Mgg16bgIPH5+0yz3QhKpMPMfnTP68AUSCENgH1yWZWWEdhJtkZ7 Y4MQ== 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=uCpiGcWgNh7qvA2EEgzcUWFqIDOvdk+4jOOcG2Ecg2y3CbwVaCn/AfLzpskLXdlplE Uund2YMybxP162v+k90t/3vfHUoV23G3TBo0KDEfRk5vuM2IQfw/fR/SEAXqnDWUdArg B12QT3JIMMzxFexBMVYz2sTUnkr88oKaqNoPzOl5zDbk6L9AysrNrxdcJXS/PyMGS1nd /BE5kb58pKIge6c/MrcbzrELKQwao0GM+ILNLrgzM04bLIVqO9Mw+EA39l9Qt6WAlWyy Ei+4zeDr9gPGI1XqU9ohlATcYcyNUbtkfKa0fFdC1qdFbjm7bAk9PtTzM7K1aZkavPOR vLTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="k52b/RsA"; 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-20020a056a02004100b0055c8d58cee9si950749pgb.714.2023.10.03.01.09.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:09:57 -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="k52b/RsA"; 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 6FAD1824E78E; Tue, 3 Oct 2023 01:09:56 -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 S239550AbjJCIJv (ORCPT + 18 others); Tue, 3 Oct 2023 04:09:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239351AbjJCIH0 (ORCPT ); Tue, 3 Oct 2023 04:07:26 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5475B0; Tue, 3 Oct 2023 01:07:23 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 3FF16660734C; Tue, 3 Oct 2023 09:07:22 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320442; bh=G1d7K+QU+qOmdvGntI5BZm0vkE40HwEf9qtRlxyqy2Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k52b/RsALlGVRVYOFw45uhCFAiQdegPSy9/pGcxNmCjv9pR4hGhGSdeD4ybRINC15 Mnu7myPS5aE5CfcMs0vuowiU2B+h07nvPYYxE38crq+uyi52dr/GXuD0pPqX5uTjGb 10hpIxDNEg7eAK+l0MpKrLJO2dC8LY247N539wxumUinyp5X26wIgZngUyrRU0DR/Z A2awLXulx9p1JLmD7pfUCKt54WQ4JN8GsyV2fb8pFRERJ6NAXpiGizrmE1xR5wvBhv DKmfhkjrvllpAPf30n8yV/CF3qxH8MXn29qNSCvU8Ekpglkh9KD6coJX98IEs6OrXU BqFZC2O0z0flQ== 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 v10 18/54] media: verisilicon: g2: Use common helpers to compute chroma and mv offsets Date: Tue, 3 Oct 2023 10:06:27 +0200 Message-Id: <20231003080704.43911-19-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:09:56 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721066641594809 X-GMAIL-MSGID: 1778721066641594809 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 Tue Oct 3 08:06:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 147721 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1929157vqb; Tue, 3 Oct 2023 01:09:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFyjFxCQ6zIZKRd+NFMP48sSaZgFUoa78isb2zzdavNXAKmpHTuXO1hlQWAYRWOyJZKdug9 X-Received: by 2002:a17:903:456:b0:1c4:62a:e4a with SMTP id iw22-20020a170903045600b001c4062a0e4amr10660699plb.64.1696320593313; Tue, 03 Oct 2023 01:09:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320593; cv=none; d=google.com; s=arc-20160816; b=b6lHrEPyC/kGysCWlvq4n2ntfDwY4CfZ4IONBq05LGBOHnZqGABelauwtL83e+P0hP 56z2c0ggI+0+MdTdnt7c2KCzuINSwTwBZgXPH/QamB5hNgppjG9Uf/PF/pKPnAQr7HxL x2druQE+e/D++8WlaMI+oVGFK9/Y51LczYEMeXQHX061DLPQicAoVjO+VbfZknSSnL7K vVk0mGQM+yNV+TcapLsMpqCCZddQdF/f5CkiYBmyMIzZkMbFjsa7jTgo7G78aE06uRbB FECNI2C5iWNd0IZV0nmIv5VVf8iyg7BaKVurjAzdh67cX3yMJ0xT3LgD+WCvARzC/9i8 Kjyw== 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=kPvonKxoAhejVRgHosJDNj15diLihVmbOhKGNvcQ64Yobhu+AOsAC3CZMa98Is0ZZC U09RZXjUjwhr0cCAT8fsqNTKEubt06egBI1lAj6cNmrRSaZX1QCOjM6nwwnHLN0ljaX/ IAuQpA2JsLAI1mpC/A/7P+1YdQk4DeJV0+MidnqtJaQ3TQ9ALrEw0ema4DY1DPpCHrz1 eQqZYCFYbvMroTF8KGeysLF/Z4pso4MDBJO5bL8Pj8b8VWKrcN4D59KIB2hF+UjzgXtY LayG7C+I4sAg/y8rF9Ose6ewZH9Hn66pI4vo4p33Wh5wLOvXw6DfHzYLHYR7laZ9Hv4w TFPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=AKIQaoUk; 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 a15-20020a170902710f00b001bbd0450af8si851415pll.187.2023.10.03.01.09.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:09:53 -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=AKIQaoUk; 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 52FAC8254A95; Tue, 3 Oct 2023 01:09:52 -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 S231199AbjJCIJr (ORCPT + 18 others); Tue, 3 Oct 2023 04:09:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239317AbjJCIH1 (ORCPT ); Tue, 3 Oct 2023 04:07:27 -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 485FEBF; Tue, 3 Oct 2023 01:07:24 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 BEF0C6607314; Tue, 3 Oct 2023 09:07:22 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320443; bh=WDraZOgWi0izES0K9FdWnGrtWWF6tf7zOBBP/EoWBNg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AKIQaoUk2fGDLfp0rpz/XWAmOnlLOuct2tROky827WNyQ2qdU0p+WNIe2bNMaNcwW /B0Q0IgLPbIz8cZuE1Z8pFh+n3/+6vuk5P+cBFmkPTjgVXXDlM7GE5FB+lhURkmtSx cBmI1B9S8dC1u6vYJno9rXZxwuQfRDpmudYFKxUtpUQBws/x9YoAvtxHMHluxvRFaL ZnfLn4KJEKDHH3Y8F9IBO6xsG9JKWbNMJHTC2YnfaCXOsE91+1V+w/SmEVm6DRaSTP seibkyxkKQeEkL3dpSNusx8KUjJadKRt0D1afPZ0tjLpBs2Ni6pclLnh9aisk4Cpa0 GPauDQjLVd6YA== 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 v10 19/54] media: verisilicon: vp9: Allow to change resolution while streaming Date: Tue, 3 Oct 2023 10:06:28 +0200 Message-Id: <20231003080704.43911-20-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:09:52 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721062359251377 X-GMAIL-MSGID: 1778721062359251377 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 Tue Oct 3 08:06:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 147749 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1937182vqb; Tue, 3 Oct 2023 01:30:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHWHmmRIteJPyMw3DLBRstaacJy7Xx12Sp74egM0dQ8bSvL6PGIjwc8zNOqe6ecLINA5FvF X-Received: by 2002:a17:90a:e389:b0:268:1068:4464 with SMTP id b9-20020a17090ae38900b0026810684464mr12282021pjz.30.1696321846740; Tue, 03 Oct 2023 01:30:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696321846; cv=none; d=google.com; s=arc-20160816; b=cO27/i5XaDNEoIf7oWiNk5qmTuxeAaTJgtW7TiLbTN/O6SczYy8TMQx3DJj+AbURS2 tp1hHsijU/UxhoChJqJ7nCBDLAnul3xzmjkOIJ321zt2WqqIPZF2XDaVS2gF/hzrB3Xp FmCKuKnihmNC80Xg3CtkTSDdRAMxlsg+/mSF9KsL52MwnD9TVnPe1YWp0YjmCM1NWAe6 yL7Vyh6IwPb8Vswb0lsL62vx5tGPbFky8DgpUn9IxjgmgAzADrLt/bpmy48SvgstM3/q uPVkSk8iKdiyY8RR1FUz6mkcBrwAxzYnaqmzCXUvz4IlQWgeRBD7Vtk6rdSQJ/WTlwwg HLZQ== 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=wuhFmhS2w+v29M9lMR5h9Bb4wbNIXpj9+P+8AwH6fjI=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=uYJJg8actZTFfDG0Xcvbwej1z4eop9X5tI+HYrsZlpAtGbi3lwTmzL8uf6jTl/uweg n5EZlYeHtOwQKPUKo3ddpGRWNn+L7qWI7FX3pSXQu9DM7892LTX/8TNvlBvOpq8czvyz Q2NAkT4hPBUKm72BjQ7L02uCESWlmHnIUpdgDMx5ANYl6cWmKT7kd17Z/e2G/5g5ml4x /PpNcu7ZAxweAWfmRVhegCycwaYcusNcQVv59JrGbG11GInw77GzyKbgunNclvr5bDzc poaLeyZ01SsHiYivBaDwxer6rxn8EQVMZNNBBgD6Qg82LizyMkTFayvQw+vA/YvmXEkc zifw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=VxqczClS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id z11-20020a17090ab10b00b00262ff3a4545si9081770pjq.169.2023.10.03.01.30.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:30:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=VxqczClS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 AFFF880494BD; Tue, 3 Oct 2023 01:30:34 -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 S239914AbjJCIJh (ORCPT + 18 others); Tue, 3 Oct 2023 04:09:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239372AbjJCIH2 (ORCPT ); Tue, 3 Oct 2023 04:07:28 -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 C830AA3; Tue, 3 Oct 2023 01:07:24 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 4A65B6607350; Tue, 3 Oct 2023 09:07:23 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320443; bh=qLvZsJraHy1cyquUmJgnlrPrhNUiYIy8VUcF3+5BgA0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VxqczClSQp5zz7dzFXnSeQ+VItyAdodAT1c1CFllI6/95XCVmC4urN90RiVgJhZ1x fnPE+jcB09DnHsfl6c89eAPlfvuqkiS+54g3DnnkdKpRAbndQX0aS+7NnmBkDiWJm6 Ljo7953dHbAjD2agQy3ZHtPqqS5nMTlA2v33AhdIYBd9UxVTAjcBayyzQVKqPiBT3l StP/H9mm320pKpNOrx2dGXfayyTtKWUqXw01OnrRXlo7KO+njY0DgXSEpIunOkGJ1n gKGlSQQJEsELad66EEc9axVOUCkQZlE5LzMqU1/ohB0Lxpd3fUqVmVUZMrCpTP25W5 IqxED93tA5uxw== 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 v10 20/54] media: Remove duplicated index vs q->num_buffers check Date: Tue, 3 Oct 2023 10:06:29 +0200 Message-Id: <20231003080704.43911-21-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:30:34 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778722376602922856 X-GMAIL-MSGID: 1778722376602922856 vb2_get_buffer() already checks if the requested index is valid. Stop duplicating this kind of check everywhere. Signed-off-by: Benjamin Gaignard --- drivers/media/common/videobuf2/videobuf2-v4l2.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index 42da0adc052a..cf881c8d8d4d 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 %u is NULL\n", opname, b->index); @@ -833,10 +828,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 %u\n", b->index); @@ -908,10 +899,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 %u\n", eb->index); From patchwork Tue Oct 3 08:06:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 147752 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1937395vqb; Tue, 3 Oct 2023 01:31:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGbHVvbE63bp9o2pDYsj0L9lU5YXa+kvOmNVVUv9vxxrPA3dUTJhofxnziWU7tyOMOcphdM X-Received: by 2002:a17:902:dacc:b0:1c3:6d97:e89e with SMTP id q12-20020a170902dacc00b001c36d97e89emr18304838plx.58.1696321874137; Tue, 03 Oct 2023 01:31:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696321874; cv=none; d=google.com; s=arc-20160816; b=oMNSqTVHXb36Dlx8u4o5ZyfUhiaOIIFZifWtfMPFOj1ggiTPc7L2ERty2IfMUu/l5E jAc+2b17JOYKQxJha7UCL+HRFmaWGbtTrxbhbLQHWMZhkSmLxUzPXFgMWQU8vwqW1B5/ wBHTmqQDXz02Jva1985U2JiuJobLqFAHbd3zVEQkQa8p/ixFhBY0j7Rs3J9h9HZSgX2J kTPQkf21/uJS3bUD6McFPQvxHYvRdfCjmhFh6sFwjC4DcwJaHwuqlIcCHTQqNXZ5/Rqk FMx3F+SOQhG3CCRzIHlo5X8diDb5N7Ap2NU4qLHAqV96X4C9Hk3aNw+4Ki2vMtxy1WbQ UyTA== 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=jonY4/8betqnvtq7NwHWoAJOcMA17cI2y7+4rqK55Ic=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=033AsFOAE1uoyrv9YnpSVt/SqjiFr5hvzJPWbm+W6p+8ZhRVqevtzfsVtIblqvOdkR evZHNVbu21cG/UGkQ549qVJGjYqvzo41qoKPF4r3G2yRRQpqOwjMSZ86N3YAafruSw8E Durn8ryxXcxPJHSzLrGTHkcWrTdLcTs+XV2F61Y6NOa0paTep8ujDgJf21DKp/yPnHQJ HasFzQg0Aw88UyGhDPilZ6fY8GVzo99rhiw65sJP50C70TGfcnLpj/EW34FJGHNnbbCr OtaI0x94ZQp7t6oVINPuUfLQMXr9yvv/xcwc9O6OHNPwuYjCbseo5c82jDC2vnPBxIcN DFGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=KGDjpueV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id t7-20020a1709027fc700b001bdf71d52b0si938733plb.456.2023.10.03.01.31.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:31:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=KGDjpueV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 39FF8812281A; Tue, 3 Oct 2023 01:30:52 -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 S239868AbjJCIJd (ORCPT + 18 others); Tue, 3 Oct 2023 04:09:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239438AbjJCIHg (ORCPT ); Tue, 3 Oct 2023 04:07:36 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56C41E1; Tue, 3 Oct 2023 01:07:25 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 C8150660731B; Tue, 3 Oct 2023 09:07:23 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320444; bh=V6so/n5DSLUhUZzOXb2TFLtP93yBP3TgQBtvx5Qlw3A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KGDjpueV8n9qx6iUDM15/yGIsddJze92Y3+J/Dq05tLsqgABvMMFL8JZqNKIFbPUB fkrtCRM1Q1Cke6SJFG5YbweL0CbbsXDQ5GYWYOT39THAjmEPdw2OlAxvuHnGRc4bN2 LI99l9fCZ4Cv+ZqKPPcaEl60cMZdujUEWNYA2KFmppNvAY5Q65E/8kgSTVHCrrmU23 +s/q6e6QMXeJJA8X7k4psND0h+g5BunBInh26mKk3i8OuqA1T8aZ4tin5tjKEK2ttQ kAyIFzpNJ+fzrQ9DsxRbsmXpSih4il8ede7y1mDTBGSygJ14+6Dhl3iNwD01kEZvrz Sbx1k0IwM1xhw== 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 v10 21/54] media: core: Add helper to get queue number of buffers Date: Tue, 3 Oct 2023 10:06:30 +0200 Message-Id: <20231003080704.43911-22-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:30:52 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778722405567283230 X-GMAIL-MSGID: 1778722405567283230 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 | 109 ++++++++++-------- .../media/common/videobuf2/videobuf2-v4l2.c | 4 +- include/media/videobuf2-core.h | 11 +- 3 files changed, 73 insertions(+), 51 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index c0104f824577..62e987ad9b33 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -426,6 +426,8 @@ static void vb2_queue_add_buffer(struct vb2_queue *q, struct vb2_buffer *vb, uns */ static void vb2_queue_remove_buffer(struct vb2_buffer *vb) { + if (vb->vb2_queue->num_buffers) + vb->vb2_queue->num_buffers--; vb->vb2_queue->bufs[vb->index] = NULL; vb->vb2_queue = NULL; } @@ -509,12 +511,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_num_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_num_buffers; i >= 0 && buffer < buffers; i--) { + vb = vb2_get_buffer(q, i); if (!vb) continue; @@ -525,6 +527,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++; } } @@ -536,16 +539,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_num_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_num_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 */ @@ -556,7 +563,7 @@ static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) * Check that all the calls were balanced 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; @@ -582,7 +589,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_num_buffers; buffer++) { struct vb2_buffer *vb = vb2_get_buffer(q, buffer); bool unbalanced; @@ -634,19 +641,18 @@ 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) { - struct vb2_buffer *vb = vb2_get_buffer(q, buffer); + for (i = q->max_num_buffers, buffer = 0; i >= 0 && buffer < buffers; i--) { + struct vb2_buffer *vb = vb2_get_buffer(q, i); if (!vb) continue; vb2_queue_remove_buffer(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); } @@ -677,7 +683,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_num_buffers; ++buffer) { struct vb2_buffer *vb = vb2_get_buffer(q, buffer); if (!vb) @@ -803,6 +809,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; @@ -818,7 +825,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)) { /* @@ -836,7 +843,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); /* @@ -936,7 +943,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); @@ -970,10 +977,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_num_buffers) { + if (q_num_bufs == q->max_num_buffers) { dprintk(q, 1, "maximum number of buffers already allocated\n"); return -ENOBUFS; } @@ -1008,7 +1016,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, return -EINVAL; } - num_buffers = min(*count, q->max_num_buffers - q->num_buffers); + num_buffers = min(*count, q->max_num_buffers - q_num_bufs); if (requested_planes && requested_sizes) { num_planes = requested_planes; @@ -1040,7 +1048,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, @@ -1061,7 +1069,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); @@ -1678,7 +1686,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_num_buffers; ++i) { vb = vb2_get_buffer(q, i); if (!vb) @@ -2084,9 +2092,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_num_buffers; i++) { struct vb2_buffer *vb = vb2_get_buffer(q, i); - if (!vb) continue; @@ -2128,10 +2135,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_num_buffers; i++) { struct vb2_buffer *vb; struct media_request *req; - vb = vb2_get_buffer(q, i); if (!vb) continue; @@ -2176,6 +2182,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) { @@ -2188,12 +2195,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; @@ -2531,9 +2538,10 @@ 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_num_buffers); kfree(q->bufs); q->bufs = NULL; + q->num_buffers = 0; mutex_unlock(&q->mmap_lock); } EXPORT_SYMBOL_GPL(vb2_core_queue_release); @@ -2562,7 +2570,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)) @@ -2600,7 +2608,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)) { @@ -2649,8 +2657,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 @@ -2660,7 +2668,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. * @@ -2710,7 +2718,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; /* @@ -2760,7 +2768,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 < vb2_get_num_buffers(q); i++) { vb = vb2_get_buffer(q, i); WARN_ON_ONCE(!vb); @@ -2779,18 +2787,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 < vb2_get_num_buffers(q); 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; } /* @@ -2984,12 +2997,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. */ @@ -3036,7 +3049,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 cf881c8d8d4d..a4ebef82d94e 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_num_buffers; i++) { vb2 = vb2_get_buffer(q, i); if (!vb2) @@ -765,7 +765,7 @@ int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create) validate_memory_flags(q, create->memory, &create->flags); create->max_buffers = q->max_num_buffers; - create->index = q->num_buffers; + create->index = vb2_get_num_buffers(q); if (create->count == 0) return ret != -EBUSY ? ret : 0; diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 1d6d68e8a711..dffb9647d4d1 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -1141,6 +1141,15 @@ static inline bool vb2_fileio_is_active(struct vb2_queue *q) return q->fileio; } +/** + * vb2_get_num_buffers() - get the number of buffer in a queue + * @q: pointer to &struct vb2_queue with videobuf2 queue. + */ +static inline unsigned int vb2_get_num_buffers(struct vb2_queue *q) +{ + return q->num_buffers; +} + /** * vb2_is_busy() - return busy status of the queue. * @q: pointer to &struct vb2_queue with videobuf2 queue. @@ -1149,7 +1158,7 @@ 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); + return (vb2_get_num_buffers(q) > 0); } /** From patchwork Tue Oct 3 08:06:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 147716 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1928842vqb; Tue, 3 Oct 2023 01:09:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEIqef8t2AotbxdiXAiwcT4wsv06iERMZxbz36AkDem21L53jUYx3LDipAykM5kWWC9+fjH X-Received: by 2002:a05:6a20:6a0c:b0:154:3f13:1bb7 with SMTP id p12-20020a056a206a0c00b001543f131bb7mr16679121pzk.49.1696320549627; Tue, 03 Oct 2023 01:09:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320549; cv=none; d=google.com; s=arc-20160816; b=MkJ4se39PmuWi0JvoOUG+2jdDFM8883qwPLIZD4MQwuDdMsn1uw3Ken3T2kXHRuYlK 7tNvGnfZNk2ftQhHPLMTQ6Wa5sGMHNKKiYsIGOoKR7Ym04woXABSqmEOtYzsANec4nys XUg2pTFGr17nVT6cd3FzTKYF5wUAtWx1uLsmU8typZAAxrvMHrBDa6GK8R9cwtBGhjb7 O23bkcETVpsURgfXF2sTzYwzwtTLy0IDORYozGrtur8QpN9HIvVfr+xADx1dS3YH7zIT lRss6y0KL2UqwzNCZy/IGu3KsRE+DjKUiqTiPQbuFy4H3keL322Ll63q1BbaLfURIfJX U++w== 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=d+Zh7OhCiZiOOWKfbCvE9mpOVb6/vmByOpoeFDYFpv4=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=BrKRJRVuoj4VnepnDa+j4MajqaAMsZ/M/kAFzoeC1M2IweFQlDjNHDzhMb32Hfct5q hfm2uc6UVCC/c/gKhvvQ5+Le07Mjni2HWv5vIfxgt4QlJXJaODxhj6iyrFCYqEdQXJM5 NdVPmEw0i1rTlVqJSSkDg1Av2U2pDQJHK+5DJbFi1+Tdqbm94Dlu8T5buA990XHG4KGz w2beTOTt6MYjGO6sRY0rJb9UZ1QHMglF+tGYpVfHeueXelzKIenNiWJD7G172sSc+LfA fhiVNne/T1jJglpw5YSu3V9PxwCArI4723/r+09e3fUcdwvSl8Jj+O3PH1W+7bqnflcN 5mIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=cXQBHl28; 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 c18-20020a170903235200b001bf88e777f9si1025526plh.33.2023.10.03.01.09.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:09: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=cXQBHl28; 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 7345F824928B; Tue, 3 Oct 2023 01:09: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 S239628AbjJCIIx (ORCPT + 18 others); Tue, 3 Oct 2023 04:08:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239452AbjJCIHg (ORCPT ); Tue, 3 Oct 2023 04:07:36 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3EA6E4; Tue, 3 Oct 2023 01:07:25 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 4D94A660731D; Tue, 3 Oct 2023 09:07:24 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320444; bh=o2sVtoPPYvq8hM/qyihWIqN4hasDvFA4zhZmTyTxJEg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cXQBHl28z3w576xIMzmVcsgwiZ8Au8MHBX+w26WURG2hh2RMCuZclgWUu+GoY88kK 6tVKH7eeY3PoZm8I4E69QVXgzAaeOatVL7yKS46h5QbtIfcQcyDMb75slc53UJvJCm VxHx5xsay8SzhetvZdjE0XPT8Oezi1tDGoxd1EmJIbyRlpfykXVMcp3gHb1f3MR+Ef luY3UQtIyJuEI8jyDsEe0wgn7Sehrsb6r2pnCVaDhzEbwLr5kRk0FJEITuf411pNWK j3rY7339Eb9pMFn+PMYcAii+mKPMEXazpThFtkYPilBuMqj/6Ce1vQrbIARoCsbtOf JeOkuvBmqG2wA== 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 v10 22/54] media: dvb-core: Do not initialize twice queue num_buffer field Date: Tue, 3 Oct 2023 10:06:31 +0200 Message-Id: <20231003080704.43911-23-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:09:08 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721016831103351 X-GMAIL-MSGID: 1778721016831103351 The above memset already zeroed all the ctx fields, it is useless to do it here again. Signed-off-by: Benjamin Gaignard --- drivers/media/dvb-core/dvb_vb2.c | 1 - 1 file changed, 1 deletion(-) 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; From patchwork Tue Oct 3 08:06:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 147751 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1937289vqb; Tue, 3 Oct 2023 01:31:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFp/w28fXMURmvZMvOkHNP+3Yy5abXPt2LPLIbvLeaYQmlL1pkDlziB94dBkgn7KEX2dkeV X-Received: by 2002:a05:6a20:8427:b0:166:6582:a7d5 with SMTP id c39-20020a056a20842700b001666582a7d5mr478400pzd.3.1696321860494; Tue, 03 Oct 2023 01:31:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696321860; cv=none; d=google.com; s=arc-20160816; b=J7ni0sT5+X+WbWPUTT3HtpokVrCt39NcRUvbd+5PGTdT9s41t1KUHPF2S7iZHPv0zY QVjDfq6mLVbk8Uk4cnuZc6gEsrcqOmBhdWBic0Hkmyae4lxpOPrdWxe9hPbfnqIoa1im 9oMVYgfcmHrnOGhD6NCx7HUkytDiYst/D8H2cYX6qfoGcHrs4fk/Oa/pbwIMHPWQuMa1 WEGYZBtSKKy2nBq1wG8K/0hG9iyb2dlS61O7JcWKMyJnPp9RbCdYQYdXvOfSScijxlIe UI6MwkUwUfQI//ceENVkzq4o5VFFwuz9A+UxiJpyLmVKoz5WFZo/js7UWWnWxgZk9mne Eogw== 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=4u0tbnVEtzf7uFUy5O5GUVi6lUPIj12M/GhbBAenuws=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=tZB0ecvOsEJy0F9w3IvpBkYRI4kLbCjZMdGTvjnuBccEetS5Gaee6Fscman5DRntyb KpInmYYUpLoPvUHwB174AgO370lIIJ6PduUwWVFAwGijR6RGGLeAsU4CKZxYen9UIGNF a03wWV1zs9Bux4B7vxpM8abPIYYek3/6GOIYlUABi9y1wjOsZYiehU474BvFSbXi88Sc eA/QX6RM2bN3bwwhAlV7Zv56j7TVH/n2rQKs9u0L/N06jDt0W9i7c+eVdLqm7i8hAG0j s6bJQp0Ww0kPVIzokDhLk4FGCoG9J5VBcR9dNgUe0rZ3Ic7Ck+N7/X09qcrUFvcjmKno u3Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=VRogHSXP; 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 ay35-20020a056a00302300b00690f8063627si966473pfb.38.2023.10.03.01.31.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:31:00 -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=VRogHSXP; 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 76B4E8040C48; Tue, 3 Oct 2023 01:30:36 -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 S239828AbjJCIJa (ORCPT + 18 others); Tue, 3 Oct 2023 04:09:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239431AbjJCIHg (ORCPT ); Tue, 3 Oct 2023 04:07: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 5C5E0F1; Tue, 3 Oct 2023 01:07:26 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 D209D6607352; Tue, 3 Oct 2023 09:07:24 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320445; bh=rkThknrqAdahL7+ESWJTTDJdizQjBtgRoFGagWtq+LE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VRogHSXPzfZ/I0k0Nzl91W9qV1mJMn+tjIirdiiHTO6dtSHaFslE+FVMvlJIYmxI9 wXKpJ/L9LAHZcGSrOlLuhfts7X+cAj12JTuwNQkwhv52wzqgNDEYSnoE5FSGnhFz/p nJcBKyfHtwZRFP85ZukyaV+4p1Oonen2z9kenY17r8yqN2TTPkoxQtTRMkHfSxKE5C Q9PeNGRjp+gge+o080sE4GFhP4PC51g5VFDANdZzlkn1Bvs+anQRTGTbSaA3ze36ec JAEjM8q9tubHNNX0jJB1U8GBAXz91081XKBrEhVpbsp8gM4iFn8gaiogKM0u/kuzRp 7BV8HRejDxrCw== 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 v10 23/54] media: dvb-frontends: rtl2832_srd: Use queue min_buffers_needed field Date: Tue, 3 Oct 2023 10:06:32 +0200 Message-Id: <20231003080704.43911-24-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:30:36 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778722390844599247 X-GMAIL-MSGID: 1778722390844599247 queue_setup checks for a minimum number of buffers so use queue min_buffers_needed field and remove the check done in rtl2832_sdr_queue_setup(). Signed-off-by: Benjamin Gaignard --- drivers/media/dvb-frontends/rtl2832_sdr.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/media/dvb-frontends/rtl2832_sdr.c b/drivers/media/dvb-frontends/rtl2832_sdr.c index 02c619e51641..597b1548ed8b 100644 --- a/drivers/media/dvb-frontends/rtl2832_sdr.c +++ b/drivers/media/dvb-frontends/rtl2832_sdr.c @@ -440,14 +440,9 @@ 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; - dev_dbg(&pdev->dev, "nbuffers=%d\n", *nbuffers); - - /* Need at least 8 buffers */ - if (vq->num_buffers + *nbuffers < 8) - *nbuffers = 8 - vq->num_buffers; *nplanes = 1; sizes[0] = PAGE_ALIGN(dev->buffersize); - dev_dbg(&pdev->dev, "nbuffers=%d sizes[0]=%d\n", *nbuffers, sizes[0]); + dev_dbg(&pdev->dev, "nbuffers=%d sizes[0]=%d\n", vb2_get_num_buffers(vq), sizes[0]); return 0; } @@ -1364,6 +1359,8 @@ static int rtl2832_sdr_probe(struct platform_device *pdev) dev->vb_queue.ops = &rtl2832_sdr_vb2_ops; dev->vb_queue.mem_ops = &vb2_vmalloc_memops; dev->vb_queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; + /* Need at least 8 buffers */ + dev->vb_queue.min_buffers_needed = 8; ret = vb2_queue_init(&dev->vb_queue); if (ret) { dev_err(&pdev->dev, "Could not initialize vb2 queue\n"); From patchwork Tue Oct 3 08:06:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 147718 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1928878vqb; Tue, 3 Oct 2023 01:09:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEdYonDIOx9mCkgD7bW4y8c7lGSeONEBO8rS8QU4xjO58MVj5mIQVILRRtZrlKJtoWk+mAR X-Received: by 2002:a05:6a21:99a0:b0:140:253b:b658 with SMTP id ve32-20020a056a2199a000b00140253bb658mr14331910pzb.57.1696320554642; Tue, 03 Oct 2023 01:09:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320554; cv=none; d=google.com; s=arc-20160816; b=MYl/mu8CYMnC4rSy7o++RiLQGyPbzABFRa2D+vqpt+20FlX0qnOf1Q2EpnocS0Ei7x NtYPFbnXqcETKCIVX+sprF4eEixSrErhTgHh817d7xNvq55TyWVELgdk5VJItm1zN3/R MuE9KSgs8qeNO2MEVw7ObRYQDYZ9+T/JTDi0IrH5huIVsWzckymNY/F0N/qkGRoywRg0 yuJ2vPCC19qXoH93kw/asyI69yAAMHXEjeA1Azjf2HdLpPHQGm+S/dxKrfpDoPxu8DvD PVVPZNpiZHog0ubfMxVH4WmHVvmrsk8Q2Enw3iucocSx/wSNm8EZa8TdZaR2NNZ975Tr VBhw== 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=mBXaPj6DG3Z3CGCFPIqmZfr720c4sPgatvICR4AllgI=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=cAhxDva44QNy7C4zUt3YiVadTiyKRyGNFFBE4gxT0AHmYDdpSAAn14U3yrCmMB54hh ksHaLT9hBESrVR16BRpxDveb2lIXbLB1+rV+JMFClR2WQkvGQBb+Py0vXdUlzAkd+zjl S/edi6Oj30Mt+SVAeIUy+xX8awtxD2fXnPfZlLzNnVJ7Ied4NlPC879e5Xf71D6lobG8 DjN/ysx/8UudY1oKGrVDE+gdGEz7Welu7ZnIl47PqOINmdhhf+JMpqe7Bg1JQdYJH9CW Oe+lQNmG1FVYxH/2cQ83I8eWbaxJHvuVo+iJtEQo/yhqsC+UmgYAVHtdxJ7rLRhRcPEX O+0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=dUB7Zp9T; 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 az1-20020a056a02004100b0056513361b4fsi955893pgb.741.2023.10.03.01.09.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:09:14 -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=dUB7Zp9T; 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 B130C814E365; Tue, 3 Oct 2023 01:09:13 -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 S239633AbjJCIJE (ORCPT + 18 others); Tue, 3 Oct 2023 04:09:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239443AbjJCIHg (ORCPT ); Tue, 3 Oct 2023 04:07:36 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5F99FA; Tue, 3 Oct 2023 01:07:26 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 58DF56607353; Tue, 3 Oct 2023 09:07:25 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320445; bh=ZEZh/1jz6LKW7llMFxu5ts8tvF/3dDwXLVtLxVrQsiY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dUB7Zp9TtJlX7vcgy2qMpzBC6McncVMZg6xRpfBrZ+llPsL14RTXOlX4h4Q138FqW /aHz9cqUgfVRdX/CNCC17tmVsJP3p9dDRiiv4VbUT/CfZF3zo/3xr1ao9dxv0H7fL0 +817VxBq56jxIpBk6oeL3d9zu3bEaJHvUKRrdEoD1LF/lxypp3XyE8OzPh2cq231wN 0qOwO0hlS2mrRWQ17Z/EsPdbcHwTT67C27fuPpMosyWepNl0TXzM6/DcEXE6GY4wRt //hesVP/BqnkBYvX2ZwLz7ib7nBrhJBMDMIadDDDR7DY5UXr1nHNWd0eMKB7GeIwoB auHEZ+C/n3U0g== 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 v10 24/54] media: video-i2c: Set min_buffers_needed to 2 Date: Tue, 3 Oct 2023 10:06:33 +0200 Message-Id: <20231003080704.43911-25-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:09:13 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721022263110721 X-GMAIL-MSGID: 1778721022263110721 vb2 queue_setup checks for a minimum number of buffers so set min_buffers_needed to 2 and remove the useless check in video-i2c queue_setup(). Signed-off-by: Benjamin Gaignard --- drivers/media/i2c/video-i2c.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/media/i2c/video-i2c.c b/drivers/media/i2c/video-i2c.c index 178bd06cc2ed..0a38b9614764 100644 --- a/drivers/media/i2c/video-i2c.c +++ b/drivers/media/i2c/video-i2c.c @@ -406,9 +406,6 @@ 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) - *nbuffers = 2; - if (*nplanes) return sizes[0] < size ? -EINVAL : 0; @@ -794,7 +791,7 @@ static int video_i2c_probe(struct i2c_client *client) queue->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; queue->drv_priv = data; queue->buf_struct_size = sizeof(struct video_i2c_buffer); - queue->min_buffers_needed = 1; + queue->min_buffers_needed = 2; queue->ops = &video_i2c_video_qops; queue->mem_ops = &vb2_vmalloc_memops; From patchwork Tue Oct 3 08:06:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 147717 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1928874vqb; Tue, 3 Oct 2023 01:09:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHwQQ6xHobMEJd+wC5xcRyIjVGOE+HR0LV1S2LgoF+pG4fa4PWSKfjIC9Emoe6WRzeH5ELy X-Received: by 2002:a17:902:e84a:b0:1bc:5924:2da2 with SMTP id t10-20020a170902e84a00b001bc59242da2mr15250291plg.56.1696320554340; Tue, 03 Oct 2023 01:09:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320554; cv=none; d=google.com; s=arc-20160816; b=VTr+w4Xqt5xEyk7YywLct/psoKKSEljG7ePEwtiWgV8leWtX0owj19rxV9Y2iLJy// PSqEqZ4m+f7wSVxJTnHuvc7CAo8rmEzkv0YhmhFhg9ATUWWM723yziPgPG2EU8Ms0MxQ qiguk8nJuxO0lXLIbzYWxkxqDR0aDOesWxjc86H23yQNt70rAiJcqS4N3x2b/wPiQ0bh UM/J5MV5R0J7cW6MGK5rcc1yoZljGYzr8MKSY2GhhpOfbesr6CAeAjOM4HpziSZTWslS z4OyT+1AmNyP9tYQEB+roBtHVCEVx5gYjjKT32YdwB7r+oAvm019p+4WmpKT0Ma8wkB6 9fOA== 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=PmW7Z5NzQBNoTpp+u7NKXF/tYEVc6UqlJQkmg8Bhq70=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=S5sQn16umht72pqH1VYSaGy0eI7TOA585Q0b/0RvCQOPWkoZt/P0JbjriUeVs5vXEv Vi/S4fyfmiDfjukaylkx1TqHg4+yRRyCpsmguky2XEol1iNhbmLdlWd2isI0EB32bnUY bT4c34JANxvzlvsoEZWGNi0DtqTk9UhB/+KvODJ3p0T5IhNaOyJ1h6UGfco7nkH8Q4FE ipY13MyrkxMMmAKIbA2Do7BHl+cp8Ic1mzMV1h+atd4oMGxSF7T9K6ZPCocZiRXYJbf6 PDYqNZPXtuCfNmGYEW1r1Yk6qJggMCBw+VGIC3HVEaQwSxlU2QDFnhQGjGZ50qicznZ1 kXqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=c4FiWMZ2; 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 s18-20020a170903321200b001c4329b77bfsi849618plh.123.2023.10.03.01.09.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:09:14 -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=c4FiWMZ2; 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 A477D824928B; Tue, 3 Oct 2023 01:09:13 -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 S239248AbjJCII6 (ORCPT + 18 others); Tue, 3 Oct 2023 04:08:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239453AbjJCIHg (ORCPT ); Tue, 3 Oct 2023 04:07:36 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68C8DFD; Tue, 3 Oct 2023 01:07:27 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 D2E356607355; Tue, 3 Oct 2023 09:07:25 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320446; bh=rFkYvrsLIxo1F3JyDJJ7M8J5xfn6Sk0yrCHC7ra2U7I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c4FiWMZ2kFjTILE1eg1120K+BXPvF5F/v+HIpp33sF+j1YS60kO5mDxH3FlaLKGf9 rvzXHc0UDuQx4/vH5a4AkBQViE3sS5Qrpbv+4CnVvr98HtxyhHZMrhMaZxq0jdAmWh /JCKL9+vS0E4NJYHBlZz2gF4kKLSS4Bpl1ww6NMEcEC9cIixykT0hLuUtYy21yLD/W XyV1SuSLfOyoCuFBNYhTninS0fvTzjKFIA9g9cuynZlEmBMHZIYUStFBFr7f22LW6I HPed5c8iPsyG24jMEoWPbijycjJBVJeWovNq3QmLzeANFLTEZENDKwQgMz+yI8SyTY 69vhnyRLrh1uQ== 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 v10 25/54] media: pci: cx18: Set correct value to min_buffers_needed field Date: Tue, 3 Oct 2023 10:06:34 +0200 Message-Id: <20231003080704.43911-26-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:09:13 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721021364204813 X-GMAIL-MSGID: 1778721021364204813 Set queue min_buffers_needed field to 3 and remove the useless check. Signed-off-by: Benjamin Gaignard --- drivers/media/pci/cx18/cx18-streams.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/media/pci/cx18/cx18-streams.c b/drivers/media/pci/cx18/cx18-streams.c index 597472754c4c..6ed2c9fb882c 100644 --- a/drivers/media/pci/cx18/cx18-streams.c +++ b/drivers/media/pci/cx18/cx18-streams.c @@ -117,13 +117,6 @@ static int cx18_queue_setup(struct vb2_queue *vq, else szimage = cx->cxhdl.height * 720 * 2; - /* - * 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 (*nplanes) { if (*nplanes != 1 || sizes[0] < szimage) return -EINVAL; @@ -286,7 +279,11 @@ static int cx18_stream_init(struct cx18 *cx, int type) s->vidq.ops = &cx18_vb2_qops; s->vidq.mem_ops = &vb2_vmalloc_memops; s->vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; - s->vidq.min_buffers_needed = 2; + /* + * Let's request at least three buffers: two for the + * DMA engine and one for userspace. + */ + s->vidq.min_buffers_needed = 3; s->vidq.gfp_flags = GFP_DMA32; s->vidq.dev = &cx->pci_dev->dev; s->vidq.lock = &cx->serialize_lock; From patchwork Tue Oct 3 08:06: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: 147712 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1928717vqb; Tue, 3 Oct 2023 01:08:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFSoQrSgcEVBTIbfw1B5fRkkbOIhKVLOuBS47hbuzgHR9/Ua3ulXwd7K01U1fxfkjTUDivj X-Received: by 2002:a05:6358:7206:b0:145:6fdf:9c86 with SMTP id h6-20020a056358720600b001456fdf9c86mr14441118rwa.13.1696320531485; Tue, 03 Oct 2023 01:08:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320531; cv=none; d=google.com; s=arc-20160816; b=DAQaJpSYnjPbsR6qbS+RSnE5CpVN1yDHmk6rBDQjt99CqOx2mzgv09M4UQQrWMrayI xyfGkW9SN9IOBnKvUZWuREkDXt2lYZGwyb4KBpVS//XiB4hfeAraWBtfSAOWMEp5geT/ ILz4YFrxQZhrJ1+OhVCPpyHOZrAL3fQmSmYittXqa6ODk4V/JsB7cOI2fQ8B4eLp0osg cgoqlVb/DpsPk9kWamOdt/QwuuPYK0d5JEuEw+PLTxx5NYsqrkMHAgc1oCI4d1o6LE4k FOYAy4E2vNqH71CSxmsFvAjJj2uQ5oJPuObjLiXRgDhVn7zyMCauWaeA1C7vR6V0yFRb mhhA== 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=mxhqX9L/LTLjAo8r4FRZmw55ljZYm0j0MEPgb49dKlI=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=hk1kN9RdxLTfm89dXwxElL+3LDl5D/OQTIHEK9MGTlHyrTQ9CVgBh+ZsCSnOFQAEJu bzYQIkFG3ah6M2NlVFNfSizIcm+ID53nywncaxwb+sBTiIUYbjlGLriKitBoV2ZryG3I xEi6FrId5XEd/M825mGilrt8iLVcrU18N6bsI/Uh98rVI+J1cQ9o2PjsCS5VwdrlDIWc EsLKo3G6whN5Z52/Un6mLWW/0qof+fX00fQQut9pADWAXb3MTTCu5ABObEbcgltdD/iW r+8b3nrjY3zyEqzNK6JzrJQdAhZBkRP0+eKie/eoiVYhbyrC2fWHveHPWYMfodBhQN5Y c2LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=hZ2VfmGY; 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 bk13-20020a056a02028d00b0055b640a6b3csi879278pgb.884.2023.10.03.01.08.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:08:51 -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=hZ2VfmGY; 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 BDEAC814E354; Tue, 3 Oct 2023 01:08:50 -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 S239746AbjJCIIn (ORCPT + 18 others); Tue, 3 Oct 2023 04:08:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239445AbjJCIHg (ORCPT ); Tue, 3 Oct 2023 04:07:36 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41A38102; Tue, 3 Oct 2023 01:07:28 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 5CFE66607358; Tue, 3 Oct 2023 09:07:26 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320446; bh=7OP/lnsbD5MzPZ4L/gceSmxIzda3Ng9eLtu0phjni7k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hZ2VfmGYVHi/dnTP+YqWFYiyKF3JtP4EZM4tG4D84XQVdyGz+cgYIZsE1JY20DuSI qQCI8LF/CoieabGlir1fILZuOeGnF/GG+kns46Su80aBUEssGGpt+vN0aD28g/EfFB GuNoQKW9+z2I0xh+u6R5bm/TarSvCKrYqMI5EC4UiJB/nLzr6zj3RBbtd+cG7f8rnt guOexMSvOG+H1ikLvyQTChUPMf5XB7eBU82nqinxPs6sQCRd4K1iRyS1HBdBT2lPpb y6fGFLvHl3+waddovE0q/RJjLLRDKl5Q/OGB2Qj8njCFo40uFVYbljvIJsQamJJM6G 6FbuG4MPBq/dg== 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 v10 26/54] media: pci: dt3155: Remove useless check Date: Tue, 3 Oct 2023 10:06:35 +0200 Message-Id: <20231003080704.43911-27-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:08:50 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778720997148011719 X-GMAIL-MSGID: 1778720997148011719 min_buffers_needed is already set to 2 so remove this useless check. Signed-off-by: Benjamin Gaignard --- drivers/media/pci/dt3155/dt3155.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/media/pci/dt3155/dt3155.c b/drivers/media/pci/dt3155/dt3155.c index 548156b199cc..d09cde2f6ee4 100644 --- a/drivers/media/pci/dt3155/dt3155.c +++ b/drivers/media/pci/dt3155/dt3155.c @@ -128,8 +128,6 @@ dt3155_queue_setup(struct vb2_queue *vq, struct dt3155_priv *pd = vb2_get_drv_priv(vq); unsigned size = pd->width * pd->height; - if (vq->num_buffers + *nbuffers < 2) - *nbuffers = 2 - vq->num_buffers; if (*num_planes) return sizes[0] < size ? -EINVAL : 0; *num_planes = 1; From patchwork Tue Oct 3 08:06: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: 147711 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1928671vqb; Tue, 3 Oct 2023 01:08:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFZX9EtcEZZdpQ5TJWFdVilnVgiwrZeaDKuC61Sr6Bu2vYED3rl8x01Xy+smHm39zdA0enj X-Received: by 2002:a17:903:26ce:b0:1c3:e3b1:98df with SMTP id jg14-20020a17090326ce00b001c3e3b198dfmr10529995plb.52.1696320524945; Tue, 03 Oct 2023 01:08:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320524; cv=none; d=google.com; s=arc-20160816; b=X/4j9nO6dkurSJtJNHLmZMyGGAunEnr2v+qox6vmpMyviTfGYkK+nz3eFyHi708Bb1 qAmwt09dQ92eMOtw6lGnpdGFqTaXdq4j/NXxj/uTn5kUjw8nwq7hqma95V8uTtll0Z6n NbDDSZADLOZv8loL4WGKL2hfzfLLKuQZj2P2KvT+32TQMxbAJThSdj4NLuNSVnLrLZBd JYbFo2TxbpduvABFdmG1mItApu7wFZRpEk4nrPwcvbsbFNrQHDUydTjMZpAEaMlruhnN 3Y8cK73V6Ju2IQp+mizI1wK7iqLIMNAglj87QzceNfzQhKo/PfIFsNkm4W3axEd1Una8 Zv7Q== 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=EGIyUnXfYlZrvHeWCo2ngnGTPgOrZHbbiv5X9rjqVAs=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=yZ4UGxzel3VcHT+9Mf7UimuBPiDLY1wq4OBuuy7Mh5wXqYuPQG6ibw16E3ILMWkezo tE4JxgUmXraPcZ/NgQ/DSOYqtlldOga80pmjeUINQBH/v1Bpd7MdLX3esNuOp8vWJXw6 JhDKHp5+UVdK/L3+e5Kz0ozU8aeScxt5J4WrEm1k6IXT/GgcBwy3VC/UCMsHzPu+gKSp UWNXsyeCSHhnWGTbMzfOobUE9rS0Qpc1BejJB3Ki7jRlwnq7JgaQxo8jdb+4kJm19lNm JDi3FJkRT9I339H0zFBS6J5iAWn9YxGVByXG0ic/QT3C5Tj9sC6jAyrNuC1mcKQffcTl nVVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=TM877k3d; 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 f4-20020a170902684400b001c3ba275321si924593pln.76.2023.10.03.01.08.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:08:44 -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=TM877k3d; 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 0C05A8243BD3; Tue, 3 Oct 2023 01:08: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 S239738AbjJCIIk (ORCPT + 18 others); Tue, 3 Oct 2023 04:08:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239446AbjJCIHg (ORCPT ); Tue, 3 Oct 2023 04:07: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 7AED3B3; Tue, 3 Oct 2023 01:07:28 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 DFD2F660735E; Tue, 3 Oct 2023 09:07:26 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320447; bh=ZWZu+iiWZeSR97TuxWAcPyCT2zWmqcsNlEZTasx6lQc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TM877k3dbdv5cZ3/+fzoBT0lguta5bDqCV9H8tQ8PNrG5rqShpGoZHosFKCqo+gR2 aNnRhEh910+mZEG615eL480UAWFDxh5mBICdi8AV1G2/xg53Q2C7SWF+7SmWfip1Mk 3q12j79ajrgx/XNulaWFbSKsJlmeAs34SBtQ7Rbz8u6zY48K68sA2uNRgIDumytrUa vnN34JOqeZOMSddzFZGcz9Oiw3GCGautxBvRG3pHJoUiegtBBD/DDk1ds/db79eaMP tF2MEa9LEcz3+IHiIXmLh++xqfhOqDLuGe9J63hN1PKcD6HAL8CG9SJd15m7vc4rRb zFQtQW7z+30Zg== 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 v10 27/54] media: pci: netup_unidvb: Remove useless number of buffers check Date: Tue, 3 Oct 2023 10:06:36 +0200 Message-Id: <20231003080704.43911-28-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:08:44 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778720990703221142 X-GMAIL-MSGID: 1778720990703221142 vb2 core tests this already so remove it. Signed-off-by: Benjamin Gaignard --- drivers/media/pci/netup_unidvb/netup_unidvb_core.c | 4 +--- 1 file changed, 1 insertion(+), 3 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..52de9b0af812 100644 --- a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c +++ b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c @@ -297,11 +297,9 @@ static int netup_unidvb_queue_setup(struct vb2_queue *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; 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]); + __func__, vb2_get_num_buffers(vq), sizes[0]); return 0; } From patchwork Tue Oct 3 08:06: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: 147714 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1928779vqb; Tue, 3 Oct 2023 01:08:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1lOlzEv6dc7M8EftYZXBbRKkANF/lQ4848O2DN6JRt8Baz9Xvj2mskwHNxkzHwZO+ydYe X-Received: by 2002:a17:903:2309:b0:1c3:6e38:3940 with SMTP id d9-20020a170903230900b001c36e383940mr14052794plh.7.1696320537841; Tue, 03 Oct 2023 01:08:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320537; cv=none; d=google.com; s=arc-20160816; b=ZGYUbEGQxPNoO7Y6cjNQIrniAdcwo2eBhXWpQ4qsGIGX9E7W5q664+yD7+1E61qser 944As5nWfps7hOiZaKLMs/mrgLzus0pxiWu3OKevLqKg32p9UWeZmMR6JuQtHGDDZr3T rfS/ovn8CiPtE4SmrUcmJlLg2fLrhqQjf7rpMyge4eI9V0IgYzWq439In5bMnuyDYVD/ vRN2EpRytd9ajgmpFyH2955RmB83s1yAlUzd/0nRyfWPG5V8wDDj/dLeZDoJVMfzlbog +ZlX/BrfjggOplb6tQMzz66iBGLzEdaEUZCM5gX6vlC9GBx10z4dy9OgJjJrHjGfzaWu dVrg== 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=ziV2hb4ohbfnjPJz2x4Pd4VE/hmi7lg5RaQe5DPV4Io=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=Mb3CW/bWHOklckSAA68vh8PnX08dC8GXiznnVOTFJIisk6A5NPrs09oXTjaR/c4Tyy dVa+QSjhOfvb/E/D3Rleqm19H9wfBpHYE2n76t5Q0v79P1WWykl5aJqpHIFjrfLcHfJ8 yoGbhZDrQq6bq6Gjtl6+u5s1u/xNaKWxgubC37lpKNRTyITuRhDQtXAOJ70gtyyZoI70 lr2Tl6DoK6ht9bNdfx3Cool947I+Zjde2UrReCBjTzoFlhaVJGxqMizBKgm0uWt98mGU PhX5jj/7ORd/LajwZV/9yub2322kvYHbU0oqsFcAjHyfL7a2QaFuNY9N7HsT1azkDRjR /2+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=STmpSyYy; 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 h4-20020a170902f54400b001c76e9f12a3si994108plf.575.2023.10.03.01.08.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:08:57 -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=STmpSyYy; 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 2121D81444F1; Tue, 3 Oct 2023 01:08:57 -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 S239755AbjJCIIp (ORCPT + 18 others); Tue, 3 Oct 2023 04:08:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239456AbjJCIHg (ORCPT ); Tue, 3 Oct 2023 04:07:36 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D24710A; Tue, 3 Oct 2023 01:07:28 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 6B0F66607362; Tue, 3 Oct 2023 09:07:27 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320447; bh=zysh0fIOtYpsYqIRMileMUIIdpZZkRuacJmXooFftR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=STmpSyYyHlwFkpXxLb/WqLEzqf//uE3Kj37tTlrx7Z3xznrZPmZ03hpIwzyIjou4d uY1gEDUs3oocNkREoyJsbc9kRT4XwppQMvEXqqqC6irLDxFGquTN2TuO113X1zUKwH 2uFYQrNiV7wDFP0Qd+Q0skR0QEQg/FJ/hq27cU9bVYGX8y+TZqLmTcqGpbhckO4SW3 EsoXNfyIH9n4Cfb+koeQdOhNNN3GLCXgKX7vcIf6nPIyU9kzfw18Tjlt9cORjX3QbU FEzwRxla4tW+52UTKK8eg+YRYkm7yKSov5+yezNgK8jwYKMWDIJEI+d/BH//JTk7FV mS+eMOb0uBSng== 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 v10 28/54] media: pci: tw68: Stop direct calls to queue num_buffers field Date: Tue, 3 Oct 2023 10:06:37 +0200 Message-Id: <20231003080704.43911-29-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:08:57 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721004502071422 X-GMAIL-MSGID: 1778721004502071422 Use vb2_get_num_buffers() to avoid using queue num_buffers field directly. Remove tot_bufs < 2 test because min_buffers_needed is already set to 2. Signed-off-by: Benjamin Gaignard --- drivers/media/pci/tw68/tw68-video.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/media/pci/tw68/tw68-video.c b/drivers/media/pci/tw68/tw68-video.c index 773a18702d36..c0a8257b02ca 100644 --- a/drivers/media/pci/tw68/tw68-video.c +++ b/drivers/media/pci/tw68/tw68-video.c @@ -360,13 +360,11 @@ static int tw68_queue_setup(struct vb2_queue *q, unsigned int sizes[], struct device *alloc_devs[]) { struct tw68_dev *dev = vb2_get_drv_priv(q); - unsigned tot_bufs = q->num_buffers + *num_buffers; + unsigned tot_bufs = vb2_get_num_buffers(q) + *num_buffers; unsigned size = (dev->fmt->depth * dev->width * dev->height) >> 3; - if (tot_bufs < 2) - tot_bufs = 2; tot_bufs = tw68_buffer_count(size, tot_bufs); - *num_buffers = tot_bufs - q->num_buffers; + *num_buffers = tot_bufs - vb2_get_num_buffers(q); /* * We allow create_bufs, but only if the sizeimage is >= as the * current sizeimage. The tw68_buffer_count calculation becomes quite From patchwork Tue Oct 3 08:06: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: 147724 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1929242vqb; Tue, 3 Oct 2023 01:10:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEsUqtgAxlpNmqdFRpPM2XzRuw99K7VlrdVSuQOOt7nH1XCBsp3nplzM78M44w91tXmI3He X-Received: by 2002:a05:6830:a57:b0:6c0:abdd:a875 with SMTP id g23-20020a0568300a5700b006c0abdda875mr15260036otu.18.1696320607129; Tue, 03 Oct 2023 01:10:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320607; cv=none; d=google.com; s=arc-20160816; b=ClnGTNHo2K+3UMW6Aj8X2Sa2qayNDnur5hy5U1UAl514TD/ixcliCxm0DeZb6rsu23 Gr5bF6WadKQatOyRJwdZn0kGTjK62W1vfXDYaFdVu+EB68Mdwl2GA30ClW4I0PV8eW+v viuT9nbI3mUuRFXACDzrUylbNE+bJCV8vaL4t0r3xLhxZgi9S4AFJlqFDQgflWASQtj8 Mk6FDEfpgt1ytej3e1CN5IVCzb6V3WIJNZ6r5k7vN17LzcHNSpPOetww0/y/ihCw7MAR p5V3Tg8+zshxrtAB1Yzbdg20bMX3SgvQTIo8zAUHvOVOBvY1a4LftLnAOvLa6Sm/XI6Y CQNQ== 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=QLYlo9XYgH6iBcNR/XOOMljUho1Rg9mdosWEHBzdo7A=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=QhKzajYQ2u+uNU25w0BLn30S/tSL5GhcDr62WxAhlI/NFJu14ERI84UTyCPaWYM47X OoJ9K6CQPcO1K3CzSRh43fS5npNOy6+J/F5XJHByJZZ6R5vxJOr37FGqded1jg0MVMOI lYtnfF02VtDBX8iePXbeJlfQ8WC2fpnP/e4e5iJVu2qTvWpJYb5EWLjn8qD7WLicf18I 2VR2L/a+OxfeTe4leuNuaHbHeKlecWoeSTUEw7CRZYCOuYky/Pd7DfKRiLLZEoeYi4Pm S5Pb7ckhDxN5ElyhzkutRj3PJg0aSNSASy5l1/iWSFjgsaCpCD6+Ns0kijn61Fwv4Ptv 8Cog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=j7Bq2gtV; 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 b192-20020a6334c9000000b00573f6ee58fasi912013pga.376.2023.10.03.01.10.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:10:07 -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=j7Bq2gtV; 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 559C6812280C; Tue, 3 Oct 2023 01:09:48 -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 S239762AbjJCIIq (ORCPT + 18 others); Tue, 3 Oct 2023 04:08:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239458AbjJCIHg (ORCPT ); Tue, 3 Oct 2023 04:07: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 8EB6810E; Tue, 3 Oct 2023 01:07:29 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 E97B26607365; Tue, 3 Oct 2023 09:07:27 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320448; bh=fLRtME703ZZcICdPkAIYRy+HHmsEI0CB5+N7/vWII0U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j7Bq2gtVDBhG9iQjYBJ80RtnofhcA50IlzJC0yCXhO2cOrKNN5UBe9owntP7hRBrI k0HktMWXpaon0mnJO+nbeTF28WFt5Z2T8r/Vd8fynoJN/5ONlerRvAIgxhQcHurtNn 8c1kAbmaR4PFESyeY7cvgkF0qFaz7GXe5Xrm3HoDGvUb9T89BhAU7/5yvIIUxAfvU7 pMERitgw0waPxTdRigtrOQGAlT5AZCB6YmWWmn9586VeI3S6KNjmIZIiWCvuW8kXRo 3oCgWettXC7D9M4flcyRJEtpJMqVoihVcxBDkhZFm0+DyOIl6EIJYNtNWJH19KKPbh AWH5LSiEkw/mw== 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 v10 29/54] media: pci: tw686x: Set min_buffers_needed to 3 Date: Tue, 3 Oct 2023 10:06:38 +0200 Message-Id: <20231003080704.43911-30-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:09:48 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721076997155634 X-GMAIL-MSGID: 1778721076997155634 vb2 queue_setup checks for a minimum number of buffers so set min_buffers_needed to 3 and remove the useless check in tw686x_queue_setup(). Signed-off-by: Benjamin Gaignard --- drivers/media/pci/tw686x/tw686x-video.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/media/pci/tw686x/tw686x-video.c b/drivers/media/pci/tw686x/tw686x-video.c index 3ebf7a2c95f0..74cd864365aa 100644 --- a/drivers/media/pci/tw686x/tw686x-video.c +++ b/drivers/media/pci/tw686x/tw686x-video.c @@ -426,13 +426,6 @@ static int tw686x_queue_setup(struct vb2_queue *vq, unsigned int szimage = (vc->width * vc->height * vc->format->depth) >> 3; - /* - * 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 (*nplanes) { if (*nplanes != 1 || sizes[0] < szimage) return -EINVAL; @@ -1221,7 +1214,11 @@ int tw686x_video_init(struct tw686x_dev *dev) vc->vidq.ops = &tw686x_video_qops; vc->vidq.mem_ops = dev->dma_ops->mem_ops; vc->vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; - vc->vidq.min_buffers_needed = 2; + /* + * Let's request at least three buffers: two for the + * DMA engine and one for userspace. + */ + vc->vidq.min_buffers_needed = 3; vc->vidq.lock = &vc->vb_mutex; vc->vidq.gfp_flags = dev->dma_mode != TW686X_DMA_MODE_MEMCPY ? GFP_DMA32 : 0; From patchwork Tue Oct 3 08:06: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: 147715 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1928816vqb; Tue, 3 Oct 2023 01:09:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFynQaLFGpqSsRNvZMImttOr6uvGjyf4QxuOP/TKzX+0HhoMRGDORivkZZu5faD/L8H4DmZ X-Received: by 2002:a17:90a:ce8c:b0:274:67d0:f57 with SMTP id g12-20020a17090ace8c00b0027467d00f57mr9290708pju.48.1696320544722; Tue, 03 Oct 2023 01:09:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320544; cv=none; d=google.com; s=arc-20160816; b=m38lDfg3sP7YnBMplBqAk7dz8RHidDw5vQgGTchv1lc6hbUCcIjln35dpHBSRH4Ja0 3UclNxs4ub7M/n2FK4Q0ei9Muhj5G8V5LndUxOdgI7p4LKUR4ugbZ/1i7h//ZD8H8P7J yefygUWy2W7tjTQ6Q3RZ0TwEX2KvrcX1enkpqwuKXWS3+K2Oi9SCMBFIszSnVMmT6uXe EVHvLYPSGIkuvllRGcDF+qlo12w+Q/cznLSELmm5Fixx2Ze+/rdE7xw9WOHqN39W2Frx 23yLu81OQBIRnDfbxwquSJT8K4yqaIz82ouxER8FfrS4j1I0JA9RA1Z1+vRfWAcSWH3L dSDg== 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=UoodlCaxuTXcklmCtS5aPdZ4FPUFAVvmvcbc+ooGj9g=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=Nr8biaWD/9VzONbCcpm1fZXLEFg01m68m5CRk9Cun2cPpy5Fqt72wLb82nAXxtxP5z SoOIMOV9ohclq7fzuECjtzsz40skm2YDwInU9VxIoXyz8FUBIV56HzIW8/8c0M1lG3Cn W4sAUO42VbKhM1Pth436bkkXQGRs1nY8GPIbTPxGXn+tPGW36jSvLSrCNX6KwinHNmGH BxMoN92IAilvQoFxdlfFjGIv/HL03+a6J+Nkvbsym/e/kFq5YGk1/bypqKCnm3RbEwMn TkdTFAvAyjNnLTV7PbyxRQT++CGerszrRVoN1XimuHXTxBBozkMMprswhugST0UicWFj T7Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=AqDc1rt9; 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 126-20020a630084000000b00553813c2df0si892082pga.513.2023.10.03.01.09.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:09:04 -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=AqDc1rt9; 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 67CE0822C608; Tue, 3 Oct 2023 01:09:03 -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 S239767AbjJCIIt (ORCPT + 18 others); Tue, 3 Oct 2023 04:08:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239461AbjJCIHg (ORCPT ); Tue, 3 Oct 2023 04:07:36 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 070BB111; Tue, 3 Oct 2023 01:07:30 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 740EF660731C; Tue, 3 Oct 2023 09:07:28 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320448; bh=e/xfKtsVji2TnuFJG4XtWU3Pf3eRSMy1R65/FhNyyWI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AqDc1rt9htd40mROtzfmBxcUyoXL3yt7PGxwKlNU5HKuKyZ2hoCk99rBpBZ11qgWp Q+3y1f22lolc8nnICwmFtb6ExZDZ7RztK4TfYtq1o3XePzj+ftjtwL6KhAql+/lqHM f5MCqr79kuPypDA1ZeaI5Ul1jmhdIY48gnpV1pCIcuYZBTRfVsHchXYIQVtrnyOx4x hniExmmA+dK6kqe0xJxkNGY6TMFWVF3yNOvoSTGpUk2UKZTqNZklwK37pZlOSFYVP6 pvpXU8qJ5SCkC+2PdMm6BQpAnw+kV1N1JjBSb/ztNyzjR/Y3OmYekRD1Ei3O/O5JyD NI7hRwY30a8uw== 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 v10 30/54] media: amphion: Stop direct calls to queue num_buffers field Date: Tue, 3 Oct 2023 10:06:39 +0200 Message-Id: <20231003080704.43911-31-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:09:03 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721011112906286 X-GMAIL-MSGID: 1778721011112906286 Use vb2_get_num_buffers() to avoid using queue num_buffers 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..49d641f60cc9 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_num_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_num_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 Tue Oct 3 08:06: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: 147719 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1928898vqb; Tue, 3 Oct 2023 01:09:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGKheJPYT9gy+tP9akJUMPMphxJf+h2/oWiSQRqXsqgBzcQoQyWPW6HY++36g7zKFoD4ZHK X-Received: by 2002:a92:c545:0:b0:351:1311:c282 with SMTP id a5-20020a92c545000000b003511311c282mr15869501ilj.9.1696320558723; Tue, 03 Oct 2023 01:09:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320558; cv=none; d=google.com; s=arc-20160816; b=dDXRlurt5T3xfICiVWOaogohrQIBilHS0CMR7FNvypmTb54A7xidlqIU4rkarI/OzM xRONJTesJygOrzP0ulOaC/9oN5k8IN2+DymgqrV9PPzO3Z1q26WhNFMub4ZPXr73SX3m Ji18vqJvFC6goBohv0txC6oTayfOOH8MqSQeEkbcehNXzLVchwlnBjBydPdegwMtZC1y bJ1mac5ZQkfk9DpO5h+u/rkzGMfZsiX4e5qAkqORKNUqcqUx28WH3jHpkYRcz1R8F9Iv Gp9hI194EoUEBMaZOyByaJf/Q42eHtON4K7K3TEdoay72N31+JHedElAUDnDti75MHkV aJeg== 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=UK+VcAPY+9TyTx7/wKc8kzzZwmA1/1INeTvGzghjuXE=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=bfKmpv94gk9WyA4W0q07Ms5kv7ydneXJeFR1XkzFMMJie1EAAVMP+iMLBiAYhGA5Cx PJIznS93qMur7iokRkJlK+CrhDqgEt0QE5rvNODJ+OehaXpEmgLS5VtviYv8oMqffd8t cwI1DK+tfYrYLV7b5bwktOagN+FMok8ih6uYp0wQZ6Zl9/ZRaCVCbW1QcUHQuAjpRhcH 5FsqCvEOwYvRd+e5Nf3EL9biCw6zW8e5aBSYel6rH9sDcrqqyHjmMdE04OCsxkOY9uqM 8+4U8aU/iLPZ3mV3CyFXbGlCUCEzPyX6g7pGX4mcXrod/Cp0B9daLx4wDU9VDYejdAWt 6pAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=HA2RIAoB; 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 k6-20020a633d06000000b00565e42df278si888738pga.759.2023.10.03.01.09.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:09:18 -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=HA2RIAoB; 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 DA619814E365; Tue, 3 Oct 2023 01:09:17 -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 S239412AbjJCIJJ (ORCPT + 18 others); Tue, 3 Oct 2023 04:09:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239467AbjJCIHh (ORCPT ); Tue, 3 Oct 2023 04:07:37 -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 80659115; Tue, 3 Oct 2023 01:07:30 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 F40526607369; Tue, 3 Oct 2023 09:07:28 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320449; bh=7ahm4bRo2QGnRbUv4/W2PwABO3vJuq3eWNYXbDqDhag=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HA2RIAoByMGpvUIqJYxtjI9p1yDsTJ33qXlbjyujOEEVM5r6CnssSgETWDp4xC++N E2/HLLIsJ8V1RfglnYWRXAl4V4o7Xo4HAWiU96mKqhbDZE0tqoCYK9rTVpfI9HqVrB vTTW6l2h1hSYeIuN4vBPZRxpghalCQVRPqxWdB8prlNviaaPDbwnSGSE2Pdw+R3SJR vmSjJdud8Vmv8pkHT1zqlYhryufNlSNHY7PCaD46FNTrwm/pipRXaDHTaWoDbjVkn1 OIQ+jrX6vrXDqzEF3jvEQ9BhpqjyM1s7dQ0sW/HExgkW4IETrTd1mSSS8xqtyTN/Wd P5GdSFQTpY87g== 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 v10 31/54] media: coda: Stop direct calls to queue num_buffers field Date: Tue, 3 Oct 2023 10:06:40 +0200 Message-Id: <20231003080704.43911-32-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:09:17 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721026150723595 X-GMAIL-MSGID: 1778721026150723595 Use vb2_get_num_buffers() to avoid using queue num_buffers 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 Tue Oct 3 08:06: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: 147728 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1929555vqb; Tue, 3 Oct 2023 01:10:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHkWtf8zoCVR6LB8OpFw9+2q79kazM4n3KByk4PsfcIYelqP1849z3MkK53I+AfNJJYpVZd X-Received: by 2002:a05:6a20:5648:b0:15c:b7ba:ebda with SMTP id is8-20020a056a20564800b0015cb7baebdamr12765516pzc.55.1696320649305; Tue, 03 Oct 2023 01:10:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320649; cv=none; d=google.com; s=arc-20160816; b=GzJ/qAKY0QD3R1QK1UqgdXDlLw3GowpEO3hXcfY+tQvo3qIJbMUQiK9c1xLRzNErag ybNWkHTJoLVvAIOYMGT3GCf2bKX2PLjUJPFwPZBs7XYXQCZfHypZQVwCx/WK4NnhgCz1 rDtoqfrefScm2LqLWmnRr1Tthi14i1APgbX+sw+jwQyrPyNE5O1ff9QliMzMtJYw4AAs ZMoGpCSEKHei90znXO0A0EqaudHqRYfSviPT54f8J7v7yId58PVVsdEzbCWApR/rYnzG uwZhQbvA7fuW39AFGgZnBoFTTjbNdKE1xEqyaW6le7QtNxO/ywQlAAuJvsTScyPsogrv +eoQ== 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=MdOb2KX2msFDwFRaeW1XMfIvboa2XixAo7//2RhoQss=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=sBeA759ayrYwziN5u7Di8HQMMSxc2/k9JqiQy8mAi1vPwsSjOn0LKty+N0JPjxBPk6 qJay7P9S+oEVF8ciFnIxzFhh5hQCWEaUbooypgW+NaGpF24eY6+uDpI/hp51uSVhej+v LLcZfpmkZxhb+Y/l225R4pIUBCWSwdJTIYc+9srFJcQjOIKSJ9FaIji+OZ6up2d4xQtX ow94zFRFeE+95IOsoVbU84gqhBdQuFaCvb7k00bK9i4yfAwTXgjm900QflpjXpgXiyp7 q9JT6ZFB5z4w194riErJ6LXwMZPAZta+pVgFjjT2M1fDXDj0oeTFMCs/zlss2sEU9Cu/ MNeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=aouIgfHU; 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 s132-20020a63778a000000b005777bea0b6asi873506pgc.859.2023.10.03.01.10.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:10:49 -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=aouIgfHU; 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 AB23C804C64E; Tue, 3 Oct 2023 01:10:24 -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 S239684AbjJCIJ0 (ORCPT + 18 others); Tue, 3 Oct 2023 04:09:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239471AbjJCIHh (ORCPT ); Tue, 3 Oct 2023 04:07:37 -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 2A74A124; Tue, 3 Oct 2023 01:07:31 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 808EF6607327; Tue, 3 Oct 2023 09:07:29 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320449; bh=MYUuJWbv+ZXdDCGlYiYfyK0RcIjAuLHGgJwZJ+iw65U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aouIgfHUpZ34XMtP486egUVR8pDgPO7TclzgII3ekgLNikTOpAI2UpcEAC7LLwSH7 D89yIlTrqRBJBVUgNynJm4jABlV9JXe8NwU3MkdLvU9JqpuHZwKHVSAM20+UN7E4my vKBNekMVXQKK9IE3rXLp1doGJvHzdnpJ1+xR+Dzymw6uxxaPDMrfW7jVt/vYpPO8K5 ars2ELVawrq7HymAUbvuO8AMNUOY+KSjHyZ6JDRCTCdefdAFOLaEDfCox2pFrE1LOb sJ4DaKDcGlWcLGARps36iPnYBSgpqrvOEyDft22Ox0RqD5qVZJI963hREHDylSiUhj JIsaci3tkkXQw== 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 v10 32/54] media: mediatek: vcodec: Stop direct calls to queue num_buffers field Date: Tue, 3 Oct 2023 10:06:41 +0200 Message-Id: <20231003080704.43911-33-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:10:24 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721121485044773 X-GMAIL-MSGID: 1778721121485044773 se vb2_get_num_buffers() to avoid using queue num_buffers field directly. Signed-off-by: Benjamin Gaignard --- drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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..8c580956b905 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_num_buffers; ++i) { struct vb2_buffer *buf = vb2_get_buffer(q, i); /* From patchwork Tue Oct 3 08:06: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: 147722 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1929185vqb; Tue, 3 Oct 2023 01:09:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG2R8BXvHhU93r3M/NjwblBw2GKx3Ayli2oOkY1G85nUq4tN6mqksYNAZc9W+rgyYus3CqG X-Received: by 2002:a05:6a20:1387:b0:14d:c05c:6620 with SMTP id hn7-20020a056a20138700b0014dc05c6620mr12713858pzc.31.1696320597418; Tue, 03 Oct 2023 01:09:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320597; cv=none; d=google.com; s=arc-20160816; b=s1JnvKm7HbbqTMeqKzVNyT7PbVW+PHuHHhGC3cFo9SlkLUseNc8iCfYgKhatC0+WcI T0vPCjhpiRBhckOhZYuRm2XrKo+fro/DK000ZsgxtzhgrHtt17KA+hemffW1i5Ebp5NY SDVBO+p2owSricKdrO1PSBuXfYIK9Il0CFJs0ZVEC21/+q8HTWmnDoTKR0Hnkf6vOIIE HWZb2cHex9cbnEurDt8kYc5hqHPIpezzRORWM/zU00L0D+MOcoFblC8XuzP45GPFk3/q 3GHHQr4KSnKw4nEpAkmS/0l3O/rtRg4hPsn/R+N5sHitf5SUHXP+rsuP0qtJMg/4SG7J M3Bw== 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=Nv+laEtgXgx7GQGb5vu27MK1wy6XGoa3DVnvbIWhVo8=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=G8jo9cpSNkfYEFYDJnX6Q+o5B9X/XSfqG4ds4clwZ2W8Ks20CVSf/y1DkbaLvevRFb bH04Swm9K6q+KmZIAC7LN78i1DoIiO8eD8XQiGejJy7bxo9HMPQIYg1n0I2aEbE/M1Xa 8NXwrOMSEXPT/xeI8PPeCeLNOq7qjUOeJWVpvcpKrYMT0ynAvLSXsKsSr4vu4oMQidaY EEp2ikM5hbqQhC7WCTl/Txfdp4OPGSgbdlcVHp1/KP3Bwb1V3Js4zRwKugjbMqr1RSeq EGeD6nAv3DbqoFeN0JFjHor6s75sv8ws2LalSlfMPwlvWuwLmjxhisSur0HCgIoESWBv zzKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=cc489ryu; 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 cu8-20020a056a00448800b0064f78c32b89si955954pfb.95.2023.10.03.01.09.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:09:57 -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=cc489ryu; 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 9E21180F668B; Tue, 3 Oct 2023 01:09:45 -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 S239316AbjJCIJT (ORCPT + 18 others); Tue, 3 Oct 2023 04:09:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239472AbjJCIHh (ORCPT ); Tue, 3 Oct 2023 04:07:37 -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 A073F193; Tue, 3 Oct 2023 01:07:31 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 0B6EE6607315; Tue, 3 Oct 2023 09:07:30 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320450; bh=39A9g3IYIYcRCFD80WoAPZ3565fBRND1EIIP73qIh+Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cc489ryuVXN6cO6oh7m3jteFhDZpIUSYC7bZOSDUgfwL33wSEveh6eRqn15Ib76dq UhIr+9IFW8BGajoODCoPk1+dEACei6cuwSbsMNKmAY1IMB7WWadUSzyIoTnXPHF/AT Zk//qkPrSHqJtAoEJcvDSY0m/EeTcQXFPwebaCLy8p6oioqiusjE0fOhsxXhNoCXzW dkqmeaRr1UeYcyH0cB7DDnbGqNj+iQWXgPJXpjKJRGsz52mWmlJ3ZspVvsdJk7cV5H X4DFJJBHE1AyQYLCsgjaFiORmDQ44Hs7+ym1QjuH8AwsDlGKk4UNr5Jz2KwHMHNxJ5 ws1cGmNMaY3Ng== 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 v10 33/54] media: nxp: Stop direct calls to queue num_buffers field Date: Tue, 3 Oct 2023 10:06:42 +0200 Message-Id: <20231003080704.43911-34-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:09:45 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721066529035452 X-GMAIL-MSGID: 1778721066529035452 Use vb2_get_num_buffers() to avoid using queue num_buffers 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 Tue Oct 3 08:06: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: 147741 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1930358vqb; Tue, 3 Oct 2023 01:12:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHHjvIpthrHmBscR0g/AxiWbu8VpVw0zNRBx6FxKeoX0mbH3haScTed24FIDX6KpggPWojV X-Received: by 2002:a05:6a20:f397:b0:15e:dc75:66af with SMTP id qr23-20020a056a20f39700b0015edc7566afmr11095998pzb.59.1696320757684; Tue, 03 Oct 2023 01:12:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320757; cv=none; d=google.com; s=arc-20160816; b=rTqhO94ny2GWB7M/c4sxYIpcHfu4ybPONfQDdeudvaZVi+6Ae3Vo3g5v1i7mA2FTAH UnbjZXZE+9uAkKQWVU1YAsZOCLrBAnainffEey/RI7RBXIPLM8mKgN5H1x40wvdziCIF oihw9Meug1HMivlYCwys1ljKV79mZVcDE3ST3yvh6pueve+3wYBNx0dFPW1rPFzsjc7d zEojP44eiI0jOSXCCLI5QOuDZ7jEgkaOq0OvpIumsin0jVbHExoKmHvFodBXxCsjkOBC EGqYkRcEThaNgrJ5bkEBF8WYif38VfE8gbxkuInDLoKZcKsynK7d/5VgiZU+eVM64rBk MYpA== 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=tBIVbW4WLQCv5IssZ+dxuNiWdgjFxHzgD99kxkSCzJg=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=FtaKGDbczaR+jA6WKCBP2BkwYOwfdTDWoWdEoylmezFrvk8XCCfIVJyN58LI351891 3V3DvYWDdeCZZrj2Kum/8hmSxxdWkeO3YIIVCW8FZnbdzGV8WqqBMqlo20+slV8JVhmw W4h8AsW6AiBmV1c91zzYZGqktLiCRjZZpq0b7ZyC4O4brFPKMBJRaLX+Byf0vWFNm1SY Gi6LrOE88Q8YYmM/nRqXpA0xGFZVB76Ekeh6tviBPDqYeq+UO7j2NjK0osG5afk8zY9r jVIMNoBydGAUr0GEiEFhK9D8LkieV1QZo5rwr2bc1eg8IBW8+2LNGqA5MZ5a6qKpOLNe PA1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=XlWAfaST; 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 g14-20020a056a001a0e00b006934390d0casi967552pfv.36.2023.10.03.01.12.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:12:37 -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=XlWAfaST; 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 177EF802A2A5; Tue, 3 Oct 2023 01:12:16 -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 S239546AbjJCIJN (ORCPT + 18 others); Tue, 3 Oct 2023 04:09:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239479AbjJCIHi (ORCPT ); Tue, 3 Oct 2023 04:07:38 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63500197; Tue, 3 Oct 2023 01:07:32 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 8998D6607370; Tue, 3 Oct 2023 09:07:30 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320450; bh=H1GfOB6mMJ44+7OCOGMjuo+dWjaU6UnQ+DdGWJmRb1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XlWAfaSTXg87NJNtSL7sLxzjqJul6QYunE6ahi5vV4Uwkf8VdGmA6gNwUHl4ixPNc 64TU1XdVJe/F/b9nWagYg5XjyPn8TM+ZxvU83snjR6s8wHawbsVbGsb+F/2NBWlBd7 VcLlJP92mf3JlSsS/7D6NBjoyMppFVRewnSWN8r7sFGQed4yJlfoQSBRNCiqYuE948 0Idvq+NpO8ypyvXkhZ6YYkFKQKKjiw8iDg5mk/mProNOEeyCl/3kqg4gSjYcPuYQXx YI1swEP1ce5FqXJJPH06LBBS2LOrOqnOZiI57yfHm7iGK9dXgsCM1Lj8Za4iaHCpD8 PiCRmsiXDx5Pg== 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 v10 34/54] media: renesas: Set min_buffers_needed to 16 Date: Tue, 3 Oct 2023 10:06:43 +0200 Message-Id: <20231003080704.43911-35-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:12:16 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721234523120129 X-GMAIL-MSGID: 1778721234523120129 vb2 queue_setup checks for a minimum number of buffers so set min_buffers_needed to 16 and remove the useless check in rcar_drif_queue_setup(). Signed-off-by: Benjamin Gaignard --- drivers/media/platform/renesas/rcar_drif.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/renesas/rcar_drif.c b/drivers/media/platform/renesas/rcar_drif.c index 292c5bf9e50c..bb84fc089d5d 100644 --- a/drivers/media/platform/renesas/rcar_drif.c +++ b/drivers/media/platform/renesas/rcar_drif.c @@ -425,13 +425,9 @@ static int rcar_drif_queue_setup(struct vb2_queue *vq, { struct rcar_drif_sdr *sdr = vb2_get_drv_priv(vq); - /* Need at least 16 buffers */ - if (vq->num_buffers + *num_buffers < 16) - *num_buffers = 16 - vq->num_buffers; - *num_planes = 1; sizes[0] = PAGE_ALIGN(sdr->fmt->buffersize); - rdrif_dbg(sdr, "num_bufs %d sizes[0] %d\n", *num_buffers, sizes[0]); + rdrif_dbg(sdr, "num_bufs %u sizes[0] %d\n", vb2_get_num_buffers(vq), sizes[0]); return 0; } @@ -1310,6 +1306,8 @@ static int rcar_drif_sdr_probe(struct rcar_drif_sdr *sdr) /* Init videobuf2 queue structure */ sdr->vb_queue.type = V4L2_BUF_TYPE_SDR_CAPTURE; sdr->vb_queue.io_modes = VB2_READ | VB2_MMAP | VB2_DMABUF; + /* Need at least 16 buffers */ + sdr->vb_queue.min_buffers_needed = 16; sdr->vb_queue.drv_priv = sdr; sdr->vb_queue.buf_struct_size = sizeof(struct rcar_drif_frame_buf); sdr->vb_queue.ops = &rcar_drif_vb2_ops; From patchwork Tue Oct 3 08:06: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: 147720 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1929117vqb; Tue, 3 Oct 2023 01:09:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHZWsNCyAas4cou+mQmItzoPPy5jREUU09RCJPyeP3t5Or08yi9VoaB1V7j/hSFW5rq+nA3 X-Received: by 2002:a05:6a20:2589:b0:14e:43b0:5f99 with SMTP id k9-20020a056a20258900b0014e43b05f99mr13307002pzd.52.1696320587123; Tue, 03 Oct 2023 01:09:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320587; cv=none; d=google.com; s=arc-20160816; b=tRD2XSnoav7pMMDO/wwhOgQ6ht8GGA9Y7fUuyB530bh/w4iyRjyy3e8CnswnOw7sc9 g3uST5tkgSIrkS3Dx2/sHEogL+Eg03lh7VgnzrdTA9+o7xJ8Gio6PALZZfh9OovfpNgD t6JdmolZp69tRKiHcLu9CLRTU/rPZngdnjI/AMZTdzs2oMrpnKFAR0616ag2Pc7S2sfb HljHDyhyIbDjmyPC5UTduGkUoyx4igGDWmYSnmLiOPNMyudVf/dBwiNExDQGLJhskNwT V1AClEugeqPzF5z0dptd3V1Xp2CILMREU+XlZoGBGmG+7Gu/5lu99HkFvLGqQHPZD1fd ShKQ== 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=wH2S6ZMYTSuMBfj/bSmXs0tW3siNrN6r9Aflom22WvI=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=OE/84ZDaF7FWSDx82EK7Pez/T+ZICR4Pr+56lJ7cH130AA3ZiWdRoch2hRvXOklT88 m9WAOO9RKUMuumMEK4A3TaeHhP7MpY4vAesS2TDCNKaGxeTWLpmHHLtwqQuK7qPSHHFL OsySyDsAHuvLW8W+b8nYv99e04m6r8QA9ETof+aTHk/fpmyFk5AvoT82aTK5/8IVnwir sWZMjep+onpnoKvv8WmNWetusxr7WS6Av2K2+RsE+3jgpLpX7UdKmRu2jELLDS0QAqIN jgwaAN/uY2SzEWeakmi2w9JuE7QoDh2KGFrxmCyad/exlhHSok6QlcuwTb+1eP3L6Mh/ s5Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Ous9vBJX; 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 by27-20020a056a02059b00b0056c297d163asi1024679pgb.523.2023.10.03.01.09.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:09:47 -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=Ous9vBJX; 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 546B6814E353; Tue, 3 Oct 2023 01:09:46 -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 S240003AbjJCIJq (ORCPT + 18 others); Tue, 3 Oct 2023 04:09:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239490AbjJCIHi (ORCPT ); Tue, 3 Oct 2023 04:07:38 -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 A1EAD1B4; Tue, 3 Oct 2023 01:07:32 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 139D16607372; Tue, 3 Oct 2023 09:07:31 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320451; bh=N6G4XfbycDnQUCOa7KuKCVKXaGxpGnmE1Di5qhpdnGM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ous9vBJXl4Is8k+bDEceHHXnDJnaHLB7Oorw/14K8akp/zMks9AqOP3lRsd126Kt9 +EjWLKH/FSWgP1v18KVxw/UzaiqPXWG6kbv88zNYQYAEVq1cw2wEEIwWcRfgCh88qz 0A+b9vCH5C0fzq2ZqoqC08JOCQJnBbuA7ywbPPQQGub8YfO8qkRVX+LbCTH4+Hclyr BqXIrPFwN9G8alXmaWZe52HupIqpPx7WgnsjaWFWRl92cX/pmM65fYxNwnCs9E9BVz mXW/gQPptwYNpMIXqPP9ti0tjIEugxEyaaOhVhRbyXJDbDlzn4kBpioDuhAqipTwoW 06/bGG5815YrA== 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 v10 35/54] media: ti: Use queue min_buffers_needed field to set the min number of buffers Date: Tue, 3 Oct 2023 10:06:44 +0200 Message-Id: <20231003080704.43911-36-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:09:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721055747775690 X-GMAIL-MSGID: 1778721055747775690 When queue min_buffers_needed field is correctly set vb2 queue_setup() does take care of it and we can remove the checks from drivers. Signed-off-by: Benjamin Gaignard --- drivers/media/platform/ti/am437x/am437x-vpfe.c | 7 ++----- 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, 8 insertions(+), 19 deletions(-) diff --git a/drivers/media/platform/ti/am437x/am437x-vpfe.c b/drivers/media/platform/ti/am437x/am437x-vpfe.c index 5fa2ea9025d9..80a74ee59bb9 100644 --- a/drivers/media/platform/ti/am437x/am437x-vpfe.c +++ b/drivers/media/platform/ti/am437x/am437x-vpfe.c @@ -1772,9 +1772,6 @@ static int vpfe_queue_setup(struct vb2_queue *vq, struct vpfe_device *vpfe = vb2_get_drv_priv(vq); unsigned size = vpfe->fmt.fmt.pix.sizeimage; - if (vq->num_buffers + *nbuffers < 3) - *nbuffers = 3 - vq->num_buffers; - if (*nplanes) { if (sizes[0] < size) return -EINVAL; @@ -1785,7 +1782,7 @@ static int vpfe_queue_setup(struct vb2_queue *vq, sizes[0] = size; vpfe_dbg(1, vpfe, - "nbuffers=%d, size=%u\n", *nbuffers, sizes[0]); + "nbuffers=%u, size=%u\n", vb2_get_num_buffers(vq), sizes[0]); /* Calculate field offset */ vpfe_calculate_offsets(vpfe); @@ -2233,7 +2230,7 @@ static int vpfe_probe_complete(struct vpfe_device *vpfe) q->buf_struct_size = sizeof(struct vpfe_cap_buffer); q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; q->lock = &vpfe->lock; - q->min_buffers_needed = 1; + q->min_buffers_needed = 3; q->dev = vpfe->pdev; err = vb2_queue_init(q); diff --git a/drivers/media/platform/ti/cal/cal-video.c b/drivers/media/platform/ti/cal/cal-video.c index a8abcd0fee17..924465b37e5f 100644 --- a/drivers/media/platform/ti/cal/cal-video.c +++ b/drivers/media/platform/ti/cal/cal-video.c @@ -604,9 +604,6 @@ static int cal_queue_setup(struct vb2_queue *vq, struct cal_ctx *ctx = vb2_get_drv_priv(vq); unsigned int size = ctx->v_fmt.fmt.pix.sizeimage; - if (vq->num_buffers + *nbuffers < 3) - *nbuffers = 3 - vq->num_buffers; - if (*nplanes) { if (sizes[0] < size) return -EINVAL; @@ -616,7 +613,7 @@ static int cal_queue_setup(struct vb2_queue *vq, *nplanes = 1; sizes[0] = size; - ctx_dbg(3, ctx, "nbuffers=%d, size=%d\n", *nbuffers, sizes[0]); + ctx_dbg(3, ctx, "nbuffers=%d, size=%d\n", vb2_get_num_buffers(vq), sizes[0]); return 0; } diff --git a/drivers/media/platform/ti/davinci/vpif_capture.c b/drivers/media/platform/ti/davinci/vpif_capture.c index 99fae8830c41..8a4cc62cf562 100644 --- a/drivers/media/platform/ti/davinci/vpif_capture.c +++ b/drivers/media/platform/ti/davinci/vpif_capture.c @@ -122,9 +122,6 @@ static int vpif_buffer_queue_setup(struct vb2_queue *vq, size = sizes[0]; } - if (vq->num_buffers + *nbuffers < 3) - *nbuffers = 3 - vq->num_buffers; - *nplanes = 1; sizes[0] = size; @@ -1428,7 +1425,7 @@ static int vpif_probe_complete(void) q->mem_ops = &vb2_dma_contig_memops; q->buf_struct_size = sizeof(struct vpif_cap_buffer); q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; - q->min_buffers_needed = 1; + q->min_buffers_needed = 3; q->lock = &common->lock; q->dev = vpif_dev; diff --git a/drivers/media/platform/ti/davinci/vpif_display.c b/drivers/media/platform/ti/davinci/vpif_display.c index f8ec2991c667..6fc32314cf9c 100644 --- a/drivers/media/platform/ti/davinci/vpif_display.c +++ b/drivers/media/platform/ti/davinci/vpif_display.c @@ -122,9 +122,6 @@ static int vpif_buffer_queue_setup(struct vb2_queue *vq, size = sizes[0]; } - if (vq->num_buffers + *nbuffers < 3) - *nbuffers = 3 - vq->num_buffers; - *nplanes = 1; sizes[0] = size; @@ -1168,7 +1165,7 @@ static int vpif_probe_complete(void) q->mem_ops = &vb2_dma_contig_memops; q->buf_struct_size = sizeof(struct vpif_disp_buffer); q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; - q->min_buffers_needed = 1; + q->min_buffers_needed = 3; q->lock = &common->lock; q->dev = vpif_dev; err = vb2_queue_init(q); 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 Tue Oct 3 08:06: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: 147750 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1937266vqb; Tue, 3 Oct 2023 01:30:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHZBOB0fyQJxLgjo2vHg/jgi1uh2GGjofwpqaPHo4OIO1eft5Dgh0r+XTQu3ShNQD/pNJL7 X-Received: by 2002:a05:6a20:7d8c:b0:15d:4cf1:212e with SMTP id v12-20020a056a207d8c00b0015d4cf1212emr3421000pzj.4.1696321857236; Tue, 03 Oct 2023 01:30:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696321857; cv=none; d=google.com; s=arc-20160816; b=eFGCuYHEUf61ZSvpTZyW6+UZK2uLVK0zN2VAW/frD6QlGSRRf2sX6WIBiNNKGrcEXm oOMEV+f2rbsvIQMdBI8F22YkO2nNrBXHNfD/tiJ3TWv0dl3Q6zhyjVxIGuYZr8qckaCg RbdDvpghG/wskc8h7kZqM1xw4HHBHylg/pkSeHv5szJKBvPXDeUBwldN8tq7ay2gCqE6 +IJRy7ydh1PhleUux+c3n9MT42EHqGbocMZNyPsqwNCsbjVRI2h0SAPecBi72hfSXqRc CEP0ehllVcR8RZjs5aElyJMRtyPE65H8FdMZlfb6vb4U/yYDwNqpQ2+TRpnW39QILQ7V 4OFg== 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=NmMJopZe+RRIIQiptzntRlZDNkaPuU35a0baCr9EGno=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=ZMaPDaMH/g518oxacA2vGcJQazCvFcevUi62xA9iRohJPEidfQScuvYzcIFQ0d3sgZ euDu1mEtmQQB8p/dREg/FUYMu5bx8euGwtPsFi5uSWWB4ZW03WQJHuNYhGhO6/8IEnMk C7L1mvUuACum0oCjnEWOJlH0lvJ3N336RtiynxJtX1c21MrfhUxJH91decz9OVZKF+2x ad0v15xFX21QmhQnxcx/XOadRbJOInqxUmDdNDfofjUw/dqcwaYDIfxwEkNIQlIHE/tZ rqGy3u9wQ9rslf11N98+7cmb/DypJpiseRh0dT96Hi2z66t2LdA1cTQ/RfH1zvw4c6hv 4GDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Thk1R8gS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id l26-20020a65681a000000b005789f94cd34si938234pgt.636.2023.10.03.01.30.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:30:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Thk1R8gS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 5BCA18023769; Tue, 3 Oct 2023 01:30:39 -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 S239963AbjJCIJn (ORCPT + 18 others); Tue, 3 Oct 2023 04:09:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239493AbjJCIHi (ORCPT ); Tue, 3 Oct 2023 04:07:38 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B33F1B6; Tue, 3 Oct 2023 01:07:33 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 948D66607376; Tue, 3 Oct 2023 09:07:31 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320452; bh=VdkA3cGwhU6mks7jszAxr2TxDs9YvsJ75Ji6rKZEsA0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Thk1R8gSBlf/qo9PXQ6My+Kj5qDw7mcgR/tG8cfnPR2LTsetF4K9UmYxhHB/AvjMH jxvupwOnuUFCc8VxkZdSOiH2WCV2YJoKEcTy0xg3NTg15MA0y+s1wTbF7ZdS2t2gNH 7zFGQQ/tf8MeLc8oNNMZ29WJoYZohQ9/yR2a+81SNCg/L2CYwgaDt9KJ3GJ95E/sLr t+4eUNeKWr2PX8AjL8gZ4NrX4bYfhBs3mwVVwPDWud63+EE3Tpm4hwu36Iy6kCsan6 baEbWdXy46LaO48uTCFUfvOlAnt6WlVFZFxz53pHRDy+go8stHCwR1dFJLz/6Ud6vT mMRwWld6WozhQ== 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 v10 36/54] media: verisilicon: Stop direct calls to queue num_buffers field Date: Tue, 3 Oct 2023 10:06:45 +0200 Message-Id: <20231003080704.43911-37-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:30:39 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778722387559028224 X-GMAIL-MSGID: 1778722387559028224 Use vb2_get_num_buffers() to avoid using queue num_buffers 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 7aa45d0fd291..41e93176300b 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 Tue Oct 3 08:06: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: 147727 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1929335vqb; Tue, 3 Oct 2023 01:10:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IECHv/wZwnQ7Q66ejm6b1wrriJRm7NfyAwrBadbtSLyS0yqvDgBAZOPQvKLYebEqRSHD4ZK X-Received: by 2002:a17:902:c40a:b0:1c7:5a63:43bb with SMTP id k10-20020a170902c40a00b001c75a6343bbmr8376535plk.8.1696320617278; Tue, 03 Oct 2023 01:10:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320617; cv=none; d=google.com; s=arc-20160816; b=wUp/Dl0TkFbP/gLErVxoG5BJgpz+BjUue+ci0/gs484RFe/EZcG/EAE2QlWi0cg6Wk 7oiBtQ93vRpWu6jUzDNKFIexlq52tkxcziCEhPsDRBjWPQKseu+VEZbzBwRgJEfPY5dM nrGJc6vhxxoTifzkvj5APmnZcN0iSba6+SCYM5I7wul6jV/ET0a2ih1zKl9nrIPiXOEl bNBZaI5UPVaDJcRz2A2NXure30m3Vpa3pYmamc/sBbFg0X73mduT/cRxxq4B+Gz9WRkT wOMgW9uu0sU2DRJ4QhZY9/7UcqU61Xs6mwbgcZ0D3VZnEQ/uiJLz31ZHBeq0FbsUz/Kk X/xQ== 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=u8zczsYwGqvaKRf+FC+QQEU2D+hBDhW9iNnNE/FqbdI=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=qHjIiYrbZP3DjesvhHAvzZTu7WAb1/NFBtDImalLbH7+G8DzFfK8hVhOpwLxFpPlpl OT6ri2aEHfpNV812lulqckrXqb+BGdiVhZ24fv/3KRLcQa1OE3bfqj5sEBqMFCxwaOM+ gRCQeulVp7xFPNDZ/DofgV+WvUGu5eiLKOp7yiZuET0dOfgMRXn1WsIjvMMRiNifVpBo vK56f2YTbuycTfmgOxvNmkAZRWk/oPCp/Fs9wLz/yxcQsXoJ9JzhRMusBnvtK+nxmcHR /Ltv2Jk52scK1asD9WT390JfQalbNe/is9owQTJBzXAJqPDetyGeM7JdPEz0VYA2Nyeh 32qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=iUpdLbPI; 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 s9-20020a170902ea0900b001c77674ea94si999186plg.434.2023.10.03.01.10.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:10:17 -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=iUpdLbPI; 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 89564825A982; Tue, 3 Oct 2023 01:10: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 S231251AbjJCIKN (ORCPT + 18 others); Tue, 3 Oct 2023 04:10:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239500AbjJCIHi (ORCPT ); Tue, 3 Oct 2023 04:07:38 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7140A9; Tue, 3 Oct 2023 01:07:33 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 295A36607377; Tue, 3 Oct 2023 09:07:32 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320452; bh=OKKl92mS0RJ4pRr3nE8UzbQQ6Z5/x2ee+cgMWQr4mBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iUpdLbPIaoG9iv3BMGdIcp+Sp1+HLj9fxMxAT+uH3iJ7e/SvI3LdLC26jgGseGnwB Cstkv+AYG0x1E2tbdSQl/du5jqDTnxJwpiQVzrFgYza9w9yuAklopEAgAcA8dmX8vL WkWPLLFiOmBKcSEZgkypoblcXqNJhQYnjCTlt8XNq5y9rbc77y0+c+vur84VQzs30h yiP4biDjL755rP8tpYCpTZlyojacjW1XastceeVkMfJtC3xXWZwkNgUCuyS6ul7fdL lTpi2hAELgYO1JSPcAOw/IwyvICdJ3bLCObsFdBqQICb72KfDkecUbrh/k36IaLwqq LKmN3oPvsRq8w== 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 v10 37/54] media: test-drivers: Stop direct calls to queue num_buffers field Date: Tue, 3 Oct 2023 10:06:46 +0200 Message-Id: <20231003080704.43911-38-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:10:16 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721087575787022 X-GMAIL-MSGID: 1778721087575787022 Use vb2_get_num_buffers() to avoid using queue num_buffers field directly. If min_buffers_needed is set remove useless checks. Signed-off-by: Benjamin Gaignard --- drivers/media/test-drivers/visl/visl-dec.c | 4 ++-- drivers/media/test-drivers/vivid/vivid-meta-cap.c | 3 --- 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, 18 insertions(+), 19 deletions(-) diff --git a/drivers/media/test-drivers/visl/visl-dec.c b/drivers/media/test-drivers/visl/visl-dec.c index ba20ea998d19..7aa70da72b97 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_num_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_num_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..0a718d037e59 100644 --- a/drivers/media/test-drivers/vivid/vivid-meta-cap.c +++ b/drivers/media/test-drivers/vivid/vivid-meta-cap.c @@ -30,9 +30,6 @@ 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; - *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..24c6dc896255 100644 --- a/drivers/media/test-drivers/vivid/vivid-vid-out.c +++ b/drivers/media/test-drivers/vivid/vivid-vid-out.c @@ -73,12 +73,9 @@ 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; - *nplanes = planes; - dprintk(dev, 1, "%s: count=%d\n", __func__, *nbuffers); + dprintk(dev, 1, "%s: count=%u\n", __func__, vb2_get_num_buffers(vq)); for (p = 0; p < planes; p++) dprintk(dev, 1, "%s: size[%u]=%u\n", __func__, p, sizes[p]); return 0; From patchwork Tue Oct 3 08:06: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: 147730 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1929852vqb; Tue, 3 Oct 2023 01:11:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFsWOV5RqoxGJyi1ns/pq4U+sc5vEzJOfOHMiETvWZhLk7Q3r6LtDAdhZkgoeHoK4RpYtC9 X-Received: by 2002:a05:6a00:21cb:b0:68a:6305:a4cc with SMTP id t11-20020a056a0021cb00b0068a6305a4ccmr15916131pfj.5.1696320693318; Tue, 03 Oct 2023 01:11:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320693; cv=none; d=google.com; s=arc-20160816; b=0Fp5qrMYkeCjazKLZcZEu2HHeqT/imO+x1x5PVtECj0FUBejNRl+wfyZZltZ/afOv5 gOLILxVkKjPyppibpQo0LfaK+aaLlqNLfkyZvTEWqa1T756cNU0Vwp+PYNaJqKN3MkJl /WraTQJHwJi7Fx1zfieV4eOk6Yd0MpoS9fnt4JJUKtiItX36WS05BgwApQNWmJkKLPfY dzTWzc40ys1YB00l9xPH/nuCrYlfKLiXn2Mc+X/98TGVMc3GdjX40RRPUeSrIRyKijzC ET+FMjZeAQLySh1CYLzYtilVnRk3w+FnwDtxTsD2NgifITJEk2nKehCpD1mvjILhVV7F gKUw== 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=cD8j3JYb+3YSWSQCgATdZE305FevL9wMDgQfebteqyc=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=Lccgdrf/qo1l5vOBG6Z1clydIOw7xxbISrJYF3XdKWc6nUduO/0JTZotQscLq5fm25 lHMBzuxRxyXGQkKDDAPQJUdV82+9u0sQhcDChq+MSKaDSW94RsAtjYx6xEOreVpVOBVe w/OB/Xe6XKx+GSeiAMjIr596Rwe4h7kwX20rxKAzHZy8L+oiIiBa0emim1l0i0nYQnqQ LUdSkqepH+ysA/+5PuQsKp34T7Qhr8AUXrX1YRLVMiEamhBu/8+k12hCaSMMhu/B5Zkv AG1alxk9YNMTH+Mhqmvvh7EgnaFhhxQinzeK6CqSymXgSbefrI129YUlXgjENZzLQcZf p9eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=FTp3Ij9q; 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 d9-20020a056a00198900b00690d25b198dsi984989pfl.103.2023.10.03.01.11.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:11:33 -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=FTp3Ij9q; 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 E3BCB809ABC6; Tue, 3 Oct 2023 01:10: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 S231302AbjJCIKS (ORCPT + 18 others); Tue, 3 Oct 2023 04:10:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239498AbjJCIHi (ORCPT ); Tue, 3 Oct 2023 04:07:38 -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 45E9DC4; Tue, 3 Oct 2023 01:07:34 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 AB12A660737A; Tue, 3 Oct 2023 09:07:32 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320453; bh=ipUXv7UJIHHhxRMQZmIK4W+snIi8YRwkVW1/aAA+P6g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FTp3Ij9qx3FklCKZlgKj2YKvWXUzApuFPn2mXDEOGcM7i2aNehDBbdmtAwN46GPVq 2NcNySXp+Upe6tPd4wr9XrrasEhX8F+U+uTFHMgfvbgLf6w0J+FHaI1EtC4JV68j+H m8e05lR8IxKEgOxfu+XarKdGTopOlTLjqOJ3dnbv5JuMsS5JmVCKzMoEqWp1M5VTpT DXeCdhpDLspnGEM76ID4+22BCKdGQ0UlxWWWod7XwzLmgIVJ5+Lxi352SjA2CUgh6p ItthGS48tiKucRUGF8lgcpDvAQFDJbxXl56Rx5yzEs6DoH7EFCbcUkViD6wA844leC v6JkzOMcMUH+g== 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 v10 38/54] media: usb: airspy: Set min_buffers_needed to 8 Date: Tue, 3 Oct 2023 10:06:47 +0200 Message-Id: <20231003080704.43911-39-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:10:43 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721167289636919 X-GMAIL-MSGID: 1778721167289636919 vb2 queue_setup checks for a minimum number of buffers so set min_buffers_needed to 8 and remove the useless check in airspy_queue_setup(). Signed-off-by: Benjamin Gaignard --- drivers/media/usb/airspy/airspy.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/media/usb/airspy/airspy.c b/drivers/media/usb/airspy/airspy.c index 462eb8423506..56bc1b23d39b 100644 --- a/drivers/media/usb/airspy/airspy.c +++ b/drivers/media/usb/airspy/airspy.c @@ -483,15 +483,10 @@ static int airspy_queue_setup(struct vb2_queue *vq, { struct airspy *s = vb2_get_drv_priv(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; *nplanes = 1; sizes[0] = PAGE_ALIGN(s->buffersize); - dev_dbg(s->dev, "nbuffers=%d sizes[0]=%d\n", *nbuffers, sizes[0]); + dev_dbg(s->dev, "nbuffers=%d sizes[0]=%d\n", vb2_get_num_buffers(vq), sizes[0]); return 0; } @@ -1011,6 +1006,8 @@ static int airspy_probe(struct usb_interface *intf, /* Init videobuf2 queue structure */ s->vb_queue.type = V4L2_BUF_TYPE_SDR_CAPTURE; s->vb_queue.io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ; + /* Need at least 8 buffers */ + s->vb_queue.min_buffers_needed = 8; s->vb_queue.drv_priv = s; s->vb_queue.buf_struct_size = sizeof(struct airspy_frame_buf); s->vb_queue.ops = &airspy_vb2_ops; From patchwork Tue Oct 3 08:06: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: 147725 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1929280vqb; Tue, 3 Oct 2023 01:10:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHNhRP95ZZkYafpo1Q4/jioQsE9aXFZqavK6IKl/puchCaTn9IkQAIsOxcBSFiKlSDcjEWf X-Received: by 2002:a17:90b:fc7:b0:270:1614:11c7 with SMTP id gd7-20020a17090b0fc700b00270161411c7mr3148733pjb.2.1696320611191; Tue, 03 Oct 2023 01:10:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320611; cv=none; d=google.com; s=arc-20160816; b=JXcKlcD7/ZxcX68faMmSDnA8P7yiBTnnDlN/JpmSM5TiVsXbT2dfcQWckdI7eG2fS1 TusEYJ0LbqIi3jGIlmrvvuR5zsDw20xitGHZCtO9MLeD9GoY6KD4RIIrBtawuztNlXcf eDvdO0W/TQ9AXC9InKwiTvZZMiaPf9xJ3ykzl5Fo2MXivwbgf0Hn3yXo87tHuDlDgQWZ sj4MCW+Mn8U3YxcKve1dsVSk1sxkUU64CMRsDVZd28vHezPFlSdzBhMKy+xvDnFdwgQl QULvzUei9mVEYTO302iPKWRE22McYDrmQbHeGrceRG2uUJiWVvC2QDu90PMhFhsAQPhB eOqw== 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=ER83NPi30J3seQDoSaM/YXD649vL/4o83t3smZbJ/84=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=Om87sEFN3ma2g/mBSyBduzI2NcoZFNj2pw5tI+5OClTkB5cka0kYpmeQ8kcKhgee90 E/wC9+4lBaQKIrUxSLl49Vht8EZVjWVLpRSEBRX1PWFtGtzHaWqO4NzQFUJwbxsCCudD xly08qvFnZ+TZh0oVTLl/JU2XtLzwM9e+6aFYTBIA6i97wX+7eiw5WF5CI0auunaAo6W RUr1Hdi/9E1rBW05czTXqffVacStrCzmGf732b184uLNt0bPbHeXeNfGNRqdUeDhIqVW FnFhu6dcjn+WWQ6XXccCMl7f8PDnFFbPmbsdpYVRmftNu4Uoes/n5ZvHqW6fBnA3kVh6 NXsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ZHl9kcaI; 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 nk13-20020a17090b194d00b0027460ba24bfsi9478674pjb.65.2023.10.03.01.10.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:10:11 -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=ZHl9kcaI; 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 77E29825A985; Tue, 3 Oct 2023 01:10:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239599AbjJCIKA (ORCPT + 18 others); Tue, 3 Oct 2023 04:10:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239408AbjJCIHk (ORCPT ); Tue, 3 Oct 2023 04:07:40 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 173F3F0; Tue, 3 Oct 2023 01:07:34 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 38D36660737C; Tue, 3 Oct 2023 09:07:33 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320453; bh=fi+Fxcs6m07q1y5Umer9Ad8BDnSh9/sSAfF+r67YVOU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZHl9kcaIjEE3QPHTc0x6G9y5uUi6tcSbCAI3vRU+1S3tcOuUoUQvglY1UkD8fJLaq UHwDtEdwOS8zYExRaEFzAfdlI6a5+zi2VlsfW1Eb21VWV+hvdLAKC1MX6cLxJj1Ahf MTGEXC33jOTxI5kegirgL8iL8GKatS85mlqKQEcn9kVNHOhqlk+cy8AUQdcPzGmUqx smAZxcTczGTF/8OKqTI6CJeBMu/tVodTcN9fQjV7tJJWjggUp4oL2GfmFGs7aaOyCR sgjIKPmtkRluKu4zcUsYc0OtMi4OD96aXDd1uc7o1QOB3al7N6fRF6NEttWjalhBuv smbqutsiK9nQw== 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 v10 39/54] media: usb: cx231xx: Set min_buffers_needed to CX231XX_MIN_BUF Date: Tue, 3 Oct 2023 10:06:48 +0200 Message-Id: <20231003080704.43911-40-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:10:10 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721081297043291 X-GMAIL-MSGID: 1778721081297043291 vb2 queue_setup checks for a minimum number of buffers so set min_buffers_needed to aCX231XX_MIN_BUFnd remove the useless check in cx231xx queue_setup(). Signed-off-by: Benjamin Gaignard --- drivers/media/usb/cx231xx/cx231xx-417.c | 4 +--- drivers/media/usb/cx231xx/cx231xx-video.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c b/drivers/media/usb/cx231xx/cx231xx-417.c index c5e21785fafe..fecdb12f5ef7 100644 --- a/drivers/media/usb/cx231xx/cx231xx-417.c +++ b/drivers/media/usb/cx231xx/cx231xx-417.c @@ -1223,9 +1223,6 @@ static int queue_setup(struct vb2_queue *vq, 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 (*nplanes) return sizes[0] < size ? -EINVAL : 0; *nplanes = 1; @@ -1777,6 +1774,7 @@ int cx231xx_417_register(struct cx231xx *dev) q = &dev->mpegq; q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; q->io_modes = VB2_USERPTR | VB2_MMAP | VB2_DMABUF | VB2_READ; + q->min_buffers_needed = CX231XX_MIN_BUF; q->drv_priv = dev; q->buf_struct_size = sizeof(struct cx231xx_buffer); q->ops = &cx231xx_video_qops; diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c index e23b8ccd79d4..26b593844157 100644 --- a/drivers/media/usb/cx231xx/cx231xx-video.c +++ b/drivers/media/usb/cx231xx/cx231xx-video.c @@ -717,9 +717,6 @@ static int queue_setup(struct vb2_queue *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 (*nplanes) return sizes[0] < dev->size ? -EINVAL : 0; *nplanes = 1; @@ -1805,6 +1802,7 @@ int cx231xx_register_analog_devices(struct cx231xx *dev) q = &dev->vidq; q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; q->io_modes = VB2_USERPTR | VB2_MMAP | VB2_DMABUF | VB2_READ; + q->min_buffers_needed = CX231XX_MIN_BUF; q->drv_priv = dev; q->buf_struct_size = sizeof(struct cx231xx_buffer); q->ops = &cx231xx_video_qops; From patchwork Tue Oct 3 08:06: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: 147744 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1930805vqb; Tue, 3 Oct 2023 01:13:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHs3ktpAxnIhx1zUrzrZ8mDQlyC2VlYXLJGRfr70GH6Xp556rphpE+dq6bUf/6S3Fl5i7W/ X-Received: by 2002:a05:6e02:130f:b0:34c:e6e6:80d5 with SMTP id g15-20020a056e02130f00b0034ce6e680d5mr12101684ilr.26.1696320823695; Tue, 03 Oct 2023 01:13:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320823; cv=none; d=google.com; s=arc-20160816; b=u/tmvja2XkHB5H6HixgYkeEdXNzJBah4/rv65Jx9CbKkoenNv3iW+v8lFykm5M5ptr cC4+RdcYtlge6Jz/4B73KhqwSe5hiKn/5sn2/LtL6zuIzNX6u1wXUtaEgAJFQRlT/CSx oM5EuhPXxm6LLajtI8fN2RGOQOV+BVsAeMhK6PCZi8I0bvhMjkQf1qeQPzn2gnm0VIJC N5Bt4Y6iPgAGz+IbjW328VgXKA3pXzJptDMw+OxYBAdQPVrE9q214sDm7fgA+iiVzKvg IPo8n0PaR7CNBns39g646nJev0OVNa2JzhuKAqaYYiHM0YmXtLZO7jU/F3k3BCO51D0s DiqA== 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=6Uo+DWz6nzURRzOrpiTlNauRcx9JlP212HftAuLBiRM=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=JAANH/sXsy3cBgonLgbEojexHIQ7dVNS88yjthnLXlViFVDS0oZN5weCg+NskCgZWS 1XnnwH/2AVCPq9+tjq1rXgA8SPI8K1u3Jma3vDnOoX68jhtNgT5U5KpSyR7O5XFajSso /EG/SKnSs5T5wWnXXh88d8Mhe9aC7luFVH484CRiM7J5YOP6opXIVW/SvhBrl3h7mxl+ yOB7AsZHx2gac/4WsZ44qHTggygKhzVAdQjlPUa3XQKUHQg2cJNJTBt0P4U+Og1w8uxw jNvn6eGsJxerZIoyUdk/yYgQsDRwBdcgl+1R819sHsZ/qiBsMf3qAoa0hRXkUzA1Ym/w rIMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=dXnbzTmp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id h63-20020a638342000000b00578b952e954si943154pge.112.2023.10.03.01.13.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:13:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=dXnbzTmp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 739A88125FEB; Tue, 3 Oct 2023 01:13:21 -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 S239696AbjJCIKD (ORCPT + 18 others); Tue, 3 Oct 2023 04:10:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239523AbjJCIHl (ORCPT ); Tue, 3 Oct 2023 04:07:41 -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 70782BB; Tue, 3 Oct 2023 01:07:35 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 B9F14660737D; Tue, 3 Oct 2023 09:07:33 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320454; bh=pDUB2yjXKjklQT9CTDtddlAytBql2bguZ0k3zUQQEeE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dXnbzTmpsOk4IgBNUvj38HbbxM7ZpTofbuwq30ClOKB8rTKBd0WrjLHS6NRhJs+3m RJCn21UOpSReIQKDlanWpHlfUDzjarItawFO2o2fJlsUaYTcI8j6Sur84i8kC/Q8Uv SiUjZAvehJ12Qr6C4UeWEZJtAx7fo19jcdwlKoCy8cKI6a0gGk1KCDppo+8Ne9Ytkf ITO5dx853jwq7VKQSEJc3auLPyqhCTRxoq5lng7jG9h/LoOCLh026JRWk26hptiOEM 9hEyDR/G6SRwrIXv+RRl9WlaNCvtcEH9D7h9bmVPTUe1ofBpFtrmBqiPdLV4+PvA61 Bhr4LcAXyiADA== 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 v10 40/54] media: usb: hackrf: Set min_buffers_needed to 8 Date: Tue, 3 Oct 2023 10:06:49 +0200 Message-Id: <20231003080704.43911-41-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:13:21 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721303623906897 X-GMAIL-MSGID: 1778721303623906897 vb2 queue_setup checks for a minimum number of buffers so set min_buffers_needed to 8 and remove the useless check in hackrf_queue_setup(). Signed-off-by: Benjamin Gaignard --- drivers/media/usb/hackrf/hackrf.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/media/usb/hackrf/hackrf.c b/drivers/media/usb/hackrf/hackrf.c index 3e535be2c520..2e856b20aa21 100644 --- a/drivers/media/usb/hackrf/hackrf.c +++ b/drivers/media/usb/hackrf/hackrf.c @@ -754,15 +754,10 @@ static int hackrf_queue_setup(struct vb2_queue *vq, { struct hackrf_dev *dev = vb2_get_drv_priv(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; *nplanes = 1; sizes[0] = PAGE_ALIGN(dev->buffersize); - dev_dbg(dev->dev, "nbuffers=%d sizes[0]=%d\n", *nbuffers, sizes[0]); + dev_dbg(dev->dev, "nbuffers=%u sizes[0]=%d\n", vb2_get_num_buffers(vq), sizes[0]); return 0; } @@ -1392,6 +1387,8 @@ static int hackrf_probe(struct usb_interface *intf, dev->rx_vb2_queue.type = V4L2_BUF_TYPE_SDR_CAPTURE; dev->rx_vb2_queue.io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ; + /* Need at least 8 buffers */ + dev->rx_vb2_queue.min_buffers_needed = 8; dev->rx_vb2_queue.ops = &hackrf_vb2_ops; dev->rx_vb2_queue.mem_ops = &vb2_vmalloc_memops; dev->rx_vb2_queue.drv_priv = dev; From patchwork Tue Oct 3 08:06: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: 147726 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1929322vqb; Tue, 3 Oct 2023 01:10:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFj2rpgXBUGBoQATENzW4RESLr6e2JPKHKOeoN+yPhRoWU+gHXiItMOH9dQWwDYX/C0NzjM X-Received: by 2002:a17:903:32c2:b0:1c2:193e:1126 with SMTP id i2-20020a17090332c200b001c2193e1126mr2787338plr.28.1696320616332; Tue, 03 Oct 2023 01:10:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320616; cv=none; d=google.com; s=arc-20160816; b=MOr8VO7tYLLJCAOoXiCyjzc7teEShxPub+xmgyaTche/F4DDu8H+ycf6OEWT4Mrf99 mysX0Iho8iUJl4yauJzSHq+RzcNwf8SGeQE9tAOLm6h5tk5RBePRvj4XD8la/LHQjqm0 DDHN4cltrMau5Vd0ZGHQ08nfc/5RKvmNndC02xFo9d3mG2JuY8463V0mj4tNcDJktt3L rq6Z13eXowoKueo8PVNTLZT39crAOYX68P7iytSnM0koZ/58J+oPIodFVjLBjhaUIDmJ vtaVxAnxJiqgM2xURB9R8ls+bxG34TSfkAGOrsZJdf/SYPrUb6aV0GJKHCMGQVrq/Otk TlwQ== 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=qTuPHPU4Io44nAdkQT6nBOAqUL8jchiAXtKAUc5aY3c=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=f+EUXFgQDAAMUOlAc/ZuJnlTcnSzJZHW87uKbXAqyvyXusDJvPB4puC9cdRooGhyax brBO4fpq0SExqJL3Aez74C/xO2ewJXvJZLotZQpgT7aebN4vhfDki/x5SbyhU7VmktaW bviQUQA0Y5UeXvsf4ePwhF/TA7khsRDgK0dj3L1h553eyX5gV42TEPUBYHUaVy/wsy+Y iaStwRw5yDhSdcvk6ArY55slNHsiGjFPmsTPmV8yZCfu+BxHRRyCF8mxxCTy/GGpopvO HL+vI6HKmnmohp0X+nhF1mq33icSPk4c07m2vxvKVYhhi9dKPLiGvgzkcl7Tm58zvd8V rePw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=KnnXCWtd; 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 e6-20020a170902b78600b001c5bb1f0cccsi879074pls.275.2023.10.03.01.10.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:10: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=KnnXCWtd; 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 49C2E824E780; Tue, 3 Oct 2023 01:10:15 -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 S239313AbjJCIKI (ORCPT + 18 others); Tue, 3 Oct 2023 04:10:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239528AbjJCIHl (ORCPT ); Tue, 3 Oct 2023 04:07:41 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 690FAF1; Tue, 3 Oct 2023 01:07:35 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 476FD660737E; Tue, 3 Oct 2023 09:07:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320454; bh=nwepyznt8z6pxABzkpFHR6clGV59kYVToyX8aj6cN+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KnnXCWtdllxU0DZMzzl8fzfEhbINPZZ/1/qStYUhK+64H4TVNwrNaNjNIhxLenM4y T5oTB8rImornc1k7g+Aa7oYLBOKapEiLJ163Tytr9r8P63uQAWm1LnP/EmoMxzdZlB F20gY/g6bsnpgewMb7z89Xxu/LA9fS6SG/NexwCK4sOHhxBgpoaD9baHBJKYDX6C9E L9lz0WUCsVxzX9epta9uooCYqnE3g3+Gk8egnveVyePCFj43lIQ25VRgl7s5RMAL4o oJJNafBHbp1d8v3w4AQ++aa2V/fHHFdLSogLnvOE5Kq8VurHTpa04W7VjzTieIwhRG HyxISeXk0z+KA== 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 v10 41/54] media: usb: usbtv: Set min_buffers_needed to 2 Date: Tue, 3 Oct 2023 10:06:50 +0200 Message-Id: <20231003080704.43911-42-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:10:15 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721086246648374 X-GMAIL-MSGID: 1778721086246648374 vb2 queue_setup checks for a minimum number of buffers so set min_buffers_needed to 2 and remove the useless check in usbtv_queue_setup(). Signed-off-by: Benjamin Gaignard --- drivers/media/usb/usbtv/usbtv-video.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/media/usb/usbtv/usbtv-video.c b/drivers/media/usb/usbtv/usbtv-video.c index 1e30e05953dc..0e9e860be47f 100644 --- a/drivers/media/usb/usbtv/usbtv-video.c +++ b/drivers/media/usb/usbtv/usbtv-video.c @@ -727,8 +727,6 @@ static int usbtv_queue_setup(struct vb2_queue *vq, struct usbtv *usbtv = vb2_get_drv_priv(vq); unsigned size = USBTV_CHUNK * usbtv->n_chunks * 2 * sizeof(u32); - if (vq->num_buffers + *nbuffers < 2) - *nbuffers = 2 - vq->num_buffers; if (*nplanes) return sizes[0] < size ? -EINVAL : 0; *nplanes = 1; @@ -892,6 +890,7 @@ int usbtv_video_init(struct usbtv *usbtv) /* videobuf2 structure */ usbtv->vb2q.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; usbtv->vb2q.io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ; + usbtv->vb2q.min_buffers_needed = 2; usbtv->vb2q.drv_priv = usbtv; usbtv->vb2q.buf_struct_size = sizeof(struct usbtv_buf); usbtv->vb2q.ops = &usbtv_vb2_ops; From patchwork Tue Oct 3 08:06: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: 147731 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1929856vqb; Tue, 3 Oct 2023 01:11:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGSVd4ArR/47CFicuI0Sx7rqp0MkhovcGC3D/2hlq9/c1YYPQHYfUrquQFQ62EQJw8MyjMi X-Received: by 2002:a17:90a:b101:b0:274:8330:c7da with SMTP id z1-20020a17090ab10100b002748330c7damr11796128pjq.28.1696320694048; Tue, 03 Oct 2023 01:11:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320694; cv=none; d=google.com; s=arc-20160816; b=Iv5u7lpWDs7D3rydAFk/QIHsbPRRtzokwVkRTGBOudFwMfUe9AFwvJqLae5YvOoJgj CamHk+8Q579RoaCFVBp9Y54H9zCQ3an1x3Qw/qBNphSTk/nTrqwbrDssAJGWYxF9m6PZ yT4QtUElAMdepxBIoPX0zAk253630NeJ+XQW/VGRzCXeGlSa6WgbTWLd6+BulpnQIjIS j/NGMfW2B68l+P2Vehsvyx9aL0WurUxjFNOSkoiE7fZYARuvC+zndU0RJI9lCEj6159D zjvMzAhaNxlK8Ry9fUwIpXG2snFNXZAH2ZEPdjPvoabEZ2biZmOhDcibtZ3eTmTzgiPs 19lQ== 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=bNduaqrku0Jg47XZY3aDAjxbyic9avl6NAHhoHeTqtU=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=Dx+NElFRn7G2Y8UyVkaT7IzJQzrbIHhfMbYzhKI4zCID5lU0ltt9lAVJDAcecF01Iz zF93iidCtbXLaQFtsk4XfQ89TSCEzAVVwGgBiy4WFk9KjQVyIVIE52EfTYX50Psbf5/m kh+DajllJXtDEUxDuqb0pYgAL8/DbldLbPGO552qPkqxPFDnVHAQq6gaINuAzNZlSjA2 FFH3g0UOovHDV87GctyANxeaALYTXznmHabgQQsMAHVvyY7V8U7Rz5F+dABCjrXXAVL2 ut3usLNvRY8emKJlchhaluutvX15GFu6Uw2hOBlUAC0VEeJ6sGEmpSc+nTaKDZjdGjsL BweQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=IuRAw8jE; 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 hg9-20020a17090b300900b0024e47fae466si873153pjb.180.2023.10.03.01.11.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:11:34 -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=IuRAw8jE; 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 4F6968029DDA; Tue, 3 Oct 2023 01:10:48 -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 S239804AbjJCIK2 (ORCPT + 18 others); Tue, 3 Oct 2023 04:10:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239549AbjJCIHr (ORCPT ); Tue, 3 Oct 2023 04:07:47 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEFA2EE; Tue, 3 Oct 2023 01:07:36 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 C2122660737F; Tue, 3 Oct 2023 09:07:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320455; bh=7wWHAQBKZERZL+C0cKr4cK8pX2+DM141L+tvnughidA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IuRAw8jEBFwvC2xOA/+4P3LEk57X/hk2wWBg5ouQdwIO4kYGW8RycUbB/FHSLpd8k EEprlsd3AcrU5Tc7K1iwvBPLNY9Fq5zfZw34tKHJ7mw18ifFBi8vxtf4XJVF1cAe+J YYQyONScYasy99wzVUpCZCfNNFh0RK2IH2T/s6fecMp0Ikm8cIg7pZTjsJ2aO9JptW BSZHx2y50l1EGbWT873dFgi+8hVdinYG2fV5CpIJD+11q7q7rSu+Im9CLGwsK3onnQ oSoQfRbHuA7aGOzhb6r885lDPCTLzPxRbX2I5maECc91KwYM97QnhwYFjNLQnvGmf1 KtBYwBT2ITOcg== 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 v10 42/54] media: atomisp: Stop direct calls to queue num_buffers field Date: Tue, 3 Oct 2023 10:06:51 +0200 Message-Id: <20231003080704.43911-43-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:10:48 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721167898986121 X-GMAIL-MSGID: 1778721167898986121 Use vb2_get_num_buffers() to avoid using queue num_buffers 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 a8a964b2f1a8..09c0091b920f 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -1028,7 +1028,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 Tue Oct 3 08:06: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: 147736 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1930040vqb; Tue, 3 Oct 2023 01:11:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFEHkdT5Vp5I4/4V6aidWTetZcc7kJzGNpmWoZy8Qhg9ZVTQCinnFaBUTwGDBQjVkaT07rk X-Received: by 2002:a17:90b:3781:b0:26d:d81:82fb with SMTP id mz1-20020a17090b378100b0026d0d8182fbmr10494712pjb.29.1696320716533; Tue, 03 Oct 2023 01:11:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320716; cv=none; d=google.com; s=arc-20160816; b=uKhEuHRaww2xmNjYAOtDy68FDFT7YE9OlKuFC9IfTB+ByuwB4uCbsuqIRyBWZgYpP2 f1A7wtwVHXnUStq2vb4jwQpA6rxdtRmM+r9u8r+iuJlmWYpbf58IMXEj6BXIuFeONvjq mvmOyp87Ao0MF4JpiboDj0cDkXRf6I9Or9Fz4Onn+ZC8UUfl6ueIBopu7RX3MUdX6J7O bBDCEYWQGSS72NRNIM7ndgzHqbOpZv2jHvGyX7dn55lQ/9ngbaBjM6sx+3O3CHVIAx5P afCfNSYDm0oF1/uOQeO6nkumqV83HLeeH1sol8OdRbND6R5/dj/hHEv1nwCYDtqLXtfz 5kcQ== 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=J/AixmhINWwllXoUE6TaGJLLvNPmGkjrDHeZV6N6Jrg=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=I9kHQN9yIH25QAMmHWrN/PgSe7WBandXT0OpuMdnhO1gf+pU2JvmIPVef/vGx4F5vD OzCKREM50OdRKpnI8ob+He8GlP52Z7onLAa3wNMkvVcRtr0npowEEE6oyGhERVRX416F DeF86E7vWkt/80eczdilWImQDy9HCZn9K73YfVHwaO2Z/L38+Oz2trvw5UXpoCEfUMZo QpzsH/0aufyEB1Fr8mHWCjnU3VizowSgeH+l7pmmn7j5Zr3fdhxHrJTT566nM6yjf3Am qCyzCk6w/PwwXf0fD1Sa6Atcyr4ZLG4lNkCdSnFCTsRlTKfd1TGabZMv9i3IBLlsDhmm sBIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=G0D2D57C; 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 w184-20020a6382c1000000b005777c70ebfbsi920846pgd.612.2023.10.03.01.11.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:11:56 -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=G0D2D57C; 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 D1584806E56A; Tue, 3 Oct 2023 01:10:49 -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 S239790AbjJCIKY (ORCPT + 18 others); Tue, 3 Oct 2023 04:10:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239545AbjJCIHr (ORCPT ); Tue, 3 Oct 2023 04:07:47 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3444BFF; Tue, 3 Oct 2023 01:07:37 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 4A6A4660735A; Tue, 3 Oct 2023 09:07:35 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320455; bh=bradh2DjPo+ZZEdsMUYFEpcwZsisivarvW4Ps2cAzgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G0D2D57CrGK1Vq6Jq3MCmxNDB3FLxQo+v75pWD0P0s3SCtGQUQcxEk9usaKmnDiys gSF2R3qROSVKa4G3IT6cdmCDuVcqzHumgPwCYUCZDXQ7v6IH4gyoPcJcxtNWZn8rTY kEB5lY0+on/qdl8+1CvBWeyqYJsAxMbpSPfrit0OSoxgLWqhg2JMgEX4CVLDrb7ZQs Y1ve9v38b4WmErZeO3BOjZS4TVBKvf2O83U4Cnve8g8CuuhRxXoqFmob4H5+tqtI/K l7B/Bl+AOo13I56EKpTlbxs3hOLHHilPqu3OryGEEFKLOHQ2hHJdGAFsRv+Vegk9PA ViiWuDk4JHlPA== 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 v10 43/54] media: imx: Stop direct calls to queue num_buffers field Date: Tue, 3 Oct 2023 10:06:52 +0200 Message-Id: <20231003080704.43911-44-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:10:49 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721191767176319 X-GMAIL-MSGID: 1778721191767176319 Use vb2_get_num_buffers() to avoid using queue num_buffers 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 Tue Oct 3 08:06: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: 147737 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1930044vqb; Tue, 3 Oct 2023 01:11:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG9wGvJ5PXZLMo0xAGp/+x9xXcFkYe+Q0aa/DjbNbdFh1c56BZPnwdlFkAJW3MU7HO2O0E7 X-Received: by 2002:a9d:67cb:0:b0:6c4:9ca1:f13a with SMTP id c11-20020a9d67cb000000b006c49ca1f13amr14363602otn.35.1696320717146; Tue, 03 Oct 2023 01:11:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320717; cv=none; d=google.com; s=arc-20160816; b=CgR7gHNIjGBH4I5K5Z2QioqnZDAKF2UdVAqEbyZc1MBzzzj06m1scZxClIWHwWxEF3 2lqyyPFMHKvUsfl0VPRe1l+5AIqNW1ylQYx03+yi8qsuShQgoNQQyEF5qdx9CZlWh0JO 7LuB9PBfcsKk5TMm46TOztqEjGPTrFw1pX8xyP9s7ryvMPofWXjal2/rRbXV2d+bKyow EfXR+U3Yv1qRIjmIOWvqVWtXchSl39sIPWIBscY62bukbAUCAvvZz+WlTiG703CWLxoT xb3eiAZHnbLeZBF3jJ4igd58TdpgjOQXHZwxFTuTtIRNbY5h+BChSbXfSeBhPG4WRibK 9DLg== 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=SO/5YMLEx27n+1dMpaToDiDOXkzTfj9EXlddDQjAh1I=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=RGzclUKoc1sIF4nml0UkRXLUOAMxKFgJCTJMWdx+t7EZXMpsPh5+/AEK4kg2F+9Wt+ P4ATmZfoVz4YWDEVSWbgFq2/eXcxJG41Zj+m7Dc+SwdQM0Vvs0gntmaGph7rfexsFHtO Ab5PdbsxdpiR/J2iV1l2YBOQ9OelcRqqSBdOVgYweZR0X/xtj9ou8ezzDIcjvFbsEniS SVrO9P8gdFwHzcJsqUHEVtIk/HmOzwSYbFTIPdClBxsGGG1+yKFc5jhCvUTP1LON9JKL oOoQu3ISuHwd7Xbust/GoN0LbeSx3UVYz2XKLW7KBE0a+cFFmILRE/QY4XNR212jj8JU SohA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=iynotduX; 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 x4-20020a654544000000b00565eccbc52fsi950486pgr.303.2023.10.03.01.11.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:11:57 -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=iynotduX; 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 B730E80A1442; Tue, 3 Oct 2023 01:10:53 -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 S239792AbjJCIKd (ORCPT + 18 others); Tue, 3 Oct 2023 04:10:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239341AbjJCIHr (ORCPT ); Tue, 3 Oct 2023 04:07: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 7327A101; Tue, 3 Oct 2023 01:07:37 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 C8ED46607382; Tue, 3 Oct 2023 09:07:35 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320456; bh=2yNWC1m2r+gRNh8g1TSEbdzG2+a2rAX6C09uBWYHlio=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iynotduXom0mnVSjzfCHN7eq8AlnPICk9dX9zUHVH3dkMwRUfDgFzoyokKtbgeGcp ofDBwNYui3KxYsdWHETWADoZzPCNPYVZhuSkATaXzpYgUIChLXIUxAsTlzCF1tJ0PE AQV6fLGjdl+rlvasdByqDp0czbNbE+lb+g7AeN1jYOUC7apYfrYNB8xV4/CjlKtq4T 0BOe/3XAy+Zdb5l66aaNGTFZMyETQrTUbHjbQpBVQT+2jc1NxbneMdx9C+qoPP5hvo t3drbsv4lELBNNXoVqcgjzNCAnV5nwyl2dmaDjjLhq4Sc3jMyI/C28xrArJfaGB4Va 8cfhcaS7e90kw== 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 v10 44/54] media: meson: vdec: Stop direct calls to queue num_buffers field Date: Tue, 3 Oct 2023 10:06:53 +0200 Message-Id: <20231003080704.43911-45-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:10:53 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721192067522274 X-GMAIL-MSGID: 1778721192067522274 Use vb2_get_num_buffers() to avoid using queue num_buffers 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 Tue Oct 3 08:06: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: 147732 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1929862vqb; Tue, 3 Oct 2023 01:11:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHGG++RBfAZCaPF/8Mop2cXMpJoZpurjiDokaPLB6csL3eXHuaXOtPlYV832E9jEI3PKBu1 X-Received: by 2002:a05:6a20:1008:b0:14d:cca3:a100 with SMTP id gs8-20020a056a20100800b0014dcca3a100mr10982006pzc.36.1696320696593; Tue, 03 Oct 2023 01:11:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320696; cv=none; d=google.com; s=arc-20160816; b=J7LEOnGOb68p+gQtAbTwqz8jYq0nAFyPYesh0osd/3YYbycu4HoExqC3iNlS3lznkA raQ4JukpKNeknfjHHp+aZSCpn1syGh1vbqDPXahe1cTffyjwTUG5v90Y5R6xhipo3Pxy wvjoy6DZQBhi3635hw4zl0GoVQY9FfnRpVtXFbOaj4fxEkHBleaa9AWLaVI/WOqWthkK u0otvqXpn5m+o6HvVqMr+fHCwjIdkFX5Iz7lOzBb0niEU4UI8f6jS+837YP078KcewPH Swqn/T4moWHzBJr2XcVncdxBWmrVR2F8wCNmEUmjJwMg9aB51exDM+t3/MDBo3YOtIP/ lC8w== 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=e/kWDIlxFNyUk5NMsbnFpDAvpdaqAjU87hGMJL2rUgA=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=OXBak6xLnry86+LOOex4VqOywxY0jaFNZp1oRq72lYaAnULQ2FZnIm/r1vKzPx3/Fm wh+HIPIKwRsd1gKGFyetfQSkYX0Rbl7z3vK+YgDSYqS4CU7xvllFBM0KgvR1Pv4rTUgC UlKVgKD+0roDc2HMuvMpc10mGT6SZF7lQaKB3ssBvDtQpKOVJxnB5VN6HAtVOoNbWfcP lYXwL3dgkIjiPiCj0DEZKvLOqP08GD43XA9t3hFnkcZZ77taQlQgkXO8L2mHdIpJj0sn 55hhTWECiyfrvRxp+4k/NLmcm/L+ytQ5nRanwClffqqXbQZt/NUBsxWLJ03pK00n41sG 69Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=MYmVTXQc; 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 bv6-20020a056a00414600b0068fad24a32csi934572pfb.27.2023.10.03.01.11.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:11: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=MYmVTXQc; 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 55B0B801D4A0; Tue, 3 Oct 2023 01:11:05 -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 S239251AbjJCIKh (ORCPT + 18 others); Tue, 3 Oct 2023 04:10:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239555AbjJCIHs (ORCPT ); Tue, 3 Oct 2023 04:07: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 1B1C2103; Tue, 3 Oct 2023 01:07:38 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 5624F6607385; Tue, 3 Oct 2023 09:07:36 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320456; bh=M07izUxouDHh4XgYCeqDbFmPp7eQPVY+TVAj4HO/ALk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MYmVTXQcZs8j1QIq/6gSHlTBIB25QQFV7oICT19Jp0gV78wSJ079xwodLyuvFl7jZ PA3sexZQQI3t6c2lx1E9JkNz2X/CnBZLJPMGSdCfiJO4CAm2sfQ588ZOP2Fnz6ISVF 9M2LjUIxtW7jfFEzXMyTqekkbcW1aoachxzn5JwQjGY3bIuIceSWWNcgAWf3RM0AIh j7/hDV3rrwXzHs7PW+KOKjrnixtvg+CaKYGiRU//qyYtluoaFtBKkRXTsxWsm689b5 jbJdh1Oxv31RvPN1tqHERO6Hc6qtNoH9bp4KewL+DBqC2SeED7x4zNEM0Cc+jLzuWk Jie09zIdBk9BA== 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 v10 45/54] touchscreen: sur40: Stop direct calls to queue num_buffers field Date: Tue, 3 Oct 2023 10:06:54 +0200 Message-Id: <20231003080704.43911-46-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:11:05 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721170812495433 X-GMAIL-MSGID: 1778721170812495433 Use vb2_get_num_buffers() to avoid using queue num_buffers field directly. Signed-off-by: Benjamin Gaignard --- drivers/input/touchscreen/sur40.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c index 8ddb3f7d307a..e7d2a52169a0 100644 --- a/drivers/input/touchscreen/sur40.c +++ b/drivers/input/touchscreen/sur40.c @@ -847,9 +847,10 @@ static int sur40_queue_setup(struct vb2_queue *q, unsigned int sizes[], struct device *alloc_devs[]) { struct sur40_state *sur40 = vb2_get_drv_priv(q); + unsigned int q_num_bufs = vb2_get_num_buffers(q); - if (q->num_buffers + *nbuffers < 3) - *nbuffers = 3 - q->num_buffers; + if (q_num_bufs + *nbuffers < 3) + *nbuffers = 3 - q_num_bufs; if (*nplanes) return sizes[0] < sur40->pix_fmt.sizeimage ? -EINVAL : 0; From patchwork Tue Oct 3 08:06: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: 147739 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1930164vqb; Tue, 3 Oct 2023 01:12:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGnWd8AD9nY22uRH35xFct31ca3a+2vxfsd+aTucx9gmoEepofmEa+p70fGLPX9Uuiz/Rc0 X-Received: by 2002:a17:902:724a:b0:1c1:f15c:976f with SMTP id c10-20020a170902724a00b001c1f15c976fmr11235490pll.26.1696320731298; Tue, 03 Oct 2023 01:12:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320731; cv=none; d=google.com; s=arc-20160816; b=df39uXeSeNNQw5XCR4uYwW+WuZ53Ce8LFlcgJntUVL3Zd4HKJ+yt5KDxHSRQOQH4h7 OZv7rua+ztEqt+ieTq5VCeMVsEXKjm421rTs/QIt2R8yyBr+83RmS3htTovW/RrLXa98 pJQjHxogL9u3RgHiZ7mixD3zrs5EF846YVnXcM70h94aUUaPCtNGNmO7VbPOGROUJTsn BZiOgoAcMAi2oH8e8hJaTdR2YflBgkx2KJESiyHAvHYqbnUKQqb6TwnjbaPS/dXnKkWO Vj+6/JyW8dMppAColCgJzsAozM/oBbddlTsJAcD528gfzU/guF29o7QinPMxZWA/Uq/S fz0A== 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=tNAbg+knkabZcIfZKYQJcMQ9aVj2QfkLtg7kl/Xz8lA=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=OYYhiT5SAUNqSlOYkwxM0tfsBiCyQ4L5EAjhogK/yOVrm6u5yxfCFb+MpcF599E8qY ljpcGJ2GFLiGc8HgZfEi+vpYI+28GaoZ7Gf0t2eB0/OHR2hQeQ9HVL0QKmiKgNLsUBHn svm6Vee90aDE16IaQsx8ced5enw9u4/L4nEThunGMpt0mU5NfH2zXVefKYpoEDytrYHS zpStr975gwabEti3K9xjQNDhlwXvubJlobNajKBHMBehSXAaUpDLJJk2iU/HHPXScOai tC8YxSCRFiPJV6PUAbhE71QsV5pRVpyUG5+ilJXzv/Ohg19eqxa097CdZ3O/PQs3zBhg nzjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=M44ioBZh; 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 m18-20020a170902db1200b001bf741231f7si984505plx.570.2023.10.03.01.12.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:12:11 -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=M44ioBZh; 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 26EDC8077460; Tue, 3 Oct 2023 01:11:46 -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 S239499AbjJCIKm (ORCPT + 18 others); Tue, 3 Oct 2023 04:10:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239584AbjJCIH6 (ORCPT ); Tue, 3 Oct 2023 04:07:58 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09161116; Tue, 3 Oct 2023 01:07:38 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 D67136607387; Tue, 3 Oct 2023 09:07:36 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320457; bh=ph7BpDmTndhVgQkibEyHEMgMXbFU1u8TVxC65OSPSxg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M44ioBZhEwt4ZQbAALO2XXtYqIDGCjGeVsmIoBks7uX9DDOhq8vUWkL5PGfjQVglZ 1+sPRHNS8dyXnQiakiWavVMU+UfU4V9x9Q5iFbyPHq1AXLmWM9PZQtfrIfdR6zz+H+ nzAjBiiAU3PJX2OitiWDAmvtVuxmuT47sLRz0CwXHRrPiYF+qu7NkdopQ0cVaymreP 7hd1ZJM4803LMbS3FvYju4wirdhfnaO4b//9sBjo5t8xECVF05/hHuWvS35dqb9Ivb Alpu7hyS0WYUujk7vlDAP56gQBjz/GwtSOH4v0W/euDtaia/xsmOwtku4DFdm2Stbr 0cAoRIKo+NhmA== 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 v10 46/54] sample: v4l: Stop direct calls to queue num_buffers field Date: Tue, 3 Oct 2023 10:06:55 +0200 Message-Id: <20231003080704.43911-47-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:11:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721207212554134 X-GMAIL-MSGID: 1778721207212554134 Use vb2_get_num_buffers() to avoid using queue num_buffers field directly. Signed-off-by: Benjamin Gaignard --- samples/v4l/v4l2-pci-skeleton.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/samples/v4l/v4l2-pci-skeleton.c b/samples/v4l/v4l2-pci-skeleton.c index a61f94db18d9..a65aa9d1e9da 100644 --- a/samples/v4l/v4l2-pci-skeleton.c +++ b/samples/v4l/v4l2-pci-skeleton.c @@ -155,6 +155,7 @@ static int queue_setup(struct vb2_queue *vq, unsigned int sizes[], struct device *alloc_devs[]) { struct skeleton *skel = vb2_get_drv_priv(vq); + unsigned int q_num_bufs = vb2_get_num_buffers(vq); skel->field = skel->format.field; if (skel->field == V4L2_FIELD_ALTERNATE) { @@ -167,8 +168,8 @@ static int queue_setup(struct vb2_queue *vq, skel->field = V4L2_FIELD_TOP; } - if (vq->num_buffers + *nbuffers < 3) - *nbuffers = 3 - vq->num_buffers; + if (q_num_bufs + *nbuffers < 3) + *nbuffers = 3 - q_num_bufs; if (*nplanes) return sizes[0] < skel->format.sizeimage ? -EINVAL : 0; From patchwork Tue Oct 3 08:06: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: 147733 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1929882vqb; Tue, 3 Oct 2023 01:11:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFUfNQGA3bHyUK3QzCLSoIjahbPxjZrErCjy4LbidGu3qiFifVmMAxZ4PgASKa7JjOJKZGO X-Received: by 2002:a05:6a00:1825:b0:68e:2c3a:8775 with SMTP id y37-20020a056a00182500b0068e2c3a8775mr15000167pfa.33.1696320698025; Tue, 03 Oct 2023 01:11:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320698; cv=none; d=google.com; s=arc-20160816; b=Gdwlm9PkTWXSauRV1cXIzH53Tu4W21rLjZiA0GV+qJn5yEcJWSHeQMaIOslFuw02Uf pkQfnDvYPoW6X9oO6HdUvrrvexTw86cU6io8BCsPL6rsnj3xkKavczUMZUmp2AKozZBj H/NvYb8sQhdE5VSJR1OdqY896fo9C9dNmwV35VuObAvKf07GLYOkIf0HxCPLKpwJRLvB buVLOzcph1dt81Pnn5gJud0T+x5AINP6bICbvceh2MfK1WONnQHc1fF/KA4XETwn5i98 VgcKCaUNstbH+XCb7/m+M54rrJ/sqLj9lM6inwGB3XOIYhj0yHmOcRA2AGjSLK+ttveV nT3Q== 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=VX8R6FNAbkZWYkueMBme92XT1wQcqt/mdQigvZGLeSI=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=xXikuZcAR6DiiKKfrhSXBLekixnp4GQBntOYfLYdrkniRm8vzp2B52ty+2llhcX4I3 W3p6Qufd5FYUojE1BWm+f92pXnaOTgQzgtqZGNHpaN+7McEn9yqSuLBXYzrVmbqNr9Fc UStrg3QdSivFQhqTk3xbfWaP/0mTz3DwQViGQFTzJibQdSSOBn8qtfbG1dBM6yifEqXl 62VItw/eYNisjily4iHjA6U0CanBTH4EM/sxWJbIBZCIFNDIXmy0qBR58DcCBu4YLvMC OUitEAb07xCLoBTSt1Ay783297tLTALjxFB2qXfj6ruiF4A+fh0FAEnVvsXspPydlWG0 I2BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=CeGOACJ6; 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 bk13-20020a056a02028d00b005859b1b34f7si926925pgb.862.2023.10.03.01.11.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:11:38 -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=CeGOACJ6; 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 786958153D09; Tue, 3 Oct 2023 01:11:20 -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 S239610AbjJCIKr (ORCPT + 18 others); Tue, 3 Oct 2023 04:10:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239350AbjJCIIB (ORCPT ); Tue, 3 Oct 2023 04:08:01 -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 832F91BF; Tue, 3 Oct 2023 01:07:39 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 63D8766072E6; Tue, 3 Oct 2023 09:07:37 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320457; bh=KSp/qlyb4qZpMVJTjYq3/CPJYCUJtKhZMjqFSVLO9ao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CeGOACJ68l3iNAs2qo3ldowsagtp3cQicupSSWr2Ye9NBptxqIknD2Qdj3nGICTHo zI+phreMwrpQh7Z+RsgOBSHdtVZkmmOxxSvHyqiYk5Tbd5acFCMXOEtjGYo2XNOu3B 3Px116X5jpfboXh1CZ/Lt5DDtj3vbnIPexTdgbPDyfusBRT4zwzbisHdUvwVQVLdor EDF5oGHdxdyF4+QdbWesfHWXG5e9xfyyJSfdqPHdm7olxMGFEB6pPPywRmlPImlfaY zsfDzeWuUQ3sNsy3btmCxLSOLe4fz7KwOBT+dhMF7zUqVQWSBVGQU8f9wckW7Ad0Em x4B54q5F8Q4VQ== 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 v10 47/54] media: cedrus: Stop direct calls to queue num_buffers field Date: Tue, 3 Oct 2023 10:06:56 +0200 Message-Id: <20231003080704.43911-48-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:11:20 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721172252898683 X-GMAIL-MSGID: 1778721172252898683 Use vb2_get_num_buffers() and queue max_num_buffers field to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard --- drivers/staging/media/sunxi/cedrus/cedrus_h264.c | 8 ++++++-- drivers/staging/media/sunxi/cedrus/cedrus_h265.c | 9 +++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c index dfb401df138a..88061310f815 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c @@ -653,8 +653,12 @@ static void cedrus_h264_stop(struct cedrus_ctx *ctx) vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); - for (i = 0; i < vq->num_buffers; i++) { - buf = vb2_to_cedrus_buffer(vb2_get_buffer(vq, i)); + for (i = 0; i < vq->max_num_buffers; i++) { + struct vb2_buffer *vb = vb2_get_buffer(vq, i); + + if (!vb) + continue; + buf = vb2_to_cedrus_buffer(vb); if (buf->codec.h264.mv_col_buf_size > 0) { dma_free_attrs(dev->dev, diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c index fc9297232456..b8b66d0d951e 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c @@ -869,8 +869,13 @@ static void cedrus_h265_stop(struct cedrus_ctx *ctx) vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); - for (i = 0; i < vq->num_buffers; i++) { - buf = vb2_to_cedrus_buffer(vb2_get_buffer(vq, i)); + for (i = 0; i < vq->max_num_buffers; i++) { + struct vb2_buffer *vb = vb2_get_buffer(vq, i); + + if (!vb) + continue; + + buf = vb2_to_cedrus_buffer(vb); if (buf->codec.h265.mv_col_buf_size > 0) { dma_free_attrs(dev->dev, From patchwork Tue Oct 3 08:06: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: 147743 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1930791vqb; Tue, 3 Oct 2023 01:13:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEiqA23iTHUdQWswPs3+KrfacpaCfj9mye2xusWbqH5mU0a+nSceL1zz9g7SXkTaA9wPLiS X-Received: by 2002:a17:902:bd94:b0:1c4:2271:55c3 with SMTP id q20-20020a170902bd9400b001c4227155c3mr12190964pls.38.1696320821297; Tue, 03 Oct 2023 01:13:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320821; cv=none; d=google.com; s=arc-20160816; b=poVxYxiDTwlvKAkabwcZ+0wvyriK0BZ+01ihDl8g2QDuaVOxxYyYNBOIdq/krwkZtp VP9rj7F2VGfI9Hvu9bN+E7ZKOOA0UWtSd5cK00SItys5/+jGNGm3f7wFGX9ep5LeIM7z F4qwpy9jF8A3N7BNGZTCkqR+LpAC06fnZ7F4PnlOMsxmoqFlnd4eUwEdlv0Tv5vvX1ta 8ndeJyTw4DgwqBtkTVOk1miP4y88+Gx9oAcKud9wUgPfTWgaqLctHkF1ffJAsvlOG0QP YZ9vyggKItPw/cF8csF5vRfnuLQlPlkwPePlDPh7NWLV1GinhUy/IgMFv7ZjRIufes7J 3lxg== 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=wDA22phgcQzkhMuwmjl1yY4drfu1OKCwHivGH2oVgkU=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=gCdAlvDbqVuRZlX+eEm8CM0vsipaAQrDcawKdTReWJ9UQOYNindWcqfrBHOHbjS2yL DfFLSA0QXMDOixqBioQ2MdgPTBZ20rjL4BEruGhxKAR+8KthCvWBejIvWAMCgiLY5Lgw R1HL8+/SbfRIZsPUprorh5zrjqSxLFzZu84nMD4NrB7kycTqBgiFI5x/TNtKeb8+hbj7 e5SW8BeYoGW7PtMz7CbxvcNypeCNUURjQ40TUyaZvOKmiIDt8FdFqbqBJLDKwHgC0fi6 We4USCEHopKhcnSjBNljc2r03CG7fcPlFkQ//2ck1PV0i85ArT7qr/Lx0LcBpIcgQnPb V2Eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=M3epeRo7; 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 km3-20020a17090327c300b001c413905d87si919509plb.49.2023.10.03.01.13.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:13:41 -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=M3epeRo7; 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 D9D368077460; Tue, 3 Oct 2023 01:13:19 -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 S239555AbjJCIKo (ORCPT + 18 others); Tue, 3 Oct 2023 04:10:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239353AbjJCIIB (ORCPT ); Tue, 3 Oct 2023 04:08:01 -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 14A8CCC4; Tue, 3 Oct 2023 01:07:39 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 E1E0E660738A; Tue, 3 Oct 2023 09:07:37 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320458; bh=xoGuB9BqmG5292CiK1lPMwRIslKTljuiyBog3GEPqdU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M3epeRo7idthRIkC77R8NXH8vtYvFbZRowl2OSrBqZLi/rVfVG91spufAYXsEwrEw 54h9V3+diJdFyZ3n7vg9LgnHHFbE88LtTCGiBGPB9lrj/K8iP6FOrYuU5mW9n98Xie Affli3/ItOCO9a5UPj13mOPlKAuMQSZmtCMvoW6smc6dfSZxTVx+jbVHeKLbEpWJV+ 0lqgo4JW6LOrFt9+GFzLkTL6CM/ToS82cxAhpFFHIyfVwiZjwi5cAgx5Ublz/e+3zE enEcuGdzFdQ7FmvduPuZ+oQo1gxv1hTAuFNiiKWOWqhJBPSr20HyLoIsReON589FCR jdNTycXzJVSlA== 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 v10 48/54] media: nuvoton: Stop direct calls to queue num_buffers field Date: Tue, 3 Oct 2023 10:06:57 +0200 Message-Id: <20231003080704.43911-49-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:13:19 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721301559829976 X-GMAIL-MSGID: 1778721301559829976 Use vb2_get_num_buffers() to avoid using queue num_buffers field directly. Signed-off-by: Benjamin Gaignard --- drivers/media/platform/nuvoton/npcm-video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/nuvoton/npcm-video.c b/drivers/media/platform/nuvoton/npcm-video.c index ac8d73b794d3..29b3c55f5396 100644 --- a/drivers/media/platform/nuvoton/npcm-video.c +++ b/drivers/media/platform/nuvoton/npcm-video.c @@ -393,7 +393,7 @@ static void npcm_video_free_diff_table(struct npcm_video *video) struct rect_list *tmp; unsigned int i; - for (i = 0; i < video->queue.num_buffers; i++) { + for (i = 0; i < vb2_get_num_buffers(&video->queue); i++) { head = &video->list[i]; list_for_each_safe(pos, nx, head) { tmp = list_entry(pos, struct rect_list, list); From patchwork Tue Oct 3 08:06: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: 147738 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1930077vqb; Tue, 3 Oct 2023 01:12:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFQbjrk4dUJSecXsZURWdXeWr4bZjZGnWJrcqK6bi9iFu7YuCnBLXk/06lmz4/jNHlzW7pN X-Received: by 2002:a17:902:f54e:b0:1c5:d747:a124 with SMTP id h14-20020a170902f54e00b001c5d747a124mr16975012plf.9.1696320720605; Tue, 03 Oct 2023 01:12:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320720; cv=none; d=google.com; s=arc-20160816; b=HNOk+N0tfyiGrn3F+fqwasnFfIJnrehUhZQ3mZ8T/5r+L/pvSpvEhqxhbop6t/ykhx R75D5D0PWLuIBStj9L5/I+ByA/DyJ+rLxR8AY+Wk9X7M8XoIspBaO3iSw1OmZT21Cy7r JGbNFK3r74/VgL6wNsgQON+Fmmvo2bvmNfRJx37TTdXx7aw0h93z/DeFQi0H3iuYBFgE 4FrUlD5HoXvVHnwU4DTcfdXw3WZoiYdf+ModegoCMGVZjE3fqUI9kG0V7AjQ4fGEipTU /40ADdpHMx/xlKhGnodVLRuF3yL8MQPsD/UWW81W2D5G1DZNSxqtGL1VOHaSATDNOmWU gClw== 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=Og4LlbJBiymUpAzpII335idKUT/YD2hVLoI7j+fK+Do=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=U1bKRxPcJyOBje8pIGskF9uWiS32/gNMaoWWLrVFtnvwammOGqwZsEsKO1VZwLbqQt NML5oyyq/+Yh5vM875mVN0y8aL55lRpLJpx7J9+VWxG0R+md5VDQJg6+JBaKFgkoFwVq S2L/8FWeTcNDXRB86ZHYUUb6pBUT+OTG1fvg1uD/IQ/9sHXkqwdaWex6fFiY/mqf6bm3 It6O2MjdhuR8VuFbBh8Mg07pJjsIesNghFIDK2CVIE9Jr2oRLLuu2BlaYtXl0j0abs9u z2M3exIq6Xlm3rnlFekI6ucqOFR7JXN5xoCo6GWbVUP/YQ7abmtg3JVtSD3oADyml1Lq TeBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=O2cJokiL; 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 r21-20020a170902e3d500b001bb9370760fsi902281ple.90.2023.10.03.01.12.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:12: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=O2cJokiL; 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 882E680D240D; Tue, 3 Oct 2023 01:11:47 -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 S239438AbjJCIKv (ORCPT + 18 others); Tue, 3 Oct 2023 04:10:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239603AbjJCIID (ORCPT ); Tue, 3 Oct 2023 04:08: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 876CACCD; Tue, 3 Oct 2023 01:07:40 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 73F44660735F; Tue, 3 Oct 2023 09:07:38 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320458; bh=wB4sQiMR9YdZLlurPoJdXQiGaX0CoGGpXiBFK9+XFCI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O2cJokiLRxG/YD7xdQKkS1vBqzB4psIO4k5MD3aEjjDk0Jh4oq75A77DkV8PChVC+ 0ixtP0ze4Cyw99Alaby7ILg3eVsKBcQ8iuz0RhrMWC1RkTMoZ2SV+4vU1ZJhEQh2ZS BSfHaRoDF8ROJuxk14DG+Jqm7ys3syfYpMKJ7pUFM0LPKCXNk5T5YhgdiCJMkUcIDu 6KrHXI66QTEpSiOrzOc+wTpf3DUbR2LYwLoUL8EywBAduEz6tK/vVhRorxA1cY2eWi 64aw7OcnNoJw4wo5IsmQ9vtjRL5+VmQ17XZVqUcrjn2r3fbM4MAkKLCBJxBplSN+c8 dlamxslWhVT7Q== 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 v10 49/54] media: core: Rework how create_buf index returned value is computed Date: Tue, 3 Oct 2023 10:06:58 +0200 Message-Id: <20231003080704.43911-50-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:11:47 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721196115043622 X-GMAIL-MSGID: 1778721196115043622 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 | 21 ++++++++++++------- .../media/common/videobuf2/videobuf2-v4l2.c | 20 +++++++++++------- include/media/videobuf2-core.h | 5 ++++- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 62e987ad9b33..21ea096864a5 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -441,15 +441,21 @@ static void vb2_queue_remove_buffer(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_index) { unsigned int buffer, plane; struct vb2_buffer *vb; + unsigned long index; int ret; /* Ensure that the number of already queue + num_buffers is below q->max_num_buffers */ num_buffers = min_t(unsigned int, num_buffers, - q->max_num_buffers - q->num_buffers); + q->max_num_buffers - vb2_get_num_buffers(q)); + + index = vb2_get_num_buffers(q); + + *first_index = index; for (buffer = 0; buffer < num_buffers; ++buffer) { /* Allocate vb2 buffer structures */ @@ -469,7 +475,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory, vb->planes[plane].min_length = plane_sizes[plane]; } - vb2_queue_add_buffer(q, vb, q->num_buffers + buffer); + vb2_queue_add_buffer(q, vb, index++); call_void_bufop(q, init_buffer, vb); /* Allocate video buffer memory for the MMAP type */ @@ -812,7 +818,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_index; int ret = 0; if (q->streaming) { @@ -898,7 +904,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_index); if (allocated_buffers == 0) { dprintk(q, 1, "memory allocation failed\n"); ret = -ENOMEM; @@ -972,7 +978,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_index) { unsigned int num_planes = 0, num_buffers, allocated_buffers; unsigned plane_sizes[VB2_MAX_PLANES] = { }; @@ -1034,7 +1041,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_index); 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 a4ebef82d94e..6d9f1be41a19 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -808,11 +808,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); @@ -1040,15 +1045,16 @@ 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); /* * If count == 0, then just check if memory and type are valid. * Any -EBUSY result from vb2_verify_memory_type can be mapped to 0. */ - if (p->count == 0) + if (p->count == 0) { + p->index = vb2_get_num_buffers(vdev->queue); return res != -EBUSY ? res : 0; + } if (res) return res; if (vb2_queue_is_busy(vdev->queue, file)) diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index dffb9647d4d1..d433bf84e30c 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -803,6 +803,8 @@ 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: index of the first created buffer, all allocated buffers have + * indices in the range [first..first+count] * * Videobuf2 core helper to implement VIDIOC_CREATE_BUFS() operation. It is * called internally by VB2 by an API-specific handler, like @@ -819,7 +821,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_index); /** * vb2_core_prepare_buf() - Pass ownership of a buffer from userspace From patchwork Tue Oct 3 08:06: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: 147740 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1930243vqb; Tue, 3 Oct 2023 01:12:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEwLtbCcPsZ250bbDac78cPtJhnQmRGOWOETASm7kL93lRlDoaBrm6UMEyGtLOlOxQ6jwND X-Received: by 2002:a17:90b:1952:b0:26f:7555:76 with SMTP id nk18-20020a17090b195200b0026f75550076mr11334698pjb.11.1696320742180; Tue, 03 Oct 2023 01:12:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320742; cv=none; d=google.com; s=arc-20160816; b=HoDnev/IkVyLV/Wnjal88BSxL31jurnFxHu+z+IwQsVxbgbKfhIK601FVy1Y4r00s4 x8iXFiiH2W7BJmLBic/RdEA8rJkMVsiznAMGLN43fOWkrQrO4sXqJbI+m0XCXIFXx9xJ /7FhIrWUjBpPA5AXI68T0OGzR0XGdhd+YDkQd1AyA8JgX1I38pKzSMZSRaBjZFu6FDHz 14aKJJIdD9Hry3OK3zMa+ScdD5xLXFBfXOMD3P4+jn/R+yeHyBz+fEIgOeEPiswZH43G 5U18HndS1Ej48hgu9zPafUN2tdxPg0x4LJZT+lFBWQ1juLRApstHkIi2DsucrNLtoovW 0uoA== 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=JzX7mtTn9J3A+DbMbIEZCVlxGOOoZppq+ug1JprwZQM=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=W1WJbJruaXerFZoXC4B4+TSZEkjNzXij9RWQK1Rvt8eshbVZhNkLuT1Oyr5fMxplRv efmA0SisjCebh9/Uz7WcoOEYVyKMOKZsn9561m/edJvNMhr8uyk6vfmvXHkbVPDV3y/o GrulXP23z5GOVU1govHr3xYa94/1py+Kb5sxqtQNGU0abxtCGvKqQfCeoiwuMvELNaO7 GPjgU4uc/3b7ZDnNuJwUfiCIuxXgZ4xpAcc4nA1c6YNEMDGTkQ9LWksSD47VzVAuDgJQ 19QbeyrzbrLLrX0J3O0gk3poND+cZ3IQZAHTK5mX8Cj94Occ/N04P8EGsDFxPElzla8L gkgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=UeBkkJ4b; 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 p15-20020a17090a748f00b0026c198d8182si9638922pjk.105.2023.10.03.01.12.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:12:22 -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=UeBkkJ4b; 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 E74AF8028B73; Tue, 3 Oct 2023 01:12:01 -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 S239928AbjJCIK4 (ORCPT + 18 others); Tue, 3 Oct 2023 04:10:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239605AbjJCIID (ORCPT ); Tue, 3 Oct 2023 04:08: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 874C8CCC; Tue, 3 Oct 2023 01:07:40 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 F32AC6607366; Tue, 3 Oct 2023 09:07:38 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320459; bh=E6zPaaDAW6kiwZqm2FWTBZy7hyGfz/7igqSRFzSXR1c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UeBkkJ4bZIc7EaxrQcszaBZloGPb+hUTGjkwoCak3aNNctYdtFepLQaESI5rpS2Wc 3MP0JD8U6a+XghRS+FcpckNYOaUf05D1hvfTNURIn5tTO2LKdYS5ySGu/RMidvdxeH cH4B7lU3KHw/izmTaYGNk1P92tqqS7B2roBd3/97yuzM9u9mT4mFiYP+y9JX+oPPCi uOIg4lE9bUWxq9cT5wyj1TDpttF5ZgsapaYnDrDaGsZ7V+CBlrewcPfEb7ecLD6K2x 9VUwkp2xJl9sGi70D4Zcexm3Ki/bGyoOSyCTaeneBYiG4vfaUUDmRHVEEZXVOrW7Wu L5wrtOOmC9cWw== 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 v10 50/54] media: core: Add bitmap manage bufs array entries Date: Tue, 3 Oct 2023 10:06:59 +0200 Message-Id: <20231003080704.43911-51-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:12:02 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721218475605595 X-GMAIL-MSGID: 1778721218475605595 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 | 43 ++++++++++++++----- include/media/videobuf2-core.h | 19 +++++--- 2 files changed, 47 insertions(+), 15 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 21ea096864a5..a8db8f51d4ac 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -413,11 +413,12 @@ static void init_buffer_cache_hints(struct vb2_queue *q, struct vb2_buffer *vb) */ static void vb2_queue_add_buffer(struct vb2_queue *q, struct vb2_buffer *vb, unsigned int index) { - WARN_ON(index >= q->max_num_buffers || q->bufs[index]); + WARN_ON(index >= q->max_num_buffers || test_bit(index, q->bufs_bitmap)); q->bufs[index] = vb; vb->index = index; vb->vb2_queue = q; + set_bit(index, q->bufs_bitmap); } /** @@ -426,8 +427,7 @@ static void vb2_queue_add_buffer(struct vb2_queue *q, struct vb2_buffer *vb, uns */ static void vb2_queue_remove_buffer(struct vb2_buffer *vb) { - if (vb->vb2_queue->num_buffers) - vb->vb2_queue->num_buffers--; + clear_bit(vb->index, vb->vb2_queue->bufs_bitmap); vb->vb2_queue->bufs[vb->index] = NULL; vb->vb2_queue = NULL; } @@ -449,11 +449,12 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory, unsigned long index; int ret; - /* Ensure that the number of already queue + num_buffers is below q->max_num_buffers */ + /* Ensure that vb2_get_num_buffers(q) + num_buffers is no more than q->max_num_buffers */ num_buffers = min_t(unsigned int, num_buffers, q->max_num_buffers - vb2_get_num_buffers(q)); - index = vb2_get_num_buffers(q); + index = bitmap_find_next_zero_area(q->bufs_bitmap, q->max_num_buffers, + 0, num_buffers, 0); *first_index = index; @@ -875,6 +876,14 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, q->bufs = kcalloc(q->max_num_buffers, sizeof(*q->bufs), GFP_KERNEL); if (!q->bufs) ret = -ENOMEM; + + if (!q->bufs_bitmap) + q->bufs_bitmap = bitmap_zalloc(q->max_num_buffers, GFP_KERNEL); + if (!q->bufs_bitmap) { + ret = -ENOMEM; + kfree(q->bufs); + q->bufs = NULL; + } q->memory = memory; mutex_unlock(&q->mmap_lock); if (ret) @@ -944,7 +953,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) { /* @@ -971,6 +979,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_bitmap); + q->bufs_bitmap = NULL; return ret; } EXPORT_SYMBOL_GPL(vb2_core_reqbufs); @@ -1007,9 +1019,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_num_buffers, sizeof(*q->bufs), GFP_KERNEL); - if (!q->bufs) + if (!q->bufs) { ret = -ENOMEM; + goto unlock; + } + if (!q->bufs_bitmap) + q->bufs_bitmap = bitmap_zalloc(q->max_num_buffers, GFP_KERNEL); + if (!q->bufs_bitmap) { + 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; @@ -1071,7 +1093,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) { /* @@ -2548,7 +2569,9 @@ void vb2_core_queue_release(struct vb2_queue *q) __vb2_queue_free(q, q->max_num_buffers); kfree(q->bufs); q->bufs = NULL; - q->num_buffers = 0; + bitmap_free(q->bufs_bitmap); + q->bufs_bitmap = NULL; + mutex_unlock(&q->mmap_lock); } EXPORT_SYMBOL_GPL(vb2_core_queue_release); @@ -2903,7 +2926,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_bitmap)) { struct vb2_buffer *b; /* diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index d433bf84e30c..fc1fcd8faa64 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -346,7 +346,7 @@ struct vb2_buffer { * describes the requested number of planes and sizes\[\] * contains the requested plane sizes. In this case * \*num_buffers are being allocated additionally to - * q->num_buffers. If either \*num_planes or the requested + * queue buffers. If either \*num_planes or the requested * sizes are invalid callback must return %-EINVAL. * @wait_prepare: release any locks taken while calling vb2 functions; * it is called before an ioctl needs to wait for a new @@ -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_bitmap: bitmap to manage bufs entries. * @max_num_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_bitmap; unsigned int max_num_buffers; struct list_head queued_list; @@ -1150,7 +1150,10 @@ static inline bool vb2_fileio_is_active(struct vb2_queue *q) */ static inline unsigned int vb2_get_num_buffers(struct vb2_queue *q) { - return q->num_buffers; + if (!q->bufs_bitmap) + return 0; + + return bitmap_weight(q->bufs_bitmap, q->max_num_buffers); } /** @@ -1253,7 +1256,13 @@ static inline void vb2_clear_last_buffer_dequeued(struct vb2_queue *q) static inline struct vb2_buffer *vb2_get_buffer(struct vb2_queue *q, unsigned int index) { - if (index < q->num_buffers) + if (!q->bufs_bitmap) + return NULL; + + if (index >= q->max_num_buffers) + return NULL; + + if (test_bit(index, q->bufs_bitmap)) return q->bufs[index]; return NULL; } From patchwork Tue Oct 3 08:07: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: 147742 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1930600vqb; Tue, 3 Oct 2023 01:13:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFRGzFBc4IYtONxnQrFVmy7Qd3Bnx39GdQf9WiRl+TWzmE/oOkfV1H9/nG92GhtKR5F0Mgn X-Received: by 2002:a17:903:1207:b0:1c3:ae56:4594 with SMTP id l7-20020a170903120700b001c3ae564594mr14931993plh.49.1696320798406; Tue, 03 Oct 2023 01:13:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320798; cv=none; d=google.com; s=arc-20160816; b=AGYH8vOybfaqQ82j3if2NiXWIRK6Me8huM/SoCJD0/nfLS+sMPK6uucxbbkWor3JxI tJGxnJirhRZYcZXOz+kG8rMB7f2+ppj7prfVfeQ3cqWyyONY5F3cMq+8Cq359DG94K1r m+dLBUYln5NzDQoY31TmipOq4Xt/10G3yzYj3GTL+sByXru4xNSjXunz31MyclLlVx/N OqEUTsskoAoYfCEGolDYT1KROlDsu3nsHzwz1IFm7sUiclfjhPWOwd8VIp06qrSqMvzF gWvn3Bh8OejghC7R8wbrvEUkGZpOb3y+8RyybC8pmNxjjvprvNAydcwpILFGrq9Xcg7m JuqA== 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=QpSInaJKUJ/DlcL8VR6iHm3p4p7re09L2HT4Ec1k7sA=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=JlMovjRYtt1XIxgQ+G4xFrpoznePZ6jp85llxXKASbDQm/kpHQ1CkZqbh0LPIdnofd SD+WZ3mMxpXzlevYdZYKN3v2AVwW1fQvfyCpXPQh/ehyHlXkKX6Q89zbmTToj/5SbJb+ 2LcO6LegHKQg4Njmaiv1/OpXT1lmQRWFVeJvZAQGAuTclaskb1wSdGfejsIcqd1RdWaV EEYUxouGdBLm6U3nqzaNPH+PBjAltQyiI3xMpGPSdyu5PkEVMibi5g01wMUz1DS0Ip/j /GNzsXP29neVcEsdsAIVnjObxmvvBx6Ps/UZB844M6RtSHXZ9afyG/9UzINfc7zLU8g9 9bWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=kDmos9em; 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 lf8-20020a170902fb4800b001b973681493si878826plb.16.2023.10.03.01.13.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:13:18 -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=kDmos9em; 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 64F01806897B; Tue, 3 Oct 2023 01:12:52 -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 S231267AbjJCILD (ORCPT + 18 others); Tue, 3 Oct 2023 04:11:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239617AbjJCIID (ORCPT ); Tue, 3 Oct 2023 04:08: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 343F6CD7; Tue, 3 Oct 2023 01:07:41 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 7D2E3660738C; Tue, 3 Oct 2023 09:07:39 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320459; bh=q/3LosksKvWNMIF8T4vY+RgX/8FTOCEMyeIR9ij3S98=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kDmos9emz0kk3EzVluf+oXNYg+7uUrdxFFziIbw2V5MX5DnCPMcIPrF3DOo0S4FBE fO2rmm8j6H2tzuAg98PxZECXqcteulRFHJB84xpKghY7wYjjVYcgW5SOkkus79y2WE B9RCka5y0Mldy6ZYwDeHMOx9Tw2otiWGvvuWY7a+uThMJTkNprvzR9hJHBCJ187tCl v0tZPDiJvLcAIP8b0XZyLd9oYVsB18nHAW16iT948/HxkoZtLraUa7zdarazj4QRaS M6qU4V2afrqNO5N9NqfuEXl6YdkLL8Y647uvD5fpX2u5OUx/UMXpw7vfLGHWdFKaAB ItSFwogKq8OaQ== 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 v10 51/54] media: core: Free range of buffers Date: Tue, 3 Oct 2023 10:07:00 +0200 Message-Id: <20231003080704.43911-52-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:12:52 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721277810450962 X-GMAIL-MSGID: 1778721277810450962 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 | 40 ++++++++----------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index a8db8f51d4ac..4862c75d43ee 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -516,13 +516,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_num_buffers; + unsigned int i; struct vb2_buffer *vb; - for (i = q->max_num_buffers; i >= 0 && buffer < buffers; i--) { + for (i = start; i < q->max_num_buffers && i < start + count; i++) { vb = vb2_get_buffer(q, i); if (!vb) continue; @@ -534,36 +533,32 @@ static void __vb2_free_mem(struct vb2_queue *q, unsigned int buffers) __vb2_buf_dmabuf_put(vb); else __vb2_buf_userptr_put(vb); - buffer++; } } /* - * __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_num_buffers; + unsigned int i; lockdep_assert_held(&q->mmap_lock); /* Call driver-provided cleanup function for each buffer, if provided */ - for (i = q->max_num_buffers, buffer = 0; i >= 0 && buffer < buffers; i--) { + for (i = start; i < q->max_num_buffers && i < start + count; i++) { struct vb2_buffer *vb = vb2_get_buffer(q, i); if (!vb) continue; - if (vb->planes[0].mem_priv) { + if (vb->planes[0].mem_priv) call_void_vb_qop(vb, buf_cleanup, vb); - buffer++; - } } /* Release video buffer memory */ - __vb2_free_mem(q, buffers); + __vb2_free_mem(q, start, count); #ifdef CONFIG_VIDEO_ADV_DEBUG /* @@ -596,8 +591,8 @@ 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->max_num_buffers; buffer++) { - struct vb2_buffer *vb = vb2_get_buffer(q, buffer); + for (i = 0; i < q->max_num_buffers; i++) { + struct vb2_buffer *vb = vb2_get_buffer(q, i); bool unbalanced; if (!vb) @@ -614,7 +609,7 @@ static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) if (unbalanced) { pr_info("unbalanced counters for queue %p, buffer %d:\n", - q, buffer); + q, i); 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); @@ -648,7 +643,7 @@ static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) #endif /* Free vb2 buffers */ - for (i = q->max_num_buffers, buffer = 0; i >= 0 && buffer < buffers; i--) { + for (i = start; i < q->max_num_buffers && i < start + count; i++) { struct vb2_buffer *vb = vb2_get_buffer(q, i); if (!vb) @@ -656,7 +651,6 @@ static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) vb2_queue_remove_buffer(vb); kfree(vb); - buffer++; } if (!vb2_get_num_buffers(q)) { @@ -850,7 +844,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); /* @@ -960,7 +954,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, first_index, allocated_buffers); mutex_unlock(&q->mmap_lock); return ret; } @@ -1100,7 +1094,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, *first_index, allocated_buffers); mutex_unlock(&q->mmap_lock); return -ENOMEM; } @@ -2566,7 +2560,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_num_buffers); + __vb2_queue_free(q, 0, q->max_num_buffers); kfree(q->bufs); q->bufs = NULL; bitmap_free(q->bufs_bitmap); From patchwork Tue Oct 3 08:07: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: 147735 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1929987vqb; Tue, 3 Oct 2023 01:11:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEolruIrfZPkuHDld6lwuExU26ZI1jaaH1QlKf72jqcCM0w+oWfOhOraJsxAGUSH39MmvTZ X-Received: by 2002:a05:6a21:2726:b0:14d:446f:7212 with SMTP id rm38-20020a056a21272600b0014d446f7212mr12473833pzb.46.1696320710118; Tue, 03 Oct 2023 01:11:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320710; cv=none; d=google.com; s=arc-20160816; b=p3J+wfwP0WTykAVlNy+DrECzEVTvqUmi1cBiy6LxzyRdIkxrgILdaqHGXrxp1O5441 IFKoU8tm7+P2zaidH7C2uj+KCQfxcG99jjOlJjSgUWWN+DPi0je0iFaeycFiRqAxQpbw xFjB12xVIDMZ3GhpmdmuY+Cc2XGb04BTvA+PUIGPBLbIMhuXq42WC982H5OHjr/l0P0+ JFMY3hS50DWWT/FlTYGbt35xj18d7cgZpaB6zCHyVSAZLCJRo9sU5AcLsfBxW11WBDal pWGMu2Yeuk0+oJ7XMk/qXPMzbraMY6DvKsbhyJfcxq9fSFg0nf367Ioz5nyh3uskvqor BZbA== 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=yL3vrhFA7mJ938TSNKcd09ukz5L64/nYsrNFza/0IE0=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=k3/93rZi+HU+N0E97pnS6p5VzzAasYCE0MnlVOintKm38JwayWeV0vIfAgs51Z4y6S ArYunfUxYutyn25EkBKDKWqaNpKinsL6+QP/2U0dP/fn0uk4CvyiMHuy3Izv8rB0gnnK uFQ8gWy5Svzj6kR6s6trrB2DyMpwZPfZk8RVY1uF6hleJsX0Ur8YfMRoH9JQKKOKu0uh N07XM//Z/MzRaVXidJCLaJOAoZndn0806l5C5ZdlHbRogCWGpf7nw2h2gYkOUFz5VnWY xzYrW2UKpTmSf7hya+Tz8dTYFfrXzp0CAaOztrdo7BW1oyeEAVmZtFrks41QGf0+eIBC lSgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=h4RyuNCg; 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 bw26-20020a056a00409a00b0068e285eaa31si947215pfb.259.2023.10.03.01.11.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:11:50 -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=h4RyuNCg; 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 33D998153D3D; Tue, 3 Oct 2023 01:11:49 -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 S239333AbjJCILN (ORCPT + 18 others); Tue, 3 Oct 2023 04:11:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239629AbjJCIIE (ORCPT ); Tue, 3 Oct 2023 04:08:04 -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 EB8BACDE; Tue, 3 Oct 2023 01:07:41 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 09293660738D; Tue, 3 Oct 2023 09:07:40 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320460; bh=Wb82srCfDv0jWXdkpI69iBBFj8MsexFVjGjk9sZvjvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h4RyuNCghb3OuA4uRJUHHywqZUVEwmEMAIeUidqZ93dRQJvjsWA/6ohRuAl4aZZHH cwtWoN+npA2CV/iOKbEXf3xPfO6hSVYfF0fS6TJYAtO1hOCWm+sERDkN1NMGev3sN4 04KXN4MVPsgneFzbjOpv5EFlKp/C43tNhsYMmm5siJZvou8fY1kcOIO6yB65vu0H3N IZYFhmrVGqZjIYBFMuL8UV2i+b/LZKoDVx5yQcQYuT/MxkAVIw5GJVOritueqmAAdk r0wPlORO/dny801ZFNF9XyU/TThVq/I5OJl3vCL/YPPIRE4fwAMpYF1DXdIFPvgzc+ oK0LpDBwy/q9A== 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 v10 52/54] media: v4l2: Add DELETE_BUFS ioctl Date: Tue, 3 Oct 2023 10:07:01 +0200 Message-Id: <20231003080704.43911-53-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:11:49 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721184498209773 X-GMAIL-MSGID: 1778721184498209773 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 | 80 +++++++++++++++++++ .../media/v4l/vidioc-reqbufs.rst | 1 + .../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 | 12 +++ include/media/videobuf2-v4l2.h | 13 +++ include/uapi/linux/videodev2.h | 17 ++++ 11 files changed, 196 insertions(+) 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..4791df1395d6 --- /dev/null +++ b/Documentation/userspace-api/media/v4l/vidioc-delete-bufs.rst @@ -0,0 +1,80 @@ +.. 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 +Drivers using this feature must expose the ``V4L2_BUF_CAP_SUPPORTS_DELETE_BUFS`` +capability on the queue :c:func:`VIDIOC_REQBUFS` or :c:func:`VIDIOC_CREATE_BUFS` +are invoked. + +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/Documentation/userspace-api/media/v4l/vidioc-reqbufs.rst b/Documentation/userspace-api/media/v4l/vidioc-reqbufs.rst index 0395187e1a5a..bcdf72dcbc22 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-reqbufs.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-reqbufs.rst @@ -121,6 +121,7 @@ aborting or finishing any DMA in progress, an implicit .. _V4L2-BUF-CAP-SUPPORTS-M2M-HOLD-CAPTURE-BUF: .. _V4L2-BUF-CAP-SUPPORTS-MMAP-CACHE-HINTS: .. _V4L2-BUF-CAP-SUPPORTS-SET-MAX-BUFS: +.. _V4L2-BUF-CAP-SUPPORTS-DELETE-BUFS: .. raw:: latex diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 4862c75d43ee..ffd1d1a03a79 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -1662,6 +1662,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_num_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 6d9f1be41a19..dc33d7e2a228 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -696,6 +696,8 @@ static void fill_buf_caps(struct vb2_queue *q, u32 *caps) if (q->supports_requests) *caps |= V4L2_BUF_CAP_SUPPORTS_REQUESTS; #endif + if (q->supports_delete_bufs) + *caps |= V4L2_BUF_CAP_SUPPORTS_DELETE_BUFS; } static void validate_memory_flags(struct vb2_queue *q, @@ -753,6 +755,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; @@ -1015,6 +1023,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 da355355a869..a2153b80b120 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; @@ -2161,6 +2168,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) { @@ -2910,6 +2926,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 fc1fcd8faa64..29c34947098e 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -507,6 +507,7 @@ struct vb2_buf_ops { * @supports_requests: this queue supports the Request API. * @requires_requests: this queue requires the Request API. If this is set to 1, * then supports_requests must be set to 1 as well. + * @supports_delete_bufs: this queue supports DELETE_BUFS ioctl. * @uses_qbuf: qbuf was used directly for this queue. Set to 1 the first * time this is called. Set to 0 when the queue is canceled. * If this is 1, then you cannot queue buffers from a request. @@ -595,6 +596,7 @@ struct vb2_queue { unsigned int quirk_poll_must_check_waiting_for_buffers:1; unsigned int supports_requests:1; unsigned int requires_requests:1; + unsigned int supports_delete_bufs:1; unsigned int uses_qbuf:1; unsigned int uses_requests:1; unsigned int allow_cache_hints:1; @@ -846,6 +848,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 ef1402537395..da21f07857b9 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -1036,6 +1036,7 @@ struct v4l2_requestbuffers { #define V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF (1 << 5) #define V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS (1 << 6) #define V4L2_BUF_CAP_SUPPORTS_SET_MAX_BUFS (1 << 7) +#define V4L2_BUF_CAP_SUPPORTS_DELETE_BUFS (1 << 8) /** * struct v4l2_plane - plane info for multi-planar buffers @@ -2622,6 +2623,20 @@ struct v4l2_create_buffers { __u32 reserved[5]; }; +/** + * 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 * @@ -2721,6 +2736,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 Tue Oct 3 08:07: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: 147734 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1929940vqb; Tue, 3 Oct 2023 01:11:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGkW9hGBmuG+rJflNFJSKyymXjO3QeOOv9Ts006NS7J1ClmtYgfp6d8rFNnFrD2UcYkgjoY X-Received: by 2002:a05:6870:e2cd:b0:1bb:6792:4787 with SMTP id w13-20020a056870e2cd00b001bb67924787mr15401254oad.40.1696320704100; Tue, 03 Oct 2023 01:11:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320704; cv=none; d=google.com; s=arc-20160816; b=shiGiXHSL/rt17CFzHeXL0ULlFt3jwZcueDzUVSvxm5pHGDlkIbIQaAmbzWbWlKoQp mE6FHyvcQies5Fv0qc96tYQS6oUzrcBhAkWgRc9/VY3PrjWuMsJMkI141/sEjWs8zEey WimzjT1/cCYDeVH8HMC96ExMeNc221+Q6FPNOuhDIajdr7pZaOts76bCSxopAsaOdUKP BmKZQscjz84hVD7Jk3j/UWfmS5bMt9HP4jcKhwOQtOBR83ekRJ5FK324frBxJ2GU4z6g 0U+N66fGHTrMz0zDxERmNDPEOA6kum6/Tt9U0hatcphQo/lrlxBD8VNJa1vuAOtTwCOH jJ6Q== 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=BBbmoeOgSzf6cmSDSYo0xxyyvrTQBdluhroEQ4pTGbE=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=sYxD5w4EQpyMDxqlF9mlXdJ63zo6NaVCjzY5BIrqHebv1tSqYdhWIw8Zqawdj5dw9W qIgt52PQe5+kIPdD66hRJRhxPnDc9QOCQe+qdwDI0E38A9J/uMJKWVbMuLH4UaNox+dq xQOeI+m/oeT0urIy9//0Y2H+oPOIjjaWO/qWhzhVs58gSJeOpQ8PJWSaUb1oJxN8W7W3 y4Oxtkc44Lbtz2k8VH3GAzPOADvnozx4YSAYwinkJQtmkivglSn1XA4t+PeXYxZ2s4nS JezLjVA2tBqoctEc9AbJnNB5I5pv8zzLlvtpOvGHdyOjL07tH/FHxEGHjsji1ftsMCn6 N/5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=DvNdwH+D; 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 p21-20020a637415000000b00573f94e8b83si893813pgc.265.2023.10.03.01.11.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:11:44 -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=DvNdwH+D; 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 01EFD808726E; Tue, 3 Oct 2023 01:11:42 -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 S239860AbjJCILH (ORCPT + 18 others); Tue, 3 Oct 2023 04:11:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239627AbjJCIIE (ORCPT ); Tue, 3 Oct 2023 04:08:04 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F001CE6; Tue, 3 Oct 2023 01:07:42 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 8993B6607392; Tue, 3 Oct 2023 09:07:40 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320460; bh=LkM/7EVzkzeCersLJmzLfirkGugiivs+DlFzZEGNCYQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DvNdwH+DCR82uJhgZPIOTq6JPG603jOW5tj5nuVwfOoaaWFPiUtnihdSzrWVX2r6T BAk8TZeGkCUk5jk4fxywmys9a3u1nVsGtpQVz2jvFw00hhSjP+LlbolJ3iwaXAG1WI JGlll0f8ORVl8ZilGCdGOeVoQPx7AAF1OhEGWYDqbC4hk226i6ZtlsbgoQfWHyhMwc 99t10F5rOa/J5HV6VrBgKXZ26qshstDcHu8Pfm6aypdtRkMS+UfIMRlgBywLsunExq 5wqBqrVxtKIj+GkkvKjNFA9fcgPvfrfagqNFKi/hkUg9jhxmSZwLzwkAtPXLu88yqI fXKkPbWteNFMA== 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 v10 53/54] media: v4l2: Add mem2mem helpers for DELETE_BUFS ioctl Date: Tue, 3 Oct 2023 10:07:02 +0200 Message-Id: <20231003080704.43911-54-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:11:43 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721178762746642 X-GMAIL-MSGID: 1778721178762746642 Create v4l2-mem2mem helpers for VIDIOC_DELETE_BUFS ioctl. Signed-off-by: Benjamin Gaignard --- .../media/platform/verisilicon/hantro_drv.c | 1 + .../media/platform/verisilicon/hantro_v4l2.c | 1 + drivers/media/test-drivers/vim2m.c | 2 ++ drivers/media/v4l2-core/v4l2-mem2mem.c | 20 +++++++++++++++++++ include/media/v4l2-mem2mem.h | 12 +++++++++++ 5 files changed, 36 insertions(+) diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c index 7f5b82eb6649..c8fed313c36f 100644 --- a/drivers/media/platform/verisilicon/hantro_drv.c +++ b/drivers/media/platform/verisilicon/hantro_drv.c @@ -248,6 +248,7 @@ queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq) dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; dst_vq->lock = &ctx->dev->vpu_mutex; dst_vq->dev = ctx->dev->v4l2_dev.dev; + src_vq->supports_delete_bufs = true; return vb2_queue_init(dst_vq); } 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..17213ce42059 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, @@ -1133,6 +1134,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, dst_vq->mem_ops = &vb2_vmalloc_memops; dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; dst_vq->lock = &ctx->vb_mutex; + dst_vq->supports_delete_bufs = true; return vb2_queue_init(dst_vq); } 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 Tue Oct 3 08:07: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: 147745 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1931238vqb; Tue, 3 Oct 2023 01:14:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEyKxtU/t98tYGQPm6fwkGjG36FmnNYHdNzs2k/ypt2hiGWyNqIkTg1eRArXKIWNZWw7PQn X-Received: by 2002:a05:6808:5d6:b0:3a7:1278:1899 with SMTP id d22-20020a05680805d600b003a712781899mr14221668oij.15.1696320889086; Tue, 03 Oct 2023 01:14:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320889; cv=none; d=google.com; s=arc-20160816; b=aCTf/8GP/dFzR7hNGdo6BYpHo8GUJJDM7xpB6QqBpedEAScyZ6R9+aPJ1cp2U+3oI2 PdJj8AUGQngupC1LAmxYA1f4guTRdixNlcBP175pe8JLh3OgsxnsWP32WdRYB7vivMz/ POruhw2Zd7ZsLqcuncNm17RJnSr970ZDILoXzBs8MeB5YQMmPOCk13zRemyRcZWqAe9R XZ9M1fJLhZ8F4aOZIag2V6zHkbcIkv9Dv72OpQXWYSUdlczGOIH2lmWClyXgsI2KQFVp oWn0RRf5fjyKrp61Vztay/8q0yMrbv4qunOcKieaWNjA5jf7eO5F02JKMKoVnzotX0NN tQFg== 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=Pj/z7RfOb9X265i4Wzm5VJPLBCEwxlnajjqXRifZfkg=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=Vqp3Bg+56zD7BHD7GRr+dsC+5SRtRnfM9KLhql5hln5zrrmmMEkQf8HrebMPpfR5zi AWYv0d+cFi7ArDmDRbgLkOn4FhJ5CtMwr2P2gFBQnQk48Bm6CJm17UBwJXCWRgiHL6M1 UacDBBqXtP8fPvqcmQ2n+LTdk0pWnRELyGR8PSGBK3owUjLr6SZSuWBcydtt3fJfnoR6 OCp8VXR03F3Nq4NcVdU+NgO33x0ya1UgZ/5DsMEwZsP93Fdnon+Aeae18NClI3O+8nRR PnutGPWxPv7xU/+cj/z/Oogk2EynlRPh2RQ3LBbZB6JgrtkMHu/oTwuez78/DDah9f7S QgQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ohZcVsGA; 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 i11-20020a17090a974b00b002765eee2b6bsi9496720pjw.46.2023.10.03.01.14.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:14:49 -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=ohZcVsGA; 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 DF0B0801D111; Tue, 3 Oct 2023 01:14: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 S239881AbjJCILR (ORCPT + 18 others); Tue, 3 Oct 2023 04:11:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239640AbjJCIIE (ORCPT ); Tue, 3 Oct 2023 04:08:04 -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 E5A9ECEC; Tue, 3 Oct 2023 01:07:42 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:b6df:b784:6a0f:8451]) (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 13E1A6607394; Tue, 3 Oct 2023 09:07:41 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696320461; bh=WlpSngD7A0Xes3T2AjXSHPISBbEOvphWL+prcr4Zf8E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ohZcVsGAm/1UJqiTPfm5xWPKPXOQRIoXNDNf31MARNtEiDnl7E0PQv70As+1QV1CR Ovij/ohisSDftVMAKIUKjo8kwWWEUL1hvIhN0RdThDr9daxiofmEcUf2TRfktR4GFC jB/Ml9DSluFsipG0KKveRUkwgGeYJpcKObBKfDYfdTN6Cm4jAFKU5736Qx2OchByHn T/q6rFRDLI7RydgctdZAjtnHOWZzSgeIyWwpmgYmaUMoVnL9FdGXkhHM1MUXOSmeRW uYmfPcsIlnqtd171/ro8uq3iDLipO7RgZg8IMfHcaORMtt0jhzAlw3PFz3fFrWTo7d UwLp1HSoZ+bCA== 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 v10 54/54] media: test-drivers: Use helper for DELETE_BUFS ioctl Date: Tue, 3 Oct 2023 10:07:03 +0200 Message-Id: <20231003080704.43911-55-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231003080704.43911-1-benjamin.gaignard@collabora.com> References: <20231003080704.43911-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:14:33 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778721372367893523 X-GMAIL-MSGID: 1778721372367893523 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 | 2 ++ drivers/media/test-drivers/vimc/vimc-capture.c | 2 ++ drivers/media/test-drivers/visl/visl-video.c | 2 ++ drivers/media/test-drivers/vivid/vivid-core.c | 13 ++++++++++--- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/media/test-drivers/vicodec/vicodec-core.c b/drivers/media/test-drivers/vicodec/vicodec-core.c index 69cbe2c094e1..f14a8fd506d0 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, @@ -1725,6 +1726,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, dst_vq->mem_ops = &vb2_vmalloc_memops; dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; dst_vq->lock = src_vq->lock; + dst_vq->supports_delete_bufs = true; return vb2_queue_init(dst_vq); } diff --git a/drivers/media/test-drivers/vimc/vimc-capture.c b/drivers/media/test-drivers/vimc/vimc-capture.c index aa944270e716..fda7ea3a6cb6 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, @@ -435,6 +436,7 @@ static struct vimc_ent_device *vimc_capture_add(struct vimc_device *vimc, q->min_buffers_needed = 2; q->lock = &vcapture->lock; q->dev = v4l2_dev->dev; + q->supports_delete_bufs = true; ret = vb2_queue_init(q); if (ret) { diff --git a/drivers/media/test-drivers/visl/visl-video.c b/drivers/media/test-drivers/visl/visl-video.c index 7cac6a6456eb..bd6c112f7846 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, @@ -728,6 +729,7 @@ int visl_queue_init(void *priv, struct vb2_queue *src_vq, dst_vq->mem_ops = &vb2_vmalloc_memops; dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; dst_vq->lock = &ctx->vb_mutex; + dst_vq->supports_delete_bufs = true; return vb2_queue_init(dst_vq); } diff --git a/drivers/media/test-drivers/vivid/vivid-core.c b/drivers/media/test-drivers/vivid/vivid-core.c index b5656330578d..e139569a0e9c 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, @@ -876,12 +877,18 @@ static int vivid_create_queue(struct vivid_dev *dev, q->type = buf_type; q->io_modes = VB2_MMAP | VB2_DMABUF; q->io_modes |= V4L2_TYPE_IS_OUTPUT(buf_type) ? VB2_WRITE : VB2_READ; - if (buf_type == V4L2_BUF_TYPE_VIDEO_CAPTURE) + if (buf_type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { q->max_num_buffers = 64; - if (buf_type == V4L2_BUF_TYPE_SDR_CAPTURE) + q->supports_delete_bufs = true; + } + if (buf_type == V4L2_BUF_TYPE_SDR_CAPTURE) { q->max_num_buffers = 1024; - if (buf_type == V4L2_BUF_TYPE_VBI_CAPTURE) + q->supports_delete_bufs = true; + } + if (buf_type == V4L2_BUF_TYPE_VBI_CAPTURE) { q->max_num_buffers = 32768; + q->supports_delete_bufs = true; + } if (allocators[dev->inst] != 1) q->io_modes |= VB2_USERPTR;