From patchwork Fri Aug 25 08:02:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vikram Garhwal X-Patchwork-Id: 13365122 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 9E5F7C3DA6F for ; Fri, 25 Aug 2023 08:03:32 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.590555.922936 (Exim 4.92) (envelope-from ) id 1qZRmk-0000u5-Gu; Fri, 25 Aug 2023 08:03:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 590555.922936; Fri, 25 Aug 2023 08:03:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qZRmk-0000qz-3n; Fri, 25 Aug 2023 08:03:14 +0000 Received: by outflank-mailman (input) for mailman id 590555; Fri, 25 Aug 2023 08:03:12 +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 1qZRmh-0007G4-Mz for xen-devel@lists.xenproject.org; Fri, 25 Aug 2023 08:03:11 +0000 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20600.outbound.protection.outlook.com [2a01:111:f400:7eae::600]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id d3cea309-431d-11ee-9b0c-b553b5be7939; Fri, 25 Aug 2023 10:03:09 +0200 (CEST) Received: from SJ0PR13CA0188.namprd13.prod.outlook.com (2603:10b6:a03:2c3::13) by DS0PR12MB7804.namprd12.prod.outlook.com (2603:10b6:8:142::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.29; Fri, 25 Aug 2023 08:03:06 +0000 Received: from CO1PEPF000044F5.namprd05.prod.outlook.com (2603:10b6:a03:2c3:cafe::7c) by SJ0PR13CA0188.outlook.office365.com (2603:10b6:a03:2c3::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.14 via Frontend Transport; Fri, 25 Aug 2023 08:03:05 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000044F5.mail.protection.outlook.com (10.167.241.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.15 via Frontend Transport; Fri, 25 Aug 2023 08:03:05 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Fri, 25 Aug 2023 03:03:01 -0500 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Fri, 25 Aug 2023 03:03:00 -0500 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: d3cea309-431d-11ee-9b0c-b553b5be7939 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nMjiC0Nkq7g3Jm2aw9sUlVaeRE74l8OFPLoNaw5QgiMrCEMbb52tyyvplAXwpMB4mUPSbN/4WAFF/ngniJnxSbVJGxQeMwAZf9Wf0C1ukUmcDVZ9Y06JOtmWbK5dJqhPXIHchP82o6ebGddxHNK9vrHrAUdoRVZxXUOCdsTJq6djd1wl+JS5lq4tY5NjzWJSL7rqCuqTGbc8bsrlVdsGcyKN0Jt8YF9ImbW/mV32R/bwpp+3uDZQDEIoR2cKrRSjr/X3Zx3mIbsQHqSUnGsdKWlyaO2Ig1iobVJoRT6Jvv2K20BZDugW4LCTSMlNaHKfBb8H0DCIA7xCAiMPqSjdLw== 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=653u6xWPNriUED+G4weH7ZKsZbL2O1CzT4XNOpC6uN4=; b=eI9U8dpioistzfKA+X1FtTjeLC/MrD31yX6n5sDJl6ekswmVVOKKT6C4R5QkqYz831up7e3CStiG7gg4LIS98hcwpobWRaKDZ6HTVD8J+RuYtoxysZJ3noBpBbShz6YyM8xku6JpIFkz4utDlRppiSBWXMHYLA4c/vzp8SnGswqbz6ULy4M07ulRad9WDfapVPmB4+1jOASmrFI6ZWx6hq81rzxVQqCZSiZ5diHYin6Xubljn+2UwU8ii+PDLEAtpFxy62+riyJOskXo3cs25uGyI2xwvyb42MV5e9bYOCcIqyqC1C1DVFyNqZpc8lbc+qAqI1YtLdQXQlCE9DoRwA== 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=653u6xWPNriUED+G4weH7ZKsZbL2O1CzT4XNOpC6uN4=; b=TU7uY2SGH39yZGXVbw0AIfjnBgbRs70cMZv7CGtwx8JhpD7itiY25szXkQKC5ZOWK8WPwaXkmUHbZs8Rbbbk48y+EQhlXvRaW1UeXViM70UGy9baZ1h1RxHzK8vCVAVWK78rmRRwaFHQGX/6QXqZUAQ5IaNYVJkoCk3WPf/GvRA= 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=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , , , , Vikram Garhwal , David Gibson Subject: [XEN][PATCH v10 07/20] libfdt: overlay: change overlay_get_target() Date: Fri, 25 Aug 2023 01:02:09 -0700 Message-ID: <20230825080222.14247-8-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230825080222.14247-1-vikram.garhwal@amd.com> References: <20230825080222.14247-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F5:EE_|DS0PR12MB7804:EE_ X-MS-Office365-Filtering-Correlation-Id: 438c18e0-22a6-43ae-1da2-08dba541b671 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xb8ndx0ya9H0rFFlbM+u+px5gtawftpjvhtTosdabWRc2xkSWI53697QzRJ5WdkOFJoQEp0aIZvDuFf5mARvzCYsjWQHE8C3uFia0Gs47Siuwb3qpVMyfVwBXSuiDGLHILgkqvWQ4Xkv6VI2+PFFJyjX0k6tPXOnKCvPlj+Ltwy+2lrRmO+1pf+NhVqnYCHKZLxSeFJKLMKnY08yf6ko33J4I3RvfIDUD5274ZI43Jiw00dHFfUuJx2N4Or4Xofk7KuyBwQpbiSXIs+d4KlSk+LWVyLd4GXtI/gKW+khqYipq072EF1dh8JSP3abUkSJSALIZzu+bnf04dl4NFpZOVkiPf1rrMShXcVPBgT6DMTnH7+nXn01IL3cbxpaISQPn4Rd3Eqp26OwUqvCMbe+qtqqTGFQXLcZGi9i67Qoap3x526ywNLROn5CALcsS658DQ8Y0AeeYWnUn0DKbWzhWiQlXVY2ggwPSNAOKsa6TXUFTi71el72CdcbnCZLzurVaRNiWJ5tZ3suTn/LyPRwVPup3z+6J8RTkeLmfj14gh6BWQtbq/2oClZE9PEI+mcZ2utdvAHhtK9rNfCTABCd7J+nNQ2b+YwHqT7CzJ7Z/2webTBZFoPgUD9zQvlj8Wtz5dl+LpOd+jO2W2wk9XyNgn+GBvHsOY84JMX5+SowRq3ZYaDULj/ouYHnWMmDq/3DR5djn3ifoRXYcTmac8DNdRFGLhY9aAkJqYDislJ63BZw3UKoGsGA5mmflcH8KWvEPM6A4fBdq3iDtS+zrUjrPA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(136003)(376002)(346002)(396003)(82310400011)(451199024)(1800799009)(186009)(46966006)(40470700004)(36840700001)(82740400003)(81166007)(356005)(40460700003)(8676002)(4326008)(8936002)(54906003)(41300700001)(316002)(36756003)(6916009)(70586007)(70206006)(86362001)(40480700001)(47076005)(26005)(478600001)(336012)(36860700001)(1076003)(44832011)(83380400001)(2906002)(2616005)(426003)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2023 08:03:05.3662 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 438c18e0-22a6-43ae-1da2-08dba541b671 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F5.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7804 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. Signed-off-by: Vikram Garhwal Message-Id: <1637204036-382159-2-git-send-email-fnu.vikram@xilinx.com> Signed-off-by: David Gibson Origin: git://git.kernel.org/pub/scm/utils/dtc/dtc.git 45f3d1a095dd Signed-off-by: Vikram Garhwal Reviewed-by: Michal Orzel Reviewed-by: Henry Wang Acked-by: Juline Grall --- 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 */ /**********************************************************************/