From patchwork Mon Jun 20 09:01:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 9186991 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B595B607D1 for ; Mon, 20 Jun 2016 09:27:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DDAD24B5B for ; Mon, 20 Jun 2016 09:27:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 92A4E26538; Mon, 20 Jun 2016 09:27:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D67C24B5B for ; Mon, 20 Jun 2016 09:27:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752803AbcFTJSs (ORCPT ); Mon, 20 Jun 2016 05:18:48 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:36207 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751501AbcFTJRa (ORCPT ); Mon, 20 Jun 2016 05:17:30 -0400 Received: by mail-lf0-f66.google.com with SMTP id a2so4845647lfe.3; Mon, 20 Jun 2016 02:17:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=j3qprLVn8v783135RoRgIGe9ZylcFEp470zX7fSimuM=; b=elkikBOj2mSr0yYnCCs62RkFjyzJini5xF63q8XIYBd0B1hNPH4K/ZtfY8hQg0KRdN 3DEUw6A4CEm2sT8J8gdBzVSt7WdVPhcRX8ykaMOV3scMDEhio/1LX9JRXjXBECu0TbG4 RT00hSszlwOqlHbGMR+TZwIQ4IH5fxo3R2esfYEAvx9mTl328ilRjoleh1jWHeYC1wKr qXSJ2Gtu+W8iBYm3vyCu3nWoa6NJJqrzILR7JSTQyIb9/xqbKu4bnD8EFTjV2Z55LunH TL3k4v9Lcm5Qef5vBiyLewLtVi/qt6WtmQsU7Rk9JJbDUseytqDNX4vlb9SleWk8f9lk GxBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=j3qprLVn8v783135RoRgIGe9ZylcFEp470zX7fSimuM=; b=LS6MVlaL1MXSxyNzoyFTdwguxBZcWQmHnFhgTa3q2XQb6QZLa9PM/f4KAPBFxGwygf MzOuKq1G6XChEaHmbxServ7yp7mVu5f1LQ6qb/XaIAQgN+IDUqFTjWlo8rdPAEKVvs9J jY+nw5QfrU/YDJgqCFSKP8BpzlKnVJaO6CLHNDhQsTIfEK2Lg53q2E3QdwKla9CDyIZ8 xKzNn5QRNhf7xdn9mSHqeQtDh91RTFLRZMJC9qYOOazcotC+z3wDu+44lzjUeAGbQaU6 gqNs0RTjMZutLeuDt8JcXRB96YpfTlD6ypNJRf28G6mWnpsq+ZdYgyGSgrMEHfqKqKBh Q7Fg== X-Gm-Message-State: ALyK8tL/NsVXLJkUU9C4cpwQBSdScFy9/ycAO22E74436Lrcspg5ApHTPUVuzJCi1GUu/g== X-Received: by 10.25.30.194 with SMTP id e185mr4515574lfe.202.1466413308401; Mon, 20 Jun 2016 02:01:48 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id eu7sm3387653lbc.39.2016.06.20.02.01.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jun 2016 02:01:47 -0700 (PDT) From: Ricardo Ribalda Delgado To: Pawel Osciak , Marek Szyprowski , Kyungmin Park , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, hans.verkuil@cisco.com, Dimitrios Katsaros Cc: Ricardo Ribalda Delgado Subject: [PATCH] vb2: V4L2_BUF_FLAG_DONE is set after DQBUF Date: Mon, 20 Jun 2016 11:01:44 +0200 Message-Id: <1466413304-8328-1-git-send-email-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.8.1 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP According to the doc, V4L2_BUF_FLAG_DONE is cleared after DQBUF: V4L2_BUF_FLAG_DONE 0x00000004 ... After calling the VIDIOC_QBUF or VIDIOC_DQBUF it is always cleared ... Unfortunately, it seems that videobuf2 keeps it set after DQBUF. This can be tested with vivid and dev_debug: [257604.338082] video1: VIDIOC_DQBUF: 71:33:25.00260479 index=3, type=vid-cap, flags=0x00002004, field=none, sequence=163, memory=userptr, bytesused=460800, offset/userptr=0x344b000, length=460800 This patch changes the order when fill_user_buffer() is called, to follow the documentation. Reported-by: Dimitrios Katsaros Signed-off-by: Ricardo Ribalda Delgado --- drivers/media/v4l2-core/videobuf2-core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 633fc1ab1d7a..63981f28075e 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -1771,10 +1771,6 @@ int vb2_core_dqbuf(struct vb2_queue *q, unsigned int *pindex, void *pb, if (pindex) *pindex = vb->index; - /* Fill buffer information for the userspace */ - if (pb) - call_void_bufop(q, fill_user_buffer, vb, pb); - /* Remove from videobuf queue */ list_del(&vb->queued_entry); q->queued_count--; @@ -1784,6 +1780,10 @@ int vb2_core_dqbuf(struct vb2_queue *q, unsigned int *pindex, void *pb, /* go back to dequeued state */ __vb2_dqbuf(vb); + /* Fill buffer information for the userspace */ + if (pb) + call_void_bufop(q, fill_user_buffer, vb, pb); + dprintk(1, "dqbuf of buffer %d, with state %d\n", vb->index, vb->state);