From patchwork Tue Mar 8 06:48:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 12773018 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CDDFC433F5 for ; Tue, 8 Mar 2022 06:08:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241954AbiCHGJI (ORCPT ); Tue, 8 Mar 2022 01:09:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234547AbiCHGJH (ORCPT ); Tue, 8 Mar 2022 01:09:07 -0500 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50056.outbound.protection.outlook.com [40.107.5.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5411933A1A; Mon, 7 Mar 2022 22:08:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lJmUq1hSK5sdwDEw3jlBzhcH6gb0XZlgR0nCL/aIw1K2JKsnPt/tptkFRSIBZ+eSroLn6+ZlkpHGNWmbfKsOQwNyQro01iDzR4cHXhhcdLhe7P+7K5KII4rdXJhPrIUdD7StL4I7CdYDjp3vEZyk256fRuLe3U7ksTbYj8LkFnaz28kPrV1SzKJ1bsgdrAQpSrdjBO3MRh+KOkeDcFj6V7oqyQsRgmO702HSkhn54lWSyjPUgU54kNOL7YZSKhWWqMjukzPJF+S+GrZKyYrhofNSlDhFfv5oDRcoMyXTCSBC8YAHV1RGneasQi5YpaO/sBld4qZNIhg84t6clte+wQ== 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=AitnvJcbD8JKrCHHw/dNfu2AezJnfznY2LREixRoSd4=; b=H2s+SLuxvM1eY43SaVB468I8jBd2Y1+87JBAb/3064YSSfc9OJKzv3EPdSXH2wutawV3BclhiHdZ0QKcBOaNk3Ef12NhIbb9XM2DJ3xmLdUOywUSI3jkoHs5z82S9oo01+qfn98qmy6kDagv1jV9aKD4MPhP5Aa6jt/oSJf35KXZZPcr6ytbTSLZ0mt/TrsnQFzQMFVqLiuHsssUVUgPqTABaZ3YIf9b6yBa71rCQ/W4zkY2md0h6b5YW9IslaknVEeOiBk34j7IdKj2p45ZlvkHxKXYE41/prN5jFB2Q6AGByqJaLVHAFmOg5362U34Vh30qV/N+9yR+TU5nEHA3A== 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=AitnvJcbD8JKrCHHw/dNfu2AezJnfznY2LREixRoSd4=; b=TDpF0xxlGD2d7GfWDgDmKLlQEOSx92Nxld+eMi8yEFcK27J3w211bOIBr6VNcQ6jf51C8aVrULPEsl0NqIJvskpsMSNSvPt49c//lJRfeGdRTI8GfLVbesS5/Uo7sGPRhEmScDvsKyyje7j2f0RzySSHYMcKe5A2oKNMmKNKNYE= 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 VI1PR04MB5471.eurprd04.prod.outlook.com (2603:10a6:803:d0::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.15; Tue, 8 Mar 2022 06:08:07 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::5538:7e34:6843:2bc7]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::5538:7e34:6843:2bc7%6]) with mapi id 15.20.5038.027; Tue, 8 Mar 2022 06:08:07 +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@nxp.com Subject: [PATCH V2 1/2] remoteproc: introduce rproc features Date: Tue, 8 Mar 2022 14:48:20 +0800 Message-Id: <20220308064821.2154-1-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.30.0 X-ClientProxiedBy: SI2PR01CA0028.apcprd01.prod.exchangelabs.com (2603:1096:4:192::21) 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: fe9324d7-1ea4-4635-92f9-08da00ca0392 X-MS-TrafficTypeDiagnostic: VI1PR04MB5471:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: f8y9lDB/4tTe7od+wnrQYxd9E8DuMd4ydT+7b1lD0z5u05dMWgyOVypqU5E2WFve9q4YhVFeuZ2q2AUkwemwwfCFWVpeYpMgKmsP9yP9tcl2WWiELJxK55sMBNJg18jg6f3hH06w7j9T3Ey6SRx6gmnSP1HmerN0P0hZiF/NWgnEjVQlwO2C1mTXqLwAUkAY2zYMQnLes005kpZ8jNeVGAJMn/kSwtlo4jaTbXlJF88L5HTevUNiL7uVuI1PjHzl7BloElZQVwQ1/Mjw5WzocfsMojAjMjlRCt47forZ+AWVdR3qGVRV6hcgrJL774/qRt05eWo/FyFTAY3+oXLHDTw/C9KVZVVFFNjYN2LqpyHIRxmSMb880wC1MYPzqjdR2yAWVfuACvJL438QhmFBvXwEOjCFeG9k9sW/ElBmg/DQun8hb+NAH/BhpYQ5NhwEz4VEOU/PtnymgnCmqs8O/9m6SkxOxHNHTc5b/ohh23iG99RUCLBKDuMDhPXR/Hh9Y5vl20pSt4R04xXmjJXCb+SeeEEtrl5N8XunCaqfk0Ndt2wjDdxg69Nw/RBq5N64YivGWb8b47DlW4RoqyFpFN9zzFtUyYfOxCGnM3miSBK8KsKZa0eOAVTefedJ89qbE43TLtyvk2lsYWO4i37b1yT8wL9fOerVMXhiEu9s95n1AzfBRCP3DMfWXi838j8XbjuPLbS4cQ5hNYraZt4UrA== 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:(13230001)(4636009)(366004)(6506007)(66556008)(52116002)(1076003)(66946007)(66476007)(6512007)(6666004)(5660300002)(316002)(8936002)(4326008)(8676002)(86362001)(2616005)(38350700002)(38100700002)(6486002)(2906002)(186003)(26005)(508600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IsmqLPRIt8ye6jj+mRj8L1F1hvm9v18PaoLd/CtR4XBkNh5b2T1DgJ2SUBogTlLRMVzmHwyaFVkopSs8nf30eTDWgDacBmc2sIFtXDqhMbHlKGhwYtIz1j7LclnmN9tL3Z3Zr+O98x2Md7hmcdDstVF5eSbb1AuKRsDHbE12W1MopBslPAXGILZchHwSwxrpzuSRtUneGHpPLbt+DIEzPdpSaTtJ6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dt4P8btTORw5G6lMmk7dgqYaG5V2koJPee0llGa8pwdM5mIneQNQQYbJuJ8amCOMh7jlaxIsajlD3/+gqD8oSUSNo7liGcCIDwcDcjyHCR6cigNqgU2G9aVmbWrh+C7u5EH9p3CA6CXxuYCK6d2Lx/lkPh5ryO7HuWm49GmYIp7C+JQHatpY9hGtKmogcU2zIBnldj1rP6pde3zdtAtUTeS+J04GanxCeh476TAZmLpbBQg4Ds507rZsTUs3UnUOjzApP3xrTdnj14jIfLu+/LKmeCvyCU/wD2EjQMMQXtfeCrKTD/di2nbDMXca3Oeuld1N8ixRg= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fe9324d7-1ea4-4635-92f9-08da00ca0392 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2022 06:08:07.1864 (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: XLsJemREMKpB7/0CkS1kxsFddJolmsKNjlLkJknLC96ncHSSfCC54/IEH3sMTAcBPD8A9SMSzUJIBJUdZszjFA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5471 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org From: Peng Fan remote processor may support: - firmware recovery with help from main processor - self recovery without help from main processor - iommu - etc Introduce rproc features could simplify code to avoid adding more bool flags and let us optimize current code. Signed-off-by: Peng Fan --- V2: New include/linux/remoteproc.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 93a1d0050fbc..51edaf80692c 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -417,6 +417,7 @@ struct rproc_ops { * has attached to it * @RPROC_DETACHED: device has been booted by another entity and waiting * for the core to attach to it + * @RPROC_CRASHED_ATTACH_RECOVERY: device has crashed and self recovery * @RPROC_LAST: just keep this one at the end * * Please note that the values of these states are used as indices @@ -489,6 +490,11 @@ struct rproc_dump_segment { loff_t offset; }; +enum rproc_features { + RPROC_FEAT_ATTACH_RECOVERY = 0, + RPROC_MAX_FEATURES = 32, +}; + /** * struct rproc - represents a physical remote processor device * @node: list node of this rproc object @@ -530,6 +536,7 @@ struct rproc_dump_segment { * @elf_machine: firmware ELF machine * @cdev: character device of the rproc * @cdev_put_on_release: flag to indicate if remoteproc should be shutdown on @char_dev release + * @features: indicate remoteproc features */ struct rproc { struct list_head node; @@ -570,8 +577,19 @@ struct rproc { u16 elf_machine; struct cdev cdev; bool cdev_put_on_release; + DECLARE_BITMAP(features, RPROC_MAX_FEATURES); }; +static inline bool rproc_has_feature(struct rproc *rproc, unsigned int feature) +{ + return test_bit(feature, rproc->features); +} + +static inline void rproc_set_feature(struct rproc *rproc, unsigned int feature) +{ + set_bit(feature, rproc->features); +} + /** * struct rproc_subdev - subdevice tied to a remoteproc * @node: list node related to the rproc subdevs list From patchwork Tue Mar 8 06:48:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 12773019 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F05F0C433EF for ; Tue, 8 Mar 2022 06:08:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344183AbiCHGJJ (ORCPT ); Tue, 8 Mar 2022 01:09:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241622AbiCHGJI (ORCPT ); Tue, 8 Mar 2022 01:09:08 -0500 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50056.outbound.protection.outlook.com [40.107.5.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 793A733A1D; Mon, 7 Mar 2022 22:08:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EjVlRUSj8cvbPIKzaD5YHCmuEIwH73T3wOb4Vq93DXo+FwC6Uos3tsnOI/Yrdjp4PQomhdSflntGttBG+wlrpxpVHiYrC6EU6f1N9oX0Ui7pX9SGMWGNvxxBe8TCPTJiN8vJE8Ytda66FAbTSFWk4/EDV/9jVgcfRqMw4TtkpqkMT9z4Gb9cveAzYSPeJxQiNDxSCQKfwDz/nbl0ZhMVvDHPJSyyRIMdrMQzXYINHrHubwDvMUySpH6FsIq24ZVeLKKtnIUfT2MOWgGQNc2ufIf6xICGMRshGxiwtzmNXPMAhXmWgg5mRYnTNMeudsqI9GsRvWSAMYUJZG5Zd+IitQ== 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=3kl27rtUBGCsH5Da/betVraMEJ30saeOo6bRW46sqlQ=; b=EHneSVa6Ro/zV6+Y8dRe40QbOcPpfgOayZWNsidRjtXJP3bIfr1EAkLLrzHA/uO1I8x7w5pZpCYkLmfhlJ7pXFfswMDBvIjDTuMpWYMkwsCMjXZeAlUbd4dIEiclHvfA2tUTJ3aqcg0TdDgTx604Yw9zLK/BqpLrnUoX3h4Xm5qRvl9CcB3hmGBrszj409sAXq8zwtliwbkhc77zW3fzXmWRIWEf65H4JmM3RDWbCYsWeJ1YT4lVZk1M616QApC9Q5xH1RgvuvRRs6evYK1btrghOoRhpXrpLDTiTFerDnJ6sLnO2HIajbNAGubQk70tdktOv3ntTDAq6NZ55Jyl0Q== 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=3kl27rtUBGCsH5Da/betVraMEJ30saeOo6bRW46sqlQ=; b=OD4bW2nYKcPYpvP/lshchaXrT6pcMch5CnMz+aZZz/o84s6Vu8JAylE41QX1devox8iAUz/e7PFBGuzf4J0Tdfy2XVGUjd0qI+M9YkrslhpiwehoZ8xIfu6Iyyid1+jPLKNKcmlQ6Wue3uWc6Jx40DUfWtD/1GDKTeDSbMcc4kU= 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 VI1PR04MB5471.eurprd04.prod.outlook.com (2603:10a6:803:d0::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.15; Tue, 8 Mar 2022 06:08:10 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::5538:7e34:6843:2bc7]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::5538:7e34:6843:2bc7%6]) with mapi id 15.20.5038.027; Tue, 8 Mar 2022 06:08:09 +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@nxp.com Subject: [PATCH V2 2/2] remoteproc: support attach recovery after rproc crash Date: Tue, 8 Mar 2022 14:48:21 +0800 Message-Id: <20220308064821.2154-2-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20220308064821.2154-1-peng.fan@oss.nxp.com> References: <20220308064821.2154-1-peng.fan@oss.nxp.com> X-ClientProxiedBy: SI2PR01CA0028.apcprd01.prod.exchangelabs.com (2603:1096:4:192::21) 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: 5f7a6543-82f8-42d0-2fea-08da00ca0537 X-MS-TrafficTypeDiagnostic: VI1PR04MB5471:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G9PJrtuWgToOpa3xI/gF6pIJgdPf+m85z7EMQ0DwWj/i9H+ZisQ98o3jKt+gKMWYIkRRQISZ3oCFpQ2Uy5Ijb1mGN3J2ByaiXdFac5InmX0JpUqMpw9m0Zim378eFqmQINDAnPntOp1y82hs/4OJTPSxwpLJ0CoT+P21QcIy9s7cu2uh9th5/DJAp3OsH0WnxNDq8nX9PzWFsvTCZ3i0rVJV2/NGwyIy89CU0SD4zGkwQXli03Gw9M1USld8d2/7F9EjLe77AaQrSlmxcBDuZWPwSDLpU31iVf4AYpnnXw3a7NIMj7cg2peoZ/DRmB6it1DeSHd8Oi/o0WAkwTe4XPQHUWq8jSsocugXjDRiXnQm7Bdew94Iao6jQR0W2msZ0U7F0+tHIrzOaIKaWuo6vdagMhNXRUKKNOXxhSBfRoMji76G0DCh6ju36xg15yQp8lgZpzc1tgwGRfWS/G43L9b4bKTisAihS6MIYkP+xuM5gop/m/s/KN+/z7Uns7q2SnnOk14BbqK3C1YZeScq/+6nyQPDDi3ZJ3ELhNYB0voFajc0Zh0W7gArrut+Tb19S6qqX/XIHxWZpyXFQn7sVWuK7Sfb9Ye/Rsgmivu6U4b/7oFQevUlTyXuWXNKcD6WPMZNDqt9trtnns9jGcXFosv+m27W/p0TS9kyf/wIJgMp9QBJ9WCEUpUIHDpGIaTeZWwtNGsEuEXYWkA+rnIfzA== 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:(13230001)(4636009)(366004)(6506007)(66556008)(52116002)(1076003)(66946007)(66476007)(6512007)(6666004)(5660300002)(316002)(8936002)(4326008)(8676002)(86362001)(2616005)(38350700002)(38100700002)(6486002)(2906002)(83380400001)(186003)(26005)(508600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4crspq09TAAfvT7iT3KeKikynK1chOb3fjlN0sVu2FzPjXIQGIg7DKXM3IHA0XTXZu/9QDrVPCXSLxaCDlvBdv4suqhNyk3DsLnQIa5CURUA0gYHlYL5QcHZlFyamORLeZ3zEpSAUcj6wqMyZ2iCg0AVDWa2xjHemHzLEsrKMdsmFLQaWWMJJhwVLg7y6k1YNbQ8F84xmw5eCIZEy8kh8Bv4RuD0X4PNRY4YZu09QLjJZK3w+F0Ee5X6lXwlJqsTyJKy7DpZyBS9Py/4G69Ly6bT+maIpKt738c0ktE5kGRBHx/y602WboWlwLf9MPDipLeXLa4WqRND5gl9ZYaTce0+2uHQWLNxmJz6hS6Vsf2LHPXNdV3NmvQOCYyYgm08hSQmNNGnBM17LXHBX6Jfw/5w0yVYTngpbvaUoWdjdza3sbZQmtgtipWojXWFQslzir0+0zP3YTSd3moexAvSoCXDzQyJxAbMLj7fR0OJrGuQwOg13SnZQgUyS0zqUYbzOZqAw45sAuAMsrjEM/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uV5Z2AobU5LzxL81eJJhTbmpczPPtavQ/5ORDkIq2mv0LqEY0= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5f7a6543-82f8-42d0-2fea-08da00ca0537 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2022 06:08:09.8961 (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: oaORpQ7X2llgnKlwFluEjF5u+YdAMMy4cOirGvypVPM78xkXBWtJqx7HdsCCjsQNz669m9rjX/ho4jewx8COAg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5471 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org From: Peng Fan Current logic only support main processor to stop/start the remote processor after rproc crash. However to SoC, such as i.MX8QM/QXP, the remote processor could do attach recovery after crash and trigger watchdog reboot. It does not need main processor to load image, or stop/start M4 core. Introduce two functions: rproc_attach_recovery, rproc_firmware_recovery for the two cases. Firmware recovery is as before, let main processor to help recovery, while attach recovery is recover itself withou help. To attach recovery, we only do detach and attach. Signed-off-by: Peng Fan --- V2: use rproc_has_feature in patch 1/2 drivers/remoteproc/remoteproc_core.c | 67 ++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 19 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 69f51acf235e..366fad475898 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1887,6 +1887,50 @@ static int __rproc_detach(struct rproc *rproc) return 0; } +static int rproc_attach_recovery(struct rproc *rproc) +{ + int ret; + + mutex_unlock(&rproc->lock); + ret = rproc_detach(rproc); + mutex_lock(&rproc->lock); + if (ret) + return ret; + + if (atomic_inc_return(&rproc->power) > 1) + return 0; + + return rproc_attach(rproc); +} + +static int rproc_firmware_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 @@ -1901,7 +1945,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; @@ -1915,24 +1958,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_RECOVERY)) + ret = rproc_attach_recovery(rproc); + else + ret = rproc_firmware_recovery(rproc); unlock_mutex: mutex_unlock(&rproc->lock);