Honor FDT status property
v4 cover Honor FDT status property
This series introduces a new function to check for the "status" property in the FDT nodes and uses it to ignore CPU nodes that are disabled.
Changes in v4:
- Rename fdt_parse_max_hart_id to fdt_parse_max_enabled_hart_id
- Assign correct Reviewed-by: tags
Changes in v3:
- Don't check the property in PLIC/IMSIC/ACLINT drivers
- Start writing this changelog
Changes in v2:
- Implement the functionality separately from fdt_parse_hart_id
- Turn patch into proper series
Jan Remes (4):
lib: utils/fdt: introduce fdt_node_is_enabled()
lib: utils: check if CPU node is enabled
platform: generic: check if CPU node is enabled
lib: utils/fdt: rename fdt_parse_max_hart_id
include/sbi_utils/fdt/fdt_helper.h | 4 +++- lib/utils/fdt/fdt_domain.c | 14 +++++++++++++- lib/utils/fdt/fdt_fixup.c | 3 +++ lib/utils/fdt/fdt_helper.c | 23 ++++++++++++++++++++++- platform/generic/platform.c | 3 +++ 5 files changed, 44 insertions(+), 3 deletions(-)
Signature · 1 line
2.36.1
PATCH v4 1/4 lib: utils/fdt: introduce fdt_node_is_enabled()
If an FDT node contains a "status" property and this property is not "ok" or "okay", this node should be ignored. Introduce a function that checks this.
--- include/sbi_utils/fdt/fdt_helper.h | 2 ++ lib/utils/fdt/fdt_helper.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+)
include/sbi_utils/fdt/fdt_helper.h +2 -0
@@ -48,6 +48,8 @@ int fdt_parse_phandle_with_args(void *fdt, int nodeoff,int fdt_get_node_addr_size (void *fdt,int node,int index,uint64_t *addr,uint64_t *size); +bool fdt_node_is_enabled (void *fdt,int nodeoff); +int fdt_parse_hart_id (void *fdt,int cpu_offset,u32 *hartid);int fdt_parse_max_hart_id (void *fdt,u32 *max_hartid);
lib/utils/fdt/fdt_helper.c +18 -0
@@ -216,6 +216,24 @@ int fdt_get_node_addr_size(void *fdt, int node, int index,return 0 ; } +bool fdt_node_is_enabled (void *fdt,int nodeoff) +{ +int len; +const void *prop; + + prop =fdt_getprop (fdt, nodeoff,"status" , &len); +if (!prop) +return true; + +if (!strncmp (prop,"okay" ,strlen ("okay" ))) +return true; + +if (!strncmp (prop,"ok" ,strlen ("ok" ))) +return true; + +return false; +} +int fdt_parse_hart_id (void *fdt,int cpu_offset,u32 *hartid) {int len;
Signature · 1 line
2.36.1
Anup Patel
AppliedPATCH v4 1/4 lib: utils/fdt: introduce fdt_node_is_enabled()
Quoted 8 lines · Jan Remes
If an FDT node contains a "status" property and this property is not "ok" or "okay", this node should be ignored. Introduce a function that checks this.
Signed-off-by Jan Remes <[email protected]>Reviewed-by Xiang W <[email protected]>Reviewed-by Anup Patel <[email protected]>
Applied this patch to the riscv/opensbi repo.
Thanks,
Anup
Quoted 50 lines
--- include/sbi_utils/fdt/fdt_helper.h | 2 ++ lib/utils/fdt/fdt_helper.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+)include/sbi_utils/fdt/fdt_helper.h +2
-0@@ -48,6 +48,8 @@ int fdt_parse_phandle_with_args(void *fdt, int nodeoff,int fdt_get_node_addr_size (void *fdt,int node,int index,uint64_t *addr,uint64_t *size); +bool fdt_node_is_enabled (void *fdt,int nodeoff); +int fdt_parse_hart_id (void *fdt,int cpu_offset,u32 *hartid);int fdt_parse_max_hart_id (void *fdt,u32 *max_hartid);lib/utils/fdt/fdt_helper.c +18
-1@@ -216,6 +216,24 @@ int fdt_get_node_addr_size(void *fdt, int node, int index,return 0 ; } +bool fdt_node_is_enabled (void *fdt,int nodeoff) +{ +int len; +const void *prop; + + prop =fdt_getprop (fdt, nodeoff,"status" , &len); +if (!prop) +return true; + +if (!strncmp (prop,"okay" ,strlen ("okay" ))) +return true; + +if (!strncmp (prop,"ok" ,strlen ("ok" ))) +return true; + +return false; +} +int fdt_parse_hart_id (void *fdt,int cpu_offset,u32 *hartid) {int len; --2.36.1
PATCH v4 2/4 lib: utils: check if CPU node is enabled
In reply to Jan RemesIgnore CPU nodes in FDT that are not enabled.
--- lib/utils/fdt/fdt_domain.c | 14 +++++++++++++- lib/utils/fdt/fdt_fixup.c | 3 +++ lib/utils/fdt/fdt_helper.c | 3 +++ 3 files changed, 19 insertions(+), 1 deletion(-)
lib/utils/fdt/fdt_domain.c +13 -1
@@ -165,6 +165,9 @@ void fdt_domain_fixup(void *fdt)if (err)continue ; +if (!fdt_node_is_enabled (fdt, doffset)) +continue ; +fdt_nop_property (fdt, doffset,"opensbi-domain" ); }
@@ -308,6 +311,9 @@ static int __fdt_parse_domain(void *fdt, int domain_offset, void *opaque)if (err)return err; +if (!fdt_node_is_enabled (fdt, cpu_offset)) +continue ; +sbi_hartmask_set_hart (val32, mask); } }
@@ -347,7 +353,7 @@ static int __fdt_parse_domain(void *fdt, int domain_offset, void *opaque)if (val && len >=4 ) { cpu_offset =fdt_node_offset_by_phandle (fdt,fdt32_to_cpu (*val)); -if (cpu_offset >=0 ) +if (cpu_offset >=0 &&fdt_node_is_enabled (fdt, cpu_offset))fdt_parse_hart_id (fdt, cpu_offset, &val32); }else {if (domain_offset == *cold_domain_offset)
@@ -414,6 +420,9 @@ static int __fdt_parse_domain(void *fdt, int domain_offset, void *opaque)if (SBI_HARTMASK_MAX_BITS <= val32)continue ; +if (!fdt_node_is_enabled (fdt, cpu_offset)) +continue ; + val =fdt_getprop (fdt, cpu_offset,"opensbi-domain" , &len);if (!val || len <4 )return SBI_EINVAL ;
@@ -460,6 +469,9 @@ int fdt_domains_populate(void *fdt)if (hartid != cold_hartid)continue ; +if (!fdt_node_is_enabled (fdt, cpu_offset)) +continue ; + val =fdt_getprop (fdt, cpu_offset,"opensbi-domain" , &len);if (val && len >=4 ) cold_domain_offset = fdt_node_offset_by_phandle(fdt,
lib/utils/fdt/fdt_fixup.c +3 -0
@@ -38,6 +38,9 @@ void fdt_cpu_fixup(void *fdt)if (err)continue ; +if (!fdt_node_is_enabled (fdt, cpu_offset)) +continue ; +/* * Disable a HART DT node if one of the following is true: * 1. The HART is not assigned to the current domain
lib/utils/fdt/fdt_helper.c +3 -0
@@ -283,6 +283,9 @@ int fdt_parse_max_hart_id(void *fdt, u32 *max_hartid)if (err)continue ; +if (!fdt_node_is_enabled (fdt, cpu_offset)) +continue ; +if (hartid > *max_hartid) *max_hartid = hartid; }
Signature · 1 line
2.36.1
Anup Patel
AppliedPATCH v4 2/4 lib: utils: check if CPU node is enabled
Quoted 5 lines · Jan Remes
Ignore CPU nodes in FDT that are not enabled.
Signed-off-by Jan Remes <[email protected]>Reviewed-by Anup Patel <[email protected]>
Applied this patch to the riscv/opensbi repo.
Thanks,
Anup
Quoted 90 lines
--- lib/utils/fdt/fdt_domain.c | 14 +++++++++++++- lib/utils/fdt/fdt_fixup.c | 3 +++ lib/utils/fdt/fdt_helper.c | 3 +++ 3 files changed, 19 insertions(+), 1 deletion(-)lib/utils/fdt/fdt_domain.c +13
-1@@ -165,6 +165,9 @@ void fdt_domain_fixup(void *fdt)if (err)continue ; +if (!fdt_node_is_enabled (fdt, doffset)) +continue ; +fdt_nop_property (fdt, doffset,"opensbi-domain" ); }@@ -308,6 +311,9 @@ static int __fdt_parse_domain(void *fdt, int domain_offset, void *opaque)if (err)return err; +if (!fdt_node_is_enabled (fdt, cpu_offset)) +continue ; +sbi_hartmask_set_hart (val32, mask); } }@@ -347,7 +353,7 @@ static int __fdt_parse_domain(void *fdt, int domain_offset, void *opaque)if (val && len >=4 ) { cpu_offset =fdt_node_offset_by_phandle (fdt,fdt32_to_cpu (*val)); -if (cpu_offset >=0 ) +if (cpu_offset >=0 &&fdt_node_is_enabled (fdt, cpu_offset))fdt_parse_hart_id (fdt, cpu_offset, &val32); }else {if (domain_offset == *cold_domain_offset)@@ -414,6 +420,9 @@ static int __fdt_parse_domain(void *fdt, int domain_offset, void *opaque)if (SBI_HARTMASK_MAX_BITS <= val32)continue ; +if (!fdt_node_is_enabled (fdt, cpu_offset)) +continue ; + val =fdt_getprop (fdt, cpu_offset,"opensbi-domain" , &len);if (!val || len <4 )return SBI_EINVAL ;@@ -460,6 +469,9 @@ int fdt_domains_populate(void *fdt)if (hartid != cold_hartid)continue ; +if (!fdt_node_is_enabled (fdt, cpu_offset)) +continue ; + val =fdt_getprop (fdt, cpu_offset,"opensbi-domain" , &len);if (val && len >=4 ) cold_domain_offset = fdt_node_offset_by_phandle(fdt,lib/utils/fdt/fdt_fixup.c +3
-0@@ -38,6 +38,9 @@ void fdt_cpu_fixup(void *fdt)if (err)continue ; +if (!fdt_node_is_enabled (fdt, cpu_offset)) +continue ; +/* * Disable a HART DT node if one of the following is true: * 1. The HART is not assigned to the current domain lib/utils/fdt/fdt_helper.c +3
-1@@ -283,6 +283,9 @@ int fdt_parse_max_hart_id(void *fdt, u32 *max_hartid)if (err)continue ; +if (!fdt_node_is_enabled (fdt, cpu_offset)) +continue ; +if (hartid > *max_hartid) *max_hartid = hartid; } --2.36.1
PATCH v4 3/4 platform: generic: check if CPU node is enabled
In reply to Jan RemesIgnore CPU nodes in FDT which are not enabled.
--- platform/generic/platform.c | 3 +++ 1 file changed, 3 insertions(+)
platform/generic/platform.c +3 -0
@@ -107,6 +107,9 @@ unsigned long fw_platform_init(unsigned long arg0, unsigned long arg1,if (SBI_HARTMASK_MAX_BITS <= hartid)continue ; +if (!fdt_node_is_enabled (fdt, cpu_offset)) +continue ; + generic_hart_index2id[hart_count++] = hartid; }
Signature · 1 line
2.36.1
Anup Patel
AppliedPATCH v4 3/4 platform: generic: check if CPU node is enabled
Quoted 6 lines · Jan Remes
Ignore CPU nodes in FDT which are not enabled.
Signed-off-by Jan Remes <[email protected]>Reviewed-by Xiang W <[email protected]>Reviewed-by Anup Patel <[email protected]>
Applied this patch to the riscv/opensbi repo.
Thanks,
Anup
Quoted 21 lines
--- platform/generic/platform.c | 3 +++ 1 file changed, 3 insertions(+)platform/generic/platform.c +3
-1@@ -107,6 +107,9 @@ unsigned long fw_platform_init(unsigned long arg0, unsigned long arg1,if (SBI_HARTMASK_MAX_BITS <= hartid)continue ; +if (!fdt_node_is_enabled (fdt, cpu_offset)) +continue ; + generic_hart_index2id[hart_count++] = hartid; } --2.36.1
PATCH v4 4/4 lib: utils/fdt: rename fdt_parse_max_hart_id
In reply to Jan RemesThe function returns the highest hart-id of the harts actually used in the system (enabled). Change the name to reflect this fact.
--- include/sbi_utils/fdt/fdt_helper.h | 2 +- lib/utils/fdt/fdt_helper.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/sbi_utils/fdt/fdt_helper.h +1 -1
@@ -52,7 +52,7 @@ bool fdt_node_is_enabled(void *fdt, int nodeoff);int fdt_parse_hart_id (void *fdt,int cpu_offset,u32 *hartid); -int fdt_parse_max_hart_id (void *fdt,u32 *max_hartid); +int fdt_parse_max_enabled_hart_id (void *fdt,u32 *max_hartid);int fdt_parse_timebase_frequency (void *fdt,unsigned long *freq);
lib/utils/fdt/fdt_helper.c +1 -1
@@ -262,7 +262,7 @@ int fdt_parse_hart_id(void *fdt, int cpu_offset, u32 *hartid)return 0 ; } -int fdt_parse_max_hart_id (void *fdt,u32 *max_hartid) +int fdt_parse_max_enabled_hart_id (void *fdt,u32 *max_hartid) {u32 hartid;int err, cpu_offset, cpus_offset;
Signature · 1 line
2.36.1
PATCH v4 4/4 lib: utils/fdt: rename fdt_parse_max_hart_id
Quoted 5 lines · Jan Remes
The function returns the highest hart-id of the harts actually used in the system (enabled). Change the name to reflect this fact.
Signed-off-by Jan Remes <[email protected]>
Looks good to me.
Regards,
Anup
Quoted 39 lines
--- include/sbi_utils/fdt/fdt_helper.h | 2 +- lib/utils/fdt/fdt_helper.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)include/sbi_utils/fdt/fdt_helper.h +1
-1@@ -52,7 +52,7 @@ bool fdt_node_is_enabled(void *fdt, int nodeoff);int fdt_parse_hart_id (void *fdt,int cpu_offset,u32 *hartid); -int fdt_parse_max_hart_id (void *fdt,u32 *max_hartid); +int fdt_parse_max_enabled_hart_id (void *fdt,u32 *max_hartid);int fdt_parse_timebase_frequency (void *fdt,unsigned long *freq);lib/utils/fdt/fdt_helper.c +1
-2@@ -262,7 +262,7 @@ int fdt_parse_hart_id(void *fdt, int cpu_offset, u32 *hartid)return 0 ; } -int fdt_parse_max_hart_id (void *fdt,u32 *max_hartid) +int fdt_parse_max_enabled_hart_id (void *fdt,u32 *max_hartid) {u32 hartid;int err, cpu_offset, cpus_offset; --2.36.1
--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
Anup Patel
AppliedPATCH v4 4/4 lib: utils/fdt: rename fdt_parse_max_hart_id
Quoted 11 lines · Anup Patel
Quoted 5 lines · Jan Remes
The function returns the highest hart-id of the harts actually used in the system (enabled). Change the name to reflect this fact.
Signed-off-by Jan Remes <[email protected]>Looks good to me.
Reviewed-by Anup Patel <[email protected]>
Applied this patch to the riscv/opensbi repo.
Thanks,
Anup
Quoted 43 lines
Regards,
AnupQuoted 39 lines
--- include/sbi_utils/fdt/fdt_helper.h | 2 +- lib/utils/fdt/fdt_helper.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)include/sbi_utils/fdt/fdt_helper.h +1
-1@@ -52,7 +52,7 @@ bool fdt_node_is_enabled(void *fdt, int nodeoff);int fdt_parse_hart_id (void *fdt,int cpu_offset,u32 *hartid); -int fdt_parse_max_hart_id (void *fdt,u32 *max_hartid); +int fdt_parse_max_enabled_hart_id (void *fdt,u32 *max_hartid);int fdt_parse_timebase_frequency (void *fdt,unsigned long *freq);lib/utils/fdt/fdt_helper.c +1
-2@@ -262,7 +262,7 @@ int fdt_parse_hart_id(void *fdt, int cpu_offset, u32 *hartid)return 0 ; } -int fdt_parse_max_hart_id (void *fdt,u32 *max_hartid) +int fdt_parse_max_enabled_hart_id (void *fdt,u32 *max_hartid) {u32 hartid;int err, cpu_offset, cpus_offset; --2.36.1
--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi