[Skiboot] [PATCH v4 1/2] cpu: Add helper function to return number of cores available in the chip
Shilpasri G Bhat
shilpa.bhat at linux.vnet.ibm.com
Thu Feb 11 18:31:45 AEDT 2016
get_available_nr_cores_in_chip() takes 'chip_id' as an argument and
returns the number of available cores in the chip.
Signed-off-by: Shilpasri G Bhat <shilpa.bhat at linux.vnet.ibm.com>
Reviewed-by: Joel Stanley <joel at jms.id.au>
---
core/cpu.c | 11 +++++++++++
include/cpu.h | 1 +
2 files changed, 12 insertions(+)
diff --git a/core/cpu.c b/core/cpu.c
index 68c027c..d347903 100644
--- a/core/cpu.c
+++ b/core/cpu.c
@@ -317,6 +317,17 @@ struct cpu_thread *first_available_cpu(void)
return next_available_cpu(NULL);
}
+u8 get_available_nr_cores_in_chip(u32 chip_id)
+{
+ struct cpu_thread *core;
+ u8 nr_cores = 0;
+
+ for_each_available_core_in_chip(core, chip_id)
+ nr_cores++;
+
+ return nr_cores;
+}
+
struct cpu_thread *next_available_core_in_chip(struct cpu_thread *core,
u32 chip_id)
{
diff --git a/include/cpu.h b/include/cpu.h
index 982b48a..9eaf59c 100644
--- a/include/cpu.h
+++ b/include/cpu.h
@@ -166,6 +166,7 @@ extern struct cpu_thread *next_available_cpu(struct cpu_thread *cpu);
extern struct cpu_thread *first_available_core_in_chip(u32 chip_id);
extern struct cpu_thread *next_available_core_in_chip(struct cpu_thread *cpu, u32 chip_id);
+extern u8 get_available_nr_cores_in_chip(u32 chip_id);
#define for_each_available_core_in_chip(core, chip_id) \
for (core = first_available_core_in_chip(chip_id); core; \
--
1.9.3
More information about the Skiboot
mailing list