From patchwork Thu Aug 22 13:48:49 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: 13773460 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2070.outbound.protection.outlook.com [40.107.20.70]) (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 6E3F11CB318; Thu, 22 Aug 2024 13:40:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724334020; cv=fail; b=O9PnKpnovgNLQZ2zHj5Gr6dKzg7QIV2dg9JvsAK21TxzmVc7OJNGgixaFon01pleIeao1MhTAu4sj02zLCyCw9qQMSuForu6hiyael4GmMzbWCWS6Zjk1vkgvCdrRPawpZeVwW/7L/UbNjjaXy0Eth7biF/Pj4QyB0jdq8CYHlE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724334020; c=relaxed/simple; bh=GXhkHNqL0+RWEHovKYViiMu/YGS8tXK6n3z7gvAOEks=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=W/ydDm8Mn37VkpMY5+zykOju92KoY1Y/Pl+kNvW8C+KqldAnfEVHR+jWlMReOlXUl8Y1Xk92ts82AdcpOdEO0+ZRFlGf8hUZSq2E5V+p1F8K5zgIin9U3bJAVJpZpRdv47GUU/AvNy5of4cCVShZRvoX2MJgpZE9DTdIJBeOs+E= 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=nMt8JlBF; arc=fail smtp.client-ip=40.107.20.70 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="nMt8JlBF" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=o4z5N9eCWWgdq1rON3jmOm1xH7sPCfX/qK0VXXV2xX0Na2Utx6IG3zG/PNSu3WI3HJmOKxfV2eAcJSdDKte9slH09cxFZORbhSGq33akwEqIpJcrCDFQbwmaswlAxXlN8MMuvA4gxm2dO3C+YAzHsXcBmCmqIq/RbBWFHOZ34y3d3pc0PS0Li9J3lki6AKc37lPkeWs3bnwTxI+kwTkpYH/nU7QinjbKhXxcBuK0xSsMcnDUgYSnRu9DnS0OQ7l+G4TuulN+daLe4vKLyekFVp8ifjiwnqO6oX57C7K8rrNLEngjHHZUeLvyr/2/vt2uo26lWCLXdeBKEkOwc2utbQ== 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=X/4TdqO7xD4oZ98hwQlEfiM3HWZFuD3eY8KClVy6sZ0=; b=LMYnTu2Vcx90KacGtfn2cZ/ie4baSoQqvp6mANeQwaCoJRsmVB6B5s41k3gY2NOekg0stTpc6v2HVSJ8YeJJAwkEhwcuzfFR2jVuCcmzL1cYNlCNDMTKhqx3nNdLQzhKFddHopUOoTuybyjvm0uEqb5GuBUFm4UBSfuAKMWunyNhwNGpPOGYxbVbLAfQAKJ1aDjQsbkY+eVEYuCzNsUrKuW4LCGbjku9SGzK8dESLlwt74VoObPu21+u0/Kie+9w2+RFXFuyWf8yNLIFyEC2uBVtM3PlaoJ9UAMCksU9m5Lchzt01HuqJ2k7Ll2dNZdNEbsLbmfbfDk79p4MeStx4Q== 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=X/4TdqO7xD4oZ98hwQlEfiM3HWZFuD3eY8KClVy6sZ0=; b=nMt8JlBFtOW5his0WZvwTRNCO+aOD0nGuQq/Ht3rQW6FJoGza7jGrBGo9TNAHMDtsdE8l4QmQSv7Y9EHvX5mRFqHE9DvR6cHEt/TKjIRGg5IRUnpzO1O5NvlBsPmHY4ccaurjrFgjCFcCFuOQZaio3HDXVcv5Mh6RThLEEqFHg8hGowtO4r0I0Oe7r5KBdQ6xQor3xK5jcou1NSG3+IQs/cYi9HrNrfnFDdvogPMK4Pvt7wXemzfHRpxW64rX7az7IMpEKcbFP4CFzwiM7LnWfr9r6cSs8F580RD/KKT6/GJ3zh0g6q+mtHuOHbEiaIxmZPqY9q8bmxWh9ASQBEIHA== 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 GV1PR04MB10126.eurprd04.prod.outlook.com (2603:10a6:150:1a5::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Thu, 22 Aug 2024 13:40:16 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%6]) with mapi id 15.20.7897.014; Thu, 22 Aug 2024 13:40:16 +0000 From: "Peng Fan (OSS)" Date: Thu, 22 Aug 2024 21:48:49 +0800 Subject: [PATCH v3 1/2] remoteproc: imx_rproc: Allow setting of the mailbox transmit mode Message-Id: <20240822-imx_rproc-v3-1-6d943723945d@nxp.com> References: <20240822-imx_rproc-v3-0-6d943723945d@nxp.com> In-Reply-To: <20240822-imx_rproc-v3-0-6d943723945d@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.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1724334552; l=2358; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=+g8vBcVQ1XudqDTT7ofwoWn74vmRIC6pTXYhqi5R1K4=; b=Li1vQN6WF44YVokSWNMP5DC0qafyE7fZk0Fy9V/IE8zlbISCYc8Ttn2faz3OmKCGLtfOF+XOq CHuvfo0Xyh3CagD8w7pwOJMrxS0gDaqmR5mzIEuxlCNrSJf+3ZCJK3A X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR02CA0051.apcprd02.prod.outlook.com (2603:1096:4:54::15) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|GV1PR04MB10126:EE_ X-MS-Office365-Filtering-Correlation-Id: e346a209-f7d7-4ef3-e0de-08dcc2aff4fc 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|52116014|7416014|1800799024|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?SM1TqHF3X3IUuD77OH++2Z7o3nmQE0F?= =?utf-8?q?W/wvcG42F2OuFOpGVQyVeR/9I1Rds0UZ5pK4gecH7/DdoYC0lKPzQLoFjpy7jpwTw?= =?utf-8?q?U/tKvJTV+m4ZtVCTzE/1xXQ5PrlKPnwV0K3/a8kO6jcnk3LGlk2o+Ka0l+iDVks1g?= =?utf-8?q?0pdCgSOCPhmq+Pp8g9XWsRtoH/3oPuihR8aWmBkiFtNMEYubLqmieUk4g6hfTI9cW?= =?utf-8?q?HkSunv9g1vYohG2daq4RGkPHAq7f8v8a+kMjCIIKSOC360ZW/JkP41KGHHbKDfMbd?= =?utf-8?q?8ZUm7ZCcLWEr+F+A+XrLz83hAjo+Ff2/AEhUWI+qyjyfrLpu3F9L4/sG7II2kHxCx?= =?utf-8?q?/xo3TwbzT0zFHvy7auFg3RsxRL8pDUmrWlroLctCmUHExc4TmChi8IqL45kB2IqxH?= =?utf-8?q?4eSdipx9Qo3PAyLH/ZbCwHtcOxzaELC0fHNZ3Z+YvHmdMrIziJhbotN4Y7kR/XxB2?= =?utf-8?q?wXCfZN7oo/UY+5OcnqZ4VQN2d2DKsGzykCxytYH/ux7HIqCIkGAXUjccp37peOmHx?= =?utf-8?q?EPWheh7++Gj6JHY5SC+ZEPmU+jQw0n+kNRavKXKpadq8nI7cxtFjqM967ZXnasH7a?= =?utf-8?q?fOw6du+ElC/iNRmEb0VgTCzKKg3XjrzIFkIwR79MRbKnfqz1SUguWTjNh5UBwZdjJ?= =?utf-8?q?6N8OmvppFnLpAt8FLZ3CKpATmRWCcP/USLidrOGlIT5fGAn0AeISuYpkxR94DKDOH?= =?utf-8?q?DkDBzhl9HwDc92a6NwoEx+UAyQeQbzBZefr9J0DQNwsHZFbXBSFedAEiTst2TrfhB?= =?utf-8?q?8oVkbgbwmYaZ9mdKxzOD03VpNxqKc1V+kpegsyro/eoVVwrcgrWUy/b3MIFH6JiFi?= =?utf-8?q?sOU+lgMDk38C2gQM3ahFz4E2uQTww1tRYAeEq82pKS3g4sH+EA3kwRzBQKzvL6Cr0?= =?utf-8?q?GocjwhKh1allIdyrr5wr0m9El7Ta/ARZOxPLQos5bcG2W/+Yx0oiwrV31mHcQZ3vh?= =?utf-8?q?rBVCsa+7r3xhCrpR/0ltYoM5PiQ1i20oe8pH9Swqj479e+toFQq+Ny0PDrqe+dkCy?= =?utf-8?q?pf/2gu5sI2Bkc5a+XBvXhG86T70x3XPLo7NgfeOyDyCIvJhyBmnLXbEx8prlnmkCb?= =?utf-8?q?vCu3fVQ2ftrl3CdZAS6Z22M9s6INnPU1KJA+hgUqS8KlJMNpYWz/VLTyEgu+tOFCH?= =?utf-8?q?BxlpGSMDAQg0JUFHuROl9RzNUkD9vEEsIp/KtysRkN8cpG9/aoWZwRD1j+DRhnkzm?= =?utf-8?q?73/wE2KBESHgbzeCnubQGSF2+abAkpSsWcwXV+LDkFR7sia2lct3sk1tX+1izbL0r?= =?utf-8?q?XlLeVbkdbKBhVxlZ0RAOiZElFPulXvVXKVWY/VTvZTspGtePomkicN695Uet9nENH?= =?utf-8?q?0Nze1GB5IcO8SvXt7Y0DeOBbgsIZUXsIkw=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)(52116014)(7416014)(1800799024)(376014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?xzFvWGiLKdItq997Ezq6UrzisOnz?= =?utf-8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8?q?hhFONzJaOG30WHau+I1k2lKw+33+Apy65XLffzeJeSHzFqYJqJ93MQCQqwVnPEMq5?= =?utf-8?q?op9GzDnEjKfZ/63dZ4iBJojm4qD2m3plDHJewYXQkI52pJNutkyAJjT5kRYhNWfKq?= =?utf-8?q?AMc/0i3GTHJUul140Vt0NRCJHw1L+FdHKCu9ZmF62+5V4rnx2aL2Iu6WqwRQU4JDr?= =?utf-8?q?AKXGq0dGQq8EpikgEmk8JNj0Jp5fQdYfdopMTQRlhC28rfniGQbIWx0ndcYUb1m5T?= =?utf-8?q?GfbI2nNh6d0NJSO0nJvUCwDgbNVI8U0TkSASlepX+Xfsjn4KRqZpvTxPwI6IxttKP?= =?utf-8?q?bL2MjeUPTWaQvnp9VKBiml4lmaq80XiWY+1F19PLA4KmvByhJd2bNZmg7y7rTSzxZ?= =?utf-8?q?y8i/M2a+73murxQ1Ra9ptIdjw5JpH07+HZslzEO0ovcDQwRn/BrfQjHm6nyzN/ymv?= =?utf-8?q?CTywEL51HJzcUayzeqNm4J2ppgpxepNZIo990sm03DuvlEVZiyfFXhnboJKuzdbmA?= =?utf-8?q?jGSDEE0rR6n5GW6SlXrgQjzw5rAjFzk7EcJbBllKwYnKS2IcT7CUxirD5PK4/BM2G?= =?utf-8?q?vKYf5bAxXlWt71EEtTx5Y+apWmsr00uPm39LnuJck2DHg8yA1LF6YqmMd/4mMm55t?= =?utf-8?q?HyM7XSlO1nMS?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e346a209-f7d7-4ef3-e0de-08dcc2aff4fc X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 13:40:16.8789 (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: 4t9oTKWcEC4rJTe0LGygyPqP9g2+pAX4UPL7fi1vGZ8yRIJSEu+DwrZCL41h+SlToW99BjJeY+3mfm3yxCzeFQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB10126 From: Peng Fan Current mailbox is blocking by default, but there are cases where we don't need to wait for a response. Linux just needs to send data to the remote processor, so let's allow tx_block mode to be set (true/false) depending on usecase. No functional changes. Signed-off-by: Peng Fan Reviewed-by: Daniel Baluta --- drivers/remoteproc/imx_rproc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c index 9744b004bd77..22677f581067 100644 --- a/drivers/remoteproc/imx_rproc.c +++ b/drivers/remoteproc/imx_rproc.c @@ -90,7 +90,7 @@ struct imx_rproc_mem { #define ATT_CORE_MASK 0xffff #define ATT_CORE(I) BIT((I)) -static int imx_rproc_xtr_mbox_init(struct rproc *rproc); +static int imx_rproc_xtr_mbox_init(struct rproc *rproc, bool tx_block); static void imx_rproc_free_mbox(struct rproc *rproc); struct imx_rproc { @@ -369,7 +369,7 @@ static int imx_rproc_start(struct rproc *rproc) struct arm_smccc_res res; int ret; - ret = imx_rproc_xtr_mbox_init(rproc); + ret = imx_rproc_xtr_mbox_init(rproc, true); if (ret) return ret; @@ -629,7 +629,7 @@ static void imx_rproc_kick(struct rproc *rproc, int vqid) static int imx_rproc_attach(struct rproc *rproc) { - return imx_rproc_xtr_mbox_init(rproc); + return imx_rproc_xtr_mbox_init(rproc, true); } static int imx_rproc_detach(struct rproc *rproc) @@ -794,7 +794,7 @@ static void imx_rproc_rx_callback(struct mbox_client *cl, void *msg) queue_work(priv->workqueue, &priv->rproc_work); } -static int imx_rproc_xtr_mbox_init(struct rproc *rproc) +static int imx_rproc_xtr_mbox_init(struct rproc *rproc, bool tx_block) { struct imx_rproc *priv = rproc->priv; struct device *dev = priv->dev; @@ -817,7 +817,7 @@ static int imx_rproc_xtr_mbox_init(struct rproc *rproc) cl = &priv->cl; cl->dev = dev; - cl->tx_block = true; + cl->tx_block = tx_block; cl->tx_tout = 100; cl->knows_txdone = false; cl->rx_callback = imx_rproc_rx_callback; @@ -1083,7 +1083,7 @@ static int imx_rproc_probe(struct platform_device *pdev) INIT_WORK(&priv->rproc_work, imx_rproc_vq_work); - ret = imx_rproc_xtr_mbox_init(rproc); + ret = imx_rproc_xtr_mbox_init(rproc, true); if (ret) goto err_put_wkq; From patchwork Thu Aug 22 13:48:50 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: 13773461 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011040.outbound.protection.outlook.com [52.101.65.40]) (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 4C2AC1CBEA0; Thu, 22 Aug 2024 13:40:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724334026; cv=fail; b=FWJuB7ga36Z3ZWCQv62ghIaelL+pFIvb70Eug1hKftqXBC7beJu9Ve7jOoGMMjxJVcsIAuBayMkGualki9rUZRPjbU3Dgrq+gw8mwEmFk7GFjJHHIdK3YhnyvmJj9WeMMlpOgoapxWiQhyUGkEfNAT1rLpUvtArZwEUBJ8iEyYA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724334026; c=relaxed/simple; bh=w+TPPT45cb9WV15Y7zDr9x9H68pC59Lum7yjE4ZAfys=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=Wpe1dNTPsbQ5RmX4mjcFic1PSWUFLkNDKQQHdbBEiSunZA/CupIY2+FP71mDN9VNipu7KgRtxVrlAwiBo7H2tsUO1KwBwTfhDQCnUvPdJBLhp+fdplOfqzI4HNU9fyetdC0USeS2/lqXfqiVmK7fYXig6eRuqx5qlzFqu0LUUBM= 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=Frvwsf3h; arc=fail smtp.client-ip=52.101.65.40 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="Frvwsf3h" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Kjgj4ZWc4+Fou4zaoesShcwvFRIggk8T+TdM2UKayjhPxaAWIZD3uNtH8DNsL8g/7o6Ac1zOhPhrr+rKCQEWrUcDN6rSnlCc+E8q3IIeJbyUYusOc5MIgthCc7Perwhz2mnHUH9ulUxjBPjXv4AjfiRQOLmFIxr4DX9wN/ErxYKmg/5lhqCO0F05qIGbADSJxGjmOMrHKiD+YWfj2NKf0xk3msIxbFpckkfeXilaicpcQMsWzlqF9SroEUW5y+ePX7u0rMxd6hYOmBiAR0xJGYFDLLhM+ntCZBFLnWabSjV/4MsnGrz3lYrlBZzSJ3o34LSpjcuhQz6ewVQ8wWti7Q== 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=hwSo8qLVHExplBhnhsSjw7wuPhKRRWPn68FrIT4/cMc=; b=pM24E9TLx42FzQn2wHf+8E6u3laRmYDa+eiAseIBLv0PFbWtTusbIlpBtAnnfJEYcZbkoFTLvxjFQwl5MxkGVYaFg6tYyZZOsCP2eCNl/U3LNdt+D3r8U4Y+XyLrw5b/uOtaLhyLsFQnMglCf4Cwv5IbyHZtOHg4tqo/0Tjm3sKDyuCXN5BcphCV2JrwZkyB7Y0ocW8G1ktAmIV5T94UKPw7e/qgsJjp3e+jJ+tV4Fm1m4C2TljeTsqHV0/hoGcMq/vmdjfGJdh2IA5qy6oDFo4b8UyEq654IB5KzIFLe2LyYGTpHqs1HfKySpUxVsGCWzdB6wySiModUCyMfvfuOQ== 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=hwSo8qLVHExplBhnhsSjw7wuPhKRRWPn68FrIT4/cMc=; b=Frvwsf3hWHuW3DR03uVdjTfWGi4eRoX2EwOYxHdraWP9gWgU1m7bCCIvIkhV7Am69JDd2VqOxUEgerUaVFlPKoNMplr8r0wDiZNU8DY3dxzj0UwstIq5qF+m2ooB/WFfiL7mTe/SAcAiGUiKQ6s7TcfpqmgvsDeBN8eS5z9MT4FtEa80ZP8Fkjkus4W3J22UIukq4VI79WxrjzTGWumehK71i0bJOJu33g8azKX2lMZpu9uKnxzC/64c3p/WqRDciEwEVOfajGUXvZ3LR6H3skkbd2NSYi4aCToC8WPLVC2564cQFwgZxMIDzmhJd/JuW49Su+sK3VhxXLXCvngE8Q== 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 AS8PR04MB8449.eurprd04.prod.outlook.com (2603:10a6:20b:407::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19; Thu, 22 Aug 2024 13:40: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%6]) with mapi id 15.20.7897.014; Thu, 22 Aug 2024 13:40:20 +0000 From: "Peng Fan (OSS)" Date: Thu, 22 Aug 2024 21:48:50 +0800 Subject: [PATCH v3 2/2] remoteproc: imx_rproc: Add support for poweroff and reboot Message-Id: <20240822-imx_rproc-v3-2-6d943723945d@nxp.com> References: <20240822-imx_rproc-v3-0-6d943723945d@nxp.com> In-Reply-To: <20240822-imx_rproc-v3-0-6d943723945d@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.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1724334552; l=4226; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=HUszYL2Nyr15Mk1+3EqrILWezvor7LPShO2UpXI1BSQ=; b=42FEQh9UatXbDWHWlKEI6BQYTDNobEe1Nu8cnk61kVo5ufkaadnEQDc7dyh1/6/IQFquLUxCk rNBc2gaKHjmCgLKq5tqssvdn9PcqYGM15+yHAjisyxTLfJYgk01Om5H X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR02CA0051.apcprd02.prod.outlook.com (2603:1096:4:54::15) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|AS8PR04MB8449:EE_ X-MS-Office365-Filtering-Correlation-Id: 0055b7c4-b99e-45a5-0234-08dcc2aff77e 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|366016|52116014|7416014|1800799024|376014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?wx5Sdi172SubwtvCPaNedL5KmrtdeUe?= =?utf-8?q?6rJ8IGRfh3hjd54A811t50bs5LSiE/27v8fSq+NI6KljIkIcs6U+TElQbzkO83VnZ?= =?utf-8?q?/Bp/kNr+0iqTI2lqdgBRme3EMMjLI43Bit6Nf4hWXw63zUldkRlwHNiBR10Ai5fmB?= =?utf-8?q?IoaIHt5hrUApuC1xvBL0FOsXDsMXnjWbFnDFg8EVWcpjm0PlWGSdcaQ5LroIuHOzp?= =?utf-8?q?wC0lnr5S5rV7DzIojtOHL7mUmHaaf0B3zHUiMaxobVxqJ6mAl9waEikZ6a0q2r+Ky?= =?utf-8?q?0++2MZR8tWtYkyQY3qFXiGtii2tx6JDFSBnTpjA2+yqKqLQzhNlF/ZUi6p9JRsCX/?= =?utf-8?q?ei3gR3km8GUkDDDkd5OlEElbJaSZgOsrkLlIO7Omq7+lz47bPYu17NfuG2kg0MKMh?= =?utf-8?q?MVmCfYW8rxif3YYFL45kq4fBeaq3/WfukT173GvyPNLXUJTS8/CuwtKusu2hU1Jeg?= =?utf-8?q?QPaimfUfKe0nkz/5KrFImtX86wnAp32+y9JjeRR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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)(366016)(52116014)(7416014)(1800799024)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?RU5oqIapqcR4mfzd+nygE3rYoNUP?= =?utf-8?q?LSYtSP1SvqbY2unli5AxbsUawKSlohaXf6MF0b+0K1Hlm7oN4iO7gyAG+WrH8mauc?= =?utf-8?q?iqyK6CyhngqyczAee4faXZ6bb/WfFZNLzKW51bF8cLjbDwOMOCPQMjlpBNlO+zsJx?= =?utf-8?q?bmj+c5JylaNXcKrnATSXNkPns8JquHWpIDOBiU5vriwHymtcqZrBxv51NowK3VtuH?= =?utf-8?q?RbDiP42ReVmQhEHZ7AvVA5jbJukzD9RryY9vqTwfMrNiACXMFgZxVEvpaYwRYo2iw?= =?utf-8?q?cuW9NzIWLuczi+su4qZq7tDWXiI+nTS6MeTtm472tjJcq/bactYTT6hZopmoeZfxh?= =?utf-8?q?6Womfw9BsJt3w4XnByI3Wev4eA90heY1eJbJcnsMYMjoXnfu5FvZmp8ln9pZdWFa/?= =?utf-8?q?e2GkKINhS0ZE2+nUKqBZfz+VN8FK8bkVvolztm0oEx3Z1kh8WY2b7BhLbjvXqXpq1?= =?utf-8?q?YeMLl5aodlAA+OP+mifZce1x4JGJRNlErULjHsarXqXB87CShGv6FiaEfJBa19hJv?= =?utf-8?q?6AJkCAZPCVs3KjE0yabNU6WwP3JHmW+yW5d/l+BIb4dmzq4EmKlkx8Iyzs/VBBwc7?= =?utf-8?q?ZIrOeY6kvAOa2RkMo0ZF7p4UPcRN0mU6a5LMpH2zUZwdn1vF+hPknw3crT78FdzAA?= =?utf-8?q?YEhqcpC/F3RkpndWomZp2K2ukX5kLXCCevKztNqNBw6BuD/3Y/aDPgWraQChKZKiJ?= =?utf-8?q?F71L3ZUNQOPMMkkie8GghrqtmbcpOUlbh+jA/yV81QMCwniqVXFq9PId4oerXylXQ?= =?utf-8?q?gfH06fc8770ldsjn88xiH8Hc1BMdz33YrBvw77vj4lqQJdtlJYZdHrjy/+uNckAfA?= =?utf-8?q?yQ0oRXpki30NgSXOAFGTNbroEXtwY6EMzh+WW9n243BndCBwBcYzCaYsQUJKy9ma2?= =?utf-8?q?a3DhK7iVwfIYCbWru2+X/P0x8e4stKtck3Gc66BMjKzcE+KZURBwGRfeh1keac2vK?= =?utf-8?q?fRsj1Waj2AydE99SyjIPwbN84Gs3Z2ITHuKHTOuVnhmnwSeQqQVUM8Vta2gjON/ot?= =?utf-8?q?uBK0x74F/9VZdi5THiRiS+lCSGZ8r4qa3L39EIUrDRIMyZ7VmE/gvsBSEYJyT7A1t?= =?utf-8?q?hxcfpg/94xnIl/uNsKt7NXtYzAf39j7+2IiJG0sreq8xwqI5rbLliGPGzDE89IVlo?= =?utf-8?q?2GrRqAuwKjWDivg7Psyxr/wA+9nUz2Sk4iPD51VonX4UTrxYcABrqvTR4M8dfJhWm?= =?utf-8?q?MHL1fwYrPn+TVwpqjybaVbX5cR1rvn6Ib81h6IMzJgrM8o51S1DLUld/5Kx3xmHcV?= =?utf-8?q?wSCyoworoc3rgR6JUW4dqcst2qVNP3wO9dzPOj3NEvnpBCLNzgf9Wa+mMgx8rW0Ug?= =?utf-8?q?t3ALB8SZPOOLwqHFO6AJ43E//95gnTLtenmclxNACT1sJdggnv3HxGcJZvjthcUxL?= =?utf-8?q?sE2XF0kwy253h2fjTdBsX0HHxHYMWr67H4k/tEz5RsqTi44ulK5/LAy26K7Cr/ayk?= =?utf-8?q?lwRDpO/AOKReLLAO/zFZTXfNohhx4LaoeTgH1rn1cZHZ8OwsOQx938vlfz7J3zHYG?= =?utf-8?q?jri3W/2uDcdt?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0055b7c4-b99e-45a5-0234-08dcc2aff77e X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 13:40:20.7994 (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: dg/dNBUANyDjlrLLlWuVz5DPYoIsusEF05VgZcXXdBDurLx5SZ+P3p/o1uHWKCQVfFQEKKgTag+qgjHNUyLyBQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8449 From: Peng Fan On some NXP platforms (e.g i.MX7ULP) the poweroff and reboot operations are done via a separate remote core. Typically Linux needs to send a message to the remote core and requests for poweroff or reboot. By default the communication between Linux core and the remote core is is done via a blocking mailbox mechanism but Linux doesn't allow blocking operations in the system off (reboot, power off) handlers. So, we need to make sure the mailbox message send operations do not block for this specific operations. Fortunately, Linux allows us to register handlers that are called in preparation of the system off operations. Thus, before carrying the power off or reboot preparations, just destroy the existing mailboxes and create them as non-blocking. Note that power off and restart are totally different operations and are not complementary. We introduce a new flag in the imx remoteproc per device data which tells us when a device needs this special setup. For now, only imx7ulp needs it. Signed-off-by: Peng Fan Reviewed-by: Daniel Baluta --- drivers/remoteproc/imx_rproc.c | 42 ++++++++++++++++++++++++++++++++++++++++++ drivers/remoteproc/imx_rproc.h | 4 ++++ 2 files changed, 46 insertions(+) diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c index 22677f581067..800015ff7ff9 100644 --- a/drivers/remoteproc/imx_rproc.c +++ b/drivers/remoteproc/imx_rproc.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -333,6 +334,7 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx7ulp = { .att = imx_rproc_att_imx7ulp, .att_size = ARRAY_SIZE(imx_rproc_att_imx7ulp), .method = IMX_RPROC_NONE, + .flags = IMX_RPROC_NEED_SYSTEM_OFF, }; static const struct imx_rproc_dcfg imx_rproc_cfg_imx7d = { @@ -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,30 @@ 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 (dcfg->flags & IMX_RPROC_NEED_SYSTEM_OFF) { + /* + * setup mailbox to non-blocking mode in + * [SYS_OFF_MODE_POWER_OFF_PREPARE, SYS_OFF_MODE_RESTART_PREPARE] + * phase before invoking [SYS_OFF_MODE_POWER_OFF, SYS_OFF_MODE_RESTART] + * atomic chain, see kernel/reboot.c. + */ + 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"); diff --git a/drivers/remoteproc/imx_rproc.h b/drivers/remoteproc/imx_rproc.h index 79a1b8956d14..17a7d051c531 100644 --- a/drivers/remoteproc/imx_rproc.h +++ b/drivers/remoteproc/imx_rproc.h @@ -26,6 +26,9 @@ enum imx_rproc_method { IMX_RPROC_SCU_API, }; +/* dcfg flags */ +#define IMX_RPROC_NEED_SYSTEM_OFF BIT(0) + struct imx_rproc_dcfg { u32 src_reg; u32 src_mask; @@ -36,6 +39,7 @@ struct imx_rproc_dcfg { const struct imx_rproc_att *att; size_t att_size; enum imx_rproc_method method; + u32 flags; }; #endif /* _IMX_RPROC_H */