From patchwork Fri Jul 19 08:49:04 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: 13737008 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 5DA1FC3DA59 for ; Fri, 19 Jul 2024 08:42:02 +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=XNSxgizy+rrvrZ17tCcZ6RNMk2PwDZ358yswXzx4I5s=; b=SKXNtzkt9xJEfQ2H5gIcLIWsBW o4avuz4yHB+sNW0t2K8LOVSqh94eN1rS0gRUjfoD/Klpk5ZXkkIJFkR77qYa3LQ2hLoqfjudX3pV0 eA+COg5ucGZoD3MtXAMslxN7L4psOJQKMtXXtkv8MSG3gc+MgPPwNmWWCubzWnzJsepp6UOu3Rl8M RqKOhkoOHUfBnx72n0a4Q6EhIECAs3ikfNDOV9yLN2FnQ32jWjXmnbNwNbM+UNPslQdGrPekcwftn pHhVHAyRCJCMxu2qW1YD1Mb6/12hyFsNDEo4OU/3YOyjAZ+b1hjDVARTKGchAo9YqwARZ9jXOAVl5 L5M47dJg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUjBY-000000027WA-2Tm0; Fri, 19 Jul 2024 08:41:52 +0000 Received: from [2a01:111:f403:c200::1] (helo=DB3PR0202CU003.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUjA7-000000026l3-2g9e for linux-arm-kernel@lists.infradead.org; Fri, 19 Jul 2024 08:40:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fuB6ii/wRT5hjyvV1PrHdMrX8qUrrQB5G31uzqawLlEfc6a+5HAoS1FVFVMAQ/jIhTttA9ZWWmk23FYzhdRqLCrBjKYnHUZRZlaok4Qj5D5aPHHQ0lS+oSbQmo1XybPrztgRYbEgSx+u9kpJ/ocu512Y9H8c+91tWQoaIMUrcaACanf0siRPD7rJYTWb0DZJsKM48qmhc0UOcIHin4zc4Pif1lBIQNfbjcK2+PrTWVHdqoKbJnHNp2t8UR1iXFrkYI1abHNvkEDEFIL1wVedu19ITkN0t68MkvZuh14h91nDntG8FS7JyeLEkNawuar4iFt7H+cw/68umW0GLQuZKA== 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=XNSxgizy+rrvrZ17tCcZ6RNMk2PwDZ358yswXzx4I5s=; b=Wg4EFsoy0NXOvepJtRo+zcSfzSeM9CrZ8i+UEr6zPVqEdL/7AU5ekwmPhyIc1PsbyPtdq0kifWqJQi33hRVEn9BogIBO/IzP3yer/11M8VnizkKUW84DODCvVqtyMUnwXVnjFktyl8cHaVn+hFgykwv6cJ3E/21diLeK3ZTT11rCAEoyNm9ZxZgooLcwXfODDInf3T/fnLkEl98Z0aYeYwlZr+Wh2XRKSu/LfKZCkE7B3q7yTvSccBQrcVWruYZbRb7CTh2acyBCpRmbc3uLjI2A+adfJu7d5ulwV+0avrXHKQ4Drd8nKAvxHeb+mp6Q/i2HQVvKb1G1zKihZP6seQ== 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=XNSxgizy+rrvrZ17tCcZ6RNMk2PwDZ358yswXzx4I5s=; b=RRWd57XGcaI1NkCkXTjRyTKGxfnw5kMK7FHQZO8x/o2AbMXfDsVLiNhDyUF0SwwLeRppD3/qqzIi74kSgsJAZytMNDz8Bd5SpRDeE0ka3XrIHJJmhu2fBpbuEJW3ni6daKz6LAx9NoVeWaDPUQiM+uc9514pjVAlg4Xne4tOL7c= 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 DB8PR04MB6812.eurprd04.prod.outlook.com (2603:10a6:10:f8::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.18; Fri, 19 Jul 2024 08:40:11 +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, 19 Jul 2024 08:40:11 +0000 From: "Peng Fan (OSS)" Date: Fri, 19 Jul 2024 16:49:04 +0800 Subject: [PATCH v2 2/2] remoteproc: imx_rproc: handle system off for i.MX7ULP Message-Id: <20240719-imx_rproc-v2-2-cd8549aa3f1f@nxp.com> References: <20240719-imx_rproc-v2-0-cd8549aa3f1f@nxp.com> In-Reply-To: <20240719-imx_rproc-v2-0-cd8549aa3f1f@nxp.com> To: Bjorn Andersson , Mathieu Poirier , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Daniel Baluta , Iuliana Prodan , Marek Vasut Cc: linux-remoteproc@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Peng Fan X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1721378951; l=2895; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=9u+mOLa/UKnpD74PoVrTGFSC490GJBGP44V6TiFNVYA=; b=XhxP2n+9b5iHTZSeqM2AsJF3TXHNyn5hV0SXTABeJWtoTt3L2zA2e1oSOT98AEeRblWGi1ItN Xi/qe1DBDnLCTdNHe6R4uhrY7dT2UC3WAFA/fH74+5GyvCC8DPXmyEy X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR03CA0129.apcprd03.prod.outlook.com (2603:1096:4:91::33) 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_|DB8PR04MB6812:EE_ X-MS-Office365-Filtering-Correlation-Id: de398837-d19f-4d89-b55f-08dca7ce6701 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|1800799024|7416014|376014|52116014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?JlqrBtGQQu4mF2+GqJIzGiBd7tyGDOZ?= =?utf-8?q?LeyGQ6IeVFW89abO/r3csRIZPD1n6mfEc6Ak0qe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axBkVVYs?= =?utf-8?q?fP2D2wimnN+ddyzehFYWcIKv1+qbJnHGsF7qOlVeuoWIxEttZuMyOTWjEi6qw+q9Y?= =?utf-8?q?Bhdpj//lD2z/inrxunrk+kmZZshPEfupa68Kq3gLIFdtFB9VhaQ0u0tduWvGFlbcO?= =?utf-8?q?HI9Ht/e+G6f1Vx7mIE8rimRzWdXYirwbMCupVNoP3OsNu8bQ5Lqc3UG8xm9qgpTlF?= =?utf-8?q?/Ul6eKK6Bxe/qDnGyGVWcrIe4NAOAC0mhQzn0GFCyyAtIsHjZbVADE2bwYu0j/Bal?= =?utf-8?q?hy2zBZRfOx4B/qkdQw4d54TSMojFW2lxID9HQ+3a+Vg941RpVEKDfgsWrYwjwaEl3?= =?utf-8?q?aBGtKpHh4izg1XKSIJSz8AoymOGY9v2tqgUUuBPTUss8FlWxGVBxRopKPCahLGqlB?= =?utf-8?q?bb7yPUXFYiiWuacvhkkSf8J1LpHJLxXciQ=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)(1800799024)(7416014)(376014)(52116014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?HpeKASERqBWzTCkhlOpwS/aW7oON?= =?utf-8?q?lDfxMfTWM9A2sHnxivMfZJxNF51eSoPhUgs9r8s+RNCNC92a9sno1yqSAqM3n+IZ4?= =?utf-8?q?gmfNHzcvAqa7HYnWQK+Kdpi4Miy12fJ0bPO2QJChDOClH5cxxHHYWDjOmzrPTH8SK?= =?utf-8?q?W2fcJ6aQvN8MV1YmOC8fYrbzsoDuZ96XTKByIkuk6ectKJ6J9zLpZojYdES4NEQ+h?= =?utf-8?q?PDnjXcyYmR6EvO0Ssa49hhr+sJi88cYhkdf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5OWDPvk637Iw3K6j?= =?utf-8?q?ZO0ttzF1ay3EeuRcygQp7pxEgJPuVMpiMrEYeJMumD6F622MP16kcIHi2KPOsdA63?= =?utf-8?q?v3Jn2ERTC39cSVcKPelSH2ja3ECUMUod5sVilrYDNgKJ3QYrII8kSQ3wq4nn1TIYL?= =?utf-8?q?DX20YQj7SZn+AHUf2slfh7Rn8V/7KX68khCW65Ekex6tzEJQHa3Gs9Mf4RuGrGu3t?= =?utf-8?q?ch+N1fqf2hB5zKyuY+51O468YKPfmC/hqxNeMcFmDplABcr5+Bwzh4NDBnuUfYKr+?= =?utf-8?q?BBhja1eS/6zUNCjK/WlyS3Nuwvhay3mEwJWn1N+9nxUtOaKSIn779oOPn6W/PYGwk?= =?utf-8?q?lZ+1XEeXSrS+OUlQ/im7UiKnSbogf0ozxS91bft8ixUiR7V6QoEtFzZzUTPCuOeiq?= =?utf-8?q?vPY/08km6oLW?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: de398837-d19f-4d89-b55f-08dca7ce6701 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2024 08:40:11.3926 (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: 0p2FcKPldASIKuu9L6Z3AzTCIxkaN5LIbNUCuQrd656Bnrnc3E/sJivVbXXdTdx9h3AjuFvV1mzsPyDOo1+QJg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB6812 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240719_014024_310788_9CE84AE0 X-CRM114-Status: GOOD ( 16.59 ) 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. 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");