ARM: kernel: DT cpu map validity check helper function
PATCH 1/1 ARM: kernel: DT cpu map validity check helper function
Since the introduction of /cpu nodes bindings for ARM and the corresponding parse function arm_dt_init_cpu_maps(), the cpu_logical_map and the number of possible CPUs are set according to the DT /cpu nodes entries. Currently most of the existing ARM SMP platforms detect the number of cores through HW probing in their .smp_init_cpus functions and set the possible CPU mask accordingly.
This method should be upgraded so that the CPU counting mechanism will be based on DT, keeping legacy HW probing mechanism as a fall back solution.
In order to implement this fall back solution mechanism, the ARM DT code should provide a helper function to platforms to check if the cpu map has been properly initialized through DT. If the check fails the platform will resort to legacy HW based cores counting mechanism.
This patch implements a trivial flag and a helper function that platform can call to check whether DT based cpu map initialization and cores count were completed successfully.
--- arch/arm/include/asm/prom.h | 10 ++++++++++ arch/arm/kernel/devtree.c | 5 +++++ 2 files changed, 15 insertions(+)
arch/arm/include/asm/prom.h +10 -0
@@ -18,6 +18,15 @@extern struct machine_desc *setup_machine_fdt (unsigned int dt_phys);extern void arm_dt_memblock_reserve (void );extern void __init arm_dt_init_cpu_maps (void ); +/* +* Return true if cpu map initialization has been +* carried out correctly from DT +*/ +static inline bool __init arm_dt_cpu_map_valid (void ) +{ +extern bool valid_dt_cpu_map; +return valid_dt_cpu_map; +}#else /* CONFIG_OF */
@@ -28,6 +37,7 @@ static inline struct machine_desc *setup_machine_fdt(unsigned int dt_phys)static inline void arm_dt_memblock_reserve (void ) { }static inline void arm_dt_init_cpu_maps (void ) { } +static inline bool __init arm_dt_cpu_map_valid (void ) {return false; }#endif /* CONFIG_OF */ #endif /* ASMARM_PROM_H */
arch/arm/kernel/devtree.c +5 -0
@@ -62,6 +62,10 @@ void __init arm_dt_memblock_reserve(void)memblock_reserve (base, size); } } +/* +* Export DT cpu map validity flag to platforms +*/ +bool valid_dt_cpu_map__initdata ;/* * arm_dt_init_cpu_maps - Function retrieves cpu nodes from the device tree
@@ -158,6 +162,7 @@ void __init arm_dt_init_cpu_maps(void)* a reg property, the DT CPU list can be considered valid and the * logical map created in smp_setup_processor_id() can be overridden */ + valid_dt_cpu_map = true;for (i =0 ; i < cpuidx; i++) {set_cpu_possible (i, true);cpu_logical_map (i) = tmp_map[i];
Signature · 1 line
1.7.12
PATCH 1/1 ARM: kernel: DT cpu map validity check helper function
Quoted 57 lines · Lorenzo Pieralisi
Since the introduction of /cpu nodes bindings for ARM and the corresponding parse function
arm_dt_init_cpu_maps(), thecpu_logical_mapand the number of possible CPUs are set according to the DT /cpu nodes entries. Currently most of the existing ARM SMP platforms detect the number of cores through HW probing in their .smp_init_cpus functions and set the possible CPU mask accordingly.
This method should be upgraded so that the CPU counting mechanism will be based on DT, keeping legacy HW probing mechanism as a fall back solution.In order to implement this fall back solution mechanism, the ARM DT code should provide a helper function to platforms to check if the cpu map has been properly initialized through DT. If the check fails the platform will resort to legacy HW based cores counting mechanism.
This patch implements a trivial flag and a helper function that platform can call to check whether DT based cpu map initialization and cores count were completed successfully.
Signed-off-by Lorenzo Pieralisi <[email protected]>--- arch/arm/include/asm/prom.h | 10 ++++++++++ arch/arm/kernel/devtree.c | 5 +++++ 2 files changed, 15 insertions(+)arch/arm/include/asm/prom.h +10
-0@@ -18,6 +18,15 @@extern struct machine_desc *setup_machine_fdt (unsigned int dt_phys);extern void arm_dt_memblock_reserve (void );extern void __init arm_dt_init_cpu_maps (void ); +/* +* Return true if cpu map initialization has been +* carried out correctly from DT +*/ +static inline bool __init arm_dt_cpu_map_valid (void ) +{ +extern bool valid_dt_cpu_map; +return valid_dt_cpu_map; +}#else /* CONFIG_OF */ @@ -28,6 +37,7 @@ static inline struct machine_desc *setup_machine_fdt(unsigned int dt_phys)static inline void arm_dt_memblock_reserve (void ) { }static inline void arm_dt_init_cpu_maps (void ) { } +static inline bool __init arm_dt_cpu_map_valid (void ) {return false; }#endif /* CONFIG_OF */ #endif /* ASMARM_PROM_H */ arch/arm/kernel/devtree.c +0
-0
arch/arm/kernel/devtree.c void __init arm_dt_memblock_reserve(void) · line 68
Quoted 7 lines
arch/arm/kernel/devtree.c +4
-0@@ -62,6 +62,10 @@ void __init arm_dt_memblock_reserve(void)memblock_reserve (base, size); } } +/* +* Export DT cpu map validity flag to platforms +*/ +bool valid_dt_cpu_map__initdata ;
Is there any possibility of this being useful after boot? Hopefully not, but maybe there's something I haven't considered.
Cheers
---Dave
PATCH 1/1 ARM: kernel: DT cpu map validity check helper function
Quoted 60 lines · Dave Martin
Quoted 59 lines · Lorenzo Pieralisi
Since the introduction of /cpu nodes bindings for ARM and the corresponding parse function
arm_dt_init_cpu_maps(), thecpu_logical_mapand the number of possible CPUs are set according to the DT /cpu nodes entries. Currently most of the existing ARM SMP platforms detect the number of cores through HW probing in their .smp_init_cpus functions and set the possible CPU mask accordingly.
This method should be upgraded so that the CPU counting mechanism will be based on DT, keeping legacy HW probing mechanism as a fall back solution.In order to implement this fall back solution mechanism, the ARM DT code should provide a helper function to platforms to check if the cpu map has been properly initialized through DT. If the check fails the platform will resort to legacy HW based cores counting mechanism.
This patch implements a trivial flag and a helper function that platform can call to check whether DT based cpu map initialization and cores count were completed successfully.
Signed-off-by Lorenzo Pieralisi <[email protected]>--- arch/arm/include/asm/prom.h | 10 ++++++++++ arch/arm/kernel/devtree.c | 5 +++++ 2 files changed, 15 insertions(+)arch/arm/include/asm/prom.h +10
-0@@ -18,6 +18,15 @@extern struct machine_desc *setup_machine_fdt (unsigned int dt_phys);extern void arm_dt_memblock_reserve (void );extern void __init arm_dt_init_cpu_maps (void ); +/* +* Return true if cpu map initialization has been +* carried out correctly from DT +*/ +static inline bool __init arm_dt_cpu_map_valid (void ) +{ +extern bool valid_dt_cpu_map; +return valid_dt_cpu_map; +}#else /* CONFIG_OF */ @@ -28,6 +37,7 @@ static inline struct machine_desc *setup_machine_fdt(unsigned int dt_phys)static inline void arm_dt_memblock_reserve (void ) { }static inline void arm_dt_init_cpu_maps (void ) { } +static inline bool __init arm_dt_cpu_map_valid (void ) {return false; }#endif /* CONFIG_OF */ #endif /* ASMARM_PROM_H */ arch/arm/kernel/devtree.c +0
-0@@ -62,6 +62,10 @@ void __init arm_dt_memblock_reserve(void)memblock_reserve (base, size); }
Quoted 8 lines
arch/arm/kernel/devtree.c void __init arm_dt_memblock_reserve(void) · line 68
Quoted 5 lines
arch/arm/kernel/devtree.c +4
-0} +/* +* Export DT cpu map validity flag to platforms +*/ +bool valid_dt_cpu_map__initdata ;Is there any possibility of this being useful after boot? Hopefully not, but maybe there's something I haven't considered.
I do not think so, at least for the use cases I have envisaged at the moment, but it is certainly something I should consider.
Thanks,
Lorenzo
PATCH 1/1 ARM: kernel: DT cpu map validity check helper function
Quoted 70 lines · Lorenzo Pieralisi
Quoted 60 lines · Dave Martin
Quoted 59 lines · Lorenzo Pieralisi
Since the introduction of /cpu nodes bindings for ARM and the corresponding parse function
arm_dt_init_cpu_maps(), thecpu_logical_mapand the number of possible CPUs are set according to the DT /cpu nodes entries. Currently most of the existing ARM SMP platforms detect the number of cores through HW probing in their .smp_init_cpus functions and set the possible CPU mask accordingly.
This method should be upgraded so that the CPU counting mechanism will be based on DT, keeping legacy HW probing mechanism as a fall back solution.In order to implement this fall back solution mechanism, the ARM DT code should provide a helper function to platforms to check if the cpu map has been properly initialized through DT. If the check fails the platform will resort to legacy HW based cores counting mechanism.
This patch implements a trivial flag and a helper function that platform can call to check whether DT based cpu map initialization and cores count were completed successfully.
Signed-off-by Lorenzo Pieralisi <[email protected]>--- arch/arm/include/asm/prom.h | 10 ++++++++++ arch/arm/kernel/devtree.c | 5 +++++ 2 files changed, 15 insertions(+)arch/arm/include/asm/prom.h +10
-0@@ -18,6 +18,15 @@extern struct machine_desc *setup_machine_fdt (unsigned int dt_phys);extern void arm_dt_memblock_reserve (void );extern void __init arm_dt_init_cpu_maps (void ); +/* +* Return true if cpu map initialization has been +* carried out correctly from DT +*/ +static inline bool __init arm_dt_cpu_map_valid (void ) +{ +extern bool valid_dt_cpu_map; +return valid_dt_cpu_map; +}#else /* CONFIG_OF */ @@ -28,6 +37,7 @@ static inline struct machine_desc *setup_machine_fdt(unsigned int dt_phys)static inline void arm_dt_memblock_reserve (void ) { }static inline void arm_dt_init_cpu_maps (void ) { } +static inline bool __init arm_dt_cpu_map_valid (void ) {return false; }#endif /* CONFIG_OF */ #endif /* ASMARM_PROM_H */ arch/arm/kernel/devtree.c +0
-0@@ -62,6 +62,10 @@ void __init arm_dt_memblock_reserve(void)memblock_reserve (base, size); }Quoted 8 lines
arch/arm/kernel/devtree.c void __init arm_dt_memblock_reserve(void) · line 68
Quoted 5 lines
arch/arm/kernel/devtree.c +4
-0} +/* +* Export DT cpu map validity flag to platforms +*/ +bool valid_dt_cpu_map__initdata ;Is there any possibility of this being useful after boot? Hopefully not, but maybe there's something I haven't considered.
Quoted 2 lines
I do not think so, at least for the use cases I have envisaged at the moment, but it is certainly something I should consider.
Let's simply adjust the code in the future if that ever becomes the case.
Nicolas
PATCH 1/1 ARM: kernel: DT cpu map validity check helper function
Quoted 72 lines · Nicolas Pitre
Quoted 70 lines · Lorenzo Pieralisi
Quoted 68 lines · Dave Martin
Quoted 57 lines · Lorenzo Pieralisi
Since the introduction of /cpu nodes bindings for ARM and the corresponding parse function
arm_dt_init_cpu_maps(), thecpu_logical_mapand the number of possible CPUs are set according to the DT /cpu nodes entries. Currently most of the existing ARM SMP platforms detect the number of cores through HW probing in their .smp_init_cpus functions and set the possible CPU mask accordingly.
This method should be upgraded so that the CPU counting mechanism will be based on DT, keeping legacy HW probing mechanism as a fall back solution.In order to implement this fall back solution mechanism, the ARM DT code should provide a helper function to platforms to check if the cpu map has been properly initialized through DT. If the check fails the platform will resort to legacy HW based cores counting mechanism.
This patch implements a trivial flag and a helper function that platform can call to check whether DT based cpu map initialization and cores count were completed successfully.
Signed-off-by Lorenzo Pieralisi <[email protected]>--- arch/arm/include/asm/prom.h | 10 ++++++++++ arch/arm/kernel/devtree.c | 5 +++++ 2 files changed, 15 insertions(+)arch/arm/include/asm/prom.h +10
-0@@ -18,6 +18,15 @@extern struct machine_desc *setup_machine_fdt (unsigned int dt_phys);extern void arm_dt_memblock_reserve (void );extern void __init arm_dt_init_cpu_maps (void ); +/* +* Return true if cpu map initialization has been +* carried out correctly from DT +*/ +static inline bool __init arm_dt_cpu_map_valid (void ) +{ +extern bool valid_dt_cpu_map; +return valid_dt_cpu_map; +}#else /* CONFIG_OF */ @@ -28,6 +37,7 @@ static inline struct machine_desc *setup_machine_fdt(unsigned int dt_phys)static inline void arm_dt_memblock_reserve (void ) { }static inline void arm_dt_init_cpu_maps (void ) { } +static inline bool __init arm_dt_cpu_map_valid (void ) {return false; }#endif /* CONFIG_OF */ #endif /* ASMARM_PROM_H */ arch/arm/kernel/devtree.c +0
-0arch/arm/kernel/devtree.c void __init arm_dt_memblock_reserve(void) · line 68
Quoted 7 lines
arch/arm/kernel/devtree.c +4
-0@@ -62,6 +62,10 @@ void __init arm_dt_memblock_reserve(void)memblock_reserve (base, size); } } +/* +* Export DT cpu map validity flag to platforms +*/ +bool valid_dt_cpu_map__initdata ;Is there any possibility of this being useful after boot? Hopefully not, but maybe there's something I haven't considered.
Quoted 5 lines
Quoted 2 lines
I do not think so, at least for the use cases I have envisaged at the moment, but it is certainly something I should consider.
Let's simply adjust the code in the future if that ever becomes the case.
I will check against cpu_possible_mask, that will solve the problem and avoid this niggle.
Thanks,
Lorenzo
PATCH 1/1 ARM: kernel: DT cpu map validity check helper function
In reply to Lorenzo PieralisiQuoted 68 lines · Lorenzo Pieralisi
Since the introduction of /cpu nodes bindings for ARM and the corresponding parse function
arm_dt_init_cpu_maps(), thecpu_logical_mapand the number of possible CPUs are set according to the DT /cpu nodes entries. Currently most of the existing ARM SMP platforms detect the number of cores through HW probing in their .smp_init_cpus functions and set the possible CPU mask accordingly.
This method should be upgraded so that the CPU counting mechanism will be based on DT, keeping legacy HW probing mechanism as a fall back solution.In order to implement this fall back solution mechanism, the ARM DT code should provide a helper function to platforms to check if the cpu map has been properly initialized through DT. If the check fails the platform will resort to legacy HW based cores counting mechanism.
This patch implements a trivial flag and a helper function that platform can call to check whether DT based cpu map initialization and cores count were completed successfully.
Signed-off-by Lorenzo Pieralisi <[email protected]>--- arch/arm/include/asm/prom.h | 10 ++++++++++ arch/arm/kernel/devtree.c | 5 +++++ 2 files changed, 15 insertions(+)arch/arm/include/asm/prom.h +10
-0@@ -18,6 +18,15 @@extern struct machine_desc *setup_machine_fdt (unsigned int dt_phys);extern void arm_dt_memblock_reserve (void );extern void __init arm_dt_init_cpu_maps (void ); +/* +* Return true if cpu map initialization has been +* carried out correctly from DT +*/ +static inline bool __init arm_dt_cpu_map_valid (void ) +{ +extern bool valid_dt_cpu_map; +return valid_dt_cpu_map; +}#else /* CONFIG_OF */ @@ -28,6 +37,7 @@ static inline struct machine_desc *setup_machine_fdt(unsigned int dt_phys)static inline void arm_dt_memblock_reserve (void ) { }static inline void arm_dt_init_cpu_maps (void ) { } +static inline bool __init arm_dt_cpu_map_valid (void ) {return false; }#endif /* CONFIG_OF */ #endif /* ASMARM_PROM_H */ arch/arm/kernel/devtree.c +4
-0@@ -62,6 +62,10 @@ void __init arm_dt_memblock_reserve(void)memblock_reserve (base, size); } } +/* +* Export DT cpu map validity flag to platforms +*/ +bool valid_dt_cpu_map__initdata ;/* * arm_dt_init_cpu_maps - Function retrieves cpu nodes from the device tree
arch/arm/kernel/devtree.c void __init arm_dt_init_cpu_maps(void) · line 167
Quoted 6 lines
arch/arm/kernel/devtree.c +1
-0@@ -158,6 +162,7 @@ void __init arm_dt_init_cpu_maps(void)* a reg property, the DT CPU list can be considered valid and the * logical map created in smp_setup_processor_id() can be overridden */ + valid_dt_cpu_map = true;for (i =0 ; i < cpuidx; i++) {set_cpu_possible (i, true);
I don't see why we need another variable. Doesn't cpu_possible mask being set here imply that the DT map is valid.
We should start requiring valid /cpus nodes and the legacy fall-back should be temporary.
Rob
Quoted 2 lines
arch/arm/kernel/devtree.c +0
-0cpu_logical_map (i) = tmp_map[i];
PATCH 1/1 ARM: kernel: DT cpu map validity check helper function
Quoted 68 lines · Rob Herring
Quoted 65 lines · Lorenzo Pieralisi
Since the introduction of /cpu nodes bindings for ARM and the corresponding parse function
arm_dt_init_cpu_maps(), thecpu_logical_mapand the number of possible CPUs are set according to the DT /cpu nodes entries. Currently most of the existing ARM SMP platforms detect the number of cores through HW probing in their .smp_init_cpus functions and set the possible CPU mask accordingly.
This method should be upgraded so that the CPU counting mechanism will be based on DT, keeping legacy HW probing mechanism as a fall back solution.In order to implement this fall back solution mechanism, the ARM DT code should provide a helper function to platforms to check if the cpu map has been properly initialized through DT. If the check fails the platform will resort to legacy HW based cores counting mechanism.
This patch implements a trivial flag and a helper function that platform can call to check whether DT based cpu map initialization and cores count were completed successfully.
Signed-off-by Lorenzo Pieralisi <[email protected]>--- arch/arm/include/asm/prom.h | 10 ++++++++++ arch/arm/kernel/devtree.c | 5 +++++ 2 files changed, 15 insertions(+)arch/arm/include/asm/prom.h +10
-0@@ -18,6 +18,15 @@extern struct machine_desc *setup_machine_fdt (unsigned int dt_phys);extern void arm_dt_memblock_reserve (void );extern void __init arm_dt_init_cpu_maps (void ); +/* +* Return true if cpu map initialization has been +* carried out correctly from DT +*/ +static inline bool __init arm_dt_cpu_map_valid (void ) +{ +extern bool valid_dt_cpu_map; +return valid_dt_cpu_map; +}#else /* CONFIG_OF */ @@ -28,6 +37,7 @@ static inline struct machine_desc *setup_machine_fdt(unsigned int dt_phys)static inline void arm_dt_memblock_reserve (void ) { }static inline void arm_dt_init_cpu_maps (void ) { } +static inline bool __init arm_dt_cpu_map_valid (void ) {return false; }#endif /* CONFIG_OF */ #endif /* ASMARM_PROM_H */ arch/arm/kernel/devtree.c +4
-0@@ -62,6 +62,10 @@ void __init arm_dt_memblock_reserve(void)memblock_reserve (base, size); } } +/* +* Export DT cpu map validity flag to platforms +*/ +bool valid_dt_cpu_map__initdata ;
Quoted 12 lines
arch/arm/kernel/devtree.c void __init arm_dt_init_cpu_maps(void) · line 167
Quoted 9 lines
arch/arm/kernel/devtree.c +1
-0/* * arm_dt_init_cpu_maps - Function retrieves cpu nodes from the device tree @@ -158,6 +162,7 @@ void __init arm_dt_init_cpu_maps(void)* a reg property, the DT CPU list can be considered valid and the * logical map created in smp_setup_processor_id() can be overridden */ + valid_dt_cpu_map = true;for (i =0 ; i < cpuidx; i++) {set_cpu_possible (i, true);I don't see why we need another variable. Doesn't
cpu_possiblemask being set here imply that the DT map is valid.
Yes, that's correct I can use cpu_possible mask to check that, but I still want to do it through a function/macro, I do not want platform code to check possible mask explicitly, they have to do it through a helper function.
I will remove the variable.
Quoted 2 lines
We should start requiring valid /cpus nodes and the legacy fall-back should be temporary.
I could not agree more.
Thanks,
Lorenzo