From nobody Sat Nov 30 00:33:06 2024 Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011032.outbound.protection.outlook.com [52.101.70.32]) (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 D915A154BFC; Fri, 13 Sep 2024 06:23:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726208608; cv=fail; b=XLGNgWq6yvQqSuvMUBnMlSZhgeN0BITQMz71q22eK8GvGlCQSBqt1OPK5eb+oux987/khqwjg0EplOaf0d3db8I45LwwVGAR29uZFqQsnOc9YpL+rYMaZ1thXp3ioUngDehWTk/q0zzAHsIixQSwfODa677gsy2l5vq+kAuORS8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726208608; c=relaxed/simple; bh=cmVOrOaH7m5KrPgDaQFEBH3VGdyapZhflsLBP7uKJio=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=NjVSnNBlxY0ye4noO8RUkfKu5mqq2fGPz4yiBxa2HeNnyWNISHG4ePrWg06816AZlqZO+p7MkwyMo07SoBi6whlc8UOUcvBxFX+CmFoGsv5lQkFUYssJxw2nMOcvGXhJ2P2TySjIG9q6RdZQLvkq3CPxbbpj0EkgxJ96Xran3qk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=i80neMvm; arc=fail smtp.client-ip=52.101.70.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="i80neMvm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PrjbvA7jzfheHADSs02460LfqdTyx7WoP/7kJNSLUUyTu7aZ2S4JXKILo1BB7L0vSouNRaZp3lvf/YQvwq4ceAqDEKmEgw3zVuzTsB5oGFZCA91l2Eb0CZFIOMJMOtR5EAKvs3538nDrnT7QvXGXXVnplUJyI4HOOHNDE0rUtb95NZtb2fuBUIye1EhrjqkDJkd3qNaW6ab8i7Emody5jGU8p+0NA6IrAFfEdElxmI3oAKisB8ZdwwST6UOtar40jJ5rCkiZY8TnOA3ROYVojdM2nrbI7NMB/HpbFsu27yiHc4+2ZvVMJk13clUoQJv1MQ4Ay3ICe3S7mgg0QsNc2w== 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=rxXHXRF3GEQ+J4Ru/FpcKVYu2K5fm8t+NaQn9uhGukQ=; b=ZwsmcnAfEfehL39NbIFSaGvuibe/XPsntnjrnsg7ePD4v0WoewkaZcsHvsqFVClsl1YJ9/hvF+/VQrcJ0bNWn2wLgvfr9iZW6Map/KS4+NmQwKjY6btTolB0rvchaahIRfuxvh04d9KFXME9swBZY0pBtXXcRAVH+fqeESlpvNEo5+eyzUqoTvpYbH0aIXcQjJ2747ZDprmVl4yskP0ghMXvoKzZbs1U99C5D4gsuNTlHQrTiv4XXAHzYzUprJ8+xMNO3vZtt10EklDgbwevoVP6r8bZd5F2CBbYfnt9gjTNRxculQKz+3fipirKFQ86oy7sqXTYBT7ugKcYzs/PqA== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rxXHXRF3GEQ+J4Ru/FpcKVYu2K5fm8t+NaQn9uhGukQ=; b=i80neMvmeGonBG5QSj/yAghbmJnDNwnkjfk4C1h93UVA/G0zPrIjjUIPhCzvkrfTPuafEA8IuBx9my51i0Gt575fxMyD/5q/jjTwDI0sD7GNBtvn8ovEMk9dyS1Z8yK2SRKDB6bBASXDUroqA0WfrspV7mTDfdc4lFjGq04wVvRkyF1IsdBiFImIkQzlQm9loz9EJPmgx062GDNdT3b0PkOgD21X6zghmZPJdOHUampeTFFPyHyOo+7+2BjLbq9c+2Gv0VJ5lNohIOCh+a2oz5W24sRN3VfoR21A746vV/V64EQSjHr1KDWykF5yBKkKQLlN3gdhB4yE9Qw0RPTDyw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) by VI0PR04MB10856.eurprd04.prod.outlook.com (2603:10a6:800:267::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.17; Fri, 13 Sep 2024 06:23:23 +0000 Received: from PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87]) by PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87%5]) with mapi id 15.20.7962.017; Fri, 13 Sep 2024 06:23:23 +0000 From: Ming Qian To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl, mirela.rabulea@oss.nxp.com Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, xiahong.bao@nxp.com, eagle.zhou@nxp.com, tao.jiang_2@nxp.com, ming.qian@oss.nxp.com, linux-imx@nxp.com, imx@lists.linux.dev, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] media: imx-jpeg: Ensure power suppliers be suspended before detach them Date: Fri, 13 Sep 2024 15:22:54 +0900 Message-ID: <20240913062254.1886532-1-ming.qian@nxp.com> X-Mailer: git-send-email 2.43.0-rc1 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SG2PR02CA0009.apcprd02.prod.outlook.com (2603:1096:3:17::21) To PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8254:EE_|VI0PR04MB10856:EE_ X-MS-Office365-Filtering-Correlation-Id: 8ada7828-22ec-4b9b-1513-08dcd3bc91da X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|7416014|1800799024|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?zOba2f/+3v94XWKuzRxKR4Ob/ZAtQSuo2GjZ8K5KJmvDMb3CICBXuNZgFpKd?= =?us-ascii?Q?iypj9k137hN38zlv3ZgQHWTptjgGBMrn9BtGL9G2gsJyAKxYPFGcJzYdkphK?= =?us-ascii?Q?RiJx6lJdRjMqZAP0xcW72KmqP4+shXVRMjEpv0hdasxvK2+gA26XcaxlgO5e?= =?us-ascii?Q?R5bM5VHJR2w1wCBIfWZt7wj+Ooo0WncETsXKQ88xBzvXTyzIXdpEUNkYjM6l?= =?us-ascii?Q?nH0bK7IX8uQcIRJzPxa1OfDAKEqYAPlqIGC9a2txDVb29mxfHVGNsuHvL3Sj?= =?us-ascii?Q?G41R5gj2PUpl0ioKqy26tHnAvJwzMLYFr2o9RRudwcWlduJxDvs9tbi6AScs?= =?us-ascii?Q?vy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C57kJ91e0DSQrndOrPqSV/LknG6Zl8BN?= =?us-ascii?Q?g2VnnQizUQzR8Fjm/VZ9SZ6n1k8gnfEJFedqE9bO4mEQHi8A8Ql48q/ZoovD?= =?us-ascii?Q?svp3Ytf5t8jJO50zBoRe2LuxuVJCkVBdJdjGwQ607GpQAkZDvAnypLZthM5l?= =?us-ascii?Q?hqpro9S3qYMRf6+YJTbkm2wqVw6HxD6FkEScX58EZKA0QlJsDA=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8254.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(7416014)(1800799024)(376014)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?quIWXIP4jEgf5R6PY2eryZiuOszjGYUbAJVylvZD71ko92kmtgUKtscPvb07?= =?us-ascii?Q?1kGG3BSFGQTv3gtCWmYgm3SwF8Cq6GHDobL43ElhXeAwTkHZtvzWJUVEC8pO?= =?us-ascii?Q?9zrNwDE1sQ5ihADf/ogyh6h6HW+Xh5By0e/jTjdNFZzEiPNJrK9Ux72Xt6RW?= =?us-ascii?Q?hpVWwOOQP1xb4xlWvO2XuhUiPvqpKKfYKQodIsU0rhgZ4zzFM1lEUKdD1DRi?= =?us-ascii?Q?DkkpJGDaPlXapTH7+36goTd+E+QzBq/hRE28k4S7izW7trTBF6e7ykGa9NdR?= =?us-ascii?Q?nsf7NwQtYCseCEABaPuCVo9Z3NIqxWQu9W4hkuir6Ez5A2ESLNkrb6mDbhr+?= =?us-ascii?Q?OG9Sc4GW2VMT6ywSf4vOF0PW0TmFgpehL4DFxXBZzSgjwVFf9Gz00Vi3DNd1?= =?us-ascii?Q?5NY/Ii/0sMmeXYNPjCH4c+2j8faAoVfrhkdQ1oSrxIa/HF9BgDMGI7Kp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9K1Q2+MNl3cLU8xdEsFPDfGNxufjVp7dKsz4l5hxvq?= =?us-ascii?Q?HUx29b1ZogssaMDfXrfnYQuehW8HusAX629aiKHbcWLwfnD/1NHdEIJwhwZI?= =?us-ascii?Q?i+DJ2xoLuaFACEGTPP+ikn0uXYl6Mi0yDmxKtvQ5UnZDYgkLt1N+1+zwloNt?= =?us-ascii?Q?c+FhuhRM0mlw2M47WMk56UawKlz7Aclj9DJOh3vQRTT5XHkCNLsH8Zi9moNe?= =?us-ascii?Q?u95fBpi5PkEVB/f0Tx/DJ0SLVSJSaO1dlVFW7GON?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8ada7828-22ec-4b9b-1513-08dcd3bc91da X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2024 06:23:23.6342 (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: FpCwINUc+G3NPjarmaigioX6r89LqTQKBUVv0vgjTaj/oWA8ZKCkj7KJ2fEI48R0ENBJjT9mC3QCkbxKx+qjrQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0PR04MB10856 Content-Type: text/plain; charset="utf-8" The power suppliers are always requested to suspend asynchronously, dev_pm_domain_detach() requires the caller to ensure proper synchronization of this function with power management callbacks. otherwise the detach may led to kernel panic, like below: [ 1457.107934] Unable to handle kernel NULL pointer dereference at virtual = address 0000000000000040 [ 1457.116777] Mem abort info: [ 1457.119589] ESR =3D 0x0000000096000004 [ 1457.123358] EC =3D 0x25: DABT (current EL), IL =3D 32 bits [ 1457.128692] SET =3D 0, FnV =3D 0 [ 1457.131764] EA =3D 0, S1PTW =3D 0 [ 1457.134920] FSC =3D 0x04: level 0 translation fault [ 1457.139812] Data abort info: [ 1457.142707] ISV =3D 0, ISS =3D 0x00000004, ISS2 =3D 0x00000000 [ 1457.148196] CM =3D 0, WnR =3D 0, TnD =3D 0, TagAccess =3D 0 [ 1457.153256] GCS =3D 0, Overlay =3D 0, DirtyBit =3D 0, Xs =3D 0 [ 1457.158563] user pgtable: 4k pages, 48-bit VAs, pgdp=3D00000001138b6000 [ 1457.165000] [0000000000000040] pgd=3D0000000000000000, p4d=3D00000000000= 00000 [ 1457.171792] Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP [ 1457.178045] Modules linked in: v4l2_jpeg wave6_vpu_ctrl(-) [last unloade= d: mxc_jpeg_encdec] [ 1457.186383] CPU: 0 PID: 51938 Comm: kworker/0:3 Not tainted 6.6.36-gd23d= 64eea511 #66 [ 1457.194112] Hardware name: NXP i.MX95 19X19 board (DT) [ 1457.199236] Workqueue: pm pm_runtime_work [ 1457.203247] pstate: 60400009 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE= =3D--) [ 1457.210188] pc : genpd_runtime_suspend+0x20/0x290 [ 1457.214886] lr : __rpm_callback+0x48/0x1d8 [ 1457.218968] sp : ffff80008250bc50 [ 1457.222270] x29: ffff80008250bc50 x28: 0000000000000000 x27: 00000000000= 00000 [ 1457.229394] x26: 0000000000000000 x25: 0000000000000008 x24: 00000000000= f4240 [ 1457.236518] x23: 0000000000000000 x22: ffff00008590f0e4 x21: 00000000000= 00008 [ 1457.243642] x20: ffff80008099c434 x19: ffff00008590f000 x18: fffffffffff= fffff [ 1457.250766] x17: 5300326563697665 x16: 645f676e696c6f6f x15: 63343a6d726= f6674 [ 1457.257890] x14: 0000000000000004 x13: 00000000000003a4 x12: 00000000000= 00002 [ 1457.265014] x11: 0000000000000000 x10: 0000000000000a60 x9 : ffff8000825= 0bbb0 [ 1457.272138] x8 : ffff000092937200 x7 : ffff0003fdf6af80 x6 : 00000000000= 00000 [ 1457.279262] x5 : 00000000410fd050 x4 : 0000000000200000 x3 : 00000000000= 00000 [ 1457.286386] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff0000859= 0f000 [ 1457.293510] Call trace: [ 1457.295946] genpd_runtime_suspend+0x20/0x290 [ 1457.300296] __rpm_callback+0x48/0x1d8 [ 1457.304038] rpm_callback+0x6c/0x78 [ 1457.307515] rpm_suspend+0x10c/0x570 [ 1457.311077] pm_runtime_work+0xc4/0xc8 [ 1457.314813] process_one_work+0x138/0x248 [ 1457.318816] worker_thread+0x320/0x438 [ 1457.322552] kthread+0x110/0x114 [ 1457.325767] ret_from_fork+0x10/0x20 Fixes: 2db16c6ed72c ("media: imx-jpeg: Add V4L2 driver for i.MX8 JPEG Encod= er/Decoder") Signed-off-by: Ming Qian Reviewed-by: TaoJiang --- drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c b/drivers/media= /platform/nxp/imx-jpeg/mxc-jpeg.c index 979b03b112f8..1bf85c1cf964 100644 --- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c @@ -2679,6 +2679,8 @@ static void mxc_jpeg_detach_pm_domains(struct mxc_jpe= g_dev *jpeg) int i; =20 for (i =3D 0; i < jpeg->num_domains; i++) { + if (jpeg->pd_dev[i] && !pm_runtime_suspended(jpeg->pd_dev[i])) + pm_runtime_force_suspend(jpeg->pd_dev[i]); if (jpeg->pd_link[i] && !IS_ERR(jpeg->pd_link[i])) device_link_del(jpeg->pd_link[i]); if (jpeg->pd_dev[i] && !IS_ERR(jpeg->pd_dev[i])) --=20 2.43.0-rc1