From patchwork Wed Mar 23 03:44:04 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: 12789423 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 8A8B3C433F5 for ; Wed, 23 Mar 2022 03:42:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239462AbiCWDnz (ORCPT ); Tue, 22 Mar 2022 23:43:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231596AbiCWDnv (ORCPT ); Tue, 22 Mar 2022 23:43:51 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2054.outbound.protection.outlook.com [40.107.20.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 161796CA5A; Tue, 22 Mar 2022 20:42:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BgwSPSVO0Mjq7w1k/8/9L5CnHATBQYftXvdsP43thGL+RgpsD+dTKaaQD+yy6P4Q7xnjFqXuDPBKpWCRAIYunhoo6R3cYqEWLvMIwFMc1TLXjBdtY8l1BMcyVh1uNU3vULZ+QGxhzI1MWoTAX6SB56pk7toY5go+BQRo/IJsG3igXfX4NdF2ASJ6uoc2ktK7qLek2UeZim/vh7EprSBqxDSsPXx9KBWOYWCzb3Bv2QDDcsX/whEc3P6D3103rf6gB5kPf+2Nv2BVvaofVd/ROcQ2vkZL3SD9SRUZW/pY8xMPcPHUOHproDR1AdxbCpGUwKr47/iEB+l3JGl531iETg== 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=2zsBUw2ZzVw/TdhfoZEZuFjx0pPfrRdO/0TtQzBg4QA=; b=Ae3JD3fejPw8VH5aDFKoNG+QVPPRGpD2kd5psR6uDl5i4nx2CSlR7iQ9HDYtw/qTYCt10f9Ctmc95NKLRRmXzoY7/MU/oOJnlVw6jNBQz2+oQm/CI/EWsIUJ74VT1uXBNIJ60W6qS3iE1xtIgYv8tgPBxxoyaaQ4kDFMSXcS2hHNxjmF6+MALL+hmkFH17mlJ699/NsxKca3oItMg+OFPjo8nBKnp3QidCJ8CchtmSCZZJHOT/tcVb2s9ks2jMsl6Lc8w5j6IQnG8VqZQbToJcoE5v7me2PtIVepDpRzQAzxZJKQ/h+IdCrMXjrxAal9IJ8nvvIqS1M5NojctYJBBA== 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=2zsBUw2ZzVw/TdhfoZEZuFjx0pPfrRdO/0TtQzBg4QA=; b=fAhijZGmfYuh9tvKJ741JHKOiodEejutW74V2T2haZDsZM+D59hfAg7dpl7Z2vwy7jUgk140LC/0QbGPcDF7noquhG0+ciX/044dqoGKNIqNcBDH6MpC1qMaDCBo71deq752XZPYXly8SsG4vhI/pZWIp7+TkyyoIScDnCE7uJg= 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 AM0PR04MB6868.eurprd04.prod.outlook.com (2603:10a6:208:18c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Wed, 23 Mar 2022 03:42:21 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::1d8b:d8d8:ca2b:efff]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::1d8b:d8d8:ca2b:efff%3]) with mapi id 15.20.5102.016; Wed, 23 Mar 2022 03:42:21 +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 V4 1/2] remoteproc: introduce rproc features Date: Wed, 23 Mar 2022 11:44:04 +0800 Message-Id: <20220323034405.976643-2-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220323034405.976643-1-peng.fan@oss.nxp.com> References: <20220323034405.976643-1-peng.fan@oss.nxp.com> X-ClientProxiedBy: SG2PR06CA0111.apcprd06.prod.outlook.com (2603:1096:1:1d::13) 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: 5c6b4f07-a47f-470c-02de-08da0c7f22a8 X-MS-TrafficTypeDiagnostic: AM0PR04MB6868: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: RtCQBwYrPVzAsm4Caoq8t0BnySsIIXB2b5l0fa0GlYI4nzIMuDMjvWqJLZZQRiH31+goGUGn/aW+Tvqx7nKMG+5RYRinyQ+JN1guS7sV4r0jtOZuBiIrfM+QFXoJ9jXrJ7ATyesE3R6HPENZW+znm9vUMmSZkR/vlDD0p1N6ez/8DSEp1kGFYjq/G/4GnPjFpmEXvGMIG0oC2XPk5xLdBWUcoI3L2xCwZd6OtejZhBFEHlYxUdP/Rt7q1kKxNSk224GskdDZjTDsJFoFWRLY1BMIpp3LNTtxYpG/aiYN87p7LGYMCC8G90bD/5a3N7klaGWQDVYFMzY95Eu6mo/TiIoL5BJTsovNQAkAEWYcNbZlTt9T8lD5g8orFjh6dK3KpaklKuHUocqHgIBJX3akroZfhRdekoJSdPrrcjhnsKb8ZlCqt0nBZCnwB93sMHxWEQEve0bgcqI30bEwkn99jqoEsPki6AmJSVRJ9lG2gA95PrIdBGQ6ZHr12GLK5ERMQ6VVQ1rrsfp3vGAiaYmvlbxsd1nqgGer8Jj9OggDO13suuUFV5idO2poBT+K5QNA/DyfFb8plPQtYKV3jzHeXzvV/UySpeLv1CplfGwdNgWN00N1PFbK57ir8QlmK4oQqpJIPmX9rl7TL7NV7z2t35cIHsj/Hd3/AuNcORUeK8iziRvMJRNpCsfxt3IfoqrteU2WcJT7UXjp0nHXufsQ/g== 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)(52116002)(38350700002)(38100700002)(26005)(186003)(6512007)(8936002)(2616005)(5660300002)(2906002)(66476007)(66556008)(66946007)(508600001)(6486002)(6506007)(6666004)(316002)(1076003)(86362001)(8676002)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sh9Lh75u7VH/Qrj0y8osjEz3LgGn+LrE52xl2ZS/h75pOGxnPfLLKF7FsyRUCttZdnvNyLXfClD1RXz55g2LlZxRc00Di8qk+FP/kknnEfe6FoMFThuvfMtOuR/buTJVZMm8FV4A/VMsQohrDR79XYTrP9XERbbVtQHquThwThbPafTqRmAWhD7cHcvsRup2kH2ezXQPV/dd5TphUPvq9pp4VTrfCo4yPJlndOXvcibkyJ1OBBwKqG3r3KLn22dibPh5b12pss/3PXvZ63iuvDMAoyKdgna7Q0tP7HwZZX815pbrGypsF1f95hk1RmDclgqmxmNjr1TEgMOQwjuAlqB2Ozg3bE8rIwJ4tBofOkadMEW0U/M3ZCbBSl2QOHxDC12Q0mxz2q91ERHxuKKTYBLTUp540Mb2Y1es83FOFknE8hkfs5Pr6TcGUOZtS/qIVjZwRfOV8oo9pXyNMaZMzL3pasq6V9WhqqycAxW2kUSuF5GUT/4I2D/YsEz+bTHD8BQZjZc1gmRAP4elEZcn3rRJ/+8ZC2FcZAUrYiWhNhCDE6422ny4JHAax3lzuGwUXuXWkXoIoH4kFsvoGsUNWPYwamtvxQVy+n5zftl+10maNxAs08U5LlodO2zO2o264HTviCOUF9fn18oElPsDlOb1pdHKGzq2q/W1ItfTYofSdpYGAxTw8pVQ7+FADVi8zZ69eBj4AEAozxknxm7DmUabAcXtOJPDwkE+z8kDX9yApA+6iPW145b8YVqd+XyYWqWuv6wpWEnWVOIcgBVl7xbnMGo9IdaV0wO9KpJfav3eJve4US1nFmj763oaBQCjp/AW4hXXDShgU14qmfqs8CVmzqOCcVsqrjKV6FbLPc/TuoqyFFbMHGTHrKBEPGM+IUkadadZkp2hZM3Ibfv80d6Y6nD0FMie1JphD7IJWTVg3XZ6wNcjldaIKHyzwZ6X11jABnxkQumnwS8MeC8FHFjZJT4uHQ70b0yllAahx6I7egqleaaZoQugRzlE7tlUUM2chwd7YbWAmUeYrFJtI/dj8m2CDQN7Y0PvHKP2GzvbJAj50muG393k93iNpwvlL4feOw2fCcfH2fQZJB4ajTGS7slND6U73cTL7iuXkq9ilp7oWCgUqMNJFdG5fyu+jx1Xs2DxX6GihOSxGOQTm2FEZZxLeURxN+MHpTWLjpWW1uK9UXtEO5lyL2Zaj84SXAY4wvxawrAJG7/BuVke7x5J2WOgXHVaF49ufSCKfflnhpUfKbNuR/HWIQ8C8tt4fs5tIhqaVO3d6szv5zWTeP+U/Yr5NaT34/HAZ3WqnKapZrnG72OWBcDlQm+GVgo7iKldVavTiVs+h9M9o8djmHWKxdzLCQpzxB0QBqZqkD8EMIQ+PiZ0OakXLrQUfEEfMsCNEATXpdSdvJsU5G2A4cp5zoUKuaH+eJB1jS9Hs6NMqro2tOUCD5UHvbf7llHQ X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5c6b4f07-a47f-470c-02de-08da0c7f22a8 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2022 03:42:21.0817 (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: Isgqnp6D9P3aLd+C8r2nC6pjLwRQWza4jBHYQtTSvIyCZDb4xIAX0kMn2JjeyAiwWPIpdaCdBTb/ZlQ2l/0zuQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6868 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 | 10 ++++++++++ include/linux/remoteproc.h | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index 72d4d3d7d94d..e9ae743c5587 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -24,6 +24,16 @@ 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 void rproc_set_feature(struct rproc *rproc, unsigned int feature) +{ + set_bit(feature, rproc->features); +} + /* 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 7c943f0a2fc4..7847c6b10a69 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -489,6 +489,11 @@ struct rproc_dump_segment { loff_t offset; }; +enum rproc_features { + RPROC_FEAT_ATTACH_RECOVERY, + RPROC_MAX_FEATURES, +}; + /** * struct rproc - represents a physical remote processor device * @node: list node of this rproc object @@ -530,6 +535,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 +576,7 @@ struct rproc { u16 elf_machine; struct cdev cdev; bool cdev_put_on_release; + DECLARE_BITMAP(features, RPROC_MAX_FEATURES); }; /** From patchwork Wed Mar 23 03:44:05 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: 12789424 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 2046FC433FE for ; Wed, 23 Mar 2022 03:42:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241618AbiCWDn4 (ORCPT ); Tue, 22 Mar 2022 23:43:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240440AbiCWDnz (ORCPT ); Tue, 22 Mar 2022 23:43:55 -0400 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30062.outbound.protection.outlook.com [40.107.3.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42E4670CF9; Tue, 22 Mar 2022 20:42:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DvmH42ZewpgUu++yLGlSS//qSNrzzEk+L3KWDCMxLh4Ia3zXnJSNPG4hQF78+InxemoQMEOq4GPqQwdboHK023+exmA6VqcSU0Y2fVY/7oOmtB+jErLW/0qbVDqjiG1tZ6Tnc4siNjgzktAMTvJ3k+Dowj8JWnfdf6ksa7xrKf0/Bii/0sVJwrE3SyIEJZoZCU/39hZJwEFqG8ojK3Afbe+ypAv8q+SfTA52v3LMVgXxtrDfuOGEemKF4jRr5r+9JcYMP05en4Dxq3I1VZjbNr4SRE2J5WtcaeV9p3E6n0+5BRvY/7yRePs5IuK1cE4Ouq23cL3J+kWxx3PF12dfEg== 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=iVHg8SrcD1/iCrzLq8zCMg7MJyiD06axkQZdB8BR1Fw=; b=KZhhqD+DtBi396iYX6yZvuP4x1/YMmtTzhM7X9NCpNDFLKN9u1iT+tVI12ZIf08S60Bc9QlFrgv6ziNrf6MMJlI4RyNavtrYlYrBQiOf/rCYk2RsaZiPcM+GKaFhKECK9sBtNHSpFiR9keU3vJg8rxlmyyPEsok+xvDQb4VqHx/FHN6ZVDcb3DZg4ni1LE/JIapHND6+iHPX8W+HoFBaUXI1DSbdoq6yVodRRBfi10aiuVuR3lVWge8yX0o3iLmAbqOBV5r22zOZGN8GuRSjZ04wtAuQu7cukYrnSkg0xdq2lkYD7bwr6dVBJCkYbN/FepwZNxjimN0fEMIMBbU2gg== 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=iVHg8SrcD1/iCrzLq8zCMg7MJyiD06axkQZdB8BR1Fw=; b=A+bpVrBbGJRNTm4Yb05WvywK8Z3zual3EnTdZ0avskRCSEfPq+HA4keuRjPwXN62dy7czIQzENt7bsOxOYwF/7Sgcbm/QhaN3uc8ZSss+VWDPIzBL5SKIdKjunazVbqheir1QAPN0vkY+PBdeApmkFm8k5SMNNGxvz2R7IVf+ms= 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 AM0PR04MB6868.eurprd04.prod.outlook.com (2603:10a6:208:18c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Wed, 23 Mar 2022 03:42:23 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::1d8b:d8d8:ca2b:efff]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::1d8b:d8d8:ca2b:efff%3]) with mapi id 15.20.5102.016; Wed, 23 Mar 2022 03:42:23 +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 V4 2/2] remoteproc: support attach recovery after rproc crash Date: Wed, 23 Mar 2022 11:44:05 +0800 Message-Id: <20220323034405.976643-3-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220323034405.976643-1-peng.fan@oss.nxp.com> References: <20220323034405.976643-1-peng.fan@oss.nxp.com> X-ClientProxiedBy: SG2PR06CA0111.apcprd06.prod.outlook.com (2603:1096:1:1d::13) 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: e93f289e-8a02-4cca-a499-08da0c7f241e X-MS-TrafficTypeDiagnostic: AM0PR04MB6868: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: FkTD/+EuKG6lDroA37TuU5Uj6dggrHyptK5Vfuhyi1+026X1LPvcXls90HYiCN6rh9HQojWZlskvpxuizp12eNl8dcyeMSO+rzkiAZW/GC/tvFkgC0IN4Rey3NES/J7b0QeHfzpXBxU7SZxCK73LTBaDxMwnMCH2NvUY0Cl68IlfLN9ubqBI9R0gBWBE7lj9eNlCUaPJGPz1MoOUGy22bfuG3X9UrRP2Mwg3QGEUn9RGWHZ0BOuDizIIC5R1EtuBdmKk4sCV8XxyGvUTUrPCYnICw4qU2IJa//uLZAmQHeP0gY57VLWfLA7etNrdCtMdbBvLvAdNfw94GM9IPI5tKwriKXf7Pm1621zo32CA1nn3s1Uz0Cw64esMYVoPu18oiG2+2Skcxxapty6P3FuVkYga+qeO9AuCdN2aWI+N4cWudkdgE+rjlvbjZlhC8o4CFeNq6wb32tRRMPxAFIR2NsJ9e8EOvVh2T3kfmXO1f43md9sVD+yhtkBpX4qF76BruMGP55/cdu4Jc+tDCzm93FtdZf+uU46iz8RwTCRa6OOYmCjuvW8ARWmgfNAJ35s5qG2JQ8y8BtxyIky/Ij0UOk68bWFTVfPEHEVq60yOipEzUonvrvEaqJ56SSp1EDO8veDj424sRSBt0fUBy9VVQsRuFpRWwAW5X+LDlxzL6zVTPH1MiMW0zRu03+7xYityeTSgZNQ1i3FpjfLMbPsBdg== 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)(83380400001)(52116002)(38350700002)(38100700002)(26005)(186003)(6512007)(8936002)(2616005)(5660300002)(2906002)(66476007)(66556008)(66946007)(508600001)(6486002)(6506007)(6666004)(316002)(1076003)(86362001)(8676002)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XdsH/WqwsXmDnN3lOHKECrM0M5XwAToDWyOVoCf0asmScxLmM+CRTKqFhmCvXSsGgdMOC0TPnUt/Z7+0ya3oYfV+zo26xzIw/IoBRWN+L8H2Tzo+gT68H5NX304aCU20Qx0/thhBkx0GozK/jh+vtmuvFHRnqd3pjQCK0YmEaPWrMwwWPZRwEOOUug26W83kbMOOH8QJiy5OWJCT1DCXtvX8CuAD6IXFlE6XkeDaPnYgmaxFpDtrrLyN72jOny4ZDT1vs2NBEYo5bS0GZlBG8BWl1atjAq+mDS+3M7MXknLR9Oif6YFIff1f0uYk2A48R0+Gl4rhPCYy2J9eVD6Av38NkFQ/HBXiCqc+4PVk2vgKUdYkgeuNdLgD7h9T8Ykd9YrbZ8elCFrIMYUjQ20RTY57Jl/kvgxT9B8vDVVR6ac5m//v957PKVu27r/TCEmzR1dK3sFg1TqDPwGwbcQZIfjyy8B4HkSNiY0Q5nHD12gRKMV0MlGzVyDZdNqOwQaLpqz4MnIV9lgx7yODU6yQJx2y7XO+KZWsGkZ7tHj6UKNqvAI2MmsZcOCWxPMqeu8decuSUdzI5e+lEe1ltGXZ9p2D/mokaaF9wHgNnZuxE6uEbKgK8jedCx6uIEGrVxyVYTvzJmoAEimCsKIVWF9DOyE7p6Ppn+5zyDwFZTHXHgbCiLLkmoA6nKyeBwcvOjfPYcdYBGFex8awvEPo6qgtdH+84Yhj1j77JJH74PThzBcHQ5BmNKnFpi7sPId/5WqIi56cEOqnlLSGCtYDUNHNoVCjrUPjijnfLMYt18gr2L2xCS7aZVQbDV2GX+5CbVhBEBFsdU5Z9c/EkPhon7lDpmhumLC6C0hmj505LV+eLFZstCpqrJ2J6lW2vCWrN150OWeILdYLmDEYKYd9RLkMbJbvVEhTig2bvOdPjN4EmlbvStuJR7qA6Md55YBg/KNaYnppnmpRDFoOma1UTJusfhOK7VX2fknCP4zsC+4E3TScso+Ur9JQD7hpvvvfvV+OQ/RwDugayzcTNRm8ew/4r1DNiYYZlfmLSv6VEdS6uxMP8SS469Yi73PKDEOH0v1AY7qbmIAQvmPT+45Diogk9icPsxgpP4PL/lvaGI4VzN9t5PhRBwkzqWAbp11PoVp0jSJyM453Le2C1hkFncsCi/uEfR7dlJca4lO97MelKH42GETh79vuMhrrYSoscm38usTRQHLn7eXidI1PPrYok/Jdx2TknRNNuN7iBTUz2w2tbKNNppjp5KVp4p/VR3Ks6LEMvcl8r/vSq1e9jbuywLn0NclgbrxRQLnFKnoISF66KzXGL+OyyNHw/SSBZmHM21GRYlHvzgjnGxRC13dRodTWXKp5ttybDwcJ/axV03e9QOI7HvAXsTh8eCIh95PU51NLJ2WLGB+fZVAs+i/v+LIMvPYDfO6LP2c9sxZeB8hT2rFNiojH8a2o1z+rfAh7 X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e93f289e-8a02-4cca-a499-08da0c7f241e X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2022 03:42:23.5226 (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: bt5pyPymTEUsWBHG6DeSStux6kCXVqfbDX2kiamgNkw9U9B2SdrEH2Q+NWg7qoGIYKm5HBUI5Cj5eJp4TdIbzg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6868 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 --- 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 c510125769b9..ad04515750ef 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);