Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2131018yba; Fri, 19 Apr 2019 12:46:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwg8asxc2yBAN0QAtHhKoyGREpmQrJs4SzZn/AF8JcRKR5DcdKSCK3YOAKoQaklmbNhh4o X-Received: by 2002:a17:902:e990:: with SMTP id ct16mr3569471plb.35.1555703160053; Fri, 19 Apr 2019 12:46:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555703160; cv=none; d=google.com; s=arc-20160816; b=uoT906X3dcDRioZK0KqWnYiXzS049Y4RyVxcmPL6ZHhK/M/N13qXTv51/KN6xQ2pl3 jDoFl3nxE3rivyHGn/2CF6AhaAS0E7Tea8IHzCg39jT/d7O+LQ3hkAJh3EJZ9GrvBDQA n4sYl6X9ZC9f5iNd73tFJb0+ORy9Tv2YGiXRswCpwS8TJ2Rs5+SepAejR5jYC2rI5yFn YZXy7ihy/7jKMPwHK3AZffotsMzndE01N47VODTqF1LT85dKBOiwkBhE1+h1syTGawSJ spH/UIokL7V0YaVGmj2aJcIUdyBPRG0o9NXETWOQT0TOZ+1yj+HTYzeWkQzBfbgBb081 7ZmQ== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=clo+kiAhMVtl/eXKgiPzSD53WQkhiMDT1nX2jh5dhLg=; b=EQIbqf+qRgPwC6l6R5cDNvc8muAXRVySrBV73YlFcs+LR6GZQh91kB5FbR0iIyBj4j 4vz39lIAF/CMkdNQLaV1zBa+2awET7uBkrkdhVohem7WSv8htUvGlkF3XhOTmsPTG25k Z2zR8Le1C1HLjWyimSlqKKX/5O0rtsO27ETpsxh5AwpYyMgEB9lUzkdJ44I7+sWqgioi yFGzDNpt+PcefmIqR19wJ4wKCLFArcM/yXUnPNrVIoOj5L3M0e81gZCN+l5JaOOfkqVh xfLYHt8x6cgmPsWOET4cBDecULe0j0SLgJjzlBBa7fVJKDdkngJgBUl3gRgLv7if2k43 fPOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="JWLF/zTS"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o32si6299342pld.190.2019.04.19.12.45.44; Fri, 19 Apr 2019 12:46:00 -0700 (PDT) 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; dkim=pass header.i=@chromium.org header.s=google header.b="JWLF/zTS"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727595AbfDSTol (ORCPT + 99 others); Fri, 19 Apr 2019 15:44:41 -0400 Received: from mail-ot1-f52.google.com ([209.85.210.52]:44576 "EHLO mail-ot1-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726673AbfDSTol (ORCPT ); Fri, 19 Apr 2019 15:44:41 -0400 Received: by mail-ot1-f52.google.com with SMTP id d24so2368478otl.11 for ; Fri, 19 Apr 2019 12:44:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=clo+kiAhMVtl/eXKgiPzSD53WQkhiMDT1nX2jh5dhLg=; b=JWLF/zTSOG3UTQfuwm4tf+fo9Z+oPu/GOCm+KykhNMfrnav0ThzdWKqtu47jK+qUyL NLcyYXL2YHXwx54wNOYo9MJRGbOv5lrDAZNYxTc/d5lw2lokla3/lIhiQCgDdMeykcOb WiuXHcn6KgN9NvaN30qIOzhXDCy89Nl7CeMLA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=clo+kiAhMVtl/eXKgiPzSD53WQkhiMDT1nX2jh5dhLg=; b=lS3Y1lKslNKqXGRA7Zbcs2XFWw0CTaJ5RMafD2FiLsglYXuSx2iftFDQnyg7k6P9zz vaVq3D7nMD05TEHj1vdcECuVYX03qFaw5LDCCXAG3yLU97LMYgPlxqSgjNEBb2ZraXuL RJBMxUHi5F0mOTWZISNOzgor1m2y/5OgV3EMXVGQv5IP0MwZ1s468jsMbeoaxC62LZkL 2XjZFW/n6GnRQuxUTFKbvpiHeRFLnHFf3PhccX/BytRSPiqIKXp8BgKH3Ht34XIMx+/X 4s9Lc2e4p+eSOMItM2U1nwhM7KFXhj4ErDB6PX5UZwsAPA6tk8UUaAcN9SGVZxdhubGz zHqg== X-Gm-Message-State: APjAAAXRAXTGfKl0+iHiSED0TJmYlKdeI/wbIG36HtWREC92RtQXamwA p7QpPpM0y2RHH+ttIhZ7FLRAUiKte+Q= X-Received: by 2002:a9d:62d4:: with SMTP id z20mr936319otk.299.1555648049754; Thu, 18 Apr 2019 21:27:29 -0700 (PDT) Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com. [209.85.210.46]) by smtp.gmail.com with ESMTPSA id f90sm1528905otb.54.2019.04.18.21.27.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Apr 2019 21:27:28 -0700 (PDT) Received: by mail-ot1-f46.google.com with SMTP id k21so3508721otf.1 for ; Thu, 18 Apr 2019 21:27:28 -0700 (PDT) X-Received: by 2002:a05:6830:15d4:: with SMTP id j20mr902735otr.367.1555648047603; Thu, 18 Apr 2019 21:27:27 -0700 (PDT) MIME-Version: 1.0 References: <0df3d4b5178d8a37b67b275e0771741c6c268de3.camel@bootlin.com> <20190418081816.GO13337@phenom.ffwll.local> <8265f098722d0cd5aae606d7ee6d955f168ac8f3.camel@ndufresne.ca> In-Reply-To: <8265f098722d0cd5aae606d7ee6d955f168ac8f3.camel@ndufresne.ca> From: Tomasz Figa Date: Fri, 19 Apr 2019 13:27:15 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Support for 2D engines/blitters in V4L2 and DRM To: Nicolas Dufresne Cc: Daniel Vetter , Paul Kocialkowski , Linux Kernel Mailing List , Alexandre Courbot , Maxime Ripard , Hans Verkuil , Mauro Carvalho Chehab , Linux Media Mailing List , dri-devel , Thomas Petazzoni , Eric Anholt , Rob Clark , Dave Airlie , Maarten Lankhorst Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 19, 2019 at 9:30 AM Nicolas Dufresne wro= te: > > Le jeudi 18 avril 2019 =C3=A0 10:18 +0200, Daniel Vetter a =C3=A9crit : > > > It would be cool if both could be used concurrently and not just retu= rn > > > -EBUSY when the device is used with the other subsystem. > > > > We live in this world already :-) I think there's even patches (or merg= ed > > already) to add fences to v4l, for Android. > > This work is currently suspended. It will require some feature on DRM > display to really make this useful, but there is also a lot of > challanges in V4L2. In GFX space, most of the use case are about > rendering as soon as possible. Though, in multimedia we have two > problems, we need to synchronize the frame rendering with the audio, > and output buffers may comes out of order due to how video CODECs are > made. > > In the first, we'd need a mechanism where we can schedule a render at a > specific time or vblank. We can of course already implement this in > software, but with fences, the scheduling would need to be done in the > driver. Then if the fence is signalled earlier, the driver should hold > on until the delay is met. If the fence got signalled late, we also > need to think of a workflow. As we can't schedule more then one render > in DRM at one time, I don't really see yet how to make that work. > > For the second, it's complicated on V4L2 side. Currently we signal > buffers when they are ready in the display order. With fences, we > receive early pairs buffer and fence (in decoding order). There exist > cases where reordering is done by the driver (stateful CODEC). We > cannot schedule these immediately we would need a new mechanism to know > which one come next. If we just reuse current mechnism, it would void > the fence usage since the fence will always be signalled by the time it > reaches DRM or other v4l2 component. > > There also other issues, for video capture pipeline, if you are not > rendering ASAP, you need the HW timestamp in order to schedule. Again, > we'd get the fence early, but the actual timestamp will be signalled at > the very last minutes, so we also risk of turning the fence into pure > overhead. Note that as we speak, I have colleagues who are > experimenting with frame timestamp prediction that slaves to the > effective timestamp (catching up over time). But we still have issues > when the capture driver skipped a frame (missed a capture window). Note that a fence has a timestamp internally and it can be queried for it from the user space if exposed as a sync file: https://elixir.bootlin.com/linux/v5.1-rc5/source/drivers/dma-buf/sync_file.= c#L386 Fences in V4L2 would be also useful for stateless decoders and any mem-to-mem processors that operate in order, like the blitters mentioned here or actually camera ISPs, which can be often chained into relatively sophisticated pipelines. Best regards, Tomasz