summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAnup Patel <[email protected]>2020-03-15 11:39:25 +0530
committerAnup Patel <[email protected]>2020-03-19 09:30:01 +0530
commitc51f02cf143b081c2a81717393a0e6cef2ce2521 (patch)
treeeeff8cd451d20bfa543df626e1713a59803e6fb4 /lib
parent75eec9dd3f04febd7df8e5ee3fb90c236e50ded3 (diff)
include: sbi_platform: Introduce HART index to HART id table
A platform can have discontinuous and/or sparse HART ids so we cannot always assume a set of HARTs with continuous HART ids. This patch adds support for discontinuous and sparse HART ids by introducing HART index to HART id table. This table has platform hart_count entries and it maps HART index to HART id. The HART index to HART id table has only two restrictions: 1. HART index < sbi_platform hart_count 2. HART id < SBI_HARTMASK_MAX_BITS Example1: Let's say we have a platform with 2 HART ids 11 and 22, for such a a platform: hart_count = 2 hart_index2id[0] = 11 hart_index2id[1] = 22 Example2: Let's say we have a platform with 5 HARTs ids 0, 1, 2, 3, and 4 but out of these HART with id 0 is not usable so for such a platform: hart_count = 5 hart_index2id[0] = -1U hart_index2id[1] = 1 hart_index2id[2] = 2 hart_index2id[3] = 3 hart_index2id[4] = 4 OR hart_count = 4 hart_index2id[0] = 1 hart_index2id[1] = 2 hart_index2id[2] = 3 hart_index2id[3] = 4 With HART index to HART id table in place, the hart_disabled() callback is now redundant so we remove it as well. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Bin Meng <[email protected]> Reviewed-by: Atish Patra <[email protected]>
Diffstat (limited to 'lib')
-rw-r--r--lib/sbi/sbi_init.c4
-rw-r--r--lib/sbi/sbi_scratch.c7
-rw-r--r--lib/utils/fdt/fdt_helper.c2
3 files changed, 7 insertions, 6 deletions
diff --git a/lib/sbi/sbi_init.c b/lib/sbi/sbi_init.c
index 1c2f6b9e..2b9afb74 100644
--- a/lib/sbi/sbi_init.c
+++ b/lib/sbi/sbi_init.c
@@ -279,7 +279,7 @@ void __noreturn sbi_init(struct sbi_scratch *scratch)
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
if ((SBI_HARTMASK_MAX_BITS <= hartid) ||
- sbi_platform_hart_disabled(plat, hartid))
+ sbi_platform_hart_invalid(plat, hartid))
sbi_hart_hang();
if (atomic_add_return(&coldboot_lottery, 1) == 1)
@@ -322,7 +322,7 @@ void __noreturn sbi_exit(struct sbi_scratch *scratch)
u32 hartid = current_hartid();
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
- if (sbi_platform_hart_disabled(plat, hartid))
+ if (sbi_platform_hart_invalid(plat, hartid))
sbi_hart_hang();
sbi_platform_early_exit(plat);
diff --git a/lib/sbi/sbi_scratch.c b/lib/sbi/sbi_scratch.c
index a756fa78..8b635705 100644
--- a/lib/sbi/sbi_scratch.c
+++ b/lib/sbi/sbi_scratch.c
@@ -19,7 +19,7 @@ struct sbi_scratch *hartid_to_scratch_table[SBI_HARTMASK_MAX_BITS] = { 0 };
static spinlock_t extra_lock = SPIN_LOCK_INITIALIZER;
static unsigned long extra_offset = SBI_SCRATCH_EXTRA_SPACE_OFFSET;
-typedef struct sbi_scratch *(*hartid2scratch)(ulong hartid);
+typedef struct sbi_scratch *(*hartid2scratch)(ulong hartid, ulong hartindex);
int sbi_scratch_init(struct sbi_scratch *scratch)
{
@@ -27,10 +27,11 @@ int sbi_scratch_init(struct sbi_scratch *scratch)
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
for (i = 0; i < SBI_HARTMASK_MAX_BITS; i++) {
- if (sbi_platform_hart_disabled(plat, i))
+ if (sbi_platform_hart_invalid(plat, i))
continue;
hartid_to_scratch_table[i] =
- ((hartid2scratch)scratch->hartid_to_scratch)(i);
+ ((hartid2scratch)scratch->hartid_to_scratch)(i,
+ sbi_platform_hart_index(plat, i));
}
return 0;
diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c
index 47cd1d30..2ea52caf 100644
--- a/lib/utils/fdt/fdt_helper.c
+++ b/lib/utils/fdt/fdt_helper.c
@@ -30,7 +30,7 @@ void fdt_cpu_fixup(void *fdt)
sbi_sprintf(cpu_node, "/cpus/cpu@%d", i);
cpu_offset = fdt_path_offset(fdt, cpu_node);
- if (sbi_platform_hart_disabled(plat, i))
+ if (sbi_platform_hart_invalid(plat, i))
fdt_setprop_string(fdt, cpu_offset, "status",
"disabled");