Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp706258imw; Mon, 4 Jul 2022 18:25:43 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vzHidRV1zrSS9Oy+tk0ZYkpd8bDCMcoRQYFTNTJa0Si12w0vaz6mKenLogryLy73jJFAII X-Received: by 2002:a17:90a:eace:b0:1ec:b2a6:c9cf with SMTP id ev14-20020a17090aeace00b001ecb2a6c9cfmr39801341pjb.26.1656984342836; Mon, 04 Jul 2022 18:25:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1656984342; cv=pass; d=google.com; s=arc-20160816; b=fKHJuo64AgV4KCdPY7LGMgFi/JSLb//Gexryn1p+6H5IO9DDJwr8XVqRjGJsBr+BKa l2XbfdILQo06BCxpPQryc2CXsn/RiIPwdNa1cLV+u0HFGz+pz3wQr1phEI9BuGtXjNsT DakQLSKfvUKZsKVDp0Yh2qDW0xe7B+oyCMRv17/iTQX+C2G37Nby4YNsqaOm34FFom/M eoF+m79NiBzQslGLOsnmu88sqb90hDy6qGDXXX4dgE3B4q/KNVHp8Sl4w9xKcaPGaXQC feFBgwgI5qXqLu2L37731WbKmVEj3LvknkAT0V0lsPYSR+DZ8jtYEt5khVizRxR9ryXf yiQA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rPQbJWZPWISzBcw/TBuoplLlGV/IqikeycOVRNRmXNo=; b=DdPs6Glw0xS3woXWm2QRhUFNkwM+DV8edIEu1VSQ9hvn2NYwMnlFrJ6tArc9TlRkKT aodj7O9oZZHy+y2tY+cY9GSOQ5qGYIsEXqUTCNX7OpV/QbKq2Q2MSn+8M9srYnY5JiNq bKLCjht3moBnMzTmiAwQAPFWy4enXEqje2YmFgCnbObRA1rauiZBAgML1u4VjkJM5dIe WVl/1swcCCKYcRR8M2mI6LWP72s2OkVwZe126UiSEZxCFHF3yRwPalGl9UvwRi5ifC5+ Tlhb0UtYDu3PWSZFws4fhPzkNxoxyAxNNFwb06nKYW54jLdsUJnUQLa6XO1+APYQVOPn BW1A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=SKJUN3Ju; arc=pass (i=1 spf=pass spfdomain=oss.nxp.com dkim=pass dkdomain=oss.nxp.com dmarc=pass fromdomain=oss.nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x18-20020a170902821200b00156b24c4bb6si38784435pln.120.2022.07.04.18.25.30; Mon, 04 Jul 2022 18:25:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=SKJUN3Ju; arc=pass (i=1 spf=pass spfdomain=oss.nxp.com dkim=pass dkdomain=oss.nxp.com dmarc=pass fromdomain=oss.nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233178AbiGEBN7 (ORCPT + 99 others); Mon, 4 Jul 2022 21:13:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231624AbiGEBNz (ORCPT ); Mon, 4 Jul 2022 21:13:55 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80041.outbound.protection.outlook.com [40.107.8.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63E16E0CD; Mon, 4 Jul 2022 18:13:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pz0mcfGmf2QLkCxihSF2LY54Es8YwNP2CG8Ky5VIrMCgfFw2s0V4tdNjGSNjFymH/WlmgFWYzd6ly62NaPsjmORcT3B+0fF2ZQm9Y1Ox47RBiXhioAMkxF0AgQixRQ33Y1FCLBx5N2VBIZC+H0O6lmkHVpMhtGZrYaGPDKjMcUZuvdAAdu1zFvgye+B5GznBtEpeYAM4QDuik3wX6RdR2E7ftCcZXs7OUJjKSkkQ44U0/Gyrz2mv2SSKQI452uHuY/zhEC7KApLsWOK36gX7qCZwHEh8reQbzcYac4en7hH7hXBOpIVBq8rz+of8VLF+5pWcXvNgnvFvcDGMUZqDDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=rPQbJWZPWISzBcw/TBuoplLlGV/IqikeycOVRNRmXNo=; b=O/zmCSItmLFbSsKCQzDpaV+z+700CQCegpODN4ybLziMSygV3aj35vUgfOz57EAFRMnecRAHtASrnwsQXnY/4RnbVCNzbskzMXucV33J2/gtpudKCn3bPDrwPvp69rLJBFmeo/nQurkkEEdVyAi+QEwtLE8suSfh9mA9DH9eZ7aZomM/ScUKMaE15c5dxY5M7zqzbiyLh62jpZ/nXzfS2mhtnonXdRJgA71vE61FS5+qs+XoQnXIlidVuVhbLmQwWUpx4dqDwav2+tj/Rj2UXAoPUHa0PQ+vqNq3HssShXrB3EWioB07unSUfbhYdlyB0tnkdZlxDMMu81/8+ZCnQw== 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=rPQbJWZPWISzBcw/TBuoplLlGV/IqikeycOVRNRmXNo=; b=SKJUN3JuFxC1v2+0iT1Eavon6x9vLLPwOWj3c+rwxKAfGs6IUteyLrrBQsWSXu1lmeNdKEyzE95HFPqju3BxjSqM09qdnegO+puLWEUfbiMCd9s5jJfjpovdfOYW+CG/2ZOdCvMcV0jTEdiyenEaSRhMhQNnmqru0n0rTYeKJaA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by VI1PR04MB4365.eurprd04.prod.outlook.com (2603:10a6:803:49::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.20; Tue, 5 Jul 2022 01:13:51 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::fdd4:8557:334b:180d]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::fdd4:8557:334b:180d%7]) with mapi id 15.20.5395.020; Tue, 5 Jul 2022 01:13:51 +0000 From: "Peng Fan (OSS)" To: bjorn.andersson@linaro.org, mathieu.poirier@linaro.org, arnaud.pouliquen@foss.st.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Peng Fan Subject: [PATCH V7 2/2] remoteproc: support attach recovery after rproc crash Date: Tue, 5 Jul 2022 09:15:27 +0800 Message-Id: <20220705011527.2849057-3-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220705011527.2849057-1-peng.fan@oss.nxp.com> References: <20220705011527.2849057-1-peng.fan@oss.nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SI2PR01CA0053.apcprd01.prod.exchangelabs.com (2603:1096:4:193::7) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4d5ff74f-28d5-4575-2fd5-08da5e239eea X-MS-TrafficTypeDiagnostic: VI1PR04MB4365:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SDys6XYaDDMHK+SjzIelDdIjhKqAmjpu9tfcGKCB/L8Mcm1bboL8DjnTA1Kw3SWyUpeBIFgg7biApINOLM6wCyCrFvdv5Qch8JfQBYB6GzbHaKylxezaRrr7dJ1mcMqp9wetxSdySMA/cCmEI1xRh1pCEy9rjPa0T+8bgOvlq9lbc2C/MmvyKW/ZcqU7oIVclIPiolYWOz0H6nLzZCDIwsMwwgi7QexE3KNdLkv2mVBxn6rxpyPye5eEeOOj3yGAk5IN5dDGHFJBtwwjB7QmJaGGemgCUxgkBrwSP7iN6JCe1AKWryIfuiSRAq5pDVNECMgwnLLY6ciIit8rvXO6tiNcqpGlZ4fCnelJsAgOwE48Xg5AoDZgDSJFSkOjOpTRSceI+AJMlkOeVgg60mBIPgH/sSqE/AW9NPA+cS5GnfTXe4R9S+WhUJZ8R/jY7GQoa9mz076bomwn5Uz2E3sa/wwH45FzyuvhIt7Z+JD7WOMG5giZyxdZCKWFZHukBBjvxY+m7wDZRH0XRkuQrxtwozxl3DwyeSnE3SGAuPTXXMrrhhnkia/ieO6JbddvYQOzQSBdQsfNk1I6O07ZVTUw12LdTjE067xuPJsLzD1Prv9U4iV7IuWOFpZClbHEulvVq0/8ciho//PoDs3Hjs/eWOtEqPVoJhRN6itSskjMB5b8sNLeNbjRNux5bkWFwg72j0QTXv/V7srNAQJes6mxRHg8IYNNVuGzfUxXHcYjhi9s272URoY1IoCYpnvn2YBtxflZzdvzGMoUhjZ3g8/NA31CVoeDm3CLk71Z43rl4vew61S1Z0id8gB17SacfzRL X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9417.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(376002)(366004)(136003)(396003)(39860400002)(346002)(6666004)(52116002)(2616005)(6506007)(4326008)(66946007)(8676002)(66476007)(41300700001)(86362001)(6512007)(66556008)(26005)(6486002)(316002)(38350700002)(1076003)(478600001)(38100700002)(2906002)(8936002)(186003)(83380400001)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?V/fwJoQT1CRYWG9BJhSXYciza7BvhZUUYgHRNOyc9gj0cx5BdhROFKDIg03R?= =?us-ascii?Q?GLl+mL2PCb81b0x/OL91/AtVBN4I1SQcCwhNV9jOwy4N/Ogsmdgye6Hk0V5G?= =?us-ascii?Q?AQSexWU7U0RJm4Q3LXMNycdnM806krxv1qjvn2H9l2I/iSLjBOz7f6Hyownc?= =?us-ascii?Q?i5cdfkCSJ0CSv2Xno6a1ztayuiJMV+2jm/gzkDrXD5xgcMdkiRjcY/ZT8vmf?= =?us-ascii?Q?27CWZCIyL9BDUuUHEjVrG/NioL2TQ9Vs+kcW31b4i2hNCOlMGu0yWpDNSGD6?= =?us-ascii?Q?+MEpgXt0idb50v+XWqus+SjjjxTw4APQ6UeUEXxGdjG+57nTdNBIW78Se5cA?= =?us-ascii?Q?Hlm3pd98WUZjRaLDdbPFkhbx5M0WPm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3J+GN7bD5g/qyec6HRmwJ2hEwM/uOTOVHh/wXBqM/ey+LtwgZ7knS0edMNwJ?= =?us-ascii?Q?pWoA/paD4A4omUhvDr5WvYetE78IqHklIYBggAr4h0QVMHjPLcuFe7UYXRO6?= =?us-ascii?Q?v6QpDG9mbm3LdDyE9PDZmEgRMJSSwly86sQl5gZXH4Wh/dM15dsXkkhQyrnV?= =?us-ascii?Q?3yTqm1XYXBt3Eq5pHeeXnNLYu+HZ/xLtQRvO3G2VShQ/OcPAVDPUq5nqtV2/?= =?us-ascii?Q?dKde0kkAd9c/k6Wxv6Fg6E4eHw3dMrf8jOB2/Qa1wrWdAit7SX/Eu1CJynYN?= =?us-ascii?Q?NKtCW6I1o2Y1dtrCz3dSlQ4xGK3ab0A6Z31TzjxT?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4d5ff74f-28d5-4575-2fd5-08da5e239eea X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2022 01:13:51.1703 (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: d9viw6dqY7Ou9ODPWdKcFLnWUUlNZViagwYU8vxs1H+dTboE3j0NcoRGW4Ta929q9rKBxyRVUqZ5cGJxH8HpeA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4365 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peng Fan Current logic only support main processor to stop/start the remote processor after crash. However to SoC, such as i.MX8QM/QXP, the remote processor could do attach recovery after crash and trigger watchdog to reboot itself. It does not need main processor to load image, or stop/start remote processor. Introduce two functions: rproc_attach_recovery, rproc_boot_recovery for the two cases. Boot recovery is as before, let main processor to help recovery, while attach recovery is to recover itself without help. To attach recovery, we only do detach and attach. Acked-by: Arnaud Pouliquen Signed-off-by: Peng Fan --- drivers/remoteproc/remoteproc_core.c | 62 +++++++++++++++++++--------- 1 file changed, 43 insertions(+), 19 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index ed374c8bf14a..ef5b9310bc83 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1884,6 +1884,45 @@ static int __rproc_detach(struct rproc *rproc) return 0; } +static int rproc_attach_recovery(struct rproc *rproc) +{ + int ret; + + ret = __rproc_detach(rproc); + if (ret) + return ret; + + return __rproc_attach(rproc); +} + +static int rproc_boot_recovery(struct rproc *rproc) +{ + const struct firmware *firmware_p; + struct device *dev = &rproc->dev; + int ret; + + ret = rproc_stop(rproc, true); + if (ret) + return ret; + + /* generate coredump */ + rproc->ops->coredump(rproc); + + /* load firmware */ + ret = request_firmware(&firmware_p, rproc->firmware, dev); + if (ret < 0) { + dev_err(dev, "request_firmware failed: %d\n", ret); + return ret; + } + + /* boot the remote processor up again */ + ret = rproc_start(rproc, firmware_p); + + release_firmware(firmware_p); + + return ret; +} + /** * rproc_trigger_recovery() - recover a remoteproc * @rproc: the remote processor @@ -1898,7 +1937,6 @@ static int __rproc_detach(struct rproc *rproc) */ int rproc_trigger_recovery(struct rproc *rproc) { - const struct firmware *firmware_p; struct device *dev = &rproc->dev; int ret; @@ -1912,24 +1950,10 @@ int rproc_trigger_recovery(struct rproc *rproc) dev_err(dev, "recovering %s\n", rproc->name); - ret = rproc_stop(rproc, true); - if (ret) - goto unlock_mutex; - - /* generate coredump */ - rproc->ops->coredump(rproc); - - /* load firmware */ - ret = request_firmware(&firmware_p, rproc->firmware, dev); - if (ret < 0) { - dev_err(dev, "request_firmware failed: %d\n", ret); - goto unlock_mutex; - } - - /* boot the remote processor up again */ - ret = rproc_start(rproc, firmware_p); - - release_firmware(firmware_p); + if (rproc_has_feature(rproc, RPROC_FEAT_ATTACH_ON_RECOVERY)) + ret = rproc_attach_recovery(rproc); + else + ret = rproc_boot_recovery(rproc); unlock_mutex: mutex_unlock(&rproc->lock); -- 2.25.1