All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vikram Garhwal <fnu.vikram@xilinx.com>
To: <xen-devel@lists.xenproject.org>
Cc: <sstabellini@kernel.org>, <julien@xen.org>,
	<bertrand.marquis@arm.com>, <volodymyr_babchuk@epam.com>,
	Vikram Garhwal <fnu.vikram@xilinx.com>
Subject: [XEN][RFC PATCH v3 04/14] libfdt: overlay: change overlay_get_target()
Date: Tue, 8 Mar 2022 11:46:54 -0800	[thread overview]
Message-ID: <20220308194704.14061-5-fnu.vikram@xilinx.com> (raw)
In-Reply-To: <20220308194704.14061-1-fnu.vikram@xilinx.com>

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.

This commit is also applied to git://github.com/dgibson/dtc:
    commit: ad9cf6bde5b90d4c1e5a79a2803e98d6344c27d7.

Signed-off-by: Vikram Garhwal <fnu.vikram@xilinx.com>
---
 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



  parent reply	other threads:[~2022-03-08 19:47 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-08 19:46 [XEN][RFC PATCH v3 00/14] dynamic node programming using overlay dtbo Vikram Garhwal
2022-03-08 19:46 ` [XEN][RFC PATCH v3 01/14] xen/arm/device: Remove __init from function type Vikram Garhwal
2022-03-14 12:31   ` Luca Fancellu
2022-03-15 22:29     ` Vikram Garhwal
2022-03-15 22:42     ` Vikram Garhwal
2022-03-08 19:46 ` [XEN][RFC PATCH v3 02/14] xen/arm: Add CONFIG_OVERLAY_DTB Vikram Garhwal
2022-03-14 12:42   ` Luca Fancellu
2022-03-08 19:46 ` [XEN][RFC PATCH v3 03/14] libfdt: Keep fdt functions after init for CONFIG_OVERLAY_DTB Vikram Garhwal
2022-05-17 17:36   ` Julien Grall
2022-03-08 19:46 ` Vikram Garhwal [this message]
2022-03-14 14:55   ` [XEN][RFC PATCH v3 04/14] libfdt: overlay: change overlay_get_target() Luca Fancellu
2022-05-17 17:51   ` Julien Grall
2022-03-08 19:46 ` [XEN][RFC PATCH v3 05/14] xen/device-tree: Add _dt_find_node_by_path() to find nodes in device tree Vikram Garhwal
2022-03-14 15:35   ` Luca Fancellu
2022-03-08 19:46 ` [XEN][RFC PATCH v3 06/14] xen/smmu: Add remove_device callback for smmu_iommu ops Vikram Garhwal
2022-03-14 15:45   ` Luca Fancellu
2022-03-08 19:46 ` [XEN][RFC PATCH v3 07/14] xen/iommu: Move spin_lock from iommu_dt_device_is_assigned to caller Vikram Garhwal
2022-03-14 15:58   ` Luca Fancellu
2022-05-17 18:19   ` Julien Grall
2022-03-08 19:46 ` [XEN][RFC PATCH v3 08/14] xen/iommu: protect iommu_add_dt_device() with dtdevs_lock Vikram Garhwal
2022-03-14 17:34   ` Luca Fancellu
2022-03-08 19:46 ` [XEN][RFC PATCH v3 09/14] xen/iommu: Introduce iommu_remove_dt_device() Vikram Garhwal
2022-03-14 17:50   ` Luca Fancellu
2022-12-07  5:21     ` Vikram Garhwal
2022-03-08 19:47 ` [XEN][RFC PATCH v3 10/14] xen/arm: Implement device tree node removal functionalities Vikram Garhwal
2022-03-15 10:10   ` Luca Fancellu
2022-05-18 18:31   ` Julien Grall
2022-12-07  1:37     ` Vikram Garhwal
2022-12-07 16:50       ` Julien Grall
2022-05-19  8:13   ` Julien Grall
2022-03-08 19:47 ` [XEN][RFC PATCH v3 11/14] xen/arm: Implement device tree node addition functionalities Vikram Garhwal
2022-03-15 10:40   ` Luca Fancellu
2022-05-18 19:03   ` Julien Grall
2022-03-08 19:47 ` [XEN][RFC PATCH v3 12/14] tools/libs/ctrl: Implement new xc interfaces for dt overlay Vikram Garhwal
2022-03-15 10:49   ` Luca Fancellu
2022-03-17 15:47   ` Anthony PERARD
2022-03-08 19:47 ` [XEN][RFC PATCH v3 13/14] tools/libs/light: Implement new libxl functions for device tree overlay ops Vikram Garhwal
2022-03-15 10:58   ` Luca Fancellu
2022-03-17 17:45   ` Anthony PERARD
2022-03-08 19:47 ` [XEN][RFC PATCH v3 14/14] tools/xl: Add new xl command overlay for device tree overlay support Vikram Garhwal
2022-03-15 12:11   ` Luca Fancellu
2022-03-17 18:18   ` Anthony PERARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220308194704.14061-5-fnu.vikram@xilinx.com \
    --to=fnu.vikram@xilinx.com \
    --cc=bertrand.marquis@arm.com \
    --cc=julien@xen.org \
    --cc=sstabellini@kernel.org \
    --cc=volodymyr_babchuk@epam.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.