diff options
author | Anup Patel <anup.patel@wdc.com> | 2020-03-02 16:21:38 +0530 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2020-03-11 15:30:26 +0530 |
commit | 9aad831e87dae70bf78357d49529c7ee56bd7175 (patch) | |
tree | 9302760f1b71913baeca4cf09ff5e04003d517af /lib/sbi/sbi_ipi.c | |
parent | 466fecb95732c6c7eb98e897df71996d0cef479b (diff) |
lib: sbi_ipi: Use sbi_hsm_hart_started_mask() API
This patch replaces use of sbi_hart_available_mask() API with
sbi_hsm_hart_started_mask() API.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'lib/sbi/sbi_ipi.c')
-rw-r--r-- | lib/sbi/sbi_ipi.c | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/lib/sbi/sbi_ipi.c b/lib/sbi/sbi_ipi.c index 006844b..144b04a 100644 --- a/lib/sbi/sbi_ipi.c +++ b/lib/sbi/sbi_ipi.c @@ -37,8 +37,7 @@ static int sbi_ipi_send(struct sbi_scratch *scratch, u32 remote_hartid, const struct sbi_ipi_event_ops *ipi_ops; if ((SBI_IPI_EVENT_MAX <= event) || - !ipi_ops_array[event] || - sbi_platform_hart_disabled(plat, remote_hartid)) + !ipi_ops_array[event]) return SBI_EINVAL; ipi_ops = ipi_ops_array[event]; @@ -74,33 +73,32 @@ static int sbi_ipi_send(struct sbi_scratch *scratch, u32 remote_hartid, int sbi_ipi_send_many(struct sbi_scratch *scratch, ulong hmask, ulong hbase, u32 event, void *data) { + int rc; ulong i, m; - ulong mask = sbi_hart_available_mask(); - ulong tempmask; - unsigned long last_bit = __fls(mask); if (hbase != -1UL) { - if (hbase > last_bit) - /* hart base is not available */ - return SBI_EINVAL; - /** - * FIXME: This check is valid only ULONG size. This is okay for - * now as avaialble hart mask can support upto ULONG size only. - */ - tempmask = hmask << hbase; - tempmask = ~mask & tempmask; - if (tempmask) - /* at least one of the hart in hmask is not available */ - return SBI_EINVAL; - - mask &= (hmask << hbase); + rc = sbi_hsm_hart_started_mask(scratch, hbase, &m); + if (rc) + return rc; + m &= hmask; + + /* Send IPIs */ + for (i = hbase; m; i++, m >>= 1) { + if (m & 1UL) + sbi_ipi_send(scratch, i, event, data); + } + } else { + hbase = 0; + while (!sbi_hsm_hart_started_mask(scratch, hbase, &m)) { + /* Send IPIs */ + for (i = hbase; m; i++, m >>= 1) { + if (m & 1UL) + sbi_ipi_send(scratch, i, event, data); + } + hbase += BITS_PER_LONG; + } } - /* Send IPIs to every other hart on the set */ - for (i = 0, m = mask; m; i++, m >>= 1) - if (m & 1UL) - sbi_ipi_send(scratch, i, event, data); - return 0; } |