Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp49928pxa; Wed, 26 Aug 2020 04:37:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxi8AHWRJ8tH/PPzSZFIkXkKb1Wm98NNTu/IRL5hhqh6cDNFXHWj4En/ugJtEuga8IJn47k X-Received: by 2002:a17:906:eb49:: with SMTP id mc9mr14987857ejb.36.1598441824181; Wed, 26 Aug 2020 04:37:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598441824; cv=none; d=google.com; s=arc-20160816; b=zm6J8oGkkVRnxWsdJmoUw+JONxbu0kB7JaToIxfXbLqX5dNkJXqaMSxIibYboDnKRi Yu9q7lqlxq+K5p85fj1jltUZVKPPkHMzN9kyO8Egoc+jYz0YdKYbskUNf9+oTJfXGZFV mAVvDiyaqgcUIyQyHKjNViQXzQ44scmi/HbzHG9RmRE4xfPDArtuffFK8JKHbAynDKvs pUGZH83BeMQb0yz1gFRZYJjT/PzoAm89yI9K9LBX7sP5v2PoXVWngdyYqLMP0ao5j0lK B244uQGPswr9Fs4fxw3GTg6tAcbjsbKDMZYg3U3e+hPJ5ZwRTuZhkLnkBoeV4WR1qNET nNxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=BwPP+Wy6wA+3eWc/onU66ibaN4gluQuh0nP0l3YOUgY=; b=amjbHzaQdwcXOnSVtUex7yc1if5MSCAR3PPO0u7QkTrJNdsP+DneQLY8fmepjbqhMA pV5oh7284qV0425JKIcZaFgTpHcB8YhUiUhhCekeJd/E0y4zq8NDixXkuJb2CNs1FX5U HHJ1aU9Uz3vC6AylbJyTbUzQ23n1Q3ezhICiJI8gLwhTFKNDXzSbxyM/1HjJ1XDo81gG kur1tJRvubX9Zt9AAc2VTHztS8AdycBTgKSdoDD8JhB+D1OmPho1veQasQJiC2B8WfV+ PtJ9auLOlxSI66YYXUOgP/KR5KWS79UxZu7gfh932XYAHZ+kKXAPUOsunespd1nw+XQp o5Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=E7VxO8g4; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i7si1283605edg.600.2020.08.26.04.36.40; Wed, 26 Aug 2020 04:37:04 -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=@gmail.com header.s=20161025 header.b=E7VxO8g4; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729005AbgHZLeb (ORCPT + 99 others); Wed, 26 Aug 2020 07:34:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728946AbgHZL0d (ORCPT ); Wed, 26 Aug 2020 07:26:33 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55EECC061574; Wed, 26 Aug 2020 04:25:52 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id w14so1923164ljj.4; Wed, 26 Aug 2020 04:25:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=BwPP+Wy6wA+3eWc/onU66ibaN4gluQuh0nP0l3YOUgY=; b=E7VxO8g4aPMfq4QDhK8BsuM/jTaOOwMzE+iUebvg+1KPXgHLZ/uheF+srixOBQG7Pw mLT7kFfr9VzTvSHgpAYSYS7u9G88jbHWq6gmLad6k+pHRahNDthV0vEzV6IaS4pfcq4n kjQoVV+4Fu1N8eW2tX21cbqFOBCfg+4cZQ2eKCH9863QtfIlYDwhQg7fl8+mo1nXwFga t04AS7oMBGiNPQUFds5R425WHFGNzo8sktu/aAwLxsDkLJGJU46IhGZ/82XC53oRzL9b yzxBJPtoIWzKEXDoSWgBA7pLE6yDyFjunnZWtjoGLwIiFoIuzG4x/rfy/upwZ/PNOerC 7ozQ== 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; bh=BwPP+Wy6wA+3eWc/onU66ibaN4gluQuh0nP0l3YOUgY=; b=c9Z0dF+HrTEFzkgArBpE9UB9aWLRD/k/Gn1sXpglnliApxb15xWkbzxWabv/pTjW2H KHZEnD4rrvuKOxNcSi+KIxTpNlXnya1s86oBzzXsi0Hj4oPWjKO1c9R5RZC8FWwkB8Tu KUMb7ziWW28tRR0jnlWUztgqqh8B2DqSAi1Z/Nx4fKeR3BRERizNdhhcWRnpT+80eQs6 QMACT3wzl1ud8Bb/lOpRLO6dEGPRqKkg0uMNACxRIEasXt1xpNpHu31SOPbErzVBMSfH EIkPsDQAEMp9cHOFXrL9gxOo0nlmOct0711reyK5s1t7GRqs5Dd/3yTNUMi9vgtrXpFe R0Rw== X-Gm-Message-State: AOAM5302LD5l3hG4Cbpt33YkytOaaEvVNdeg/gAJ3WeCzF9f5LgCVblW EL1yQuPqTn9rf2HhBDD7PPdh0/6heIx2fdpm8hLyjZso X-Received: by 2002:a2e:9904:: with SMTP id v4mr6738335lji.321.1598441149742; Wed, 26 Aug 2020 04:25:49 -0700 (PDT) MIME-Version: 1.0 References: <20200825145556.637323-1-gnurou@gmail.com> In-Reply-To: From: Alexandre Courbot Date: Wed, 26 Aug 2020 20:25:38 +0900 Message-ID: Subject: Re: [PATCH 0/2] media: v4l2-mem2mem: fix poll() bug To: Ezequiel Garcia Cc: Mauro Carvalho Chehab , Hans Verkuil , Nicolas Dufresne , linux-media , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 26, 2020 at 7:10 AM Ezequiel Garcia wrote: > > Hello Alex, > > Thanks for the patch. > > On Tue, Aug 25, 2020, 11:56 AM Alexandre Courbot wrote: > > > > This addresses a very corner case that probably nobody ever encounters, > > but I have hit it when playing with vicoded so here is a tentative fix. > > > > I'll try to make a more complete review soon, but meanwhile > I was thinking if it was possible to include a little kselftest program > for this issue, something CIs can pick-up and test corner cases like this, > making sure we don't regress on the issue. > > (Or alternatively, v4l2-compliance?) I am not very familiar with kselftest, but IIUC the conditions that lead to this issue are easier to reproduce using v4l2-compliance, where we can have a user-space driving the queues. It would also have the benefit to exercise all drivers. I'll think about adding such a test, thanks for the suggestion! > > Thanks! > Ezequiel > > > Patch 1/2 addresses the issue that when the last buffer of a m2m device > > has been dequeued, any attempt to poll with EPOLLOUT will result in only > > EPOLLIN being returned, even if OUTPUT buffers are still pending. The > > issue stems from the fact that the last buffer check if done first, and > > returns immediately if true. > > > > Patch 2/2 builds on the first one to (hopefully) clean up the code a bit > > and make the function flow easier to follow. Functionally speaking it is > > supposed to be a no-op and it can safely be dropped if the former code > > is preferred - the actual fix is in 1/2. > > > > Alexandre Courbot (2): > > media: v4l2-mem2mem: consider OUTPUT queue first when polling > > media: v4l2-mem2mem: simplify poll logic a bit > > > > drivers/media/v4l2-core/v4l2-mem2mem.c | 42 +++++++++++--------------- > > 1 file changed, 18 insertions(+), 24 deletions(-) > > > > -- > > 2.28.0 > >