Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5465708imu; Mon, 26 Nov 2018 00:25:42 -0800 (PST) X-Google-Smtp-Source: AFSGD/UOrS3j3cYJ0IrBYdy9suNyrsfq6Hq/JOwT2xo8C/5byE2BpE3jMl0h8uhDmyrmwklWAadB X-Received: by 2002:a63:c42:: with SMTP id 2mr23958015pgm.372.1543220742828; Mon, 26 Nov 2018 00:25:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543220742; cv=none; d=google.com; s=arc-20160816; b=R6o9FD3hQyc1Rid/n9UZV4hgFByxVMtlYP1GOX2HzRtptYiKOehdufXGn4MOYEOHZG VXOLTA0gFeEzmgf2Gh3ldw4XdNJD9Ld5Aiw/qzf/ngHfJGbzBNcR6ssXovqAilEa7s1f KreBl4sz2sVEfc874jCY+q7VNaE6NTEVfW7pye6B+GDV+TugJVqzqOaIrBb82DP/pjCS jt+L5qStgcPWbQuCrYDRnfVQrJ/7GnRe132K2c5+rGKV53QIun1O67gB/zTLra1jm0N1 RCUH5knFMhuUe2nmRBrybQN0zMa1q/t7EI6zjtnxfA2ioHAxcE4Dl3h0eOzc63zXiP9e fMHg== 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=OiKx+Bt+6ITT1ounE1XuKJu9KKOSZSJzsuxXBCFoUw4=; b=czQFjnMPNQHI/duOZ9A5kjlN/cC1UrnDEDOQQLvZ2McMKkXgTtclzirsimDs6QYVSP 67JROWZ4QqVEwsSILuIOHN8za566+Z0/hAYjA2TGLXzKmn7/ZImlG+a1eq1q0rgssBjw Z+pWO9Tx/AnyG/xJcNERNPh1VQpHcIJi8F7l5/VO4RsDPDr8k0n7B2KMvX61Ok2dlQ7Y CVrb+DL0iHyk+RHOhmGp1NKoTwZ075UM/FbY2R1tHIstY42bBb/pM9LrPh/dcdkWA6F8 +9Yh7fVTjRyTuR0Qz5O2ThhUmf1N/wv4XA2u9lX3qpHk3oMi7KU65/kxCGDce/W5+HaL 25CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ZNLvK97R; 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 b10si47718118plz.233.2018.11.26.00.25.27; Mon, 26 Nov 2018 00:25:42 -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; dkim=pass header.i=@chromium.org header.s=google header.b=ZNLvK97R; 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 S1726242AbeKZTQu (ORCPT + 99 others); Mon, 26 Nov 2018 14:16:50 -0500 Received: from mail-oi1-f194.google.com ([209.85.167.194]:39976 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726191AbeKZTQu (ORCPT ); Mon, 26 Nov 2018 14:16:50 -0500 Received: by mail-oi1-f194.google.com with SMTP id t204so15017704oie.7 for ; Mon, 26 Nov 2018 00:23:28 -0800 (PST) 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=OiKx+Bt+6ITT1ounE1XuKJu9KKOSZSJzsuxXBCFoUw4=; b=ZNLvK97RJKAZ1RyeCG+8nqvHoTp5JgvfNmb+JhmCwJ6ulCzHF2IuKvgK30QIcObkrZ upARHQiV/zFrPw6I/x0N7mc8v3W4VIWo1bESjb4ilXk9zcbzyRMeXridnLjHeGyTa/Ck VOHlDsC39q9v/aieVPtWYUOFbPNFAUal5ysCU= 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=OiKx+Bt+6ITT1ounE1XuKJu9KKOSZSJzsuxXBCFoUw4=; b=Hk7oNQ+L6Xy1GQuVoQgI2bkWcZXhvAMiw7R4s2H1vtfQvFTsTc8ZYpZP5j0wYqvB80 jsadDcXsmVMkGk7UMgrrjgmL3p5XHI789NzP7TfGL2QZythLbj1u19DKFI7Od3/4vT5j 2NPa5FvtBx/cxJjjuZJi87sYnK6LROvO7G/NEYS0su95BGkO43DyU0eRRonCVf3CLTNk nqVvYxSmq6zK58OxKnAywiU5+q/4xU6qYOiH6NtWmcC0fD68UROn5BKqWkcShsFfQ7g0 vyonh0crp4epFhx44llg4prVjhPgegeg3hX5A3tY2V1EJ3zbQv5T/V9RC/i+NpfhtrA/ 1bNg== X-Gm-Message-State: AA+aEWb4jUbzI7f+eVoo+/kVlVUueWkrVhm4fP3JH6YZHH5oLtHFd0Qe eUQz2dDfcLux0XJPHTLROcn8z3HCIkFYEA== X-Received: by 2002:aca:3c06:: with SMTP id j6mr103825oia.126.1543220608132; Mon, 26 Nov 2018 00:23:28 -0800 (PST) Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com. [209.85.210.46]) by smtp.gmail.com with ESMTPSA id d124-v6sm20543165oia.29.2018.11.26.00.23.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Nov 2018 00:23:27 -0800 (PST) Received: by mail-ot1-f46.google.com with SMTP id s5so15771589oth.7 for ; Mon, 26 Nov 2018 00:23:26 -0800 (PST) X-Received: by 2002:a9d:6287:: with SMTP id x7mr15398361otk.304.1543220606629; Mon, 26 Nov 2018 00:23:26 -0800 (PST) MIME-Version: 1.0 References: <20181113093048.236201-1-acourbot@chromium.org> <463ac42b795933a54daa8d2bbba3ff1ac2b733db.camel@ndufresne.ca> In-Reply-To: From: Alexandre Courbot Date: Mon, 26 Nov 2018 17:23:15 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] media: venus: fix reported size of 0-length buffers To: Nicolas Dufresne Cc: Stanimir Varbanov , Mauro Carvalho Chehab , Linux Media Mailing List , linux-arm-msm@vger.kernel.org, LKML 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, Nov 23, 2018 at 8:53 AM Nicolas Dufresne wro= te: > > Le jeudi 22 novembre 2018 =C3=A0 17:31 +0900, Alexandre Courbot a =C3=A9c= rit : > > On Fri, Nov 16, 2018 at 1:49 AM Nicolas Dufresne = wrote: > > > Le mercredi 14 novembre 2018 =C3=A0 13:12 +0900, Alexandre Courbot a = =C3=A9crit : > > > > On Wed, Nov 14, 2018 at 3:54 AM Nicolas Dufresne wrote: > > > > > > > > > > Le mar. 13 nov. 2018 04 h 30, Alexandre Courbot a =C3=A9crit : > > > > > > The last buffer is often signaled by an empty buffer with the > > > > > > V4L2_BUF_FLAG_LAST flag set. Such buffers were returned with th= e > > > > > > bytesused field set to the full size of the OPB, which leads > > > > > > user-space to believe that the buffer actually contains useful = data. Fix > > > > > > this by passing the number of bytes reported used by the firmwa= re. > > > > > > > > > > That means the driver does not know on time which one is last. Wh= y not just returned EPIPE to userspace on DQBUF and ovoid this useless roun= dtrip ? > > > > > > > > Sorry, I don't understand what you mean. EPIPE is supposed to be > > > > returned after a buffer with V4L2_BUF_FLAG_LAST is made available f= or > > > > dequeue. This patch amends the code that prepares this LAST-flagged > > > > buffer. How could we avoid a roundtrip in this case? > > > > > > Maybe it has changed, but when this was introduced, we found that som= e > > > firmware (Exynos MFC) could not know which one is last. Instead, it > > > gets an event saying there will be no more buffers. > > > > > > Sending buffers with payload size to 0 just for the sake of setting t= he > > > V4L2_BUF_FLAG_LAST was considered a waste. Specially that after that, > > > every polls should return EPIPE. So in the end, we decided the it > > > should just unblock the userspace and return EPIPE. > > > > > > If you look at the related GStreamer code, it completely ignores the > > > LAST flag. With fake buffer of size 0, userspace will endup dequeuing > > > and throwing away. This is not useful to the process of terminating t= he > > > decoding. To me, this LAST flag is not useful in this context. > > > > Note that this patch does not interfere with DQBUF returning -EPIPE > > after the last buffer has been dequeued. It just fixes an invalid size > > that was returned for the last buffer. > > > > Note also that if I understand the doc properly, the kernel driver > > *must* set the V4L2_BUF_FLAG_LAST on the last buffer. With Venus the > > last buffer is signaled by the firmware with an empty buffer. That's > > not something we can change or predict earlier, so in order to respect > > the specification we need to return that empty buffer. After that > > DQBUF will behave as expected (returning -EPIPE), so GStreamer should > > be happy as well. > > > > Without the proposed fix however, GStreamer would receive the last > > buffer with an incorrect size, and thus interpret random data as a > > frame. > > > > So to me this fix seems to be both correct, and needed. Isn't it? > > Totally, thanks for the extra clarification. Awesome, thanks for confirming! Stanimir, can we have your thoughts about this change?