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: 13815048 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2058.outbound.protection.outlook.com [40.107.21.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5C2513D2B2 for ; Sun, 29 Sep 2024 10:16:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727604998; cv=fail; b=egMRGNSa9MROm9Un5DOOwjD2IXJrALwt0vkjz0cQHYNNKhKvK35Y4AjshNG/V2m8ahEXmQR3bpL98xt9V2THkcompv2U9rX1bZFALpmAVhyF2cgjCC3PgnvA7npBoHFBkZA/XAh4VIymt7T9ER1jp4bmrI6K8/cOUIXdBJJzpIo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727604998; c=relaxed/simple; bh=oUy+31n7CBKUGGQmzAOyf9xQBztVpGCE27ZHj/LMnJE=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=pEsCCyKM8c9L/4MB4k/XjLYs9F/rFd4nfh8T3G4WmmJnWufHspbVNl7u0haNmZmer7N7TOplbbxYwaZCehOnZg7rTzpxShi0RQV2DFW/JZWwtKrTjYYK2uB5VureTguA/D4PkRzpeE6dqeVBup8R4RZe9iOCzptSwdy3AcLszsQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=bb1AF49E; arc=fail smtp.client-ip=40.107.21.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="bb1AF49E" 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) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: 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?2Md5V5JGMb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pwKjahMzlTuKEThUoTj4bdiJW9IwzsO+nPq39ObHEC+36o1lLG?= =?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?D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q?NFQVWnfEBR63CY53/WItz+aPJSIkQPK+ebysnmR5QJSDWMYwlSBh1raS6Buptt6at?= =?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 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)