From patchwork Tue Jul 5 01:15:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 12905888 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 5BD41C43334 for ; Tue, 5 Jul 2022 01:13:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231664AbiGEBNx (ORCPT ); Mon, 4 Jul 2022 21:13:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229699AbiGEBNv (ORCPT ); Mon, 4 Jul 2022 21:13:51 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80083.outbound.protection.outlook.com [40.107.8.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B781DE83; Mon, 4 Jul 2022 18:13:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L8JEmhnw/XLG+rbP+2xgNPa1/AHxfd2XkcvRAqw89aKM76FWuhZhLHnGweorliYN2P9PnHAuz349ubh3FohF7G+KCJvh4R1+bzgEtZ6qF4e0oosP3bhdNvEXfDfUXfTSDlMMcSD8WmOK9KNVeQebGp6RThZ1eqE5Q7Nz3VThYVc9IUxJMfpXz9HcwvNHlO0/3jNVeRQ2LPzHA9nq2UMIReB1uG85em5EvzoBnwKNE91+8stTbqDcd6n/DufuL0qWLhNbGbfbOa8tDF6lYFfjh8vAJeTIUW/glBxHd5puTXkDflOEP9Xrcw7qDfy0p7dJFDp22Q9WJ6rrno6Vgb4ddQ== 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=wOu05O4LPNwJdNIi00SmXbN2GkM0DgItVxF4qTyK0HY=; b=YeJCJIZp4LXxUAOJFtY/g46jgFxrRaqcVJZeNvxJlPGWpQ0TXrzxOUZ5+d0xhOCAFcAYSWCZcwu3kDhqKy8jStqXn1Sm8kXJgK4N0WAAdjitjaYJhnz6cTaQ/OT3z9DEst33cggl9cmbZfHG50VVt3pwvR1t+jza9/eU7UgsByU70EnecJTPdUrk0+UK+4o5hpjBSw5xohzAGH5kg9MKw8I0TnBuTzIb/As/pVnghSD6qbh/xmXkn+eARvRLrO5OTjiC+wgNO1b7zAf4yw6LAYrm9NTfN1/krt6dyCm4HqZ9bZmPyElKwb/s+/FOPJQfirGysS/sigRCWaMTa5XBLQ== 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=wOu05O4LPNwJdNIi00SmXbN2GkM0DgItVxF4qTyK0HY=; b=GBbyiwdljHA+6vu4zSHSGUnyxlJTIv2+1H6BEs7MYqY7JMn2+jpiMvbbSoedZfa3ni1X8PYSHR/MlyfGHS6+04vE5DqQpk6WYojU3LxjUm6XnZJbe6SNgP5ZAaSQmpO4BenC5OXTIKGboERlmDMUOFv1TXrj95b2SQCqynvlhwQ= 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:48 +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:48 +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 1/2] remoteproc: introduce rproc features Date: Tue, 5 Jul 2022 09:15:26 +0800 Message-Id: <20220705011527.2849057-2-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> 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: c2a4e50e-aea0-49d8-ce1c-08da5e239d86 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: cnKaf2ejGha6NrqG0J1750MeI+pOgH4kpImf7zK5ONU9ZJ/bdoHzyUtRPBns6yADBT89y0LngM0OG8V1OCosmBCmaO99fSSy/NwQ6l93TGBwPe7do6yIRGYYs7OSt7FvXqusyRe7SGnCWAaJ6NYtBhFVe8OTQZkAaxfwgCIWy9yBV0Ak8AT5flIWXDGa4MNiVb4LUff9gj9nqLsIrK4by8nlH2/DQtu7rx/+qzNweq9kyWsyEUHGuj/YCWjbEsoOJYdwy4UvZ10BOMjN0ZEKgkTtLwDctT0k9iclkQgI7X6KjW7w/gZ4WdIDAUkP3yYW6EINHzf7JntC/PUjuqhLUhUKnXIPxUHjSMKBTeVa17eB/muQliDjGhsdBOPAgM3GIdFbyw/KPDfLbInefty1ws5wBLUcONDLTofv3XnOGW2zbZc0esKXljJLEP8aRUYVQtZr4z6C5s1UMrzhdNi2ULLYTJqIJ0INFtjibQlrL6+Lkp8kRqSGBK7ssqILsJsGZwm46lmvO9uCQZ/Jjy31bGVCkK88yEfTi2JdHgu4XrnEKNUrOuSofrddG9NqI9cmOMkTL4KUWp59oS/CASvGY1bJnf81jSmagRQROWJHod1k2ZPeAN2rLt6rPmLev8nediKWfz9VyHic2pUMNHDdYL1yIMrjhQeC49NtJ5BqArqounPtegOHFof1T4Gz0O6pW5pXXlJflZ/0UYp3rFGWa/S/lE2YXfsssc+Dh88wndYRSREnEMH3MAv6Obt8SuJHOJ6zjs5P1ignostcH4+wZpJkdGGriBrjoCHdHHlOgf1rjCwZdQeCJ8ehuX+HBrE2 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)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YAQlmWXsbuerkti93IkXNrqjEtbfi5ngYLH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HlmC45fhKDfN0UXpPwguXjpMJ8cM16dyev49Cc79VSLiFIAP2U1YTC19cX5XlFtZZOc+wQBZO1zSETOP47EGtVpo7crJl8LoN63dZLEVQuPhCMMMa3veGuEXtfewrDffu4buBFqDXFGwjon+BWU55dtIMYhrnxO7qf3Q50CWpX66c6v2o4hMGnGowTHGV5fcb5EqvYegt6l4RrbXWN76akt8L9JUaDfVZtlLy5+Doi2K3LZTaKCH60tpF79U4L3gxC6Ocf4UcBFi8/lpFvkGSoeusu4bPQVSh/OBQM1RdxdDxeANe1oB3n77B6jyMbo4y1UDo3JaKIAy0q4uHS5FDetIeiZ4Jups5nm4UOy44C9DlcI+7Co8GljbCe3V6acuJieC7oaCB7dbkL/SXN7VPhzl+SpJaDBcUtMSsbZtFMwHwtid0wE62xRhOxVzgBuSl6VHtXUORmME8ucnO02PRDkzJwzKZIuDzdr0P/KMMPrL5xlkoO6y5IljEEd X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c2a4e50e-aea0-49d8-ce1c-08da5e239d86 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:48.7788 (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: eG+2Qspcw2iQystJ0znZwWu8GJHc3rHLyg0Op2fJR71VHyKVdF72lluUy3FMMT6uqB3UuQDfNmOU9mqpfV8nQA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4365 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org From: Peng Fan remote processor may support: - boot 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 Acked-by: Arnaud Pouliquen Signed-off-by: Peng Fan --- drivers/remoteproc/remoteproc_internal.h | 15 +++++++++++++++ include/linux/remoteproc.h | 16 ++++++++++++++++ 2 files changed, 31 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..18869924e299 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -489,6 +489,20 @@ struct rproc_dump_segment { loff_t offset; }; +/** + * enum rproc_features - features supported + * + * @RPROC_FEAT_ATTACH_ON_RECOVERY: The remote processor does not need help + * from Linux to recover, such as firmware + * loading. Linux just needs 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 +544,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 +585,7 @@ struct rproc { u16 elf_machine; struct cdev cdev; bool cdev_put_on_release; + DECLARE_BITMAP(features, RPROC_MAX_FEATURES); }; /** From patchwork Tue Jul 5 01:15:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 12905889 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 36C98C43334 for ; Tue, 5 Jul 2022 01:13:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231809AbiGEBN4 (ORCPT ); Mon, 4 Jul 2022 21:13:56 -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> 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: V/fwJoQT1CRYWG9BJhSXYciza7BvhZUUYgHRNOyc9gj0cx5B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knQbtRPRiLarUXh6+lXutffkIbWG+4f9YtzKsLrmD/ZdxZe7+EDecl+quzLxgIzaHZkL5i4yl41fbfG+izOwU5FbgH6RXxORxrjbwKHiMHSJqepHIHuLwUmT9EveTj77mWAxpxv0vdV3J+GN7bD5g/qyec6HRmwJ2hEwM/uOTOVHh/wXBqM/ey+LtwgZ7knS0edMNwJpWoA/paD4A4omUhvDr5WvYetE78IqHklIYBggAr4h0QVMHjPLcuFe7UYXRO6v6QpDG9mbm3LdDyE9PDZmEgRMJSSwly86sQl5gZXH4Wh/dM15dsXkkhQyrnV3yTqm1XYXBt3Eq5pHeeXnNLYu+HZ/xLtQRvO3G2VShQ/OcPAVDPUq5nqtV2/dKde0kkAd9c/k6Wxv6Fg6E4eHw3dMrf8jOB2/Qa1wrWdAit7SX/Eu1CJynYNNKtCW6I1o2Y1dtrCz3dSlQ4xGK3ab0A6Z31TzjxT 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 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 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);