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); }; /**