From patchwork Wed Jun 15 03:19:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 12881778 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1EE3FC43334 for ; Wed, 15 Jun 2022 03:21:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=J1I7eW9tepkttGlgjgd4y43bbZC4qkekhV6wX5dySZs=; b=x2nq5GZ1mfLXfC fkXVcavFSkQByoFxObgcX5EGsWFAnmsXAbLcPxljHmNgkLTyDW4CS2xz6VgUAY3QP+b2nsKJ04rGe /dhhzjGbw07/57wkksMHPjjo1NBsCX4OqfTaUu4RH1JQ/kqv9nwpBoabLGbXMUkrSFp+JHrpXmkHm ch7EyC0mLYvmto4jBBEO1vbB8SVAQCqru/r/TkAsqESi29CjjwqkZq2Mi62IQjJJQB8Fo3M9mANdh rQlFduXF1me4TDc1UdYrWBGNDug5QIJmXutNgxp4rK8QBWGUZ0Edfm00Cr0lAhlukPL3hiW72S1zj DYZ7bBVnKjW/CSUi3kHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o1JZh-00CKGX-L3; Wed, 15 Jun 2022 03:20:09 +0000 Received: from mail-db8eur05on20628.outbound.protection.outlook.com ([2a01:111:f400:7e1a::628] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o1JZe-00CKFG-Ck for linux-arm-kernel@lists.infradead.org; Wed, 15 Jun 2022 03:20:08 +0000 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 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: /NrMQ4iG0FrwA3Y0dG9PzhSwm7bL978k5mUXERHSSyIgH9Ee6Zkil9R21Og0oE2T5AWVVAEe8mMs8ZfiSY3VAdPjxTqpjhjz0OEbMRP1uZHyKxMrJhJ6cDr+6dF31pQ6UUHjcS/8EVA4u4sBet7dtJGIZmnxrnX+Z6zadzr7tLpcG8+aIbF9dubjIJrJC3j3YjkHupymg4DZIRvEqUxN92HvCdxotaTIQl1qS3qOLWyPOdPGEBSAHBTK9d5HS8DqOXo/3py5IZoptQav1mUEGd3YvET7qVQ6T+5fcp2xDrgdmJ7XIln5o/V6F4rWlr2GlZ84KSz+NJA2xBWtEBZvWOdlyeugHXsd24sIy7WpDRLe2Ss+wI0YED6236uGmGo+UIGMj8wTnk7nLmCzam8+DafQpvMRU7Wo9RpfhlyXMWlxkCSJdiuc71Mv9Jtg9iMXA1BSe+ib3Trl1T35TWkuDT9iQz+oSXRtwiKGJM3ptsM4b1UqQZCdr5TYm5yDimmalNRGxcRud/w5gs73as+QlvBR/0qyzPOkeeFp+g8NbonRWON5C16e4C2DMelEa7qElZyMnfo2ORVHLVS5kxieHH8XpdWYVXhZeWHvIYNgZ5UWZ6C0ABkxNKC9K0LItt2+xag8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wIIDNcSkVZqYqmQu2tZdpc3cFaVc8W6abw== 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220614_202006_650885_E95480DD X-CRM114-Status: GOOD ( 10.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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);