Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1369732ybg; Tue, 2 Jun 2020 08:11:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvGBXQ8tGI1Ugrxf2qjMiJtpijigltcmQsm6TdKDDNkod8JNk4//ZlBcujXPpHkPaMA3gv X-Received: by 2002:a17:906:3481:: with SMTP id g1mr22889984ejb.530.1591110713311; Tue, 02 Jun 2020 08:11:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591110713; cv=none; d=google.com; s=arc-20160816; b=mu0mh2suVJMbv40KBY0kvRbfWbNU9eGW76krRLjojGoIQY15UKYe0ljbTUtkiln2PA dONBz+QwH1cU7FtMzq1odHvwKcr8DOxSy+4OM1PKwccjSJC8SbwMpicVUOWOG+yFgZJ5 xuisLMa4ljRgzkLWwEZ2+FM1K6nbjWzUQ0n9afUfoZMtezRh+sETAetKXFsfH3E0Mp2z QBr7mtzLobsfgPpo99hUbEC1zBAoWwt1c3qiY3n5SsKCTa8RGAiUIAHzkt17A3hI1Etw bGppcOeiHYqVi0Ia3YRGGnuY+NHzTtMMAcsVrRgnTkY3uarI45dlTSkEg8lDSgORCYLp Q60g== 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=j1hs0sbBhFcDQ7MR3XFZ4Ba55z2Q7IxLUQ5YveNBojk=; b=mt3xCCyYc8N1ShDwk65U+aZIMD3svdpNZxPPgSJEoy+1YFdu1KoPd8z3XJjzaBFCN4 meFiagvMgTq/fD7aUT0cIAQJTJVDHp5XAIaCnu3Nsml9cYdxa6tD7SJrV3oy67aaVvyw 89RKQrRtbRwDvqRVD1pREkGRr6dyksyzyBoGrDZJLR7VRSTjA7FZk18lDKjNQ0Y67ly8 YVasaT5BMJlQKBI/0o30KGtJdfaOadnG+w5tzoUdbTltjvS4YqSEY0A6/3gYQeQpkFVV wRzwBfbiP/7xX4fb8jC6aa0wyDGsFGJkTzMjCd5lxfyHXWfxlmMZzoJEeYYm623vj/99 1XQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ndufresne-ca.20150623.gappssmtp.com header.s=20150623 header.b=ObqB132W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dm20si1889581ejc.159.2020.06.02.08.11.29; Tue, 02 Jun 2020 08:11:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ndufresne-ca.20150623.gappssmtp.com header.s=20150623 header.b=ObqB132W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726420AbgFBPJi (ORCPT + 99 others); Tue, 2 Jun 2020 11:09:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725958AbgFBPJh (ORCPT ); Tue, 2 Jun 2020 11:09:37 -0400 Received: from mail-qv1-xf44.google.com (mail-qv1-xf44.google.com [IPv6:2607:f8b0:4864:20::f44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC15DC08C5C1 for ; Tue, 2 Jun 2020 08:09:37 -0700 (PDT) Received: by mail-qv1-xf44.google.com with SMTP id g7so1899202qvx.11 for ; Tue, 02 Jun 2020 08:09:37 -0700 (PDT) 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=j1hs0sbBhFcDQ7MR3XFZ4Ba55z2Q7IxLUQ5YveNBojk=; b=ObqB132WsPXJQaYMlGIcR0AVfl9JSbInH4CY0PmjmgmBn/u/f07H1aWiAeXK+tqPwK dsi2xIus1EfNIFc8TnKO12+MaLjeALY5mTkCc5jTuZWl2xxCvcIFOQtCaYTUUSSr5lFS irXV1vv7pUCClzlnyIvArLtNRtxquZeHjdA6yuYkQ/sOqdiyKEqcLJv7MP6Q+Ru1DIxB NDg/hPpNABJmZkiuJeiUcc3n/dq5qhmzBxCuETJkfQixY+1PkSml2NBXExJqUtaq0Q13 NnEL7udrGjSMXHjfO0aAX4GwThwsArSj4m0rRa161hcPO0kqhqJKMKUh51pZA1Idf6f9 Y+Gg== 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=j1hs0sbBhFcDQ7MR3XFZ4Ba55z2Q7IxLUQ5YveNBojk=; b=O9EjdwFm41D7KsMiU3D4RFNRe97+ne293cIxNjAqtOY7q6ttV9TLW0lsmRzGxN0AsP /f3wvvuz+16DEpXxtwpOukJlbo3UdvX45AAS0J/h+b4/IvEFFj9jk9WRfGVuTaIFYzBU sUiLpf3pe+w6iK+Pr0GEKgs6jFyTFxtBWUz8vw+5AugKPamFWY6y17QX8AHyN9ikQw+8 IsCfuFKn3Y7NubUJex7YtMdZkNijlA9YU9l9+DqZsVDLR9eDzcd205yOh96jhxFz51Ge sdJSxEiOveNZCRREZU+MGJ5Xbuv7kTFU3ZKE+O9hutsccLUwyrWlSJt6/3bfZc/edyuu brow== X-Gm-Message-State: AOAM530UG+yjgSuL0udlEttE1AVHKtYsGnA9u/a/6sgxrXOIP/xwsIA7 fptjpdJmkyKLpSy+zIBPDom/ag== X-Received: by 2002:a0c:9021:: with SMTP id o30mr23107357qvo.177.1591110576105; Tue, 02 Jun 2020 08:09:36 -0700 (PDT) Received: from skullcanyon ([192.222.193.21]) by smtp.gmail.com with ESMTPSA id i94sm2871202qtd.2.2020.06.02.08.09.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2020 08:09:34 -0700 (PDT) Message-ID: <21733d1ad3c2f79a5646b4f1c541dfabda0978be.camel@ndufresne.ca> Subject: Re: [PATCH] media: s5p-mfc: set V4L2_BUF_FLAG_LAST flag on final buffer From: Nicolas Dufresne To: Andriy Gelman Cc: Kyungmin Park , Kamil Debski , Jeongtae Park , Andrzej Hajda , Mauro Carvalho Chehab , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 02 Jun 2020 11:09:33 -0400 In-Reply-To: <20200502194052.485-1-andriy.gelman@gmail.com> References: <20200502194052.485-1-andriy.gelman@gmail.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.2 (3.36.2-1.fc32) 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 Hi Andriy, thanks for you patch. Le samedi 02 mai 2020 à 15:40 -0400, Andriy Gelman a écrit : > From: Andriy Gelman > > As per V4L2 api, the final buffer should set V4L2_BUF_FLAG_LAST flag. > > Signed-off-by: Andriy Gelman > --- > drivers/media/platform/s5p-mfc/s5p_mfc.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c > index 5c2a23b953a4..b3d9b3a523fe 100644 > --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c > +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c > @@ -614,6 +614,7 @@ static void s5p_mfc_handle_stream_complete(struct s5p_mfc_ctx *ctx) > list_del(&mb_entry->list); > ctx->dst_queue_cnt--; > vb2_set_plane_payload(&mb_entry->b->vb2_buf, 0, 0); > + mb_entry->b->flags |= V4L2_BUF_FLAG_LAST; > vb2_buffer_done(&mb_entry->b->vb2_buf, VB2_BUF_STATE_DONE); The empty buffer is only there for backward compatibility. As the spec says, userspace should completely ignore this buffer. I bet it will still have the effect to set last_buffer_dequeued = true in vb2, unblocking poll() operations and allowing for the queue to unblock and return EPIPE on further DQBUF. Perhaps you should make sure the if both the src and dst queues are empty/done by the time cmd_stop is called it will still work. Other drivers seems to handle this, but this one does not seems to have a special case for that, which may hang userspace in a different way. What you should do to verify this patch is correct, and that your userpace does not rely on legacy path is that it should always be able to detect the end of the drain with a EPIPE on DQBUF. LAST_BUF is just an early signalling, but may not occur if there was nothing left to produce (except for MFC which maybe be crafting a buffer in all cases, but that's going a roundtrip through the HW, which is not clear will work if the dst queue was empty). As shared on IRC, you have sent these patch to FFMPEG: https://patchwork.ffmpeg.org/project/ffmpeg/patch/20200429212942.28797-2-andriy.gelman@gmail.com/ This should have been clarified as supporting legacy drivers / older kernel with Samsung driver. Seems like a fair patch. And you added: https://patchwork.ffmpeg.org/project/ffmpeg/patch/20200429212942.28797-1-andriy.gelman@gmail.com/ This one should maybe add the clarification that this is an optimization to skip an extra poll/dqbuf dance, but that end of draining will ultimately be catched by EPIPE on dqbuf for the described cases. Remains valid enhancement to ffmpeg imho. > } >