[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[XEN][PATCH v12 07/20] libfdt: overlay: change overlay_get_target()


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Vikram Garhwal <vikram.garhwal@xxxxxxx>
  • Date: Tue, 5 Sep 2023 18:16:17 -0700
  • 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
  • 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=hIdkQwz/vWZLb8REj8ZgK31pJlOCQXNBIIO0mzDnm/ywrt7NhZsmqZmPEDQQhvVex67Rlk8cXsPpvKTdg+78Ku7uXvUTcqJBh16IMPtvFWLZnRUPknZm+gq4ItZiUgCMazmH2miyYYY30NNjWcM3voVlBsXvuZXopTZXtN9FPSQdPzEGnJw1jDs4gipmYb3vViTSwEUhExM6VxDKmOzgs00bsxQM3MY5iRWYBOoWQjehIJHFi/9cPJ1dttKgf+ttfnQfftxIuvLRxzZaglatrJU1yzbs6lxg6eilWMSLt33oQtLlOiMeXdq03TmvASakAnZt1bQMV6P+DebBWqaeCQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F1eCggap940r3PjRkSvnfz0QJhFg8LUifFyWCbFNN1gV1nL8CbUq8ihRAJjoWGZyU5nHYurQbavX/MEC+YY+CbtVn3qNMuaKUwJKQNiGw8ADsIYhfVqxMrTN3g22TmsNI3ffiGaIjjyUkPvlCHc+8zvdR2sEpaySOJS0dK3ClCP7A62TdAYJ/1NlhS/iPy9DI6RQI40WnU11qbepxj5Tr/HJYMWkv6rp6Pp7hXEqIYxjdP01jZand/K120tPQwlUWQ3ZPh0e0SW3H0U1OPVew2RccF6QcBdw+hk6JDJOrLXDpIj+8tLylswimqUwfSLG7u/sGMtWZYp8Dm9aPhTHHg==
  • Cc: <vikram.garhwal@xxxxxxx>, <julien@xxxxxxx>, <michal.orzel@xxxxxxx>, <sstabellini@xxxxxxxxxx>, Vikram Garhwal <fnu.vikram@xxxxxxxxxx>, "David Gibson" <david@xxxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 06 Sep 2023 01:16:55 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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 <fnu.vikram@xxxxxxxxxx>
Message-Id: <1637204036-382159-2-git-send-email-fnu.vikram@xxxxxxxxxx>
Signed-off-by: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>
Origin: git://git.kernel.org/pub/scm/utils/dtc/dtc.git 45f3d1a095dd

Signed-off-by: Vikram Garhwal <vikram.garhwal@xxxxxxx>
Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>
Reviewed-by: Henry Wang <Henry.Wang@xxxxxxx>
Acked-by: Juline Grall <jgrall@xxxxxxxxxx>
---
 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                                */
 /**********************************************************************/
-- 
2.17.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.