mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 23:41:23 +01:00
lib: Don't use sbi_platform_hart_count() API
We don't need to use sbi_platform_hart_count() in sbi_init and sbi_scratch because checking sbi_platform_hart_disabled() or return value of sbi_hartid_to_scratch() is sufficient. 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:
@@ -59,8 +59,6 @@ static void sbi_boot_prints(struct sbi_scratch *scratch, u32 hartid)
|
|||||||
/* Platform details */
|
/* Platform details */
|
||||||
sbi_printf("Platform Name : %s\n", sbi_platform_name(plat));
|
sbi_printf("Platform Name : %s\n", sbi_platform_name(plat));
|
||||||
sbi_printf("Platform HART Features : RV%d%s\n", xlen, str);
|
sbi_printf("Platform HART Features : RV%d%s\n", xlen, str);
|
||||||
sbi_printf("Platform Max HARTs : %d\n",
|
|
||||||
sbi_platform_hart_count(plat));
|
|
||||||
sbi_printf("Current Hart : %u\n", hartid);
|
sbi_printf("Current Hart : %u\n", hartid);
|
||||||
/* Firmware details */
|
/* Firmware details */
|
||||||
sbi_printf("Firmware Base : 0x%lx\n", scratch->fw_start);
|
sbi_printf("Firmware Base : 0x%lx\n", scratch->fw_start);
|
||||||
@@ -119,7 +117,6 @@ static void wait_for_coldboot(struct sbi_scratch *scratch, u32 hartid)
|
|||||||
static void wake_coldboot_harts(struct sbi_scratch *scratch, u32 hartid)
|
static void wake_coldboot_harts(struct sbi_scratch *scratch, u32 hartid)
|
||||||
{
|
{
|
||||||
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
|
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
|
||||||
int max_hart = sbi_platform_hart_count(plat);
|
|
||||||
|
|
||||||
/* Acquire coldboot lock */
|
/* Acquire coldboot lock */
|
||||||
spin_lock(&coldboot_lock);
|
spin_lock(&coldboot_lock);
|
||||||
@@ -128,7 +125,7 @@ static void wake_coldboot_harts(struct sbi_scratch *scratch, u32 hartid)
|
|||||||
coldboot_done = 1;
|
coldboot_done = 1;
|
||||||
|
|
||||||
/* Send an IPI to all HARTs waiting for coldboot */
|
/* Send an IPI to all HARTs waiting for coldboot */
|
||||||
for (int i = 0; i < max_hart; i++) {
|
for (int i = 0; i < SBI_HARTMASK_MAX_BITS; i++) {
|
||||||
if ((i != hartid) &&
|
if ((i != hartid) &&
|
||||||
sbi_hartmask_test_hart(i, &coldboot_wait_hmask))
|
sbi_hartmask_test_hart(i, &coldboot_wait_hmask))
|
||||||
sbi_platform_ipi_send(plat, i);
|
sbi_platform_ipi_send(plat, i);
|
||||||
@@ -282,7 +279,6 @@ void __noreturn sbi_init(struct sbi_scratch *scratch)
|
|||||||
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
|
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
|
||||||
|
|
||||||
if ((SBI_HARTMASK_MAX_BITS <= hartid) ||
|
if ((SBI_HARTMASK_MAX_BITS <= hartid) ||
|
||||||
(sbi_platform_hart_count(plat) <= hartid) ||
|
|
||||||
sbi_platform_hart_disabled(plat, hartid))
|
sbi_platform_hart_disabled(plat, hartid))
|
||||||
sbi_hart_hang();
|
sbi_hart_hang();
|
||||||
|
|
||||||
@@ -300,8 +296,7 @@ unsigned long sbi_init_count(u32 hartid)
|
|||||||
struct sbi_scratch *scratch;
|
struct sbi_scratch *scratch;
|
||||||
unsigned long *init_count;
|
unsigned long *init_count;
|
||||||
|
|
||||||
if (sbi_platform_hart_count(sbi_platform_thishart_ptr()) <= hartid ||
|
if (!init_count_offset)
|
||||||
!init_count_offset)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
scratch = sbi_hartid_to_scratch(hartid);
|
scratch = sbi_hartid_to_scratch(hartid);
|
||||||
|
@@ -26,7 +26,7 @@ int sbi_scratch_init(struct sbi_scratch *scratch)
|
|||||||
u32 i;
|
u32 i;
|
||||||
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
|
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
|
||||||
|
|
||||||
for (i = 0; i < sbi_platform_hart_count(plat); i++) {
|
for (i = 0; i < SBI_HARTMASK_MAX_BITS; i++) {
|
||||||
if (sbi_platform_hart_disabled(plat, i))
|
if (sbi_platform_hart_disabled(plat, i))
|
||||||
continue;
|
continue;
|
||||||
hartid_to_scratch_table[i] =
|
hartid_to_scratch_table[i] =
|
||||||
@@ -41,8 +41,7 @@ unsigned long sbi_scratch_alloc_offset(unsigned long size, const char *owner)
|
|||||||
u32 i;
|
u32 i;
|
||||||
void *ptr;
|
void *ptr;
|
||||||
unsigned long ret = 0;
|
unsigned long ret = 0;
|
||||||
struct sbi_scratch *scratch, *rscratch;
|
struct sbi_scratch *rscratch;
|
||||||
const struct sbi_platform *plat;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We have a simple brain-dead allocator which never expects
|
* We have a simple brain-dead allocator which never expects
|
||||||
@@ -71,9 +70,7 @@ done:
|
|||||||
spin_unlock(&extra_lock);
|
spin_unlock(&extra_lock);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
scratch = sbi_scratch_thishart_ptr();
|
for (i = 0; i < SBI_HARTMASK_MAX_BITS; i++) {
|
||||||
plat = sbi_platform_ptr(scratch);
|
|
||||||
for (i = 0; i < sbi_platform_hart_count(plat); i++) {
|
|
||||||
rscratch = sbi_hartid_to_scratch(i);
|
rscratch = sbi_hartid_to_scratch(i);
|
||||||
if (!rscratch)
|
if (!rscratch)
|
||||||
continue;
|
continue;
|
||||||
|
Reference in New Issue
Block a user