From patchwork Fri Jul 1 09:37:01 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: 12903063 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 3B5EFCCA479 for ; Fri, 1 Jul 2022 09:35:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235026AbiGAJf1 (ORCPT ); Fri, 1 Jul 2022 05:35:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231470AbiGAJf0 (ORCPT ); Fri, 1 Jul 2022 05:35:26 -0400 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30046.outbound.protection.outlook.com [40.107.3.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4676C7479B; Fri, 1 Jul 2022 02:35:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gIBAd9KkkyrtPhaJGSSsZI2FX1/VMrKb5VxbfVBtHPsn6yOaojUjc06v4GFDfEjhRk5Q3slAQYeSdy4gy7s+lhjDW4/XkKqQDkzExjoiJFHcI6qOm25KQ6GRsl5PwrJmRzhQmQq5wEGqSip5wrhvYw+WkE54bFCTB8lawNsA1tS7B8N6GvGQ72WytLBe/hbLRd6ZHwpzA9VVrL5u/h+nK9tJSWCT2Fdb+Mul+ihojcAHOrGU6uUm70E9K6XQoIEk5iYx9okUYndw4u+n0aBlUOkpDkoeXNGQ0aPjlZuWcQ8n6ODb9dR/Jm0lA8SIs6UvWvFbD8ApoEmwUa2ePKe8Lg== 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=b58oRwSdZTUcN/KhQPHaohhJ6Pqd+I9wqlKOaVy4rKs=; b=Zzxq7e30s4vj0MPyiau8P4+mSdgmENESSJCnbledSgtb5n1BqnVJ9zka6b9gDqukAKHkpe4/sSWbwfdbJV80g3eUYGbsc1ayZdNnj+/ltr7BgUA2VD67t/j63fZ84rMZzZOwbwVXDdP4ARprXqRnaqdk5uPkdvqZAvk2T66s7x5gIvN8AR4R0RchBqyOcYxQFcyzM6TWD0BQbo+EeMyvyvvac9ZFxW56oMh5VD9GO2LmcbKT/KT8p9PvbdnewcNTk68Q+aEGK9RRZ1YRsh5ZnjQiGBHvx0iSx1aGvSlj5vZX+EsEUdYgVQleaDR5EDAuLpQYXg/FU/z5AmVxXPWy4Q== 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=b58oRwSdZTUcN/KhQPHaohhJ6Pqd+I9wqlKOaVy4rKs=; b=gAIiBuM/xhoJQ3cd/+jH/5d9thw52dCV6mO/dz262uGovZvTYjJg4zf096oJ6RfJMIWgAecEbT11N6XXq02wA5no0f1/doBp2oyTDm9s+OAEZ8L6ksIpzEolWP8aRofhSl3Qy3avQYjOoKyhAuXzVBS5gdNT0cTVyaQ6OeFMWk4= 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 VI1PR04MB4655.eurprd04.prod.outlook.com (2603:10a6:803:72::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.14; Fri, 1 Jul 2022 09:35:22 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::fdd4:8557:334b:180d]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::fdd4:8557:334b:180d%6]) with mapi id 15.20.5395.015; Fri, 1 Jul 2022 09:35:22 +0000 From: "Peng Fan (OSS)" To: bjorn.andersson@linaro.org, mathieu.poirier@linaro.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Peng Fan Subject: [PATCH V6 1/2] remoteproc: introduce rproc features Date: Fri, 1 Jul 2022 17:37:01 +0800 Message-Id: <20220701093702.265249-2-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220701093702.265249-1-peng.fan@oss.nxp.com> References: <20220701093702.265249-1-peng.fan@oss.nxp.com> X-ClientProxiedBy: SG2PR01CA0178.apcprd01.prod.exchangelabs.com (2603:1096:4:28::34) 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: 4b08fc44-6d57-48e8-b62a-08da5b4504bb X-MS-TrafficTypeDiagnostic: VI1PR04MB4655: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: c7PvdXPtsltANv3itoMpukDDOHFJaXSNCethYXH3Y8uMXDc70ehFEBDvTEr+BRd89p4QTuAyNm3EDsFyORSpLZmKtm4ly05P8crJ1PpcYAakQwq3RoVRSxTf3G+1jHGHzc2K7HibRtNgtI4cxNYMNROtcLA5ZibSF9LAvx8ZD36assdck4udqdpouHiRvYDwGGBEijiWk23I84s34cNnioTr39BeEPMgKb0hS5uN6O98rnIyU8IMF3TUZUxsmqaidHM2hNV+bmEUGKUxNcPDlhpDGvYSoL5EQx26VPeaXjKERx2K18APvNQNqEo9r6OoSDVzHWvyrc1DAqiUf8lE6tOw8B4F0YzXNbOpDh9GAndhExRtI6SZaR4QpnitmwTdazblaQ3h5yEus1DcS9t45A3tSI66tDFJhnzVhdhywgk6JcrrAsrQ07rCBoHNIrXazasxvDobvf1+Bh7vlzXPvp64INL0IGfHiYZlE1tJmiblW/MJ3chyauLcdWPTl0CcebtCXdhiGtOkY2p1fo+d0l0SJj0nBgtJdTeeQgkAz6kHoay2kFR4rjFqHEfaUyL6SDJ8jc56HXpSBjBosKeYede5+upqsiz9Z1Wf2vdH5QFLmTwmeRL1SB04DdXjs+QSOgTFYYpcRTZJJwqQjC+gKqvlp8QYwB/lfswGn6QqEcv0vaPYUq2gZZaY3KN8hK0525yPggDy4sBMn65rScRBGTebH6Yu78ARbk7ofkYPwhSOCYANJIGFXnkd20eX5sIG9RrWXOQVoBtEflnDI20+dH+8d4eubYSNYArurLlpuHQ6O1y5YpWh6gPEt9zgxe5/ 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)(136003)(376002)(366004)(39860400002)(346002)(396003)(1076003)(316002)(66556008)(66946007)(4326008)(66476007)(2616005)(86362001)(186003)(2906002)(8676002)(6512007)(8936002)(5660300002)(478600001)(26005)(6666004)(52116002)(6506007)(38350700002)(38100700002)(41300700001)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ej3qE/0FJvaQdWIy+/nHqPUg1xKsXND3S0MsRl4kQ4+v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EptZ7mRmiYJ8jvC3wIjn+fZR8ExYUr/U7SOhrRF1SkW5zIzqWdvVuq0TCDTOvM0TyHiqVrXs1slK06HlovPemvi6O4nDidyL3BS3wESnhVJh61N+PkSJnywg5BJtERpLAdvH+4ybl7D9LaiXxHyWafRNKi2c6mnMBQr13q872cDnCSrHUzCB4CsuztyAUnZp6sq1+n34Iassg8VUEUrEBbQkcCkL5Shhcb6/QjJWTheMusyZAj9rsp9OQQs8n9m+KF/d+2oEMC6D8jrMmR2NNx0naQ2Y11r7blD9Dg6fhG+wxKXTBTd4SzplVqE3Cm2vaYGWLG4tudTEUQsw5nnylRMXKPau/VcgIeg1lYRGUvywQMNy1eTpecxuh9nX+dlwYmpvStIDNDR5LNYjwcM7zMDcRBXjQHuGq54pHj3nsXbkAJ6juuvYcT5mByq454jX1zb/GoTayGCu/f X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4b08fc44-6d57-48e8-b62a-08da5b4504bb X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2022 09:35:21.9908 (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: QTdU7Q1ORa9WY7K36HAHOaGkUmEQC3kfoEEQaPvmBreyA9xCsbSrtO7PH5mbxROwkauAUUB2yJ9Qsid9jDx05w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4655 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 Signed-off-by: Peng Fan --- drivers/remoteproc/remoteproc_internal.h | 15 +++++++++++++++ include/linux/remoteproc.h | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index 72d4d3d7d94d..82247cb5d0c2 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -24,6 +24,21 @@ struct rproc_debug_trace { struct rproc_mem_entry trace_mem; }; +static inline bool rproc_has_feature(struct rproc *rproc, unsigned int feature) +{ + return test_bit(feature, rproc->features); +} + +static inline int rproc_set_feature(struct rproc *rproc, unsigned int feature) +{ + if (feature >= RPROC_MAX_FEATURES) + return -EINVAL; + + set_bit(feature, rproc->features); + + return 0; +} + /* from remoteproc_core.c */ void rproc_release(struct kref *kref); irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id); diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index aea79c77db0f..bbfb3affff32 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -489,6 +489,19 @@ struct rproc_dump_segment { loff_t offset; }; +/** + * enum rproc_features - features supported + * + * @RPROC_FEAT_ATTACH_ON_RECOVERY: remote processor no need help from Linux + * to recover, such as firmware loading. + * Linux just need to attach after recovery. + */ + +enum rproc_features { + RPROC_FEAT_ATTACH_ON_RECOVERY, + RPROC_MAX_FEATURES, +}; + /** * struct rproc - represents a physical remote processor device * @node: list node of this rproc object @@ -530,6 +543,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,6 +584,7 @@ struct rproc { u16 elf_machine; struct cdev cdev; bool cdev_put_on_release; + DECLARE_BITMAP(features, RPROC_MAX_FEATURES); }; /** From patchwork Fri Jul 1 09:37:02 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: 12903064 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 70EC6C43334 for ; Fri, 1 Jul 2022 09:35:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235309AbiGAJf2 (ORCPT ); Fri, 1 Jul 2022 05:35:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234917AbiGAJf1 (ORCPT ); Fri, 1 Jul 2022 05:35:27 -0400 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30046.outbound.protection.outlook.com [40.107.3.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 452FA747A9; Fri, 1 Jul 2022 02:35:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RgPo0njhq/NQ2eqRefo7vawrwZu4Vv2qhdL5Yst39EUTeiZ+r9sNUMqcdRmAGW0dXuwYVMpH1oyngBWqZ6Ax4/lKKLmRz1s45/uLUB9PNzfSeJT5umPbkEAtl+95B9W/uiUfBMeAEWcnk859Nq8wBDWZ5G2ZMj6y678beU4FMoA2Jrtj2PIggFd1yl/j0fXbZvdXVtayHssVz8cqf8tBVFIHMfXv7XoYT0UooCOTb+1poXqGgw8KbsVSo00BSaaEf0vAYGhSwyAmUXnV3OaT1P4mkz5d0h/o1v+dL1AD+YnGq/8thjp49Bq1RJiZfUEIsCmM+ABF3SIQGGzTjCGkfg== 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=otVKadlaaoou49b+fDAQ6ZmGz6y7tRTCzm2rje/Z1yI=; b=bP/nm+XOfzPIG1XOXgWRoyhrZf1vE8tteccTMvGmVLQFSD9V0iClGSxj4vnj+TZ3+CPvIBiI/UA9ObG2nO+vfIv+iunbkx1Bexo5iGUiF5x0ZZJUE9KVcByAbbtsQC1xeyeOTBPmde27/6LKW2JqThCHJMP5dhtz8doUrD1g+Kjuq1wZl5yunaRn+Ai7JZCgEKM60jePzx91DLh0ocOgxwjWkaoAVFv1+FU3eeuAcI0E/0R5lQMcS2RGBU0cU/pduMcgp1zb+SyroTqgUfxVxnAk7UCXuzwn4GcymbyhOS3fw7z0WPQEYH5ojcQGyatxUd7N8EKnSeaqGAMHZkygUg== 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=otVKadlaaoou49b+fDAQ6ZmGz6y7tRTCzm2rje/Z1yI=; b=dGgDxx9HxH/BFUxp/cHaUgFc66SB19X4+nOZIJxFefDDm+dujQe7/Ng5QLxLyF15Mqv7n2s0z4tZSWsh2j/M1JZPQ1H5sEN5AcFO2BjWWEKSjvDUl8+nMbotksh32ql2dD7rHtPdNeYiTW3tHl246whGbMZw/z3krGOk9YGOgGY= 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 VI1PR04MB4655.eurprd04.prod.outlook.com (2603:10a6:803:72::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.14; Fri, 1 Jul 2022 09:35:24 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::fdd4:8557:334b:180d]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::fdd4:8557:334b:180d%6]) with mapi id 15.20.5395.015; Fri, 1 Jul 2022 09:35:24 +0000 From: "Peng Fan (OSS)" To: bjorn.andersson@linaro.org, mathieu.poirier@linaro.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Peng Fan Subject: [PATCH V6 2/2] remoteproc: support attach recovery after rproc crash Date: Fri, 1 Jul 2022 17:37:02 +0800 Message-Id: <20220701093702.265249-3-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220701093702.265249-1-peng.fan@oss.nxp.com> References: <20220701093702.265249-1-peng.fan@oss.nxp.com> X-ClientProxiedBy: SG2PR01CA0178.apcprd01.prod.exchangelabs.com (2603:1096:4:28::34) 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: c0c8e266-73b6-4154-7af7-08da5b450647 X-MS-TrafficTypeDiagnostic: VI1PR04MB4655: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: j91gj4Pfq+7kf1IL1BP/e6TaIv0qm5TU62uNDAqhOmob6GRBt9kCiE/XXFVMcFdsIQGnGPQhPArw/gNAS+tNyNHdqyu8sCLmjNeWe4KPwJQr5X187M0vVGhDWxzG01rboJIKnpy+WSBfl0wcqEhMOi4qEzr7Ox0VMNBZZwPoOJFwDHeGBHojBFs8BwUB01aD6CsYzKgOxbzeRn71v1so1qq+fwGyF2gqhNLWWU7viXzQ0RsttqVy3EoXiFsQ/HQWnAaviqVDwuBfuGhyudQKuQmievYCv6XjhBQ3aQVu9HeJfodtnJbt0LUACvEEBYm8D90CDZmf+YLxJcd7dmHEoQgTjgkDNuyk4jIQxcCly6l0noL9n5en83ZzliJIjdTEIiSF/spUDa3q+EAVYXv4cbQ2cdiBPZTMKnD8+xattkJHKtdAjtrIPvZSVhWWGeI/kggCDSSNyhT6oAOlZrxmWk3TTZTt0Xeq3UTCNGZzgaWW/syiMKZAukKfxnaob3MzC5pFw9hiCKvTE2T5z8hqhCeTm9mFx9nWMcJ1XXK5Ng8MIuOWd/kWXkMEMpFearF6o6ORW+Sk6KDtncecH9RhRxzOMNCYD422aVd6+MY9xj02Xtf6X4EfMUrMa8kQQZU0TFZdHFjL/+4xyKlC5xq6lyiJeqCZt1DZC4mt3a9MBuI3x6vlrBRGmu52o4f3k9GrxETtiB4hgK8HUhUDHL4rQhgb4Km56G/8aGLNwmKK/lrg43adbw56+SHAyU10hxX9Vh4JYOHC49yHdR8F929KkielRr3/pnmSopPPPkOHdJuXTzRmFot3zCTYkvVVQJwU 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)(136003)(376002)(366004)(39860400002)(346002)(396003)(1076003)(316002)(66556008)(66946007)(4326008)(66476007)(2616005)(86362001)(186003)(2906002)(8676002)(6512007)(8936002)(5660300002)(478600001)(26005)(6666004)(52116002)(6506007)(38350700002)(38100700002)(83380400001)(41300700001)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ac5jLxBN6Lx+Bh32IHu1sCNDOKhMzRzoXMykPQFSZe7tPLA16oVH/M1ddgy/DdGMM+zy6/517cG5dKh8wrv/HddMfY3cu6gYXAnMZS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Pk6b5CG1VKlsEPo5oV+YfFtjgjIUW93lC3A+QIhLH8iTGGU8RYI7BtWkTieKXdw7icDdy7ZrD7wi8Oz0AhMJh/81le0MJ8hucK5qkXsGAd5o2H8YdiedxvA5H4QpvRVAYD9O0+F+cIrGGaWWl4yGwvpfYtNIwWaZppuBMrqzaHI415T9ueKHZDaWtkwIxl5smm68x6sFmcl6XzxiLx3Jmvz5jLPHQSU6rKJRsBGIUH3qJN2pj5R+58/mxIjKtrNoTkCMM4qYT7DdhT/fRLzmNQjFFPvtU9p/+N4q7YsZdsIIaQGkB9sFxBaya4MEBW77UH4Jdt54rqNCwStHfDY9+ppuMzcI5HegbNaZ+PPQSDv5ryVw2xN4+s5XwzXJOcgghzxV8K2IzCShI3gw0/0EcFwRc X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c0c8e266-73b6-4154-7af7-08da5b450647 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2022 09:35:24.4143 (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: ivejuijwqkQEm2mpb6AzqjcPuY4LTe5o86nnLzlfxqCndcqYFC5pgl2oqKNown7MqLu39pf054p+gJVG1/VteQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4655 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 Acked-by: Arnaud Pouliquen --- 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);