Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5491118imu; Mon, 26 Nov 2018 00:55:36 -0800 (PST) X-Google-Smtp-Source: AFSGD/UIvG9FDm77zWlYoooFGLzA5YVCKmbKgVpmB4r9shXuajkITU6EVYsxP6LNUMOygzaJTNzu X-Received: by 2002:a17:902:8bc6:: with SMTP id r6mr26554364plo.67.1543222536325; Mon, 26 Nov 2018 00:55:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543222536; cv=none; d=google.com; s=arc-20160816; b=MBIUu5WKVlLCUxjA4tE08LWC6EeFGVbJITfzvm7EwYC61Zf+VQHYfbgPk+cigZaM0h bE3F63Yai9k8YtlC5qDb4QFw0JRS9Dx0i2QaEJcL9akIFrmK3uOLRik16IQiEzslVx83 B8MOzw00Ew/FeasWHjM2sKIT5UOJXw1O8r9u4Y6ea0BP7O1+SlCPE+MZH9sfqEY4zmB8 3fyhSKnVaqi+FfPgtj7TBjQqqhC3M6CoCeH+zPXXI3kMeeRZJZE6FM4ggdOug8dCX47J 4LI4Y/a9PktK2ExBm4MQYff6xcfT0BlUfF7wOVh2DpxcYBm6e4YCcY7nqikyO7akNWMR /iwQ== 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:dkim-signature; bh=zHnWv3d3yb6Hw2J9pDGopeGI4bLUy88fCknQsL2tCjA=; b=tD5aZ9t3IvYIJ+KbaP1Rmf/8BUGhcdycMumIXOIxWpyEtncvQSobpb1cn5JsdQCP48 MSBy9WvG4cMrtbKLC3qa3YVCrMzoRGdET7qiO8uqHwPj779nZVzyq/S6AfFGOEWpeBuT MX11DgXeVSdiqQcRibAIvaG0NTJ7Q4iGhznVu2Rb5gl5xfFj+TCBJ3TAgYUaRinvvBht z7hGSaUwfh5BQK1yllwzYqVLJylPA0Ozy2NFpTLfh91BWhzgXFJzvTRVG75CUcVX8yca ZAy8Ymjyj7wAvGPuNKOUN/nDg1bT266DjY2fN2FD+8xk6+8Q0i7bnWN+ys0NiUW9V4Ea Z0lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Vq/fY/9o"; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h85si13872913pfd.27.2018.11.26.00.55.20; Mon, 26 Nov 2018 00:55:36 -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=@linaro.org header.s=google header.b="Vq/fY/9o"; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726253AbeKZTr4 (ORCPT + 99 others); Mon, 26 Nov 2018 14:47:56 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:43927 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726200AbeKZTrz (ORCPT ); Mon, 26 Nov 2018 14:47:55 -0500 Received: by mail-wr1-f68.google.com with SMTP id r10so17927940wrs.10 for ; Mon, 26 Nov 2018 00:54:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=zHnWv3d3yb6Hw2J9pDGopeGI4bLUy88fCknQsL2tCjA=; b=Vq/fY/9oDTLlOVCc512sYlzVz061IdUYttODFFnqVgq74mWidnAwBoIU1aZBFiB5VG OFR4loRJck/jB30cxLpXgeZI4i8LhFLWP+8R+pFJoetF9T3HpjG4+nmw+o6OMnvtCi3p 4ka5+gbb4Zy11nxYTb3Ms4FqHVaIdzE+FmmeA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=zHnWv3d3yb6Hw2J9pDGopeGI4bLUy88fCknQsL2tCjA=; b=SDK2dvRAFjZ9ijKuCdT7NOXreut5cwrHoaTqPNujU8gGMsXgS9+FPFC+w+fDVrpFC4 S2S7aYgd+c0Z/+lKI4kFRdm7O94Ja/6sTZBvCwNSU4I+Za4EgXhL4sPlJV5l//t99ab9 Ovi91ksl4Sq/z6UbMkZiKm8s+L0to3if+wWH4YSsj0r+66PaBqt+2GlSNW1JnbdTnhsl WEK1TdnhZusR7mSTDnk9n9+g+nvhuduoDuo4orV+XQ4TknviwpTvhxjnh5boBp1Ygbxq eXkHjbnmVAsKlKWoFP9elbFCCWgVWalVSzFlbuZHctAxH0wBBoPyYEvadTKo95G5/jMx EKrQ== X-Gm-Message-State: AA+aEWbHvhMyfwrwW2f4O0yS/MhWzHb0xQgfL9eMu3XD5iT1il0bmXob GkAx8/EAShdfaOc4psv5IycRYBo2i4s= X-Received: by 2002:adf:fe8f:: with SMTP id l15mr21705786wrr.313.1543222467246; Mon, 26 Nov 2018 00:54:27 -0800 (PST) Received: from [192.168.27.209] ([37.157.136.206]) by smtp.googlemail.com with ESMTPSA id a125-v6sm146080wmf.8.2018.11.26.00.54.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Nov 2018 00:54:26 -0800 (PST) Subject: Re: [PATCH] media: venus: fix reported size of 0-length buffers To: Alexandre Courbot , Nicolas Dufresne Cc: Mauro Carvalho Chehab , Linux Media Mailing List , linux-arm-msm@vger.kernel.org, LKML References: <20181113093048.236201-1-acourbot@chromium.org> <463ac42b795933a54daa8d2bbba3ff1ac2b733db.camel@ndufresne.ca> From: Stanimir Varbanov Message-ID: Date: Mon, 26 Nov 2018 10:54:24 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Alex, On 11/22/18 10:31 AM, Alexandre Courbot wrote: > On Fri, Nov 16, 2018 at 1:49 AM Nicolas Dufresne wrote: >> >> Le mercredi 14 novembre 2018 à 13:12 +0900, Alexandre Courbot a écrit : >>> On Wed, Nov 14, 2018 at 3:54 AM Nicolas Dufresne wrote: >>>> >>>> >>>> Le mar. 13 nov. 2018 04 h 30, Alexandre Courbot a écrit : >>>>> The last buffer is often signaled by an empty buffer with the >>>>> V4L2_BUF_FLAG_LAST flag set. Such buffers were returned with the >>>>> 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 firmware. >>>> >>>> That means the driver does not know on time which one is last. Why not just returned EPIPE to userspace on DQBUF and ovoid this useless roundtrip ? >>> >>> 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 for >>> 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 some >> 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 the >> 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 the >> 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 Small correction, the firmware signals EoS with HFI_BUFFERFLAG_EOS flag with the returned buffer, then we set V4L2_BUF_FLAG_LAST. Usually with v1 and v3 when HFI_BUFFERFLAG_EOS is set the bytesused is zero. > 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? > > Cheers, > Alex. > -- regards, Stan