Received: by 10.223.176.5 with SMTP id f5csp2747568wra; Mon, 29 Jan 2018 03:22:10 -0800 (PST) X-Google-Smtp-Source: AH8x224m2/oi0uiOsFALN7h7z8xTU2IuLubNOxb9meqfa6Wv94GJvfmz62JYQXaexJpVJ6/OZwgp X-Received: by 2002:a17:902:6bca:: with SMTP id m10-v6mr21192582plt.351.1517224929948; Mon, 29 Jan 2018 03:22:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517224929; cv=none; d=google.com; s=arc-20160816; b=dnxdYYXgLbLPkhiu7M4TkD22x19+6rpjz95o2TWFHZX07HzW5OD2YjsKNDqA6DzXi3 i7aCW+y+Nve8eO1sGTvu0s8oKbZXQbqcgsl8sRMoTtlpbB8doFLAgMumHSvQAQwVGO3t Eo2Tjlwv4Gjdy6IjaDBltk3LlHpBZhGrfkdt6FVyyR/urCpii+Ex7va3ta/3bkxPcv12 Js59H/uL3HYTSNoUgSTTcG1O20isTWNx9f+lCAIaLWEToEyuk3AaSftWvXvrlwlmyVgV opGHK0b/e5z437O+CY+4qC+S6a1dHs+KrvoFt82p61QdlnnOlf4penbWhDE9BZzxsrI8 0wfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=zN9GDMz+Cbxcbc8Z9xJ1ZqDcGITfAC1j4vIvsSB8Sxo=; b=HVMiuLgx8scd+H4qYLYtAiEoagDeELQGpt3Uf50VXZdo0CqX8Kk8BUEHciQoz7Pd2K +PX0AsqZqJnvrEyQfhJf3sVqKf9vW3KEjjUeq35wRJ/eKMiDqrLhRNeeTIku5zWCWARV C1osCo7oVqXVm42E8lkiBk4lU+4yuvNKSXQoIoGywePd7aLSXcMH6EvjaSjKQK2ItP1d Sl4vfIEmK0ulcyzACfNTYbiwWjKc08mTI5YBmJwXPf15KdUYW+RzwSwMAIwJf+YRE8rS pJoImyWkHcWmZOHhfP9QtjiZzHCAjgRCfrAzh+uCqVxm6+fFYa5mgCu0pfgK2x+1Y6O8 skdg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f3si1212143pgu.546.2018.01.29.03.21.55; Mon, 29 Jan 2018 03:22:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751790AbeA2LVV (ORCPT + 99 others); Mon, 29 Jan 2018 06:21:21 -0500 Received: from lb1-smtp-cloud8.xs4all.net ([194.109.24.21]:36632 "EHLO lb1-smtp-cloud8.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751298AbeA2LVT (ORCPT ); Mon, 29 Jan 2018 06:21:19 -0500 Received: from [192.168.2.10] ([212.251.195.8]) by smtp-cloud8.xs4all.net with ESMTPA id g7UqethGVar0wg7Ute9H0E; Mon, 29 Jan 2018 12:21:17 +0100 Subject: Re: [RFC PATCH 0/8] [media] Request API, take three To: Alexandre Courbot , Mauro Carvalho Chehab , Laurent Pinchart , Pawel Osciak , Marek Szyprowski , Tomasz Figa , Sakari Ailus , Gustavo Padovan Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180126060216.147918-1-acourbot@chromium.org> From: Hans Verkuil Message-ID: Date: Mon, 29 Jan 2018 12:21:08 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20180126060216.147918-1-acourbot@chromium.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfOblEUc3MLNyYQz8zClI3YYI+R3coEs53+phHHlobl2OGC0PbgDAVCrPjx8kR5VXJfL6bcF3z/9SkWKXHvCJShFi4Ug33Ktu7UNzm92p1preHd1vPBDx SlY1M73fQw9lbQ6WnJfAuyrFsnGVliLXDWQ2Zv09+TwlpxnDBoy16tkehfgOMDjkKABu8d1cLXd5hmqTtlKgoepycZRfuF8ptMSF08nNSrT24YI8h7nhTSBq 78pySeuCI3UJm8kjYNptV7rLY/9me8DysfvkZQgE68aLtgWd/tLmoVZPQraBfYOFRgDFr8aY5y7MIQFwZ3XBEjut5rQGMyBJgzd4X7PLekzGNL35nE9T8l9w 5146G6RZw7g6NVdnbp88LLdR0YSklndgZLSgwLBLL/NqLC+0Eg2kOTHYJlYEoJbBfRSDDiTi6RAZdUy6BvGOKF2anW6aJk6tqbw1+StKFn5dG5CpppaWMAAK 8b1nH2b3xGOgvKQE Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/26/2018 07:02 AM, Alexandre Courbot wrote: > Howdy. Here is your bi-weekly request API redesign! ;) > > Again, this is a simple version that only implements the flow of requests, > without applying controls. The intent is to get an agreement on a base to work > on, since the previous versions went straight back to the redesign board. > > Highlights of this version: > > * As requested by Hans, request-bound buffers are now passed earlier to drivers, > as early as the request itself is submitted. Doing it earlier is not be useful > since the driver would not know the state of the request, and thus cannot do > anything with the buffer. Drivers are now responsible for applying request > parameters themselves. > > * As a consequence, there is no such thing as a "request queue" anymore. The > flow of buffers decides the order in which requests are processed. Individual > devices of the same pipeline can implement synchronization if needed, but this > is beyond this first version. > > * VB2 code is still a bit shady. Some of it will interfere with the fences > series, so I am waiting for the latter to land to do it properly. > > * Requests that are not yet submitted effectively act as fences on the buffers > they own, resulting in the buffer queue being blocked until the request is > submitted. An alternate design would be to only block the > not-submitted-request's buffer and let further buffers pass before it, but since > buffer order is becoming increasingly important I have decided to just block the > queue. This is open to discussion though. I don't think we should mess with the order. > > * Documentation! Also described usecases for codec and simple (i.e. not part of > a complex pipeline) capture device. I'll concentrate on reviewing that. > > Still remaining to do: > > * As pointed out by Hans on the previous revision, do not assume that drivers > using v4l2_fh have a per-handle state. I have not yet found a good way to > differenciate both usages. I suspect we need to add a flag or something for this. > * Integrate Hans' patchset for control handling: as said above, this is futile > unless we can agree on the basic design, which I hope we can do this time. > Chrome OS needs this really badly now and will have to move forward no matter > what, so I hope this will be considered good enough for a common base of work. I am not sure there is any reason to not move forward with the control handling. You need this anyway IMHO, regardless of any public API considerations. > A few thoughts/questions that emerged when writing this patchset: > > * Since requests are exposed as file descriptors, we could easily move the > MEDIA_REQ_CMD_SUBMIT and MEDIA_REQ_CMD_REININT commands as ioctls on the > requests themselves, instead of having to perform them on the media device that > provided the request in the first place. That would add a bit more flexibility > if/when passing requests around and means the media device only needs to handle > MEDIA_REQ_CMD_ALLOC. Conceptually speaking, this seems to make sense to me. > Any comment for/against that? Makes sense IMHO. > * For the codec usecase, I have experimented a bit marking CAPTURE buffers with > the request FD that produced them (vim2m acts that way). This seems to work > well, however FDs are process-local and could be closed before the CAPTURE > buffer is dequeued, rendering that information less meaningful, if not > dangerous. I don't follow this. Once the fd is passed to the kernel its refcount should be increased so the data it represents won't be released if userspace closes the fd. Obviously if userspace closes the fd it cannot do anything with it anymore, but it shouldn't be 'dangerous' AFAICT. > Wouldn't it be better/safer to use a global request ID for > such information instead? That ID would be returned upon MEDIA_REQ_CMD_ALLOC so > user-space knows which request ID a FD refers to. I think it is not a good idea to have both an fd and an ID to refer to the same object. That's going to be very confusing I think. > * Using the media node to provide requests makes absolute sense for complex > camera devices, but is tedious for codec devices which work on one node and > require to protect request/media related code with #ifdef > CONFIG_MEDIA_CONTROLLER. Why? They would now depend on MEDIA_CONTROLLER (i.e. they won't appear in the menuconfig unless MEDIA_CONTROLLER is set). No need for an #ifdef. For these devices, the sole role of the media node is > to produce the request, and that's it (since request submission could be moved > to the request FD as explained above). That's a modest use that hardly justifies > bringing in the whole media framework IMHO. With a bit of extra abstraction, it > should be possible to decouple the base requests from the media controller > altogether, and propose two kinds of requests implementations: one simpler > implementation that works directly with a single V4L2 node (useful for codecs), > and another one that works on a media node and can control all its entities > (good for camera). This would allow codecs to use the request API without > forcing the media controller, and would considerably simplify the use-case. Any > objection to that? IIRC the earlier design documents mentioned this possibility. I think this is an interesting idea, but I would postpone making a decision on this until later. We need this MC support regardless, so let's start off with that. Once that's working we can discuss if we should or should not create a shortcut for codecs. Trying to decide this now would only confuse the process. Regards, Hans > > Alexandre Courbot (6): > media: add request API core and UAPI > media: videobuf2: add support for requests > media: vb2: add support for requests in QBUF ioctl > v4l2: document the request API interface > media: vim2m: add media device > media: vim2m: add request support > > Hans Verkuil (1): > videodev2.h: Add request field to v4l2_buffer > > Laurent Pinchart (1): > media: Document the media request API > > Documentation/media/uapi/mediactl/media-funcs.rst | 1 + > .../media/uapi/mediactl/media-ioc-request-cmd.rst | 140 ++++++++++ > Documentation/media/uapi/v4l/buffer.rst | 10 +- > Documentation/media/uapi/v4l/common.rst | 1 + > Documentation/media/uapi/v4l/request-api.rst | 194 +++++++++++++ > Documentation/media/uapi/v4l/vidioc-qbuf.rst | 21 ++ > drivers/media/Makefile | 3 +- > drivers/media/media-device.c | 7 + > drivers/media/media-request-mgr.c | 107 +++++++ > drivers/media/media-request.c | 308 +++++++++++++++++++++ > drivers/media/platform/vim2m.c | 55 ++++ > drivers/media/usb/cpia2/cpia2_v4l.c | 2 +- > drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 7 +- > drivers/media/v4l2-core/v4l2-ioctl.c | 85 +++++- > drivers/media/v4l2-core/videobuf2-core.c | 125 ++++++++- > drivers/media/v4l2-core/videobuf2-v4l2.c | 31 ++- > include/media/media-device.h | 3 + > include/media/media-request-mgr.h | 73 +++++ > include/media/media-request.h | 184 ++++++++++++ > include/media/videobuf2-core.h | 15 +- > include/media/videobuf2-v4l2.h | 2 + > include/uapi/linux/media.h | 10 + > include/uapi/linux/videodev2.h | 3 +- > 23 files changed, 1365 insertions(+), 22 deletions(-) > create mode 100644 Documentation/media/uapi/mediactl/media-ioc-request-cmd.rst > create mode 100644 Documentation/media/uapi/v4l/request-api.rst > create mode 100644 drivers/media/media-request-mgr.c > create mode 100644 drivers/media/media-request.c > create mode 100644 include/media/media-request-mgr.h > create mode 100644 include/media/media-request.h >