xen/arm, device-tree: Make static-mem use #{address,size}-cells
PATCH 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.
--- docs/misc/arm/device-tree/booting.txt | 13 ++++++------- docs/misc/arm/passthrough-noiommu.txt | 7 +++---- xen/arch/arm/bootfdt.c | 5 ----- xen/arch/arm/domain_build.c | 16 ++-------------- 4 files changed, 11 insertions(+), 30 deletions(-)
docs/misc/arm/device-tree/booting.txt +6 -7
@@ -339,15 +339,15 @@ kernel will be able to discover the device. Static Allocation -============= +================= Static Allocation refers to system or sub-system(domains) for which memory 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
@@ -362,14 +362,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
@@ -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
@@ -352,11 +352,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, true); }
xen/arch/arm/domain_build.c +2 -14
@@ -563,21 +563,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
Hi Henry,
Quoted 41 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.
Signed-off-by Henry Wang <[email protected]>--- docs/misc/arm/device-tree/booting.txt | 13 ++++++------- docs/misc/arm/passthrough-noiommu.txt | 7 +++---- xen/arch/arm/bootfdt.c | 5 ----- xen/arch/arm/domain_build.c | 16 ++-------------- 4 files changed, 11 insertions(+), 30 deletions(-)docs/misc/arm/device-tree/booting.txt +3
-3@@ -339,15 +339,15 @@ kernel will be able to discover the device. Static Allocation -============= +================= Static Allocation refers to system or sub-system(domains) for which memory 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
docs/misc/arm/device-tree/booting.txt device-tree: · line 368
Quoted 10 lines
docs/misc/arm/device-tree/booting.txt +3
-2@@ -362,14 +362,13 @@ device-tree: / { chosen { + #address-cells = <0x1>; + #size-cells = <0x1>; + ... domU1 { compatible = "xen,domain"; - #address-cells = <0x2>; - #size-cells = <0x2>;
Why did you remove this set if it relates to the childs of domU1 (e.g. kernel, ramdisk) and not to domU1 itself?
Quoted 12 lines
docs/misc/arm/device-tree/booting.txt +0
-2cpus = <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 +0
-0
docs/misc/arm/passthrough-noiommu.txt on static allocation in the device-tree: · line 39
Quoted 10 lines
docs/misc/arm/passthrough-noiommu.txt +3
-2@@ -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>;
The same here.
Quoted 38 lines
docs/misc/arm/passthrough-noiommu.txt +0
-2cpus = <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@@ -352,11 +352,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, true); }xen/arch/arm/domain_build.c +0
-7@@ -563,21 +563,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 ; - }
xen/arch/arm/domain_build.c static int __init parse_static_mem_prop(const struct dt_device_node *node, · line 568
Quoted 10 lines
xen/arch/arm/domain_build.c +2
-7-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);
There is a type mismatch here as e.g. addr_cells is u32 and dt_n_addr_cells return type is int. But I don't think this can be harmful and also it's strange for me that dt_n_addr_cells is defined to return int given that it either returns 2 or be32_to_cpup, which means it should return u32.
Quoted 7 lines
xen/arch/arm/domain_build.c +0
-1*cell = (const __be32 *)prop->value; *length = prop->length; --2.17.1
Apart from that:
~Michal
Hi Michal,
Thank you very much for your review, as always :))
Quoted 4 lines
-----Original Message-----
From: Michal Orzel <[email protected]>Quoted 2 lines
(quoted diff) +0
-0@@ -362,14 +362,13 @@ device-tree:
Quoted 11 lines
docs/misc/arm/device-tree/booting.txt device-tree: · line 368
Quoted 9 lines
docs/misc/arm/device-tree/booting.txt +3
-2/ { chosen { + #address-cells = <0x1>; + #size-cells = <0x1>; + ... domU1 { compatible = "xen,domain"; - #address-cells = <0x2>; - #size-cells = <0x2>;Why did you remove this set if it relates to the childs of domU1 (e.g. kernel, ramdisk) and not to domU1 itself?
Well, I think here the example is just how we setup the static memory, so we just want to emphasize the related part. I agree users can add another #address-cells and #size-cells for domU1 node for the parts that you mentioned, but that is not reflected by the current example (I can't find anything related to kernel, ramdisk, etc. in current example). I might get it wrong but having two #address-cells and #size-cells in that case would be quite misleading from my understanding. So I decided to remove it.
But I am open to other opinions. So shall we let the discussion go on for a bit longer? I will revert this change if most people think this removing is unnecessary.
Quoted 15 lines
Review
Quoted 9 lines
docs/misc/arm/device-tree/booting.txt +0
-2cpus = <2>; memory = <0x0 0x80000>; - #xen,static-mem-address-cells = <0x1>; - #xen,static-mem-size-cells = <0x1>; xen,static-mem = <0x30000000 0x20000000>; };(quoted diff) +0
-0
b/docs/misc/arm/passthrough-noiommu.txtQuoted 5 lines
index
3e2ef21ad7..69b8de1975100644docs/misc/arm/passthrough-noiommu.txt +0
-0@@ -33,14 +33,13 @@ on static allocation in the device-tree:
Quoted 10 lines
docs/misc/arm/passthrough-noiommu.txt on static allocation in the device-tree: · line 39
Quoted 9 lines
docs/misc/arm/passthrough-noiommu.txt +3
-2/ { chosen { + #address-cells = <0x1>; + #size-cells = <0x1>; + ... domU1 { compatible = "xen,domain"; - #address-cells = <0x2>; - #size-cells = <0x2>;The same here.
Same as above.
Quoted 52 lines
xen/arch/arm/bootfdt.c static int __init process_domain_node(const void
Quoted 13 lines
docs/misc/arm/passthrough-noiommu.txt +0
-2cpus = <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
-0@@ -352,11 +352,6 @@ static int __init process_domain_node(const void*fdt, int node,
xen/arch/arm/bootfdt.c static int __init process_domain_node(const void *fdt, int node,
Quoted 9 lines
xen/arch/arm/bootfdt.c +0
-5/* 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,xen/arch/arm/domain_build.c static int __init parse_static_mem_prop(const
Quoted 7 lines
xen/arch/arm/bootfdt.c +0
-0size_cells, &bootinfo.reserved_mem, true); }xen/arch/arm/domain_build.c +0
-0@@ -563,21 +563,9 @@ static int __init parse_static_mem_prop(conststruct
dt_device_node*node,Quoted 10 lines
xen/arch/arm/domain_build.c +0
-7const 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 ; - }xen/arch/arm/domain_build.c static int __init parse_static_mem_prop(const struct dt_device_node *node, · line 568
Quoted 10 lines
xen/arch/arm/domain_build.c +2
-7-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);
Quoted 6 lines
There is a type mismatch here as e.g.
addr_cellsis u32 anddt_n_addr_cellsreturn type is int.
But I don't think this can be harmful and also it's strange for me thatdt_n_addr_cells
is defined to return int given that it either returns 2 orbe32_to_cpup, which means it should return u32.
Yeah. I agree. I did a git blame here and found this function is introduced 9 years ago in "dbd1243 xen/arm: Add helpers to use the device tree". So I think probably it would be easier to ask the author for the following action directly :))
@Julien, what do you think? Shall we modify the return type of these two functions?
Quoted 10 lines
Quoted 8 lines
xen/arch/arm/domain_build.c +0
-1*cell = (const __be32 *)prop->value; *length = prop->length; --2.17.1
Apart from that:
Reviewed-by Michal Orzel <[email protected]>
Thanks!
Kind regards,
Henry
Quoted 2 lines
~Michal
Hi,
Quoted 16 lines · Henry Wang
Quoted 4 lines
-----Original Message-----
From: Michal Orzel <[email protected]>Quoted 2 lines
(quoted diff) +0
-0@@ -362,14 +362,13 @@ device-tree:Quoted 11 lines
docs/misc/arm/device-tree/booting.txt device-tree: · line 368
Quoted 9 lines
docs/misc/arm/device-tree/booting.txt +3
-2/ { chosen { + #address-cells = <0x1>; + #size-cells = <0x1>; + ... domU1 { compatible = "xen,domain"; - #address-cells = <0x2>; - #size-cells = <0x2>;Why did you remove this set if it relates to the childs of domU1 (e.g. kernel, ramdisk) and not to domU1 itself?
Quoted 6 lines
Well, I think here the example is just how we setup the static memory, so we just want to emphasize the related part. I agree users can add another #address-cells and #size-cells for domU1 node for the parts that you mentioned, but that is not reflected by the current example (I can't find anything related to kernel, ramdisk, etc. in current example). I might get it wrong but having two #address-cells and #size-cells in that case would be quite misleading from my understanding.
I agree with that. As this is only a small part of the DT we want to focus on what is necessary for the current section.
Quoted 1 line
So I decided to remove it.
I would mention it in the commit message because the change seems unrelated otherwise.
The same apply for replacing adding extra "====". But TBH, this change feels completely unrelated to this patch. So I think it is better to have a separate patch.
[...]
Quoted 51 lines
Quoted 44 lines
xen/arch/arm/bootfdt.c static int __init process_domain_node(const void
Quoted 5 lines
xen/arch/arm/bootfdt.c +0
-0@@ -352,11 +352,6 @@ static int __init process_domain_node(const void*fdt, int node,
xen/arch/arm/bootfdt.c static int __init process_domain_node(const void *fdt, int node,
Quoted 9 lines
xen/arch/arm/bootfdt.c +0
-5/* 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,xen/arch/arm/domain_build.c static int __init parse_static_mem_prop(const
Quoted 7 lines
xen/arch/arm/bootfdt.c +0
-0size_cells, &bootinfo.reserved_mem, true); }xen/arch/arm/domain_build.c +0
-0@@ -563,21 +563,9 @@ static int __init parse_static_mem_prop(conststruct
dt_device_node*node,Quoted 10 lines
xen/arch/arm/domain_build.c +0
-7const 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 ; - }xen/arch/arm/domain_build.c static int __init parse_static_mem_prop(const struct dt_device_node *node, · line 568
Quoted 10 lines
xen/arch/arm/domain_build.c +2
-7-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);Quoted 6 lines
There is a type mismatch here as e.g.
addr_cellsis u32 anddt_n_addr_cellsreturn type is int.
But I don't think this can be harmful and also it's strange for me thatdt_n_addr_cells
is defined to return int given that it either returns 2 orbe32_to_cpup, which means it should return u32.
Quoted 3 lines
Yeah. I agree. I did a git blame here and found this function is introduced 9 years ago in "dbd1243 xen/arm: Add helpers to use the device tree". So I think probably it would be easier to ask the author for the following action directly :))
The code was imported from Linux where it seems to be more common to use "int" rather than "unsigned".
Quoted 3 lines
@Julien, what do you think? Shall we modify the return type of these two functions?
I think it would be good to be consistent. However, there are other users of d_n_addr_cells() (some are expecting 'int'). So if you switch to a different type then this use will be consistent but not the others.
I would only suggest to look at it if you have if you have copious time and fancy going down the rabbit hole :).
As to which type to chose, we are phasing out use of uXX in new code. So this should be 'uint32_t'. I would also be fine to use 'unsigned int' for the outside interface.
I don't have a strong opinion either way.
Cheers,
Signature · 1 line
Julien Grall
Hi Julien and Michal,
Quoted 27 lines
-----Original Message-----
From: Julien Grall <[email protected]>Quoted 10 lines
Quoted 10 lines
docs/misc/arm/device-tree/booting.txt device-tree: · line 368
Quoted 9 lines
/ { chosen {docs/misc/arm/device-tree/booting.txt +3
-2+ #address-cells = <0x1>; + #size-cells = <0x1>; + ... domU1 { compatible = "xen,domain"; - #address-cells = <0x2>; - #size-cells = <0x2>;Why did you remove this set if it relates to the childs of domU1 (e.g.
kernel,
Quoted 3 lines
Quoted 1 line
ramdisk) and not to domU1 itself?
Well, I think here the example is just how we setup the static memory, so
we just
Quoted 1 line
want to emphasize the related part. I agree users can add another
#address-cells
Quoted 1 line
and #size-cells for domU1 node for the parts that you mentioned, but that
is
Quoted 2 lines
not reflected by the current example (I can't find anything related to kernel, ramdisk, etc. in current example). I might get it wrong but having two
#address-cells
Quoted 1 line
and #size-cells in that case would be quite misleading from my
understanding.
Quoted 7 lines
I agree with that. As this is only a small part of the DT we want to focus on what is necessary for the current section.
Quoted 1 line
So I decided to remove it.
I would mention it in the commit message because the change seems unrelated otherwise.
Sure.
Quoted 4 lines
The same apply for replacing adding extra "====". But TBH, this change feels completely unrelated to this patch. So I think it is better to have a separate patch.
I would revert this change for "====", as sending a patch adding "====" seems to not make too much sense.....
Quoted 76 lines
[...]
Quoted 5 lines
Quoted 5 lines
xen/arch/arm/bootfdt.c static int __init process_domain_node(const
Quoted 5 lines
xen/arch/arm/bootfdt.c +0
-0@@ -352,11 +352,6 @@ static int __init process_domain_node(constvoid
Quoted 10 lines
Quoted 10 lines
*fdt, int node,
Quoted 9 lines
xen/arch/arm/bootfdt.c +0
-5/* 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",Quoted 4 lines
Quoted 4 lines
address_cells,Review
Quoted 3 lines
xen/arch/arm/bootfdt.c +0
-0size_cells, &bootinfo.reserved_mem, true); }(quoted diff) +0
-0
b/xen/arch/arm/domain_build.cQuoted 25 lines
Quoted 25 lines
xen/arch/arm/domain_build.c static int __init parse_static_mem_prop(const
Quoted 4 lines
index
b76a84e8f5..258d74699d100644xen/arch/arm/domain_build.c +0
-0@@ -563,21 +563,9 @@ static int __init parse_static_mem_prop(conststruct
dt_device_node*node,Quoted 20 lines
xen/arch/arm/domain_build.c +2
-14const 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);Quoted 1 line
Quoted 1 line
There is a type mismatch here as e.g.
addr_cellsis u32 and
dt_n_addr_cellsQuoted 4 lines
Quoted 4 lines
return type is int.
But I don't think this can be harmful and also it's strange for me thatdt_n_addr_cells
is defined to return int given that it either returns 2 orbe32_to_cpup,which
Quoted 4 lines
Quoted 1 line
means it should return u32.
Yeah. I agree. I did a git blame here and found this function is introduced 9 years ago in "dbd1243 xen/arm: Add helpers to use the device tree". So I
think
Quoted 1 line
probably it would be easier to ask the author for the following action
directly :))
The code was imported from Linux where it seems to be more common to use
"int" rather than "unsigned".Quoted 3 lines
@Julien, what do you think? Shall we modify the return type of these two functions?
I think it would be good to be consistent. However, there are other users of
d_n_addr_cells()(some are expecting 'int'). So if you switch to a different type then this use will be consistent but not the others.
Quoted 8 lines
I would only suggest to look at it if you have if you have copious time and fancy going down the rabbit hole :).
As to which type to chose, we are phasing out use of uXX in new code. So this should be '
uint32_t'. I would also be fine to use 'unsigned int' for the outside interface.I don't have a strong opinion either way.
I personally would like to keep the current way, changing the type to me sounds like out of scope with this patch and will bring us the risk of breaking other places.
So I will address the commit message and "====" changes and send a v2.
Kind regards,
Henry
Quoted 5 lines
Cheers,
--
Julien Grall