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 <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
This commit is contained in:
Anup Patel
2020-03-15 11:39:25 +05:30
committed by Anup Patel
parent 75eec9dd3f
commit c51f02cf14
6 changed files with 89 additions and 28 deletions

View File

@@ -165,10 +165,12 @@ static int fu540_timer_init(bool cold_boot)
return clint_warm_timer_init();
}
static bool fu540_hart_disabled(u32 hartid)
{
return (FU540_HARITD_DISABLED & (1UL << hartid)) ? TRUE : FALSE;
}
static u32 fu540_hart_index2id[FU540_HART_COUNT - 1] = {
[0] = 1,
[1] = 2,
[2] = 3,
[3] = 4,
};
static int fu540_system_down(u32 type)
{
@@ -192,7 +194,6 @@ const struct sbi_platform_operations platform_ops = {
.timer_event_stop = clint_timer_event_stop,
.timer_event_start = clint_timer_event_start,
.timer_init = fu540_timer_init,
.hart_disabled = fu540_hart_disabled,
.system_reboot = fu540_system_down,
.system_shutdown = fu540_system_down
};
@@ -202,7 +203,8 @@ const struct sbi_platform platform = {
.platform_version = SBI_PLATFORM_VERSION(0x0, 0x01),
.name = "SiFive Freedom U540",
.features = SBI_PLATFORM_DEFAULT_FEATURES,
.hart_count = FU540_HART_COUNT,
.hart_count = (FU540_HART_COUNT - 1),
.hart_index2id = fu540_hart_index2id,
.hart_stack_size = SBI_PLATFORM_DEFAULT_HART_STACK_SIZE,
.platform_ops_addr = (unsigned long)&platform_ops
};