From patchwork Thu Oct 12 11:45: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: 151945 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1164502vqb; Thu, 12 Oct 2023 04:47:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHij/NlyKKcR6Lwm54SS3XfzLtLAuqFI/+/VeSd+sxFDoqr73b+6+YZe+2fqjytAa9Zkl+y X-Received: by 2002:a05:6a20:8f01:b0:163:d382:ba99 with SMTP id b1-20020a056a208f0100b00163d382ba99mr28804595pzk.5.1697111223889; Thu, 12 Oct 2023 04:47:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111223; cv=none; d=google.com; s=arc-20160816; b=eSZApJcrLMQ8oS05x00JZTILKakKX3RUpMwDezpiXi9oFyUXHM6qCc9yI1yl3suThH QKizeXP9Znv291syTChGw3nm69+pYgngWgI/7jAWrCL9KctrAtjt86QcKts400LJKsrC 2+tgn2LjPc5bnypVmDUTpeLvXbgs+5rxyhAsdKlECXVZc43zc+s7YLxxJL99Sq1cFofm 1W66v40udP8fk4zzF2OX5m2tyDVSvkse/KLndSUiqdQcq0XCEcIpqs8B4hjBbgB3b4Nk Aaeenj/t3V6sTNjJvhlQ2AGY99ARlAIq+KJ9ONclfRRc0gfUA+ObUzhM+MWUiiQVNkWs TuMQ== 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=sj9zEzSQKjeWdQkuGM7i4Hrn4i7fVVdzvjJAu2+KTlA=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=Yy+t+RbMGv0fXfsYocxXCMWLBv/GHonWUhWlIWDQeuUeFoz8iCxmya4UPDkyEsZ8Ze vsDXnIh/aFsYso1ghfAzu+7VcCR5JJ35d4Jx6r1pPIS8S4hFAND5WduN931qobskfBAR z93Lq5e5S2ZsvWejXA1SaUMvz+a8j3AghkDqHExXAFOdP2q4AhwDxK+TQm1SD80dEvS8 Dh4s1M9YBffAouI0Gjd1ys1LxNutcTjQyVGa4PcNYGHoLjT1bq2w2UqAwetF/PX4Gvzq XriVyMolyYgaaKeZSMLjpoXovuOWH2QjZorO2IACj+ejtHW+FwkDS0mMoPmeoXeZjVj5 884w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=d5VYelnd; 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 9-20020a170902c14900b001bdca6456c3si1981799plj.46.2023.10.12.04.47.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:47:03 -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=d5VYelnd; 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 EDC3B822CB58; Thu, 12 Oct 2023 04:47:02 -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 S1378333AbjJLLq4 (ORCPT + 19 others); Thu, 12 Oct 2023 07:46:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343858AbjJLLqx (ORCPT ); Thu, 12 Oct 2023 07:46:53 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88FF0A9; Thu, 12 Oct 2023 04:46:51 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 C82406607346; Thu, 12 Oct 2023 12:46:49 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111210; bh=cMzVFA9/TUVo9VWr/5JcyqG4OOKgwWqTUUieq9IONwI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d5VYelndvKS9apDVWUIKnJDTC/LhhIBeTGDA9MCyEcBjx8JxmZG44Z+KRW1iKezgx hT+0k31ZtmSB4GRp4XSVomidcSrV7svZFsWD9NWOU4WBgCJWkYaiy8d8flhPlgcfnD lpZKNSO0qxOfHGdufAUHhmQ2jIA+62ZbInopNcSyJVVSGWAov6DU/W2UZrBJsKn5Zb eQJ4sfBNWXAUzGS4gGpxnlFXBQC6f8ePTaDhghtE6sCwOB7nafEcvKftOkLoLaMv7H OKGeCmxpiwDqKmiR1+UvwPu3ZgIgIIQyfwJnD7Gmb4V4/1pyx5HJqa+WBBaNy0zRWA VeRQ5lAdZU/hA== 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 v11 01/56] media: videobuf2: Rename offset parameter Date: Thu, 12 Oct 2023 13:45:47 +0200 Message-Id: <20231012114642.19040-2-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:47:03 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550098826594586 X-GMAIL-MSGID: 1779550098826594586 Rename 'off' parameter to 'offset' to clarify the code. Signed-off-by: Benjamin Gaignard --- .../media/common/videobuf2/videobuf2-core.c | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 27aee92f3eea..a5e57affeb30 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -356,23 +356,23 @@ static void __setup_offsets(struct vb2_buffer *vb) { struct vb2_queue *q = vb->vb2_queue; unsigned int plane; - unsigned long off = 0; + unsigned long offset = 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); + offset = PAGE_ALIGN(p->m.offset + p->length); } for (plane = 0; plane < vb->num_planes; ++plane) { - vb->planes[plane].m.offset = off; + vb->planes[plane].m.offset = offset; dprintk(q, 3, "buffer %d, plane %d offset 0x%08lx\n", - vb->index, plane, off); + vb->index, plane, offset); - off += vb->planes[plane].length; - off = PAGE_ALIGN(off); + offset += vb->planes[plane].length; + offset = PAGE_ALIGN(offset); } } @@ -2185,9 +2185,9 @@ 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 plane associated with the given offset */ -static int __find_plane_by_offset(struct vb2_queue *q, unsigned long off, +static int __find_plane_by_offset(struct vb2_queue *q, unsigned long offset, unsigned int *_buffer, unsigned int *_plane) { struct vb2_buffer *vb; @@ -2218,7 +2218,7 @@ static int __find_plane_by_offset(struct vb2_queue *q, unsigned long off, vb = q->bufs[buffer]; for (plane = 0; plane < vb->num_planes; ++plane) { - if (vb->planes[plane].m.offset == off) { + if (vb->planes[plane].m.offset == offset) { *_buffer = buffer; *_plane = plane; return 0; @@ -2304,7 +2304,7 @@ EXPORT_SYMBOL_GPL(vb2_core_expbuf); int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma) { - unsigned long off = vma->vm_pgoff << PAGE_SHIFT; + unsigned long offset = vma->vm_pgoff << PAGE_SHIFT; struct vb2_buffer *vb; unsigned int buffer = 0, plane = 0; int ret; @@ -2335,7 +2335,7 @@ 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, offset, &buffer, &plane); if (ret) goto unlock; @@ -2380,7 +2380,7 @@ unsigned long vb2_get_unmapped_area(struct vb2_queue *q, unsigned long pgoff, unsigned long flags) { - unsigned long off = pgoff << PAGE_SHIFT; + unsigned long offset = pgoff << PAGE_SHIFT; struct vb2_buffer *vb; unsigned int buffer, plane; void *vaddr; @@ -2392,7 +2392,7 @@ 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, offset, &buffer, &plane); if (ret) goto unlock; From patchwork Thu Oct 12 11:45: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: 151950 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1164768vqb; Thu, 12 Oct 2023 04:47:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEclma//dHMpQ3MjWR1wxMIbFJlKy+G6u5k66kuuVRWb993MoDXFsfysmoNisGWCUZ7xLHc X-Received: by 2002:a05:6e02:2185:b0:357:5188:1f83 with SMTP id j5-20020a056e02218500b0035751881f83mr4082615ila.1.1697111254529; Thu, 12 Oct 2023 04:47:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111254; cv=none; d=google.com; s=arc-20160816; b=bVqEMoCNz1COi3PVo+9kkaIej4vViF/029RroJ2cYNtEGoqOIFty0SPSykNP66UmN9 IU4Wau6pjg6wVhomGcsHdmM/wGqJ9b+eKoyGUwDELMDRV+XJUvcVNYwCtMPgtKYdJKba JG+BuiWsfPpNGS4ki8dlBSl3OBic6fXikNybzUydxBzbO0uSRn9fgsDqtr2Y1Ji3V/pT EcpgXdyrG7lUa0SgWllyaGeeqm7HbGx5KoJOqpJrcHIk02HhUeKAKt91AxjTG9gifLpx P+i+qvNCTY5XlHj8GtL9F78B3eX1p7+fg97kg1GjtLQHNBus/T7S8LS8IqFK/tRgEPiT 495g== 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=P++PSUnKxA1FoBnWZtRCB7asB3D81oFP8RoeOwSpsrM=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=tmJx89y//U+NPUEitns3WXsLsfR69jr5cqtPJ6gTQRWbkR6UjATz2Sp1X1U/9k+HMG fLFDBjESPo7P0P+7ntVvTqk0+RTiJMfpHbUStamZtfiOGduC3ngGIEsDwx8bPaTX0/q0 hfNwrgXSlrgjG9OlDhiEmUYCSUgNoKWnGm4Q7STSSHYCckMHEeSGWlom1gB/izDQoA+o PURn3lML4CY/6DhxLAj1h/zKBhCBGya4tBKuy4ShjRrJgZJWOIMmogzK+6kkKODKqOjA pgVjJ1ih/hbg7vsWANejyAxSIEXJjREfQgoCcQ2/DKgyte1qVQHgvDxuCPgOKeOwYrUJ cWeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=WgyGRT3W; 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 s196-20020a6377cd000000b00578a2142861si1801397pgc.531.2023.10.12.04.47.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:47:34 -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=WgyGRT3W; 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 5FB0881A7D1D; Thu, 12 Oct 2023 04:47:24 -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 S1378422AbjJLLq7 (ORCPT + 19 others); Thu, 12 Oct 2023 07:46:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378262AbjJLLqy (ORCPT ); Thu, 12 Oct 2023 07:46:54 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8D6DC0; Thu, 12 Oct 2023 04:46:51 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 52F226607347; Thu, 12 Oct 2023 12:46:50 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111210; bh=7foNNb6amO3+FMMwIl173lEOz6gYhJG/dA79F9jwpAU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WgyGRT3Wun6oQTjVb/4d2xo/H9h+Mo51gVh/Qv4FpnOR8cd80YKFO/8Zh4K4zPGas hjIR2gGYFRJmkUgurilkUADwklRY+OK7p5fTIO6ZkrEvl37tn9PQ5gnAftD0pwJIQa VLMXBNvUQCw0lQ6KilJH5GQk2JDNxO9Ac6KjjJEJmzmUNASybx9wVA8QEDYLRUaKYe tPR5blQGz+SdckyNdIm/itHL86EH1uITlplFCeK/mHWi5WWYBEy8f6G0zqysttAFNT GF5HQrLx0jU8QB7ngsivbga72hPDZ6Qg5jkQN8ezpwVnBC9ICpHxQGDQyRp26XR9H5 kntHkJmG+XW/A== 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 v11 02/56] media: videobuf2: Rework offset 'cookie' encoding pattern Date: Thu, 12 Oct 2023 13:45:48 +0200 Message-Id: <20231012114642.19040-3-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 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]); Thu, 12 Oct 2023 04:47:24 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550130505738638 X-GMAIL-MSGID: 1779550130505738638 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 --- .../media/common/videobuf2/videobuf2-core.c | 73 +++++++++---------- 1 file changed, 35 insertions(+), 38 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index a5e57affeb30..09be8e026044 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,27 @@ static void __setup_offsets(struct vb2_buffer *vb) unsigned int plane; unsigned long offset = 0; - if (vb->index) { - struct vb2_buffer *prev = q->bufs[vb->index - 1]; - struct vb2_plane *p = &prev->planes[prev->num_planes - 1]; - - offset = PAGE_ALIGN(p->m.offset + p->length); - } + /* + * The offset "cookie" value has the following constraints: + * - a buffer can have up to 8 planes. + * - v4l2 mem2mem uses bit 30 to distinguish between + * OUTPUT (aka "source", bit 30 is 0) and + * CAPTURE (aka "destination", bit 30 is 1) 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. + */ + offset = vb->index << PLANE_INDEX_SHIFT; for (plane = 0; plane < vb->num_planes; ++plane) { - vb->planes[plane].m.offset = offset; + vb->planes[plane].m.offset = offset + (plane << PAGE_SHIFT); dprintk(q, 3, "buffer %d, plane %d offset 0x%08lx\n", vb->index, plane, offset); - - offset += vb->planes[plane].length; - offset = PAGE_ALIGN(offset); } } @@ -2188,10 +2199,9 @@ EXPORT_SYMBOL_GPL(vb2_core_streamoff); * __find_plane_by_offset() - find plane associated with the given offset */ static int __find_plane_by_offset(struct vb2_queue *q, unsigned long offset, - 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 +2219,15 @@ static int __find_plane_by_offset(struct vb2_queue *q, unsigned long offset, 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 = (offset >> PLANE_INDEX_SHIFT) & BUFFER_INDEX_MASK; + *plane = (offset >> PAGE_SHIFT) & PLANE_INDEX_MASK; - for (plane = 0; plane < vb->num_planes; ++plane) { - if (vb->planes[plane].m.offset == offset) { - *_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 +2307,7 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma) { unsigned long offset = 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 +2336,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, offset, &buffer, &plane); + ret = __find_plane_by_offset(q, offset, &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 +2367,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 +2381,7 @@ unsigned long vb2_get_unmapped_area(struct vb2_queue *q, { unsigned long offset = pgoff << PAGE_SHIFT; struct vb2_buffer *vb; - unsigned int buffer, plane; + unsigned int plane; void *vaddr; int ret; @@ -2392,12 +2391,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, offset, &buffer, &plane); + ret = __find_plane_by_offset(q, offset, &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 Thu Oct 12 11:45: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: 151951 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1164808vqb; Thu, 12 Oct 2023 04:47:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF8XLEM7q/cK1TfuwwgSYGPu6aTSVwXboaaQ15WTYhjsrIpWLNdo2BSWZtUIr79F34GoemG X-Received: by 2002:a05:6830:490e:b0:6c4:7516:f2cf with SMTP id eq14-20020a056830490e00b006c47516f2cfmr29355359otb.2.1697111260480; Thu, 12 Oct 2023 04:47:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111260; cv=none; d=google.com; s=arc-20160816; b=JIGFUjY+tGqQjgFnARJVlvkac8FMQetjXqm9ddBXKLmfVRum6ojVSxk2qsskKAMcYz VjeUWJuUkcOk5KF8GTNuL0p7nsbBuzi93kCpAroed9zIrkJuLCu8olLor9NVK2Mr60di 0tZGlsdAQ9gZSVKHeArf5PwvzJxu+iO95zyMCWI1/6AMI0Kfw6NXNPCrxb1hkER5X6DM zpkxfiV3koGqiqPrbLArhUYixheXttRL4Ad2dhe8WxZbkivhTi5LLsm2qJu8s2hY+mXL F/Ah+CZGi6hpT7pvy9Yy3a1Tl33gFlDtdU9YGykMYbwMS6YNMJsJ6L2ukO8N+slwG4LM 2CWg== 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=EuTgtxyPbErCrKgvGy4Be2VTKeTj33LFpgdcasSoc4k=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=iKftxYv64BRoaz0Ac0iBTtw+OdTOlOSP1yhjGIkp3FvPYb+FEIT3z+oiTnl8CQlITg iupNTRPFY0K0A2e/hpaRn4ff40OOgJK/dQsFIVR9ecKJN8UyHRptHNtBlVgDtrD89T0b C601RC7kFthufMSZlTShd7sGOwTZUz53LcGHU7r/7uUZeE0TPhz4gHzon3YJlBqt0nRI HwDyJT8p+dyyGu2Qeun5Mo4NJb8pWYYUTOok648QtV4c1e9Xa0BAfgIcGH2lU7kbJapD YHVqETdIPD9fVoBrNoLN5r848++ZrSu/3IIdQh8OYFJDAEZdQKcBhTiWk8Ha7TagTDZB vNig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=d0Vb5yg8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id fo23-20020a056a00601700b0069fe19ca863si11476574pfb.284.2023.10.12.04.47.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:47:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=d0Vb5yg8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 5DC8E83741F2; Thu, 12 Oct 2023 04:47:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347204AbjJLLrB (ORCPT + 19 others); Thu, 12 Oct 2023 07:47:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378209AbjJLLqy (ORCPT ); Thu, 12 Oct 2023 07:46:54 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C6C3C4; Thu, 12 Oct 2023 04:46:52 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 D22196607348; Thu, 12 Oct 2023 12:46:50 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111211; bh=xMJ8tMojfr13gTY+PpecndOGeS4i3P9Tk9kRrGKcBSQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d0Vb5yg800NBnbps2lBfIjdmI+Nk9X7Z+HUG/OhSGGIb/xKUKkaChkfykyV+Z0igH +yat9F7ZLG5f7N992/tn+aNdv8m82HKhXpeV+iTbq79HNk0nTQbwznumDPfXqQk5ni 3s++jlxrkL5b+92W/j07LlSI2nTDHAcWwKBcEaMYhXO9rTndxm3uEvNHCCcRcjBXHX Dft0V8mD1KhWU45yBziHsUaKEar+UseGWgsVQSpZO/r9x3Q72APSdm/8nJS+3L9mLm vjK7S0r7JpPPMibS2H5+Y/RIyYqz87CJUnsZELLjnKP0pTNWO+UMgBz0Vxj0r1tD8k yjxLkgoLP6NAg== 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 v11 03/56] media: videobuf2: Stop spamming kernel log with all queue counter Date: Thu, 12 Oct 2023 13:45:49 +0200 Message-Id: <20231012114642.19040-4-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:47:31 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550137254914397 X-GMAIL-MSGID: 1779550137254914397 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 09be8e026044..47dba2a20d73 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -533,25 +533,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; @@ -572,29 +573,37 @@ static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) vb->cnt_buf_prepare != vb->cnt_buf_finish || vb->cnt_buf_init != vb->cnt_buf_cleanup; - if (unbalanced || debug) { - pr_info(" counters for queue %p, buffer %d:%s\n", - q, buffer, unbalanced ? " UNBALANCED!" : ""); - pr_info(" buf_init: %u buf_cleanup: %u buf_prepare: %u buf_finish: %u\n", - vb->cnt_buf_init, vb->cnt_buf_cleanup, - vb->cnt_buf_prepare, vb->cnt_buf_finish); - pr_info(" buf_out_validate: %u buf_queue: %u buf_done: %u buf_request_complete: %u\n", - vb->cnt_buf_out_validate, vb->cnt_buf_queue, - vb->cnt_buf_done, vb->cnt_buf_request_complete); - pr_info(" alloc: %u put: %u prepare: %u finish: %u mmap: %u\n", - vb->cnt_mem_alloc, vb->cnt_mem_put, - vb->cnt_mem_prepare, vb->cnt_mem_finish, - vb->cnt_mem_mmap); - pr_info(" get_userptr: %u put_userptr: %u\n", - vb->cnt_mem_get_userptr, vb->cnt_mem_put_userptr); - pr_info(" attach_dmabuf: %u detach_dmabuf: %u map_dmabuf: %u unmap_dmabuf: %u\n", - vb->cnt_mem_attach_dmabuf, vb->cnt_mem_detach_dmabuf, - vb->cnt_mem_map_dmabuf, vb->cnt_mem_unmap_dmabuf); - pr_info(" get_dmabuf: %u num_users: %u vaddr: %u cookie: %u\n", + if (unbalanced) { + pr_info("unbalanced counters for queue %p, buffer %d:\n", + q, buffer); + if (vb->cnt_buf_init != vb->cnt_buf_cleanup) + pr_info(" buf_init: %u buf_cleanup: %u\n", + vb->cnt_buf_init, vb->cnt_buf_cleanup); + if (vb->cnt_buf_prepare != vb->cnt_buf_finish) + pr_info(" buf_prepare: %u buf_finish: %u\n", + vb->cnt_buf_prepare, vb->cnt_buf_finish); + if (vb->cnt_buf_queue != vb->cnt_buf_done) + pr_info(" buf_out_validate: %u buf_queue: %u buf_done: %u buf_request_complete: %u\n", + vb->cnt_buf_out_validate, vb->cnt_buf_queue, + vb->cnt_buf_done, vb->cnt_buf_request_complete); + if (vb->cnt_mem_alloc != vb->cnt_mem_put) + pr_info(" alloc: %u put: %u\n", + vb->cnt_mem_alloc, vb->cnt_mem_put); + if (vb->cnt_mem_prepare != vb->cnt_mem_finish) + pr_info(" prepare: %u finish: %u\n", + vb->cnt_mem_prepare, vb->cnt_mem_finish); + if (vb->cnt_mem_get_userptr != vb->cnt_mem_put_userptr) + pr_info(" get_userptr: %u put_userptr: %u\n", + vb->cnt_mem_get_userptr, vb->cnt_mem_put_userptr); + if (vb->cnt_mem_attach_dmabuf != vb->cnt_mem_detach_dmabuf) + pr_info(" attach_dmabuf: %u detach_dmabuf: %u\n", + vb->cnt_mem_attach_dmabuf, vb->cnt_mem_detach_dmabuf); + if (vb->cnt_mem_map_dmabuf != vb->cnt_mem_unmap_dmabuf) + pr_info(" map_dmabuf: %u unmap_dmabuf: %u\n", + vb->cnt_mem_map_dmabuf, vb->cnt_mem_unmap_dmabuf); + pr_info(" get_dmabuf: %u num_users: %u\n", vb->cnt_mem_get_dmabuf, - vb->cnt_mem_num_users, - vb->cnt_mem_vaddr, - vb->cnt_mem_cookie); + vb->cnt_mem_num_users); } } #endif From patchwork Thu Oct 12 11:45: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: 151961 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1165228vqb; Thu, 12 Oct 2023 04:48:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFP3+OqUAacOwcAhDvJmmhXI9gChAHYDnX4njwo9artqix9gNncMWNmbSweZX+P1bFJptgm X-Received: by 2002:a17:902:d4c9:b0:1b8:9fc4:2733 with SMTP id o9-20020a170902d4c900b001b89fc42733mr26657642plg.3.1697111311975; Thu, 12 Oct 2023 04:48:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111311; cv=none; d=google.com; s=arc-20160816; b=kKeO6QaI6c6DAAPnxm5q/xKVGoQ8uMtP64Gw1TEMU1KQUQAYKweY58WJ2EYw8Jxxqs t/wXQ1Dmjffb19vrhEOUzPZ3uqgjAmNi2cJ707BBrQpC+85KnFvbOPJ6mvmlkeGtR6EJ bSTMJdlxY/YsOrt9aUoB8XoG5VMHmJ/bGqmFbYQYLsWv8iVo3Rt5SiDiVzjPQHw+FtZX YcZNCLtpE6RZFJ52imCflMmi0fOi7ftcfvwGF6tjnxiXdixzU9lvLPhBH81oMZHndg1m HSV5JIRuSN4RwU1ggLmtjgXO7d97bT65eMTJX1WLjjlRRVBkUjXfjIMr4UW+z2VxzHip asSQ== 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=zwBog/JKXvJtHhAWX+ALn9JJ2e001poaMqGxcBNLCmc=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=LpxzcQhzQKPH4XV44ugowJ72suzSEzZPhFQ9LDI1yxGvaFX5OAT8dotbTuvOWut4ay QtVHV9MulYMREeBqCIkXHeqXXkAL8Gs+/CVVFOibR8AmJL2G2cJdo4NmTS3Fig5gKEjk TveVavkRSWGomgWGmN0Km2uaJ/nuzEfal6qljFHigfLPrtB6x7MFukGnmPMMr5ma7ygo E+x02FyOywuecSMxIcmIk7VujWcAyipZOfJ1JmsqM1CZgrvHjyZF3Xou+8tQOSzV5y1K 06YatVWFQUioCSq9VwAzeUCALbNvVt8QtffdhCaFKFxStsU5/inhVhdshsx6eLG9ytRn kz2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=htOaCnm3; 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 d10-20020a170902654a00b001c427a74e31si1990919pln.628.2023.10.12.04.48.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:48:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=htOaCnm3; 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 C7267812A609; Thu, 12 Oct 2023 04:48:18 -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 S1378500AbjJLLrE (ORCPT + 19 others); Thu, 12 Oct 2023 07:47:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378307AbjJLLqz (ORCPT ); Thu, 12 Oct 2023 07:46:55 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1436BA; Thu, 12 Oct 2023 04:46:52 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 5E3456607349; Thu, 12 Oct 2023 12:46:51 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111211; bh=SgVWW+qYbUxKSm/wwCivJbJa6o307xOPj5mXnwJw5sE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=htOaCnm3XM+t18h5zcQ/drT0uA95UgBP/taCyWWBTXy6dZThdUTdo+gfnZhan2jXG 3u3ScAPtHTbqpqP4+WmJL7ZYt7xEyQckN+Kg4dvH7q2XAKVR/ve8QcKdKy7hPqW8z+ Ga+71QZa8ufC47NComTNpSgERRDzrj/JwfnKF0Pmr0X9e/VMme7kWPmemw3jiOmSSS go5O6JfsKqtOGPJ7oFr3BgpJTn0HcVw13qMJ4sodU+p3Zm3rq1gcFS94vEK6n4ehbI o/P37/P302z/SQpC9+F4vCR++Y6XbIQm0DZrSEMjgveYIEc1d0Xp4nTBceDgajkx3e xnfYAJQ864u2w== 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 v11 04/56] media: videobuf2: Use vb2_buffer instead of index Date: Thu, 12 Oct 2023 13:45:50 +0200 Message-Id: <20231012114642.19040-5-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 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]); Thu, 12 Oct 2023 04:48:18 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550190980747529 X-GMAIL-MSGID: 1779550190980747529 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 47dba2a20d73..968b7c0e7934 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -654,9 +654,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); @@ -1490,9 +1490,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); @@ -1507,7 +1504,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); } @@ -1562,12 +1559,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)); @@ -1654,10 +1649,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; @@ -1666,8 +1660,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"); @@ -2240,9 +2232,8 @@ static int __find_plane_by_offset(struct vb2_queue *q, unsigned long offset, } 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; @@ -2267,13 +2258,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; @@ -2292,20 +2276,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; @@ -2710,7 +2694,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; @@ -2895,7 +2879,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; @@ -2998,7 +2982,7 @@ static int vb2_thread(void *data) if (copy_timestamp) vb->timestamp = ktime_get_ns(); if (!threadio->stop) - ret = vb2_core_qbuf(q, vb->index, NULL, NULL); + ret = vb2_core_qbuf(q, vb, NULL, NULL); call_void_qop(q, wait_prepare, q); if (ret || threadio->stop) break; diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index c7a54d82a55e..697c8a9f98cd 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -667,7 +667,7 @@ int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b) vb = q->bufs[b->index]; ret = __verify_planes_array(vb, b); if (!ret) - vb2_core_querybuf(q, b->index, b); + vb2_core_querybuf(q, vb, b); return ret; } EXPORT_SYMBOL(vb2_querybuf); @@ -723,6 +723,7 @@ EXPORT_SYMBOL_GPL(vb2_reqbufs); int vb2_prepare_buf(struct vb2_queue *q, struct media_device *mdev, struct v4l2_buffer *b) { + struct vb2_buffer *vb; int ret; if (vb2_fileio_is_active(q)) { @@ -733,9 +734,15 @@ int vb2_prepare_buf(struct vb2_queue *q, struct media_device *mdev, if (b->flags & V4L2_BUF_FLAG_REQUEST_FD) return -EINVAL; + if (b->index >= q->num_buffers) { + dprintk(q, 1, "buffer index out of range\n"); + return -EINVAL; + } + vb = q->bufs[b->index]; + ret = vb2_queue_or_prepare_buf(q, mdev, b, true, NULL); - return ret ? ret : vb2_core_prepare_buf(q, b->index, b); + return ret ? ret : vb2_core_prepare_buf(q, vb, b); } EXPORT_SYMBOL_GPL(vb2_prepare_buf); @@ -803,6 +810,7 @@ int vb2_qbuf(struct vb2_queue *q, struct media_device *mdev, struct v4l2_buffer *b) { struct media_request *req = NULL; + struct vb2_buffer *vb; int ret; if (vb2_fileio_is_active(q)) { @@ -810,10 +818,16 @@ int vb2_qbuf(struct vb2_queue *q, struct media_device *mdev, return -EBUSY; } + if (b->index >= q->num_buffers) { + dprintk(q, 1, "buffer index out of range\n"); + return -EINVAL; + } + vb = q->bufs[b->index]; + ret = vb2_queue_or_prepare_buf(q, mdev, b, false, &req); if (ret) return ret; - ret = vb2_core_qbuf(q, b->index, b, req); + ret = vb2_core_qbuf(q, vb, b, req); if (req) media_request_put(req); return ret; @@ -873,7 +887,15 @@ EXPORT_SYMBOL_GPL(vb2_streamoff); int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb) { - return vb2_core_expbuf(q, &eb->fd, eb->type, eb->index, + struct vb2_buffer *vb; + + if (eb->index >= q->num_buffers) { + dprintk(q, 1, "buffer index out of range\n"); + return -EINVAL; + } + vb = q->bufs[eb->index]; + + return vb2_core_expbuf(q, &eb->fd, eb->type, vb, eb->plane, eb->flags); } EXPORT_SYMBOL_GPL(vb2_expbuf); diff --git a/drivers/media/dvb-core/dvb_vb2.c b/drivers/media/dvb-core/dvb_vb2.c index 909df82fed33..b322ef179f05 100644 --- a/drivers/media/dvb-core/dvb_vb2.c +++ b/drivers/media/dvb-core/dvb_vb2.c @@ -360,7 +360,7 @@ int dvb_vb2_querybuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b) dprintk(1, "[%s] buffer index out of range\n", ctx->name); return -EINVAL; } - vb2_core_querybuf(&ctx->vb_q, b->index, b); + vb2_core_querybuf(&ctx->vb_q, q->bufs[b->index], b); dprintk(3, "[%s] index=%d\n", ctx->name, b->index); return 0; } @@ -370,7 +370,7 @@ int dvb_vb2_expbuf(struct dvb_vb2_ctx *ctx, struct dmx_exportbuffer *exp) struct vb2_queue *q = &ctx->vb_q; int ret; - ret = vb2_core_expbuf(&ctx->vb_q, &exp->fd, q->type, exp->index, + ret = vb2_core_expbuf(&ctx->vb_q, &exp->fd, q->type, q->bufs[exp->index], 0, exp->flags); if (ret) { dprintk(1, "[%s] index=%d errno=%d\n", ctx->name, @@ -391,7 +391,7 @@ int dvb_vb2_qbuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b) dprintk(1, "[%s] buffer index out of range\n", ctx->name); return -EINVAL; } - ret = vb2_core_qbuf(&ctx->vb_q, b->index, b, NULL); + ret = vb2_core_qbuf(&ctx->vb_q, q->bufs[b->index], b, NULL); if (ret) { dprintk(1, "[%s] index=%d errno=%d\n", ctx->name, b->index, ret); diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 4b6a9d2ea372..cd3ff1cd759d 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -747,7 +747,7 @@ int vb2_wait_for_all_buffers(struct vb2_queue *q); /** * vb2_core_querybuf() - query video buffer information. * @q: pointer to &struct vb2_queue with videobuf2 queue. - * @index: id number of the buffer. + * @vb: pointer to struct &vb2_buffer. * @pb: buffer struct passed from userspace. * * Videobuf2 core helper to implement VIDIOC_QUERYBUF() operation. It is called @@ -759,7 +759,7 @@ int vb2_wait_for_all_buffers(struct vb2_queue *q); * * Return: returns zero on success; an error code otherwise. */ -void vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb); +void vb2_core_querybuf(struct vb2_queue *q, struct vb2_buffer *vb, void *pb); /** * vb2_core_reqbufs() - Initiate streaming. @@ -823,7 +823,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, * vb2_core_prepare_buf() - Pass ownership of a buffer from userspace * to the kernel. * @q: pointer to &struct vb2_queue with videobuf2 queue. - * @index: id number of the buffer. + * @vb: pointer to struct &vb2_buffer. * @pb: buffer structure passed from userspace to * &v4l2_ioctl_ops->vidioc_prepare_buf handler in driver. * @@ -839,13 +839,13 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, * * Return: returns zero on success; an error code otherwise. */ -int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb); +int vb2_core_prepare_buf(struct vb2_queue *q, struct vb2_buffer *vb, void *pb); /** * vb2_core_qbuf() - Queue a buffer from userspace * * @q: pointer to &struct vb2_queue with videobuf2 queue. - * @index: id number of the buffer + * @vb: pointer to struct &vb2_buffer. * @pb: buffer structure passed from userspace to * v4l2_ioctl_ops->vidioc_qbuf handler in driver * @req: pointer to &struct media_request, may be NULL. @@ -867,7 +867,7 @@ int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb); * * Return: returns zero on success; an error code otherwise. */ -int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb, +int vb2_core_qbuf(struct vb2_queue *q, struct vb2_buffer *vb, void *pb, struct media_request *req); /** @@ -931,7 +931,7 @@ int vb2_core_streamoff(struct vb2_queue *q, unsigned int type); * @fd: pointer to the file descriptor associated with DMABUF * (set by driver). * @type: buffer type. - * @index: id number of the buffer. + * @vb: pointer to struct &vb2_buffer. * @plane: index of the plane to be exported, 0 for single plane queues * @flags: file flags for newly created file, as defined at * include/uapi/asm-generic/fcntl.h. @@ -945,7 +945,7 @@ int vb2_core_streamoff(struct vb2_queue *q, unsigned int type); * Return: returns zero on success; an error code otherwise. */ int vb2_core_expbuf(struct vb2_queue *q, int *fd, unsigned int type, - unsigned int index, unsigned int plane, unsigned int flags); + struct vb2_buffer *vb, unsigned int plane, unsigned int flags); /** * vb2_core_queue_init() - initialize a videobuf2 queue From patchwork Thu Oct 12 11:45: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: 151973 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1165624vqb; Thu, 12 Oct 2023 04:49:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFY82JQ4mgAtoYS1SMoXRCDyoGpHg9b9RyexmkbfoGsyNtdXyekxExOE5y4USVyer4ffINO X-Received: by 2002:a05:6870:f708:b0:1d5:1a99:537f with SMTP id ej8-20020a056870f70800b001d51a99537fmr25520222oab.2.1697111356723; Thu, 12 Oct 2023 04:49:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111356; cv=none; d=google.com; s=arc-20160816; b=QyVQlMxUn3KY4oq+RZgKIJI8Q0J/eYUUaz7UCWIaQXhCAzlCzH4T9jlkkFbK4lMoJq b9xmUXESCK9HSPay6h1/ij0POEaVopEBAKql2F9tIZt1EF1konnvciW2yLwKzzf+yo7/ GHbFmK5rL0SO3Rp8HkK5HzrvLwlrvRrKifBidEvBL5tloxOBye6+DM+nHIoDNPQl7dw+ 1qNNPMVh88zrR8WUJw5GcR4b1BY82Kupt82cvvTVir51r0DLOW75OWGoY575woPYGdk7 T0Q6qYpzKLxuGA478FpNd/IiUkCz+3IqKZa/fB1JmRC80D1HMC2oz1Wofmj59rm3tOXA U3lg== 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=wWQRy1zk86ZPk2B0Cm/yxC2KTJkecgQRSx89z6xvuWw=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=nNHcmeJs5gfb0IXfr73INCFWcWVqSiFPb7QVgsRfFsIIJIn7rOsgqPzLsE5UFR8eTF Li36h7WRZ3ZziZpRw5SK/4BvzEf7t1efOE82rTqZ55DFddrxnm5i9Liu7ZM8kF4V4rQX ExAFvRi+rLjmN95bbL9BUCCeJqi71KKZpsnfoEi7ybAXoQiwunuOx2geiR3HAS0jUklT ITD55YHpnFm9m/i2VIu6tPPr/ZITLi5EVXSuBG5Z+kYSfSv2Dp7Y+gHLA9o6xCMej3Ix 9kXrxFPHlY6PnmVVrgRtHL7nVTmypiUylCqkzPsuCMZMhtbruzXS7Tg+dc+AhfhezEzi C8Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=kJczl2w3; 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 k63-20020a638442000000b00585a4fc83f9si2013126pgd.291.2023.10.12.04.49.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:49: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=kJczl2w3; 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 47FF6822F8DF; Thu, 12 Oct 2023 04:48:57 -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 S1378555AbjJLLrO (ORCPT + 19 others); Thu, 12 Oct 2023 07:47:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378329AbjJLLq4 (ORCPT ); Thu, 12 Oct 2023 07:46:56 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07EF9A9; Thu, 12 Oct 2023 04:46:53 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 DCE65660734A; Thu, 12 Oct 2023 12:46:51 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111212; bh=VYm9fOq3n1h53fXDICN4BDe54mzYrLR/ixXCM7EATlk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kJczl2w3KCViLRq4xPy+xtYekhNCqOefhubjiWjYrdm1df6bb0MppSaoVb8m4Pn84 cUiKESgJ6hj82R2GCkXXARUyGsgR2ns6WJgqTrRfGxfbvWjC0RtM7TFgAxgI1JctUj JBoib68OTt35iZNb2Eh0hgH2UpV0xQyNpgsMoZl6gH/G6v2oR40M5bA7LtB8+kf4gT RWBG29rZ3u9KDoBrWIBS2J7EcPAW7AAeyh8ioOfZZ3A/bCwaxLphp3xtWJYUGLtaAY x/rTmTkiL/BMhfJkqmFH3mHdvIp9Gxtp/Jn1ozce6Ew2NZH6uDLC6o+xZ8ZUqubonU mffEr+ebJ/WhA== 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 v11 05/56] media: videobuf2: Access vb2_queue bufs array through helper functions Date: Thu, 12 Oct 2023 13:45:51 +0200 Message-Id: <20231012114642.19040-6-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 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 howler.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 (howler.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:48:57 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550238133120422 X-GMAIL-MSGID: 1779550238133120422 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 in preparation for when buffers can be deleted. 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 968b7c0e7934..66d0f42f5691 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -408,6 +408,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 @@ -436,9 +461,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); @@ -446,9 +469,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) { @@ -456,7 +479,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; } @@ -471,7 +494,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; } @@ -494,7 +517,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; @@ -522,7 +545,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); @@ -563,15 +586,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", @@ -611,8 +639,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; @@ -648,7 +681,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; @@ -1633,7 +1671,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); } @@ -2034,12 +2076,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)); } @@ -2073,9 +2121,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() @@ -2224,10 +2277,12 @@ static int __find_plane_by_offset(struct vb2_queue *q, unsigned long offset, buffer = (offset >> PLANE_INDEX_SHIFT) & BUFFER_INDEX_MASK; *plane = (offset >> 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; } @@ -2615,6 +2670,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; @@ -2665,11 +2721,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; } @@ -2678,12 +2741,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); } /* @@ -2811,15 +2877,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) { @@ -2862,7 +2930,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. @@ -2889,7 +2958,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 @@ -2960,7 +3029,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); @@ -2969,7 +3040,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 Thu Oct 12 11:45: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: 151947 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1164684vqb; Thu, 12 Oct 2023 04:47:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGACPViVhJBOMosiS8IZoxNwWORujTbbsX1zH7znvRrWePHCRBaCYcn9weUTxuv1puNdX1y X-Received: by 2002:a17:90b:4f4d:b0:27d:9b6:ec1b with SMTP id pj13-20020a17090b4f4d00b0027d09b6ec1bmr3923372pjb.4.1697111238707; Thu, 12 Oct 2023 04:47:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111238; cv=none; d=google.com; s=arc-20160816; b=eEhHZd37BUpdquJIGaW3702VZcIqg1b9Oo10oV4sbUnjDME1Yh9tjOnk6JT2NdKieQ KRHzOkPEDysioKdFeVlcf7194qbWdL/QXr+sXmpYFj1IoGFq161Co5qrJMhxaDRiGiOb luD9V8eHx67jnBYIa/1tPgVAEqslbg+ytGnJxKLqGULlUwk5qHRcQxWTt0FMTj5uDpHX 0XqLygsTAlwE+D3U2Ek185u/u849Vg5Bk/wWJVitlMQPn2Dot1fLQbnvSsYtEJGVo+R8 z+iW16meD9Vk0zul2cl/1aNHrSrYKOufUCIsyP5Sp4OtjUgI9PSZhpT/a06UFpZAD+9S 4bJw== 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=AfjxoPu9oQOE+yd42J+m8aDDR1ZRoe42v2TYb5DGPiM=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=IydsXFxl4b0W+qJQwSb0YfMjfTu54mDljTO0GwT/sGFTYAVlqY/GoX2UNLuo20Alou T5FalGXaW6u9OnFE+1E857oaudeSxdcNdk6wIkW5x3XIWDqc2K1keVFg3ldKJ+jM32q+ gNozcKljdvVeO9ZefaZj+DyO+ywUPn36ogqINPiyoPoDwf5qNUHyKqzvvWiMWhXyzPO9 +od0PH6WYqXZ0KzyJD62h0xtUzyGjkAIaSDbsgTeS3tz0Pmeb5KpKPT/uUKKqAZ8v/Pi ynzlp888rGDUhZ8RXwW5nAxz5GzvcuJPQUGPdgdBXtHzEfxkmIzYwmgPWWIsfISw+lMP 3RIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=hjFh6xvA; 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 qe15-20020a17090b4f8f00b0027d047d9070si2352742pjb.91.2023.10.12.04.47.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:47: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=hjFh6xvA; 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 ED440822CBC1; Thu, 12 Oct 2023 04:47: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 S1378568AbjJLLrL (ORCPT + 19 others); Thu, 12 Oct 2023 07:47:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347167AbjJLLqz (ORCPT ); Thu, 12 Oct 2023 07:46:55 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07F8DB7; Thu, 12 Oct 2023 04:46:54 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 67E56660734B; Thu, 12 Oct 2023 12:46:52 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111212; bh=LnC/LgabfPomUWVgSsCIVeH8QJzOQ0dsjpcXwnRWi1w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hjFh6xvACVR4dphfZJxcOqem6SOEhSzu4SjAiP6ObmI35oWJAZu0EMWDuNlHuX1OD 2fQ2bmWJ/d1MakJ5WhgHV25ZSHDZD942xb3BBcsP7OOgODC8Cx36sB29eReR1ESFnd UcWNNZRsGy4sTLOKdYKrm/tYMF4oqjvhQdcGSERpljlmAS+icSgN7oeWzEK/1AwYDh u8OnOufan0XhzTKyr/k62xSdol/b+/T6mvvnb0cnGT3xCKNJ/f7EV+uFOqjl/M91SK Pq6umy3sDCJ0H6PdC7/DVzpM6RVN055/HI/0hMUnHh6JdHM/Szbbb1oN1p9qUwJgZp vCqSVec8JRMCQ== 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 v11 06/56] media: videobuf2: Remove duplicated index vs q->num_buffers check Date: Thu, 12 Oct 2023 13:45:52 +0200 Message-Id: <20231012114642.19040-7-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:47:18 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550114215526981 X-GMAIL-MSGID: 1779550114215526981 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 3395e702ad1f..b9df2bdae389 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); @@ -829,10 +824,6 @@ int vb2_qbuf(struct vb2_queue *q, struct media_device *mdev, return -EBUSY; } - if (b->index >= q->num_buffers) { - dprintk(q, 1, "buffer index out of range\n"); - return -EINVAL; - } vb = vb2_get_buffer(q, b->index); if (!vb) { dprintk(q, 1, "can't find the requested buffer %u\n", b->index); @@ -904,10 +895,6 @@ int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb) { struct vb2_buffer *vb; - if (eb->index >= q->num_buffers) { - dprintk(q, 1, "buffer index out of range\n"); - return -EINVAL; - } vb = vb2_get_buffer(q, eb->index); if (!vb) { dprintk(q, 1, "can't find the requested buffer %u\n", eb->index); From patchwork Thu Oct 12 11:45: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: 151946 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1164678vqb; Thu, 12 Oct 2023 04:47:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF9PCQmZmqENVqISHlgrxZcQmizdsZ+H8481HGQxNrQjziE6r+t/aBwSKPnP7ppEISuyN9f X-Received: by 2002:a05:6358:e91c:b0:143:6813:bffa with SMTP id gk28-20020a056358e91c00b001436813bffamr19042305rwb.0.1697111237897; Thu, 12 Oct 2023 04:47:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111237; cv=none; d=google.com; s=arc-20160816; b=dBNtM84NdN7Z7pyRwgHNOncaqfECh/C88yHAnSjFKu0IUejD/jhaHBG+Tzc+9gwBbA uDQvrtxXYbMWEmlX8vq3CddX+UERrK8Yv7J8OAbcde9fNtL9w+4zEcKC4FtLi5eCXx82 0HUP93ovUDj6hwh0ljqYe++6WIrJlSrGTB6s3Hk2SugNru9CWny5djnVfIHVSbHCm9b1 NZzJLhaP+qaQlxFyzNTgfqjveaI6mvdqx5BA+tyd08j6tdfxNC6TSN/xN5O3DVGWHMbJ SH4lST77q2NrafbYXd5GgFr7UOIHdNwV2iThESRm/HbtMM5eK5fYtzZ95E+6u2rljWlP dLFg== 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=UcK1M6ba+qPsIpOiLnurj5VZil6Dh9wjABNphkn5ocE=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=t3Xwrh26GV0MsuTG58KHA4Wv4RdZCCKxX6Nm6C0J5NXpaFBOf2cpPvjBWNNCsD2U8W IkJvDn8km0RK9krO5i09t2WGKYnpOnprsDoiHvFPd2xKec6qCPyvEzY+uz6h40e7PsVr 0UV7rgTEfXDUbNSEC3/dsO0BkMTALfbhk/xmprCje+WngsbSyaeGOOHozHFgQtGVfiGB Zxf+aJLP80JfFjrQUDo2kE6HTB/onwBHGt8s/kbhKxRCbKbxWzv06+yxdZp6G8Z+eZXo 355qlpxFQ+HI5UIHuE/TlVS4L76OzPkRacGEEt2IjRe+/pdCYNYhrLYC62joZ0GXvusR sNHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=cgcyRpJV; 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 x37-20020a631725000000b005893c5bd119si1951781pgl.425.2023.10.12.04.47.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:47: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=cgcyRpJV; 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 BE1A5822CB68; Thu, 12 Oct 2023 04:47: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 S1378400AbjJLLrH (ORCPT + 19 others); Thu, 12 Oct 2023 07:47:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347190AbjJLLqz (ORCPT ); Thu, 12 Oct 2023 07:46:55 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A786BE; Thu, 12 Oct 2023 04:46:54 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 EF28A6607350; Thu, 12 Oct 2023 12:46:52 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111213; bh=lM3wXK65Q+RBpyeYExb53Y3bnLmIcGL+rErhrVO2B80=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cgcyRpJVkzZnipPZ8a0wBHk4u4e5u/VyFtdTKHoQQNPvYdMqr55oBWzpZfHTh0e3a giMKZFpip9opPC9lVsURFcU9P3Wj9XWNpC70hS6dpQ/r/WdgvcfN3HfOnj1OUc7CRt lRpBSRFtvqaM58EaOSI2bJuIp6/U0sbtw6oyvepdoOf1EJr7aCkFzNg2gDCtVE+Kua 0LwWWKKKOOWsZALkqnbAtULrnrj8X8jT/sMTjNq1V3CFj1LZFhLSLr1lKWGxOCkUqO RL2gN7+WDWiHGkxWzKUVdHEngBMOu03bnHiTG4kZD2u6Ifn2FRLFSaUTF1ye1+qWdW gvmt79KyABSZg== 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 v11 07/56] media: videobuf2: Add helper to get queue number of buffers Date: Thu, 12 Oct 2023 13:45:53 +0200 Message-Id: <20231012114642.19040-8-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:47:16 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550113187535612 X-GMAIL-MSGID: 1779550113187535612 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. Signed-off-by: Benjamin Gaignard --- include/media/videobuf2-core.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index cd3ff1cd759d..8f9d9e4af5b1 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -1139,6 +1139,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. @@ -1147,7 +1156,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 Thu Oct 12 11:45: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: 151949 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1164744vqb; Thu, 12 Oct 2023 04:47:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEZk+EPjVXSsCQjMn+E0x9LKtKbv3JZZKHaU/Z9QPor5AkrgfIGkwTr7GFq03V5FK4bVkGT X-Received: by 2002:a05:6a00:1d22:b0:693:38c5:4d6d with SMTP id a34-20020a056a001d2200b0069338c54d6dmr26407754pfx.2.1697111251388; Thu, 12 Oct 2023 04:47:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111251; cv=none; d=google.com; s=arc-20160816; b=iCvbZI37lKXIMAFXOH0PmFBAEdiSdj//n3rA1E3TdST2L1eFgq6qZ9UbjeAgP4dbnt JYRDvRvyNhRAdT/+p206a9yJgNE7hpysa/tT2trPESYNWSdFwXml0iLz8CAYcaU9eCa3 81AguV8HrpiZ9qzcik2i//uC7Bx+QxLpD/NUb1DgiA6ucaJ7Vxqno5HI3v8usKgIzbPX dZIfJZYe+I1DZdfgqP5tL++QW/vNu96FTBaFZxEb14DV4rqcIfASzR+eEGRgBRRZ4bzt M5e3mW2gq8rfrdRWiIE3n1NoHHez24v5Br2QUw/Os+1WdR1w5HRgXayAJmVQSvB8iOj2 Q1SA== 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=TuEkp0nJfxr6fZIcEGQsy9e6YgySOSd0gSRU5/uBwbQ=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=WoFLmn/95G/hHJ+lszbDo3TQYdx10PleLnzieGQbODWKY75dOzBWIV2naDebRJOuIE 7msWzpr23JMkIGRLZ6KK7P5hoF2tZm5g5k3BBcVHOi7bvzMV9gWcUVqdBjJfCI2HWnJQ 641Y/QYK2QrSCFsjQXZRsEPf27JDhc28hsCXfD9rRgrzTOlweSLiK9Cs28qeaCmYErKr vkS+8yIPBjf+M/igFMRxQDz5wuzkLtul7RFJhMjfwDZ89FiNVecqBnyWz087vrv8oBif Iuh7598l5KY1l2bOLqIGbUrdkKPvHu51UUo3ZebgYkUv3oRPLUavUoX81uhr37Gxp/ri MKGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=GF1qAOun; 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 h12-20020a63574c000000b0059bb496956csi2097975pgm.202.2023.10.12.04.47.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:47:31 -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=GF1qAOun; 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 A0D6B822CBCB; Thu, 12 Oct 2023 04:47:30 -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 S1378872AbjJLLrU (ORCPT + 19 others); Thu, 12 Oct 2023 07:47:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378356AbjJLLq5 (ORCPT ); Thu, 12 Oct 2023 07:46:57 -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 09CCCC0; Thu, 12 Oct 2023 04:46:55 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 7CFEA6607351; Thu, 12 Oct 2023 12:46:53 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111213; bh=XZKIOuHPlG98fAVl1AGsI7xcqz0nwN3hGsPnWR2e1/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GF1qAOunGYcbWAy3fjIcqN+y+pTHDZzq3znZDCCcJ0jviq73W+rmhKnVleissSeDq g8VJ0wh8lOJJY1+jY2ijIAcQ47a4zrIvLwx7fORGwPq0zEg1ScPs+N6ZREEcSSWYU7 /EranrvpOENJeae6/W1+qG4vZQahdHlDAciMnFTWkazlCUExhg9bkFC4fhxPjt2tpv GCUJvWQHHf+aifXQCG1F0H10AhooA6AsKgFViGZ2in5ots/gjKFHbErtNonhylIaLE of/5sCqq2l47gIuihHgdaiA9FBvoo1mTT0KssLye2v3uNGcD/j9OMC+GVQdHI1VHcI vcCrDAmW+Weow== 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 v11 08/56] media: videobuf2: Use vb2_get_num_buffers() helper Date: Thu, 12 Oct 2023 13:45:54 +0200 Message-Id: <20231012114642.19040-9-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:47:30 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550127285379444 X-GMAIL-MSGID: 1779550127285379444 Stop using queue num_buffers field directly, instead use vb2_get_num_buffers(). This prepare the replacement of num_buffers be a bitmap field which is need for delete buffers feature. Signed-off-by: Benjamin Gaignard --- .../media/common/videobuf2/videobuf2-core.c | 111 ++++++++++-------- .../media/common/videobuf2/videobuf2-v4l2.c | 4 +- 2 files changed, 64 insertions(+), 51 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 66d0f42f5691..c427aca285e3 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -429,6 +429,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; } @@ -512,12 +514,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; struct vb2_buffer *vb; - for (buffer = q->num_buffers - buffers; buffer < q->num_buffers; - ++buffer) { - vb = vb2_get_buffer(q, buffer); + for (i = vb2_get_num_buffers(q); i >= 0 && buffer < buffers; i--) { + vb = vb2_get_buffer(q, i); if (!vb) continue; @@ -528,6 +530,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++; } } @@ -539,16 +542,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; 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 = vb2_get_num_buffers(q), 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 */ @@ -559,7 +566,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; @@ -585,7 +592,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 < vb2_get_num_buffers(q); buffer++) { struct vb2_buffer *vb = vb2_get_buffer(q, buffer); bool unbalanced; @@ -637,19 +644,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 = vb2_get_num_buffers(q), 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); } @@ -680,7 +686,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 < vb2_get_num_buffers(q); ++buffer) { struct vb2_buffer *vb = vb2_get_buffer(q, buffer); if (!vb) @@ -806,6 +812,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; @@ -821,7 +828,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)) { /* @@ -839,7 +846,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); /* @@ -934,7 +941,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); @@ -968,10 +975,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; - int ret; + unsigned int q_num_bufs = vb2_get_num_buffers(q); + bool no_previous_buffers = !q_num_bufs; + int ret = 0; - if (q->num_buffers == VB2_MAX_FRAME) { + if (q_num_bufs == VB2_MAX_FRAME) { dprintk(q, 1, "maximum number of buffers already allocated\n"); return -ENOBUFS; } @@ -1000,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, VB2_MAX_FRAME - q_num_bufs); if (requested_planes && requested_sizes) { num_planes = requested_planes; @@ -1032,7 +1040,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, @@ -1053,7 +1061,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); @@ -1670,7 +1678,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 < vb2_get_num_buffers(q); ++i) { vb = vb2_get_buffer(q, i); if (!vb) @@ -2076,9 +2084,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 < vb2_get_num_buffers(q); i++) { struct vb2_buffer *vb = vb2_get_buffer(q, i); - if (!vb) continue; @@ -2120,10 +2127,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 < vb2_get_num_buffers(q); i++) { struct vb2_buffer *vb; struct media_request *req; - vb = vb2_get_buffer(q, i); if (!vb) continue; @@ -2168,6 +2174,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) { @@ -2180,12 +2187,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; @@ -2513,7 +2520,8 @@ 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, vb2_get_num_buffers(q)); + q->num_buffers = 0; mutex_unlock(&q->mmap_lock); } EXPORT_SYMBOL_GPL(vb2_core_queue_release); @@ -2542,7 +2550,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)) @@ -2580,7 +2588,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)) { @@ -2629,8 +2637,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 @@ -2640,7 +2648,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. * @@ -2690,7 +2698,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; /* @@ -2740,7 +2748,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); @@ -2759,18 +2767,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; } /* @@ -2964,12 +2977,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. */ @@ -3016,7 +3029,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 b9df2bdae389..daa07f62c219 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 < vb2_get_num_buffers(q); i++) { vb2 = vb2_get_buffer(q, i); if (!vb2) @@ -762,7 +762,7 @@ int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create) fill_buf_caps(q, &create->capabilities); validate_memory_flags(q, create->memory, &create->flags); - create->index = q->num_buffers; + create->index = vb2_get_num_buffers(q); if (create->count == 0) return ret != -EBUSY ? ret : 0; From patchwork Thu Oct 12 11:45: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: 151948 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1164741vqb; Thu, 12 Oct 2023 04:47:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFP9lpmhzgGET1qMs3avuxS25G/8os4xants2uETL91OiyHEUKmdmgQAfHwQckgLjyRDXl/ X-Received: by 2002:a17:90b:4d86:b0:27c:fd8d:164a with SMTP id oj6-20020a17090b4d8600b0027cfd8d164amr5423573pjb.1.1697111250013; Thu, 12 Oct 2023 04:47:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111249; cv=none; d=google.com; s=arc-20160816; b=CVmfKs918LJqQSieyXApYvUZzthLGde1O+AhWILt8uku9aE1egfN27CQiaO04M7vNm q+qfc9BneUxz+g5kHvEr+ZYuuOex8pnqLwoaxyfu/fuTCB7mL3lsqLwAWb64GCzlrcY2 Ha/MM0Oxqj02hRe//5cQxuWjAE7Q+PKO3xM6oT0dszXaN3J3RBGWxbffbVGzcJL82aQ2 4PpTsEcmLAK/qkxe1Ht90T22+o+uubALNVunAiGMmYURJp5yOfoCGjkewv5/zrwOqUqF FdjG2TejFsV4zbsMj5HDDPwkM+ua8o/D1W5dC0RwpBWbWmmfHLrNhcXf8Ko1bK/4o3VD uEUw== 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=U9SUHzV9OOe5vx4PeBkdle/xt/W+APydzs+3ArsKJaQ=; fh=YhVWgOX82fKLE5M+MoEX/CwrdcPd8SQ1dctjbZBk3rU=; b=dM25G5iLMdwexHtjKhqfnLR4llIkSc2EoQ5DyiEh4Mt8X+jb5TyonxkcWVLOaZucBR qn3NgWwJ4S59NXLxmrgIu+dfle2GTanMb+oXiQeKIXER+h5AG03wO/4scmyRSH2xNE5P H2b6p0jhnA8TenGn9hPQUvbcdp/sjTGv04O/jU5Gi5owMSoga+B4DmoIwlu65f4o/5tG L+T1rjjyQFA2Itg6kywGjQPD1+FPsQ4FMuop+OotPqqCcww4zZumoqdS/WOiZNZu86tC cYIOtkhuvmrncsCIOllgRZu6hQQi/HiUwJVZk8u/7QrcQ0s4o0JOj4kBmRMEc3MevGrI Av8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=aCrikTOF; 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 l7-20020a17090a49c700b002773294d636si2110581pjm.103.2023.10.12.04.47.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:47:29 -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=aCrikTOF; 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 6B70A822CBCB; Thu, 12 Oct 2023 04:47:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378547AbjJLLrS (ORCPT + 19 others); Thu, 12 Oct 2023 07:47:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378358AbjJLLq5 (ORCPT ); Thu, 12 Oct 2023 07:46:57 -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 88E4BC4; Thu, 12 Oct 2023 04:46:55 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 060206607354; Thu, 12 Oct 2023 12:46:54 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111214; bh=5KfiWYUr0TuNoyvJdKtw2RV1255T2m+jeyJI0vr6Ff0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aCrikTOFQybhK78pRCHx52ATJ9QJM/2nih3qOdvHPt30k7OwFV+0OqwpP1uHh6jeM IagDd2MgB1FK7117PgJtoRgcv8MI4a9n0rcmnADoF+BEpfnfLgR4zapCwExnMb6BPI VI/cAmuc+8H4d+dbulHdbcEr7V/ZxswF/fT2F72zvmANmQ/OG+ZE36CNpjgH0AZzjr oSCFEYVg5BptWYhbs60sJFLVARp8V4YQijlI0e4M3xxWArbN0Gz4GqGwVtWKhPeDtK EMXdR6l983d1A7vjIZBHoWxSXtOp6+Ra8JMz3Iey/I83Ei1JZ5s2mZO/83RIBK8XKm mxFPoM8dmj7tg== 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 , Zhou Peng Subject: [PATCH v11 09/56] media: amphion: Use vb2_get_buffer() instead of directly access to buffers array Date: Thu, 12 Oct 2023 13:45:55 +0200 Message-Id: <20231012114642.19040-10-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:47:29 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550126185948712 X-GMAIL-MSGID: 1779550126185948712 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 CC: Ming Qian CC: Zhou Peng --- drivers/media/platform/amphion/vpu_dbg.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/amphion/vpu_dbg.c b/drivers/media/platform/amphion/vpu_dbg.c index 982c2c777484..a462d6fe4ea9 100644 --- a/drivers/media/platform/amphion/vpu_dbg.c +++ b/drivers/media/platform/amphion/vpu_dbg.c @@ -140,11 +140,18 @@ static int vpu_dbg_instance(struct seq_file *s, void *data) vq = v4l2_m2m_get_src_vq(inst->fh.m2m_ctx); for (i = 0; i < vq->num_buffers; i++) { - struct vb2_buffer *vb = vq->bufs[i]; - struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + struct vb2_buffer *vb; + struct vb2_v4l2_buffer *vbuf; + + vb = vb2_get_buffer(vq, i); + if (!vb) + continue; if (vb->state == VB2_BUF_STATE_DEQUEUED) continue; + + vbuf = to_vb2_v4l2_buffer(vb); + num = scnprintf(str, sizeof(str), "output [%2d] state = %10s, %8s\n", i, vb2_stat_name[vb->state], @@ -155,11 +162,18 @@ static int vpu_dbg_instance(struct seq_file *s, void *data) vq = v4l2_m2m_get_dst_vq(inst->fh.m2m_ctx); for (i = 0; i < vq->num_buffers; i++) { - struct vb2_buffer *vb = vq->bufs[i]; - struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + struct vb2_buffer *vb; + struct vb2_v4l2_buffer *vbuf; + + vb = vb2_get_buffer(vq, i); + if (!vb) + continue; if (vb->state == VB2_BUF_STATE_DEQUEUED) continue; + + vbuf = to_vb2_v4l2_buffer(vb); + num = scnprintf(str, sizeof(str), "capture[%2d] state = %10s, %8s\n", i, vb2_stat_name[vb->state], From patchwork Thu Oct 12 11:45: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: 151952 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1164821vqb; Thu, 12 Oct 2023 04:47:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHcyYM0fTWo+7Oo7YSkUJX5Qt6nEAG1AMnA3STxoSjylIEDB9K2LO8YyeOg2fnQDtetf7ly X-Received: by 2002:a05:6a20:5484:b0:171:737:dfaf with SMTP id i4-20020a056a20548400b001710737dfafmr10213486pzk.5.1697111261434; Thu, 12 Oct 2023 04:47:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111261; cv=none; d=google.com; s=arc-20160816; b=MfZh655wmvsPy5tJWqut3wkwG/+exA8E8GujAp2UxW3V9rbnJ7W2pJ8K7lpPZctpxI Tu82yTC7VZha1aQR5aIjNPyF4FLzf9Iv+txAOkTWHH7Ug+YxEfKtuvzhjIYFJGJXMMvB 0lhFm45ZB5+f1EI4ASNNNHwTvUD2Q1iJHCs/qSAa8sAee5b5dSiKRNX2br/w86HKaLGW xNS33Bofu8GK+2Kd+rmkY4zBbldxDPhYGo0xQbKjfqMPN89IZPbv8PJVA3vfMASEYyNj dc9WV+vITxX95G/Li6pM2YBugUtSC1GScfOhcyKGE2NDT/LQ8v/06Xkakjjc8+aKV7O9 uyyw== 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=CQMe5k+Loh3Shj8fNSo9spwZuKtXp194mTPiUqm2HQE=; fh=YhVWgOX82fKLE5M+MoEX/CwrdcPd8SQ1dctjbZBk3rU=; b=DZPo78e8AhG2gXAWyzpbw1Zpv9oN/YuR++y9ehGpRhFC65pr1EnuViLM72YS6Cu32l W8KghoKTovGM+mvZ0hxgTgTBI9DSMvq9tQ4N+zK82pzFLTH5q7rN2xLyDOx2YNbY7sxI hc+KZsA1V+sbMfvKLPRz2j8oCL9kEDF+thPKjro2vVRKCV60IOlatCyRS8auQghqX16K YNQpKpVAjjjJofOeNnPJI0xXhcoEMNxUKEQ166W88i61tTJrebfOUOI2xhAoqO7r5l++ b7LsvRuv5x+5jvoAoe5j5mu87dxiP8HDnu+JDIUQKzAdx1qrEU+xKCAzn/yDeQpO40Ml MRvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="ZRiZjv/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 d11-20020a170902cecb00b001bdd1f48f91si2248767plg.564.2023.10.12.04.47.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:47:41 -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="ZRiZjv/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 06F62822CC03; Thu, 12 Oct 2023 04:47:39 -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 S1378551AbjJLLr0 (ORCPT + 19 others); Thu, 12 Oct 2023 07:47:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378367AbjJLLq5 (ORCPT ); Thu, 12 Oct 2023 07:46:57 -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 0AC45B7; Thu, 12 Oct 2023 04:46:56 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 8199B6607355; Thu, 12 Oct 2023 12:46:54 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111214; bh=fUpiGVSgUDEJ7+9Xx6wCjlwiYUUChFkfdk0Qh3AitbU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZRiZjv/DeBap13OYizL3LhT/ze673fBiKlHtq+PvCJYQfuUOALJHLB3B5n47IrbM3 Lx4GyeyrfH5Pev4+MXFCr0vIePnxw7mKH9O4jCBh42IS8nRBs6He/m8wlFZHqu1fzJ NMYHlL/vf0U8Vgsfzqjr0dDXKyYeF5HkX0/CPnZN9bwzxCd6eBe9iG5nTekVGtaRBD xOEQkwKKC/2J03T7Fpj+w1U56p+VblzkMaM4cPcVUiMdr/n7xw41uzvoyPbXSxKUln M98kVZ9dopqVHbslRwGWuKro2f4G7YEzBnbzfht0RcCTATCk/x4SnWereHK83JpFsJ 7IfkroYNQq7Sw== 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 , Zhou Peng Subject: [PATCH v11 10/56] media: amphion: Stop direct calls to queue num_buffers field Date: Thu, 12 Oct 2023 13:45:56 +0200 Message-Id: <20231012114642.19040-11-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:47:40 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550138113014734 X-GMAIL-MSGID: 1779550138113014734 Use vb2_get_num_buffers() to avoid using queue num_buffers field directly. Signed-off-by: Benjamin Gaignard CC: Ming Qian CC: Zhou Peng --- 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..940e5bda5fa3 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 < vb2_get_num_buffers(vq); 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 < vb2_get_num_buffers(vq); i++) { struct vb2_buffer *vb; struct vb2_v4l2_buffer *vbuf; diff --git a/drivers/media/platform/amphion/vpu_v4l2.c b/drivers/media/platform/amphion/vpu_v4l2.c index 0f6e4c666440..87afb4a18d5d 100644 --- a/drivers/media/platform/amphion/vpu_v4l2.c +++ b/drivers/media/platform/amphion/vpu_v4l2.c @@ -439,7 +439,7 @@ int vpu_get_num_buffers(struct vpu_inst *inst, u32 type) else q = v4l2_m2m_get_dst_vq(inst->fh.m2m_ctx); - return q->num_buffers; + return vb2_get_num_buffers(q); } static void vpu_m2m_device_run(void *priv) @@ -587,7 +587,7 @@ static int vpu_vb2_start_streaming(struct vb2_queue *q, unsigned int count) fmt->sizeimage[0], fmt->bytesperline[0], fmt->sizeimage[1], fmt->bytesperline[1], fmt->sizeimage[2], fmt->bytesperline[2], - q->num_buffers); + vb2_get_num_buffers(q)); vb2_clear_last_buffer_dequeued(q); ret = call_vop(inst, start, q->type); if (ret) From patchwork Thu Oct 12 11:45: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: 151953 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1164827vqb; Thu, 12 Oct 2023 04:47:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFGP7wBmf+qM7HRSMOF5/N2pBf+SavxbSKumHLLNlb7wcxgPWNHGgIyICCjjwsT1JqpO0/S X-Received: by 2002:a05:6a21:197:b0:14e:2c56:7b02 with SMTP id le23-20020a056a21019700b0014e2c567b02mr29895329pzb.0.1697111262050; Thu, 12 Oct 2023 04:47:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111262; cv=none; d=google.com; s=arc-20160816; b=KmOjcvMew9hFUbyQtl+P+OpQBswqAYbyfaB5YIu+nRGTZCBV/2o7yoVY9CaK8DNSCi jqCzzW4IfB1h3BBp9Zyp8rDbyLvVJhj+67+o9qWm2rs2T4KJuHyeHNMr+TevpBGR1ZCm gM1DstvXJhByv0UoWJCb/KZVmULmbFShHTCx4lAC1yeLQldxZs1wwwV/IVlMJ9oiIxib T2pPgP3OfIA0RfGF9d642rZLP6qBRdDbfyMA/HUDGehqXKIPJ7MwL045thkXOncqDi3J VNyJY3IyzPWDjc8BL4D1wFL8aTKOx0tlGvaepmeLVxhvRgFX0XIWlGO+Lj0mDmj0GSCh aDzA== 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=qrE62SaPzWqVf99DN374z0e59gOg9GbF/UW/QBDlGcU=; fh=+NS11/YTnD7GglrGYsYnSnUacC2YXoJUirkP5/1okOw=; b=FvR40en6hHRKvjn7/rfelVxYDgUWHFtZ2413wvTLfH/HyFXD5kGG77y1QiC183K6Ab raSMOBkYFPRknMPrE8KmQT3/29d1yKiiuhWPUuqaWk7l3FmvhO5xFv1suj+t6F50zXxc Z2AwDhtvwWYB/lKz5MLsvCKdwTM/SRX3JLHGB00d8Obkay69+iMqVLIdYGkK/GPkhcsg xFf9y6aGfwRtnJjVDA1lrSFTv2RgzIK20tRIcVqoheSqa74xAsyQUWnIpTOi7cM4CXym dclrtxMJ8f32doZaC49g1mfnUgOxQceIaoyaILYhYU+b+Xay8v6QQzs+xTW6eGUuZwst gzlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=lIVod7tu; 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 r2-20020a632b02000000b00565e865d381si2038975pgr.447.2023.10.12.04.47.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:47:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=lIVod7tu; 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 E4096822CAFD; Thu, 12 Oct 2023 04:47:40 -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 S1347197AbjJLLrc (ORCPT + 19 others); Thu, 12 Oct 2023 07:47:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378368AbjJLLq5 (ORCPT ); Thu, 12 Oct 2023 07:46:57 -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 9D513CA; Thu, 12 Oct 2023 04:46:56 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 0FBFF6607357; Thu, 12 Oct 2023 12:46:55 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111215; bh=MGLugV4XKBfs3FJS6N+PAFm552tDzbWRNRQyV9Pe41s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lIVod7tuTGDcKArBuubJAgvI/LrQ1zpDOLm2MxFdMDrYt7XopXrYAFtjoTTgFjiH9 3ewK/S5MnhjfjC8b4QkFGqA/owyrUS4jD4+E3bDhLE22mdc8L9bq+xOWlE3C+9ADVM CNMVtMjxnG2KpJtGUPKbHOaNMpU/klmnTqqzeaPjfzksXPjW+oD+JGFWv63h4aDB0t iJmhMbi2ewqVua4+gSHRXruY35gF8RF3CJ+RY0DUzlbXpToSwt/gU3qNrdM2KyQHSh o7cyZ5IcMrCELw8MyF3/NW0Jo/HP+GSIQpZKIBbhQ2WhJmCSSXtV7UyzPMeDA0Cgea nb5+KD9jLs+HQ== 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 , Bin Liu , Matthias Brugger Subject: [PATCH v11 11/56] media: mediatek: jpeg: Use vb2_get_buffer() instead of directly access to buffers array Date: Thu, 12 Oct 2023 13:45:57 +0200 Message-Id: <20231012114642.19040-12-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:47:41 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550138465923619 X-GMAIL-MSGID: 1779550138465923619 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 CC: Bin Liu CC: Matthias Brugger --- drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c index 7194f88edc0f..73a063b1569b 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c @@ -598,12 +598,11 @@ static int mtk_jpeg_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf) goto end; vq = v4l2_m2m_get_vq(fh->m2m_ctx, buf->type); - if (buf->index >= vq->num_buffers) { - dev_err(ctx->jpeg->dev, "buffer index out of range\n"); + vb = vb2_get_buffer(vq, buf->index); + if (!vb) { + dev_err(ctx->jpeg->dev, "buffer not found\n"); return -EINVAL; } - - vb = vq->bufs[buf->index]; jpeg_src_buf = mtk_jpeg_vb2_to_srcbuf(vb); jpeg_src_buf->bs_size = buf->m.planes[0].bytesused; From patchwork Thu Oct 12 11:45: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: 151954 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1164859vqb; Thu, 12 Oct 2023 04:47:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFwEFMt0YXHjxj0JFr7IrV1tjA5UC9U9oFw30NZfJ4H25YRK+krOoXtROilphSkyaU53h8n X-Received: by 2002:a05:6a20:8408:b0:172:55c1:f1d4 with SMTP id c8-20020a056a20840800b0017255c1f1d4mr7549122pzd.4.1697111266241; Thu, 12 Oct 2023 04:47:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111266; cv=none; d=google.com; s=arc-20160816; b=lOtLwProYAehc7NbbMWqdU6l0SyZK8Q9/20hQ7Rmt0BCqwTC+2SmJ4AB1AtaaMHkMv oHL/wWH2vbouWQyKtZWUCB1SOCfXvg+V0PN+jp6k76+VFTLGMfxW3M+42rswCZEkE9F3 Q4CpNC+pyyPtcZGqGDHWH2WKz1N9B+kfVS3oscFDq+GNRUch0dg4fVi3/j4GBXdCnAU8 ux7nIK2JADvgVY2t0AFL4v/1qerZbL4ClsKqPpRnbSqxWU0SP4q/CNPo8HkJCi7FeiLM Cdksm6bAxRirXHN99oVfjEgyte+vcpR727jwx0fXZGYIM8q0NWeC0orlZ45bIogBQmFK ZC1g== 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=h6Wt5ZXH7wEpvAHo+HItmpVGbqd9IQOis/K3NFElIIY=; fh=+NS11/YTnD7GglrGYsYnSnUacC2YXoJUirkP5/1okOw=; b=R40MP8ttmGzQyMoa2ie6K5MhqygBn3EUXZhft/1Gf/3ZmpjvMWo1YCVDF2sbgYWjoX th+KRCuck7OVRSoJRJkaeNA2FOreZQuzGDQUFeI6N7fQ1WPJUInxR9vr8ErQ0Nze+Fge 4V1Z7XZuEQRpoHbsKshoT0sG42J9e16kX8Nif5+SYnSdF3clwjvTwejAnkRVUsW8lM3t a/KL+WDP5Scqc1zGbM7yy1GIXcxrH/3EISoFMygU1z3M7U6zmRKYXvoTVd2obu+r+ie3 kewBajqEM7/QyKYHz9Da87Y0yjumtVRkGhIWoMDDQ4wIqszfUZd0/+Z+wZwnwn6hgJjJ jniw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=YW55GPui; 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-20020a170902a41500b001c62e465391si292986plq.147.2023.10.12.04.47.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:47:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=YW55GPui; 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 41C74822CC07; Thu, 12 Oct 2023 04:47:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378684AbjJLLrg (ORCPT + 19 others); Thu, 12 Oct 2023 07:47:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378398AbjJLLq7 (ORCPT ); Thu, 12 Oct 2023 07:46:59 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D25DCC; Thu, 12 Oct 2023 04:46:57 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 99D886607359; Thu, 12 Oct 2023 12:46:55 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111216; bh=LFTEg/R/Wor/QN2odw5Z+gHhYekb/C2BteTgt/nxpjI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YW55GPuiNAo1nw5erBfgCCEKO1clLvGNiedo9r43ueQ6UvP4U/glJh2RXx4j9HFXc A8YqtaHCe53j68YuaVmPDgxDS9V/YBbGRDuCIB59vKMuHRABdjQzPnBhNuGVznZFRO 5buTjaiW5trxoTqgo6O2+6jLQG3NPgIas2KlC+TVpAxhH5QPJotUKwHX9UC/6s1ULN 9+UlEOfJ7/8QOxjcA5UqRS9/6pNLrJrSG5wnOsQK68z8fW6RyiQXTf/wXgkuQWc/g0 leTBSXi1j6a4JmymT+lNdj1dM1jnsT6LotrrSUf0BfdnxHNmTXrrMqBqStNM39WUbV CI/NBJI/Sl/eA== 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 , Bin Liu , Matthias Brugger Subject: [PATCH v11 12/56] media: mediatek: vdec: Remove useless loop Date: Thu, 12 Oct 2023 13:45:58 +0200 Message-Id: <20231012114642.19040-13-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:47:45 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550142742233428 X-GMAIL-MSGID: 1779550142742233428 Simplify code by removing useless loop by using video buffer index. Signed-off-by: Benjamin Gaignard CC: Bin Liu CC: Matthias Brugger --- .../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 Thu Oct 12 11:45: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: 151962 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1165265vqb; Thu, 12 Oct 2023 04:48:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFQX1GhDAnCej1DUmPsc9tx8BTqtK33b4PahWQHNkz44KYxzriIY9LotN9P3MmL8h0OMiJV X-Received: by 2002:a05:6a00:398c:b0:68a:6cbe:35a7 with SMTP id fi12-20020a056a00398c00b0068a6cbe35a7mr26808033pfb.2.1697111315558; Thu, 12 Oct 2023 04:48:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111315; cv=none; d=google.com; s=arc-20160816; b=zW7SjXWPgwqHo4oFPVB/pBSmyM5d7+DJDRnk0raqP8fkGutb4wszp6I1kNRmxVnVz2 ql6jKvxM9UblOcUfaZJ4V8YuQBgEDHDBOi08vpkd89u7NZfNFMI7zD0Lxpe7QvFGiTYW FXShZDgOuXLYhSsWFoz2ZZbCr23Wa6uX6tKaMjeZ8moVES4WjhBv9iJD5WCPayAsL4w7 Xl5rajjTewv7ReQqA1nwqGD3Q84Z+5uSQBtRf1ha45wBuNikuY7lQxVuIHW5veH+v2/D G1ez+WnR1dZKTx7I01QIcA8sAMfWoyNNmHQpFCi2LQWceQdce5yqIr1fWxZXWHuOck54 1zPw== 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/2/ke0QMz//Zl/CbcZOBhFw7DOZCKxXsEqeL6yrYVc=; fh=+NS11/YTnD7GglrGYsYnSnUacC2YXoJUirkP5/1okOw=; b=ZvSFWLplYKg/xRqPbC1PNdnhAiWxps7XmD/5AE2kZMA5te9rBlWlJ4zs/d0a1clVBp fI+4y6/eQOkaEp5+m8HYOL0FPDqLcwMANyUNBpmnEDfILu5Na9L31dZg8Mj5nk4K9/yV 8RDQXV8RDDh4saggwmll3kP21cskoqfaO8jsvzhJ8OJq757ED6cZwPvfC1+vE9iuh95j M2HVJPdA0Jzi1j9VlVMdDCVqOhfnmliSxEyw/MYNdAsY8GPJEzCAiuL1ca4rkCD4HKQL XbZRipDjHC+sUxcpu5NlHBFYukVYVfavCkK//11SNUD7pbIuEjHnL94nuwY5SxD+eeOf 1FyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=LfKNONkE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id r15-20020a63d90f000000b00584b293d17fsi2088501pgg.550.2023.10.12.04.48.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:48:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=LfKNONkE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 6BB9F80A64E5; Thu, 12 Oct 2023 04:48:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378699AbjJLLrk (ORCPT + 19 others); Thu, 12 Oct 2023 07:47:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378399AbjJLLq7 (ORCPT ); Thu, 12 Oct 2023 07:46:59 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD0B2D6; Thu, 12 Oct 2023 04:46:57 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 3379E6607360; Thu, 12 Oct 2023 12:46:56 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111216; bh=Zz1JpVQW0VlREf/hRiNNIL1yZp9YSUV1Bv2nIqpcIz8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LfKNONkE71F9KwTT+xG4nOO2wifyo0MmJf3Es5F9t6ugm7UeB0dePbu7IXqPUumeC y1EYiqrSSv9Ly7qT6QmRjwNf86grM9ro93QN30crPCN/wJt8m+xdV7QfgfgEl5VNhU x639PQKNR370CFkHK11OjZLuyyxeQg13pfLJple8BPzGQuqUwoFZwNeX4Uuae7Vje7 E4/ksubU0JacHGFrAKUJoBtefsVN9+YSWJ6ptHYIRaLkz3vw/MKr0GzeHWCVkx1R0e S5ugM5y7Bx/gbwrRpy99IlULx00nvDgN1wZ2KIYALO9pE6uUV/TMAXEWJBbM6cifhE PguiSqz9/JD4g== 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 , Bin Liu , Matthias Brugger Subject: [PATCH v11 13/56] media: mediatek: vcodec: Stop direct calls to queue num_buffers field Date: Thu, 12 Oct 2023 13:45:59 +0200 Message-Id: <20231012114642.19040-14-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:48:21 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550194783583883 X-GMAIL-MSGID: 1779550194783583883 se vb2_get_num_buffers() to avoid using queue num_buffers field directly. Signed-off-by: Benjamin Gaignard CC: Bin Liu CC: Matthias Brugger --- 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 eb381fa6e7d1..181884e798fd 100644 --- a/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.c +++ b/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.c @@ -912,7 +912,7 @@ static int vb2ops_venc_start_streaming(struct vb2_queue *q, unsigned int count) return 0; err_start_stream: - for (i = 0; i < q->num_buffers; ++i) { + for (i = 0; i < vb2_get_num_buffers(q); ++i) { struct vb2_buffer *buf = vb2_get_buffer(q, i); /* From patchwork Thu Oct 12 11:46: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: 151980 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1165799vqb; Thu, 12 Oct 2023 04:49:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEfiayT+2Jq9QyxkusgrLyWDFLigCMbrRk0c2J/QnNwvacJGbDIt2/kofx0THQqCwkb7mXz X-Received: by 2002:a17:902:dac8:b0:1bf:1a9e:85f7 with SMTP id q8-20020a170902dac800b001bf1a9e85f7mr27096412plx.1.1697111379802; Thu, 12 Oct 2023 04:49:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111379; cv=none; d=google.com; s=arc-20160816; b=inCFbT38NRdb1UBy5ziz3VSUkADeU7fu57wQJJiX2IlxGSZbwLoPdrZ+ib+svjzzZ9 RRzXzhzKmrR06ygUGOJpLMV8THXCebHKjdN2j+n5SfIEUO+8cF1kiE6AJc77B7J2REhF EFhRv2CYN/vOfh90kRjtmNutIVBzMgYy6WZ8HIN0LN8/rBPeXvLxmzg1HpKqj9e1MhB2 R9FrwFqgGHsj6vE3qQXcXc/l0Z5n3V9niI1ryxnoEA0oolSxSSGmgcAfWcbneSLFREcn 4dltqRhPFSWTMfoDrxcatciPFkXRAsF3XgmYs8Y8/jSVjv/RrQpm6UHgR9br0OGu/6or qFog== 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=B09KGIG+dGa9eyLZuv6Yc26Yj7bDl61pGIsQ9S5qtwY=; fh=NPTCYP6kV89VhZcTyqjnuKz2OW5UZUbu4oezKHT17AA=; b=u1sqbxUYbeAI5NYFkrFEPWjUeXhEGGypdxylIkEfZlIzwB6+NM1aw4epCoQk8/gZAu cqswcElYO00JTXYnNQimRbjkP3y4rQ1I7SQjanE1OQlLHNRxubURDoAJ7qRlX+aNK8Wt oW2CwH4jvBTESUxIJ1I2S3e6kuryUAhYd6E4fAqQIeZg+8bOouhKPbE5U9V8cHW4ewmc 9KC4iC4++0DyArMea1b6agHp8YjZ5EMpoSvxBoTZSWIXITFL9wjH574fy6MMLrKHfHi7 JR6QQpOw6Po9A0eI7S4pccsmebbU+OwIGlvo6/qv89VPOqzkSC73iKT0SOnmTWheifAx PBWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ZjxLpWSv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id x9-20020a1709028ec900b001b9736814b6si1931972plo.309.2023.10.12.04.49.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:49:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ZjxLpWSv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 003C08374BA7; Thu, 12 Oct 2023 04:49:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379040AbjJLLsm (ORCPT + 19 others); Thu, 12 Oct 2023 07:48:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378420AbjJLLq7 (ORCPT ); Thu, 12 Oct 2023 07:46:59 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B80DD7; Thu, 12 Oct 2023 04:46:58 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 B96386607363; Thu, 12 Oct 2023 12:46:56 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111217; bh=Hv6K096kuas0tXEWfFOtf8PobL2avYs7g7RnPKhbESI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZjxLpWSveTl5mI39YW3w3hnP4PhPurR3mMTD6rz5mEIWqdX9O6WD6n+3CP83NfN8y epDyHS6WEw80cpQwfEfnCl1XUvTLXAHsGwpe10zZ7/7kzfBEbvkuLF8V6r585LLz5w G7i3jTLIucF3X/OG4OWcenlXnCpI+gxPa/AwfI5KiD6NMEiK8enGegE0t50PmTT1AO 3Nfl+vYuqmUn+dxI3uu2OTZhHM8nIO5sCEn08tN7bxN79PYW+lZck69jHI/9XFpeLl T2Q/EmJD1HGoi8TXEuWFTiKGDYzD2GgLI+OQcPLVZXjHw1GsaU33jHcdf4tnc7e8/h qagE1kl/ECLTA== 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 , Jean-Christophe Trotin Subject: [PATCH v11 14/56] media: sti: hva: Use vb2_get_buffer() instead of directly access to buffers array Date: Thu, 12 Oct 2023 13:46:00 +0200 Message-Id: <20231012114642.19040-15-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:49:28 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550261935158695 X-GMAIL-MSGID: 1779550261935158695 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 CC: Jean-Christophe Trotin --- 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 Thu Oct 12 11:46: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: 151965 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1165420vqb; Thu, 12 Oct 2023 04:48:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGzMnGKpSHPFknL2NSZS9wPgUJdjEc+DsLhsA3kOtndd2TvqvqGiPNv0xbphEs4zwb6uXox X-Received: by 2002:a05:6a20:431e:b0:13d:fff1:c672 with SMTP id h30-20020a056a20431e00b0013dfff1c672mr27114934pzk.4.1697111330557; Thu, 12 Oct 2023 04:48:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111330; cv=none; d=google.com; s=arc-20160816; b=tlw6TeFlx+YlZvmKa0GoJbFsoogsmBdSSvNcdLqc26ZaqYcbxM4RfhZHKZcbcWcbqb 2snMZcMMiIjCN9rtkfI+B6mxecVpP9EdjMhaaGuz12ggT2OKTHRhaXwYhI66+0qAQWfJ ZhMYqnbIFxRHN8NM3fn3YzdMAg4Ip9f/RPaiY+f+Vu/22cWNrenKOearU898wFjqdWpB Y6kNrfeQPw0XiTLZIpMRGEZjQhyC38DqsnCEJh+mEzOinTACrD85TcS9lda/IM4nMB8j SRwXRhUEatuJ6OWx7VQNle8FJg7UbyYMJ3PehV5fmDwkW24Q4L76R+lFVm6hGh0+RED0 Ankg== 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=KhsnX0kuDSomvyM1FppCUfaHN9eJDPiMMD7A0UUBHvA=; fh=R7B7Bon9pv+GFCDou9bQ9Fb3T633P/NGL4WG9w9NtOc=; b=EiFouBLVVLdhycCo0nK4MZEdd+66ANPqIeBtXYJxmHKfExzMXKhd1LIaRIuCdR8PQG ++jxeXLTOrVjIvfXmPJkKCFAv8NMxRDBO6KHoBYGSLsnYoEI8Qrf6xdoL4nMIeDlHpQH mGfOsCyUXMieJAr4WXdAdmhEoHCRooVt4dBkaeHq9daPMXqGULxfBYnyZ4Btyug34Bd5 V1nZN2nqnujXarAvyIeTv0hQ1w0VKbiYTAV2Fpnks3jGJWGf7t6wp58t8sTj0jxG0UYd U40GtJN20pxaDBLpqyw7w65MOf9TboTUVqf80GVtPpl0dGQVPnSfcXg6XyOj6nOgiaaD ZmSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=PE9MjYBP; 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 v1-20020a17090ac90100b002777081181fsi2109780pjt.51.2023.10.12.04.48.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:48:50 -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=PE9MjYBP; 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 93106822CDC2; Thu, 12 Oct 2023 04:48: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 S1378697AbjJLLsj (ORCPT + 19 others); Thu, 12 Oct 2023 07:48:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378444AbjJLLrA (ORCPT ); Thu, 12 Oct 2023 07:47:00 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C42D5D8; Thu, 12 Oct 2023 04:46:58 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 46CBA6607365; Thu, 12 Oct 2023 12:46:57 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111217; bh=qwarzGzHP5vh6PEOd7Cabtlc3uVGMjYvMu5ypKhoB8o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PE9MjYBPlqrHDjSsYPQkstb5fvWfBm2zhux6BgbrHOSpcZsMmm8tu5MKzKE65wDpB bX4uRrpewZIayuCfop/Dcl9qnlCJq7IE4y/3kktoq2m37PLjuaV601NEC58QDWuXFP MpOC7Q6mzCTp5z4SuSREampVluVgh5oTVujlWEzCnHbEmG7wF3YgKbe8JFV4XMBgb0 Ut34UzvHvwbMMQXHH6E4EVwMNVXAAPJmM6/PdZThL+y1kwyTI+iRiABc4FIPUobRRC g+OMgB+W5tPs7drp3CMYrzxfBIsEB2+1cSfPnaSVAc8ydDgKRWHnd3t5F0R8SV94C0 zuMhHCT9PFvtg== 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 , Daniel Almeida Subject: [PATCH v11 15/56] media: visl: Use vb2_get_buffer() instead of directly access to buffers array Date: Thu, 12 Oct 2023 13:46:01 +0200 Message-Id: <20231012114642.19040-16-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:48:49 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550210473844622 X-GMAIL-MSGID: 1779550210473844622 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 CC: Daniel Almeida CC: Mauro Carvalho Chehab --- drivers/media/test-drivers/visl/visl-dec.c | 28 ++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/drivers/media/test-drivers/visl/visl-dec.c b/drivers/media/test-drivers/visl/visl-dec.c index 318d675e5668..ba20ea998d19 100644 --- a/drivers/media/test-drivers/visl/visl-dec.c +++ b/drivers/media/test-drivers/visl/visl-dec.c @@ -290,13 +290,20 @@ static void visl_tpg_fill(struct visl_ctx *ctx, struct visl_run *run) for (i = 0; i < out_q->num_buffers; i++) { char entry[] = "index: %u, state: %s, request_fd: %d, "; u32 old_len = len; - char *q_status = visl_get_vb2_state(out_q->bufs[i]->state); + struct vb2_buffer *vb2; + char *q_status; + + vb2 = vb2_get_buffer(out_q, i); + if (!vb2) + continue; + + q_status = visl_get_vb2_state(vb2->state); len += scnprintf(&buf[len], TPG_STR_BUF_SZ - len, entry, i, q_status, - to_vb2_v4l2_buffer(out_q->bufs[i])->request_fd); + to_vb2_v4l2_buffer(vb2)->request_fd); - len += visl_fill_bytesused(to_vb2_v4l2_buffer(out_q->bufs[i]), + len += visl_fill_bytesused(to_vb2_v4l2_buffer(vb2), &buf[len], TPG_STR_BUF_SZ - len); @@ -342,13 +349,20 @@ static void visl_tpg_fill(struct visl_ctx *ctx, struct visl_run *run) len = 0; for (i = 0; i < cap_q->num_buffers; i++) { u32 old_len = len; - char *q_status = visl_get_vb2_state(cap_q->bufs[i]->state); + struct vb2_buffer *vb2; + char *q_status; + + vb2 = vb2_get_buffer(cap_q, i); + if (!vb2) + continue; + + q_status = visl_get_vb2_state(vb2->state); len += scnprintf(&buf[len], TPG_STR_BUF_SZ - len, "index: %u, status: %s, timestamp: %llu, is_held: %d", - cap_q->bufs[i]->index, q_status, - cap_q->bufs[i]->timestamp, - to_vb2_v4l2_buffer(cap_q->bufs[i])->is_held); + vb2->index, q_status, + vb2->timestamp, + to_vb2_v4l2_buffer(vb2)->is_held); tpg_gen_text(&ctx->tpg, basep, line++ * line_height, 16, &buf[old_len]); frame_dprintk(ctx->dev, run->dst->sequence, "%s", &buf[old_len]); From patchwork Thu Oct 12 11:46: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: 151983 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1166377vqb; Thu, 12 Oct 2023 04:50:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEquG2NvRuMY6ezkrK4Zt1SjGsvpvGmm30GSTxx++cNDsyKgLL6jVKTji69b7iVm2fgf7It X-Received: by 2002:a05:6a20:8f02:b0:15c:b7bb:2bd9 with SMTP id b2-20020a056a208f0200b0015cb7bb2bd9mr28336595pzk.6.1697111455553; Thu, 12 Oct 2023 04:50:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111455; cv=none; d=google.com; s=arc-20160816; b=wGhzWEsJghLFovyWAmUw19j9XjeJ6IwuIRmSJOx/ie3J4P/ZbaLqxNCG1ehP+SRx9g l0Yl9YZLkQ98+9cs0zDFLnbWYB6e1eW6cP2Lqh2AjwKbvZ+K8u4GuTP6LjnFccQ+GsF0 e3cRAJa9Yh7y+ED9mtUMLP1WdNo3GOGoJT7DD8Ebfy8Q4zIprEeOvqW840xQdr4QGIqc ljzTVRnmpX8d+ZcxG3LnBNMQKy0XtIK+Ly6qNo4m1s1v/Yd7gtmixATabqfuf74ei8eL WAvTLfHSWBKErimTn2RJcLqX4Ob2DJEF4wRzOoBcbgzY8W74kZ4W8Wm5TgNRimV855aZ IvJg== 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=qPEIuGvMUx0Y6lpP2jaVnp425U8/1WBusmlHrwPIhKQ=; fh=O6aRB12iLfQPcoaBoN6ND3UiYcgSMHP3FYKR6EKS/0Q=; b=QF5jTTlXKBWVwJ1LwoEJNyBcJMCLk1Hc1ZjNZAOHBa+Gvio6IvcCDuN7KW4RML6Zqn 5fpzI1tqOJHsQmIALSaQKdBIyHxrrv7IN/v7aT1mKd8pRmA4xIS8/nNuGY0uxZi4nWVf dPrDYqx6VkxabvB9QCvcHURCAZz5cj3AwY0gllqooCQWuaTgZ/nnBKxKFgANcPMscXeO BEjhFajruH6SC0O5JAkzfVfm7BV33K2eiu5D5G7ydtQqwCezcTx1/5UIu/4H9Hdh45qc 5t4cDf22A2VTHQLdCuSAa6wlymqNldo3iUEXuW0eQ8KhXQGw+w9xje0qH6hb64Ax2kxH AFjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Zxz4EYtV; 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 n6-20020a170903110600b001c1eed8a336si2265650plh.167.2023.10.12.04.50.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:50:55 -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=Zxz4EYtV; 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 625EE81A8A8D; Thu, 12 Oct 2023 04:50: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 S1378398AbjJLLsd (ORCPT + 19 others); Thu, 12 Oct 2023 07:48:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378449AbjJLLrA (ORCPT ); Thu, 12 Oct 2023 07:47:00 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C777DC; Thu, 12 Oct 2023 04:46:59 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 C79EB6607367; Thu, 12 Oct 2023 12:46:57 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111218; bh=7OL5E3CW8F8eZCTu2km16+HY1SvtZLOVfrgm1/VXjy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zxz4EYtVb8eZSFa5Uwvd882wFWuAYhX2LKeQKSPTPbU4mWMEoKiEiWXHDiyBIQMyD vuvvnvWLu5IpQp8AwlFYRHQ+Wi6muvQsoSy5Jih1Y9pAWsC7Hvlk3ORXDoYxmwfkKi gcqO73cFAkkQwww8Uvr66ULYAuxbLJ7x1IimWRPkFx8vRQmX48eESO8YdIEtqNxJRO 2JOIN3GCYW8iRYzERUCZgC7JJhndFqoWai8IbOsvIK9wI3urIN5xxNd8L+59a88/zl MqvlbV2vdVD8dfpeZrBIDN2AuOqdktfMIjd3wBXfocEyJEjAiraiZytR6p3glVau8q cv7/ZPt5Lp1CQ== 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 , Hans de Goede , Sakari Ailus Subject: [PATCH v11 16/56] media: atomisp: Use vb2_get_buffer() instead of directly access to buffers array Date: Thu, 12 Oct 2023 13:46:02 +0200 Message-Id: <20231012114642.19040-17-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 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]); Thu, 12 Oct 2023 04:50:22 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550341412062432 X-GMAIL-MSGID: 1779550341412062432 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 CC: Hans de Goede CC: Mauro Carvalho Chehab CC: Sakari Ailus Reviewed-by: Hans de Goede --- 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 Thu Oct 12 11:46: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: 151974 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1165668vqb; Thu, 12 Oct 2023 04:49:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE5JS73TyDYnMAavh65L5/P05wK2BSkB443xpYsIn3BAqth4iQIE0JfE5I/wkhHVD6Amy2A X-Received: by 2002:a17:90a:2dc5:b0:27c:e2d5:abb6 with SMTP id q5-20020a17090a2dc500b0027ce2d5abb6mr7522631pjm.0.1697111362352; Thu, 12 Oct 2023 04:49:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111362; cv=none; d=google.com; s=arc-20160816; b=nnnIOntgFgjIc06uGY7sD6Xw6J8ZfjBtJiFf+mgfu3j2qBGEGztjGRD7pu6VCoztHP gLPninACuVGm7a9oWkVivGOxFVLKvcsbgUHTSabwJXcvAsZrlBaKjVwpjj4TfJOaKQyY Zp9zGewybW2zliX9z7Lcsdkv5qwkjoEmzQ5ElzWY31cZgEe+GcRO15k8HUFOkdOvcDF8 CKy5grV1GoGlTjhqVeoSUoeJDT2YvrAWyBmbVkf49THGA4dM3IbOzaPDf02pjLjTws/3 h0HelYYs9UMOqr1SgUWW8BEyeO5Rv3KIlfYXMNQu0w43nLw1v9Z3Gh81UtdYytoRHFzO hImg== 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=uG4E7/r1sBt2/JHh3VW9t07bzXinx1yTa+6SpOwLc5Q=; fh=O6aRB12iLfQPcoaBoN6ND3UiYcgSMHP3FYKR6EKS/0Q=; b=KqykWHhqxNRwjMV8hS6DtcdwKkoRKyBuitOszaSyxUg8mqOIDY49Zb48bEBhrA6Foc fn87rio3bufwfI5L0mjBV0hR+yo+7l+9dcycWFkNbiPHC6wKRYySgdvmewYzFT5cOw+k PDdyxfp2dQqzft5wk+0uAoIN81m5auUO7iWqQq31TLY5Q7tOOzWQAti+wq+P31WaUIWU JP3RKJkwSuv7ViFsptkEAtvwIOlzegSmLGvqKSRfoKb69o+UIfpZirCbndr914CW12Ww JU9+uR0t63/f9krPyFsV9o+AdiqwHCMaD5Z6dZiCF73xuLwVXo6e2I69QIC9yZJBmhKC Vngg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Imzaqt52; 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 44-20020a17090a09af00b00277651787f1si2278437pjo.145.2023.10.12.04.49.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:49:22 -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=Imzaqt52; 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 5704681A7D1D; Thu, 12 Oct 2023 04:49:10 -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 S1379004AbjJLLsZ (ORCPT + 19 others); Thu, 12 Oct 2023 07:48:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347199AbjJLLrB (ORCPT ); Thu, 12 Oct 2023 07:47:01 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB3F5C4; Thu, 12 Oct 2023 04:46:59 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 5C49B6607368; Thu, 12 Oct 2023 12:46:58 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111218; bh=+ac6y9CN7AEDcWAriiIST3GyWqbq9cgUUTvdotEB6/A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Imzaqt52nbCypSbgVlMK7HiA7wfMRQz5QJ5l/b7I4hElPPTJ5r4DfxO/zMU55hCGp Gf688FMecpuRjSxxtB3D1pTSjQ0LAuyhUdF7U4gKNMoR/PYNq5p/M+2nU/LTcOBJyO fXs42nuD3dS3uTYKTkA02PWgRXCBOzci73PkRwhHHg6D9oQLXp7lI1nQgBB41NO9e4 buGTpx/3FcnbQ4qwHk3pakP73BEFc2UMjEEt4HB1l6k+uhzvR5j5GkVFSpspL2na/H cj6Ur4UInc7HjGLiefWCj/jfJfyS6m5DD3l68GyNCcqOswydV4+Joq4uoMkcndvNsT bOtRR17f7TYCA== 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 , Hans de Goede , Sakari Ailus Subject: [PATCH v11 17/56] media: atomisp: Stop direct calls to queue num_buffers field Date: Thu, 12 Oct 2023 13:46:03 +0200 Message-Id: <20231012114642.19040-18-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 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]); Thu, 12 Oct 2023 04:49:10 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550243630621910 X-GMAIL-MSGID: 1779550243630621910 Use vb2_get_num_buffers() to avoid using queue num_buffers field directly. Signed-off-by: Benjamin Gaignard CC: Hans de Goede CC: Sakari Ailus Reviewed-by: Hans de Goede --- 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 Thu Oct 12 11:46:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 151967 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1165461vqb; Thu, 12 Oct 2023 04:48:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFbbwvOsk9YSdB8MS2r3wd1jineshHptIPaVD47CncZIxfDWWnKsJfz/d9rbilH8VeEt0l+ X-Received: by 2002:a05:6a20:9393:b0:16c:b95c:6d38 with SMTP id x19-20020a056a20939300b0016cb95c6d38mr16712770pzh.2.1697111336669; Thu, 12 Oct 2023 04:48:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111336; cv=none; d=google.com; s=arc-20160816; b=BXcmmpD58gOrLH4LKUg3xXV1ThgdlKDIpmNs4CD9a2OoIcqnL0ke+rBbk6dHWKzgj4 gkQcq6HBXyfUOXSl0RI54tYUVZDtwOSeJgARTHm7qQOFNvsQ37UZ60pRv5Y0t/g5ZQ2J CKboSUmXQUDSe/J/8jUKJoPHG3gUm8iFSCgojpq05V5uD+OzrFW1inMNyxe4oVucAyik XnKSl3KFB6FpgOAUIAKcIjr1lv0tqXDAH9NHidm5HYenN+NlB0q9CR++QTlcvtA9gqBm VPBJ0muQNpc0sL1rq1QzFp924WND3hryBx5dOzb59FdAfgM/aqZjayxa661l8tysUg1k n41w== 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=GEk7/p0tq+8qOB8YA0DrBvPI0KABf1JKqLfH5tTd/4vmhUr+Q1liLL/ip+OVR5Hm4b dMureATmkIZE/dXyyNiXohh0ky8mZsGaMMAHAc/0yL7JJOT27fNLVEBdGvdo//Uxj/J6 h7aN8MJRwdwODhXLUb6/G8LMseVozmMDIOxF70dp3gyJeNwv6qEWRq5K9FKerSYX+wLQ tzerx/mrH2jHU1U87WGtxrAYbtrtc+OPahve5RcVGvihItuMizD1qYhdvULAHltmClUZ olY4N4MSTM4TOAcHmMMe7kfuwQfLkxtWpVKbtuU1afaIro+LXX1UVODclNjafFMHO+7R KKIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=khy5hIdL; 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 e35-20020a631e23000000b005649f560ebesi2094698pge.525.2023.10.12.04.48.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:48: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=khy5hIdL; 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 81C4E81A8A84; Thu, 12 Oct 2023 04:48:46 -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 S1378945AbjJLLsV (ORCPT + 19 others); Thu, 12 Oct 2023 07:48:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378475AbjJLLrC (ORCPT ); Thu, 12 Oct 2023 07:47:02 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75EE0E3; Thu, 12 Oct 2023 04:47:00 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 EA8AD660736B; Thu, 12 Oct 2023 12:46:58 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111219; bh=EMKVWITArl2PHuWHDFd/NcTii9pr6T7GjKNa1Tuop1w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=khy5hIdLyuzHv4KJZZ2yr72/PXDrFjCI6XCW/IgkECTXGG0O0HSooxknKod+2r8vE c6kcJqjIApQNzeXmpVPcx6sqb1BOJCtv/x22TCE3STSG18W0/KU40PS1qNo7VwYtfo xv6J1UVmI6eGMO5Ggzh1dUNVQTQWYNhjcBUT0S2gBBBzqPkYGtvT8xT3mFgJ1WB/lq 3sYZzTDGiyPPdniFyIyOGBN3ESSxS0u8YxPaFgmWcPlBXz0PRdOh3xifIZ0uth+eKu r6fZ8vPfNl7/1tSfGK284dxAquGEnIA2/yA7EAtz9v6wBxH3LFmYunWhRedKR3fBw5 Yyf+rN1DuRz8Q== 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 v11 18/56] media: dvb-core: Use vb2_get_buffer() instead of directly access to buffers array Date: Thu, 12 Oct 2023 13:46:04 +0200 Message-Id: <20231012114642.19040-19-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 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]); Thu, 12 Oct 2023 04:48:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550216983038577 X-GMAIL-MSGID: 1779550216983038577 Use vb2_get_buffer() instead of directly access to vb2_buffer buffer array. This could allow to change the type bufs[] field of vb2_buffer structure if needed. After each call to vb2_get_buffer() we need to be sure that we get a valid pointer so check the return value of all of them. Signed-off-by: Benjamin Gaignard --- drivers/media/dvb-core/dvb_vb2.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/media/dvb-core/dvb_vb2.c b/drivers/media/dvb-core/dvb_vb2.c index b322ef179f05..3a966fdf814c 100644 --- a/drivers/media/dvb-core/dvb_vb2.c +++ b/drivers/media/dvb-core/dvb_vb2.c @@ -355,12 +355,13 @@ int dvb_vb2_reqbufs(struct dvb_vb2_ctx *ctx, struct dmx_requestbuffers *req) int dvb_vb2_querybuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b) { struct vb2_queue *q = &ctx->vb_q; + struct vb2_buffer *vb2 = vb2_get_buffer(q, b->index); - if (b->index >= q->num_buffers) { - dprintk(1, "[%s] buffer index out of range\n", ctx->name); + if (!vb2) { + dprintk(1, "[%s] invalid buffer index\n", ctx->name); return -EINVAL; } - vb2_core_querybuf(&ctx->vb_q, q->bufs[b->index], b); + vb2_core_querybuf(&ctx->vb_q, vb2, b); dprintk(3, "[%s] index=%d\n", ctx->name, b->index); return 0; } @@ -385,13 +386,14 @@ int dvb_vb2_expbuf(struct dvb_vb2_ctx *ctx, struct dmx_exportbuffer *exp) int dvb_vb2_qbuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b) { struct vb2_queue *q = &ctx->vb_q; + struct vb2_buffer *vb2 = vb2_get_buffer(q, b->index); int ret; - if (b->index >= q->num_buffers) { - dprintk(1, "[%s] buffer index out of range\n", ctx->name); + if (!vb2) { + dprintk(1, "[%s] invalid buffer index\n", ctx->name); return -EINVAL; } - ret = vb2_core_qbuf(&ctx->vb_q, q->bufs[b->index], b, NULL); + ret = vb2_core_qbuf(&ctx->vb_q, vb2, b, NULL); if (ret) { dprintk(1, "[%s] index=%d errno=%d\n", ctx->name, b->index, ret); From patchwork Thu Oct 12 11:46:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 151981 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1165903vqb; Thu, 12 Oct 2023 04:49:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGFzBpyoYSeOVSJSnhiJDNFAAy62hDhEoixkaEjZ4gkJ0kRe+NV9Z762UONIDpV5TIVURMx X-Received: by 2002:a17:902:dac8:b0:1bf:1a9e:85f7 with SMTP id q8-20020a170902dac800b001bf1a9e85f7mr27096986plx.1.1697111395403; Thu, 12 Oct 2023 04:49:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111395; cv=none; d=google.com; s=arc-20160816; b=KTyDLB3dMe/ukRmVXHB1LusSMxg8B72E0JldXYEyq0YJVzHevRDkIfiIkQl/w5nzSZ 0xBcSljMTw00WXO8ATUqxcATdEqetbR1NWopbBrXzd2WMMDAoyGmT40U2H/rMq6F4N4d YpM5Okhi/wXB+GkD1WqlweRBPRUiG1GaU7mUkuJOUxpqRP9S0uGY+TVQSOTJYJr1CMk5 3MVW2aTYEFimv7tGCOFBGvISzlglsnFlvipMxUYpFQ6A8sYTABJiBihEWxbRBc0Euc3W tCxYazFzoOJyTrsdQPSU/R9dNFitgs54BSMN94pZ4m4eMro9KzpMHZjQpsx8eUuMk/mT HzdQ== 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=YYWVDCyXuPvVNosQGrS3chyUS5Q0+9MLcvrGH3QK6j3MxWuq/fhW+W/lW41v4xr54d aQE5/ant91KHj0uaYKdCJlIPcdWUkKyIlLGprSxK1qEnHM30jC2GOpzFRD8OE3RsMvhs vRcbcRQG61DmAR6uSyiUZ1KRHOD6j5jInkPMHC9qMdyXSaDM2dXgAvAMSZeaVwjFRkxq 54Tl2eHJNIV8x0pITqHh+Eq2rBzKcqmgvLyzHnq/JESZvpMab0URYd+CotqlySRHH868 wU/OxLEetZAwsPjaVHksc4MEKiSBqFApa6j57BQA6yHpRJxhZwws6/VqTqNAtc2DQYYF YjlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=T6c2WzuJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id be6-20020a170902aa0600b001c76a1aa6basi1967373plb.27.2023.10.12.04.49.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:49:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=T6c2WzuJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 5E9AE83741E0; Thu, 12 Oct 2023 04:49:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343824AbjJLLsS (ORCPT + 19 others); Thu, 12 Oct 2023 07:48:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378478AbjJLLrC (ORCPT ); Thu, 12 Oct 2023 07:47:02 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18C80E6; Thu, 12 Oct 2023 04:47:01 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 75DBE6607358; Thu, 12 Oct 2023 12:46:59 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111219; bh=o2sVtoPPYvq8hM/qyihWIqN4hasDvFA4zhZmTyTxJEg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T6c2WzuJOXCb7OrdeYtPepo+zhAeAHO7DQmDBSK27YLwAgt5567H3AuSCWnFDkmDB TWlA9tD0YKldYAFQ9s8W6zPZjlPYIGGIefPVnQCU1WYI4cR0U1C+FYSx+dxF4YY/Mp GBOHYgNGmEjgqwSYio7cVGKr6/uTEl6FfjUGEdkALNl+QfKuF3FuUnwJve3mOLXW0a Cg1dfBPwkLl3sYA3P6BftijFalxP/zcH3HCoxambTKLt+cHpb4NhfpwbBMCYVt4I6X vSVCksD3GdV3pWJEgjhxSr50uuBcgNLxRRz9/dq2Pa1JvEQrqOlLrEAX4OAdUwAf1n x+EQ+wHbkG5bw== 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 v11 19/56] media: dvb-core: Do not initialize twice queue num_buffer field Date: Thu, 12 Oct 2023 13:46:05 +0200 Message-Id: <20231012114642.19040-20-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:49:39 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550278514121967 X-GMAIL-MSGID: 1779550278514121967 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 Thu Oct 12 11:46:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 151955 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1164931vqb; Thu, 12 Oct 2023 04:47:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEG5NGnOSVktpxVfwgK4OQ1VOOOWiSsjkl3vF1gLJC4o87NKuGV4P4wZsG7QljSv2eJJ/zy X-Received: by 2002:a05:6808:2026:b0:3ad:f5d8:2da9 with SMTP id q38-20020a056808202600b003adf5d82da9mr29335272oiw.4.1697111276972; Thu, 12 Oct 2023 04:47:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111276; cv=none; d=google.com; s=arc-20160816; b=WwXNPjEiQFmtqzAGp2KVA/97eeKvpnjymVgfVG4rzWEULLo11b/b8Kf1OR300sOYRq DsvzIC6xmqLq3SoHa41ECxK4vT6VQu6KzSGfa8WdID7SaOuOEL+s2LOTsShb3In+VhVz XUzPls+wOQLFZJ0+5LGLhOmLrp1Hu2f6oCY7xbN+QG8O3Ro9yFqoQzaSDrrIRtTyjhBI nu7a6BZCjBVzBA4t6Ckwup2kBYvU6U5gQVwei9elcceFxzsB/FS+2obmEYXg1RvLGTs+ dqkSh45WLLwwsJTPxAhhWv16nAmVFWHUqzheYro10UX3tpr8wYtkd1kppFDIfdM0N2uR WUDA== 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=5vielkOJMqA0ytGuj4VcIXvslkPviGgJqqY/Lasa6Ho=; fh=p0AH8hgimiy85Lh1cXLIqpi5zFbeLa4s8fsQNMmUBzM=; b=m42J+qq17yufMpIqxq/+yxv6m7Ih9m12NTlMA1V4e0u/JKhwVFhZxD0TJvVRA9E2v0 Y+uLGbP1797L0UAlecr4pWOMLh0fGYT/qcNA7XR9gKmg10Lhebi6z+ewO6awpG6Biofo vPqgZKEI8BnWW+2EYPfOKlyWmPKPXsFhFoTWB49rm2JPnM8BnZA/+TiO/1JvzGVl9rIc r1OgzNGaQOHX+8FVqs35RsxEzMrZP++pqVWcU2lblgDKWvxYB8sfqiSOSKGfXGaqJlx/ NtospvC8ohrJy1ZBLdB8BQBfURS93L2sOcAjzvOCehcrABbpfoxlhI/3Tn0N6AL5m9qO 9AjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=US3th3hf; 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 cb7-20020a056a00430700b00690c23d353asi14152041pfb.217.2023.10.12.04.47.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:47:56 -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=US3th3hf; 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 41E16822CC58; Thu, 12 Oct 2023 04:47:56 -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 S1379102AbjJLLrn (ORCPT + 19 others); Thu, 12 Oct 2023 07:47:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378548AbjJLLrL (ORCPT ); Thu, 12 Oct 2023 07:47:11 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99BEDEA; Thu, 12 Oct 2023 04:47:01 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 0498A6607346; Thu, 12 Oct 2023 12:47:00 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111220; bh=GJfXFDdnhGS92TEmv49OanHL2tR3kTI5Ce9MknjELEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=US3th3hfJtwGDlltn2tiBSpDfxGx696Sr4C++b8Vp4MPXfcZqMEwbSfaaD3yrDLQn ufgqhY8RxztnDKdXxSgt1e+ud+vbz5XIulKShZXOJVWfSt+fPETsPr69q6gCInhQhf dX/yL89aJoMkPkL8lUhUst6kNCj0QPfLcZ1cxYsO8l/Sans2SmFtPXnH3MucvNnv8E 9vdQLAEzA5AXM8l5gOcs23ki6ZcRwA74IaJcscWjaVxYGPuIjxxSDHAcsJylgEooEl vd0TArlTOjDYzSKUm9vo/1wuMvFUxbuejc44WJGvQh+zP8GiKnn02zLSoadhi0l3lX nUjMPXE/xlg4Q== 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 , Antti Palosaari Subject: [PATCH v11 20/56] media: dvb-frontends: rtl2832_srd: Use queue min_buffers_needed field Date: Thu, 12 Oct 2023 13:46:06 +0200 Message-Id: <20231012114642.19040-21-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:47:56 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550154075946967 X-GMAIL-MSGID: 1779550154075946967 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 CC: Antti Palosaari --- 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 Thu Oct 12 11:46:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 151960 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1165135vqb; Thu, 12 Oct 2023 04:48:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH2hmu4YL2g235uwvzdVjztXXg5bczhRnEzFO4J1ms/hQYRueZiP7fyjqSBgvDl2x15hRou X-Received: by 2002:a05:6830:63c2:b0:6bc:a824:2750 with SMTP id ci2-20020a05683063c200b006bca8242750mr21017904otb.2.1697111301108; Thu, 12 Oct 2023 04:48:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111301; cv=none; d=google.com; s=arc-20160816; b=ML8qMNaamPx2d2Mat3WIT/llVdnu6DuTYIdsFVsBfupUPHVcIQ0TIAsKZww32DrmtY h+3ApZVucZzJ2vZMFqVb+IQ2h1zWUFCCfKDxrwyjZPUL3L0CumC8Tk3ucJUaxTS2Kppb IiNAuieNOspVfvmMot9w6qWhUzXgGVL7TFlSfvJE279++6OPi4DOq1EX/SBkQGlKD5lu 4KESYeMuHDBH9lhP5+V6iDIX+PgsMmKj50BmSShZ3CQXPQOgJ2AA7DJnv7VRMWbU2gnq hSrfQGaxFzFmyVbjoTaImCneSGQ2ymlAtY9kCd7Cc4uhpyqyhfr6370E7ohMBrvckKbz rwSg== 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=9xb2HxFyj1VWE4LL8F6mZIXiQjdsk4zJ01SDd/HcuPw=; fh=nyy6kl3x7bvRns0O2iGfKgaQnRSGFqx2aqkUiW72Nok=; b=SrtvD1dOGmv6epkzZuNC/F0Dbt/UqmcqsughyMIZTOlT15U1xJX9ytXakUv65YdOLn lxuU9cFUO7FUUBC8DjlhugjAZKtPmq14B9Dc5cgT35dSmnD1Ul0yi5r+pVpmkSt+KLui mYWAejtFXEyihn9icZV+pSCOKHicEPS9Wr3bZHk/vzFQNH+k+fkdz42JQgpKVwhXGYlg IhzsDArUDmSv4/7LXdPaCTsyvGMu63QwDSgiOkyOKf18IMF4puSWNdFbH2LooPFKJCJ1 qFy4vic995Aeft021l44gLs+JMTRtmdp/77xRd5jeDv8fHGY62yLTfSmEzTlQhxqev+F moCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Ikpsd6wm; 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 i194-20020a636dcb000000b00588fa0def2asi2089047pgc.778.2023.10.12.04.48.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:48:21 -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=Ikpsd6wm; 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 24024822CD4E; Thu, 12 Oct 2023 04:48: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 S1379211AbjJLLsN (ORCPT + 19 others); Thu, 12 Oct 2023 07:48:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378557AbjJLLrL (ORCPT ); Thu, 12 Oct 2023 07:47:11 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15545F1; Thu, 12 Oct 2023 04:47:02 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 87F366607371; Thu, 12 Oct 2023 12:47:00 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111220; bh=Jt1mNMm36fegL/wBY23liBF0ngeSMzYwFlorrhK5AKs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ikpsd6wm0YYrF8nGwJim6Sv46Xxi4+ScsUHZDGZGFg11Xq2SIcNnZJuk8JxZjYeis 1dDxmHOF/e9SWZ2vztz3EwGYkBzKS253R+V/+GwZ2hWFFsD93tg2yIctLbvp0BeXcv BGYfejgSuF20/iraRJ/0RSvSu5UBlJHtf0zjg5kyeA7bTHO1piM1KbtvRCpHMaT+qV CQQcxvHf/hi49UYNaT/ndwxI53687YmNz08aGpUbvHR1txfHCs8KfZQvXSofhTjT5E uR9MpIn01HNnQiYlZ9l9CkBIdPtUDlyqK5CShCdD4Mzgiz/BXMOwaUjYClBjruaA8A r0IVcbFWDbhlg== 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 , Matt Ranostay Subject: [PATCH v11 21/56] media: video-i2c: Set min_buffers_needed to 2 Date: Thu, 12 Oct 2023 13:46:07 +0200 Message-Id: <20231012114642.19040-22-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:48:20 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550179681603493 X-GMAIL-MSGID: 1779550179681603493 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 CC: Matt Ranostay --- 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 Thu Oct 12 11:46:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 151959 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1165117vqb; Thu, 12 Oct 2023 04:48:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF3PnWV+9scsWrtmr30xRZnOEBp9y7D09cvPx5bQAIosWNIr4eot2UbePwCu+iBG+A1kSRK X-Received: by 2002:a17:90b:1496:b0:27c:f88f:11a5 with SMTP id js22-20020a17090b149600b0027cf88f11a5mr6135245pjb.2.1697111299137; Thu, 12 Oct 2023 04:48:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111299; cv=none; d=google.com; s=arc-20160816; b=jGzJvnvLSBTJWjB6xQ0zFwuPOJ6BUMZq2y6zBT9IKJ5171hiU/6xDQE91BmHS0C2Ic SghH6NJoIjIvAkjLZedscU+oByrVcEv5efPyqs8PqomcXZBN6pc051GinHayzqqPzypk 6DnYqlBu7iAetGKU9RZftd080TZPrhe+gJNT0syfBGWHfVKdiYk2IXqNvR5yPn6T+X53 fBKF5PmARV6AJ36blpLJ6SyhjwK6MeY/Ado8X80VjX0lkpIJC0YpOnZS1YHuRTA06KiS gZk8hCudHFJzSrWuoGrbVqkhsqYroXp6ifXn4GZtbnAjPv3ewtVsbIDJJyhjzaWJoiMw vrNg== 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=o2J7dUrEgQsuh900jy30fGQFA4/dmEnjcts9KQQ/O6Y=; fh=6G0QHlZndv6E4oxTLEO2WsSggK/WBr9zf05IDJK155Y=; b=vfEP0QrLHqHntNxl+JhZhkcu9/r2INn4SwoXNt9bgJOvGDKL//cJKZB+6Yc5TFtpQr hW1xxlKP3EYGL/iNr1NW2a4dOqU6VpWvXzxfLVAIqWWGL9CjT+lxMTsFsRF5Kf3vXo3E cbIWCxYI+dzvpIUscEYYQgKWkAoV4gJQA2P52vn+o4qst3SVq1/5yrgdWtFfPrFwe9Qi /kSpTHv8Oa4P+AEQKS2fDjzlUe13nrIHI9FdaEyNOul4hhBD8kEb8uWoneunSdZKYAZy /i6KnjvcF+TMWm0ZPK278rRXPRFTJ59s3T7+15qhzLUZXs2BtW/OJOLWIlw/2NtvMlWE DVlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=OoqCZCxG; 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 my10-20020a17090b4c8a00b00278fe20df4dsi2320955pjb.43.2023.10.12.04.48.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:48: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=OoqCZCxG; 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 94EE2822CD4F; Thu, 12 Oct 2023 04:48: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 S1378640AbjJLLsL (ORCPT + 19 others); Thu, 12 Oct 2023 07:48:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378570AbjJLLrM (ORCPT ); Thu, 12 Oct 2023 07:47:12 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F37BF5; Thu, 12 Oct 2023 04:47:02 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 159826607375; Thu, 12 Oct 2023 12:47:01 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111221; bh=RixrAQBOgKHoPu9fntvJtw2OX9PZEEsf/szxAuITdMY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OoqCZCxGG5mYLqH7BsWI3ks9lAvuN2A0vIWLC0g+B1qchAvXw3rEGBCIl/oue4HFM cgeVXAHwqToHSGSY0lHLFv93r78jW99SwLlvH3ClkMT2sHvhEmBwlcodI7Ylun6Cr3 LQGRiWfYOqXOllevieIMsnB50EhzAmJt15tGHhNVxMNGtLujVUhM2ug8kBH7ddSq/M evTYgma4Jv4k45A5+otebtqyjeTYRKBZWqyI08NJBhqakXAN+PGbrTzSX4574y5nB2 KBX09pSZyVmoZDyHKkotwbfmzhZF/a45AL7+RNTPqL9mDKHJgKtPDHk+9qllOzQg8R YffczzznFjvUA== 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 , Andy Walls Subject: [PATCH v11 22/56] media: pci: cx18: Set correct value to min_buffers_needed field Date: Thu, 12 Oct 2023 13:46:08 +0200 Message-Id: <20231012114642.19040-23-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:48:18 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550177877575645 X-GMAIL-MSGID: 1779550177877575645 Set queue min_buffers_needed field to 3 and remove the useless check. Signed-off-by: Benjamin Gaignard CC: Andy Walls --- 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 Thu Oct 12 11:46:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 151964 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1165412vqb; Thu, 12 Oct 2023 04:48:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IExEL8TxS7Q+5DQYr+4sP5vfW92tvPqQCXk8pMeXYjJLnQcd97cmeq9KZkoYMGCdiKLSQa9 X-Received: by 2002:a17:90a:17c5:b0:27d:3b8:a08a with SMTP id q63-20020a17090a17c500b0027d03b8a08amr4258530pja.1.1697111329929; Thu, 12 Oct 2023 04:48:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111329; cv=none; d=google.com; s=arc-20160816; b=L3IEgz4bjfOP/KS/DnVTU5wQWma0EJud6y7n79/yKVXpxa6srsYUR/i7Auxexn7WpM 9IMv9NIqxXE7vKzp6fBqXNnhlH8rLoND8BKn3CTDmnxPAo0JN9NBxoPWlKrV4SYpGhF3 fVtQGGWsIhdb1F/ET0MskS22sc7vqnNd8W8HT94cXZpyGePLZdtnRFJSu4Uf+RVLgAA9 NIWa4lrmiyImOZ5be9Vkkr8DeLOODM4b7asEJFgNUHzW5aHpTQuE5CQIbXpxwpRwbHUs aaerE5PpoQvwJzlxEoRmEP11KlzuTLnSj2UVL7QQKCI3O9Sfg5FITjLgZNTdV3AAap4N w8Tw== 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=asinf2Tzb5VS32WEi7Z88al+VuzJaXQtutXJtF1Ggv4+6p5UGNP+ml06x7Gzw0Z4LA HuWh/97oonOem2MbcM4l1isBafowl78l529t2/aXWAqVLIhxDTU+QSMROhkCQgkncziK ol5x9JEij21RW8CFlWgayoaRqBR10y8EPau7KBeCi1CI0awhYsZ2JNawLZxuK0JnEmZZ IfHK8GQ3gGBoyZF2nbNyutSJZ/1It0oQXPNb+Vq+vNJv/CX4QI6JGn0+QR3edNZ8Pmxg JH2uutuFJsBcuU+D4cv4030SVtHh7Ohnh2oSDEgYt2DE0SlNBuXs9+7Yqe8u9ENCAZxK JRyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=T8iTKldx; 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 q193-20020a632aca000000b00565701e9a36si568709pgq.752.2023.10.12.04.48.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:48:49 -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=T8iTKldx; 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 22D1A8190698; Thu, 12 Oct 2023 04:48:39 -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 S1378866AbjJLLrx (ORCPT + 19 others); Thu, 12 Oct 2023 07:47:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378576AbjJLLrM (ORCPT ); Thu, 12 Oct 2023 07:47:12 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27ECEFB; Thu, 12 Oct 2023 04:47:03 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 97DC36607347; Thu, 12 Oct 2023 12:47:01 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111222; bh=7OP/lnsbD5MzPZ4L/gceSmxIzda3Ng9eLtu0phjni7k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T8iTKldxdPoVGjc1OZd3nlBPGGAsW6nR9nFmP9nJEqoSJ+Qf7dFZ0UQ5K7+VpJSaF 2h8ySGip1qNoUv1VkS5r1/Km0OIEc8DKcy/X8uIzz8PWq1FL22LkgWFAVxZyuREmnP /dxn6VcCuB8mjGuudOfza3UhINJl0zgdDxAgrYj9P0YGCDuy+xRRwZvZ/3l2BpdyZa +qSRaur88qCpLOLmsgoyJv4ahRkjakt+U8bmTpOa2QchCmF9LJ745axVM845FnZrxJ mPvjm3Z/+BfWR5iAAmgo7eISs7596yYS+zvhO6z+wJvBc9/4nMXvud6uytgEcIq2ET YjSD4MWM+BHDQ== 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 v11 23/56] media: pci: dt3155: Remove useless check Date: Thu, 12 Oct 2023 13:46:09 +0200 Message-Id: <20231012114642.19040-24-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 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]); Thu, 12 Oct 2023 04:48:39 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550210109316572 X-GMAIL-MSGID: 1779550210109316572 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 Thu Oct 12 11:46: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: 151957 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1164971vqb; Thu, 12 Oct 2023 04:48:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH3tpWSMLZPwESqORgK7+v9FQRZY8wdS0TqyhIHCfjTPFcKuErap03CYyLByFskZbr4y6V4 X-Received: by 2002:a05:6a20:daa8:b0:171:947f:465b with SMTP id iy40-20020a056a20daa800b00171947f465bmr10006641pzb.4.1697111282136; Thu, 12 Oct 2023 04:48:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111282; cv=none; d=google.com; s=arc-20160816; b=u+mHJnHx2XI0nnS8EuaKwGeH7iOyp6x5CHk2VdwaSE0MJU6Ujkgl0ljyr91i2q0Ctz RjU5epKlUKvQgep6UOKZwrUVVW+q+0W2uGn8VLLH+arNf7pvQtFH5oaXHj3+het4/PBP VJYLdmFk1tJdx+cIQqJH6A9FhjN0ndcA9iuEh8vJk+DAVrNyz3FiDyiHa4uXZXRBtIbX bZ3d0179LwRJ6+s0ubjeSMtRpdEXKMIsfJwr1NqWBPd+p4QQKjls41PutZXm14g8CJ8l R2nD1n1TjeD2ll9oEu+5rWQE4qqA/LLhmWbCJP7Bd1G9qGUXkEXO8oK8JZX9pCwbYqQA K3Mg== 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=o96y52cxqh3GUQXV0vXJPlmMlIJubnqHdq2MDJskkE0=; fh=kpy8hnP6Gews7/w8dNjLiYrKq2Pvrz/5/ZgUjYw+mFw=; b=VQ+cRiAfOdSowPFep/yxH1VHKlwpkSDvyPnBVJJZtkTGuRJPJiY2GeKqsZOFd4BMIy 4MS/e4Bz/32X4C3r3wuUFXFURQHGlYqV0QwVUhJHDF2JszQJcftvOS3Y6FxG5NNbCZUM GHwZs7r79KR7aKJOvLOd73Fb3C5YhY/NQP94fUVhWNJ6Fe8YINCGAbDiAYhVIXa4oW2h v+9eYOKAL7i24s2Ag9qUsa065ECi6K3J7AeKUSU27uWrKFHYhgfoJUg3kz5Xi6xheyEu EMa1zCS79yvtRW7m+5EUwKY1el7SQ+s3Kd5/dySPh1n26Y2sa34CUee2q28RmMVkcpBi dDNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="ldW/Ogjn"; 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 k4-20020a170902d58400b001c60de17b50si2055551plh.182.2023.10.12.04.48.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:48:02 -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="ldW/Ogjn"; 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 D6B2D822CB75; Thu, 12 Oct 2023 04:48:00 -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 S1379172AbjJLLru (ORCPT + 19 others); Thu, 12 Oct 2023 07:47:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378597AbjJLLrM (ORCPT ); Thu, 12 Oct 2023 07:47:12 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B05F6103; Thu, 12 Oct 2023 04:47:03 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 2B9EB660737C; Thu, 12 Oct 2023 12:47:02 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111222; bh=tcL10ushjZKOfejORLVlDBPX8x0SngzD2gGkivTGU0g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ldW/Ogjn9kC7gijcctJUy/y/+tFA0G7iAnA/ttNi0MVF+0mW3uyktXU526npAf3Wd B8jXbM6qUhwD4mEpacvh2dWg6MJNrsnW6dpB5ib3/1mvycY4+CBfekkt4EjWGKu5tT LrMbdQ+L9Qviv1A8u8gVDalkbsHMBXdPyTD3EPT/+xxlJxg+Prl3SfhCCQNm7zSf9w NOw3TH2uk3HtGi0/wwAHViVKX8HCyoCNJdUba0qgVOCyqpbCbVO3pdmOz72ATTysmj yb3MqZbn66e2YrfsDGI4rkDivBXmmL8PVFzGf7/LwkbgCG97VWKM9OLI7HX0Y612ho dGi7FgsOFNteg== From: Benjamin Gaignard To: mchehab@kernel.org, tfiga@chromium.org, m.szyprowski@samsung.com, ming.qian@nxp.com, ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de, gregkh@linuxfoundation.org, hverkuil-cisco@xs4all.nl, nicolas.dufresne@collabora.com Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-staging@lists.linux.dev, kernel@collabora.com, Benjamin Gaignard , Sergey Kozlov , Abylay Ospan Subject: [PATCH v11 24/56] media: pci: netup_unidvb: Remove useless number of buffers check Date: Thu, 12 Oct 2023 13:46:10 +0200 Message-Id: <20231012114642.19040-25-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:48:00 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550159566410233 X-GMAIL-MSGID: 1779550159566410233 vb2 core tests this already so remove it. Signed-off-by: Benjamin Gaignard CC: Sergey Kozlov CC: Abylay Ospan --- 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 Thu Oct 12 11:46: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: 151966 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1165450vqb; Thu, 12 Oct 2023 04:48:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFsdn3SGu5fmYi/goCxZhX1gy4inNYFrJ+UGUZxhAT5oXi4Pbfyb6glVX0GsmerqGkYtyTb X-Received: by 2002:a05:6358:e91c:b0:143:6813:bffa with SMTP id gk28-20020a056358e91c00b001436813bffamr19045080rwb.0.1697111335436; Thu, 12 Oct 2023 04:48:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111335; cv=none; d=google.com; s=arc-20160816; b=lWMH8aVJtIjwCgzU5BHq9D15J7EI9UrlW0MfiQZp3Cx7N5gfzwFKKeclsePainDhU7 hiHdWRBnIPS/CvTgoDsyBHFDX0nnrR4byPSyHGBjXeA7qLCtuuLXgAINi0dOOQcKKZki cDT/EL2EyGhkxNX8tRbpqSRfSbmHdZXpbmsguK5Euh/pYYnxKD3Muhqyb4bASlyArQ5i b7dA3PU3P9vHJNCvPyIUT01MHVtGutu6Yp2ThZRzd44cT8ooEM7DZJz/iLdygsTPp8p7 Ua7bD683TUlrK5+DzkVf6G64J2/Uc9izQt0OcvQuNe0L6lDc5EuSTH/iYT7he63TASM/ G10g== 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=KrcM1SaP34NjtQZxSBGkEIDOEicLxrDOhe6ObP/YMHQasLxP4rYTtZlFuZs0hyrTHS g0yKya5faWM+lg6JhioVPY09EMxQ0uX60j+jNBNXyoEEDV9XErJdHlxD/NjJ0HnPzVhO 5OmXhn0aKyxTx4wiHzZSGyJEjkz9VNodBWGxm0A89vWrFf0/uAhO8j5VERCmOv4+IpTF O0sPTE7P07zikmiCeNA8BS92Yk3VOd8bm9iMr4Tmq0J41PsiU+jjR+2qokmopyNvJojy PboUYLW3mmQcHNVhXy96lnNNmK7xETDpgMsU85PL3M3mJIDcQYM1W10hAzmukSVBpPEc s+ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=LjSTgXHJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id dw8-20020a056a00368800b0069f456b74e9si12033278pfb.292.2023.10.12.04.48.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:48:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=LjSTgXHJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id C60858374BB0; Thu, 12 Oct 2023 04:48:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379164AbjJLLsF (ORCPT + 19 others); Thu, 12 Oct 2023 07:48:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378613AbjJLLrN (ORCPT ); Thu, 12 Oct 2023 07:47:13 -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 A1EC9DA; Thu, 12 Oct 2023 04:47:04 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 B3A04660734D; Thu, 12 Oct 2023 12:47:02 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111223; bh=zysh0fIOtYpsYqIRMileMUIIdpZZkRuacJmXooFftR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LjSTgXHJlxgyZ+bvIf6sMbUqVS/2vBIxqlUtcMc0jxVNsA2FpOa+Ek9Ek0PJTHjUT 901g/0zx77kLJ9lQ+xak0DJ8TojxT/k8YoYuoUUmBEuQm7kq92MVUWdMC1BIwO/MdO Kezi2LxtDCibe9m4J39eVUYQ228tscXbqmirgSvmALVKm3rX4KSiYKf3HHu0/uKUWr SdzhvuD+0vpARnkQvPWoe1JDyk6cUpzrIKEDep8cMXLKv8SN0Mk7m1685XvNjRK1Tf QRaoKH+VBZK+v20t2p8zaoyx7rXQzwdm2W6yv17zqA8B6VHOAGN9OdeFkDo6R8M6uw OAjzhRNHy7jEQ== 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 v11 25/56] media: pci: tw68: Stop direct calls to queue num_buffers field Date: Thu, 12 Oct 2023 13:46:11 +0200 Message-Id: <20231012114642.19040-26-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:48:45 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550215636954559 X-GMAIL-MSGID: 1779550215636954559 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 Thu Oct 12 11:46: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: 151969 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1165545vqb; Thu, 12 Oct 2023 04:49:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGj/djAux20WGHi5u5x+2vLqA5iWqoXHh2BcJ1s9cP9mjWELPNCrlbsIjcGuGlgshU20I9c X-Received: by 2002:a05:6a20:9417:b0:16c:4959:c372 with SMTP id hl23-20020a056a20941700b0016c4959c372mr12251154pzb.6.1697111348351; Thu, 12 Oct 2023 04:49:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111348; cv=none; d=google.com; s=arc-20160816; b=bvo9TUDtERjnPty06n8SaEpIwNSuR+u8kcwIyO8AUSL5MRfy63yz+z5xQgiT6G9fmp Zn6EwJeWFiVu5ajinpIIjLYSCGYgKO78nsj7DdcjHrLhT7mFS4FfwLUcY5M7ARd83Ew5 APB9SLDS1pvGh3LF9Vitvarf0S3GUS/kfLN73KTL4Yf1PevGenzZER86BCCuNNKIWg4Q V7f7f31ueu4z0PHshuZAgZR6Mh9+06EuYSg2aHRyi2ljVWg5VwKzpqIKQGbvYdsDje/v vFh0Wq1vTsmLXvecnB0aD1zMuMvPpjJWI5hYGmFWTtfa+yGlaxoW54oa/4PejJj93N4m tk0w== 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=HY072FxIFa+EvkYb26aQ34aqlD/sIlNV70RLY4SKuKo=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=p/4oalQrh/7ofUDia150UHhnM7VUmiAFDlOVdlvPHOVz9afYeHFgxkBBeKFW4qdlZH eaf0RRBLpa6h7qJVjAN0CyLxEyOpYHYr/dulagjpqB9TN2A/I4rExpyiLin065g6YLDC AACd2JfctdC4PMGBlMyoC8H4Ad4PpxAVCerJOErBD6HPG942NzQQCnsF1e/zGRtGOCMl 8rU5OocC4iDe3tR606qnYTueTy+NAGb8QSTxtxXEkR7Q6JjwqShuS8sWW//msW+0fzB1 IJsjv7FMv9VT8tMs23X829Ou5vU1IIhuLRMtbr9mmYig1TCfR7r0oJ5FFrIQiVTvlGWQ PrUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=R8PddrSw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id i10-20020a17090a974a00b00273fa934cc1si2105001pjw.167.2023.10.12.04.49.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:49:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=R8PddrSw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 6000683741F0; Thu, 12 Oct 2023 04:48:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378850AbjJLLr7 (ORCPT + 19 others); Thu, 12 Oct 2023 07:47:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378624AbjJLLrN (ORCPT ); Thu, 12 Oct 2023 07:47:13 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9FAA111; Thu, 12 Oct 2023 04:47:04 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 3FA8A6607382; Thu, 12 Oct 2023 12:47:03 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111223; bh=YCZw7PvG0/vvqRoLk52CD8Z7MDM+1YNzRKdH40h8V+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R8PddrSwYrJypqDe18vfuYP8TLYDSYw/idYGlsRcstM2f0sRYMh/DPISe+y0ffJuu 4kt/lfC2uRsFMfkzckVlAIFWIp2JhQb4rb5icnyD8NU3HdBfP+UUakTQzFCowgDnPi JHHmQ8jHbxn7T91f2FbBAGBPAdi+FmWo6RBneluLVp/CPmxsQl7Pph2msO3HmussbO WuNnVvFhOBDdtJMm8AAAstTlo+tI1U2BP/QgmQ2bkmktV2CfbHVTvuWscER4ftwdMY YcbX3JpKccSevXBp2Z+l8xzLIpyyPPfBQbzosLLm/vYs3STa/MARBTjF0Dw+9UOZUd p3nADtjXcOBzA== 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 v11 26/56] media: pci: tw686x: Set min_buffers_needed to 3 Date: Thu, 12 Oct 2023 13:46:12 +0200 Message-Id: <20231012114642.19040-27-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:48:58 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550229239472255 X-GMAIL-MSGID: 1779550229239472255 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 CC: Ezequiel Garcia --- 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 Thu Oct 12 11:46: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: 151958 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1165079vqb; Thu, 12 Oct 2023 04:48:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGejbMy20sCDMh9tmwhoOAXfFt+KkAirs3CRt5yoTbGBrxDtpoCol/DoWn1RbKCiipUgsuW X-Received: by 2002:a05:6870:f708:b0:1d5:1a99:537f with SMTP id ej8-20020a056870f70800b001d51a99537fmr25518189oab.2.1697111296697; Thu, 12 Oct 2023 04:48:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111296; cv=none; d=google.com; s=arc-20160816; b=q6L/Qy3dTL306tYhiapXWlWLlht1W3yl1upTwdQ5YIcxjhKqs5v4X1xhxUk0f+CfQ9 rjng28vHhkBOlSEXSWBKQm/V2dDGO/xPzHVMC8vogV+roB9v5+BcpbWw14uQzLDASqyQ XFATE00znjEVvc/u8gyyDoa5o/k61Nn+7ggGcP4Oayd4uQzeIzL8ECdPRkRkZmpATt73 ciENetEEBOfjzJ2QhyFYx7OMBHxdBm76w8oSyl7v1R5c8P5FUzyjVdWmanZcsCZjpfuY AAlY357qaIXp5UYnDrnFXKZXx+hNIXdvnJJ8FOxAqYEAubtNDxLmGU+RV0VId+mWGSjd XUHA== 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=nQfxfWgxf+UciazPlm08ZD4s+pDT829wW2uEfBoYZ54=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=lyqMJpZ97OcVCRIqp8hoEiJqQw6U+cKTkQ6ywbYI2ltwvNGRVS/yftUD2SH/5TROEc JFNLil+sC/E6FY8otGbkZPYAz+zlXH5i86QzMEP7czwyGtwiZ7WYaroNyc+YuoGuh2vG jZOoR7h0K+zwgaZP7NtzOl3hkJ5EnNijIY1R7SCmHyihoqNzAD9eExzzennGxOUjFH74 YQ847CyFu6hDCcsuDoWyOzYT3598lC6jaovKZHK9YxfjCfMvgIRt0vG+jvlf+AzdVhSo KQ77MfTbgzPhKUwls8CzBXfnaZQCmIxB6KCwz2qkEgrdwqFoDUdX6weTKqq42qh5zbQQ WE5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=EzeW+HbJ; 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 by13-20020a056a02058d00b0058511efe7d7si2534016pgb.97.2023.10.12.04.48.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:48:16 -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=EzeW+HbJ; 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 5FDCA822CCD8; Thu, 12 Oct 2023 04:48:15 -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 S1379203AbjJLLsC (ORCPT + 19 others); Thu, 12 Oct 2023 07:48:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378628AbjJLLrN (ORCPT ); Thu, 12 Oct 2023 07:47:13 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84E94118; Thu, 12 Oct 2023 04:47:05 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 BDD416607350; Thu, 12 Oct 2023 12:47:03 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111224; bh=VxrSf2TjcSSXRnDg1WucVdGn4nlvPFqwpAeCOwuv/a0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EzeW+HbJ86unAEmGAC4vwmJ5F7x1j/bC6V+hGCcN+5PwyTHBMfIvdhLsKjsTR6ZbX fzQPZLHybtEUgDa7WYxo0o71ObcPkUH5LzJLacnFer5iGKBIpLqBWJNeysKjFDobrB X7RqRCOAfXa11sAbZyri9l/IiKiV5KSN/bTFfS4qB4aHNQeBlbvv/aUcts+CkrS5tV adUoQc3HeGOD5k8DFDyMzyGsgMG+ObIy+0OIIKbroXzOYavehZpulR1xFNOWu3iMnl wzWotHSL9RGn3Rx45EgailuFTCK+EenWeSiFlZqoXd0HP0/RT/jPvM85wcM/pkWObV o/vagGaCYrGdQ== 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 v11 27/56] media: coda: Stop direct calls to queue num_buffers field Date: Thu, 12 Oct 2023 13:46:13 +0200 Message-Id: <20231012114642.19040-28-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:48:15 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550174958373690 X-GMAIL-MSGID: 1779550174958373690 Use vb2_get_num_buffers() to avoid using queue num_buffers field directly. Signed-off-by: Benjamin Gaignard CC: Philipp Zabel --- drivers/media/platform/chips-media/coda-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/chips-media/coda-common.c b/drivers/media/platform/chips-media/coda-common.c index cc4892129aaf..f1d85758f6dd 100644 --- a/drivers/media/platform/chips-media/coda-common.c +++ b/drivers/media/platform/chips-media/coda-common.c @@ -794,7 +794,7 @@ static int coda_s_fmt(struct coda_ctx *ctx, struct v4l2_format *f, if (vb2_is_busy(vq)) { v4l2_err(&ctx->dev->v4l2_dev, "%s: %s queue busy: %d\n", - __func__, v4l2_type_names[f->type], vq->num_buffers); + __func__, v4l2_type_names[f->type], vb2_get_num_buffers(vq)); return -EBUSY; } From patchwork Thu Oct 12 11:46: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: 151963 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1165410vqb; Thu, 12 Oct 2023 04:48:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEKIJ/HhDhYALtO8cGF0WzFwUtrAL38mk07DdBQbnkNfa60leVP88rGLb+T9KIY7V05hyVV X-Received: by 2002:a05:6a21:789a:b0:159:f5fb:bf74 with SMTP id bf26-20020a056a21789a00b00159f5fbbf74mr28345138pzc.3.1697111329776; Thu, 12 Oct 2023 04:48:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111329; cv=none; d=google.com; s=arc-20160816; b=YOI890cAT+vNna1Hyd1PqNN29Sjts5GKUhstagjIxV2CosldwJOgAW36Qz9b7H49wE moSy0HMKyYCz4Ve6bOUZETTdyOjaGe2QMG5zMSegHz38qwzNHaYu/w5LpaF6fULbJg8b CY6AnXMsDpH480GkBRnigXvJS2E1Ufco0LbuZ5tmnytzLukVT43koBcaQsdViYByq8Zz p5AbDyNe8Hvs+2+VR7kwg5UKNMTfDqUcMqyo1wzIwRMu0wOXZ0IDmSdp0SAGMxxvqYhk 47U84F/gHpM/OcQVxmvv0tMDOHTdOTim5hvZgXH0GK1yyuOOJm6Q5kY+mLoTEdLsoyvY tncQ== 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=3H7aO0A592LjQ24S0E6A824+PevC9tGJHZ/klkXuv6s=; fh=CvL1xjq7cAmV80HKhOVeAebMHLceLC2GOvcrwdD6rg4=; b=NtcRwKuRIt40CArz+rFWK8r5t7TX/F3qxhqEUv3aykCOp+dZt0wZVfE3/CI2zOf9Ox yPnA0sihDazsACIbl6AC+JvyX3ilZ9GfzaHQnTE8Y8Yto6xkB9cECa0w/u/C0VMephi6 kVm1wE/fb+MuurkZoPZxMlFiTDjio5fzTMrgDxHZoMaUZ05dJEduXGRm9g5rH/K6tPqV KxmgY8MO3eNFgOUcv6otCb8jbxs/wWrmoscHisf3muE44i4mVuK9il0IaYro91kG2J5P QVr4gRTeZyYuzJGO+8C0EudDxjiX5rs5eWOLZYUBhNTswXTAwKovgmyWJaeICsBE2zvs MWrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=a2ltNEdL; 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 rj5-20020a17090b3e8500b0027d18475bd3si2315865pjb.168.2023.10.12.04.48.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:48:49 -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=a2ltNEdL; 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 938B1822CDEC; Thu, 12 Oct 2023 04:48: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 S1379016AbjJLLs3 (ORCPT + 19 others); Thu, 12 Oct 2023 07:48:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378643AbjJLLrN (ORCPT ); Thu, 12 Oct 2023 07:47:13 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11EB1120; Thu, 12 Oct 2023 04:47:06 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 4A4ED6607385; Thu, 12 Oct 2023 12:47:04 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111224; bh=NSsT5y0sZ7mP+MM3A0B4dMDIfAFW8bmEdwcgMfSAIYI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a2ltNEdLuXjdQ/dkYvVFBvKSBS6dV31uotYvl/1pbWi04aQ3fZPw4uqDgC/rfS4PP eJhYvxsq0STkwS3kmVgiYPtZaYSnlAacWoHAKYw5y5FS8rK3NY38P6YHXYB5lNce9t 6h1U57TwT17xSoakkle1mbycjhD4XOMO2fMwjz8WGz/Vf9xP9P39hJFaUr7OxCfkhI 4M3YLu2oOJtmv9lE3R8bu6MICCv0LJhytQjaUu8+9uh2rG8ArUFiEeNGVZhRlDgz6E Roh09VQe6IkaVLnywzEo6lPyzcEGWGyBIkZMFR4ZbIBOHxYOQrQ6qX+gVwMDTtdx7f EFhfwQv9BwY6g== 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 , Rui Miguel Silva , Laurent Pinchart , Martin Kepplinger Subject: [PATCH v11 28/56] media: nxp: Stop direct calls to queue num_buffers field Date: Thu, 12 Oct 2023 13:46:14 +0200 Message-Id: <20231012114642.19040-29-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:48:48 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550209730052314 X-GMAIL-MSGID: 1779550209730052314 Use vb2_get_num_buffers() to avoid using queue num_buffers field directly. Signed-off-by: Benjamin Gaignard CC: Rui Miguel Silva CC: Laurent Pinchart CC: Martin Kepplinger --- drivers/media/platform/nxp/imx7-media-csi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c index 15049c6aab37..4c467fb82789 100644 --- a/drivers/media/platform/nxp/imx7-media-csi.c +++ b/drivers/media/platform/nxp/imx7-media-csi.c @@ -1245,6 +1245,7 @@ static int imx7_csi_video_queue_setup(struct vb2_queue *vq, struct device *alloc_devs[]) { struct imx7_csi *csi = vb2_get_drv_priv(vq); + unsigned int q_num_bufs = vb2_get_num_buffers(vq); struct v4l2_pix_format *pix = &csi->vdev_fmt; unsigned int count = *nbuffers; @@ -1254,14 +1255,14 @@ static int imx7_csi_video_queue_setup(struct vb2_queue *vq, if (*nplanes) { if (*nplanes != 1 || sizes[0] < pix->sizeimage) return -EINVAL; - count += vq->num_buffers; + count += q_num_bufs; } count = min_t(__u32, IMX7_CSI_VIDEO_MEM_LIMIT / pix->sizeimage, count); if (*nplanes) - *nbuffers = (count < vq->num_buffers) ? 0 : - count - vq->num_buffers; + *nbuffers = (count < q_num_bufs) ? 0 : + count - q_num_bufs; else *nbuffers = count; From patchwork Thu Oct 12 11:46: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: 151985 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1166475vqb; Thu, 12 Oct 2023 04:51:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH88KS4ipkKZ6J6yz+56z5K3lSdTQRAEI64MlmE1zdJtKIrCNDpKGmkmndR1VwuJm3BxFiD X-Received: by 2002:a17:902:e5d2:b0:1c4:1cd3:8062 with SMTP id u18-20020a170902e5d200b001c41cd38062mr26861724plf.2.1697111469489; Thu, 12 Oct 2023 04:51:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111469; cv=none; d=google.com; s=arc-20160816; b=sN4Cfm4iqZzB8wT4bGOs8B2pOZ99y68QUpnAqAnfZs14mjiJpOnHMPl1BezIoDAWv4 MD+Q2CnlZK0ApI6FC9uOYPCRJburRzLzyWR4NSdSUik0hgAZobf50qavTKfZXSd1ySV7 3KzHHLLXxdwM9NOPW4OtMb4gx6bnLf85C4+Tavoh5T+3T9VA06+X41q99T6H6WGXi4ih FEIUpR1pqAx/YfvpRIK2VErazMs75TAfkQk/V0x7V/cZmHoiN0WEzsLb0p4UtQZKUmNu T+AuTWtsHhnPqAiAXXwoKqi4xqIYAxRFkAH6TmJnbGRSVnmMmFJfU0CI8STdR4yiqTuI ZnbA== 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=IbcNvtBb6R2GsKrbxEY4D84V1Qu2aTmsMxQuDj2g0AQ=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=xGbmyFFqMa5Zs4OFfBqxvrLB9wmnTZeFMKhgedF6xgBxbIllQUeM28VnYPMTbvhUGA vUaH0x+mxtPuBRXzBpGwm/z5QQCGuAVSj56CkQp5CCUlRH1fnOOizNg/aUAfTS/ltw/W 7kwvyPPhuMEpx0I0VzTmjCxLYoVwbYBXar+2E/GJO6EBcyJqVuk9cJbiwlkhVAOzQXqt hDw1H396iBxnClYXN7YARm2L3yXznDzxO5/mGagojFoF6letWFtujsmF2L5KwUJxe38f UMa4Auu8SyWmvRABs5JDdFd9VEuhczSaJyfMqxgoMs2mJjBH5Nj94I+Jww7YL/7B9u9i YXsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Gt4nc0tx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id y22-20020a17090264d600b001c6223e5675si1931440pli.188.2023.10.12.04.51.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:51:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Gt4nc0tx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id BF9B980A64EC; Thu, 12 Oct 2023 04:50:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379103AbjJLLsp (ORCPT + 19 others); Thu, 12 Oct 2023 07:48:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378658AbjJLLrO (ORCPT ); Thu, 12 Oct 2023 07:47:14 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9864D124; Thu, 12 Oct 2023 04:47:06 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 D47F96607386; Thu, 12 Oct 2023 12:47:04 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111225; bh=51uRb95lmgtzN6hPPISI8XHQeJXuX3+AzrSS67M/f6s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gt4nc0txfNVIZ5gk4/sqZ4qB2MaTfQYsWPhxWnma3yviaHOoARF6sXyzRJQqcO8Ou XTEAtThthuhUpmbSiRuoovR62A4gy/9MJ8/7brNgOXyfIqXGQCUcR/peYoJGA/2lV0 Z9vAeqBAXyTu7CBu6KxUgbS2Q1gHaAfosZtAX6AwGHCqrpP1m1SXj17i8IzP5iDUGh G3OZaWgQg60lJGtoYrK7Ojy62GGP601fLQ42VL2fzdALe+zUaGUxyPvSFyNtKID3qP SR7pFSjVWzGBjGtXWYmY8LuPddgpfsOvoev0Wod6oVczcObQtZhTUb4igjZ1ftwAnC 4roVOh35d8nIg== 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 v11 29/56] media: renesas: Set min_buffers_needed to 16 Date: Thu, 12 Oct 2023 13:46:15 +0200 Message-Id: <20231012114642.19040-30-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:50:54 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550356035155193 X-GMAIL-MSGID: 1779550356035155193 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 CC: Philipp Zabel --- 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 Thu Oct 12 11:46: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: 151970 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1165548vqb; Thu, 12 Oct 2023 04:49:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFdwxJREtM2AutMRB3U4O8N0i5WEnPsry4JYNxCzWYp4zEhsdvQGSyBBoRAsIQvXV/595cW X-Received: by 2002:a05:6a00:3ab:b0:68f:c309:9736 with SMTP id y43-20020a056a0003ab00b0068fc3099736mr25596840pfs.3.1697111348523; Thu, 12 Oct 2023 04:49:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111348; cv=none; d=google.com; s=arc-20160816; b=T92U/ePOAfri/FqapDzkYfzGJkpZsfYOF3PUkfcmjLHr8dZKJt4NXzJGfCu4gVXnG1 WPmmQEwq5N6+J3fFaf/IvD8hchblw8DUk4FZtoMF1Oc7Z2Mc4PfnT3xtOUrIPDPmN9LT g8G83irJTuFy+N3MptH1cV+VcuhrL4hUD7WM+Vi/EDRMCYbWh3l6NggxL6/IMPZwQD7C JsZPQdOeqp7NoK3rC/67HeJb9Hm3vDnyonL4rl3MeCO3J3eBElXXtcZKWzcnozZXrPnm RsnVFpCc7crxx9e/EsfPw6bCRUqud5XWMGxazoaLyfeDTVsAXBkGhMOaAFw/8IH6gmM2 ab5A== 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=dreqWwoXmak59SsnpmmXUjxLjs31zjo08LBSQeCifLE=; fh=N6ugtfNsynmfBJwExzB6j0reiQ5L5ldIIl+DJ0NYKOk=; b=BQ8kuVJWREG+iL4q9bA7Xe33cOAnH9EgwxDnnyF59IaZxTuifqZMHt68Nu9qRUC4hz hItVW/lsvUOa1FDPPrw+jI3rNYCEmD6X0My//QKPgValV7oe/9sKQQWMrJ5iEeFhaFD0 apJGq9LUMBbRENY/7d7L17GpSy7VHLV8Q7+DiW5u6W9eLqQhskXq8EB0ruG+MDRH9b5D x3GTOaZPtZYLE4gpW/yLDrZXYmahPX+/8kWpihMcX9Er+/NhfWZZM7H82RU88Qf08Duk mO+oQLbmGULB30DEKGqU4jRlQlIBHJICYLOdQz6y0dR3zLPNobiyhrWJjBvAOGYoWETc 6R4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=GBfEFpri; 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 z9-20020aa78889000000b0068fef37e5bdsi3582311pfe.244.2023.10.12.04.49.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:49:08 -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=GBfEFpri; 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 5B638822CE02; Thu, 12 Oct 2023 04:49:07 -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 S1379171AbjJLLsw (ORCPT + 19 others); Thu, 12 Oct 2023 07:48:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378671AbjJLLrO (ORCPT ); Thu, 12 Oct 2023 07:47:14 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E6D712A; Thu, 12 Oct 2023 04:47:07 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 5CC6E6607387; Thu, 12 Oct 2023 12:47:05 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111225; bh=z1P/3O08IkeE+Et5UD27w3xE7KdKdzhm59GKXS9wTKw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GBfEFpriASh4jR02Y1szsu1UfdrTYdCX5K+WBMax3riKRsFRZ1KjEqdKOcJm3hpst XCkYcDe+3NDvFH1C5l/ukP352uv/2c/8d1DMu8DMwJ9bxtxD2dfGv4yT8hiCvjczP7 cJ362c/PfZcPMJGirgfoGCQ4wFnCTWqB3JkFTaUkVqhQ14MsMTPaV6loOk8fRkb4YR s2RusMwI2wj0VrSEm0hs8rjb3xog/azFUd70IO3Rmm5fSAROzxwyGr/g++0T0Yu1rX peL1zDxhtonNox+4AABvY63ch13qFxZbtpKKxDI+WFFxVc5Eby8OdLPr611MxlwFlx F1QKszrE2jIwA== 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 , "Lad, Prabhakar" Subject: [PATCH v11 30/56] media: ti: Use queue min_buffers_needed field to set the min number of buffers Date: Thu, 12 Oct 2023 13:46:16 +0200 Message-Id: <20231012114642.19040-31-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:49:07 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550229284720453 X-GMAIL-MSGID: 1779550229284720453 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 CC: "Lad, Prabhakar" --- 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 Thu Oct 12 11:46: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: 151968 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1165507vqb; Thu, 12 Oct 2023 04:49:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH0PQXxI2N9mWI/uOlBNEtAemhpBWKKJV0VbUc38j8hO2AtQnNoLHufn1elymGmjrcD0ZwJ X-Received: by 2002:a17:90b:3b50:b0:27d:1593:2b0b with SMTP id ot16-20020a17090b3b5000b0027d15932b0bmr2874108pjb.0.1697111343962; Thu, 12 Oct 2023 04:49:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111343; cv=none; d=google.com; s=arc-20160816; b=BXmTqcna1VOKK6n4kwKFV7Bv1YuX6B9aUM1aoTYZbCmK5G4gExUHCa5UohHqbkDvSz XlXhTjvMYWMjt03FqXaNqa4U8eREG3eBrglWjUPohcasglApZ6Jrcfgq6tdGV43HS2Ps 1kFwA3nRiwS8YSmPkhWeoswOqPCDv8IyO3XSFkHaVOCiIJoIoe1NZaqEV2qU5Os8pebz a46nrIwZU2fNhYvGPDJkRgHnsU0RfEdinETEEZx/hdQ8xf6BdBeH965KwWI+RulOxV/B PaKwBfghW6ZqTnGV0IuCewbnGb/XkJUfkqrATBQcTrpcyJllLNGIOPks9u98VGlcXEsk mJ0A== 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=dAlpY4jZ149+ohKIDbU/K7k/g6xRlqzb1xXX3/H0UKE=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=ftYqWRkI/+zwQAlQr9GOjhI0MOaXwY5jCVGVPIr7abEfJ/ciiPqOIDsqypgklWAKob XrbfimM0HnfWoF7F6NiSvp3XB1J4FnGC+OLQym9Y2u4T1TcYFGYbFjrsz/gLdyCvdJkP +88gxuuy3zqxouEWzcJ1vXVIlBZc6CA9NS7v5BdVP1a4WLzGCvqlP5GtvL9DYfKHEj+M J18vj0LOs9VJC8W/VlTGPNzsJSHo1c1lmT6PjDWWc5yOGvsOkkPxFYgr2VLltOt3Ds96 VtbJL7DXfjASoRz5LGcBGtCoQc/4YCJq3ky9XrvzZL0/OUCoZK7V3G79Iof7koWoi4xu BA7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=mYp0GjKa; 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 p36-20020a635b24000000b00578b4992008si2066914pgb.133.2023.10.12.04.49.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:49:03 -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=mYp0GjKa; 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 29073822CC57; Thu, 12 Oct 2023 04:49:02 -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 S1378347AbjJLLss (ORCPT + 19 others); Thu, 12 Oct 2023 07:48:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378675AbjJLLrO (ORCPT ); Thu, 12 Oct 2023 07:47:14 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F3E012C; Thu, 12 Oct 2023 04:47:07 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 E1D406607389; Thu, 12 Oct 2023 12:47:05 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111226; bh=cwJWUlnwaw24g7k0RvJm2NeRk0x74b48EFhNNZXgOSU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mYp0GjKa40MKIS0Cll3rPRzwXXaz2vb+gb7JwMQ0tjMs/f2kJZkUlk0LAtFQx6p3b 2vDLV/3iMZoprbcpqoFFGblmdIBsUucWRgFZfxVDKISKNgXKuW4JV7NEGmgbEXznFK XV0mSjb1YLmp7lRb2y/ZhnQ0RP3p0eLQqcfR4d6yrgq7NsN5OKYLc4oqteuA0iL07v NF0mtovt+pSWnCxvY9pBNzBtsBAXsX9BSw4Xwin9SxnbWd/koNuGFe9dQt6c9s0Ly2 8H52/ah0wkUxjEc1gmC4TQNYBRBpX97TYnvyLbDhlMS6AwGt4WKTT35Vku0S9/nku7 ae7BtiTB1osaQ== 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 v11 31/56] media: verisilicon: Stop direct calls to queue num_buffers field Date: Thu, 12 Oct 2023 13:46:17 +0200 Message-Id: <20231012114642.19040-32-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:49:02 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550224412131808 X-GMAIL-MSGID: 1779550224412131808 Use vb2_get_num_buffers() to avoid using queue num_buffers field directly. Signed-off-by: Benjamin Gaignard CC: Ezequiel Garcia --- 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 64d6fb852ae9..8f8f17e671ce 100644 --- a/drivers/media/platform/verisilicon/hantro_postproc.c +++ b/drivers/media/platform/verisilicon/hantro_postproc.c @@ -195,7 +195,7 @@ int hantro_postproc_alloc(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; + unsigned int num_buffers = vb2_get_num_buffers(cap_queue); struct v4l2_pix_format_mplane pix_mp; const struct hantro_fmt *fmt; unsigned int i, buf_size; From patchwork Thu Oct 12 11:46: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: 151971 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1165569vqb; Thu, 12 Oct 2023 04:49:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEISj59z04sWRN7Ar51PI5z81N7H1Mik/n7lsCkKWdhiyi3ckSrGUKI5gjXwsZLmtelM7jr X-Received: by 2002:a05:6a21:a596:b0:163:d382:ba84 with SMTP id gd22-20020a056a21a59600b00163d382ba84mr29305888pzc.5.1697111352225; Thu, 12 Oct 2023 04:49:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111352; cv=none; d=google.com; s=arc-20160816; b=PxPs3UMYfI5uwCLKIMPTDTZRX9tv7pSjLTVN9aTFKQJX84FcOMVLwby6dh1jMi+pRa JKkkRbowbT8SDZ9QEo5v1zlEdJnXwnlOaQjv9041n7qkSAdnIcLWe9kRqPNPec2VfGHb OygIalZq80Hm5ltvqGcfKP4+x5fDaX1vF3G4/o4W/2hYzFawJxMA5DwP48GrswhOBLhx wfxIdP7+qQ7/pSLvrCU89E4G+yA8TyyHFDVJ772bj3unKiw/PDIxa05qwSotGP5++vJW 8E+O+D9qBQYbvdCtPp/IbStkuX1MCSPAhG7oGtgOsweTOzCzGUuDx5tb4xjHJrMVZpie x7JA== 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=XhUTBTuVB8DZb6aUBl+O3Vq+VnVbuBGByiqQ4Uv5WSQ=; fh=R7B7Bon9pv+GFCDou9bQ9Fb3T633P/NGL4WG9w9NtOc=; b=Oy+yMXE3irSxmv4bv4L6kqKxd7TC8xZQu3YpOe4HdjcFrAJV08uF+MFGPo4DM3RbF6 Hxr6gXw75jFsqWtcn04WKo5+6no44C+yUrjLltyY0sUrHAxClIbyNo6JMF7OhY1bbYa6 SS7uLLQailJzgJlLzMpSEEYEeVZqgBkqJ4sDmHIpXM44kT1z+9yytuVcgUwAzbr9hjHV BHxV4+BLw6B40Rus54+jIVvuE4YVp/1b8XqXKomxeAImBXjisD/AsClJ8sGlkPD/aMZh EHB6lzi63PyZsj0iUycEeFf4OKPioZmPuil92/0Tzys0z9XNvtpquwbHC8E5h1bRz65v cvPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Jl+BxZg1; 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 x189-20020a6386c6000000b005855e5e2f98si2119479pgd.75.2023.10.12.04.49.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:49:12 -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=Jl+BxZg1; 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 731D0822CC58; Thu, 12 Oct 2023 04:49:10 -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 S1379381AbjJLLs6 (ORCPT + 19 others); Thu, 12 Oct 2023 07:48:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378732AbjJLLrP (ORCPT ); Thu, 12 Oct 2023 07:47:15 -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 33B6513D; Thu, 12 Oct 2023 04:47:08 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 6A0A1660734F; Thu, 12 Oct 2023 12:47:06 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111226; bh=kDFtrZ4zFUeHfWfJJ6YMQqB6iaea9mEI5MMOiS3HlSA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jl+BxZg1vf0RrKfn/NsEj2nUgLll8t3S+MrVeafFLGO+6yL/Z2hC0rDg7TBn44B63 oBqlQaJXiFtG4uxCzHlsSK9XQa664LdHE7Etxye8z+xh7GO8ZXpFhrc3NoRhGjQGC9 a8JqPvoIxNxxCTiHOHJC+XdzCuhZB8xLNiGL3czjyhIxyyrCORK8l26fiX+pjQnJjS F2zGK2NPRDdaWLaDmaqUJ58XVH7qVXTEsLlCR1saKGrLgrk3WX6v1EatsZ5l5KAthm xdzZA/8DJynGdICB95DaCTI7ENGOtCkR6rwC9nlM9YL9DUkjWjVHOu81IPL21QJMkQ 8+yUpmBvNCIpw== 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 , Daniel Almeida Subject: [PATCH v11 32/56] media: test-drivers: Stop direct calls to queue num_buffers field Date: Thu, 12 Oct 2023 13:46:18 +0200 Message-Id: <20231012114642.19040-33-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:49:10 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550233171845890 X-GMAIL-MSGID: 1779550233171845890 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 CC: Daniel Almeida --- 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..4672dc5e52bb 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 < vb2_get_num_buffers(out_q); 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 < vb2_get_num_buffers(cap_q); 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 Thu Oct 12 11:46: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: 152004 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1193494vqb; Thu, 12 Oct 2023 05:34:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFNflBKtY18z7YUa9Pdq81R2HDwbUU73ti7yVup3miBY72QunnufEonLHdlkoIaktgvk/An X-Received: by 2002:a05:6a20:a123:b0:13f:65ca:52a2 with SMTP id q35-20020a056a20a12300b0013f65ca52a2mr26608727pzk.5.1697114043435; Thu, 12 Oct 2023 05:34:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697114043; cv=none; d=google.com; s=arc-20160816; b=hVsYbH+3NbZBibOZgYoV3TPLmYp/yYFyJLNvlTvhpj8opnXG6KcBdTTzDwsA440huT oQqYFaEJwELDz7jV7EvSW2PQrrJxTej7GPlfZRc9vpZNNkG/cFjaVWA/3Z1fpsUxWVMp 9qWANegPbXn49j0K8EzadGK5CdUCo3zAc3WxLpiOyzwwHMu5AHQsPmIcbBIjWXRZWt9H mhQDCUyVwYpdygiVmFOjb8Co2HvaWWZehdblttuZ9qTTDWQLmxToAvxBdI7HH8Nn2eyW 3Ak/X9L5xx3FS4MWkUEWQ6BagC7hkeY9oczNrjH64hfd2AlGuxTWiyiEWNS1FROF4LiP tz7w== 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=mZs75sxNyEMKxgyp24DosHVVPoQJidrdHhoLAIzZ8gc=; fh=p0AH8hgimiy85Lh1cXLIqpi5zFbeLa4s8fsQNMmUBzM=; b=nG2rN3J5arqJRilHpBTUnIbHNIfzxWoV47M0gEmEgCulVj26eiO2gUYSbddCTcMTVH ETG9J3UPOIspjVQHK1rYH7PDttK3VsFJNZuUTKd9AVDxtroSHHhhY1liFgQi5ayCTvC2 4w0Rd1GHbOjdXjgrpd4ZSguDqDCEQx+zzeybZs1reAAYaK462LGfne1CPPI3LJRzZJUn V5bRvx40QIUluzGKuo8q6AhGHFzTJqzASJfcWRjVZBE9tI8O5Gnh+wmSZohrJo4s4BCo egyEsRgHdnolkZTCuzl6e+O5SeWBhhEgQFNjxZfGs6ePA0wN1zj20DZvJ6E+eVr+dD05 KVQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=L8cYZ8LK; 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 d4-20020a17090ab30400b00276ea6d9ac3si2056381pjr.182.2023.10.12.05.34.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 05:34:03 -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=L8cYZ8LK; 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 EB0B781AA505; Thu, 12 Oct 2023 05:34:00 -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 S1379324AbjJLLs4 (ORCPT + 19 others); Thu, 12 Oct 2023 07:48:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378706AbjJLLrO (ORCPT ); Thu, 12 Oct 2023 07:47:14 -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 B44FA185; Thu, 12 Oct 2023 04:47:08 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 EC0CF660738C; Thu, 12 Oct 2023 12:47:06 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111227; bh=2/0WQage6iY7ZIfSwpoGdnzQlJzC1UZq8fdQbr8LRKw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L8cYZ8LKwxDdQJC/fkFna0Z4loJWQY4rlLc2nv/Iu86jK57Dgo5nLbgWL6uzreecL kXVb7RHCUVlKxJXrPlrZTBFj0wjGyXvpXiK45iRJ3QADd1AjZvZTBkp4lJ47u1w2tz 8LSUo+83BEFBQ9rAZKDCL3bHB+qY/PPmhiOLoehJZIQtbLpsWqyyk8XPRxj1K1ZTbY xBeynsjCo2i/JM5xiLNWE8A8rfak1nxqGNM5ADSU/4GokgPl+JIZaITV8jQKANfJXE vR5aneBs49rxfpAOgs6fzUVB2eslLVMTPIGMR8A6GyzQlfki+NJE+lFeWQ+IidYIrS iFucW8Q+HNdxw== 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 , Antti Palosaari Subject: [PATCH v11 33/56] media: usb: airspy: Set min_buffers_needed to 8 Date: Thu, 12 Oct 2023 13:46:19 +0200 Message-Id: <20231012114642.19040-34-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 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]); Thu, 12 Oct 2023 05:34:01 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779553055447579405 X-GMAIL-MSGID: 1779553055447579405 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 CC: Antti Palosaari --- 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 Thu Oct 12 11:46: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: 151972 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1165612vqb; Thu, 12 Oct 2023 04:49:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFwNB000TGccRMUScGt7YAYJ04yNDHooJgjdfDb3v1K03i8sBM5i65/VCCMp5L/8nHpucAu X-Received: by 2002:a05:6a21:a596:b0:163:d382:ba84 with SMTP id gd22-20020a056a21a59600b00163d382ba84mr29306015pzc.5.1697111355783; Thu, 12 Oct 2023 04:49:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111355; cv=none; d=google.com; s=arc-20160816; b=goKSa12BC9cr1nUNUMRGL2Yqp/FiSUrhLp3FebMBuXKbfAOWJL2FfDzJIEuqpeAiqg yCrFhuQjBzk7v1b8jc16kbS0KfcaUmwDraFDtilDHgxLnAua5Mh0KjeRCWtXJmHPZ4sd uN9qMgzJGe/uGiXF2cFamUXq3Nl4L8Q6a83QLZJqwoUl6gTSuU7UM46tKzCAsXQj93R8 mI2rr4vE2IT6AEB9ICkTe7bIz6AnufjhIGdwRcJtm7OsdkDKwBVuubtDOdnYIu2Zq+hl sFprKLJJ+df9PTOI7gmLS2cyb5+gvJ3QAX1bjkG6WSE2Kn+4NVupN2bqZsBxVkIdBgMT Ge+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=ER83NPi30J3seQDoSaM/YXD649vL/4o83t3smZbJ/84=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=EVlwF4HaX95laGj+7+FnYhxGRGppcuVdjtpY3qGkxjDEDRxVmM897I6GG7ri4Zbijm Q43/zBPvIEQH5g87zWAgRQYskPsVTtrG37+5hzlCwfPo/tSz6yNqrUEc+msLuIycGydX R6SII/TtetMvBoKHaXj8iK37B2TFzHc5AF6Hl/DWl78dgG8G/EL3ZpqyLDo9lejJmzzy K+cDwpmADLV7xbYrBCciudkp8iO/EeHyUTAbinxrEGRF3iXDNjTYZmSqlTBrGQz6pihv KY9wvj0Ks4LmoU4SRA4F+TN0quOqbMEsUWzsEKVbAnsjOMf6E/s+DhZa8WPRbs2LX2Gr IvEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=MeUP9vNz; 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 k63-20020a632442000000b00578f7063ae7si2162268pgk.682.2023.10.12.04.49.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:49:15 -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=MeUP9vNz; 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 C55EE822CE1D; Thu, 12 Oct 2023 04:49: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 S234148AbjJLLtB (ORCPT + 19 others); Thu, 12 Oct 2023 07:49:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378755AbjJLLrP (ORCPT ); Thu, 12 Oct 2023 07:47:15 -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 48E9018B; Thu, 12 Oct 2023 04:47:09 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 7AD7A6607342; Thu, 12 Oct 2023 12:47:07 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111227; bh=fi+Fxcs6m07q1y5Umer9Ad8BDnSh9/sSAfF+r67YVOU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MeUP9vNzWBasugY68j+66SW3C/LzkLPve86K4aNyyQ8g++Q76e+RYBrQ7LINrkiK2 dsRGKCnEg6ehWToc0Tncef+RTzatdbeo/RNZrTk3Dbo5KvI4v47Vt6wvsvpenCVL0/ y+0a8Wh1yV6ny/p02Tl32UDcVc7xMtAlNltup5VYEr43eFC1BV4fb0nqEsusg3DHtU rQCOAq2Yfh3yQTde3Wfmp7KWiR0PWlxKxpY3IszrosThGBVzGgCd5HOOCuLe0XWICi EZvCqXBc9OZUrFfT5a44sHvMPfl1hTbJXeMn5R0TEEji6U92aR0Ok3gWrm45MOQ8ky 0oR+n+dAb7a5Q== 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 v11 34/56] media: usb: cx231xx: Set min_buffers_needed to CX231XX_MIN_BUF Date: Thu, 12 Oct 2023 13:46:20 +0200 Message-Id: <20231012114642.19040-35-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:49:13 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550236739244057 X-GMAIL-MSGID: 1779550236739244057 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 Thu Oct 12 11:46: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: 151987 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1166557vqb; Thu, 12 Oct 2023 04:51:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHzetRzu218HAF4zVtEqhEi7d5GDbl/ujBEwAdLIPUUoZiZLIe9BecKZ7Mh8gzfh7AOdF7a X-Received: by 2002:a17:902:d4c9:b0:1b8:9fc4:2733 with SMTP id o9-20020a170902d4c900b001b89fc42733mr26663385plg.3.1697111479430; Thu, 12 Oct 2023 04:51:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111479; cv=none; d=google.com; s=arc-20160816; b=vlOBuTbjbgeNDq3nPjd0GrZiCt0V4ZOiv66YcLnw3dVo9Aa7UFTBtat4ZcNbhsBc7w j70NEKRdh0LnE93JGQ2Du3i/zBfctujWgJCJ/ZGMetA/30D0A37DduIp2hDCSiqQW0D3 UCyMbURKb+99vpf21ZJJz+O4OmYM3VLguLyQeoc5fG3XEKh7kDYc+9MF1nPOkraDTB5K pUPmd/ZHx9cDRmZqr1OibSWtLJ57hSM1j41vq075DmMc4QGxa8trIUQXEuYk+5uHweNV lTSoETnl6jonnU+oL2lLWFPvB5iCJB2aoGGv7fSzUljNv3wbQHx6cMDG0pfgAorrJTv2 9DcQ== 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=880OYilSR3s/ka6XPIa3CAbS09woXqMQeX/b/wUiKAQ=; fh=p0AH8hgimiy85Lh1cXLIqpi5zFbeLa4s8fsQNMmUBzM=; b=oB04VUupAB2wb1GUwbHIIKKr1HcYoId8UV6tIZSETX6HTtiAmOHigNLxDpAD0oX9JN Xcyf7eHy24cThMp0Pq/pFgWzYKoeJbNLAVVwqs5PQeHRfgmvngh0VVI/vzmrA9ZmXVXz HQHAgwIsBPQTN1eyiCMkomffOEYMidPCTaf/9vaeU98AryuPrnWkwQlxyFuh+jJpnVr5 aTakkDdfsjCOEjo/t9zf7veLrnoUSDrBmcKnNFmPax1mzkaU+gpOstYh07S3C6XOXOoG PwrC3BLJZgfdTqu16vtY9nQx8yJ+powSYOB5hhBMQ3YEW5z1MARAQ09zBS0CR1XGnXA0 rH0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Gf62AcjP; 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 ja2-20020a170902efc200b001b5589848absi1961668plb.234.2023.10.12.04.51.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:51:19 -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=Gf62AcjP; 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 47E2A822F8E6; Thu, 12 Oct 2023 04:50:00 -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 S1378732AbjJLLtG (ORCPT + 19 others); Thu, 12 Oct 2023 07:49:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378811AbjJLLrT (ORCPT ); Thu, 12 Oct 2023 07:47:19 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C28519E; Thu, 12 Oct 2023 04:47:09 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 04BCE660738E; Thu, 12 Oct 2023 12:47:08 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111228; bh=Zne8+1+gt7T5bArgwI34aDgBwx9md9yjRlThQEon5Pk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gf62AcjPOWvhMdRnJLmE7bGshcMQ4KNh+hthHIVDXid8l3MkgBetP/26Xjn2KSMtb H8EIQSwmX8n+aIhWpFXtdiS3F+VD8K0qfKNtKDWURVfH22H2dLYAxvb+SWUBXxslQB 7fhI0AoGLYmOPsk2AfDcf2O9hPNloqPwd89JElrVskjwHUhCpOGFyyeJdn6VboNJhP Ac99fN6a8lkBmEnmkgSvKIVnNUyJSXkvto5CExml7BtvuC4Nx1w5XdmzPPb7C8Qi3b 342KiEz+CMwVHJEKp5FmaLjASvSoTU+TKexyrkuS7nQqQLVOR5ZPbF8Gs3IfcZmZDz wauoulmDnt5fw== 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 , Antti Palosaari Subject: [PATCH v11 35/56] media: usb: hackrf: Set min_buffers_needed to 8 Date: Thu, 12 Oct 2023 13:46:21 +0200 Message-Id: <20231012114642.19040-36-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 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 howler.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 (howler.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:50:00 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550366710553656 X-GMAIL-MSGID: 1779550366710553656 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 CC: Antti Palosaari --- 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 Thu Oct 12 11:46: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: 151976 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1165727vqb; Thu, 12 Oct 2023 04:49:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGyCUL4KTCkelY3hcCrTn2nZuYrpbTXOwOzlKJ3NZfqKLqpyyiw5cJhywT2IZ9IK2WIrab1 X-Received: by 2002:a05:6870:f708:b0:1d5:1a99:537f with SMTP id ej8-20020a056870f70800b001d51a99537fmr25520744oab.2.1697111371041; Thu, 12 Oct 2023 04:49:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111370; cv=none; d=google.com; s=arc-20160816; b=y5zvqZOPWjGJRHcbUuCHhJ9480dpSzo36KX0FIyLAB4SDno9+7KbzNFzPRbLEnkeac d8XV89mMzbD72kJRmDyL/HtxhW3hmioSI0Wt5Z8n0FqQrKvaYkA/zkY08YEEQpRyjyxA +MkHtN7kC0dOWONxosjenkPle5QupGdVjx4AqH/EY+5ZcteyDVv+pUuwY25Sdf8yakLz +npuglmtxipmEBSreNM8IW2CUF10rKIfza3RazDEhUKCdH3WJ3O2CeZBnB0IfogrCveL 2PwIEOhJcaCagFYvz65EKDfqdRMY8XNzeZ4Ll4otedsj+XKpo9osoGigIiGgzXCaCS05 yIcA== 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=odpDeE1tVGI13smqOsmSl3Ka1Tt5a4UqlhtGFbUwLi7wwemGDOe/m2mNdhD/pdT8Cz eEVqxfnX/YH9sS3a1rzgcDHP70YFiGDa16SwmgEIfqjBcH2hnCVzeLj1TEtSJaRKsrt1 ASUtVT7HvikimvJvPum/Khe0wfoR20xCdMgwtUfTfCe+5C52Paz9GdmCy1GuxjAZC87F Zc7HGN75VuSAG9uNMkSShYFrLTy0xICm4yUG9MZgtI22mnF8tJAQftHV5UYz91alh+n1 b2l4qNk3GgOGWZmuJDnImFbYbPm1BhZWvYKvnrfOtN1zM9BWoKjdQDtWV/xmsD+LxVYS dKHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=mN6W36Wo; 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 j193-20020a638bca000000b005898cf9919asi2082943pge.177.2023.10.12.04.49.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:49:30 -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=mN6W36Wo; 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 0EA5D822CBFF; Thu, 12 Oct 2023 04:49:30 -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 S1378780AbjJLLtW (ORCPT + 19 others); Thu, 12 Oct 2023 07:49:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378849AbjJLLrU (ORCPT ); Thu, 12 Oct 2023 07:47:20 -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 9160F1A6; Thu, 12 Oct 2023 04:47:10 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 86A5C660738F; Thu, 12 Oct 2023 12:47:08 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111228; bh=nwepyznt8z6pxABzkpFHR6clGV59kYVToyX8aj6cN+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mN6W36WoEkjWrR30vYtboERgKPchBJyh+WD7O8aVg2uy/HCHqIyoh+sOf2TbXXvxV EoBPi2859Pjn0XZK9IZE6QhBmT6jiRnpsfUnPPEFuZrrwpVXGAotRvmcfW1Gc9SXVJ oBrU9XziAdJLDsG7AcE2xpmi41nBeHIRxm7r8rbbJTNImrGhs/nzsmO+I7u1j9Mr5r xj7zcs6k2KrOy1FC0ikpSWXrKnr7+VX2VYmOYxYiHzy2W5/zZNj5C6khlQ2sqz/2Sz CH1LKyFEVs64Q4oIxigN+qxllG2HtV+qwIeuB4Nm+zguIX8HEgUfe9QL1CHa4tWbE1 ew0PRHfGaxX0w== 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 v11 36/56] media: usb: usbtv: Set min_buffers_needed to 2 Date: Thu, 12 Oct 2023 13:46:22 +0200 Message-Id: <20231012114642.19040-37-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:49:30 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550252900876911 X-GMAIL-MSGID: 1779550252900876911 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 Thu Oct 12 11:46: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: 151975 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1165687vqb; Thu, 12 Oct 2023 04:49:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGmYrmeFErwvlOM6PJjoyMJ1O5PxMgT3fBSFiJocwvwqcKKSRUgG36vOmXG1/ou40/NMdtA X-Received: by 2002:a17:90a:1:b0:27d:1f88:3cd with SMTP id 1-20020a17090a000100b0027d1f8803cdmr1601416pja.4.1697111365490; Thu, 12 Oct 2023 04:49:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111365; cv=none; d=google.com; s=arc-20160816; b=g9dayKE5yCsPt+zE6Fi00G6CAE287W8nbM8hPjYmmNZb1O0bSvrAfVZeBmILE6/cDn KUUuQms2v83sKD2A32IDKvqNEkSsLgQFuWtLhWB/Ax5/cKLwnYwVHo5JerjiqJFrhfar yVd3tOEJcORCFiqgkXYq/4w5tMvFBow83uaa/TPc2aBZi0nz/vl/nLImQpFFENypZMG/ CVs1W8ZzKOPqXgMo3d4F0cv3nLJIUG9G0l7/nWsMPGHWZdfjJ+TbChof/9J8bJr071qp f1B/14rgBPXxnBh1eRBa2UURuXRGdxOReUK3nZh+tDa96IOD78rqcdPgu1JWnxNUVSmn PSSA== 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=8BPzQYccziwI9KpKIdTVFE9/sJYut7XJo6Iy5Z814FQ=; fh=171ZbtLkqTQvfc21XcAM+Vd/toNFohdADskHHVOkNqQ=; b=zP2SEtoFTgEqWjlSz4zC//z7c1QgHLNq/v9U65m001Yd0WZnuL2exzNpo8lnEttqNP ozmLZu93lZcKTWa35r8A8eXOPh9n7vmn3AnFudCWWkcS1+FbjV/b0mR06ZdDM9rXmn4m Yminiob7XtC3NTKVX3MKzJnEya2XOe1zB1BzBAIh3jgG2uTkPogVjGATYZ/3aeDcLJvp 8tuOw84a12Tu1BSJvd+bbjbf3M5E1jS/14nPs6GeQ/p9qqqhLU4yDCq+39FBJwJwvEV1 nTP0l0Wv6A6McluvQnmin1rxhYho8wIohmDuqsaSwnDb9VjZDUzFp1bXAv8jcY4vmqti baJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=mdZn7Avt; 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 nn13-20020a17090b38cd00b00276671731e3si2154050pjb.136.2023.10.12.04.49.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:49:25 -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=mdZn7Avt; 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 8F8FD822CD6D; Thu, 12 Oct 2023 04:49:24 -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 S1378381AbjJLLtP (ORCPT + 19 others); Thu, 12 Oct 2023 07:49:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378868AbjJLLrU (ORCPT ); Thu, 12 Oct 2023 07:47:20 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D814CA; Thu, 12 Oct 2023 04:47:10 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 133B06607395; Thu, 12 Oct 2023 12:47:09 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111229; bh=mz6L3tQb5oP+x6Uw4FTrcS9pwtcQjO0juMIWxd3jOzM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mdZn7AvtFYaWUfkn6a6ksQuZNdZm0VxQYMjyHDOc76jFdH6KIau3URG4gdjOhF/QC jJHraV2V5P8MQRYx6ka3AujPNE4FgAlqXc5lCdfOMb1MX0U2LwLbZJIU6AwAT09ved wAQL+3nNkMxAdr8piP4brX+imcIgA2R4lHpkmbuHz9lRb0NOY03N7/Eu0A7+qmsl7s qxTezDnvuG+fGvuan0sVCDkMwnZBFyLWllL9vRD7/NQT7pn06LArJ+k5Ivgs9nM/vT 3bPrA8fV/mpAQATRhFSBdm3rm2uthCLu36I/ll+hjzcCOQVGFD8fds1aQYZC4iuDkf p+IlctXtii1Yg== 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 , Steve Longerbeam Subject: [PATCH v11 37/56] media: imx: Stop direct calls to queue num_buffers field Date: Thu, 12 Oct 2023 13:46:23 +0200 Message-Id: <20231012114642.19040-38-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:49:24 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550247088922024 X-GMAIL-MSGID: 1779550247088922024 Use vb2_get_num_buffers() to avoid using queue num_buffers field directly. Signed-off-by: Benjamin Gaignard CC: Steve Longerbeam CC: Philipp Zabel --- drivers/staging/media/imx/imx-media-capture.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-capture.c b/drivers/staging/media/imx/imx-media-capture.c index 4846078315ff..ce02199e7b1b 100644 --- a/drivers/staging/media/imx/imx-media-capture.c +++ b/drivers/staging/media/imx/imx-media-capture.c @@ -605,6 +605,7 @@ static int capture_queue_setup(struct vb2_queue *vq, { struct capture_priv *priv = vb2_get_drv_priv(vq); struct v4l2_pix_format *pix = &priv->vdev.fmt; + unsigned int q_num_bufs = vb2_get_num_buffers(vq); unsigned int count = *nbuffers; if (vq->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) @@ -613,14 +614,14 @@ static int capture_queue_setup(struct vb2_queue *vq, if (*nplanes) { if (*nplanes != 1 || sizes[0] < pix->sizeimage) return -EINVAL; - count += vq->num_buffers; + count += q_num_bufs; } count = min_t(__u32, VID_MEM_LIMIT / pix->sizeimage, count); if (*nplanes) - *nbuffers = (count < vq->num_buffers) ? 0 : - count - vq->num_buffers; + *nbuffers = (count < q_num_bufs) ? 0 : + count - q_num_bufs; else *nbuffers = count; From patchwork Thu Oct 12 11:46: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: 151977 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1165734vqb; Thu, 12 Oct 2023 04:49:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFQYo9sZUk/uk3/SSdC+paeiScOw5s5Dz7z/diT4c5xxghgbQwE4OoHRS7O88/a1SQTRXM5 X-Received: by 2002:a17:902:d352:b0:1c9:e121:ccc1 with SMTP id l18-20020a170902d35200b001c9e121ccc1mr1242955plk.5.1697111372603; Thu, 12 Oct 2023 04:49:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111372; cv=none; d=google.com; s=arc-20160816; b=isWHiM4QiVPf5kW8ZXu8KUiBEMq1k1OsgmeoF0JBq07bG5ZO2CrDf0jkF9cocb2w36 9a+oxY/osfQgq7WHLLPQiOCYS5np0BUOa9ARNa1zDlDkR0TVRmy3BPSYi9M/R6tSTLlC qyYeNr0F/kHgC3RFoIBhRcfWf0Hesdb0Szw77nwyzBrAxQRIG5YPuRn2+CMETwKdY6zl lCWPtf5UfNedgxu/WSWnv2pjyFaRQgNQZGptCe+s/jk9hDJ2CmFThrhhtZLhTCFPQwLf Ha1BxIMZruA8u/hZ2UwUUBPcbcnKWNtWf0eJcbRUQzolTiJ1E9eporQ5lwXV7+VjdaOn Be/A== 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=vErr4M751FH+ODJS8LWDgvO67SFFTD8IDaC6t+0qq54=; fh=htjdJE4hfcTI3Ydhhcx4l9rF1suJMuuEBK7FcgcRZDc=; b=Vgo/2t2K8TByEdai1vSt7t5p7nc7k6Ex52ZISx8CE8IKwON/9XybqBC2i2trqLwYr0 oU424kizFcR+jD1nzPvuuycl529dpwOroCDiJs/kFYSnfghOqiTVFIcGkoFCU3MC4idA CAtH+DgwHkfnLLwvb8vHytyy2hR4Be0sMwzctd+kN4zSlVcRxrm4EXjfQBZKRQutN/cI ysm8iHtpZLcAYjb7hARGpVBMrP42pgZ2KgvXxnp+DnCqi/fUcGd9GHDa0StIOqin2NRm NvCUfkiZMi19ic78cHTz8PJHmXdEGunqSNWwdjoHwAqqqcZ3RzL8ocAY1Y/deT9AunBA qBMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Sh+tqfZv; 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 11-20020a170902c14b00b001b9c1821f6bsi1937344plj.98.2023.10.12.04.49.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:49:32 -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=Sh+tqfZv; 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 82B3A822CBFF; Thu, 12 Oct 2023 04:49:31 -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 S1347208AbjJLLtZ (ORCPT + 19 others); Thu, 12 Oct 2023 07:49:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378901AbjJLLr1 (ORCPT ); Thu, 12 Oct 2023 07:47: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 CF5A31B4; Thu, 12 Oct 2023 04:47:11 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 9B8D46607396; Thu, 12 Oct 2023 12:47:09 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111230; bh=4MapzpufjNHuzajAFVNf3Saky5QdXUM7N6XKbxHUF6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sh+tqfZvlHLp4RcvFAWI9TPHsUUEe9c1wixy4BO4yMO0hJozj9bOKsGSQXh+OnQiy 5CPc19t4mO5swR+xnWDjpmM32c6UBTZz6g//8saMQp2jo0TZj+I7oEw48/qMKt8FCA pcKP9rxYxYnHHj9AMBjY9ZocwGS/unlkoipm31of+R3Q8+UGxzqL1Ghp69eU/rnaji rA2tYjRUuLXSF1LwrdW1wUi1RWQ++arkhFytt58RWW4g68M4Js1ItAiRXJFs2JTR2R KRKtQRfqgm2dxgfUiLRMWylUMPIw72uCrBgb9GmctInuNi03HsKZpDLP07Gh49YQ+W W6UQ0TZ8ypBRg== 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 , Neil Armstrong Subject: [PATCH v11 38/56] media: meson: vdec: Stop direct calls to queue num_buffers field Date: Thu, 12 Oct 2023 13:46:24 +0200 Message-Id: <20231012114642.19040-39-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:49:31 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550254545801099 X-GMAIL-MSGID: 1779550254545801099 Use vb2_get_num_buffers() to avoid using queue num_buffers field directly. Signed-off-by: Benjamin Gaignard CC: Neil Armstrong --- drivers/staging/media/meson/vdec/vdec.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/media/meson/vdec/vdec.c b/drivers/staging/media/meson/vdec/vdec.c index 219185aaa588..1e2369f104c8 100644 --- a/drivers/staging/media/meson/vdec/vdec.c +++ b/drivers/staging/media/meson/vdec/vdec.c @@ -167,22 +167,23 @@ static void process_num_buffers(struct vb2_queue *q, bool is_reqbufs) { const struct amvdec_format *fmt_out = sess->fmt_out; - unsigned int buffers_total = q->num_buffers + *num_buffers; + unsigned int q_num_bufs = vb2_get_num_buffers(q); + unsigned int buffers_total = q_num_bufs + *num_buffers; u32 min_buf_capture = v4l2_ctrl_g_ctrl(sess->ctrl_min_buf_capture); - if (q->num_buffers + *num_buffers < min_buf_capture) - *num_buffers = min_buf_capture - q->num_buffers; + if (q_num_bufs + *num_buffers < min_buf_capture) + *num_buffers = min_buf_capture - q_num_bufs; if (is_reqbufs && buffers_total < fmt_out->min_buffers) - *num_buffers = fmt_out->min_buffers - q->num_buffers; + *num_buffers = fmt_out->min_buffers - q_num_bufs; if (buffers_total > fmt_out->max_buffers) - *num_buffers = fmt_out->max_buffers - q->num_buffers; + *num_buffers = fmt_out->max_buffers - q_num_bufs; /* We need to program the complete CAPTURE buffer list * in registers during start_streaming, and the firmwares * are free to choose any of them to write frames to. As such, * we need all of them to be queued into the driver */ - sess->num_dst_bufs = q->num_buffers + *num_buffers; + sess->num_dst_bufs = q_num_bufs + *num_buffers; q->min_buffers_needed = max(fmt_out->min_buffers, sess->num_dst_bufs); } From patchwork Thu Oct 12 11:46: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: 151978 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1165781vqb; Thu, 12 Oct 2023 04:49:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHuTsXOgKq4SkovYVgnAZmtsh+SE5ZY8deEJWx9HN83XDQbZxxyaKieyftyKs5Zk2/XNBpj X-Received: by 2002:a05:6870:2e09:b0:1e9:95c8:e15d with SMTP id oi9-20020a0568702e0900b001e995c8e15dmr4617265oab.1.1697111377628; Thu, 12 Oct 2023 04:49:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111377; cv=none; d=google.com; s=arc-20160816; b=w7+7oo4kVI3/Xro5FZBzRZhfy3Sqao/iLMOgEoMy/hjeSWQRZSzhd6YW90ULZ2lR5X DA6KGCJT4u2AsVrMNssJ7N0G4P+/ms7lVzerxEC+Es/cTRDNrR3L1Za+tL5s1eLHMqiX op1HAOC82NlkT+l8d1lTZq3hx97ih8BAC3P43Ujyw/TdvSgiVXE92NAqPvjm6LrK0T2Z bXRIGyWvKNfKiYQgAiB8QQ9tVWphcBIM6yM1mC4kQKrKP7yHdFlgkJD0XflUIfYtcmA4 x3ZnKn4JaOw6XPagHf5HKyynweXojS/zavIVSAIMT9QC0eDCjsMfdRp+sWO970DxrPNJ 2F1A== 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=ei78TxWOcTSjoFVP8g+Q8911l0kULI5hASOKgXFSt0A=; fh=QEr6LkXZ0b5ECaCCGx2MOhsbOAaVsr2qEDjA2CECWis=; b=B9XxkxBabvAR5Z2yjkOkmkDocI8RWPa771TYqT66ea//35VhYiuSB9jWYjbD6bRl5e k4HeOfJtpwP3reWis1rHvzepvGleljBoxJxXTboz9SoRR54ZPL60c7wbEi1ahVKAarz8 9fgau3QnOSTVbYmwbA9Rtc1oD6+qRv6Z4B9FAea4zpAoZxg4tS8tS+YOS3x2EElJuDNE hsELdAocD0HjPzqp/b5meTQSNLptADKkrUofat4qFkp0j8IHyV3KxFiG4Se79fZY5sG1 xTUV+rlkp8nlpzRQuiaHdJBQD8RaNFJL2cp+SbOQQG/FY1mrSrLJNNSIl5Z1occ+I3ee KHiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=JDqtYrts; 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 c5-20020a6566c5000000b0058543c16567si2039936pgw.459.2023.10.12.04.49.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:49:37 -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=JDqtYrts; 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 E84D3822CEDB; Thu, 12 Oct 2023 04:49:36 -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 S1378390AbjJLLtb (ORCPT + 19 others); Thu, 12 Oct 2023 07:49:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378431AbjJLLrd (ORCPT ); Thu, 12 Oct 2023 07:47:33 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B35CD8; Thu, 12 Oct 2023 04:47:12 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 25CF06607374; Thu, 12 Oct 2023 12:47:10 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111230; bh=2ob6WtKtRZ9d5xOWNbdQXjkC4MZ/+NminFNhqg2q8Mo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JDqtYrtskHtqMoqYnBQk0pM4DnGyCO0oy5ec6FPZ7sNGN7fnhoDcH1rfICDYl0CQR dKdZjf2SIjjt+pKu4gCeXXs+F/ZWtj/dPxGa+AHtoAipbAYBJliSL3+3H+undGUYzm BtXwqOlkniaaehIuKp0NBIj4hcDDqS4Zmz6Wxd/azcGzmNKTcf3ET2qiKi3I87XOmr mPw5ipD+zjXqg3cWrJlxnkR64AZ4UUyoZq15BmMfeSRITjb6cY58PDCFI80FgYQLVH 0a7qcPxP18972eMvvqIoc2nLNBxwHRgjB9RB/OAArsO86IcXoQNE0xymqA3QZ8Cl0B HsF40gcYL9xjQ== 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 , Dmitry Torokhov , Henrik Rydberg Subject: [PATCH v11 39/56] touchscreen: sur40: Stop direct calls to queue num_buffers field Date: Thu, 12 Oct 2023 13:46:25 +0200 Message-Id: <20231012114642.19040-40-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:49:36 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550260136847551 X-GMAIL-MSGID: 1779550260136847551 Use vb2_get_num_buffers() to avoid using queue num_buffers field directly. Signed-off-by: Benjamin Gaignard CC: Dmitry Torokhov CC: Henrik Rydberg --- 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 Thu Oct 12 11:46: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: 151979 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1165792vqb; Thu, 12 Oct 2023 04:49:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFNc5i2y94+t3WeQJ40ZURkHyD5mIojrK61UXr9j3hcu9jyVC5ezRjLo1IAFvQn8Eun8Dsn X-Received: by 2002:a05:6e02:60a:b0:34f:7ba2:50e8 with SMTP id t10-20020a056e02060a00b0034f7ba250e8mr23509334ils.2.1697111378863; Thu, 12 Oct 2023 04:49:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111378; cv=none; d=google.com; s=arc-20160816; b=y0QHb7ZnjM+dX76FOWfr5TDvMtHpa3oF4jHBhW5WhBhHBWJw4Grotrnify5ELVaYEN KJiWXkVs8yUmp+DbYGrv3LywjjLmqRQiFfRA/o5q/ZUYj05+E1NNnFD9p1PQS5cY0AsJ 10GAquND+3AK8sifSDVl8GIaU4QIie1OLhCNg/tmRkxGv5RZhis5NBHZgHGX54PON+tS UPs8anuJTUpK+q3QCNlVJ13gZl//39TDY0QGNdc26wYGb5tG8SSuqPhj0Xi8GDCvTz4j /hyN81yVzFQqxM4p9Al0kqoH30vsWtshXN/acl2iuIKPvI71yVQRz1CKvohtCrzHFeY0 JcuA== 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=Xf31QwFLsCEF5ovLq68iRVG7AVmgDQSp62r8/rHxnNfeKvbJ9Kyv+h1237o93lyzFW qHoZRmXvd098qskTdtD3DCvpreAyJyyfwnQyx7DmMxo0P0MQQ93ujuBRc7b/xbVwTcUu lIFY0ZUAaIC+bPHLHnHrqK5R+iw+KSFNHw81OqUWVsVDvrk0V+h2oosatlUIRZRHQjLK QB1/zTS3KqWl1X2fmZL1HWCX45bAUzp367QhjRnfcpyFDy9Z0Ph7IHbMUaZDbbOFiSaf jizjMmmdmCEaLO6Hk5+g2tM0DtBQzhc3GE8pp83M4SP4k7GgA2/diB/+aThPiRCiaP0X NJIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Z4bQsHlw; 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 131-20020a630289000000b0055785a37147si2042490pgc.590.2023.10.12.04.49.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:49: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=Z4bQsHlw; 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 16938822CECD; Thu, 12 Oct 2023 04:49:38 -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 S1379265AbjJLLtg (ORCPT + 19 others); Thu, 12 Oct 2023 07:49:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378970AbjJLLre (ORCPT ); Thu, 12 Oct 2023 07:47:34 -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 7C679DB; Thu, 12 Oct 2023 04:47:12 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 AE3C8660739A; Thu, 12 Oct 2023 12:47:10 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111231; bh=ph7BpDmTndhVgQkibEyHEMgMXbFU1u8TVxC65OSPSxg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z4bQsHlwdarOoSvvE0kmFcZznJwFUJhIuX+KgZunxJkgDfXOPlDHVX44ksW3y/PI2 C4TXV6ACmIscGmOvecjSzPEufYgt1c8VGw/s2WirKIlFqriJQ7bzTQ5G8fGOJoBK9o h2mLve2mjj6ddLPZVv+RdsNvkMnkAJPH3k6oEkIcG8t6v2HCLxDhiTTQs/i9l2CXRH guf506zU5PWhuvJvMAxLFzykRNfboNOq5eLathYpb8LGwtXShfDfmkYocbKwBqE/3t A8t1emGuE7C+0aWB0uFvTHpebv/iRK+6cy5YQqw2x3GYg7rcG0AsY8wMJhJMMZGqgJ Gp49iEjaDVjIQ== 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 v11 40/56] sample: v4l: Stop direct calls to queue num_buffers field Date: Thu, 12 Oct 2023 13:46:26 +0200 Message-Id: <20231012114642.19040-41-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:49:38 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550260867119724 X-GMAIL-MSGID: 1779550260867119724 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 Thu Oct 12 11:46: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: 151986 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1166556vqb; Thu, 12 Oct 2023 04:51:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGJJ+otbf/WjtPCLY9RYXDaA+md1ua7tVw4dfaO1BCUNNiSjr+PnIdwm/7/eQuOb31okDPA X-Received: by 2002:a17:902:dac8:b0:1bf:1a9e:85f7 with SMTP id q8-20020a170902dac800b001bf1a9e85f7mr27100121plx.1.1697111479391; Thu, 12 Oct 2023 04:51:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111479; cv=none; d=google.com; s=arc-20160816; b=ZdQoJf/exzXFoofYjQIyZyZTVrYr25GsDYkhJzqn6jdCod2A2H3/6R986Tph+WEkgc 9B6KXXkMExDLh2pvfNuwyrzMWF67DJvjm8rKiMMzPa/QaljdaTMUVRALZ7+Y1NLgnb7E cLYmM/+y8oqrMEyCMdv50HoXD6A5CuzzVpcwQ18UxXMZ8nlISr2QHTXkHJngobLDaRVh 4XYndgflSni9jIZnSKhHV7eSgUOoQRY8pQewaw9yttMzMg9FLrwMPxB9LsRAZ9Tjql+q +PPrcY7pl88HNEUSaMOzQiJiwDjFuoyg/+dXJEQCC9HkIu5HSKCHzrPlZe8ekx+rw/os 3WvA== 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=362WKbueytuHEGcwCkpvyPQdlAvKGzTlZTHPMJDeEK0=; fh=XOQPNehgv2/6iNwDVzIYzJa3sauUpivvTAZ7odRKM4M=; b=lWooesvFDZPhR2iO6DlPx1+g6pjRogI0BZgvfxQqnC4n9eASB0tiU6in273zQN73Vx 7uaDvglLGLtHyulma9+PgBxfNYEbz+PqbpHGS/Nm0PhjsvK/uF/gR/i3L+ug6a9gfsyT H310LBrN/Ay8qnfkWhDG+wE77AshJsQpAH6SLys5p6P+mIX1X8yJ4OiMj/d9CBMjbaXM k7mZveJO6zVMS69FYt7dUaBZcsGD9h5ln2d1Az+d4MU3fe5EcIgpwkIhryWaAp03kOJJ bedv8EevxCnQiI1gJeELA+nndi+sOQjK0IyBTdzF1XjTLv5Fyk9O/AyNsEzIQmufApww 2GPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=hUw3QnNY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id i18-20020a17090332d200b001c35cccca33si2149279plr.448.2023.10.12.04.51.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:51:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=hUw3QnNY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 5908D83741F0; Thu, 12 Oct 2023 04:50:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343857AbjJLLtn (ORCPT + 19 others); Thu, 12 Oct 2023 07:49:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378958AbjJLLrd (ORCPT ); Thu, 12 Oct 2023 07:47:33 -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 ED766C4; Thu, 12 Oct 2023 04:47:12 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 3B5AF660739E; Thu, 12 Oct 2023 12:47:11 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111231; bh=jcGjQtwVZXm/63GKjgXKs2SZ3PMRIqgDfC2W6RW1MBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hUw3QnNYwlyaE6Ckbn5bcMVNybTrPj/hvxoTs5pGfX4Izeh0pkb2QsbUu7Z00U1p8 STjuKlaZDCUmdVgjAvhvRznkEjFw7H9wyQntvY1DRS5PoFX+dcnNmhxMGOTwp3vVJO n0Of2tqIBcemUrFFVI48DiTCV4GWOhaDaw5B/X/cdvpS0D+heq3d7J8KCtkOQXnyQ1 Zpzej9wBc9pRO1+IcVcTsEStnucuC4XzCaQk8NEztBe2Q0ERVYTy2zgI1tSFk7kSNh iVBni6QZL+lAampGQ5FHe8K/+VR2irTZeC7ss110pUnWh06FP0Zvld+5wFYPvmkcLV 5SMLdxzTHP0JQ== 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 , Maxime Ripard , Paul Kocialkowski Subject: [PATCH v11 41/56] media: cedrus: Stop direct calls to queue num_buffers field Date: Thu, 12 Oct 2023 13:46:27 +0200 Message-Id: <20231012114642.19040-42-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:50:17 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550366644130747 X-GMAIL-MSGID: 1779550366644130747 Use vb2_get_num_buffers() and queue max_num_buffers field to avoid using queue num_buffer field directly. Signed-off-by: Benjamin Gaignard CC: Maxime Ripard CC: Paul Kocialkowski Acked-by: Paul Kocialkowski --- 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..95e490532a87 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 < vb2_get_num_buffers(vq); 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..52e94c8f2f01 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 < vb2_get_num_buffers(vq); 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 Thu Oct 12 11:46: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: 151991 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1166735vqb; Thu, 12 Oct 2023 04:51:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvHCWmjOrD9Dityhh5fnqvGM1rQ7i9cDiPNLvJKYPKBAmNZ49o0KMAaVfeCctpJKBwzmXE X-Received: by 2002:a05:6a00:1d22:b0:693:38c5:4d6d with SMTP id a34-20020a056a001d2200b0069338c54d6dmr26416641pfx.2.1697111504141; Thu, 12 Oct 2023 04:51:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111504; cv=none; d=google.com; s=arc-20160816; b=VHJzMzULP9Dt0jR2aQpxLxmk+3nQ8mhauMMNVJC+lVe+jXg24lA6hB3hVPnvBp0VNZ NHcW/e8vdjB26bVzhhWlXKrJLiXSa1yHxxGcIJCgmjTl67tNRlRuUGxnXP8rkal2BZSn +Ktz45EGo5ykcNAJpB4J+IyGZ7S3PTaplfO9K1BsCCBK9NaeZkBFytofWESQ9dmMV/7i PBXQUUgzQ0bneKTTn+SYNSg5lcmMADrDs/fOHDprI9oE5MD9YEyV5Q2KaduMUZFXxAuS AOVcCaXfYQRfpMf32B84Zs0Tim/ciDEYQ6Mh6GdC4R1zoQyyFLFr2Cw1b3DEAOERKAGH LL+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=HUGdxYhOAn1TeNjwpyRJvPl+LJMl1y9M+zopjIghSVc=; fh=zA4Ea09BAmiDPPjR+uJVAnHTWLSizmgLd0oTzclis+o=; b=B6YCZoqx2/Oatir1SpWF3LL9gE/3mvbVjq1BkfY4Bt3wBGd1YYt7Jncep0ICMec98F wg1qMq5mqOUb6yA09nnZjeHkBEdsvXIQrVTa+4UbHMbyGJZDuEtOHOowgUk0l5bkhvkU UexCJCr8uum810m/Fw9wYURwR+cwQjv+tLfglwShrEMg3ekopx3E+Z01uzo7jTYiAvtX 2PsJXKe9wpSt9Al5X0IcPk0OE+/qTJs4ypLZDD+oOEyvfFEHndy8m2BMOiw0MflktYJA VzdfAVLynxzE+acUNRXJ46WfNQmptFTka0VrQigLFHSj9kuiSZd+eV58GsVqQgde6sD5 liUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=S+BZk8df; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id y4-20020a056a00180400b0069026254582si14866244pfa.98.2023.10.12.04.51.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:51:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=S+BZk8df; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 1338A8379A5A; Thu, 12 Oct 2023 04:51:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378422AbjJLLti (ORCPT + 19 others); Thu, 12 Oct 2023 07:49:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378972AbjJLLre (ORCPT ); Thu, 12 Oct 2023 07:47:34 -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 85996FD; Thu, 12 Oct 2023 04:47:13 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 C84C76607359; Thu, 12 Oct 2023 12:47:11 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111232; bh=wcmCqoCWnm3znNuFzs/XictU3y+G/8bndqFUAwDdrfY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S+BZk8dfAmvxBWrALG+owBFsVHdcRGqSqKhhr4l8ZcJp1jy3j5/ZUKIYroVNVwzsn z6kFVAryYiu2EaQruCBoWMD/SXFWFOe+UF7YIFFpYcOvXG/J+EVxYBDWqZa6s/SqaZ 5N1MiXSV2PftsdU2s4KSkEMyYl0duJe+XP1UPfAEbCpgMtaAyBjc6geM9EXLXv3cG8 ctfEu1WgQnSoqB1xwPGB38DJlzFQCDU+vqEjlp6ah4bmHnL/731BtJXW3ejCsSHJpe ACerqsYA6wOyCobEUO9Bahwe20vDZRLw4BSojKNI3EeWt1ks1PWi2neOlITQ9FLDuV 3zSWibJQbL9kA== 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 , Joseph Liu , Marvin Lin Subject: [PATCH v11 42/56] media: nuvoton: Stop direct calls to queue num_buffers field Date: Thu, 12 Oct 2023 13:46:28 +0200 Message-Id: <20231012114642.19040-43-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:51:31 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550392720040230 X-GMAIL-MSGID: 1779550392720040230 Use vb2_get_num_buffers() to avoid using queue num_buffers field directly. Signed-off-by: Benjamin Gaignard CC: Joseph Liu CC: Marvin Lin --- 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 b9e6782f59b4..f9b4e36a5175 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 Thu Oct 12 11:46: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: 151984 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1166430vqb; Thu, 12 Oct 2023 04:51:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGMOyby8V5bVdRtB5RQJU2IQyA/qkJFFUWy6xqAP5wkTVhmGA209lVnEJZIRdFqE7T3lQ5W X-Received: by 2002:a05:6870:f141:b0:1d5:f814:56a3 with SMTP id l1-20020a056870f14100b001d5f81456a3mr25385364oac.2.1697111464050; Thu, 12 Oct 2023 04:51:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111464; cv=none; d=google.com; s=arc-20160816; b=MwSCQjCwa2T/6DvAuyqf9ry1r9KrME0ulNTyzL5KzeRb/Jy+wl4xQVv8AyX2wOnuUg rMYj3b1hM6UNanUZTB70rzgRJi0PIdjesQuz86DHSO6I/oWySeuhzoYHGUQ0tpwv1FTm 6gCuYtQ6j9rVjvtypb+4eUrHGHvhk0qPLSXCBnoylFiQS7eH4JwbijLxltCDULRAT48I iTf55kLc+C56aCCOjwshas5SW6vV50l3sDPvj+z5dMNHyyWCmhT6tgKHb9Tqc9HQXnhs Rf7AFynuElS5NmGi5vNXh6HN3Aw9e8yTftomY+VPSWQJ3ctbNq6AsS13PybojCW5YylX k++A== 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=+6AQJdoJymSQPIJPeLIZhS5Da8mVY4uUsDlorekNog0=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=t1hD4kHh9HvgiAhZztDfBhy/yEPxjyVf287PkTTCJhXM6CicTXWkGPBt0v84/cDm+Z oPIpTIjntUJ+mgzsay2/qUEFOztOw1T77f2iWp9lQ1a40kSQ72bWj1+k27pAOV/1YBNo GdtitgMSpxzNrkCjM7GrRuv20c7m+89uc1AJruApBIyWTehn5oLcFttzCqLBa4WHQv8q vpq/bUMKIk64SoULLoRshA+D0WG/91K5pSlAHw+uZ7Jniy373EjG1TnGGnsBd2hlSbj2 Ed58nI+yGXAom56ITETVJdPpiu6tmO7J5ULn1tVxgJpuiwzcMGgbTRM9UEi1Qmmty6ex 2ODg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=eatUFjva; 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 k62-20020a638441000000b00577dd005706si2064157pgd.779.2023.10.12.04.51.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:51:04 -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=eatUFjva; 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 0540980763F9; Thu, 12 Oct 2023 04:50:46 -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 S1378954AbjJLLtv (ORCPT + 19 others); Thu, 12 Oct 2023 07:49:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379085AbjJLLrn (ORCPT ); Thu, 12 Oct 2023 07:47:43 -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 4A4D5103; Thu, 12 Oct 2023 04:47:15 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 5C17D66073A4; Thu, 12 Oct 2023 12:47:12 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111232; bh=vjPlxkR5vfp85IcfERMf2VqRMRXq6z9BgSmaLDpPk60=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eatUFjvaiC2/OpisiyK7mDbBxmvYE4JKOxYGmseuAO5Rz0FXXXzvNpFIx1Oztj/jP PstiZt0pF1Js5SoQMwGeBoT2mUJmloXN99RnDguPwiLuFFvjWL3TY1tTKvRiXCwYWC +VVnnTR9kUiCxI2gNdOtzdDnAcqwAVdyZxJKZ8IL8e2bkEQxR9nYA8t0wD2KfWtNmJ 9dQvN79WHcTdGfdWfRpgd3BtAjvWuABsfkCoRI84hqQcJoEXzoXDvOSvmCjX1vRcyE yINnvxWPVGRD340/I1OEvt3izII7Ut/33sQxaNN/0getWPc1vQPdlxoj6OImEfT8P5 i/XK8a4cbbxLQ== 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 v11 43/56] media: videobuf2: Be more flexible on the number of queue stored buffers Date: Thu, 12 Oct 2023 13:46:29 +0200 Message-Id: <20231012114642.19040-44-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 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]); Thu, 12 Oct 2023 04:50:47 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550350876395106 X-GMAIL-MSGID: 1779550350876395106 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 | 42 ++++++++++++++----- .../media/common/videobuf2/videobuf2-v4l2.c | 6 +-- include/media/videobuf2-core.h | 4 +- 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index c427aca285e3..eff4fe9c6f63 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -416,7 +416,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; @@ -450,9 +450,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 */ @@ -816,7 +816,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"); @@ -860,17 +860,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); /* @@ -979,7 +984,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, bool no_previous_buffers = !q_num_bufs; int ret = 0; - if (q_num_bufs == VB2_MAX_FRAME) { + if (q->num_buffers == q->max_num_buffers) { dprintk(q, 1, "maximum number of buffers already allocated\n"); return -ENOBUFS; } @@ -996,7 +1001,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 { @@ -1008,7 +1019,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_bufs); + num_buffers = min(*count, q->max_num_buffers - q_num_bufs); if (requested_planes && requested_sizes) { num_planes = requested_planes; @@ -2466,6 +2477,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) || @@ -2475,6 +2492,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; @@ -2520,8 +2541,9 @@ 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, vb2_get_num_buffers(q)); - q->num_buffers = 0; + __vb2_queue_free(q, q->max_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 daa07f62c219..799dd43b4aa9 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 < vb2_get_num_buffers(q); i++) { + for (i = 0; i < q->max_num_buffers; i++) { vb2 = vb2_get_buffer(q, i); if (!vb2) @@ -1143,7 +1143,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; } @@ -1271,7 +1271,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 8f9d9e4af5b1..cf276bda5924 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 Thu Oct 12 11:46: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: 151989 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1166569vqb; Thu, 12 Oct 2023 04:51:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE+z8mNwsedNQWOJ+YCxR4/T5F3HaXt0o+zzUWRbZ4OGEHyWhzskFmPKOsXuL1GDpahGtT/ X-Received: by 2002:a05:6870:2e09:b0:1e9:95c8:e15d with SMTP id oi9-20020a0568702e0900b001e995c8e15dmr4620897oab.1.1697111481355; Thu, 12 Oct 2023 04:51:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111481; cv=none; d=google.com; s=arc-20160816; b=V65d/KtijFJqebDr09eIABb+3sSeXm/DnwQiz/ihwek0ZHpHPCq+wn2SOTrVzqxSrs vJTn4GjmkHGIsSEYG3d2L0jo7AF70dEJsoa4ALzC67jt9y2e/DqFrJoRM+eFrzLCnR93 aYvZgkDvR+ldcEZN29xCycTTqXROmmO6OlWzMehS/TC/KGshgscsbOelWssyJVi2W/kc vVkB3tto8kRQH5QcObBatnJ0ChKsn9PxPZ8ZMmbmYGyxqargFMlcA4nqI7Yxd7na9lwV oB3LwHzTLbM4bdzbc4MxaAp8uSNCLDlm89QEM0+brhV7jeAc5tD0Ani0Z58f3hG3zW8G U50A== 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=MnUIrRqvXMKh/s3v2HoJ8Q8AK378I4mYSsFgKAF3+0E=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=NOd5pwO4rQ5z2ROwoPzhFYOIkn+Y8yOoyoUYmM3Zd3/aSsdjjV67HPoJtrtX/pmiOC fnY9wSCSME9sjSsOjCts3X11gglah7SHTBx/Pv3AU0jvx5OiwfBaDpI/LTPOU+zW4HKc uXP8/NB88S2DV8YRgMcM1FKiLUNQu6mznrs+hj9LTQi+evkJ3HAYOwC50ygiCe9Tr8DB cIOnut2jXKpKtMo3/XCnxlz8kbSsJ3/4/4fSIkqUh+mjhGAsboRmtOrQB310fQJ5N6so fqIGzPSPiUkLbj5GkncpI55U0YfCwEP2epALx2Iz3nEhXWUdyyQROOfKmTNRYzPwkTGp eYhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="jaN/azBf"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id x6-20020a63fe46000000b0059f0cebd054si2082782pgj.731.2023.10.12.04.51.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:51:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="jaN/azBf"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 40E6B807C659; Thu, 12 Oct 2023 04:50:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379018AbjJLLt6 (ORCPT + 19 others); Thu, 12 Oct 2023 07:49:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379132AbjJLLrr (ORCPT ); Thu, 12 Oct 2023 07:47: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 C4B5210D; Thu, 12 Oct 2023 04:47:15 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 DC2826607376; Thu, 12 Oct 2023 12:47:12 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111233; bh=kF1XywfJ//tAnpFwDZ97rkGG/GHsd3LtG8inxD4wD3s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jaN/azBfmskK1pqZvObdELo9f8Rc+xOkNVutqdlSuNJXjLDYGkWNdeOK1RnErJ+0N ENou5PU+AP0ugJLUwFx6WUod+ZlxGkDnYQYVymXlNODc6VsspMUD2GUaoxZBiKqomQ Yy4mhOB2NxyOLqF0AaPLcWrg1kJbuR4q1PKN0gjeDEMef60+e3X49wSnM8DOvAcxUE d9Fokt3oFUKxtJ+U8+gev76zGuiyXnefQGDvf4UaYwCVP2VerumjFjJSh/o7EDdYez TAyNz2fyI96wMKecBvpftNEs3MVCBt35QnMTZCsaHC/b2AMXOMHPEJuU5E2EOj83rw eMo8TBzAzsXTA== 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 v11 44/56] media: core: Report the maximum possible number of buffers for the queue Date: Thu, 12 Oct 2023 13:46:30 +0200 Message-Id: <20231012114642.19040-45-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:50:55 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550368618690290 X-GMAIL-MSGID: 1779550368618690290 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 # Conflicts: # drivers/media/common/videobuf2/videobuf2-v4l2.c --- .../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 | 2 ++ drivers/media/v4l2-core/v4l2-ioctl.c | 4 ++-- include/uapi/linux/videodev2.h | 7 ++++++- 5 files changed, 17 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 799dd43b4aa9..5f4ea4485223 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -681,6 +681,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) @@ -763,6 +764,7 @@ int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create) fill_buf_caps(q, &create->capabilities); validate_memory_flags(q, create->memory, &create->flags); create->index = vb2_get_num_buffers(q); + create->max_buffers = q->max_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 Thu Oct 12 11:46: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: 151998 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1166984vqb; Thu, 12 Oct 2023 04:52:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFhNRpFHYNehbw0vJEbq4bsRZ0Qyunbhv4GckoOBx7rnPl+BXAYCWdczKK1OyxgFdsWU7z+ X-Received: by 2002:a05:6358:2d94:b0:163:e0a:68a4 with SMTP id m20-20020a0563582d9400b001630e0a68a4mr17081160rwn.2.1697111534784; Thu, 12 Oct 2023 04:52:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111534; cv=none; d=google.com; s=arc-20160816; b=0X5c0GcML+7isJA87l+pdaJRA7YRo1EV3mhREIeGFDyvlxZLNg2rL3ZcfitFGfstU7 3OSQ6Xn3tnEWba3IIC7Mrs7UP9jYzkyiz+TpCXokP3i0+gTtDDJpbHcybkHT5Ef/MBwc 1HZ3XYB9Ew0GiPOpSnlM+NE5nMIBAQztHX12jDK18pDd1uj5nnj6Ly36G6JLRMe9qBQ6 TXFu2n+QCBicOLDjaBKu8oEgjdarO4FnUhza52tXqaZ8IJd/2AezQ/da1SWKiK03H0t5 RJvjt4snpasimkKmRYcwRLQVRtY9FmnBerRife4ygvsSWxgXKd9JPFUok1VxUULW763O P74w== 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=TgDqT0U/P7qCJOhBJj//YzMGbeCETw4h1oj5utyThnVS0OG5jhsZoVPNpsTOOO6wXZ GLcUI5yb21o/Hk/ORuUPjZDi0NY/0G0RRlb1M1kdfzydhNASRiIOm6Twhl6fqRKLNMR0 kXDfh6dDfW07++YX9h/JD4L6KFySWgUdVPrLgW2iMfjp/gS1TwQufNCAlYw1U6D4rUA4 ttvVMugQ6yRo3pLAiVdZkzvtM8k0icOSO1ri8sirZuVoRCqd1L2IdQjra6jQBucMASWY 0Y64mOM280Txvvn5n2LepqKwvxOF0qCWjeveP8TZZz16RVCzlrunhitS1FKuEZQMNd8J hl4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=WAouVKN3; 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 d129-20020a633687000000b00588e13f4cc8si2046517pga.519.2023.10.12.04.52.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:52:14 -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=WAouVKN3; 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 492D18028B72; Thu, 12 Oct 2023 04:51:27 -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 S1379351AbjJLLtr (ORCPT + 19 others); Thu, 12 Oct 2023 07:49:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378700AbjJLLrl (ORCPT ); Thu, 12 Oct 2023 07:47:41 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E7EE109; Thu, 12 Oct 2023 04:47:15 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 658226607379; Thu, 12 Oct 2023 12:47:13 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111233; bh=MaJc8KF/Sr+P2A1rELzeazrdtI+Dtx39Ekc9mMARKkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WAouVKN3OAalElzf429fDxDA3/X/KhRsnUm3ukPaWmjHHSEZdBhsjtFVUSjP2l+qq 9KVnzkreD84VAAr3Y5CIxt6zyFHRUzEDzGKGlN/gp0fQMumcwtSf4zapr/lo6UeSXv JTU6Sa95+SIAdK6M5QCN2QcYp9WZRb0Zb1/KxrUCH+LJK7Bob798lW8d/G4Ws3fmyR WpB5ztYPv0DJbSY6g3L8H0iPvnA5Fx68im1FbQiqpKf4qsbSfHt/2gSwvzvOdBVR8I T1u46E1GZQikH219t2eYkO71x4a+vgjX50i2G5mhsPk3kOAwOwJLmN2+J6Gvjps//5 9RBi3mbPAHH9g== 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 v11 45/56] media: test-drivers: vivid: Increase max supported buffers for capture queues Date: Thu, 12 Oct 2023 13:46:31 +0200 Message-Id: <20231012114642.19040-46-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 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]); Thu, 12 Oct 2023 04:51:27 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550425005632738 X-GMAIL-MSGID: 1779550425005632738 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 Thu Oct 12 11:46: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: 151990 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1166637vqb; Thu, 12 Oct 2023 04:51:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEUdGEuYNmdPZvIyWDF3vPiekJPLm7LKIOZO4D03vFczCa0w9DS60Zq45dcPBWWoeQiVqT/ X-Received: by 2002:a17:90b:3b50:b0:27d:1593:2b0b with SMTP id ot16-20020a17090b3b5000b0027d15932b0bmr2879068pjb.0.1697111489038; Thu, 12 Oct 2023 04:51:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111489; cv=none; d=google.com; s=arc-20160816; b=QgOwgGHUk5aIM2ZmW2K2z1qrAmoVE3eHw5FTEtweLvQ6K+Nkd5ziuYMonisZ8Eowi6 eW6+vt0thbmn5OdtbbCQiF/Uk63+VK+nB/UHHMRQ5cf0MWhZzFbdcZBF52lF9MqzOZrU 9vkiwb9xy/11aiHVPSAL7DdF9R8SWdCKMznRN0FoSWv4NfMPompMwniEGlR8JZfQU8/y 3LhIcrBPH4rqBJnZ8+/N6eJ3la+i2/o0s2fLVfqmSRxUonSR6lRbR9/iGaG1AN8RZ5UQ AUmDdykk90C9OSMo0C0tSpD5kaYLAZghIl6ppAZTjQduuE6kTAS0BHMUS0dxTgK8k0BO 8+kg== 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=rAJQ03j0818kyCErlpIh7ZcqjeF831UUdlPBXdGu/F45wGoSbgHKMvoqVtUtn1SoUO 2b/3LGWXVyazfGdSWplAaHoOn96ZqFAtT8sNRsnHJrD83PqtxZ5lg3xpthOZV7gaCbmF adVx59Um7uJf2A0dVyDh+vXA90977K4nFlrzRPj/hHI3P1mMaoeInzJiM3FIUjzR+wTO FylzmXTO9VsIjavqGCJ1jPwiMLTBJhOJMYk/s59ajXtdocy2b/0MMiWpxqQIn6DCi95i 3rJLqnQ3MDw/dh+HHeCxZkPfNJ6G4hQWdIua75dFAuhsV3Bp75PN4opRg5xjWWH8mNPQ 7KGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=WWNlOzYe; 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 h1-20020a17090aea8100b00252d84b7af0si2110121pjz.181.2023.10.12.04.51.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:51:29 -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=WWNlOzYe; 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 5F81E80DD36B; Thu, 12 Oct 2023 04:51:09 -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 S1378330AbjJLLty (ORCPT + 19 others); Thu, 12 Oct 2023 07:49:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379127AbjJLLrr (ORCPT ); Thu, 12 Oct 2023 07:47:47 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45DC6D44; Thu, 12 Oct 2023 04:47:15 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 E35066607392; Thu, 12 Oct 2023 12:47:13 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111234; bh=/rw+5kiG9NH9F1WJEwdp/d4z1jjMgH/1J5yw8ccESj4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WWNlOzYeWVdxJz0kJwj+I9ycT6eJ4G22oLnn1DWjjxeeE5QXv7BMcIPaI+vzbcF+G Y0fWXtlK28SSY4yS3dqwpL/uchKuTIK2x0EuV61TnOcc8enduMYwuz9grrAlw/7jXR Fbcz0LZaETZtulmiAmsTum8VlgR7WSK2KEWoQjrIt7+F6pOrIURMbpBVYfj//17SLr Jd74m04DhypvE+IDP5iGI6NNZ6recSZlVUiMR9MFxOkuifg0MkBunJiYPIj75SNtrQ VeBsD6VodeM4CC9jsGV2mFbs3OZAr6FomolF2Fbhx+WaPNDasvVIF2JGK6A3/4F+nF PUe6XzUrtJqBQ== 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 v11 46/56] media: test-drivers: vicodec: Increase max supported capture queue buffers Date: Thu, 12 Oct 2023 13:46:32 +0200 Message-Id: <20231012114642.19040-47-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 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 howler.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 (howler.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:51:09 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550376828244232 X-GMAIL-MSGID: 1779550376828244232 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 Thu Oct 12 11:46: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: 151988 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1166564vqb; Thu, 12 Oct 2023 04:51:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFYyrkMOEESdFv3QWX2mhJJOZcsXXrwPtdSJjKCQbY1w4jwFEdcSHqNTZoTwbczjXfy1YR7 X-Received: by 2002:a05:6a21:a596:b0:163:d382:ba84 with SMTP id gd22-20020a056a21a59600b00163d382ba84mr29311344pzc.5.1697111480561; Thu, 12 Oct 2023 04:51:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111480; cv=none; d=google.com; s=arc-20160816; b=z3sK6tmOa9LGFeyTGGxbrpJNCLiesN1IKFOklcvBlZhN4rvswxCxi75pjMl7hFFXIX Na+vuklTGCDRIblGjPm9oBMdpd01wv7oOBscskpP05rfxK+1t/4ofubIyMEhHmvIKQBp wt/JsGywv/3fZUCbe782L9pK1+hLnCup1XIuU70+irACEqsqqn3oJSq8k1T3hPz7V9wm 5e0sUY2nlB9cIGmvMRpqKOxpEx6qWG8SSxz3cxYgqxXK0JZng5RamrB4b1vOg89wMC/v Tlz+kRL9ARYyeF1n82kZ+GrILrB8IObUOtwUsszE2cY5DehirpINFVIFkixFMAtEwk+4 fHrg== 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=rDZ5S4QbwaTBx24HSBQddHus2mJryWMzPAdt5ItaHrI=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=faGegRfL8sBlfj2Dbx32dHh/0pKZ3AkmckmnyFhkAq9qITUKvxzNlllNHStrlcdT6+ F9mHIhqCurQJ0AJpODDoY54Ma5sEzVJMt4e5OsF+k1bSuOFmF5ZdONhnRIdAru1VGEew A15GhCExuiUVOg4rrY5kL+FUuzF3Q0CO44KWEQ/AuPwazIyulbbKUmIjSfDRerNCewb5 NBnWP1xOdYSOPfpnwhkCjGiQRqIYR7zzRTbRhoYMiNj8BgbqSlhkPD3MRRk3tAPMUEkk MQjXg2eF03dGwWHzO9fhF9tqVEpPnYWRvwX1+4Y53eEQLPXuHSbsflulGOojN2/cgIZW K6tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=JI5FPEIs; 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 5-20020a630c45000000b00578b9d1d118si2049430pgm.219.2023.10.12.04.51.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:51:20 -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=JI5FPEIs; 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 F27E380763F9; Thu, 12 Oct 2023 04:51:04 -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 S1378907AbjJLLuB (ORCPT + 19 others); Thu, 12 Oct 2023 07:50:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379165AbjJLLru (ORCPT ); Thu, 12 Oct 2023 07:47:50 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DF88D49; Thu, 12 Oct 2023 04:47:16 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 757D266073A8; Thu, 12 Oct 2023 12:47:14 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111234; bh=Io9Tjb5cn8uE3Kz5+BqDVsKX8mjkDcVIhuocPLDRTU4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JI5FPEIsBfogZ0o8JozdMKxemBhpxCMhwnmCHQj2B2aqLvhplOTzrr5AICaZmWBp7 vXtPPqTDRS6JZ45VlFweMWIZkMUGKym2es7kCo/n2QDmIqpS8PpkMYvER6jfQgDz9B OgThNzoCSaXqzHojL9JsNOnFn0TInGvnu8LQGB/zidC/fXPAko4P2vUaCc5GJTrTv4 ylTovM2MSpbF16I3mdwp60ek5o7yJGwjloMqCQd0Tj/GpxNrgP4hWzeQiJbAhhAzrZ Lzg1hovFVZzYikNNZUAjXymtDw6IrY57eqkOQOlCYNt8WgPPmOwcvOr5M2vkMXIb2R mCf1DRQhbUmWA== 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 v11 47/56] media: verisilicon: Refactor postprocessor to store more buffers Date: Thu, 12 Oct 2023 13:46:33 +0200 Message-Id: <20231012114642.19040-48-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 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]); Thu, 12 Oct 2023 04:51:05 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550367810176085 X-GMAIL-MSGID: 1779550367810176085 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 CC: Ezequiel Garcia CC: Philipp Zabel --- 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 8f8f17e671ce..41e93176300b 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 = vb2_get_num_buffers(cap_queue); 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 = vb2_get_num_buffers(cap_queue); + unsigned int i; + int ret; + + for (i = 0; i < num_buffers; i++) { + ret = hantro_postproc_alloc(ctx, i); + if (ret) + return ret; } + return 0; } +dma_addr_t +hantro_postproc_get_dec_buf_addr(struct hantro_ctx *ctx, int index) +{ + struct hantro_aux_buf *priv = &ctx->postproc.dec_q[index]; + unsigned int buf_size = hantro_postproc_buffer_size(ctx); + struct hantro_dev *vpu = ctx->dev; + int ret; + + if (priv->size < buf_size && priv->cpu) { + /* buffer is too small, release it */ + dma_free_attrs(vpu->dev, priv->size, priv->cpu, + priv->dma, priv->attrs); + priv->cpu = NULL; + } + + if (!priv->cpu) { + /* buffer not already allocated, try getting a new one */ + ret = hantro_postproc_alloc(ctx, index); + if (ret) + return 0; + } + + if (!priv->cpu) + return 0; + + return priv->dma; +} + static void hantro_postproc_g1_disable(struct hantro_ctx *ctx) { struct hantro_dev *vpu = ctx->dev; diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/media/platform/verisilicon/hantro_v4l2.c index b3ae037a50f6..f0d8b165abcd 100644 --- a/drivers/media/platform/verisilicon/hantro_v4l2.c +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c @@ -933,7 +933,7 @@ static int hantro_start_streaming(struct vb2_queue *q, unsigned int count) } if (hantro_needs_postproc(ctx, ctx->vpu_dst_fmt)) { - ret = hantro_postproc_alloc(ctx); + ret = hantro_postproc_init(ctx); if (ret) goto err_codec_exit; } From patchwork Thu Oct 12 11:46: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: 151997 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1166973vqb; Thu, 12 Oct 2023 04:52:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGhsN8vnsGBAdX9tyykS2RhGM4NetC3NoX5NzXYPWnCf4IyAZVx/3KVgqOuPxt6LXc7PvlE X-Received: by 2002:a05:6808:3008:b0:3ad:af12:2fe0 with SMTP id ay8-20020a056808300800b003adaf122fe0mr27283062oib.3.1697111533679; Thu, 12 Oct 2023 04:52:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111533; cv=none; d=google.com; s=arc-20160816; b=tVoyHqL95DOiM0EYumO90fhngvrWXIjXdhHu3g8kwvOnTabSOICrA6WuDpX0Myz4VZ JtU5Gf5UNe/1TPvEAzdqXh3kFkBIkpNPoEqPZvgfGfMJTeEsFsjVfvHPY1O4WQDJDNtO lYTSQJ9vrXkgaZdwqG4xngSvoLiSE9a5OQXe03bg82Yr9+NhAxwRUxSNf777gAMjRMxo PTTt+YG4w9yGm/iq8u+Y2YvB69w3+wf7b3KbLzyQ+XZQoX16GCDbr6HZCK5x9jXuzfkU bgOwe2e43EF33f2iFG493pNynuD2vrhBWDCDhY3bFWmQJshNCIKiiiRaY/X3gI7zglU+ Ru0A== 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=hQaDgVchBvfZHzmenfrSC7XPkayVYBFGO4QaGIVF8jA=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=g8Jip2N2IaJKTgau677oYCVjekrdnd53yNqr85i0ksiEsSjVQVbBiXx7qITlBUu2ql 3piqDNkXkBdi0ry31+f1zp1Q6yV5DAwOxzcUxyv9EtZWrKUQqUmJn/olYXcC2tquGx7/ Xu1yIjO5zBKq+kbkx6QFoUxMIn2dsu11bGJI4w6YcfGPYb/eJ5dxu3xgu70AJG4YKA5B Arlc5wxdeAFq6rNQ5FuOJFLzTiyPNwxJ80o5KPUtBtSC1r6D/NCK9pSQ6/idW73KNV2r diIpxtLTARHEFoNtLB06dnlYJGekMLMhcttI6PBcRzCU9ftf0GWxcn+oSrvgBcmYOEQC b/Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=LxskuFoi; 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 m5-20020a632605000000b00564a5b8937asi2126602pgm.341.2023.10.12.04.52.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:52:13 -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=LxskuFoi; 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 24DD9825CEC3; Thu, 12 Oct 2023 04:50:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378440AbjJLLuJ (ORCPT + 19 others); Thu, 12 Oct 2023 07:50:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379202AbjJLLrv (ORCPT ); Thu, 12 Oct 2023 07:47:51 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F969D52; Thu, 12 Oct 2023 04:47:17 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 F16D46607352; Thu, 12 Oct 2023 12:47:14 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111235; bh=deJM8nlQ4g4jiYxn4KEycstS3ftyfWcamvuNgnfVl08=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LxskuFoiyHlg/yOqclV5V57RMsK3xXFmov06o3eNQk2ctAaG7dL//VDkBlyVSJ3s8 wlqWAeLMjBHNu4qYLoW5wDUEiSbiM/ZQcz1aM6HbF7puac3rL+FfMIGowfyooptOiu 3g8cPd+dapon69H20xSmcKf1Y98xqkOolYxQYgPW8nvscV56mgqYExWut0IXC9gCrU h1mXfBMWgIX9POmqbyEO/phHn/B2alGqbYFIHWr+x6f9d4tN1x3IHfmqLGaMFXJ37J A+KjbJ/CneOaSvJuI/T+nel8D4PETWChkq5pMDZNwK2tgJoBKgEkU86FAHPl5VeoTe pSf5poroqlsVQ== 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 v11 48/56] media: verisilicon: Store chroma and motion vectors offset Date: Thu, 12 Oct 2023 13:46:34 +0200 Message-Id: <20231012114642.19040-49-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 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]); Thu, 12 Oct 2023 04:50:59 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550423863514670 X-GMAIL-MSGID: 1779550423863514670 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 CC: Ezequiel Garcia CC: Philipp Zabel --- drivers/media/platform/verisilicon/hantro.h | 2 ++ drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro.h b/drivers/media/platform/verisilicon/hantro.h index 0948b04a9f8d..6f5eb975d0e3 100644 --- a/drivers/media/platform/verisilicon/hantro.h +++ b/drivers/media/platform/verisilicon/hantro.h @@ -328,6 +328,8 @@ struct hantro_vp9_decoded_buffer_info { /* Info needed when the decoded frame serves as a reference frame. */ unsigned short width; unsigned short height; + size_t chroma_offset; + size_t mv_offset; u32 bit_depth : 4; }; diff --git a/drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c b/drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c index 6fc4b555517f..6db1c32fce4d 100644 --- a/drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c +++ b/drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c @@ -158,9 +158,11 @@ static void config_output(struct hantro_ctx *ctx, chroma_addr = luma_addr + chroma_offset(ctx, dec_params); hantro_write_addr(ctx->dev, G2_OUT_CHROMA_ADDR, chroma_addr); + dst->vp9.chroma_offset = chroma_offset(ctx, dec_params); mv_addr = luma_addr + mv_offset(ctx, dec_params); hantro_write_addr(ctx->dev, G2_OUT_MV_ADDR, mv_addr); + dst->vp9.mv_offset = mv_offset(ctx, dec_params); } struct hantro_vp9_ref_reg { @@ -195,7 +197,7 @@ static void config_ref(struct hantro_ctx *ctx, luma_addr = hantro_get_dec_buf_addr(ctx, &buf->base.vb.vb2_buf); hantro_write_addr(ctx->dev, ref_reg->y_base, luma_addr); - chroma_addr = luma_addr + chroma_offset(ctx, dec_params); + chroma_addr = luma_addr + buf->vp9.chroma_offset; hantro_write_addr(ctx->dev, ref_reg->c_base, chroma_addr); } @@ -238,7 +240,7 @@ static void config_ref_registers(struct hantro_ctx *ctx, config_ref(ctx, dst, &ref_regs[2], dec_params, dec_params->alt_frame_ts); mv_addr = hantro_get_dec_buf_addr(ctx, &mv_ref->base.vb.vb2_buf) + - mv_offset(ctx, dec_params); + mv_ref->vp9.mv_offset; hantro_write_addr(ctx->dev, G2_REF_MV_ADDR(0), mv_addr); hantro_reg_write(ctx->dev, &vp9_last_sign_bias, From patchwork Thu Oct 12 11:46: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: 151995 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1166897vqb; Thu, 12 Oct 2023 04:52:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHqamPSzrw2LhtMcbaZ5t0swULg2iSIykFO3+hMcbi/sDUgoW/eymr3E2GeYpsRvk9jPRMv X-Received: by 2002:a17:90b:1496:b0:27c:f88f:11a5 with SMTP id js22-20020a17090b149600b0027cf88f11a5mr6142777pjb.2.1697111524734; Thu, 12 Oct 2023 04:52:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111524; cv=none; d=google.com; s=arc-20160816; b=DQe90wJlEwsNT0afGm9tEMEXALSyHoRGsT+msYn+bVCB7aYBt1WzBKVOuH60BhKqiG 2qLt/l5teTh216RRUqe3SpQxuzA1+XWeFQ+DIEb5S/y9+MTc1Tfy37/5vwDPeOhc7cQA 9Ax126wkTZti33vNhdScQB14xM0eWNM64h4EK0jrxn1uPTOkjZ527d7R0LgtnaSFuCiM YL0FtmsnXwFjCUXzagaJfJP+FBTi+jcmeX/JuRpLd71+6CW0hAZM1YJp+kx17TPoZ9Vk cIWw50LBDpZL/vKRNi5ZyNYa8yiIYikjmNnFTWk80bmEwVh2R437JHk9QG1kmyhya6kO ufKg== 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=y6XiV9IcupkbgxABj43VzUXcORfiij1euWrpAY1T0M0=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=pBqUc5VzBdbKOwlbwzvubPkjy1TUpRVvMt1mQxT2h55qNymktGPLPithdzgXs+QXQh WUeV030aYlepPGPemHOvOgVSn+pdNJW4uzugfMQ00hYrjmqEWOd9nJzWzy2RC6b6uF9k eEr/tsjPjDowbCan/gAEpdnCtfUV+dRGvIIUDrFG961A4d1D+7UfIDcJ8Ktq0JqGIzLc ZozRfGnDpenJ5TBlH16urwfZwjdsoTY3vCRVvviiQBhE9GOD/TbACjd8n6zllLXXkzDE ii75ZFpBUy7X93TYO/XVZMXI8SaBg6dSjfbIKVEgKrX/6RnRcCL6rA75PITt1uwHklF5 qFHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=UlrrzfQ0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id 19-20020a631753000000b0056b024a4dd0si2011746pgx.614.2023.10.12.04.52.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:52:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=UlrrzfQ0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 0A0778075145; Thu, 12 Oct 2023 04:51:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379373AbjJLLuM (ORCPT + 19 others); Thu, 12 Oct 2023 07:50:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235694AbjJLLrw (ORCPT ); Thu, 12 Oct 2023 07:47:52 -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 6D7F2D54; Thu, 12 Oct 2023 04:47:17 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 7D11C6607360; Thu, 12 Oct 2023 12:47:15 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111235; bh=rwdI4N/UpNcGmk6GGlucekYnkxJHQ/tXy5HmEK+3+oI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UlrrzfQ0zMY+v1yBY3VcVbIjwc+FWuiuhtxkw+YEZB2jGkJOmT3MAj+7rG39BNWxH Vq86VSYZqCm1Uoxivg7YRvVuut4vCfyWfwwsId0y11/ZYR9gqiS0neAPNJh0o+BaWR 6vl9BWtk/XxU8d9gZIWG4Ey/LElVkL1R6KpRrHmw2NJskKiKcrMZfdDnuWqM27yW06 hUjEMocUkIrCUszZXQelYNAsth3Ev5nolLP9XuHfe5DHAqPsnEv1VbBRL7qc5iky83 eBE++dB7xmgvsd55mPfw3ALrUJFqswWi49gce63oeHCZG+Lh+KhU7jL+SLLpjGwhco CI84EkUVoR/nA== 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 v11 49/56] media: verisilicon: g2: Use common helpers to compute chroma and mv offsets Date: Thu, 12 Oct 2023 13:46:35 +0200 Message-Id: <20231012114642.19040-50-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:51:31 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550413981916801 X-GMAIL-MSGID: 1779550413981916801 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 CC: Ezequiel Garcia CC: Philipp Zabel --- .../media/platform/verisilicon/hantro_g2.c | 14 ++++++++++ .../platform/verisilicon/hantro_g2_hevc_dec.c | 18 ++----------- .../platform/verisilicon/hantro_g2_vp9_dec.c | 26 +++---------------- .../media/platform/verisilicon/hantro_hw.h | 3 +++ 4 files changed, 23 insertions(+), 38 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_g2.c b/drivers/media/platform/verisilicon/hantro_g2.c index ee5f14c5f8f2..b880a6849d58 100644 --- a/drivers/media/platform/verisilicon/hantro_g2.c +++ b/drivers/media/platform/verisilicon/hantro_g2.c @@ -8,6 +8,8 @@ #include "hantro_hw.h" #include "hantro_g2_regs.h" +#define G2_ALIGN 16 + void hantro_g2_check_idle(struct hantro_dev *vpu) { int i; @@ -42,3 +44,15 @@ irqreturn_t hantro_g2_irq(int irq, void *dev_id) return IRQ_HANDLED; } + +size_t hantro_g2_chroma_offset(struct hantro_ctx *ctx) +{ + return ctx->dst_fmt.width * ctx->dst_fmt.height * ctx->bit_depth / 8; +} + +size_t hantro_g2_motion_vectors_offset(struct hantro_ctx *ctx) +{ + size_t cr_offset = hantro_g2_chroma_offset(ctx); + + return ALIGN((cr_offset * 3) / 2, G2_ALIGN); +} diff --git a/drivers/media/platform/verisilicon/hantro_g2_hevc_dec.c b/drivers/media/platform/verisilicon/hantro_g2_hevc_dec.c index a9d4ac84a8d8..d3f8c33eb16c 100644 --- a/drivers/media/platform/verisilicon/hantro_g2_hevc_dec.c +++ b/drivers/media/platform/verisilicon/hantro_g2_hevc_dec.c @@ -8,20 +8,6 @@ #include "hantro_hw.h" #include "hantro_g2_regs.h" -#define G2_ALIGN 16 - -static size_t hantro_hevc_chroma_offset(struct hantro_ctx *ctx) -{ - return ctx->dst_fmt.width * ctx->dst_fmt.height * ctx->bit_depth / 8; -} - -static size_t hantro_hevc_motion_vectors_offset(struct hantro_ctx *ctx) -{ - size_t cr_offset = hantro_hevc_chroma_offset(ctx); - - return ALIGN((cr_offset * 3) / 2, G2_ALIGN); -} - static void prepare_tile_info_buffer(struct hantro_ctx *ctx) { struct hantro_dev *vpu = ctx->dev; @@ -384,8 +370,8 @@ static int set_ref(struct hantro_ctx *ctx) struct hantro_dev *vpu = ctx->dev; struct vb2_v4l2_buffer *vb2_dst; struct hantro_decoded_buffer *dst; - size_t cr_offset = hantro_hevc_chroma_offset(ctx); - size_t mv_offset = hantro_hevc_motion_vectors_offset(ctx); + size_t cr_offset = hantro_g2_chroma_offset(ctx); + size_t mv_offset = hantro_g2_motion_vectors_offset(ctx); u32 max_ref_frames; u16 dpb_longterm_e; static const struct hantro_reg cur_poc[] = { diff --git a/drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c b/drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c index 6db1c32fce4d..342e543dee4c 100644 --- a/drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c +++ b/drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c @@ -16,8 +16,6 @@ #include "hantro_vp9.h" #include "hantro_g2_regs.h" -#define G2_ALIGN 16 - enum hantro_ref_frames { INTRA_FRAME = 0, LAST_FRAME = 1, @@ -90,22 +88,6 @@ static int start_prepare_run(struct hantro_ctx *ctx, const struct v4l2_ctrl_vp9_ return 0; } -static size_t chroma_offset(const struct hantro_ctx *ctx, - const struct v4l2_ctrl_vp9_frame *dec_params) -{ - int bytes_per_pixel = dec_params->bit_depth == 8 ? 1 : 2; - - return ctx->src_fmt.width * ctx->src_fmt.height * bytes_per_pixel; -} - -static size_t mv_offset(const struct hantro_ctx *ctx, - const struct v4l2_ctrl_vp9_frame *dec_params) -{ - size_t cr_offset = chroma_offset(ctx, dec_params); - - return ALIGN((cr_offset * 3) / 2, G2_ALIGN); -} - static struct hantro_decoded_buffer * get_ref_buf(struct hantro_ctx *ctx, struct vb2_v4l2_buffer *dst, u64 timestamp) { @@ -156,13 +138,13 @@ static void config_output(struct hantro_ctx *ctx, luma_addr = hantro_get_dec_buf_addr(ctx, &dst->base.vb.vb2_buf); hantro_write_addr(ctx->dev, G2_OUT_LUMA_ADDR, luma_addr); - chroma_addr = luma_addr + chroma_offset(ctx, dec_params); + chroma_addr = luma_addr + hantro_g2_chroma_offset(ctx); hantro_write_addr(ctx->dev, G2_OUT_CHROMA_ADDR, chroma_addr); - dst->vp9.chroma_offset = chroma_offset(ctx, dec_params); + dst->vp9.chroma_offset = hantro_g2_chroma_offset(ctx); - mv_addr = luma_addr + mv_offset(ctx, dec_params); + mv_addr = luma_addr + hantro_g2_motion_vectors_offset(ctx); hantro_write_addr(ctx->dev, G2_OUT_MV_ADDR, mv_addr); - dst->vp9.mv_offset = mv_offset(ctx, dec_params); + dst->vp9.mv_offset = hantro_g2_motion_vectors_offset(ctx); } struct hantro_vp9_ref_reg { diff --git a/drivers/media/platform/verisilicon/hantro_hw.h b/drivers/media/platform/verisilicon/hantro_hw.h index 292a76ef643e..9aec8a79acdc 100644 --- a/drivers/media/platform/verisilicon/hantro_hw.h +++ b/drivers/media/platform/verisilicon/hantro_hw.h @@ -521,6 +521,9 @@ hantro_av1_mv_size(unsigned int width, unsigned int height) return ALIGN(num_sbs * 384, 16) * 2 + 512; } +size_t hantro_g2_chroma_offset(struct hantro_ctx *ctx); +size_t hantro_g2_motion_vectors_offset(struct hantro_ctx *ctx); + int hantro_g1_mpeg2_dec_run(struct hantro_ctx *ctx); int rockchip_vpu2_mpeg2_dec_run(struct hantro_ctx *ctx); void hantro_mpeg2_dec_copy_qtable(u8 *qtable, From patchwork Thu Oct 12 11:46: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: 151982 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1166230vqb; Thu, 12 Oct 2023 04:50:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH6KuLOW+h7aYC2aPuAqQpxFo3KE7JWTFdQClBBlMrQlTK7q6TvuYo1CLnfNvTNBOPIJWWG X-Received: by 2002:a05:6a21:789a:b0:159:f5fb:bf74 with SMTP id bf26-20020a056a21789a00b00159f5fbbf74mr28348844pzc.3.1697111434969; Thu, 12 Oct 2023 04:50:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111434; cv=none; d=google.com; s=arc-20160816; b=yhz6yZxhNBE46waC+RvQQUJknt2tgpuxkCLoq+YyX2lm3rtf4OQCCuAmmrMMrLt1yk Bsuly+Q6D3s7DkjapwzgYRwa37rgolzc6NAJJOxPG3qH12vwhYkv3dVZG3TND/PhzPHd PAJXFRsqPQLcenRCbOoWYSjjpF4ACZDg6abf1EKlgr91zIOo/BV3eSyjMKgjrCkoapjx 5hzTg4qigdAW2DbKVzo5+o5A1qYna6w7yxxOZdkrY6ZrfPtX3Iq3/jybqDgbLHDQp2SN c/CQLMM9R9fW6+oxbvIPOMDmDQzxHzqbq/jwT5HwuezRyuH4ppuu0xfG9H0RxYdhVRGt UjoQ== 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=nr1KYax36VZZBnabbjIyUGPTkvQFXV8YfPxk2A654tA=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=ApNENb4ZCGqSWNBvZnknxMJKO8kBLHLPo8875toAqnMKLqUfRzbKVIC3Kq52eJE+dp d3HBdi3qeCkASUlclP0+DUIFjv83JQ02PXi9jT1GeFmb0gBhmNBdL9hfWZtuBwF+WX3g 5oFHZ6v6abqdmjYV//d8TJYwYqSUjVDitfPsNjlqyi0Nu86t/CQ9TH6wzQo16vQo+cbm QIS0h1p6Ai5WozyvNUzE60ElhM91AW3eMXYAuXaoxxMJ3RH5+y9WEVD1KWmIIjGy7xvT WwNYMxrWmZa9XHtIN9i0WndvPqLwsnHgiSw4hPqNoKUkM/xIqkUmDQEjyYfCm6LQ1Svg YgNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=KGN4IloW; 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 13-20020a63164d000000b00578d2d19575si1997780pgw.237.2023.10.12.04.50.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:50:34 -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=KGN4IloW; 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 2C858822CCC0; Thu, 12 Oct 2023 04:50:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379165AbjJLLuF (ORCPT + 19 others); Thu, 12 Oct 2023 07:50:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234095AbjJLLrw (ORCPT ); Thu, 12 Oct 2023 07:47:52 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E926AD5A; Thu, 12 Oct 2023 04:47:17 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 0532266073AC; Thu, 12 Oct 2023 12:47:16 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111236; bh=dg5TyqcXTbK8D5lR679m2t1zA3rG8sR+3z3V0ZimwSc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KGN4IloWw4rUYmAUxpXEtSne/XG274cirWicK3pLPfi3Y3eHcAcGubqPOPSjqxEnx xD4IrAxLBWURuZVq4hS2zVcFU4GZV0Utpm8D4lKnzyAcpvof+XjdTwpTnUEDlTvXYe i6sCF8Uq55+LHui+IeraDjxvsxqWahOu6RDsd1rkEYHHAsLVOOmJrNAe54bwheH1im rAYuAsbLO4KmVZTmJ1JBIQeVmGzxYT5YBph9MLcub+DS/1rtoE64FCg059zvTI6oiC 7Ffg34Bwjnqd8iYW/QEVZqAR01m9ZxDlPaGNWJ4BcJSThdQVifuJNBxocw29fOrBXv p++BsMI3moJ5A== 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 v11 50/56] media: verisilicon: vp9: Allow to change resolution while streaming Date: Thu, 12 Oct 2023 13:46:36 +0200 Message-Id: <20231012114642.19040-51-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:50:34 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550320183374161 X-GMAIL-MSGID: 1779550320183374161 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 CC: Ezequiel Garcia CC: Philipp Zabel --- .../media/platform/verisilicon/hantro_v4l2.c | 24 +++---------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/media/platform/verisilicon/hantro_v4l2.c index f0d8b165abcd..27a1e77cca38 100644 --- a/drivers/media/platform/verisilicon/hantro_v4l2.c +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c @@ -514,25 +514,14 @@ static int hantro_set_fmt_out(struct hantro_ctx *ctx, return ret; if (!ctx->is_encoder) { - struct vb2_queue *peer_vq; - /* * In order to support dynamic resolution change, * the decoder admits a resolution change, as long - * as the pixelformat remains. Can't be done if streaming. - */ - if (vb2_is_streaming(vq) || (vb2_is_busy(vq) && - pix_mp->pixelformat != ctx->src_fmt.pixelformat)) - return -EBUSY; - /* - * Since format change on the OUTPUT queue will reset - * the CAPTURE queue, we can't allow doing so - * when the CAPTURE queue has buffers allocated. + * as the pixelformat remains. */ - peer_vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, - V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); - if (vb2_is_busy(peer_vq)) + if (vb2_is_streaming(vq) && pix_mp->pixelformat != ctx->src_fmt.pixelformat) { return -EBUSY; + } } else { /* * The encoder doesn't admit a format change if @@ -577,15 +566,8 @@ static int hantro_set_fmt_out(struct hantro_ctx *ctx, static int hantro_set_fmt_cap(struct hantro_ctx *ctx, struct v4l2_pix_format_mplane *pix_mp) { - struct vb2_queue *vq; int ret; - /* Change not allowed if queue is busy. */ - vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, - V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); - if (vb2_is_busy(vq)) - return -EBUSY; - if (ctx->is_encoder) { struct vb2_queue *peer_vq; From patchwork Thu Oct 12 11:46: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: 151992 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1166749vqb; Thu, 12 Oct 2023 04:51:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEFpEnUfXPlHc6lvBNmFBPRe8psYrE0q+KEC09ZgDs0u8lIfIEHCIVlzpUuCo2gyBNDdRUU X-Received: by 2002:a17:902:da8d:b0:1c1:fbec:bc3f with SMTP id j13-20020a170902da8d00b001c1fbecbc3fmr26251945plx.5.1697111506164; Thu, 12 Oct 2023 04:51:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111506; cv=none; d=google.com; s=arc-20160816; b=E7JCVENJjRMmSXVJObj5xK9YW9uXPysfy33YRXkSW66A/DKp0ddQ1uCfDuPvCB84me 6owWFA2ENUXrY+eMiKYvLyeAUDfxQh4IV63TQl2vhkWtulczYkCa83yNfuQXxwITHtv+ R6LmAkX2GTGpujg3HoKrBjsH4qOF8ASCrDG/X0xf6pRX3wsq3kwOogPeLEQIU/SaRuzU Vh7iCd0TPd99RJFG7dVWTEXxreW/kLcGCbJm5+7XCWiWDh8CxGREDLAjscQbTPHWwm99 W97SHwEnc+AVbc2eNHFnzE3xPXvR5NPi2H9Zp6aDKkctDdTG22rRdTKTzxcYpKNIcJo3 H5kg== 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=Fd4lY1zdwkEAKG/E/4QKofMlpSsJalHiyFA+bE40heM=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=iX8S7c75WM5pxCy94lVK+oH8nOjlXXL21sAnWJcwGIhhG14GVTECPAsjJrEar21ouP x9SqPFyswgLt1LABGvMhSIKO2u9Pktb5fbKYVv1pokLW7HpjeH1lOzzKu+sZW2nrtxfO A0NKirU+OeE6F2HcwDlV+AQCM1RX8ESI8A9aTUb9pQQhGr/sPszIsAL9eUxPlSpmX2CM EgNZM+50Am7ugBZ7/cnFYVY6dk7KMyQx1UjawSqHJzyOJ55/RACpgLBiXb31+eyP9S6G sYe8MIHHl4fKwYQZ5JrDr1VbQEICwsd91tKP5ULR5qWOshj2fD9KAbpZaiadBgrHFZ7x M+lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=VkmVxWPJ; 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 d11-20020a170903230b00b001c895ddcdcasi2187185plh.544.2023.10.12.04.51.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:51:46 -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=VkmVxWPJ; 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 67123822F8D9; Thu, 12 Oct 2023 04:51:30 -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 S1379451AbjJLLuR (ORCPT + 19 others); Thu, 12 Oct 2023 07:50:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378513AbjJLLr7 (ORCPT ); Thu, 12 Oct 2023 07:47:59 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65DFCD60; Thu, 12 Oct 2023 04:47:18 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 84F8E66073AF; Thu, 12 Oct 2023 12:47:16 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111236; bh=/18qZ3IuYIodk0PI+AK2EpktGt0hajJFmBWG3BBg29E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VkmVxWPJk+NlH5oxe8fy9UO+7HA0u/gwQ64+dcHmgNUvk9enMXliW7Xc0FaXC7nO0 K/MZCX/zl4OgFpCp5a9RbYbm+XipJUneIquj3kvbp70SolzD7lpy9aOrCvqCRTnkFr 6zrgnHRln7YLwtOyDQi9uJNab43kl8zPVXaa7kLtQvUywglTMeZIGg6u9/sfqIJL1L SxZrkqZ5O0kLd5PtRI9QLPmrCSPmFXmuYDY/hNWYG7eBajj9cpwfpIZwXDncKfDCcE YjLvWuUmTYNoJuRxIHc8u/InhIP/kAfEBPfFH6MRGV+QTcgUohksLsq3K7a/b4hWnE mEM8qea6NKFkw== 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 v11 51/56] media: core: Rework how create_buf index returned value is computed Date: Thu, 12 Oct 2023 13:46:37 +0200 Message-Id: <20231012114642.19040-52-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 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 howler.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 (howler.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:51:30 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550394701542151 X-GMAIL-MSGID: 1779550394701542151 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 eff4fe9c6f63..b666b7d09807 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -444,15 +444,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 */ @@ -472,7 +478,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 */ @@ -815,7 +821,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) { @@ -901,7 +907,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; @@ -975,7 +981,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] = { }; @@ -1037,7 +1044,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 5f4ea4485223..4d9b2e16afb1 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -806,11 +806,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); @@ -1038,15 +1043,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 cf276bda5924..a3a051276972 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 Thu Oct 12 11:46: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: 151993 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1166810vqb; Thu, 12 Oct 2023 04:51:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFe8j5QVdM8evUxS8utncv46FpkUsHsq0M+HVQ+asiUDwmJyt9d3ftT84mK07FtenJ4C/6d X-Received: by 2002:a05:6a21:a596:b0:163:d382:ba84 with SMTP id gd22-20020a056a21a59600b00163d382ba84mr29312902pzc.5.1697111514365; Thu, 12 Oct 2023 04:51:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111514; cv=none; d=google.com; s=arc-20160816; b=ecpCdBNa7dB924ZIbdls2F9B90+M15NHZWMVInzMlwNXH3Jbd8hV8GWsSrC/djK/MC kP6Q7t4pt98mctL72KXnwctDgDpwORXxw+oyP4/hI0k7XCL5EP7MiW4CutVRGyHZm3NN IK+MXmT68a9sQCVq8jYkMrWNP11l8PsYS8R1W39qB9dxWhqvqBuqWDW6Obs6+5W1cCsG nAPYJejUnFOCzQfE39jUwxAseJmUFa/M8EFXu9KmrCEfxvn6c9Rkz0k3H3Pmf2pg52jY uwD2vaWLozdJXeSnU81inMsxw1S/NtXPrlHunY2BLTVs3fiKGp4KN14qBfK2Xa3eSLv4 Rfeg== 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=g+c+3bBG0Loc5m/wumdZQqbip4N9vBsSkrZrjukLCJ4=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=Qp8WGpl+MeMK7/NYFwe4WiORINe0/zpVosBe3IG07BcMb1QAiW23MyU722n2JesSLW +vg/GUJdsQ639h9gZlT5fyOGtPQumNUqgdBxD0Pk6WPnjLm3St/kigzvkJ+IUcWj81RV w0uGcYb/nBs6qyLSj/CrBmQObOAEeh/0AyeyqnGEopppT/kD9MyMgBQgFtYg7Y2Sko4U fw5pq2nu5ajWNLXihY3g+mMfwfJmDwIDyzw945JEYhqXdP1j6NzmQcBbxXYR/RQnddUY oqBb0AerZdVJTLjEUgULwtwtIo1UJWayW1Oyy0RaZ/r93iMeWKlvy0UH31FRxz/wpFB7 djAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=KdEIiVzs; 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 h12-20020a170902f54c00b001c9bfdc0638si2177879plf.199.2023.10.12.04.51.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:51:54 -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=KdEIiVzs; 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 4C76A8191672; Thu, 12 Oct 2023 04:51:40 -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 S1379464AbjJLLu2 (ORCPT + 19 others); Thu, 12 Oct 2023 07:50:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378865AbjJLLrx (ORCPT ); Thu, 12 Oct 2023 07:47:53 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4814D63; Thu, 12 Oct 2023 04:47:18 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 05C2066073B3; Thu, 12 Oct 2023 12:47:17 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111237; bh=kEJbLQU/NWfSXI9ifPCtTAsM2xXQaDo8JrJIN+UqWGg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KdEIiVzs7WcM6jKxcsMd28hY9EBCXnvofp/+PFHNz7M2IBfEES0NAZag8RsnGBYSM jJ3x2TAY2JEgQrhieeCrGG2ZMv/gjfb2hmfi0qTEPosL1W1oidTNfnEY1CdziGxAta BJoDjFzYQzeXBMPAdHKbRI/hq1eHZuSlmhOSP3bZObHwKPsc5q32YfAcq9rwv435GI wL9tcowCXE6PMOzFcToK7Okj0gejNU2yBG5YWTFo7xZZP42BDzE9nNoDmnktiTSB6n 6p+xakIWFK9T76jerUBiyGnh/fzbvpTxhSFIAXaOA+LYBLKShBSW3ahVO/1ndCUF13 qVQTeuk5kdmag== 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 v11 52/56] media: core: Add bitmap manage bufs array entries Date: Thu, 12 Oct 2023 13:46:38 +0200 Message-Id: <20231012114642.19040-53-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 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]); Thu, 12 Oct 2023 04:51:40 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550403133545324 X-GMAIL-MSGID: 1779550403133545324 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 | 42 +++++++++++++++---- include/media/videobuf2-core.h | 19 ++++++--- 2 files changed, 47 insertions(+), 14 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index b666b7d09807..29d46c5be705 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -416,11 +416,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); } /** @@ -429,8 +430,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; } @@ -452,11 +452,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; @@ -878,6 +879,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) @@ -947,7 +956,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) { /* @@ -974,6 +982,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); @@ -1010,9 +1022,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; @@ -1074,7 +1096,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) { /* @@ -2551,6 +2572,9 @@ void vb2_core_queue_release(struct vb2_queue *q) __vb2_queue_free(q, q->max_num_buffers); kfree(q->bufs); q->bufs = NULL; + bitmap_free(q->bufs_bitmap); + q->bufs_bitmap = NULL; + mutex_unlock(&q->mmap_lock); } EXPORT_SYMBOL_GPL(vb2_core_queue_release); @@ -2905,7 +2929,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 a3a051276972..288477075a0e 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 Thu Oct 12 11:46: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: 151999 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1167099vqb; Thu, 12 Oct 2023 04:52:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE+3YEwVAUC2K8pqn/JBym5tJ/EOFVQLU3Y+kqG+agpGaWd99EDrc30/1EGqvIw2n1s3+Ao X-Received: by 2002:a17:902:ce84:b0:1c6:9312:187 with SMTP id f4-20020a170902ce8400b001c693120187mr26158616plg.3.1697111548208; Thu, 12 Oct 2023 04:52:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111548; cv=none; d=google.com; s=arc-20160816; b=lOMFKWBvM4y7MA0x+QQppqn03Ekbqt6TfhH2BUlfJpYFoQOOZv64t8W4h46qA7Tdqt cpsuj6+Tn6XESghwRq/Nebt3Q6jte4R4K/Wimom6/eSo8Ymw32jCEYsFzIuBIQqZz/VU Iuk9G9aknX2S9HN4tSRAGkK29qXfLB1ZlofgyDJhnogV1WfC/FkeBggnIzoka/DyZMoi G5b/8H+7/UlU3l3vW+299JpnU4fYxW9IG747qsttgb+bASP99rl3YqmZ8RiH49jQnkWQ BkQE9DaP1v7Ncl4SVSSwYb+IMy27G4/N2FocPGKEAw9EzIo5YFTlAvgiabpvYd0APjnJ TaQA== 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=jOFJMuJF96c16BSEaCfH1kdisVQa7IN38j7+97sMSBY=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=rePsSXw+dpAInChEulPCMYR/1zFh6x0WjpqtXne524RUgGwECEPmtrbvJuVjFzZaZy PuD1crmaSYVbbNUD1jYUvNmIM9ChW8+RS9JLvRGuGtt3QY2siNMuQy1jv0Lg7Zdvmsoh KHYzN3ASg8itw8b6fGBBKmyW4MthMA9MqpJ3uiL1BGoNgkTr7bUTqbmwKlyHx76sejHG BzBbeDhTiIjjxdC8ciQ4EYHfu7e+H7npCJAdlRO8zwQ1rCPiR0tipWCrhKq0KzGHOsri R1zN5etlRmzr5YFc2ut9f+SRdJ0hu7YXCXZqZxkm8GUObFfVzb6+RmcfRbv3ORIcaQye kQBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Dm4c7pjX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id p11-20020a1709026b8b00b001bbb6f4cd6dsi1926145plk.334.2023.10.12.04.52.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:52:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Dm4c7pjX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 99FE48374BA1; Thu, 12 Oct 2023 04:52:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379455AbjJLLuT (ORCPT + 19 others); Thu, 12 Oct 2023 07:50:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378908AbjJLLsR (ORCPT ); Thu, 12 Oct 2023 07:48:17 -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 957D6D6D; Thu, 12 Oct 2023 04:47:19 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 86788660737D; Thu, 12 Oct 2023 12:47:17 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111237; bh=XGb6zadLPkb1giyVQb8HPAjBYmgjSFi31wCRf9z5B9E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dm4c7pjXX7SgbHsEjusMHJW2FDK3NQ11JEILi8v+VAMfmSHE4zOq08I2oK0/vmu0G RByQZEDvtSNql4KlqJly2cvLdmUbPKwZRHGD6O4J3nqiqMAAQLWFjvjgk9kQTZhFn6 4iwdNyIrvlCaf4bHodcak7Ugq8NOasu3AgmhSrLcfYffFt5y2b5dCvXYA89+V1sicw BM5ZZWdRZ99iuECiKHCSAAvMqVscoCjDbaBJJ3XsdZ7TKS2UUMc3vcCzS3HhsO7jpu DM1jHezH27APRUyubboDr3sO3LZnbdlCWTsoIW876gfNeWk0uxmXjF8Od5p3LZHr3Z 0CDpj7iy5oJIg== 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 v11 53/56] media: core: Free range of buffers Date: Thu, 12 Oct 2023 13:46:39 +0200 Message-Id: <20231012114642.19040-54-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:52:20 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550438903042302 X-GMAIL-MSGID: 1779550438903042302 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 | 50 ++++++++----------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 29d46c5be705..7cf2463199d7 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -519,13 +519,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; + unsigned int i; struct vb2_buffer *vb; - for (i = vb2_get_num_buffers(q); 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; @@ -537,36 +536,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; + unsigned int i; lockdep_assert_held(&q->mmap_lock); /* Call driver-provided cleanup function for each buffer, if provided */ - for (i = vb2_get_num_buffers(q), 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 /* @@ -599,8 +594,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 < vb2_get_num_buffers(q); buffer++) { - struct vb2_buffer *vb = vb2_get_buffer(q, buffer); + for (i = start; i < q->max_num_buffers && i < start + count; i++) { + struct vb2_buffer *vb = vb2_get_buffer(q, i); bool unbalanced; if (!vb) @@ -617,7 +612,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); @@ -651,7 +646,7 @@ static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) #endif /* Free vb2 buffers */ - for (i = vb2_get_num_buffers(q), 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) @@ -659,7 +654,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)) { @@ -693,7 +687,7 @@ EXPORT_SYMBOL(vb2_buffer_in_use); static bool __buffers_in_use(struct vb2_queue *q) { unsigned int buffer; - for (buffer = 0; buffer < vb2_get_num_buffers(q); ++buffer) { + for (buffer = 0; buffer < q->max_num_buffers; ++buffer) { struct vb2_buffer *vb = vb2_get_buffer(q, buffer); if (!vb) @@ -853,7 +847,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->max_num_buffers); mutex_unlock(&q->mmap_lock); /* @@ -963,7 +957,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; } @@ -1003,7 +997,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, 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; } @@ -1103,7 +1097,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; } @@ -1717,7 +1711,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 < vb2_get_num_buffers(q); ++i) { + for (i = 0; i < q->max_num_buffers; ++i) { vb = vb2_get_buffer(q, i); if (!vb) @@ -2123,7 +2117,7 @@ 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 < vb2_get_num_buffers(q); i++) { + for (i = 0; i < q->max_num_buffers; i++) { struct vb2_buffer *vb = vb2_get_buffer(q, i); if (!vb) continue; @@ -2166,7 +2160,7 @@ 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 < vb2_get_num_buffers(q); i++) { + for (i = 0; i < q->max_num_buffers; i++) { struct vb2_buffer *vb; struct media_request *req; vb = vb2_get_buffer(q, i); @@ -2569,7 +2563,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 Thu Oct 12 11:46: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: 151996 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1166928vqb; Thu, 12 Oct 2023 04:52:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFZH6eD2P8qzilyPUueuiXQFPVBrXGwdwoiGkeXJBZcDuaghcskwGbgoWzYkj6Mb7m++xuk X-Received: by 2002:a05:6a20:43a6:b0:16c:b514:a4bc with SMTP id i38-20020a056a2043a600b0016cb514a4bcmr17376762pzl.4.1697111528555; Thu, 12 Oct 2023 04:52:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111528; cv=none; d=google.com; s=arc-20160816; b=P6hVrkpunzT+l1y+w+1BObZIFpxKgTn6Z07aGBItaWK2MB2XlBuACPtmHu5jnXKmyq P0yi/c6leEwG1I1BfUNUKrNv0H1NSooINV6Dg5qoO5gwOqc7Hc0L4f2Yc8w2pBprsr6K KlVGptgI3ccaxAUwJuem56exoTmDOPUvgB80JqXDk1xcSG96p/yDHnRGriVJqRbPHukk iIpTShw/taPB6l53koLiTF7GoGBx0WCt9uDblIT5nloAKrrmPdWShsMprIR6WX8P61Qp eAccJivHMrRvY5VYT9MaloJjg2V6wvlArt+5D5vvYk3cnqfquxWqPy8TnJBKWHEDDsva 4h0A== 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=2Qh0yq+I3Xlu+naSzFgfMoU2Y2julw6U/BjxawkoQfY=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=tNQCU86gOBgvGiucPvLAHT0I4qrMpFeyOlaiIFj3NePuHvFg6ys/oN1Tz+X9IQfmGS Pqz00NfeSbZM9IX5fPJfpj9UTFYpaf24WvnV61ur+zXlYy8ERZigNHAy1YjpewRLNkUr Zfo76Wv+3chK3+EUe81gb3EZqA6UM26XmisU3uBLmbqCuKQ7broUBHSZiA21qn1Y1B62 VMzDp6LEuVBGIXeoj11SC+2OvI+2DXOcuaOIA97abB373gMiinYYOsLXKV87Wx/HvE5G l1OYN/PpejU6Yg4ImtJGK/6EX8v8C+2hc6U0ijmy01kqr5lk+s7UVsr+uFH/mndfAg9V I+FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=abrlBjsG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id bd10-20020a170902830a00b001c5fca2e1besi1931267plb.15.2023.10.12.04.52.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:52:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=abrlBjsG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id AC15382F9DF8; Thu, 12 Oct 2023 04:51:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379382AbjJLLuW (ORCPT + 19 others); Thu, 12 Oct 2023 07:50:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378937AbjJLLsU (ORCPT ); Thu, 12 Oct 2023 07:48:20 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED93BF3; Thu, 12 Oct 2023 04:47:19 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 13D3B6607349; Thu, 12 Oct 2023 12:47:18 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111238; bh=ylP5rXdlbFS3HB0caPZfrn6eGXdCEIz9+rXPNJU6U5g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=abrlBjsGuaUb1NMGykZzfUKqKxpXKumg7koQiWkY83QpY4Y3KEJ5ESXoxTk8IZB/P N+pICS0aco6DgYbgm+pKm6StgVdZ9Ym7+u2qOD8G6ZU2EONac2tl8IQGLzs4nbifvm aZUnCdJASQy7MB+wRphpcRhYvMWfdxyb46+SnxNkJoN/GxA9uLEuXHDQ8O9iXkoy7z EBPIc5VfmpX+TAcdiMzxs41sJxltJHpLtW5B3Ex64kYtqMGsFK1vHI2EBLaQi665ZU kodjp/4fg84h2dGmD9D3Bgg4c2AfLq07AS3wXkXjyTc6DDfqqbWQnbo9TERu+bZUYv lS5Edt3Tf3HaQ== 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 v11 54/56] media: v4l2: Add DELETE_BUFS ioctl Date: Thu, 12 Oct 2023 13:46:40 +0200 Message-Id: <20231012114642.19040-55-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:51:51 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550418152004010 X-GMAIL-MSGID: 1779550418152004010 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 7cf2463199d7..709fee7dacf3 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -1665,6 +1665,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 4d9b2e16afb1..976eb118cf50 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; @@ -1013,6 +1021,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 288477075a0e..db3bd986624e 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 Thu Oct 12 11:46: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: 151994 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1166850vqb; Thu, 12 Oct 2023 04:52:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFYA35NV460N+TJ9OSzx2AYYZz+mykBPwVAt57VLFYAF7ORWi1WuhveQHR/s4+/3sTcqdKE X-Received: by 2002:a92:dc02:0:b0:34f:36ae:e8d2 with SMTP id t2-20020a92dc02000000b0034f36aee8d2mr22941381iln.3.1697111520031; Thu, 12 Oct 2023 04:52:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697111520; cv=none; d=google.com; s=arc-20160816; b=tlyqpcG5qT0aKVEDGzdhDXOj4uvWuW3+eiStvO4rEh2G8/gV1ZneSfdCyfCvlidjnJ mHxNv8ElmmqZP6OPV79gdHo7Llcvdx6TxNxV8k2L7mDSSsrNy2+8+ecqYUgbNY7TMfwP 0Nj/FCvwmHs9WPXZSZWgAH50W/QDW/vr61FSLn4JBP2D1Fhvy/S/simShhz6R9Rx8r1D FkjYBVSXLr9YwhP4YYywKrbAOT8rR4qWaO9ipCIEFDvZlpTve+8xONHDoN8TBzWIFqP6 IET3mJJL8Pk0adalcqsGFnWA0tuaSlVd/iGnb6SDrLEVSNOu2srK5Y3ef9iSDdp5tm7J kxKw== 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=dTSkrKQl49IzkCgf2sSVj9fTGNFVho3EjuDIE20s9b/jJ87UUd4g58YZvzxTOd4+Ns y5xCHwZLsTKqiHLr6T7sFokSmeuodbpwPQxIMsETQ4x7bAEEMLmV2xbYFFMz6yHIsHt/ zPmu+M8wzSxVQHSTPt8tUXqK17PO33rEnLayCFazpX/rcwl6g+T1nQhZfRH6rHaxuEfG 9oBakeK/j+HWjcQXfrxC06gZp082niL2jWYjSRw1wx1aRUf4QIHikvLnnZs7hFJKz54x Rt+guA6A/DHNTs5HHEqeKmcRIRMiSVDoz/IGcftb3ycTlxQ/XZiTAZClkC2ehqK8BMW2 zfhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=a7hcumR6; 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 l11-20020a63ea4b000000b00577bf1de778si2006187pgk.585.2023.10.12.04.51.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:51:59 -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=a7hcumR6; 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 9299380981A4; Thu, 12 Oct 2023 04:51: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 S1379472AbjJLLub (ORCPT + 19 others); Thu, 12 Oct 2023 07:50:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379273AbjJLLsV (ORCPT ); Thu, 12 Oct 2023 07:48:21 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50E88D75; Thu, 12 Oct 2023 04:47:20 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 8E1B5660737F; Thu, 12 Oct 2023 12:47:18 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111239; bh=LkM/7EVzkzeCersLJmzLfirkGugiivs+DlFzZEGNCYQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a7hcumR6sZwz33cd/uyeNZAJPjD+ek7TwjHHBCLQgnqw1U164uPW7Y3hnhR/tfwrS RnfEJ1MRQSSJo4oWxBMskYQf+0Yr3NKzwK4XpSXMXQwKarp8c3xajwv3lbjP4hpApq BWdjFDeDgrg4ILvLcy4aBuSLmyXhOzZCl4u5MyMjjwnxnfBQnTEmVL2vjDgSuz0vd1 MGis9KmXxUI6gRKj2B3JKDBgaNJJSFg8RWn68LOAWr6Mik42rxXEGpnEeLhP8qyD5m vIHqz3Pb/kLGtGEPTPbtgyBpCZQniNJ3gdJP6PqIAqMzfN7tilaBc7jV7x1SV3GoXZ Q6KxxtgOZHE1w== 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 v11 55/56] media: v4l2: Add mem2mem helpers for DELETE_BUFS ioctl Date: Thu, 12 Oct 2023 13:46:41 +0200 Message-Id: <20231012114642.19040-56-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:51:17 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779550409116776233 X-GMAIL-MSGID: 1779550409116776233 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 Thu Oct 12 11:46: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: 152000 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1181084vqb; Thu, 12 Oct 2023 05:13:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGySXWbPBHBrs926ZavNZRMWBQoImGjXB7iYtBwaxeU13gux/HUDt5rciw+cpBujIcpfYQ9 X-Received: by 2002:a05:6a20:7da2:b0:15d:6fd3:8e74 with SMTP id v34-20020a056a207da200b0015d6fd38e74mr29554067pzj.3.1697112816682; Thu, 12 Oct 2023 05:13:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697112816; cv=none; d=google.com; s=arc-20160816; b=qhzk6epEZ4RUuagrxvaF1BlJHIlVL4yUk3/hIo/hNzkcy5VwvROkXI7rReu6oKMlLX q+zRnbLqccXIzKDCsmHSB7xkWWF5MsLlouXf7lZ3bKkubb0y5E3tX2JPZdW6rli/mdmb E8rkL+I4ge2A6HA5eWj7YS0TnOxBgnkWJ+EnlT3VblrY1Zc3cxd4/Yol2ZzqM20A2bjw hfrEsQhl7CMxTrZ9MhHaNTZe7FOTlSnyofvWq9vD+tEknoF8ujrKbU76ahrHTz9k59wg /qmGTnZ48w/XII730q77YJq0X/81a9clXqUJEwmnb2MZvoW+eRWFpIooAd0mJXwiP97Z VsVg== 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=l+Ls/FT671Btr94VgnV1LYppGow3blSZaH5VhTMv0roX6MgiA0wUxysXQqGxsv9D9t Flpm5rBh7tTCVkA2f6SWpUOkgejGs6NWXj4YNptcMmK0sb0pbyc6lug0wZ+6imE9O0oc SM7K51BU4mBEEtbR4/CwKC1tU2ayGE2uxb9NpFXmhALfI+MAitKP4mqEipoG6S7VvRk/ jTgWNq1YEEWVew4H3f4Msko2UyVgQC7/U75unjH5Hb4xk/Cthx8nEqI1UpdwRPGYNtSJ C3qyFc1wMJaDeeGU9l1PFhZSeNjxpt27JylQq8guB8vPEIrjioVVFfD1Mwh2i4eK9FHk kRUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=U0y3rfba; 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 x19-20020a63f713000000b00589878c0a5bsi2055395pgh.71.2023.10.12.05.13.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 05:13:36 -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=U0y3rfba; 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 3C526817C88A; Thu, 12 Oct 2023 05:13: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 S1347220AbjJLMNO (ORCPT + 19 others); Thu, 12 Oct 2023 08:13:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347297AbjJLMNK (ORCPT ); Thu, 12 Oct 2023 08:13:10 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24394D7D; Thu, 12 Oct 2023 04:47:20 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 1C23666073BA; Thu, 12 Oct 2023 12:47:19 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111239; bh=WlpSngD7A0Xes3T2AjXSHPISBbEOvphWL+prcr4Zf8E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U0y3rfbaL4QH8KGfD0QLyY1iew+s/RNBKm6GFspghcCrENBXYTXg8xRyIfkir+UF2 BKBFLvcqpLoAGTH9nrnD9cRpe9RFUPJ7RxT/pJuD4ZTTom8ck9ThnLkzS9VhqvIAQI haeWlBuz9OM9VpCukP3mpc8LnDJE6WKd9jRl/gF/U6beuuwwaWc7RoRQlQ16bdCxk6 nwUedjUjGBuunt274h/m7qex5BLoWLyQ0p133YDSDBI1J6D/cW6Q5xW8G0mQX64rAT OGNo7pUc9Sq4/f//KT1riNexbNxssvif6g+VbhEAO3ZOkFbghKeHDTu+OhopR7xADC 0VwRkH4Wse9JA== 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 v11 56/56] media: test-drivers: Use helper for DELETE_BUFS ioctl Date: Thu, 12 Oct 2023 13:46:42 +0200 Message-Id: <20231012114642.19040-57-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 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]); Thu, 12 Oct 2023 05:13:34 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779551769104487815 X-GMAIL-MSGID: 1779551769104487815 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;