From patchwork Wed Mar 9 23:01:27 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: 12775663 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 A8021C433F5 for ; Wed, 9 Mar 2022 22:21:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238619AbiCIWWW (ORCPT ); Wed, 9 Mar 2022 17:22:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238611AbiCIWWU (ORCPT ); Wed, 9 Mar 2022 17:22:20 -0500 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2087.outbound.protection.outlook.com [40.107.21.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 787B11201AC; Wed, 9 Mar 2022 14:21:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kvwoEcZTXUwkTskKbkFUYtSXWFnaY3AAShgSUQuSk5+mL1Q4mlnDAJVb1m5z25GPEZuU0aCx2fERa4MICluQD/E94renavZJpxES+lDJm2ocyU98DZ8suAw07O2Xf2c0QgZM9SHGGEadjhWxncHUPtE/eT6oOIRSlbZeosU4ENPpf663c9iJM2prRiOmTBUS4kITCzWwPttTiza5Wl/xTBzfYoIvBBapMWLO2vVqTwSq5xqBt2jLJYgjKQy6UREWt4n80e+7Mo/ZzaQDEGYAIqoTZrQ0WiE8vonXXZl6g2akqhUH+Y9dTqWLQXQN1WmnX7sYCO5izc/19AX3Rn2FOA== 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=2w6XjxDsTRw2ygrMRaDXzrP9hbU44XmfL5c9KuuUHPM=; b=e6zddwOtM5tXV1DN2P9heSi8glpG9SJepyQUlFnMUaNqzjB4shhFeeQyrXY4tNttBU0tp1Z5Nn1JN/7gabfvC8hIxVUIbD2pek6KRd+X7YAe6pEOSxJIqQQ78w1/WOBtfLtNqe7Qm1KS3a1wAimDhu1VwI8pSDGLWbCdccbJ26Los0yBu6nYOoXTQbLKlna0mW8CpCBMMrGERca+CrUTbQ5fVLoY6C09KbcFjjCq5xI/xVHy7GLtlNLFcbda9LuJe8wjpmbkYwJxa56zH+srcEZPOeAiwLz+iT5hergZOo8X4EL8FsOMVMb7L+LlEf8QMhds46nSqjZDroiK4Tl1XQ== 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=2w6XjxDsTRw2ygrMRaDXzrP9hbU44XmfL5c9KuuUHPM=; b=FTvpc6MFPQUuxfhRghUQSEtrnNEwkWByB4Gf47mrh8tQidWdXZfgisbb6TlLFyXg09HqDPfXZ2D2RM2jRrsAvsLuSXSz3T9QGseUQ2jXvCPhXBqWEL6Q6fKrxzx6JnR8OJINpgycT5GqP5hDD0jlxeTTbJOs5Rgma+YsM67uV2M= 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 VI1PR04MB4512.eurprd04.prod.outlook.com (2603:10a6:803:69::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.16; Wed, 9 Mar 2022 22:21:18 +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; Wed, 9 Mar 2022 22:21:18 +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 V3 1/2] remoteproc: introduce rproc features Date: Thu, 10 Mar 2022 07:01:27 +0800 Message-Id: <20220309230128.15856-2-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20220309230128.15856-1-peng.fan@oss.nxp.com> References: <20220309230128.15856-1-peng.fan@oss.nxp.com> X-ClientProxiedBy: SI2PR01CA0022.apcprd01.prod.exchangelabs.com (2603:1096:4:192::14) 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: 23a8e1ec-14bf-42db-afd0-08da021b21c2 X-MS-TrafficTypeDiagnostic: VI1PR04MB4512: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: Xiss0xhBd1kbiE7mUW4C/+ubZqosKlubsMzFUr84Ve3XXRxF/xZZ5FCSBxH7ZMNEOLEn43vtneqVoFzP6THCPqg8inkkwBXfj0Uvu3ZfzfW0usbGWWhI3ImS7a+5234qbLP7AXlOJqHNWLV9wrFq5up67ki4NGElA4w0FsEcGFVSAACf7OWLSHlGDWHoU+4eYslOJhtVi/zzwvt4V+0TPWvW6+RDp6bqRhgFIOTUx9WDQsRvbkdu2wEoV8aZ914I2Zg3MRLTcHxhyrbWvyyVHdq908aWij8pAiDJ9/UOuzbJM8iPS4vVaO3w453Nb5sb9i5UVfJ71056Ua6+0IEhe309E0HjlIpoJstbQLpgZFRYhwdsaEsgSFg718f/wpwvjTUMcP2urCiogzIEqFneRdNM9ngWPjQHpwzDZS+KYQFVeKyyjfIV2UvErDbgzjUlnNmhwDKCbjBjVebo408jYE8C0Jc2m2vZrYW9zJ+ZYyzQTsOt7Io/oS8dCr2hE9rbwy5KpIXXLWj5AHUMMGghmdZ7qYrXEnKoeyX2m8VxUPIT2iNEuyO/gMR7w5Q0IN/mYK/KFJXw+R6yjcrlCXLx6dZEngk3ZYKVffk/5fKYGUlzP8fqWtrA5EazilBAviI/zAKpjj+Q1o0+HTX2+xA362SFJq/91g+3uuldpDDAddHWLNqLJmxVTuj+7S2rAb+8cKb8kIRkL62O+S+hRd+kNA== 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)(5660300002)(8936002)(2906002)(6512007)(2616005)(26005)(1076003)(186003)(66946007)(66556008)(508600001)(6666004)(6506007)(66476007)(6486002)(4326008)(52116002)(8676002)(86362001)(38100700002)(316002)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fcvdy3CgcQ6WhuBAvtySKEL78v0nExhU2xuoiJVqm8rrNIhL8OAkts2UIbCBH0t00WSgYKR5rMDB/1uX3R6DaIDYkim4Okvusx5qmsrwy4nnqseFKDYsABzfFkZOAIpz/pVXLMxFc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P1zQ42l0DLx4yRL6fgQY+tDwuMPNE9YO/1shZwNouq0VAqTz8kNGiX4oJOhRRPL+YpblwlFI5IgpGsJX3C3Enbra9Dx3y5ySL9jjSIv4VMMWQ11iKogkMOdfyUrKMhfa6Cf7b4GsZbd+P2OSAVZo3Rfx6/Qd29nOvPxkXETBT/YFlPpHtp5O3ZirCmknrS1aD88X/Mx1K7imjhcZ7u+6YWxLcdWen/y8+IPYS8xA7MqYso3HpdHcmtDZoLD6Qs0MdNBHpGKHy4BGEzmlpOGmm0yihqi5W24WEi12Bb63CAyW45eH8rd4fsZvcT8NBXrriPeXcbGQ7LvkUkqR4q0Zf5VUrbCEb9qI3zTWKWvAREGAUpC/MJf4f4qRnsQjZsFL2mtgdS5capULq+2sC5sWMxTzLpEPv+v1kGQ3SFoW4a/F/4= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 23a8e1ec-14bf-42db-afd0-08da021b21c2 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2022 22:21:18.2313 (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: lAhsIfM3M/Y0vG937TlhmA5MZCsgJ7C7CtSTW7B/4jXS5Y3NG8kA/pOB58wsqqj4UpxKdqyx/ActKQsN2kfIqA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4512 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 --- V3: Resend V2-version 2: 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 Wed Mar 9 23:01:28 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: 12775664 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 76933C433EF for ; Wed, 9 Mar 2022 22:21:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238617AbiCIWW0 (ORCPT ); Wed, 9 Mar 2022 17:22:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238618AbiCIWWW (ORCPT ); Wed, 9 Mar 2022 17:22:22 -0500 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2087.outbound.protection.outlook.com [40.107.21.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BFFD120E8A; Wed, 9 Mar 2022 14:21:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O2ckgYhslW0OmKCVPd4RclcfnFfrVS7Zx8Rro9PmTXO/i1f8XLzXkIGThbkBB7Cmb6GGavSOWs+1dcrPb0lUXfU7KevJShZ/LjbjJ7fPJcGLAwQtLc9m0VX9iEV0dRVEUxUyvbmAdHFlaOBOiwWWcuUuzYupro7zyF8xF0eNrG5k12Nzae/vBkQN6Qk3t/zjtHfvIvpHU+O6CDGv3Y4jJJDpnIlC6WnKx+F17EDQ0EZJflZFORPIn8OWkxlVvz0KSw9k3MIMHhLqHFfj7r20fy/K3FOT+m6GVB3U1FaltudeQOKIBa3tIxHKkYdCcUay1goaJcUTXWFCKfUAlKldEw== 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=RhEfDWu1ze6ZvDKWXQK6H8VW1nqMi7O8EtFzjmxrFKo=; b=Q7KR36K+YzMiiAwcee+A6CK5rGOnYN3KNWX3sV0b7q0DmYcyugUFDpk/pYnrB7Ti7wfoPqIjbvTxKY4y4v439OjkNLOY0aDvoYF0hby2MRXpxVPA6xZxhhsYHTMY4/QfYV95i7iOi/e2NIr80dXuIqoPPo8rWdeh9wiUaa9VDO9664Exsi7uZNHS5qGwSvucgmZry9VGOw/55qA2Ur+ba9aFdg78eNwSdoj4Dy16tJAO+3iGbo/fuHCfJNn76X3iYVY94A/v3qmtYRiWmjNQ8e1fXaxL+u8GZXscrZ7UihpZ4iB80eVspC3BVX6VKM7UlykbtxcG4KZGdkId/aH0Jw== 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=RhEfDWu1ze6ZvDKWXQK6H8VW1nqMi7O8EtFzjmxrFKo=; b=A2ifYit/B9R83XA/4W+CWjMetMA/w8qLm5FhQZHL8SL9NcyEr5go3hkhYPmjz+Tv9iQAfLDaUgnO0tn96Ym6bXkePbvGq2RSN1HOA7OB2TtOdjUmekY2QCdpnHYIZ3vRuHEFZC8Qf/CM+ckYcUaIcjFWcuIhaF5cRFZfgxpURjk= 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 VI1PR04MB4512.eurprd04.prod.outlook.com (2603:10a6:803:69::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.16; Wed, 9 Mar 2022 22:21:20 +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; Wed, 9 Mar 2022 22:21:20 +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 V3 2/2] remoteproc: support attach recovery after rproc crash Date: Thu, 10 Mar 2022 07:01:28 +0800 Message-Id: <20220309230128.15856-3-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20220309230128.15856-1-peng.fan@oss.nxp.com> References: <20220309230128.15856-1-peng.fan@oss.nxp.com> X-ClientProxiedBy: SI2PR01CA0022.apcprd01.prod.exchangelabs.com (2603:1096:4:192::14) 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: f4317c70-346d-4b0e-20a5-08da021b2339 X-MS-TrafficTypeDiagnostic: VI1PR04MB4512: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: L7G0WbRDVvOHGqJpaMfAk0wUMvXKnLbqSMHr1BXJZYsmNRfD1X/b6RI+aCYmSWQQyw+anJyascq1Z/3kvLNRxQDcydd3B3b1XiwvDM7w02XuPEUAJATRC+e1BTKUkJXltWUuvkSKt/dP/xiEHCGG6P2iS1cBQKVqIwh0u5/nZ6UuGXQozSGipS9kMAaMtIfTbfD9JzHb/gUXiL/R4VJBCGE5ntIYdUeo8W4n14RbbuyUU+yPS0iIlJtEWuAgtDXibmqmAqGB0plPk99rdjrg3M6OtVmyexkVbI2NqahywFC6A2LhUtnCMp0LEwePkND1VGMxIl6ymAlS/vugpGoEyo9J0UcQqZqBEVuw5hthwNFjdm1O3qfX4ip7Mn1tyDr3tgL1O8jZnNpLNSYCaQJCNpNINMypB9u8iFYK0knylqcTGUWxm3S7NYriE72ByLu++zhqCMrdbmGq//10PEDMGEgCy9Zz0mkEA4u3ljAHd+1ZAiAbmGO44kwOAM2tsa9gQ/2vFpl/eGOIk4B6QFyY7nX9dKq2M77FNTrKGgF5Pn9It1Sp40hnfFBfFYrk8/3qKYVTx4wCfFkPROhToZAs+41WBjLrltTtQmwHMaIeXoStppZbkuVmRJD4w0MeguGA6XjK+0Ab67Z0OWSvGqgVXvATUKT9iwc2Uay8H/CG70+akrGmoJkhwWzmlkE4XHFZ6lao/VlSkjd+A7+Bsc1ZyGemOtgjredEZCyD+alsa+8+kkVHWctKgRaCjne01g4Qzcr7eUxyVMgh2yzoPSeNc8c69k/kNuut35ZdlzHoEk0= 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)(5660300002)(8936002)(2906002)(6512007)(83380400001)(2616005)(26005)(1076003)(186003)(66946007)(66556008)(966005)(508600001)(6506007)(66476007)(6486002)(4326008)(52116002)(8676002)(86362001)(38100700002)(316002)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FVakTZIG4k7zKFbDJV0IZdmlTxYWSm13zodo//e5vo8h5E8S5x87Y6yPPb5DicTu+mLqipkSrk3jsgT+GgU20fbKOibFcXJZjSR/c4va21F3pd7g7B8N2H3NcGCUwJdD6s2WGtFN4kbawObYqz33agVu2OHs9jePE58W41cyE4elebs3ZJLGieWMGK4XvRhH5yQMlWUsq46Jyc4JNa8ZXX0GYHZJ9tBuGreYZbXOcmMb+VrKcH2oFN8h1eXcbBeXSjnpLAj0A12d02couiDRapTANZZ+6kL24cLAA0iGVz8DDD3nYyEOiahTFS/Amsl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PSssyyGk78I+hldIsTEmotdgr+46rds+vhOTIf1R2w4mqD/udYmJ2Ca+aD7EZRjwTrcKHN+fj7qtx69rMObzDb64DLgKvyrSMSnOUVfEnF1x2sQp/ZHxa4xbnxQehs0lJ7j905BZvd99Y2PObhbYo2CbK1B/89/S32NbPLvHnaP8LchiUmYT+VuA6tn8tMfinjd5Upe9c72OcywAc555bfxXA9yz7nvgEIrkmx8kHMs0= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f4317c70-346d-4b0e-20a5-08da021b2339 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2022 22:21:20.6383 (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: Poi0I75p/6sVfTqx5hXrWJZeChi+fQ6Ys3BUyg+sxRE7ydi+kcKJF9bmh9MlJhSdcJ3zFcGBBdTW2vCVRNk+sg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4512 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 --- V3: Resend with cover-letter V2-version 2: use rproc_has_feature in patch 1/2 V2-version1: Nothing change in V2. Only move this patch out from https://patchwork.kernel.org/project/linux-remoteproc/list/?series=604364 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);