From patchwork Sun Sep 29 10:16:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "G.N. Zhou (OSS)" X-Patchwork-Id: 13815057 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 73449CF6499 for ; Sun, 29 Sep 2024 10:19:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version: Content-Transfer-Encoding:Content-Type: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=Q/CYtVWryVyvSuY5gMTCtbmW5F2rQN3HY7g/bDIRbDU=; b=w2gddck0qrbXoFch25f4igt4Hj BiABLWPetKhlYxRFon3KIAUM56x5Tl0PCPw58rvYUTY1ndopWtck73NMoOM45P48LCYOelDTrx/kH bF64LO1YsrTI5KEbH3LXshSjWvJOgajuOIB/akmxP1a7rmZh1bmIEqBzq//HxTX94m+1NbPrq4tGA lH6bTC8fzEBo0w1ng4cECnCBR/nXMvV2k7h8a4+RBcoRa5VFPFXIrBMsmLb1F+bHp8RM9SpLVrEtG GV/MLoGLWriKWNluWNhlGy2/ThvhUa/8FChKl4FCWG6RoidEyadf5HW8FguIllV/VXgsXruZ7yBKI z6ynr7hw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sur1g-0000000EbFu-2BLX; Sun, 29 Sep 2024 10:19:40 +0000 Received: from mail-vi1eur05on2061d.outbound.protection.outlook.com ([2a01:111:f403:2613::61d] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1suqyn-0000000Eavj-3vpQ for linux-arm-kernel@lists.infradead.org; Sun, 29 Sep 2024 10:16:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KV5NxwhCqz6bTkmQ2gDf89hPWpP0nqPvaIUZfhFmNEP2I3POBIlT1GKSzszYJX753Ho4n6Uz0bZoaY2rCrfmDfyWYF2RktmBC4p1niZcc7tSVaNEx+ePztXRIC2IKicbq2X3Vs2BNbeZKnhfQFfLZVi6yU5wCsTECWxIIQH1CytFCbTUSW2lP6pJ09FxeesK+tO/yeT33TcqJ2akObQbbRJOgYVc0GedyYtVwDxn34+z1isZBVy68V+7MQJzwsrojfkGaxeYlus3X1hay5yxEDIXRyXKVdjdD7tdkPU7i0OIMH6AW3kqblGv2NxhHr3a/NUf8gMgVZq+2FMrp0LoMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Q/CYtVWryVyvSuY5gMTCtbmW5F2rQN3HY7g/bDIRbDU=; b=woRIIu9OI3rNlTHlR+ltuevaG6MQxaQSb0Hh6+ASQ14FL/uWtbhwlPrZAzXoxb8mUvbwUzN9mecmATdNTJkMgmptkoOWuyBJYWC2/OCj0Bymrs/6GFyYJ+i8V0o/PKIvZirFrdWVv3CKf48ExKrOyMT2MkS305Z8Tf64L6dy/AQyDUdrC2cQPMwE+RuQ3Skce+BDEjxwaZKT/Bzmc4k6Ea5o2imTdumBCLLMVAJ8Be1O3jNiEfUKEtrR+NlQD1REh+wjWkW9Q1HemItwUwmgucsXgxgl0jL1z8tBSicL4gBGfdHKyfKYUsqW6ShHiyE934jvKy9AJiQ9hGxgGrLNXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Q/CYtVWryVyvSuY5gMTCtbmW5F2rQN3HY7g/bDIRbDU=; b=bb1AF49Ei7Sg1xrLKfqRK/2kcKlynnaeITZ3HvKvPHvFhIPBW3MvCT6G5IvH0zJWgIlbR6jXB3haXluEiWOJOZC1k6G+JNxgr8G+7vPu9FnguJYlIZ9PWguoPDilc5BIO7bj/h4fcf02VEyoiSH9okLzqopENtjrwKgH43818qcjXtwc+kn+ZHmJJMw4F/8lgtYDDwBsUxn5QFf/i32EpXcqG4xoeTxqm+Dnxehn4/WpgC0NeNMy+X9AELOxmEuPHhveG9p8MPzEV9ujAhKewEeLoRIb/BmlbbtabMNrHf35IJnJ216gYUYMbmcRJGcMQqdCbS7AY680nCdcH5MZZw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AS8PR04MB9080.eurprd04.prod.outlook.com (2603:10a6:20b:447::16) by VI1PR04MB7135.eurprd04.prod.outlook.com (2603:10a6:800:12c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.22; Sun, 29 Sep 2024 10:16:31 +0000 Received: from AS8PR04MB9080.eurprd04.prod.outlook.com ([fe80::93bd:316b:682f:5e59]) by AS8PR04MB9080.eurprd04.prod.outlook.com ([fe80::93bd:316b:682f:5e59%6]) with mapi id 15.20.8005.024; Sun, 29 Sep 2024 10:16:31 +0000 From: guoniu.zhou@oss.nxp.com To: rmfrfs@gmail.com, laurent.pinchart@ideasonboard.com, martink@posteo.de, kernel@puri.sm, mchehab@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com Cc: imx@lists.linux.dev, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] media: nxp: imx8mq-mipi-csi2: Fix CSI clocks always enabled issue Date: Sun, 29 Sep 2024 18:16:35 +0800 Message-Id: <20240929101635.1648234-1-guoniu.zhou@oss.nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SG2PR06CA0205.apcprd06.prod.outlook.com (2603:1096:4:68::13) To AS8PR04MB9080.eurprd04.prod.outlook.com (2603:10a6:20b:447::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB9080:EE_|VI1PR04MB7135:EE_ X-MS-Office365-Filtering-Correlation-Id: 24f5403a-36bc-416e-31cb-08dce06fc998 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?x98ILQgydyrRMwuO4Le7AWWHuSmTb4s?= =?utf-8?q?S3b/vMIalfv//ssOBF2971ufCZxaaQCK+dhBR2yHomX4WDyimW5LmfhN35NdV0gbr?= =?utf-8?q?suhUC15bR0sJDLUbK/vxFX97yVEq3DewNipbRPov94mZgdKiYVqLAOFjwAG+bi3pC?= =?utf-8?q?2Md5V5JGMbH3JdamvuenbHXstmwC48SkYvO2YkbJ/mwWHrSlFSAh9K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o1lLG?= =?utf-8?q?knL+ZP3keP+KzFCbwKQVgyXScXOmcgfYgAl4EDoDWeopYf7h3OyMQxGWw6QRUr8Cn?= =?utf-8?q?mxML498CJ3kqnZVXYc33d+iAfyoeso8Jsy8uvcIxuZ+qts59mMu4R1uSmH6igDvAp?= =?utf-8?q?GTHyZLUO3Y3Q8LCAKLuctB/2BE5Wm4wOZliMLnNghzW4igxuelcYpdZRAzC4b53nQ?= =?utf-8?q?ggepiqvcT9DY+Iu/Pd9eCHFGMaeehUNudKv+MlmoPwfufabrLNW58wFeJZ4hO4urI?= =?utf-8?q?0ZllBiB/EeMDwTUaQOqBTvbUIZ26gf674g=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR04MB9080.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(366016)(1800799024)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?IhA8xrdMGLd+KTJDqxSrxp+uNh1C?= =?utf-8?q?Yrzy/7S10Z5UHgxOxbpcZBROcxMrTAY182RQyhbhBI/fnCzNY6c9r/eJ2A1t2a/No?= =?utf-8?q?CkbSlL2uC2AppK4ZWH1UgtTvn+YjAxNwj3NX2yMBS9fNUkvRgv4xtY/z/wA4Zz+bt?= =?utf-8?q?CIjPa40Am1rrslVcDEVQMSCcNeevenH4Y04gvkz7zhd/slU2QgBEZrX3TAvo/CtO7?= =?utf-8?q?/7e/w6UeVg4W+gia8pvprdue2Avj4kOchTLDkZ39JKDJa0bLOHJbk0yVw+iFXzp4R?= =?utf-8?q?YkQV2vYiMZ1/N7yG1uFCLazBVSLMjuSncaMxzu64m9Qr8ZZUaGRimwmhf0X8JZwuG?= =?utf-8?q?D6WUqYEjx1gEDrdznbcJIFFPJxWqqtxmTU2VuGazo82bP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DWMYwlSBh1raS6Buptt6at?= =?utf-8?q?CQbrPGNS8wSAqxK1DMfc5GSc2uHeI3LNADidZbuLv8CMw1INTs2Y+WJQm4+xGmQrK?= =?utf-8?q?4T++XigHw8odz7pyceFJvgRRCUd6ICyR2ArADtmpig60xd/eolsDJZ3rww3tAP2/C?= =?utf-8?q?fmZN25BqN3JsXlcjprHtpNCQjP8dEXze7gemKgoNfuXrOPjxW+XKajBoAZMqVGWPw?= =?utf-8?q?C8eAqG0yGb6N+xuMrFBjtJosm4hYGsfAU1815tQlrD3F9hpMlv1E/8O8WhhwtIcd4?= =?utf-8?q?NQ75D0Yj7t5E?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 24f5403a-36bc-416e-31cb-08dce06fc998 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB9080.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2024 10:16:31.0982 (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: NwpP/AALwygF0NfVagEJ3ai7C/VmHxRwLn0E+dji/4m5ECFkf1JfmaOBk2Um4KLmgsroqJvfgpdpu+87SZ3Gsg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB7135 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240929_031641_990496_72997F7F X-CRM114-Status: GOOD ( 12.22 ) 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 From: "Guoniu.zhou" Fix CSI clocks always enabled issue after run system suspend/resume. The clocks for CSI will be enabled in imx8mq_mipi_csi_pm_resume() when system resume and the state of CSI will be set to ST_POWERED. It not only cause clock always enabled issue but also system hang issue on iMX8ULP platform since imx8mq_mipi_csi_pm_suspend() will access CSI registers if run system suspend/resume again, but the CSI power domain is not active. In order to fix this issue, using pm_runtime_force_suspend/resume instead of calling imx8mq_mipi_csi_pm_suspend/resume directly. Signed-off-by: Guoniu.zhou --- drivers/media/platform/nxp/imx8mq-mipi-csi2.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c index d4a6c5532969..15029bb81b35 100644 --- a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c +++ b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c @@ -697,8 +697,11 @@ static int imx8mq_mipi_csi_suspend(struct device *dev) { struct v4l2_subdev *sd = dev_get_drvdata(dev); struct csi_state *state = mipi_sd_to_csi2_state(sd); + int ret; - imx8mq_mipi_csi_pm_suspend(dev); + ret = pm_runtime_force_suspend(dev); + if (ret < 0) + return ret; state->state |= ST_SUSPENDED; @@ -713,7 +716,7 @@ static int imx8mq_mipi_csi_resume(struct device *dev) if (!(state->state & ST_SUSPENDED)) return 0; - return imx8mq_mipi_csi_pm_resume(dev); + return pm_runtime_force_resume(dev); } static int imx8mq_mipi_csi_runtime_suspend(struct device *dev)