Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3194482imu; Fri, 23 Nov 2018 23:49:15 -0800 (PST) X-Google-Smtp-Source: AFSGD/VMuKtAkT+eVGDkTA8J+pbnIH8cc+10YbP/pbbIesrmBduL4+BR/dhY1AnlPMq0PbZeGFtR X-Received: by 2002:a17:902:50e:: with SMTP id 14mr10900920plf.141.1543045755800; Fri, 23 Nov 2018 23:49:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543045755; cv=none; d=google.com; s=arc-20160816; b=BEj9JLYjT0jZSnYbmbb4hY5SO+Kqg6r5zIf5JJRv6tP4V5fy7gN8buYwpHAoNx43Su f6GYi88+gsDr1Ru+WoF/9FBZmZJId7hyuvKDsb4xvj7ZrkMauhrrXkWtWrs+BR2uoQAD xsCqjYTG03hnnT9CASBkK9v5k5k3SQ39wR92j1IHUgCkatJfCkmq7tCgheIuUoAcsMh/ 1MTgbxRPBcTHL+9R59DoBYqsHU1YAs6l2jqKZT6dxEtOv3AIiFjmvgepDpboB8NrTL3O Ny51nJF1PbXqQ0XDuCpSGgUnsF5eCSUhMtRv/S500r9DUkR28aTTQ0u8PZHJXpxCzQtQ raSA== 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 :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=nPTGdUADIXtInbJXljs6ZE0po/cjok/A16n77ewkYBE=; b=Y848gtn+cGNraNRQ/4WeuWgPm0MXTf6of/AZzvGkrBDbtnEK9paH787g5rrpHMbrxz IcxPhQd57SOg1gnzfw0hcvhTEEjNmaNhSs4TvEh5K5hLVkYgCkgGGYn4BkqaHLp/AGut okHZb91Ejzsrefp8g77M4LUCiYrP9V8Gvh0dmcmC9PmS6PI5kzQex73D+u0Oapon1FIy DabXU5ZJJPhmy4uoniLsTSsbfY+B1bzWvxSqR6XzZz1OcHPXpuquOhFwpRbafE+Ti/d+ NAh7+94czAynFeiCBmmgXawqxKbH45MCspgqj1iplTSg3QlyrwJYkwqDmc47FG50hzew 6TaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ndufresne-ca.20150623.gappssmtp.com header.s=20150623 header.b=R+qxkSn3; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t74si45527083pgc.150.2018.11.23.23.49.01; Fri, 23 Nov 2018 23:49:15 -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=@ndufresne-ca.20150623.gappssmtp.com header.s=20150623 header.b=R+qxkSn3; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439184AbeKWKfb (ORCPT + 99 others); Fri, 23 Nov 2018 05:35:31 -0500 Received: from mail-qt1-f195.google.com ([209.85.160.195]:33853 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389089AbeKWKfa (ORCPT ); Fri, 23 Nov 2018 05:35:30 -0500 Received: by mail-qt1-f195.google.com with SMTP id r14so8943343qtp.1 for ; Thu, 22 Nov 2018 15:53:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ndufresne-ca.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=nPTGdUADIXtInbJXljs6ZE0po/cjok/A16n77ewkYBE=; b=R+qxkSn3n1EHXMWXflXIYShfYFStKFCpWtSoMK8afKhJHdD+yHeY+wiKn8Z+hGSCcm Kq1BL3mldOUWSXllMQ/zQxWaSIOGSL7WrE4DQsk7I/K0+5nrkEsA+PpTM3NVHFmVn2tn iE4bhygn+7xAmbT/4aRYqNRCLdWR36Mm1Ci5r4YWQqPgDA37pqMTaMQVUJ00FK6QRu1L YJa0kdCz4lfXLRkmQhqz1gRYIsZC4oV2nhHnrvFltToo0pVCvMU+EY2kK+h7OqbShgpT 2av6RCWb3wJt+2an34Q5GPTg7VtHMMq+jzOAP9LUR5tADs7+7r/l0FgrtWTGeooClJEM Cyiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=nPTGdUADIXtInbJXljs6ZE0po/cjok/A16n77ewkYBE=; b=QSkx80fi4CCktm14XsGH0IeJFfgc7c5SeNghlJNGBIUUbECgVW2nWWgkBcYF1Cq14s chu3IOTaOs79L11hsHk6B1V9z9HZoGNhIic5XmlJEiN/jfhDxYnL+dJcqg0A66n9O7om tWspAaFt3KTGMuR5H09r4r8XT6E01H3VE8NIlHPKJ646jXkI2tuwvORFYDP0yu6mOeYc 9ESikxWLiD9rJCNdVobArc9mamVBv12qINJ92mCtAD16DWBm6lPYzyfeMNvC9d53PFPA 7gg431X1hKYrgNHV9G0ayqzx5+pcWJ3HPp4DxNAtMbu/t/purWrFAHC9pvldIGUxFHy7 citg== X-Gm-Message-State: AA+aEWb+SBbvHa432j2l43aJS4kNOBgVDb0O1SMODgCBhYaY/1zCAd79 0+qpHg5Lw7TTnxhZwVuckbZ3sw== X-Received: by 2002:a0c:b02c:: with SMTP id k41mr11728052qvc.154.1542930821447; Thu, 22 Nov 2018 15:53:41 -0800 (PST) Received: from skullcanyon (cable-192.222.193.21.electronicbox.net. [192.222.193.21]) by smtp.gmail.com with ESMTPSA id e89sm25741521qtb.78.2018.11.22.15.53.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Nov 2018 15:53:40 -0800 (PST) Message-ID: Subject: Re: [PATCH] media: venus: fix reported size of 0-length buffers From: Nicolas Dufresne To: Alexandre Courbot Cc: Stanimir Varbanov , Mauro Carvalho Chehab , Linux Media Mailing List , linux-arm-msm@vger.kernel.org, LKML Date: Thu, 22 Nov 2018 18:53:39 -0500 In-Reply-To: References: <20181113093048.236201-1-acourbot@chromium.org> <463ac42b795933a54daa8d2bbba3ff1ac2b733db.camel@ndufresne.ca> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.30.2 (3.30.2-2.fc29) Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le jeudi 22 novembre 2018 à 17:31 +0900, Alexandre Courbot a écrit : > 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 > 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. > > Cheers, > Alex.