Received: by 10.223.164.202 with SMTP id h10csp1021613wrb; Fri, 17 Nov 2017 12:31:24 -0800 (PST) X-Google-Smtp-Source: AGs4zMYUpdnpZyrupUh4g2xNqbQs3OnxGGGr7CxqB4PNJNu98caiIAIWGFXBpgXcXXnBnm4VSxpE X-Received: by 10.99.61.66 with SMTP id k63mr6251788pga.421.1510950684743; Fri, 17 Nov 2017 12:31:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510950684; cv=none; d=google.com; s=arc-20160816; b=pR8W+aDeBF4zayLLj4E0q1hafMzBRihfY3Mn5mzNfl6qDswHrvjBXZp+zFpeuPsGte V+kW7fe0C+43BBDikuXFFuB4DNUN51OF/Dg3EdFKFhleSWcfAu8CgXlMllLSCUiYA0p6 hGU6T4jyil2Yh16juWCDrdYbqEmepol3aiPTan6NRtEz/7C+1puBs78lQtCDr4Wz3P4Z dO00Lqzc23vEaRRT2l1BIXPonWaXahMKKRr9x0GOzHAU3UCOESAx8X+UJA0KTsxC1+lm 2G0h5NqynbMcYGeKUtDnjxpjIo4l7i3A0PmoGCc1yrKdyOerO+BQ1ZXOH7UqJD2RDe3I 6A6Q== 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:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:arc-authentication-results; bh=PL6o28RKNKqL/GNoOCtKioK6dcdc2Q/xOBeDq+shIR8=; b=MjVGrnnfYJ4/iqPO52fttPenYwp3Dt+V+9IeWUH/1M6SwNA//K6LnOLF0MvtkeHbps 5lKkieiv0xdF6c/gLyDBsS4o31oY5rCuRSmJIgOhRczqm56/7o+YVWQmIreHJfcJ+k+x uuA0X1rd83gDGSZzwmm9cGgP86GiR9cRt/Kw7fjzOal7aKfkWyGkU8P9uXcRQJrc62mq hHwWIWWEK3FE4kYIJTZXMIIUgrYdWFixWB2dkxS2Odrj6GGta7wbgym4jFOGlmNTn7WP 3PMkk7sJx0VLmi2WmOPo26as3XO5H12mcmH0XiPcgWZZ0G/64GGM7ESJC5BOjO6D/SFt i8iA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o6si3314606pgn.138.2017.11.17.12.31.11; Fri, 17 Nov 2017 12:31:24 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934723AbdKQNxX (ORCPT + 92 others); Fri, 17 Nov 2017 08:53:23 -0500 Received: from osg.samsung.com ([64.30.133.232]:60787 "EHLO osg.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933663AbdKQNxP (ORCPT ); Fri, 17 Nov 2017 08:53:15 -0500 Received: from localhost (localhost [127.0.0.1]) by osg.samsung.com (Postfix) with ESMTP id 1AD8C2B705; Fri, 17 Nov 2017 05:53:15 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at dev.s-opensource.com Received: from osg.samsung.com ([127.0.0.1]) by localhost (localhost [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vXO54Hs5cRn8; Fri, 17 Nov 2017 05:53:13 -0800 (PST) Received: from vento.lan (177.17.214.168.dynamic.adsl.gvt.net.br [177.17.214.168]) by osg.samsung.com (Postfix) with ESMTPSA id A6BED2B6FB; Fri, 17 Nov 2017 05:53:10 -0800 (PST) Date: Fri, 17 Nov 2017 11:53:07 -0200 From: Mauro Carvalho Chehab To: Hans Verkuil Cc: Gustavo Padovan , linux-media@vger.kernel.org, Shuah Khan , Pawel Osciak , Alexandre Courbot , Sakari Ailus , Brian Starkey , Thierry Escande , linux-kernel@vger.kernel.org, Gustavo Padovan Subject: Re: [RFC v5 06/11] [media] vb2: add explicit fence user API Message-ID: <20171117115307.1b1a5a76@vento.lan> In-Reply-To: <6fb67083-7417-0137-9449-36a4cfdb1b9d@xs4all.nl> References: <20171115171057.17340-1-gustavo@padovan.org> <20171115171057.17340-7-gustavo@padovan.org> <6fb67083-7417-0137-9449-36a4cfdb1b9d@xs4all.nl> Organization: Samsung X-Mailer: Claws Mail 3.15.1-dirty (GTK+ 2.24.31; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Fri, 17 Nov 2017 14:29:23 +0100 Hans Verkuil escreveu: > On 15/11/17 18:10, Gustavo Padovan wrote: > > From: Gustavo Padovan > > > > Turn the reserved2 field into fence_fd that we will use to send > > an in-fence to the kernel and return an out-fence from the kernel to > > userspace. > > > > Two new flags were added, V4L2_BUF_FLAG_IN_FENCE, that should be used > > when sending a fence to the kernel to be waited on, and > > V4L2_BUF_FLAG_OUT_FENCE, to ask the kernel to give back an out-fence. > > > > v4: > > - make it a union with reserved2 and fence_fd (Hans Verkuil) > > > > v3: > > - make the out_fence refer to the current buffer (Hans Verkuil) > > > > v2: add documentation > > > > Signed-off-by: Gustavo Padovan > > --- > > Documentation/media/uapi/v4l/buffer.rst | 15 +++++++++++++++ > > drivers/media/usb/cpia2/cpia2_v4l.c | 2 +- > > drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 4 ++-- > > drivers/media/v4l2-core/videobuf2-v4l2.c | 2 +- > > include/uapi/linux/videodev2.h | 7 ++++++- > > 5 files changed, 25 insertions(+), 5 deletions(-) > > > > diff --git a/Documentation/media/uapi/v4l/buffer.rst b/Documentation/media/uapi/v4l/buffer.rst > > index ae6ee73f151c..eeefbd2547e7 100644 > > --- a/Documentation/media/uapi/v4l/buffer.rst > > +++ b/Documentation/media/uapi/v4l/buffer.rst > > @@ -648,6 +648,21 @@ Buffer Flags > > - Start Of Exposure. The buffer timestamp has been taken when the > > exposure of the frame has begun. This is only valid for the > > ``V4L2_BUF_TYPE_VIDEO_CAPTURE`` buffer type. > > + * .. _`V4L2-BUF-FLAG-IN-FENCE`: > > + > > + - ``V4L2_BUF_FLAG_IN_FENCE`` > > + - 0x00200000 > > + - Ask V4L2 to wait on fence passed in ``fence_fd`` field. The buffer > > + won't be queued to the driver until the fence signals. > > + > > + * .. _`V4L2-BUF-FLAG-OUT-FENCE`: > > + > > + - ``V4L2_BUF_FLAG_OUT_FENCE`` > > + - 0x00400000 > > + - Request a fence to be attached to the buffer. The ``fence_fd`` > > + field on > > + :ref:`VIDIOC_QBUF` is used as a return argument to send the out-fence > > + fd to userspace. > > How would userspace know if fences are not supported? E.g. any driver that does > not use vb2 will have no support for it. > > While the driver could clear the flag on return, the problem is that it is a bit > late for applications to discover lack of fence support. > > Perhaps we do need a capability flag for this? I wonder what others think. We're almost running out of flags at v4l2 caps (and at struct v4l2_buffer). So, I would prefer to not add more flags on those structs if there is another way. As the fences out of order flags should go to ENUM_FMT (and, currently there's just one flag defined there), I wander if it would make sense to also add CAN_IN_FENCES/CAN_OUT_FENCES flags there, as maybe we would want to disable/enable fences based on the format. > > Regards, > > Hans > > > > > > > > > diff --git a/drivers/media/usb/cpia2/cpia2_v4l.c b/drivers/media/usb/cpia2/cpia2_v4l.c > > index 3dedd83f0b19..6cde686bf44c 100644 > > --- a/drivers/media/usb/cpia2/cpia2_v4l.c > > +++ b/drivers/media/usb/cpia2/cpia2_v4l.c > > @@ -948,7 +948,7 @@ static int cpia2_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf) > > buf->sequence = cam->buffers[buf->index].seq; > > buf->m.offset = cam->buffers[buf->index].data - cam->frame_buffer; > > buf->length = cam->frame_size; > > - buf->reserved2 = 0; > > + buf->fence_fd = -1; > > buf->reserved = 0; > > memset(&buf->timecode, 0, sizeof(buf->timecode)); > > > > diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c > > index 821f2aa299ae..3a31d318df2a 100644 > > --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c > > +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c > > @@ -370,7 +370,7 @@ struct v4l2_buffer32 { > > __s32 fd; > > } m; > > __u32 length; > > - __u32 reserved2; > > + __s32 fence_fd; > > __u32 reserved; > > }; > > > > @@ -533,7 +533,7 @@ static int put_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user > > put_user(kp->timestamp.tv_usec, &up->timestamp.tv_usec) || > > copy_to_user(&up->timecode, &kp->timecode, sizeof(struct v4l2_timecode)) || > > put_user(kp->sequence, &up->sequence) || > > - put_user(kp->reserved2, &up->reserved2) || > > + put_user(kp->fence_fd, &up->fence_fd) || > > put_user(kp->reserved, &up->reserved) || > > put_user(kp->length, &up->length)) > > return -EFAULT; > > diff --git a/drivers/media/v4l2-core/videobuf2-v4l2.c b/drivers/media/v4l2-core/videobuf2-v4l2.c > > index 0c0669976bdc..110fb45fef6f 100644 > > --- a/drivers/media/v4l2-core/videobuf2-v4l2.c > > +++ b/drivers/media/v4l2-core/videobuf2-v4l2.c > > @@ -203,7 +203,7 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, void *pb) > > b->timestamp = ns_to_timeval(vb->timestamp); > > b->timecode = vbuf->timecode; > > b->sequence = vbuf->sequence; > > - b->reserved2 = 0; > > + b->fence_fd = -1; > > b->reserved = 0; > > > > if (q->is_multiplanar) { > > diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h > > index cd6fc1387f47..311c3a331eda 100644 > > --- a/include/uapi/linux/videodev2.h > > +++ b/include/uapi/linux/videodev2.h > > @@ -925,7 +925,10 @@ struct v4l2_buffer { > > __s32 fd; > > } m; > > __u32 length; > > - __u32 reserved2; > > + union { > > + __s32 fence_fd; > > + __u32 reserved2; > > + }; > > __u32 reserved; > > }; > > > > @@ -962,6 +965,8 @@ struct v4l2_buffer { > > #define V4L2_BUF_FLAG_TSTAMP_SRC_SOE 0x00010000 > > /* mem2mem encoder/decoder */ > > #define V4L2_BUF_FLAG_LAST 0x00100000 > > +#define V4L2_BUF_FLAG_IN_FENCE 0x00200000 > > +#define V4L2_BUF_FLAG_OUT_FENCE 0x00400000 > > > > /** > > * struct v4l2_exportbuffer - export of video buffer as DMABUF file descriptor > > > -- Thanks, Mauro From 1584340688751847482@xxx Fri Nov 17 18:57:03 +0000 2017 X-GM-THRID: 1584163030429422174 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread