Skip to contentSkip to conversation

xen/arm, device-tree: Make static-mem use #{address,size}-cells

PATCH In review Henry Wang 4 participants 4 messages Sep 9, 2022

lore
Share & tools
lore

Henry Wang

author
#0 lore raw

PATCH v2 1/1 xen/arm, device-tree: Make static-mem use #{address,size}-cells

In order to keep consistency in the device tree binding, there is no need for static memory allocation feature to define a specific set of address and size cells for "xen,static-mem" property.

Therefore, this commit reuses the regular #{address,size}-cells for parsing the device tree "xen,static-mem" property. Update the documentation accordingly.

Also, take the chance to remove the unnecessary "#address-cells" and "#size-cells" in the domU1 node of the device tree to only emphasize the related part that the example is showing.

---
Changes from v1 to v2:
- Remove the "----" addition, as it is unnecessary to this patch.
- Mention the removal of #address-cells and #size-cells in domU1 node in the commit message.

---
 docs/misc/arm/device-tree/booting.txt | 11 +++++------
 docs/misc/arm/passthrough-noiommu.txt |  7 +++----
 xen/arch/arm/bootfdt.c                |  5 -----
 xen/arch/arm/domain_build.c           | 16 ++--------------
 4 files changed, 10 insertions(+), 29 deletions(-)
docs/misc/arm/device-tree/booting.txt +5 -6
index 5395a1077c..10caf4f1af 100644
@@ -350,8 +350,8 @@ areas are pre-defined by configuration using physical address ranges.
 
 Memory can be statically allocated to a domain using the property "xen,static-
 mem" defined in the domain configuration. The number of cells for the address
-and the size must be defined using respectively the properties
-"#xen,static-mem-address-cells" and "#xen,static-mem-size-cells".
+and the size must be defined respectively by the parent node properties
+"#address-cells" and "#size-cells".
 
 The property 'memory' is still needed and should match the amount of memory
 given to the guest. Currently, it either comes from static memory or lets Xen
@@ -366,14 +366,13 @@ device-tree:
 
     / {
         chosen {
+            #address-cells = <0x1>;
+            #size-cells = <0x1>;
+            ...
             domU1 {
                 compatible = "xen,domain";
-                #address-cells = <0x2>;
-                #size-cells = <0x2>;
                 cpus = <2>;
                 memory = <0x0 0x80000>;
-                #xen,static-mem-address-cells = <0x1>;
-                #xen,static-mem-size-cells = <0x1>;
                 xen,static-mem = <0x30000000 0x20000000>;
                 ...
             };
docs/misc/arm/passthrough-noiommu.txt +3 -4
index 3e2ef21ad7..69b8de1975 100644
@@ -33,14 +33,13 @@ on static allocation in the device-tree:
 
 / {
 	chosen {
+		#address-cells = <0x1>;
+		#size-cells = <0x1>;
+		...
 		domU1 {
 			compatible = "xen,domain";
-			#address-cells = <0x2>;
-			#size-cells = <0x2>;
 			cpus = <2>;
 			memory = <0x0 0x80000>;
-			#xen,static-mem-address-cells = <0x1>;
-			#xen,static-mem-size-cells = <0x1>;
 			xen,static-mem = <0x30000000 0x20000000>;
 			direct-map;
 			...
xen/arch/arm/bootfdt.c +0 -5
index 9e1ea60094..59675f086b 100644
@@ -370,11 +370,6 @@ static int __init process_domain_node(const void *fdt, int node,
         /* No "xen,static-mem" present. */
         return 0;
 
-    address_cells = device_tree_get_u32(fdt, node,
-                                        "#xen,static-mem-address-cells", 0);
-    size_cells = device_tree_get_u32(fdt, node,
-                                     "#xen,static-mem-size-cells", 0);
-
     return device_tree_get_meminfo(fdt, node, "xen,static-mem", address_cells,
                                    size_cells, &bootinfo.reserved_mem,
                                    MEMBANK_STATIC_DOMAIN);
xen/arch/arm/domain_build.c +2 -14
index 7412303d20..9040a8c6cb 100644
@@ -565,21 +565,9 @@ static int __init parse_static_mem_prop(const struct dt_device_node *node,
     const struct dt_property *prop;
 
     prop = dt_find_property(node, "xen,static-mem", NULL);
-    if ( !dt_property_read_u32(node, "#xen,static-mem-address-cells",
-                               addr_cells) )
-    {
-        printk(XENLOG_ERR
-               "failed to read \"#xen,static-mem-address-cells\".\n");
-        return -EINVAL;
-    }
 
-    if ( !dt_property_read_u32(node, "#xen,static-mem-size-cells",
-                               size_cells) )
-    {
-        printk(XENLOG_ERR
-               "failed to read \"#xen,static-mem-size-cells\".\n");
-        return -EINVAL;
-    }
+    *addr_cells = dt_n_addr_cells(node);
+    *size_cells = dt_n_size_cells(node);
 
     *cell = (const __be32 *)prop->value;
     *length = prop->length;
Signature · 1 line
2.17.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 lines · Henry Wang

In order to keep consistency in the device tree binding, there is no need for static memory allocation feature to define a specific set of address and size cells for "xen,static-mem" property.

Therefore, this commit reuses the regular #{address,size}-cells for parsing the device tree "xen,static-mem" property. Update the documentation accordingly.

Quoted 5 lines

Also, take the chance to remove the unnecessary "#address-cells" and "#size-cells" in the domU1 node of the device tree to only emphasize the related part that the example is showing.

~Michal

Reviewed-by on v2 1/1
#2 lore raw
In reply to Henry Wang

Hi Henry,

Quoted 10 lines · Henry Wang

In order to keep consistency in the device tree binding, there is no need for static memory allocation feature to define a specific set of address and size cells for "xen,static-mem" property.

Therefore, this commit reuses the regular #{address,size}-cells for parsing the device tree "xen,static-mem" property. Update the documentation accordingly.

Quoted 5 lines

Also, take the chance to remove the unnecessary "#address-cells" and "#size-cells" in the domU1 node of the device tree to only emphasize the related part that the example is showing.

Cheers
Bertrand

Quoted 114 lines

---
Changes from v1 to v2:
- Remove the "----" addition, as it is unnecessary to this patch.
- Mention the removal of #address-cells and #size-cells in domU1 node in the commit message.
---

docs/misc/arm/device-tree/booting.txt | 11 +++++------
docs/misc/arm/passthrough-noiommu.txt |  7 +++----
xen/arch/arm/bootfdt.c                |  5 -----
xen/arch/arm/domain_build.c           | 16 ++--------------
4 files changed, 10 insertions(+), 29 deletions(-)
docs/misc/arm/device-tree/booting.txt +0 -0
index 5395a1077c..10caf4f1af 100644
@@ -350,8 +350,8 @@ areas are pre-defined by configuration using physical address ranges.
 

Memory can be statically allocated to a domain using the property "xen,static- mem" defined in the domain configuration. The number of cells for the address

docs/misc/arm/device-tree/booting.txt +2 -2
-and the size must be defined using respectively the properties
-"#xen,static-mem-address-cells" and "#xen,static-mem-size-cells".
+and the size must be defined respectively by the parent node properties
+"#address-cells" and "#size-cells".

The property 'memory' is still needed and should match the amount of memory given to the guest. Currently, it either comes from static memory or lets Xen

docs/misc/arm/device-tree/booting.txt +3 -4
@@ -366,14 +366,13 @@ device-tree:
 
    / {
        chosen {
+            #address-cells = <0x1>;
+            #size-cells = <0x1>;
+            ...
            domU1 {
                compatible = "xen,domain";
-                #address-cells = <0x2>;
-                #size-cells = <0x2>;
                cpus = <2>;
                memory = <0x0 0x80000>;
-                #xen,static-mem-address-cells = <0x1>;
-                #xen,static-mem-size-cells = <0x1>;
                xen,static-mem = <0x30000000 0x20000000>;
...
            };
docs/misc/arm/passthrough-noiommu.txt +3 -4
index 3e2ef21ad7..69b8de1975 100644
@@ -33,14 +33,13 @@ on static allocation in the device-tree:
 
 / {
 	chosen {
+		#address-cells = <0x1>;
+		#size-cells = <0x1>;
+		...
 		domU1 {
 			compatible = "xen,domain";
-			#address-cells = <0x2>;
-			#size-cells = <0x2>;
 			cpus = <2>;
 			memory = <0x0 0x80000>;
-			#xen,static-mem-address-cells = <0x1>;
-			#xen,static-mem-size-cells = <0x1>;
 			xen,static-mem = <0x30000000 0x20000000>;
 			direct-map;
...
xen/arch/arm/bootfdt.c +0 -5
index 9e1ea60094..59675f086b 100644
@@ -370,11 +370,6 @@ static int __init process_domain_node(const void *fdt, int node,
        /* No "xen,static-mem" present. */
        return 0;
 
-    address_cells = device_tree_get_u32(fdt, node,
-                                        "#xen,static-mem-address-cells", 0);
-    size_cells = device_tree_get_u32(fdt, node,
-                                     "#xen,static-mem-size-cells", 0);
-
    return device_tree_get_meminfo(fdt, node, "xen,static-mem", address_cells,
                                   size_cells, &bootinfo.reserved_mem,
                                   MEMBANK_STATIC_DOMAIN);
xen/arch/arm/domain_build.c +2 -14
index 7412303d20..9040a8c6cb 100644
@@ -565,21 +565,9 @@ static int __init parse_static_mem_prop(const struct dt_device_node *node,
    const struct dt_property *prop;
 
    prop = dt_find_property(node, "xen,static-mem", NULL);
-    if ( !dt_property_read_u32(node, "#xen,static-mem-address-cells",
-                               addr_cells) )
-    {
-        printk(XENLOG_ERR
-               "failed to read \"#xen,static-mem-address-cells\".\n");
-        return -EINVAL;
-    }
 
-    if ( !dt_property_read_u32(node, "#xen,static-mem-size-cells",
-                               size_cells) )
-    {
-        printk(XENLOG_ERR
-               "failed to read \"#xen,static-mem-size-cells\".\n");
-        return -EINVAL;
-    }
+    *addr_cells = dt_n_addr_cells(node);
+    *size_cells = dt_n_size_cells(node);
 
    *cell = (const __be32 *)prop->value;
    *length = prop->length;
Signature · 1 line
2.17.1
Acked-by on v2 1/1
#3 lore raw
In reply to Henry Wang
Quoted 8 lines · Henry Wang

In order to keep consistency in the device tree binding, there is no need for static memory allocation feature to define a specific set of address and size cells for "xen,static-mem" property.

Therefore, this commit reuses the regular #{address,size}-cells for parsing the device tree "xen,static-mem" property. Update the documentation accordingly.

Quoted 5 lines

Also, take the chance to remove the unnecessary "#address-cells" and "#size-cells" in the domU1 node of the device tree to only emphasize the related part that the example is showing.

Quoted 114 lines

---
Changes from v1 to v2:
- Remove the "----" addition, as it is unnecessary to this patch.
- Mention the removal of #address-cells and #size-cells in domU1 node in the commit message.

---
 docs/misc/arm/device-tree/booting.txt | 11 +++++------
 docs/misc/arm/passthrough-noiommu.txt |  7 +++----
 xen/arch/arm/bootfdt.c                |  5 -----
 xen/arch/arm/domain_build.c           | 16 ++--------------
 4 files changed, 10 insertions(+), 29 deletions(-)
docs/misc/arm/device-tree/booting.txt +5 -6
index 5395a1077c..10caf4f1af 100644
@@ -350,8 +350,8 @@ areas are pre-defined by configuration using physical address ranges.
 
 Memory can be statically allocated to a domain using the property "xen,static-
 mem" defined in the domain configuration. The number of cells for the address
-and the size must be defined using respectively the properties
-"#xen,static-mem-address-cells" and "#xen,static-mem-size-cells".
+and the size must be defined respectively by the parent node properties
+"#address-cells" and "#size-cells".
 
 The property 'memory' is still needed and should match the amount of memory
 given to the guest. Currently, it either comes from static memory or lets Xen
@@ -366,14 +366,13 @@ device-tree:
 
     / {
         chosen {
+            #address-cells = <0x1>;
+            #size-cells = <0x1>;
+            ...
             domU1 {
                 compatible = "xen,domain";
-                #address-cells = <0x2>;
-                #size-cells = <0x2>;
                 cpus = <2>;
                 memory = <0x0 0x80000>;
-                #xen,static-mem-address-cells = <0x1>;
-                #xen,static-mem-size-cells = <0x1>;
                 xen,static-mem = <0x30000000 0x20000000>;
...
             };
docs/misc/arm/passthrough-noiommu.txt +3 -4
index 3e2ef21ad7..69b8de1975 100644
@@ -33,14 +33,13 @@ on static allocation in the device-tree:
 
 / {
 	chosen {
+		#address-cells = <0x1>;
+		#size-cells = <0x1>;
+		...
 		domU1 {
 			compatible = "xen,domain";
-			#address-cells = <0x2>;
-			#size-cells = <0x2>;
 			cpus = <2>;
 			memory = <0x0 0x80000>;
-			#xen,static-mem-address-cells = <0x1>;
-			#xen,static-mem-size-cells = <0x1>;
 			xen,static-mem = <0x30000000 0x20000000>;
 			direct-map;
...
xen/arch/arm/bootfdt.c +0 -5
index 9e1ea60094..59675f086b 100644
@@ -370,11 +370,6 @@ static int __init process_domain_node(const void *fdt, int node,
         /* No "xen,static-mem" present. */
         return 0;
 
-    address_cells = device_tree_get_u32(fdt, node,
-                                        "#xen,static-mem-address-cells", 0);
-    size_cells = device_tree_get_u32(fdt, node,
-                                     "#xen,static-mem-size-cells", 0);
-
     return device_tree_get_meminfo(fdt, node, "xen,static-mem", address_cells,
                                    size_cells, &bootinfo.reserved_mem,
                                    MEMBANK_STATIC_DOMAIN);
xen/arch/arm/domain_build.c +2 -14
index 7412303d20..9040a8c6cb 100644
@@ -565,21 +565,9 @@ static int __init parse_static_mem_prop(const struct dt_device_node *node,
     const struct dt_property *prop;
 
     prop = dt_find_property(node, "xen,static-mem", NULL);
-    if ( !dt_property_read_u32(node, "#xen,static-mem-address-cells",
-                               addr_cells) )
-    {
-        printk(XENLOG_ERR
-               "failed to read \"#xen,static-mem-address-cells\".\n");
-        return -EINVAL;
-    }
 
-    if ( !dt_property_read_u32(node, "#xen,static-mem-size-cells",
-                               size_cells) )
-    {
-        printk(XENLOG_ERR
-               "failed to read \"#xen,static-mem-size-cells\".\n");
-        return -EINVAL;
-    }
+    *addr_cells = dt_n_addr_cells(node);
+    *size_cells = dt_n_size_cells(node);
 
     *cell = (const __be32 *)prop->value;
     *length = prop->length;
Signature · 1 line
2.17.1