From patchwork Fri Jul 12 08:34:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13731392 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 4979EC3DA45 for ; Fri, 12 Jul 2024 08:28:10 +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:Cc:To: In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type: Subject:Date:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0vbBdALk7Dt7D/DXgkbkRMc+ZTf7bDhD5YGcNlMAt8g=; b=xdNEVXNgXOplZJz1I1XZH0l3X6 3X279s6Kg3lu3m13yVYIeo8BbIv1Soc4wkyHSYL2YBMqadN3tL+aFbFUGNybhoBLSUwZE8AohAlEW pVXVQSXqrBqnnYmNyOL/KVaye24lEN5PB0c+x6itoPW9ONidUWOifIxS0yIGlmf3Wbk1gsFHNCkcp +vI9ljlAtOdSfF7fd+VXPxgPV7e2QeWilX9rMNWlz7dVeCzcjDWGLNy6wZ0QggxKGq/3lqt2XgtB2 s6tO7im9gM6ZhRWbfXNKR8wqEVXgiSFIk7F/+feFTJG6THdMX+sQvvEqhY9Z5nDYAyRtRTfHBgbti fpYfMlXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSBdI-0000000GtWf-1fa7; Fri, 12 Jul 2024 08:28:00 +0000 Received: from mail-northeuropeazlp170120003.outbound.protection.outlook.com ([2a01:111:f403:c200::3] helo=DU2PR03CU002.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSBbj-0000000Gszn-1qUf for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 08:26:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=M/AajlnpKB/gMnUfffBkw/WBmjfMgX8kXCJSrgxIMcP5PYITde1fYTAjII0bW91HacQw9DB4KPbsO7TtRW/XlKplpJleFgYnzxo2qJKBbs2ONKdiu1EhPHEEhjUZOG4fq5sydJaCcAlwvvvuW6oSUrvOEsCd6AXPtcQqiX3U94ITTE43UCRJNh68GtmwhptS1eTdKof+viFxz2csZ4ECUGhT24lnmxolvnUp/YmVEq059ifqiSS+uAp3FcTVrggc8yQ2MqYaIvhnuKPs+pELL27qgtS32tPo6zzj2pnsbs5mHmkngMF312b6/lVt8/vDf6oLhL5KwuVOzfbItno8Ng== 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=0vbBdALk7Dt7D/DXgkbkRMc+ZTf7bDhD5YGcNlMAt8g=; b=vDMDLKAGPWuUKoSi44wrbdXYmv4cYrKDYFzvZba/21zxj9osiv01rSNvixFVL1MjnuhgYdhnu+nJ4Dn1M7ec+ySDXEpm5Pkk2tYbUlX92qepdXzS+lb5tZTvdcN7JFiem8QA4LneT1d0L+37R6VxkIE2wfzSrHENZlBc0asSg9DcHRHzR2ZPGnUfmnN1vkZh9BEwwlIlpD3gqhvlr3x8ZRNoDDEfr/zVxjL50Sf4uxjsueWAWod+wxHC21Z+yQr1cqT27tpOEBc/zaAk54vy1MrIoga4oxYllRTe+Gj9C0JTK4nVMBIBB6RBE+TBTEFNK1O6Ylo2Y9gvNjS7QitI2A== 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=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0vbBdALk7Dt7D/DXgkbkRMc+ZTf7bDhD5YGcNlMAt8g=; b=FrFOvG3IlLOLrFJ604DyeeYF2Eyav7ldjn4ngmqrYLDvsQvEVePcCnpDhZlc8/j/PZNI5uROqv/gu8t732aSuuMV3gMhLDbgJ4u6CjRSGV4XSvY7GbBJQ/FDyvPqRhbjFhWgUrhyxUVswwYflI8rXQYb8ESWPEOBT8aY6Xa/yic= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) by DU2PR04MB8709.eurprd04.prod.outlook.com (2603:10a6:10:2dc::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.22; Fri, 12 Jul 2024 08:26:20 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%4]) with mapi id 15.20.7762.020; Fri, 12 Jul 2024 08:26:20 +0000 From: "Peng Fan (OSS)" Date: Fri, 12 Jul 2024 16:34:59 +0800 Subject: [PATCH 6/6] remoteproc: imx_rproc: handle system off for i.MX7ULP Message-Id: <20240712-imx_rproc-v1-6-7bcf6732d328@nxp.com> References: <20240712-imx_rproc-v1-0-7bcf6732d328@nxp.com> In-Reply-To: <20240712-imx_rproc-v1-0-7bcf6732d328@nxp.com> To: Bjorn Andersson , Mathieu Poirier , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Richard Zhu Cc: linux-remoteproc@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Peng Fan , Jacky Bai X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1720773307; l=2938; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=C4WWZBa/4F0rqsRfT5vBgK7Yyzk7BZUYKwHPL5XAbGk=; b=cQIZuDUpZH6glPAucwaT2CORGE0InjVZao9iJDbVvi6iccKXWOHj+AZE2P0KsyaaXhN2jtrGy goF16jcCn85AYFQpcg90PX3JnMQePrM2Sk5g9ODJZPU+H2RgotQaAUY X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI2P153CA0013.APCP153.PROD.OUTLOOK.COM (2603:1096:4:140::12) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|DU2PR04MB8709:EE_ X-MS-Office365-Filtering-Correlation-Id: c1bd6c9b-f0a5-4a74-f70d-08dca24c4ee4 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|52116014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Z8I/v7AaafvkqDIbK4UH1iOnTfYLtSd?= =?utf-8?q?25sKQLp2RQxMlr6asmX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en4AX+Arkcj7erwjAjOBZz8D6We82UWJ84WasY09HeXpcaiWjGT?= =?utf-8?q?4Lilse4g3XcWOiuIfycYbJ8np+mlMs97bgZkqN8R8JWsPTlO8jFWxOs/4aukLzaIt?= =?utf-8?q?zFl6dNtMMFf65BexAc90Z3PHmbucliKL7uOmLdoyBpMaUWwBvRI2/IJ43f8DsnAD1?= =?utf-8?q?nRfo+zBspLRLAMdAslsOp8We5zyOy+OaXVQ0ulYwNKjH5hzR4b12jr8myl3Yzfvgs?= =?utf-8?q?810VlYvZltMScdig9dMqPe88Ias+8rRZBLiuWyMYpYT8Ve/FiT+ftztnzaB6GhYqt?= =?utf-8?q?7W+XfJxYEeF4WsZVE7V9nIHx+6xN2M3wNKzkGgQ+0ExFfGFT4yFBsA2RGFs8V/1tC?= =?utf-8?q?ClDS/wwwPoGyvRAQhK9c+jQdkM5/Bt28m0jppDtV5V2eexa0nnlGiOqAaz8GJT5Bz?= =?utf-8?q?YzRTG1wo+hS9nUFpe/tO4J+yLsLKIb606A=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8459.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(52116014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Ea+cwz58JLr5raKsWw/c/inFjtDS?= =?utf-8?q?vPwL1Hyavf2VwMsPm5IPmBCxKPVKgO/yds0vXpJNSWOb3IDVirOVR7SGbqoqDeCv0?= =?utf-8?q?t+sIWqoESc8FnzaLilrztto5IWmpvcFcn5UUxmjG+oZiNKvx4fTpbrqgEtf7Z/YBX?= =?utf-8?q?tX0+LFJ8YsUzzwE0qeyasLsYY7M+bLtFsg5H5h9EX6pfUzd4FHrj4dQMerUGHiQ4K?= =?utf-8?q?If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-8?q?s4fJHrR11rDi7YEkrkp2GOSz6ijgh7Rflbe5IRpu3sMSCYRB4sPlK6M9E1aYHMzyt?= =?utf-8?q?A2Z602TuUYroos8EI0TSOCw818WjIlRxePw6kiSm2gMUAxS0zr8sYnebTPnTekuIA?= =?utf-8?q?96lBgKAc4YOPAapQXTtQJBlDDsMl6iVANl5EzlKnHqv0JCyjO/ODgXdXOyyKGlNhx?= =?utf-8?q?/zoCMHvZDCh0bGqET24TQza8RSOYWAcS4NdXo9QsBQDCoRHO4JmOyZ2ABsunWD492?= =?utf-8?q?kTRjrn7HX622ivpEhTCIeSzD/dEQ3ml1+EUbRtsik08+9wrsYkIAn8bUxWX1b0jAz?= =?utf-8?q?xRkyUvrFKhd4plW5mq3qIm8KzroLU1Kga49wHy3DpMeHT4VabtOha5PoDHC+yfu/b?= =?utf-8?q?oBhE52NdIxiXKrwjWzQHqIOzyJM7IG2KKtbhWFyaUATUtcDnxdy44xOABqByTV/Ob?= =?utf-8?q?XuEgFjZl3MAv?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c1bd6c9b-f0a5-4a74-f70d-08dca24c4ee4 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2024 08:26:20.5739 (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: zvFfVaqOR60f7a9+F5EXeJRwrwDB3dpeR3ht0pc+oP3CcrPLR3wsdWynkFqKoysatRosw3+a/YZKzyhJdgAL6w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8709 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_012623_529534_052F06DE X-CRM114-Status: GOOD ( 16.21 ) 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: Peng Fan The i.MX7ULP Cortex-A7 is under control of Cortex-M4. The i.MX7ULP Linux poweroff and restart rely on rpmsg driver to send a message to Cortex-M4 firmware. Then Cortex-A7 could poweroff or restart by Cortex-M4 to configure the i.MX7ULP power controller properly. However the reboot and restart kernel common code use atomic notifier, so with blocking tx mailbox will trigger kernel dump, because of blocking mailbox will use wait_for_completion_timeout. In such case, linux no need to wait for completion. Current patch is to use non-blocking tx mailbox channel when system is going to poweroff or restart. Reviewed-by: Jacky Bai Signed-off-by: Peng Fan --- drivers/remoteproc/imx_rproc.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c index 01cf1dfb2e87..e1abf110abc9 100644 --- a/drivers/remoteproc/imx_rproc.c +++ b/drivers/remoteproc/imx_rproc.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -114,6 +115,7 @@ struct imx_rproc { u32 entry; /* cpu start address */ u32 core_index; struct dev_pm_domain_list *pd_list; + struct sys_off_data data; }; static const struct imx_rproc_att imx_rproc_att_imx93[] = { @@ -1050,6 +1052,22 @@ static int imx_rproc_clk_enable(struct imx_rproc *priv) return 0; } +static int imx_rproc_sys_off_handler(struct sys_off_data *data) +{ + struct rproc *rproc = data->cb_data; + int ret; + + imx_rproc_free_mbox(rproc); + + ret = imx_rproc_xtr_mbox_init(rproc, false); + if (ret) { + dev_err(&rproc->dev, "Failed to request non-blocking mbox\n"); + return NOTIFY_BAD; + } + + return NOTIFY_DONE; +} + static int imx_rproc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -1104,6 +1122,24 @@ static int imx_rproc_probe(struct platform_device *pdev) if (rproc->state != RPROC_DETACHED) rproc->auto_boot = of_property_read_bool(np, "fsl,auto-boot"); + if (of_device_is_compatible(dev->of_node, "fsl,imx7ulp-cm4")) { + ret = devm_register_sys_off_handler(dev, SYS_OFF_MODE_POWER_OFF_PREPARE, + SYS_OFF_PRIO_DEFAULT, + imx_rproc_sys_off_handler, rproc); + if (ret) { + dev_err(dev, "register power off handler failure\n"); + goto err_put_clk; + } + + ret = devm_register_sys_off_handler(dev, SYS_OFF_MODE_RESTART_PREPARE, + SYS_OFF_PRIO_DEFAULT, + imx_rproc_sys_off_handler, rproc); + if (ret) { + dev_err(dev, "register restart handler failure\n"); + goto err_put_clk; + } + } + ret = rproc_add(rproc); if (ret) { dev_err(dev, "rproc_add failed\n");