Message ID | 20230927153558.159278-51-benjamin.gaignard@collabora.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2797899vqu; Wed, 27 Sep 2023 10:52:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH3UjAIri5i4r3IM132UuqNdBFAOd4goFGUAgI1emWcE/LLRig8Z9Ud/jT0NB3mIyr1BvD+ X-Received: by 2002:a17:903:120c:b0:1c5:de06:9e5a with SMTP id l12-20020a170903120c00b001c5de069e5amr2498060plh.21.1695837142620; Wed, 27 Sep 2023 10:52:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695837142; cv=none; d=google.com; s=arc-20160816; b=TDSWpOztS17gHX9JSdOewN78HZtm9XpWwyDRS/NtO+TdbK9Rwlb0reLGFzS4fOH0wR bj9zYqriGquf/RfgbHQWjJJ799ZD5CxYdpdBJJUkMbiMdozdpZbBfTqrcnzA2Numcjyh LVn1ioYnGI5RN83jFfqQhc8hjgc7XK11ARwiAr3CCrcPzkhYrKFDjwjOpfZUZ6Eg29lv +PgXCaUZSCXwY3d1rq4GUR2xvqc9oQ8HzAU4yHs1Pkragk14DXQ4kwJi1LGTDAvYafzf +bK+UhRXCaJo/SUR2XpymrQh2Sqs9b0rWyqKnPgbzGhbMBKecRHvtEgFvgt9Irsd/gpS Np5Q== 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=2qWN9gcWE1cCd4QDbOtoUFT3dABxhAehI8TgvGuMY4I=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=g/zBXGFzkOQH/VIeFduZxlthuj31JJqzw1LTq9Pg2wfgbDRji6gZWtAJEDN/M/u05H 9OpGjQ2R7RVEzDcMbn+chfNCcbsKM7280J5pfe6ppG9Yc6bLPZ/GEYr8Re1UImtcm1UW 3mAQpOewaAvjbP1bCk035MQBUnv8/grZCr23FbxXNvO6pSoPAQLdQ98dUoNnZ5JxKMJ4 ySPQID/BMS2GGAhPpPaVwXSBZVveURwKmGQLcVzq+AnIDi2g4W6Q3T2+O7yDwhdlssiR R+XCpTnhZmNyrjIvcAkrYpm5HEdUfj9dMov+Txf/0NI/s9wBG/BngXS41uqVdI5iRzEt kwUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=l7hvUjhR; 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 q15-20020a170902dacf00b001c434b3659bsi17394321plx.354.2023.09.27.10.52.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 10:52:22 -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=l7hvUjhR; 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 BCC7B81DFD54; Wed, 27 Sep 2023 08:39:29 -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 S233077AbjI0Pis (ORCPT <rfc822;ruipengqi7@gmail.com> + 19 others); Wed, 27 Sep 2023 11:38:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232769AbjI0Pgf (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 27 Sep 2023 11:36:35 -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 BEDCBCDD; Wed, 27 Sep 2023 08:36:33 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:672:46bd:3ec7:6cdf]) (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 1DC526607381; Wed, 27 Sep 2023 16:36:32 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1695828992; bh=Tn/0+SEs92pxnf0JZtLBn6EtBJkC+KjsYnF3S+7Li74=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l7hvUjhRCDvOCfXpTo+2MjkpJn4DcC9K4yXxmAhH1ri88E6W2bLcmZNcP21AdwLfU 4HhtSPFyBFX4ETWeOuF5us2fENDMrD7axP6qDageUb1fvZqUZis8nrtwOt+EDf/yBt FVN72t4l3bJYRbns8Ehf3KNXbDUHoTDVzXQLUvmWRjRuQTLXAnr4xEaiQLmTYQbv1h zmDpUqjYDOEGKhglbQByAQ2laL2RiWPbT4kSYQ0QC/46/M5KC7zQVY/0LpfQnJbM62 7OZqO4nkGpjZ7z5t6W5ybB5ZSAn6v+obR/jP6Ed1VRGaa/cULLkRsWgmXtUsCmlZS4 9h+pmqY0RrdwA== From: Benjamin Gaignard <benjamin.gaignard@collabora.com> 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 <benjamin.gaignard@collabora.com> Subject: [PATCH v8 50/53] media: core: Free range of buffers Date: Wed, 27 Sep 2023 17:35:55 +0200 Message-Id: <20230927153558.159278-51-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230927153558.159278-1-benjamin.gaignard@collabora.com> References: <20230927153558.159278-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> 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]); Wed, 27 Sep 2023 08:39:29 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778214127861964855 X-GMAIL-MSGID: 1778214127861964855 |
Series |
Add DELETE_BUF ioctl
|
|
Commit Message
Benjamin Gaignard
Sept. 27, 2023, 3:35 p.m. UTC
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 <benjamin.gaignard@collabora.com>
---
.../media/common/videobuf2/videobuf2-core.c | 36 ++++++++-----------
1 file changed, 15 insertions(+), 21 deletions(-)
Comments
Hi Benjamin,
kernel test robot noticed the following build errors:
[auto build test ERROR on media-tree/master]
[also build test ERROR on sunxi/sunxi/for-next dtor-input/next linus/master v6.6-rc3]
[cannot apply to dtor-input/for-linus next-20230929]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Benjamin-Gaignard/media-videobuf2-Rework-offset-cookie-encoding-pattern/20230928-003247
base: git://linuxtv.org/media_tree.git master
patch link: https://lore.kernel.org/r/20230927153558.159278-51-benjamin.gaignard%40collabora.com
patch subject: [PATCH v8 50/53] media: core: Free range of buffers
config: powerpc64-randconfig-001-20230930 (https://download.01.org/0day-ci/archive/20230930/202309301247.Y0hH4pjx-lkp@intel.com/config)
compiler: powerpc64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230930/202309301247.Y0hH4pjx-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309301247.Y0hH4pjx-lkp@intel.com/
All errors (new ones prefixed by >>):
drivers/media/common/videobuf2/videobuf2-core.c:39:2: error: #error Expected PAGE_SHIFT to be 12
39 | #error Expected PAGE_SHIFT to be 12
| ^~~~~
drivers/media/common/videobuf2/videobuf2-core.c: In function '__vb2_queue_free':
>> drivers/media/common/videobuf2/videobuf2-core.c:596:14: error: 'buffer' undeclared (first use in this function)
596 | for (buffer = 0; buffer < q->max_num_buffers; buffer++) {
| ^~~~~~
drivers/media/common/videobuf2/videobuf2-core.c:596:14: note: each undeclared identifier is reported only once for each function it appears in
vim +/buffer +596 drivers/media/common/videobuf2/videobuf2-core.c
e23ccc0ad92586 drivers/media/video/videobuf2-core.c Pawel Osciak 2010-10-11 540
2a87af6ba1b9df drivers/media/v4l2-core/videobuf2-core.c Mauro Carvalho Chehab 2017-11-27 541 /*
de4be4166a32b9 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 542 * __vb2_queue_free() - free count buffers from start index of the queue - video memory and
2d86401c2cbfce drivers/media/video/videobuf2-core.c Guennadi Liakhovetski 2011-09-28 543 * related information, if no buffers are left return the queue to an
2d86401c2cbfce drivers/media/video/videobuf2-core.c Guennadi Liakhovetski 2011-09-28 544 * uninitialized state. Might be called even if the queue has already been freed.
e23ccc0ad92586 drivers/media/video/videobuf2-core.c Pawel Osciak 2010-10-11 545 */
de4be4166a32b9 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 546 static void __vb2_queue_free(struct vb2_queue *q, unsigned int start, unsigned int count)
e23ccc0ad92586 drivers/media/video/videobuf2-core.c Pawel Osciak 2010-10-11 547 {
de4be4166a32b9 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 548 unsigned int i;
e23ccc0ad92586 drivers/media/video/videobuf2-core.c Pawel Osciak 2010-10-11 549
01cb370ff6c5ab drivers/media/common/videobuf2/videobuf2-core.c Hans Verkuil 2022-11-30 550 lockdep_assert_held(&q->mmap_lock);
63faabfd89f4db drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2013-12-13 551
e23ccc0ad92586 drivers/media/video/videobuf2-core.c Pawel Osciak 2010-10-11 552 /* Call driver-provided cleanup function for each buffer, if provided */
de4be4166a32b9 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 553 for (i = start; i < q->max_num_buffers && i < start + count; i++) {
6e57b95def5189 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 554 struct vb2_buffer *vb = vb2_get_buffer(q, i);
256f3162c17595 drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 555
6e57b95def5189 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 556 if (!vb)
6e57b95def5189 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 557 continue;
de4be4166a32b9 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 558 if (vb->planes[0].mem_priv)
a1d36d8c705e10 drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-03-17 559 call_void_vb_qop(vb, buf_cleanup, vb);
e23ccc0ad92586 drivers/media/video/videobuf2-core.c Pawel Osciak 2010-10-11 560 }
e23ccc0ad92586 drivers/media/video/videobuf2-core.c Pawel Osciak 2010-10-11 561
e23ccc0ad92586 drivers/media/video/videobuf2-core.c Pawel Osciak 2010-10-11 562 /* Release video buffer memory */
de4be4166a32b9 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 563 __vb2_free_mem(q, start, count);
e23ccc0ad92586 drivers/media/video/videobuf2-core.c Pawel Osciak 2010-10-11 564
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 565 #ifdef CONFIG_VIDEO_ADV_DEBUG
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 566 /*
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 567 * Check that all the calls were balanced during the life-time of this
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 568 * queue. If not then dump the counters to the kernel log.
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 569 */
6e57b95def5189 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 570 if (vb2_get_num_buffers(q)) {
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 571 bool unbalanced = q->cnt_start_streaming != q->cnt_stop_streaming ||
a10b2153257403 drivers/media/common/videobuf2/videobuf2-core.c Hans Verkuil 2022-06-22 572 q->cnt_prepare_streaming != q->cnt_unprepare_streaming ||
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 573 q->cnt_wait_prepare != q->cnt_wait_finish;
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 574
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 575 if (unbalanced) {
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 576 pr_info("unbalanced counters for queue %p:\n", q);
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 577 if (q->cnt_start_streaming != q->cnt_stop_streaming)
2e33dbb06da407 drivers/media/common/videobuf/videobuf2-core.c Mauro Carvalho Chehab 2017-12-28 578 pr_info(" setup: %u start_streaming: %u stop_streaming: %u\n",
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 579 q->cnt_queue_setup, q->cnt_start_streaming,
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 580 q->cnt_stop_streaming);
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 581 if (q->cnt_prepare_streaming != q->cnt_unprepare_streaming)
a10b2153257403 drivers/media/common/videobuf2/videobuf2-core.c Hans Verkuil 2022-06-22 582 pr_info(" prepare_streaming: %u unprepare_streaming: %u\n",
a10b2153257403 drivers/media/common/videobuf2/videobuf2-core.c Hans Verkuil 2022-06-22 583 q->cnt_prepare_streaming, q->cnt_unprepare_streaming);
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 584 if (q->cnt_wait_prepare != q->cnt_wait_finish)
2e33dbb06da407 drivers/media/common/videobuf/videobuf2-core.c Mauro Carvalho Chehab 2017-12-28 585 pr_info(" wait_prepare: %u wait_finish: %u\n",
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 586 q->cnt_wait_prepare, q->cnt_wait_finish);
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 587 }
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 588 q->cnt_queue_setup = 0;
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 589 q->cnt_wait_prepare = 0;
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 590 q->cnt_wait_finish = 0;
a10b2153257403 drivers/media/common/videobuf2/videobuf2-core.c Hans Verkuil 2022-06-22 591 q->cnt_prepare_streaming = 0;
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 592 q->cnt_start_streaming = 0;
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 593 q->cnt_stop_streaming = 0;
a10b2153257403 drivers/media/common/videobuf2/videobuf2-core.c Hans Verkuil 2022-06-22 594 q->cnt_unprepare_streaming = 0;
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 595 }
6e57b95def5189 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 @596 for (buffer = 0; buffer < q->max_num_buffers; buffer++) {
145085ced318ad drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 597 struct vb2_buffer *vb = vb2_get_buffer(q, buffer);
145085ced318ad drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 598 bool unbalanced;
145085ced318ad drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 599
145085ced318ad drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 600 if (!vb)
145085ced318ad drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 601 continue;
145085ced318ad drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 602
145085ced318ad drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 603 unbalanced = vb->cnt_mem_alloc != vb->cnt_mem_put ||
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 604 vb->cnt_mem_prepare != vb->cnt_mem_finish ||
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 605 vb->cnt_mem_get_userptr != vb->cnt_mem_put_userptr ||
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 606 vb->cnt_mem_attach_dmabuf != vb->cnt_mem_detach_dmabuf ||
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 607 vb->cnt_mem_map_dmabuf != vb->cnt_mem_unmap_dmabuf ||
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 608 vb->cnt_buf_queue != vb->cnt_buf_done ||
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 609 vb->cnt_buf_prepare != vb->cnt_buf_finish ||
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 610 vb->cnt_buf_init != vb->cnt_buf_cleanup;
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 611
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 612 if (unbalanced) {
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 613 pr_info("unbalanced counters for queue %p, buffer %d:\n",
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 614 q, buffer);
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 615 if (vb->cnt_buf_init != vb->cnt_buf_cleanup)
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 616 pr_info(" buf_init: %u buf_cleanup: %u\n",
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 617 vb->cnt_buf_init, vb->cnt_buf_cleanup);
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 618 if (vb->cnt_buf_prepare != vb->cnt_buf_finish)
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 619 pr_info(" buf_prepare: %u buf_finish: %u\n",
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 620 vb->cnt_buf_prepare, vb->cnt_buf_finish);
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 621 if (vb->cnt_buf_queue != vb->cnt_buf_done)
28d77c21cbeb2c drivers/media/common/videobuf2/videobuf2-core.c Hans Verkuil 2019-01-16 622 pr_info(" buf_out_validate: %u buf_queue: %u buf_done: %u buf_request_complete: %u\n",
28d77c21cbeb2c drivers/media/common/videobuf2/videobuf2-core.c Hans Verkuil 2019-01-16 623 vb->cnt_buf_out_validate, vb->cnt_buf_queue,
28d77c21cbeb2c drivers/media/common/videobuf2/videobuf2-core.c Hans Verkuil 2019-01-16 624 vb->cnt_buf_done, vb->cnt_buf_request_complete);
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 625 if (vb->cnt_mem_alloc != vb->cnt_mem_put)
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 626 pr_info(" alloc: %u put: %u\n",
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 627 vb->cnt_mem_alloc, vb->cnt_mem_put);
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 628 if (vb->cnt_mem_prepare != vb->cnt_mem_finish)
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 629 pr_info(" prepare: %u finish: %u\n",
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 630 vb->cnt_mem_prepare, vb->cnt_mem_finish);
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 631 if (vb->cnt_mem_get_userptr != vb->cnt_mem_put_userptr)
2e33dbb06da407 drivers/media/common/videobuf/videobuf2-core.c Mauro Carvalho Chehab 2017-12-28 632 pr_info(" get_userptr: %u put_userptr: %u\n",
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 633 vb->cnt_mem_get_userptr, vb->cnt_mem_put_userptr);
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 634 if (vb->cnt_mem_attach_dmabuf != vb->cnt_mem_detach_dmabuf)
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 635 pr_info(" attach_dmabuf: %u detach_dmabuf: %u\n",
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 636 vb->cnt_mem_attach_dmabuf, vb->cnt_mem_detach_dmabuf);
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 637 if (vb->cnt_mem_map_dmabuf != vb->cnt_mem_unmap_dmabuf)
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 638 pr_info(" map_dmabuf: %u unmap_dmabuf: %u\n",
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 639 vb->cnt_mem_map_dmabuf, vb->cnt_mem_unmap_dmabuf);
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 640 pr_info(" get_dmabuf: %u num_users: %u\n",
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 641 vb->cnt_mem_get_dmabuf,
14700b816b3d49 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 642 vb->cnt_mem_num_users);
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 643 }
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 644 }
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 645 #endif
b5b4541eef8eac drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-01-29 646
3e947c36af524b drivers/media/common/videobuf2/videobuf2-core.c Hans Verkuil 2022-08-10 647 /* Free vb2 buffers */
de4be4166a32b9 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 648 for (i = start; i < q->max_num_buffers && i < start + count; i++) {
de4be4166a32b9 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 649 struct vb2_buffer *vb = vb2_get_buffer(q, i);
145085ced318ad drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 650
145085ced318ad drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 651 if (!vb)
145085ced318ad drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 652 continue;
145085ced318ad drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 653
145085ced318ad drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 654 vb2_queue_remove_buffer(vb);
145085ced318ad drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 655 kfree(vb);
e23ccc0ad92586 drivers/media/video/videobuf2-core.c Pawel Osciak 2010-10-11 656 }
e23ccc0ad92586 drivers/media/video/videobuf2-core.c Pawel Osciak 2010-10-11 657
6e57b95def5189 drivers/media/common/videobuf2/videobuf2-core.c Benjamin Gaignard 2023-09-27 658 if (!vb2_get_num_buffers(q)) {
ce4686702f8f56 drivers/media/common/videobuf/videobuf2-core.c Satendra Singh Thakur 2017-12-28 659 q->memory = VB2_MEMORY_UNKNOWN;
bd50d999d4d4f3 drivers/media/video/videobuf2-core.c Marek Szyprowski 2011-10-25 660 INIT_LIST_HEAD(&q->queued_list);
a7afcaccfab2fb drivers/media/v4l2-core/videobuf2-core.c Hans Verkuil 2014-02-24 661 }
e23ccc0ad92586 drivers/media/video/videobuf2-core.c Pawel Osciak 2010-10-11 662 }
e23ccc0ad92586 drivers/media/video/videobuf2-core.c Pawel Osciak 2010-10-11 663
diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 8d35cf7cef42..3bf455f03461 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -518,13 +518,12 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory, /* * __vb2_free_mem() - release all video buffer memory for a given queue */ -static void __vb2_free_mem(struct vb2_queue *q, unsigned int buffers) +static void __vb2_free_mem(struct vb2_queue *q, unsigned int start, unsigned int count) { - unsigned int buffer = 0; - long i = q->max_num_buffers; + unsigned int i; struct vb2_buffer *vb; - for (i = q->max_num_buffers; i >= 0 && buffer < buffers; i--) { + for (i = start; i < q->max_num_buffers && i < start + count; i++) { vb = vb2_get_buffer(q, i); if (!vb) continue; @@ -536,36 +535,32 @@ static void __vb2_free_mem(struct vb2_queue *q, unsigned int buffers) __vb2_buf_dmabuf_put(vb); else __vb2_buf_userptr_put(vb); - buffer++; } } /* - * __vb2_queue_free() - free buffers at the end of the queue - video memory and + * __vb2_queue_free() - free count buffers from start index of the queue - video memory and * related information, if no buffers are left return the queue to an * uninitialized state. Might be called even if the queue has already been freed. */ -static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) +static void __vb2_queue_free(struct vb2_queue *q, unsigned int start, unsigned int count) { - unsigned int buffer; - long i = q->max_num_buffers; + unsigned int i; lockdep_assert_held(&q->mmap_lock); /* Call driver-provided cleanup function for each buffer, if provided */ - for (i = q->max_num_buffers, buffer = 0; i >= 0 && buffer < buffers; i--) { + for (i = start; i < q->max_num_buffers && i < start + count; i++) { struct vb2_buffer *vb = vb2_get_buffer(q, i); if (!vb) continue; - if (vb->planes[0].mem_priv) { + if (vb->planes[0].mem_priv) call_void_vb_qop(vb, buf_cleanup, vb); - buffer++; - } } /* Release video buffer memory */ - __vb2_free_mem(q, buffers); + __vb2_free_mem(q, start, count); #ifdef CONFIG_VIDEO_ADV_DEBUG /* @@ -650,15 +645,14 @@ static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) #endif /* Free vb2 buffers */ - for (i = q->max_num_buffers, buffer = 0; i > 0 && buffer < buffers; i--) { - 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); if (!vb) continue; vb2_queue_remove_buffer(vb); kfree(vb); - buffer++; } if (!vb2_get_num_buffers(q)) { @@ -852,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_bufs); + __vb2_queue_free(q, 0, q_num_bufs); mutex_unlock(&q->mmap_lock); /* @@ -962,7 +956,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; } @@ -1102,7 +1096,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; } @@ -2568,7 +2562,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);