Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2385424rdh; Wed, 27 Sep 2023 00:26:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFRufc8X8j314ZUgHQcvmfd33J47h+WqQIGCf8PKQO483KxXpCixzhx9Tg+3VOs5pZ9U0KA X-Received: by 2002:a17:902:d50e:b0:1c5:59dc:6e93 with SMTP id b14-20020a170902d50e00b001c559dc6e93mr2225895plg.3.1695799583858; Wed, 27 Sep 2023 00:26:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695799583; cv=none; d=google.com; s=arc-20160816; b=reIz8BXQIevVhWu6sJiV20xxCGScRJs2tgtjIUVZdd+USvX39orMJVu+3pn3fzgfEc hOP+WSehXwXWF/Daq4iAHcXqAnXkudykqvHHyRmzaQv0vZvLwEvwEytBR/YnI1bJGRhc FLH4K1gIkDXIH/lhV2aDT4Xy+vxd6kkUlxine3mJLEsn69mIBPsMk9gAL+OFDseQHT1v a2Gs3jdBbVYruBxg4gZ+hNlunxiGkOYKlwtFKQb5eC+lCOsqKWDqDAg3TsKJBbelt2Vf gQhVuVMMc3p8m67HedjVcthFAjRkY27HRDrffPsCD2HFO+zOdljSaH+6rII1tnLcWfTt KJng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:autocrypt :from:references:cc:to:content-language:subject:user-agent :mime-version:date:message-id; bh=gCKi03yeYTJTFAFsdu7pYitvjiHMF2fgPyXmTcyB17E=; fh=k8AVfwGmOKwkJ5F9dcsppgirGKZIcQCNz9R6zXXx/AQ=; b=tdue2BQY6Hb3bfffS4lcVfaPt6exyMpkcRJPOpf8vPbZf6as3fV7dg84KmHAHbFY+F jpaaREkI16yJmokieEh2GK0AFN4MdKx8qaEu/ETx0i9yjzIl+gOkIAWCsA3Wryq1sM4p WS5UxjhZQY0lDl9qwkqXdV/sSUk6LgoyH3bTFZH99NhVxFCjcPR+S5tJ8+8lq0FrqjYQ OimAQEURVptyy6DK2Cpc1oriKUwzn3Wqbn9R10W7klktbL3b+VXa48/vK9AoDxcsdBAk wVfqI78JAblSFgTPbk8WpKSdg1h8Ey7FNXaTWRDdHHeeGSx9HRQ1EDnCzoUJIzKZ5I23 Mh+Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id s1-20020a170903200100b001c62139b16esi5740465pla.4.2023.09.27.00.26.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 00:26:23 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 4104F812D203; Wed, 27 Sep 2023 00:20:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229972AbjI0HT5 (ORCPT + 99 others); Wed, 27 Sep 2023 03:19:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229499AbjI0HTz (ORCPT ); Wed, 27 Sep 2023 03:19:55 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9453E12A; Wed, 27 Sep 2023 00:19:52 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F389C433C7; Wed, 27 Sep 2023 07:19:48 +0000 (UTC) Message-ID: Date: Wed, 27 Sep 2023 09:19:46 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v12 5/7] media: chips-media: wave5: Add the v4l2 layer Content-Language: en-US, nl To: Nicolas Dufresne , Sebastian Fricke , Mauro Carvalho Chehab , Nas Chung , Sascha Hauer , Fabio Estevam , Rob Herring , Shawn Guo , Philipp Zabel , Jackson Lee , Krzysztof Kozlowski , NXP Linux Team , Conor Dooley , Pengutronix Kernel Team , Benjamin Gaignard Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Robert Beckett , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@collabora.com References: <20230915-wave5_v12_on_media_master-v12-0-92fc66cd685d@collabora.com> <20230915-wave5_v12_on_media_master-v12-5-92fc66cd685d@collabora.com> <7b159731dfbc2ab8243396eaec8f41be10af5160.camel@collabora.com> <6ae8a639-b9f5-4426-be49-5340a8b8b5e9@xs4all.nl> <330a177320fd766af8eddb76f57ea728b2e36afe.camel@collabora.com> From: Hans Verkuil Autocrypt: addr=hverkuil@xs4all.nl; keydata= xsFNBFQ84W0BEAC7EF1iL4s3tY8cRTVkJT/297h0Hz0ypA+ByVM4CdU9sN6ua/YoFlr9k0K4 BFUlg7JzJoUuRbKxkYb8mmqOe722j7N3HO8+ofnio5cAP5W0WwDpM0kM84BeHU0aPSTsWiGR yw55SOK2JBSq7hueotWLfJLobMWhQii0Zd83hGT9SIt9uHaHjgwmtTH7MSTIiaY6N14nw2Ud C6Uykc1va0Wqqc2ov5ihgk/2k2SKa02ookQI3e79laOrbZl5BOXNKR9LguuOZdX4XYR3Zi6/ BsJ7pVCK9xkiVf8svlEl94IHb+sa1KrlgGv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ugTMOhq1BG62vUm/F6V91+unyp4dRlyryAeqEuISykhvjZCVHk/woaMZv c1Dm4Uvkv0Ilelt3Pb9J7zhcx6sm5T7v16VceF96jG61bnJ2GFS+QZerZp3PY27XgtPxRxYj AmFUeF486PHx/2Yi4u1rQpIpC5inPxIgR1+ZFvQrAV36SvLFfuMhyCAxV6WBlQc85ArOiQZB Wm7L0repwr7zEJFEkdy8C81WRhMdPvHkAIh3RoY1SGcdB7rB3wCzfYkAuCBqaF7Zgfw8xkad KEiQTexRbM1sc/I8ACpla3N26SfQwrfg6V7TIoweP0RwDrcf5PVvwSWsRQp2LxFCkwnCXOra gYmkrmv0duG1FStpY+IIQn1TOkuXrciTVfZY1cZD0aVxwlxXBnUNZZNslldvXFtndxR0SFat sflovhDxKyhFwXOP0Rv8H378/+14TaykknRBIKEc0+lcr+EMOSUR5eg4aURb8Gc3Uc7fgQ6q UssTXzHPyj1hAyDpfu8DzAwlh4kKFTodxSsKAjI45SLjadSc94/5Gy8645Y1KgBzBPTH7Q== In-Reply-To: <330a177320fd766af8eddb76f57ea728b2e36afe.camel@collabora.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,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]); Wed, 27 Sep 2023 00:20:01 -0700 (PDT) On 27/09/2023 01:29, Nicolas Dufresne wrote: > Le vendredi 22 septembre 2023 à 09:33 +0200, Hans Verkuil a écrit : >> On 21/09/2023 21:11, Nicolas Dufresne wrote: >>> Le mercredi 20 septembre 2023 à 17:13 +0200, Hans Verkuil a écrit : >>>> On 15/09/2023 23:11, Sebastian Fricke wrote: >>>>> From: Nas Chung >>>>> >>>>> 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: 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 | 196 ++ >>>>> .../platform/chips-media/wave5/wave5-helper.h | 30 + >>>>> .../platform/chips-media/wave5/wave5-vpu-dec.c | 1965 ++++++++++++++++++++ >>>>> .../platform/chips-media/wave5/wave5-vpu-enc.c | 1825 ++++++++++++++++++ >>>>> .../media/platform/chips-media/wave5/wave5-vpu.c | 331 ++++ >>>>> .../media/platform/chips-media/wave5/wave5-vpu.h | 83 + >>>>> 10 files changed, 4454 insertions(+) >>>>> >> >> >> >>>>> +static int wave5_vpu_dec_set_eos_on_firmware(struct vpu_instance *inst) >>>>> +{ >>>>> + int ret; >>>>> + >>>>> + ret = wave5_vpu_dec_update_bitstream_buffer(inst, 0); >>>>> + if (ret) { >>>>> + dev_err(inst->dev->dev, >>>>> + "Setting EOS for the bitstream, fail: %d\n", ret); >>>> >>>> Is this an error due to a driver problem, or because a bad bitstream is >>>> fed from userspace? In the first case, dev_err would be right, in the >>>> second dev_dbg would be more appropriate. Bad userspace input should not >>>> spam the kernel log in general. >>> >>> Its the first. To set the EOS flag, a command is sent to the firmware. That >>> command may never return (timeout) or may report an error. For this specific >>> command, if that happens we are likely facing firmware of driver problem (or >>> both). >> >> OK, I'd add that as a comment here as this is unexpected behavior. >> >>> >>>> >>>>> + return ret; >>>>> + } >>>>> + return 0; >>>>> +} >> >> >> >>>>> +static int wave5_vpu_dec_create_bufs(struct file *file, void *priv, >>>>> + struct v4l2_create_buffers *create) >>>>> +{ >>>>> + struct v4l2_format *f = &create->format; >>>>> + >>>>> + if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) >>>>> + return -ENOTTY; >>>> >>>> Huh? Why is this needed? >>> >>> Minimally a comment should be added. The why is that we support CREATE_BUF for >>> OUTPUT queue (bitstream) but not for CAPTURE queues. This is simply not >>> supported by Wave5 firmware. Do you have any suggestion how this asymmetry can >>> be implemented better ? >> >> Certainly not with ENOTTY: the ioctl exists, it is just not supported for >> CAPTURE queues. >> >> How about -EPERM? And document this error as well in the VIDIOC_CREATE_BUFS >> documentation. And you want a dev_dbg here too. > > The suggestion cannot be used since there is documentation for that one already, > and it does not match "unsupported". > > "Permission denied. Can be returned if the device needs write permission, or > some special capabilities is needed (e. g. root)" > > What about using the most logical error code, which name is actually obvious, > like ENOTSUP ? > > #define ENOTSUPP 524 /* Operation is not supported */ > Let's go with EOPNOTSUPP. That seems to be the more commonly used error code in drivers. >> >> So I would propose that EPERM is returned if CREATE_BUFS is only supported >> for for one of the two queues of an M2M device. > > Note that userspace does not care of the difference between an ioctl not being > implemented at all or not being implement for one queue. GStreamer have been > testing with both queue type for couple of years now. Adding this distinction is > just leaking an implementation details to userspace. I'm fine to just do what > you'd like, just stating the obvious that while it may look logical inside the > kernel, its a bit of a non-sense for our users. I don't agree with that. If an ioctl returns ENOTTY, then userspace can be certain that that ioctl is not implemented for the given file descriptor. That's not the case here: it is implemented, the operation is just not supported for one of the queues. Regards, Hans