Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp111179iog; Tue, 14 Jun 2022 20:48:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgUuAVhjUL3lpEOPSS5NRovzfm0YKmYvyTeSEPqRIyO+NaO/upFwNsAGnpM4oT9/aQCGKd X-Received: by 2002:a63:67c3:0:b0:3fe:465:bfa2 with SMTP id b186-20020a6367c3000000b003fe0465bfa2mr7120122pgc.12.1655264934261; Tue, 14 Jun 2022 20:48:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1655264934; cv=pass; d=google.com; s=arc-20160816; b=Hoosdvgx/3avcEyoUBHsp1VCF9gGhNBBp3rExr1rPq7ffvDfzX0SX8GdCCHBwAUi7d ZFXN2QfJByC+R3V9DfHXsuR2hl2rnuGAgQRu1OtTh2k9Cn/YPvBISME5EpTby7kIg4kX YLkHRIueWR4q9LQRKao2/oDvrxNvpMZLnzTRm85yQTm2lgc46DQ9Ip9ML3GjTHwaj2rV QGcgm69ETpnCPn97FXS2Hd+UkZ6pBDtVWIaLmPqQ0WV0zI7wYB69xA54+99SuKGowVWy I7prEk7hpiooPwNT/lMpTsMpUhbDvPeTIVuFTAQcbel/knhPiqcLnHftppbM5K6mS2SK 629Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=izeN58nkKvbN/2XuBE3XQO8CoWEKdNWMsVYbjhuBz9s=; b=S2MpntOejubI/61SKa+muCAIKM272HcpfHlKrWdGbE72A6kdzadOOXdmgr+RZXgnlA EH72AMp+GdoI2Elga0K53i1KzBlecloFroSd/6dp5bwtGtBgkm4eZJfoBTJO2CX/be5u hTtgphHCZP+4yTqFj7gKt+uG8D4sb2/GSViFJNcXFOOU+VqrTrSHRzujl8ABggAM8VRo nSptBig8UsTXt4VT3kXCySZ+ouDjYtvn6kSr+vTGEaoXlUuEgkrqUDOh9pjticCqRsAH gR7xmYQOvDRElQleudFVke8TNoH/8lRESljVgCIK3CkUw+SfLi6I/4xmbv3wSkPTEt2Q gqhw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=bzWpPF+M; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y3-20020a655a03000000b003f9f28dd8e9si16827192pgs.794.2022.06.14.20.48.42; Tue, 14 Jun 2022 20:48:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=bzWpPF+M; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345913AbiFODUK (ORCPT + 99 others); Tue, 14 Jun 2022 23:20:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237302AbiFODUD (ORCPT ); Tue, 14 Jun 2022 23:20:03 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2055.outbound.protection.outlook.com [40.107.20.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD04C4ECF8; Tue, 14 Jun 2022 20:20:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aT1OI8COVBPuyBRT9rgUq1lZKHJLY4SaR6O4PbwuzqDVP9Y11xDBdqUfu7+rWkmt957d6HXy2XTcLihoF7ALeMbpSgDpF+C9iD0nL2LrnvJb/rgegknYq+yDoR4PePRcdpn3YE8cbOzbwHU/r8bExstiqR2xXpzHV0xD70EdKaqnKlvieyBkamwScfyrTswrKldoBU8NsPxt2WACGxwR7LYQH+41qptUNFIF6WE25N9RdZzjZ0h/qWcTigw95jWyGY9oHGxAgnwju6Fo9+o9HoboCVqP3NXhieWXX9jYesN8lXsROAj2luRUuDGZ5zm2noxI/G3ry9cyF4+QPzdGuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=izeN58nkKvbN/2XuBE3XQO8CoWEKdNWMsVYbjhuBz9s=; b=YlSgFYwrvZokZjgnNeD3nPilbOVQ6hQPZ68NYYZ5F1DDL/E785T7UIhEksD/NrNYuz5a+r+GSVqqAyA477kJSCmzEilcDaM71YoPEWa/DKiTscmEnQ0WcmngVj8Xy3RNH0KBIsZcyl7h/uqBRz/QzqWSJDcdTql8v8fs0K6Z+MTpskzYdV9E0PtnFCIirTI4xywuy+GNWBycdCc2LeSB5qqXVy/cbsIOAMx44C/Ue7U2rRd8KM9KTbRc8fMUJMU8BDhxlEpEEuFL/q15Qy4+A9jIeQ6c9CHna4XfBKWJu7nz/95Y7INXIf1cVh/TFjaGrxQbQOYdEOqZTtWSv+m5vg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=izeN58nkKvbN/2XuBE3XQO8CoWEKdNWMsVYbjhuBz9s=; b=bzWpPF+M94ytVmlQnBoaNFTIIJKRYFV5xU8f1ItG5obTjiKcKm9Ijs/bxFII0U6NQfht8qqcKt/9ZfIlBKUWf+RWeUOeJ7mRJh/UXp+q93TFSQePLnl5KPwoiMrEbPz/cLCUJetsXTFtH8zrmnmD+qgGlyMm0igraOYIrLVcbtA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) by PAXPR04MB8958.eurprd04.prod.outlook.com (2603:10a6:102:20d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.13; Wed, 15 Jun 2022 03:20:00 +0000 Received: from AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::bc48:7565:c619:62c3]) by AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::bc48:7565:c619:62c3%7]) with mapi id 15.20.5332.021; Wed, 15 Jun 2022 03:20:00 +0000 From: Ming Qian To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl Cc: shawnguo@kernel.org, robh+dt@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] media: v4l2-mem2mem: prevent pollerr when last_buffer_dequeued is set Date: Wed, 15 Jun 2022 11:19:20 +0800 Message-Id: <20220615031920.16118-1-ming.qian@nxp.com> X-Mailer: git-send-email 2.36.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SI2PR02CA0050.apcprd02.prod.outlook.com (2603:1096:4:196::11) To AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4b6b5b3b-c7a0-4977-de32-08da4e7dee51 X-MS-TrafficTypeDiagnostic: PAXPR04MB8958:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vMRl37RVnc4rJih4t9vHhwdBhm/32R3gLjXS3i01wM6ZovxU1+gswm9Slk5KPBFnt8xsYBdmI0aAnlRHLs/aRx8f8gZq6cDM2dORhOIDRRcKQySADrV10isTI7D0uIX0dy/l3vdf1Z4RpGwTVvwnTkhc3pb1Ihfgagsp6mmeojMkDbxg5aZzHhNLPEOejOZbCQ1wC36O1BrfYqzD/xB4k+6boNz+w5a+KZNzPW3PgkIoF2LnODUcnwAP5fkdHLPa4PLqo/80MG1BtHtJkmB6lX8KuSSrUitl4fJUpaGKc1Ad8MAScNiMP9opiRpRHgT9Sjx0QH+35r+2lFzLTUjTLtOkolLpNL6BqgaptFl//T+my4T9aqi0QehJqKPHLIFNmzXtKix9Re7VMLErfUKZGj6g3D2ooqT+bMee65qUICALt+FPBBA2h94l4Cl9jEJc+tAOv5xmGdIbn1PRCejUmwqMiilh1r2hl+ao8Xn5j0mQXbG5ElIrAgZy/2R85BbHyTUWnRTqfbC0LRvFb8unXCB2ewWWjdv0M1vJ0ltbkyW44RLyjyUNsIHB72QMdF1z+bhCtPoZqAWZbSJAcPjdMHBdclWv5qE3sbv0HsvE8o46p26M3iY8pcnWEUgoDmeuBpfGN20/i6C+XLHSmOV0Zek+t0rsEcwc4BWinlauRxkIU3z9VfPGMX4KFxmulgFF4FC7noFVkWW504S+M6gv0w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB6341.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(366004)(6666004)(2906002)(44832011)(26005)(508600001)(66556008)(66946007)(66476007)(36756003)(1076003)(186003)(83380400001)(2616005)(86362001)(38100700002)(8936002)(5660300002)(316002)(6506007)(7416002)(6512007)(6486002)(38350700002)(8676002)(4326008)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?/NrMQ4iG0FrwA3Y0dG9PzhSwm7bL978k5mUXERHSSyIgH9Ee6Zkil9R21Og0?= =?us-ascii?Q?oE2T5AWVVAEe8mMs8ZfiSY3VAdPjxTqpjhjz0OEbMRP1uZHyKxMrJhJ6cDr+?= =?us-ascii?Q?6dF31pQ6UUHjcS/8EVA4u4sBet7dtJGIZmnxrnX+Z6zadzr7tLpcG8+aIbF9?= =?us-ascii?Q?dubjIJrJC3j3YjkHupymg4DZIRvEqUxN92HvCdxotaTIQl1qS3qOLWyPOdPG?= =?us-ascii?Q?EBSAHBTK9d5HS8DqOXo/3py5IZoptQav1mUEGd3YvET7qVQ6T+5fcp2xDrgd?= =?us-ascii?Q?mJ7XIln5o/V6F4rWlr2GlZ84KSz+NJA2xBWtEBZvWOdlyeugHXsd24sIy7Wp?= =?us-ascii?Q?DRLe2Ss+wI0YED6236uGmGo+UIGMj8wTnk7nLmCzam8+DafQpvMRU7Wo9Rpf?= =?us-ascii?Q?hlyXMWlxkCSJdiuc71Mv9Jtg9iMXA1BSe+ib3Trl1T35TWkuDT9iQz+oSXRt?= =?us-ascii?Q?wiKGJM3ptsM4b1UqQZCdr5TYm5yDimmalNRGxcRud/w5gs73as+QlvBR/0qy?= =?us-ascii?Q?zPOkeeFp+g8NbonRWON5C16e4C2DMelEa7qElZyMnfo2ORVHLVS5kxieHH8X?= =?us-ascii?Q?pdWYVXhZeWH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FdMrUTN40dx?= =?us-ascii?Q?vrcYpf1gVhX6JfJ1haKwar0PJxKCwHQiGnSm9b1b4JQ1gBg9RvCE7/m+/9BA?= =?us-ascii?Q?9X+zARPkFTbI8sA52LEMgUSRkbzwRBQIHvAUD/uT9tIUGm4aa1EF2IyvIiTW?= =?us-ascii?Q?n+smKz8BMxIXKyMumQh2IxAuAj5Omp5pA/nZToxHw2IgiiZYSjjZuuXfditn?= =?us-ascii?Q?pPJX986B/Eehc5ULdhpFnUcPCKgF3Ai1WLAvwIIDNcSkVZqYqmQu2tZdpc3c?= =?us-ascii?Q?FaVc8W6abw=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4b6b5b3b-c7a0-4977-de32-08da4e7dee51 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6341.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2022 03:20:00.5536 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fJo50EfOJ43zOwnz8fDUX8ynvH/pubsR21STMUZ4QyloWyuDOa6Vctay14m9itz/8BlMwPmLGMeRzzDCBBxXqA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8958 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the last buffer was dequeued from the capture queue, signal userspace. DQBUF(CAPTURE) will return -EPIPE. But if output queue is empty and capture queue is empty, v4l2_m2m_poll_for_data will return EPOLLERR, This is very easy to happen in drain. When last_buffer_dequeued is set, we shouldn't return EPOLLERR, but return EPOLLIN | EPOLLRDNORM. Fixes: 1698a7f151126 ("media: v4l2-mem2mem: simplify poll logic") Signed-off-by: Ming Qian --- drivers/media/v4l2-core/v4l2-mem2mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c index 6469f9a25a4e..837e1855f94b 100644 --- a/drivers/media/v4l2-core/v4l2-mem2mem.c +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c @@ -925,7 +925,7 @@ static __poll_t v4l2_m2m_poll_for_data(struct file *file, if ((!src_q->streaming || src_q->error || list_empty(&src_q->queued_list)) && (!dst_q->streaming || dst_q->error || - list_empty(&dst_q->queued_list))) + (list_empty(&dst_q->queued_list) && !dst_q->last_buffer_dequeued))) return EPOLLERR; spin_lock_irqsave(&src_q->done_lock, flags); -- 2.36.1