Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp524697rdb; Thu, 2 Nov 2023 10:08:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGsFq+YjvGIIbTQh9Glis16461EFX3/ehB6iGPoyLo+Gbe/JacMh+9uKMt4ll2/3yAnSibP X-Received: by 2002:aa7:8881:0:b0:691:2d4:23b2 with SMTP id z1-20020aa78881000000b0069102d423b2mr18186765pfe.15.1698944917177; Thu, 02 Nov 2023 10:08:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698944917; cv=none; d=google.com; s=arc-20160816; b=Dw4xIIiEjcPivgw9IJPBliWbWZfGR6uLtIWLQtEzWtYpL/81oDBAav8IeLKERx7grC FTLxEWcPHLAkzh8ocxEptJOESb3urGLLb53pgqlzOrNzPvAc7oSJcEd6boLTgUDunUPG vFgGUl5wuEKbYIoWVdOZ5CNbBjv7qIp4Wqrx06cjbYD8Uzdd1pL/zciQ/vq24LdvBpBk b+TpOhjL4ClnlJkGa8uFSuKuwD64+1JTKumGVB9SAufgkjmG4JXk1vzBMjyupPxqSnh3 xyxM01zbyfdWtPCHcYNfatGsgav2xdsIN5igaE2h0P3PqdR6LcoXEk5LpG3Cn1Mu4bVM Xkug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=LnJYOQd6ZWtQ8OmdCJI/7G7dnTaQS5XpnkK5hEvAsNE=; fh=AyQkfapzAQXYdPK55V9tLJLdPA06YiJuBBoF+2JnIh8=; b=0Yk8vFF22oBEsuG9va8RRz6QOSrnWznvrtvlP6RQq5x11rZWau+jmNtwYf9truw+p5 Oox2PfUJyvvwF7p924csItxC2DrJw4lsXpJWPZKdul7a6AtdsvFJcP5joFHBdwW1T0km K3THQeLd6fYe8nvPZhgWO22N72rRDqDlarF2bNnO//qvMc5dLEtyIEKJPmGzDctehPkT 5TVkKd44AkHYldnhNqQqRjsyuyMZ0twjnvp7UUrbo6lQ+b0dZUs8qXDcz/JtvG91GVjD fDtq+1znvoPd/m5F9s9JnKec/dk0l1X/JumdrWVX30FrhIMjLqbrnqAadGZ3fj95SIU/ BYYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="X/cjBjLW"; 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 Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id ca26-20020a056a00419a00b00690228b1d45si4582pfb.342.2023.11.02.10.08.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 10:08:37 -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="X/cjBjLW"; 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 B930C807EDA8; Thu, 2 Nov 2023 10:08: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 S1377119AbjKBRIM (ORCPT + 99 others); Thu, 2 Nov 2023 13:08:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235577AbjKBRIL (ORCPT ); Thu, 2 Nov 2023 13:08:11 -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 80673184; Thu, 2 Nov 2023 10:08:05 -0700 (PDT) Received: from localhost (ec2-34-240-57-77.eu-west-1.compute.amazonaws.com [34.240.57.77]) (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: dbrouwer) by madras.collabora.co.uk (Postfix) with ESMTPSA id 3150B6601711; Thu, 2 Nov 2023 17:08:03 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1698944883; bh=HxO1+U33MO4A8FHmVRIQuTTtZl2QLDqDP44tUmlEqLg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=X/cjBjLWdF2rvfRRwrSOh4XeD8IkoYQ3GQEEXemVEdjGkJBf0801QkQRy177yhwyF mtOBmmTwzHCdrWIew0+Fj2tHD7vKFaaof8dPy5Ro9QXGR4sO2/3iI6RQFT1ozMd2Ve a/s7lWBzTyjnuojkQVgIdMfFy5jmK4n+3OlrIZNOtqqNuuXFRvjaQxmK/8E4yT22ck kS5LSFm/RwkD+UIcSOo3KULkhtmBMaziHpxlgG3LSeOXDSEi9luUVNk4Y7prJlqwL7 QFAlMw5Zz3YRC7Ncu1Z55g20bjtjxCqF6hw+qUPiNi9QKSiVO41muOswBrmYf8pY6v adn7Luw0ekCzw== Date: Thu, 2 Nov 2023 10:07:59 -0700 From: Deborah Brouwer To: Ivan Bornyakov Cc: Sebastian Fricke , Krzysztof Kozlowski , NXP Linux Team , Conor Dooley , Mauro Carvalho Chehab , Jackson Lee , Hans Verkuil , Sascha Hauer , Rob Herring , Pengutronix Kernel Team , Shawn Guo , Philipp Zabel , Nas Chung , Fabio Estevam , linux-media@vger.kernel.org, Tomasz Figa , linux-kernel@vger.kernel.org, Nicolas Dufresne , kernel@collabora.com, Robert Beckett , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Darren Etheridge Subject: Re: [PATCH v13 5/8] media: chips-media: wave5: Add the v4l2 layer Message-ID: References: <20230929-wave5_v13_media_master-v13-5-5ac60ccbf2ce@collabora.com> <20231017221359.20164-1-brnkv.i1@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231017221359.20164-1-brnkv.i1@gmail.com> 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, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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, 02 Nov 2023 10:08:14 -0700 (PDT) On Wed, Oct 18, 2023 at 01:13:52AM +0300, Ivan Bornyakov wrote: > Hi! Hi Ivan, > > On Thu, 12 Oct 2023 13:01:03 +0200, Sebastian Fricke wrote: > > Add the decoder and encoder implementing the v4l2 > > API. This patch also adds the Makefile and the VIDEO_WAVE_VPU config > > > > Signed-off-by: Sebastian Fricke > > Signed-off-by: Nicolas Dufresne > > Signed-off-by: Deborah Brouwer > > Signed-off-by: Robert Beckett > > Signed-off-by: Dafna Hirschfeld > > Signed-off-by: Nas Chung > > --- > > drivers/media/platform/chips-media/Kconfig | 1 + > > drivers/media/platform/chips-media/Makefile | 1 + > > drivers/media/platform/chips-media/wave5/Kconfig | 12 + > > drivers/media/platform/chips-media/wave5/Makefile | 10 + > > .../platform/chips-media/wave5/wave5-helper.c | 213 +++ > > .../platform/chips-media/wave5/wave5-helper.h | 31 + > > .../platform/chips-media/wave5/wave5-vpu-dec.c | 1953 ++++++++++++++++++++ > > .../platform/chips-media/wave5/wave5-vpu-enc.c | 1794 ++++++++++++++++++ > > .../media/platform/chips-media/wave5/wave5-vpu.c | 291 +++ > > .../media/platform/chips-media/wave5/wave5-vpu.h | 83 + > > .../platform/chips-media/wave5/wave5-vpuapi.h | 2 - > > 11 files changed, 4389 insertions(+), 2 deletions(-) > > [...] > > > diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c > > new file mode 100644 > > index 000000000000..74d1fae64fa4 > > --- /dev/null > > +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c > > [...] > > > +static int wave5_vpu_dec_queue_setup(struct vb2_queue *q, unsigned int *num_buffers, > > + unsigned int *num_planes, unsigned int sizes[], > > + struct device *alloc_devs[]) > > +{ > > + struct vpu_instance *inst = vb2_get_drv_priv(q); > > + struct v4l2_pix_format_mplane inst_format = > > + (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) ? inst->src_fmt : inst->dst_fmt; > > + unsigned int i; > > + > > + dev_dbg(inst->dev->dev, "%s: num_buffers: %u | num_planes: %u | type: %u\n", __func__, > > + *num_buffers, *num_planes, q->type); > > + > > + /* the CREATE_BUFS case */ > > + if (*num_planes) { > > + if (inst_format.num_planes != *num_planes) > > + return -EINVAL; > > + > > + for (i = 0; i < *num_planes; i++) { > > + if (sizes[i] < inst_format.plane_fmt[i].sizeimage) > > + return -EINVAL; > > + } > > + /* the REQBUFS case */ > > + } else { > > + *num_planes = inst_format.num_planes; > > + > > + if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { > > + sizes[0] = inst_format.plane_fmt[0].sizeimage; > > + dev_dbg(inst->dev->dev, "%s: size[0]: %u\n", __func__, sizes[0]); > > + } else if (*num_planes == 1) { > > I think, you should also set *num_buffers to be inst->fbc_buf_count for > V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, like this: > > } else if (q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { > if (*num_buffers < inst->fbc_buf_count) > *num_buffers = inst->fbc_buf_count; > > switch (*num_planes) { > case 1: > ... > case 2: > ... > case 3: > ... > } > } I was able to reproduce this issue by requesting a small number of buffers on the CAPTURE queue that was less than inst→fbc_buf_count. When this happens, wave5_vpu_dec_job_ready() fails here: (v4l2_m2m_num_dst_bufs_ready(m2m_ctx) < (inst->fbc_buf_count - 1) I also tested your suggestion to set the *num_buffers to inst→fbc_buf_count in queue_setup() and it seems to be working well, thanks for this. I've been working on ways to improve testing for stateful decoders so I'm curious how you found this issue? With fluster tests that we use, gstreamer seems to be calculating correct number of CAPTURE buffers to request, so we wouldn't see this. > > The reason for that is if fbc_buf_count is greater than initial num_buffers, > wave5_vpu_dec_job_ready() wouldn't allow to invoke wave5_vpu_dec_device_run() > > Here is a part of the log of described situation: > > vdec 20410000.wave515: Switch state from NONE to OPEN. > [...] > vdec 20410000.wave515: wave5_vpu_dec_init_seq: init seq sent (queue 1 : 1) > vdec 20410000.wave515: wave5_vpu_dec_get_seq_info: init seq complete (queue 0 : 0) > [...] > vdec 20410000.wave515: handle_dynamic_resolution_change: width: 4112 height: 3008 profile: 1 | minbuffer: 6 > ^^^^^^^^ note that minbuffer is 6 > > vdec 20410000.wave515: Switch state from OPEN to INIT_SEQ. > [...] > vdec 20410000.wave515: decoder command: 1 > [...] > vdec 20410000.wave515: wave5_vpu_dec_queue_setup: num_buffers: 4 | num_planes: 0 | type: 9 > ^^^^^^^^ note that num_buffers is 4 > > vdec 20410000.wave515: wave5_vpu_dec_queue_setup: size[0]: 18625536 > vdec 20410000.wave515: CAPTURE queue must be streaming to queue jobs! > vdec 20410000.wave515: CAPTURE queue must be streaming to queue jobs! > vdec 20410000.wave515: CAPTURE queue must be streaming to queue jobs! > vdec 20410000.wave515: CAPTURE queue must be streaming to queue jobs! > vdec 20410000.wave515: wave5_vpu_dec_buf_queue: type: 9 index: 0 size: ([0]=18625536, [1]= 0, [2]= 0) > vdec 20410000.wave515: wave5_vpu_dec_buf_queue: type: 9 index: 1 size: ([0]=18625536, [1]= 0, [2]= 0) > vdec 20410000.wave515: wave5_vpu_dec_buf_queue: type: 9 index: 2 size: ([0]=18625536, [1]= 0, [2]= 0) > vdec 20410000.wave515: wave5_vpu_dec_buf_queue: type: 9 index: 3 size: ([0]=18625536, [1]= 0, [2]= 0) > vdec 20410000.wave515: wave5_vpu_dec_start_streaming: type: 9 > vdec 20410000.wave515: No capture buffer ready to decode! > ^^^^^^^^ here v4l2_m2m_num_dst_bufs_ready(m2m_ctx) < (inst->fbc_buf_count - 1), namely 4 < 6 > > vdec 20410000.wave515: wave5_vpu_dec_stop_streaming: type: 9 > vdec 20410000.wave515: streamoff_capture: Setting display flag of buf index: 0, fail: -22 > vdec 20410000.wave515: streamoff_capture: Setting display flag of buf index: 1, fail: -22 > vdec 20410000.wave515: streamoff_capture: Setting display flag of buf index: 2, fail: -22 > vdec 20410000.wave515: streamoff_capture: Setting display flag of buf index: 3, fail: -22 > [...] > vdec 20410000.wave515: wave5_vpu_dec_close: dec_finish_seq complete > > Altering num_buffers solves the issue for me. > > > + if (inst->output_format == FORMAT_422) > > + sizes[0] = inst_format.width * inst_format.height * 2; > > + else > > + sizes[0] = inst_format.width * inst_format.height * 3 / 2; > > + dev_dbg(inst->dev->dev, "%s: size[0]: %u\n", __func__, sizes[0]); > > + } else if (*num_planes == 2) { > > + sizes[0] = inst_format.width * inst_format.height; > > + if (inst->output_format == FORMAT_422) > > + sizes[1] = inst_format.width * inst_format.height; > > + else > > + sizes[1] = inst_format.width * inst_format.height / 2; > > + dev_dbg(inst->dev->dev, "%s: size[0]: %u | size[1]: %u\n", > > + __func__, sizes[0], sizes[1]); > > + } else if (*num_planes == 3) { > > + sizes[0] = inst_format.width * inst_format.height; > > + if (inst->output_format == FORMAT_422) { > > + sizes[1] = inst_format.width * inst_format.height / 2; > > + sizes[2] = inst_format.width * inst_format.height / 2; > > + } else { > > + sizes[1] = inst_format.width * inst_format.height / 4; > > + sizes[2] = inst_format.width * inst_format.height / 4; > > + } > > + dev_dbg(inst->dev->dev, "%s: size[0]: %u | size[1]: %u | size[2]: %u\n", > > + __func__, sizes[0], sizes[1], sizes[2]); > > + } > > + } > > + > > + return 0; > > +} > > BTW I'm currently tinkering with your patchset on another C&M IP and would be > gratefull if you Cc me in the future versions of the patchset, if any. Yes, sorry for missing you on v13, thanks for taking the time to review. Deborah > > Thanks.