From patchwork Tue Nov 1 08:05:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 13026719 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 10CBCFA373D for ; Tue, 1 Nov 2022 08:07:22 +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=0oY/FtmAY8NhkKtCqS6tBP+naoh7Kv/QIlku+Z/AKDA=; b=cV4IWgf0EcD9vn VJtMeDNRhs6D4NUA3xY7Jn2ly1yZtshqd1DL9QSmdy+vYIIYJS5/19jidZrv53jhbcAKbranPH+iB 6fqmuoh5nsArAq/FhSKdX9PEgJ3VXk0fT8X7Bep9CV0l3ctDLA+wBWWY+8Kw7mvxZlA55b/gTTGkh imbZKPiqYPfQzYxry3Cy/E7KauDQCFe52YK5BSIiSYvaL8E89jNsvol0ADrKGZE8j/PbBE36A3coH Mq2WN/V/QZtIGz9B46c5carsBPIhVA//Ls3J4/QnqU46stHjf2BwcbfP3l21K9ZPJXyFePnsEqIr6 tbI/4QU/u5YYQWMM9hfA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1opmHl-00324y-3T; Tue, 01 Nov 2022 08:06:13 +0000 Received: from mail-eopbgr60040.outbound.protection.outlook.com ([40.107.6.40] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1opmHi-00321R-P5 for linux-arm-kernel@lists.infradead.org; Tue, 01 Nov 2022 08:06:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=St/SXLbl3+R38KLT98trfX8Bp09RKu+j/JakTF8VTL722h2bHZGg1CRdCSDErBpQGMB3oM/kKU6iqR9PqFBxLxsqoHBxhOGZr3AHWsR34t4mP6p5h7AIMg2Anv9CxqeFRTpGGYLQu4ONVVi9OYZdpHJ2NEHUkwXKEEzCHxLkMnPSsTSfn4lMzk+EQIEj0IkQKTmVX47Yz3j42qpTbCFxzYZzCox68cPLe1pb7hTRniZ3xXcYRNeqN+lZ3q7+3IfFUVLxSFRDSdd+tmZi4GCTNaX5zGpAGfamSNplmd3T3B4FDXJxHhjuPt/koFbXWsYUV7j3Lb5qNLOw+4y/Zst/3g== 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=hm2Ge+k64ec+HQsSPlZIYhvBd+Ji/aU8WeSMcOgpWFg=; b=A1RvblYaZ5XWGEHT2HTZh+g5YRXZz/NefFASBGggwwG4K7NFaBnvTOe1+i7+25ce5I1ZRPlQ9qgxUXeATpXU6OkQ1mK9YyUrBp+jJYMchVzOu0dkPMHSbc7wprPhCzylBd9SmgLSkFD201UD+eP5D4nsfcqNWTXSmIFgUNMAnXMblsqdXieGNumlak2x/aVddjX+8vVoB7G2+HOBKAzOSB9X+ZUTNWdEIQIOk+5QSmjWbzZ4MAKJkPQXGYHMQZvbTjD6IoGKvpHTDIUlQ1tMo0f4DeC4aSDV3jtcDqkDfCJBDS5m/4iM7scRH+yjSGxA9+P2n1WCXCFGSz6Ui7GX4w== 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=hm2Ge+k64ec+HQsSPlZIYhvBd+Ji/aU8WeSMcOgpWFg=; b=KktXkYu3IA7Fv6EUpJZF/s8O5Hy9npbD3aS9Go5VKuDgyJahhpF0B/V/r3B6nm7N0KAqb0FGs6tNU/U06HjJjlp9PnjMCembwSrRCwvKjGVEmWnK1R1Oa4/GqiKn8yqdEPbdxPeRcbz/RmPBFMKE2iT0SJeZqFHFUFUCC/Bwf+s= 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 AM9PR04MB8729.eurprd04.prod.outlook.com (2603:10a6:20b:43c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.14; Tue, 1 Nov 2022 08:06:06 +0000 Received: from AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::976e:7d79:975e:8d23]) by AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::976e:7d79:975e:8d23%3]) with mapi id 15.20.5769.021; Tue, 1 Nov 2022 08:06:06 +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, xiahong.bao@nxp.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] media: amphion: check and cancel vpu before release Date: Tue, 1 Nov 2022 16:05:51 +0800 Message-Id: X-Mailer: git-send-email 2.38.1 X-ClientProxiedBy: SI1PR02CA0012.apcprd02.prod.outlook.com (2603:1096:4:1f7::8) To AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB6341:EE_|AM9PR04MB8729:EE_ X-MS-Office365-Filtering-Correlation-Id: 0492b578-46f0-473d-0f9b-08dabbdfed2e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: onLrMSDx2ejuNZghy7HNq5yTtkSsPIYSko5O12PkFWMDChgAiw02Uh7J5Ks3MqNzKuVYIJGyOQuOwRunqqNNff5Oa7KQ7bInqDQu2bAUUHpgWAosatoZcbMCwook96o0sJA8E0VamufkonLfgmjWkCWGTjqjc+W+BLJYnOCvG0IzmX23bfpIDQb0NVo7gD3S7qdH1c69GW/WzlfTAeI3jxhrnnL/W64w8PZ0xSZ4lMK1tCTtiwfmbqEGwd9kIIvW5Wqtkl/OaCRt1B6k+/Gcl+NHE3AzXKrS7YG8Matz5+Fxc4JcWAyHz8oM9H71kzKD+kT7CvbgPcV2F7IR6Xci4xfFlACYR50GgkSiw7V33SXlfzBe9olh9rYms1iOrR+YQIJLE5S6LVERIGx1dyYWIZhB7m0gU9vFkiJLt/aEG0WYFgw0oXDjnz9/BZrWblO2z5yIJN1ccRd7TDBZQRYBj5p+UpdEiUa0Gg93PjyCIwnnNGlGp4c26AQ0IP0ar1UVry60QAUrm5XEk1+R+IKv3u0JogOLLgiavK2PZ9UUeXVJcLq/9mhZczs4W4DDnL58XqAeZwKsKloUCsRaDaCBueYngLwCU5CK+hT2F35+Klwpou2p3i6Dsl738nBMumXqvRBNuq91tX2xYqN5pwLFzGUVw8U5sWbAOaLh8PyxherG0EfeQVIY0RrYfJxdSRUOBfZENqt1ODzPzJCxt/3KlrAtsu06T212lvW2+sR25xlVXd/z5ShoVJiDrm95fMm9eSiv3MWZ1c3uklYu6cJTEA== 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:(13230022)(4636009)(136003)(396003)(366004)(346002)(376002)(39860400002)(451199015)(36756003)(86362001)(44832011)(2906002)(83380400001)(6486002)(5660300002)(66476007)(7416002)(41300700001)(66556008)(4326008)(8936002)(8676002)(38350700002)(316002)(2616005)(6666004)(478600001)(6506007)(52116002)(66946007)(38100700002)(26005)(6512007)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DFWzkOIdVryqUhOxDaIaFvcpIh8wYQdqFIfx2vCFJQz5BJlafGC7MZBDA8WbenyY90+x1HqfS7Hp4pDKhwzgIGPDZ5FHWLP+G0HjNN5OXVoHkyt1biDMDqz+jAqqH8orII3Hj4hUpK5y/q93l5GaA6VLOzkLB63rfcLMJXYrnzKobX448jBA+3d/V6ob8+6GZLAIizDai70UT1bDKKt8wZUMb4Q3hNBEOtwZwmO2ZFhiAug9hXtQJkeiQjCcJIlJevl7I6exscDfzbxseeVM5zfff+nS53f7gqHVaBfbZJOM1yrvoNrAxPxK+j02XEEXSk9UkJ19sClsgH+yI87MUIHZAlMSPrSrhhhBHpct1jWORn87Vp6NCEAOeiuov6Q9hI++yTBrDOUw88n0VT0w3b2UbEYfaTx15LxtAuq/r/ufDyCDMQ1mJ3uxV/0pgELxtgp+rTDLgG5izOiY5UUGXt4nv1HnxCaxZ0JBy736oGrqukQn95Rhr8EiqOYFIsVhGu/wvlEXVVt2/ROrWSKP04rfmzJ8254F3jNbiQbSPtfpJD23iA7laVbRWNLJFNR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0492b578-46f0-473d-0f9b-08dabbdfed2e X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6341.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2022 08:06:05.9697 (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: pZHo9mALCKrMk2aaMxBMeGjgR0TA0xAnlZMyLM7bXNBTvHVxfU64wQEj8YX4AJl0k8izqp7IvFkghIPz8yNWSw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8729 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221101_010610_841677_C5E9D8E0 X-CRM114-Status: GOOD ( 10.25 ) 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 driver need to cancel vpu before releasing the vpu instance, but it doesn't want to release the m2m_ctx before the release callback of instance is called, as driver may access the m2m_ctx in handling some event which may be received in releasing instance. check and cancel the unstopped instance before release. Fixes: d91d7bc85062 ("media: amphion: release m2m ctx when releasing vpu instance") Signed-off-by: Ming Qian --- drivers/media/platform/amphion/vpu_v4l2.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/media/platform/amphion/vpu_v4l2.c b/drivers/media/platform/amphion/vpu_v4l2.c index 99ad2f1c5a53..845fc53d8937 100644 --- a/drivers/media/platform/amphion/vpu_v4l2.c +++ b/drivers/media/platform/amphion/vpu_v4l2.c @@ -767,6 +767,23 @@ int vpu_v4l2_open(struct file *file, struct vpu_inst *inst) return ret; } +static void vpu_v4l2_check_and_cancel(struct file *file, struct vpu_inst *inst) +{ + struct vb2_queue *vq; + + vpu_inst_lock(inst); + + vq = v4l2_m2m_get_src_vq(inst->fh.m2m_ctx); + if (vb2_is_streaming(vq)) + v4l2_m2m_streamoff(file, inst->fh.m2m_ctx, vq->type); + + vq = v4l2_m2m_get_dst_vq(inst->fh.m2m_ctx); + if (vb2_is_streaming(vq)) + v4l2_m2m_streamoff(file, inst->fh.m2m_ctx, vq->type); + + vpu_inst_unlock(inst); +} + int vpu_v4l2_close(struct file *file) { struct vpu_dev *vpu = video_drvdata(file); @@ -774,6 +791,7 @@ int vpu_v4l2_close(struct file *file) vpu_trace(vpu->dev, "tgid = %d, pid = %d, inst = %p\n", inst->tgid, inst->pid, inst); + vpu_v4l2_check_and_cancel(file, inst); call_void_vop(inst, release); vpu_inst_unregister(inst); vpu_inst_put(inst);