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

[XEN][PATCH v5 02/17] common/device_tree: change __unflatten_device_tree()


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Vikram Garhwal <vikram.garhwal@xxxxxxx>
  • Date: Tue, 11 Apr 2023 12:16:21 -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=0odwSwlZEbTJvdLLf27PaAsLK4pjjIm+Jsb7s8Lqv7g=; b=K3LK6ruFsTA4TPqFt/ammZSl/L8ggQ6E16nomQr5n3ta6K0P+pc/IVT5pkNN8uKuBfN33CHrxT49q9EbSeedM+cJ9eBr5YKtjSRzUXAS3ki2vEzEcU272lsMobTIFxbZ35sDe9X5OMw0QP19LbdEUNveyReAdEinT6VGWtcOt+sjJ9t7O+TOqVZif8yPg+IlNbIbZP8MPBIDycowyRdg/OKXXvmcDnzoQccPxD8YtsQm4XyAdJ4AkjRQYTqVnIMebgRyjh176UgkFlaschPgOCAyq6aJPbs4nOJl6xueJtw7xLSbE+NNKhSn8K67xZDLZt4Q8tdSLM3GSuEmGpXf+g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Nd9RHJF2398b5isOKaYdNprBPl/JNuJF6/ge3zT77zkGtEPFSzds6zzf69EGMJAgklQy0X2u3+v9EzkoUL8og3kVHQixgbWQ5Njigjp66elYLenh+J7QZEtnku2fMxbv6PBqSq6XIUj6sva/sCfwpP1PsxcwsbfWdY496muh8Z0FNB87I9udOfbP5c8smQ5H8CGbfH5c8V32AP2JJfi9boLHlUPpiFHk0Qj5HgGnWlTpfQLHfHGfKZoeheoD6EWHaF6sTHYHVSB6UxxLD5olg3jxzi0vdP4lQP8I1jTuxUMXF086TLemBhklKP1rC8U3EvYFa6TzY3yYcxuxpEoqJw==
  • Cc: <sstabellini@xxxxxxxxxx>, Vikram Garhwal <vikram.garhwal@xxxxxxx>, "Julien Grall" <julien@xxxxxxx>
  • Delivery-date: Tue, 11 Apr 2023 19:20:18 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Following changes are done to __unflatten_device_tree():
    1. __unflatten_device_tree() is renamed to unflatten_device_tree().
    2. Remove static function type.
    3. Add handling of memory allocation. This will be useful in dynamic node
        programming when we unflatten the dt during runtime memory allocation
        can fail.

Signed-off-by: Vikram Garhwal <vikram.garhwal@xxxxxxx>
---
 xen/common/device_tree.c      | 10 ++++++----
 xen/include/xen/device_tree.h |  5 +++++
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
index aed38ff63c..bf847b2584 100644
--- a/xen/common/device_tree.c
+++ b/xen/common/device_tree.c
@@ -2047,7 +2047,7 @@ static unsigned long unflatten_dt_node(const void *fdt,
 }
 
 /**
- * __unflatten_device_tree - create tree of device_nodes from flat blob
+ * unflatten_device_tree - create tree of device_nodes from flat blob
  *
  * unflattens a device-tree, creating the
  * tree of struct device_node. It also fills the "name" and "type"
@@ -2056,8 +2056,7 @@ static unsigned long unflatten_dt_node(const void *fdt,
  * @fdt: The fdt to expand
  * @mynodes: The device_node tree created by the call
  */
-static void __unflatten_device_tree(const void *fdt,
-                                    struct dt_device_node **mynodes)
+void unflatten_device_tree(const void *fdt, struct dt_device_node **mynodes)
 {
     unsigned long start, mem, size;
     struct dt_device_node **allnextp = mynodes;
@@ -2079,6 +2078,9 @@ static void __unflatten_device_tree(const void *fdt,
     /* Allocate memory for the expanded device tree */
     mem = (unsigned long)_xmalloc (size + 4, __alignof__(struct 
dt_device_node));
 
+    if ( !mem )
+        panic("Cannot allocate memory for unflatten device tree\n");
+
     ((__be32 *)mem)[size / 4] = cpu_to_be32(0xdeadbeef);
 
     dt_dprintk("  unflattening %lx...\n", mem);
@@ -2179,7 +2181,7 @@ dt_find_interrupt_controller(const struct dt_device_match 
*matches)
 
 void __init dt_unflatten_host_device_tree(void)
 {
-    __unflatten_device_tree(device_tree_flattened, &dt_host);
+    unflatten_device_tree(device_tree_flattened, &dt_host);
     dt_alias_scan();
 }
 
diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h
index 19a74909ce..58ac12abe3 100644
--- a/xen/include/xen/device_tree.h
+++ b/xen/include/xen/device_tree.h
@@ -178,6 +178,11 @@ int device_tree_for_each_node(const void *fdt, int node,
  */
 void dt_unflatten_host_device_tree(void);
 
+/**
+ * unflatten any device tree.
+ */
+void unflatten_device_tree(const void *fdt, struct dt_device_node **mynodes);
+
 /**
  * IRQ translation callback
  * TODO: For the moment we assume that we only have ONE
-- 
2.17.1




 


Rackspace

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