From patchwork Wed Dec 7 06:15:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vikram Garhwal X-Patchwork-Id: 13066659 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 07597C352A1 for ; Wed, 7 Dec 2022 06:16:54 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.455838.713446 (Exim 4.92) (envelope-from ) id 1p2njZ-0008Tc-PY; Wed, 07 Dec 2022 06:16:45 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 455838.713446; Wed, 07 Dec 2022 06:16:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p2njZ-0008TU-Ma; Wed, 07 Dec 2022 06:16:45 +0000 Received: by outflank-mailman (input) for mailman id 455838; Wed, 07 Dec 2022 06:16:45 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p2njY-0007Hl-Ui for xen-devel@lists.xenproject.org; Wed, 07 Dec 2022 06:16:45 +0000 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20612.outbound.protection.outlook.com [2a01:111:f400:7e88::612]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id b7b32493-75f6-11ed-8fd2-01056ac49cbb; Wed, 07 Dec 2022 07:16:43 +0100 (CET) Received: from DS7PR03CA0024.namprd03.prod.outlook.com (2603:10b6:5:3b8::29) by DM4PR12MB6208.namprd12.prod.outlook.com (2603:10b6:8:a5::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Wed, 7 Dec 2022 06:16:40 +0000 Received: from DS1PEPF0000E64E.namprd02.prod.outlook.com (2603:10b6:5:3b8:cafe::2b) by DS7PR03CA0024.outlook.office365.com (2603:10b6:5:3b8::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14 via Frontend Transport; Wed, 7 Dec 2022 06:16:40 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by DS1PEPF0000E64E.mail.protection.outlook.com (10.167.18.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5880.8 via Frontend Transport; Wed, 7 Dec 2022 06:16:39 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 7 Dec 2022 00:16:18 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 6 Dec 2022 22:16:17 -0800 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Wed, 7 Dec 2022 00:16:17 -0600 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b7b32493-75f6-11ed-8fd2-01056ac49cbb ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DQr3GLA+FDgw6wbm/yN9MUDG2l1ZRJDz3KFWJER+1rrW8BFIYIfBgQuz2trTwvXPjKrUtg4W50N20OHsJolgO2b5kcL5p0WPsVSFM8o0gbT95+yYOFKYmaC5BIJ3VHbeiJlgudJcUG7mUi0tcwtaabKwBqDJtdIbCOe735RimX8ANRmIlolCo9x2Whi3NkDr7Jkk2NNiO04IQ+vvZEzkHNVBqGPtj7ZUbzIR8nAZkrVkF+v/HNwYcesk6jRszFUTD3WjJ38U6XKcVuhLcbU/Ln2MjHC75weEpCPNpmXAwyTvoSnqCo+gp+XOwGsu4IX9SlZjpk9/+w68PuqqyDU1WQ== 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=g6KtYvddfVW+GCdGKl8QzCqK7RXkmTVgJchJNwSNoN4=; b=AzESfRdXMJXQUfcbbVF/Dmr0G/7pO6ABftIMJN/6oFWC2iQFxrPsBEznTAiKjhJXU16aGNTx2JlLKx2ZjYAO5p7fiCPYiMEfXx80hA/0gdV/+V7Sux3c6LLfQ2Dm7ONgZDFj0eSwu+tBurMv3ba066ZXBGVaZnpi4S2JbVlcPqYe1ExkIjoUKithrONFRePIPK17+W4tA+tSMlFZfxNgVeD6xqCMXibIb1SvZj/xcEd1bfACsOu0G1thQ2BktBe6fxDlsdBjXH2YyCNgiLVsRGFTXEkTC9ELYK9PsxRWdkbOMyIL9MofQyj+WtlQCULlc1fPZ9CKZ247hZfyk5I/yA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=g6KtYvddfVW+GCdGKl8QzCqK7RXkmTVgJchJNwSNoN4=; b=v5mroyvYtjC6nez3wp+bbTwU45xdgTA4sKGJ2oeB34Q9xOTplHRhwrOeqxzepz08K9o0tPFlIVUDkejw9RxMxHRMwIwPC4IX/MmUR366AnX8lp8YSXwCeJvS1rpgUqhsEPdgZmJSzqU/hh+l9jT/iOzIS93JP3wfgBiTDXiFz40= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Vikram Garhwal To: CC: , , , David Gibson Subject: [XEN][RFC PATCH v4 04/16] libfdt: overlay: change overlay_get_target() Date: Tue, 6 Dec 2022 22:15:25 -0800 Message-ID: <20221207061537.7266-5-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221207061537.7266-1-vikram.garhwal@amd.com> References: <20221207061537.7266-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E64E:EE_|DM4PR12MB6208:EE_ X-MS-Office365-Filtering-Correlation-Id: 842a9634-8217-41d8-4022-08dad81a9a63 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZL+pOnjaKC91xIm0LPMLFE9MldlgvHBAXhvMlrmYHbsJ1hXPPwRc+8Yes2K1574P8kVJdUdjPKZTsXOrAG92ykTHtpUCFxDKX41i1FzyBYQ6rYN4pX6ShGAJRwp8wI2ZDW0hwZNRYUCm1nfkmRN6+AUQsTIKF/yI6x5tTrVulWi/4YblcM7xNjTeMtFOOXhaILoAab4y6CUjrYw+hPwhcypS77i4FSpYPo8fWV2/k83bHqCyKWYCaw3EWIHOMjjSNThjH5eGBchr1f/maZv9mf6R5FL/VVxieKc3dqk95cufAb32PLJ+wVMEZwHtzWhUI7Jrs9kdrhSaJPCxACCbBMEUYnQCiIMTN+s5aeruq4LTDPScbj6zbswEIeiAuKxBOt52GmhNBjiixtdCwxg3MASLL7m+x1kE4gb/HCFneutITTiCTtaCAXEaQ5OINMSs5xqTgMFMJJE/vsLxKZnCIBpshEJgXFKIV3IctdsimroCpgT7oAiyGfzu3IfF2sSO1LZBuVmOaGBZDZ/Up6nPKcT9gmCkfxFOHc/VjxPmQOUx15Bf7avDMK9pd2mgXbJ1PKYLKHOhxivHQP5wAoZGOFz7E642TiumG7EBcekjKgOm/hCClZx9HL8KYt77uNdUjpPbhXfZTVFhXnVRAU9JnULBUSJ1NEcj0V4VcrBrkOsEYnbIqzW29wT7tzqqUyrUu1vQejPX/9OvB0Ic95IxIz57RIo1SC1BueQ3gG1K7yX71/cXSzcKV2QFcbgSkYNto1SHX10BIZYJWnzmXqLtnQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(136003)(346002)(376002)(396003)(39860400002)(451199015)(40470700004)(36840700001)(46966006)(1076003)(41300700001)(2616005)(186003)(70206006)(70586007)(478600001)(36860700001)(82310400005)(336012)(6666004)(47076005)(356005)(40460700003)(44832011)(81166007)(26005)(966005)(8936002)(5660300002)(316002)(36756003)(2906002)(40480700001)(86362001)(4326008)(8676002)(426003)(83380400001)(82740400003)(54906003)(6916009)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2022 06:16:39.6354 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 842a9634-8217-41d8-4022-08dad81a9a63 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0000E64E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6208 Rename overlay_get_target() to fdt_overlay_target_offset() and remove static function type. This is done to get the target path for the overlay nodes which is very useful in many cases. For example, Xen hypervisor needs it when applying overlays because Xen needs to do further processing of the overlay nodes, e.g. mapping of resources(IRQs and IOMMUs) to other VMs, creation of SMMU pagetables, etc. Origin: https://github.com/dgibson/dtc 45f3d1a095dd Signed-off-by: Vikram Garhwal Message-Id: <1637204036-382159-2-git-send-email-fnu.vikram@xilinx.com> Signed-off-by: David Gibson --- xen/common/libfdt/fdt_overlay.c | 29 +++++++---------------------- xen/common/libfdt/version.lds | 1 + xen/include/xen/libfdt/libfdt.h | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/xen/common/libfdt/fdt_overlay.c b/xen/common/libfdt/fdt_overlay.c index 7b95e2b639..acf0c4c2a6 100644 --- a/xen/common/libfdt/fdt_overlay.c +++ b/xen/common/libfdt/fdt_overlay.c @@ -41,37 +41,22 @@ static uint32_t overlay_get_target_phandle(const void *fdto, int fragment) return fdt32_to_cpu(*val); } -/** - * overlay_get_target - retrieves the offset of a fragment's target - * @fdt: Base device tree blob - * @fdto: Device tree overlay blob - * @fragment: node offset of the fragment in the overlay - * @pathp: pointer which receives the path of the target (or NULL) - * - * overlay_get_target() retrieves the target offset in the base - * device tree of a fragment, no matter how the actual targeting is - * done (through a phandle or a path) - * - * returns: - * the targeted node offset in the base device tree - * Negative error code on error - */ -static int overlay_get_target(const void *fdt, const void *fdto, - int fragment, char const **pathp) +int fdt_overlay_target_offset(const void *fdt, const void *fdto, + int fragment_offset, char const **pathp) { uint32_t phandle; const char *path = NULL; int path_len = 0, ret; /* Try first to do a phandle based lookup */ - phandle = overlay_get_target_phandle(fdto, fragment); + phandle = overlay_get_target_phandle(fdto, fragment_offset); if (phandle == (uint32_t)-1) return -FDT_ERR_BADPHANDLE; /* no phandle, try path */ if (!phandle) { /* And then a path based lookup */ - path = fdt_getprop(fdto, fragment, "target-path", &path_len); + path = fdt_getprop(fdto, fragment_offset, "target-path", &path_len); if (path) ret = fdt_path_offset(fdt, path); else @@ -638,7 +623,7 @@ static int overlay_merge(void *fdt, void *fdto) if (overlay < 0) return overlay; - target = overlay_get_target(fdt, fdto, fragment, NULL); + target = fdt_overlay_target_offset(fdt, fdto, fragment, NULL); if (target < 0) return target; @@ -781,7 +766,7 @@ static int overlay_symbol_update(void *fdt, void *fdto) return -FDT_ERR_BADOVERLAY; /* get the target of the fragment */ - ret = overlay_get_target(fdt, fdto, fragment, &target_path); + ret = fdt_overlay_target_offset(fdt, fdto, fragment, &target_path); if (ret < 0) return ret; target = ret; @@ -803,7 +788,7 @@ static int overlay_symbol_update(void *fdt, void *fdto) if (!target_path) { /* again in case setprop_placeholder changed it */ - ret = overlay_get_target(fdt, fdto, fragment, &target_path); + ret = fdt_overlay_target_offset(fdt, fdto, fragment, &target_path); if (ret < 0) return ret; target = ret; diff --git a/xen/common/libfdt/version.lds b/xen/common/libfdt/version.lds index 7ab85f1d9d..cbce5d4a8b 100644 --- a/xen/common/libfdt/version.lds +++ b/xen/common/libfdt/version.lds @@ -77,6 +77,7 @@ LIBFDT_1.2 { fdt_appendprop_addrrange; fdt_setprop_inplace_namelen_partial; fdt_create_with_flags; + fdt_overlay_target_offset; local: *; }; diff --git a/xen/include/xen/libfdt/libfdt.h b/xen/include/xen/libfdt/libfdt.h index c71689e2be..fabddbee8c 100644 --- a/xen/include/xen/libfdt/libfdt.h +++ b/xen/include/xen/libfdt/libfdt.h @@ -2109,6 +2109,24 @@ int fdt_del_node(void *fdt, int nodeoffset); */ int fdt_overlay_apply(void *fdt, void *fdto); +/** + * fdt_overlay_target_offset - retrieves the offset of a fragment's target + * @fdt: Base device tree blob + * @fdto: Device tree overlay blob + * @fragment_offset: node offset of the fragment in the overlay + * @pathp: pointer which receives the path of the target (or NULL) + * + * fdt_overlay_target_offset() retrieves the target offset in the base + * device tree of a fragment, no matter how the actual targeting is + * done (through a phandle or a path) + * + * returns: + * the targeted node offset in the base device tree + * Negative error code on error + */ +int fdt_overlay_target_offset(const void *fdt, const void *fdto, + int fragment_offset, char const **pathp); + /**********************************************************************/ /* Debugging / informational functions */ /**********************************************************************/