aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>2016-02-11 13:01:45 +0530
committerStewart Smith <stewart@linux.vnet.ibm.com>2016-02-23 17:22:42 +1100
commitf7ad0d75f45130e0cec6787a7629da47f5f40f21 (patch)
tree9928dbf89b0f0c60d3ec667f14dd47716e0555f4
parent48ab7ce095047c06191f1b06fc4704311c4dabda (diff)
downloadskiboot-f7ad0d75f45130e0cec6787a7629da47f5f40f21.zip
skiboot-f7ad0d75f45130e0cec6787a7629da47f5f40f21.tar.gz
skiboot-f7ad0d75f45130e0cec6787a7629da47f5f40f21.tar.bz2
cpu: Add helper function to return number of cores available in the chip
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@linux.vnet.ibm.com> Reviewed-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r--core/cpu.c11
-rw-r--r--include/cpu.h1
2 files changed, 12 insertions, 0 deletions
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; \