forked from Mirrors/opensbi
lib: sbi: Update __sbi_hsm_hart_get_state() to take a hart index
This removes some hartindex conversions in sbi_system_suspend(), but is mostly intended to support refactoring sbi_hsm_hart_interruptible_mask() to work exclusively with struct sbi_hartmask. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:

committed by
Anup Patel

parent
97b8038916
commit
ebe0f31446
@@ -72,7 +72,7 @@ int sbi_hsm_hart_suspend(struct sbi_scratch *scratch, u32 suspend_type,
|
||||
ulong raddr, ulong rmode, ulong arg1);
|
||||
bool sbi_hsm_hart_change_state(struct sbi_scratch *scratch, long oldstate,
|
||||
long newstate);
|
||||
int __sbi_hsm_hart_get_state(u32 hartid);
|
||||
int __sbi_hsm_hart_get_state(u32 hartindex);
|
||||
int sbi_hsm_hart_get_state(const struct sbi_domain *dom, u32 hartid);
|
||||
int sbi_hsm_hart_interruptible_mask(const struct sbi_domain *dom,
|
||||
ulong hbase, ulong *out_hmask);
|
||||
|
@@ -60,12 +60,12 @@ bool sbi_hsm_hart_change_state(struct sbi_scratch *scratch, long oldstate,
|
||||
return __sbi_hsm_hart_change_state(hdata, oldstate, newstate);
|
||||
}
|
||||
|
||||
int __sbi_hsm_hart_get_state(u32 hartid)
|
||||
int __sbi_hsm_hart_get_state(u32 hartindex)
|
||||
{
|
||||
struct sbi_hsm_data *hdata;
|
||||
struct sbi_scratch *scratch;
|
||||
|
||||
scratch = sbi_hartid_to_scratch(hartid);
|
||||
scratch = sbi_hartindex_to_scratch(hartindex);
|
||||
if (!scratch)
|
||||
return SBI_EINVAL;
|
||||
|
||||
@@ -75,10 +75,12 @@ int __sbi_hsm_hart_get_state(u32 hartid)
|
||||
|
||||
int sbi_hsm_hart_get_state(const struct sbi_domain *dom, u32 hartid)
|
||||
{
|
||||
u32 hartindex = sbi_hartid_to_hartindex(hartid);
|
||||
|
||||
if (!sbi_domain_is_assigned_hart(dom, hartid))
|
||||
return SBI_EINVAL;
|
||||
|
||||
return __sbi_hsm_hart_get_state(hartid);
|
||||
return __sbi_hsm_hart_get_state(hartindex);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -120,6 +122,7 @@ int sbi_hsm_hart_interruptible_mask(const struct sbi_domain *dom,
|
||||
{
|
||||
int hstate;
|
||||
ulong i, hmask, dmask;
|
||||
u32 hartindex;
|
||||
|
||||
*out_hmask = 0;
|
||||
if (!sbi_hartid_valid(hbase))
|
||||
@@ -131,7 +134,8 @@ int sbi_hsm_hart_interruptible_mask(const struct sbi_domain *dom,
|
||||
if (!(dmask & hmask))
|
||||
continue;
|
||||
|
||||
hstate = __sbi_hsm_hart_get_state(hbase + i);
|
||||
hartindex = sbi_hartid_to_hartindex(hbase + i);
|
||||
hstate = __sbi_hsm_hart_get_state(hartindex);
|
||||
if (hstate == SBI_HSM_STATE_STARTED ||
|
||||
hstate == SBI_HSM_STATE_SUSPENDED ||
|
||||
hstate == SBI_HSM_STATE_RESUME_PENDING)
|
||||
|
@@ -142,9 +142,9 @@ int sbi_system_suspend(u32 sleep_type, ulong resume_addr, ulong opaque)
|
||||
struct sbi_domain *dom = sbi_domain_thishart_ptr();
|
||||
struct sbi_scratch *scratch = sbi_scratch_thishart_ptr();
|
||||
void (*jump_warmboot)(void) = (void (*)(void))scratch->warmboot_addr;
|
||||
unsigned int hartid = current_hartid();
|
||||
unsigned int hartindex = current_hartindex();
|
||||
unsigned long prev_mode;
|
||||
unsigned long i, j;
|
||||
unsigned long i;
|
||||
int ret;
|
||||
|
||||
if (!dom || !dom->system_suspend_allowed)
|
||||
@@ -163,9 +163,8 @@ int sbi_system_suspend(u32 sleep_type, ulong resume_addr, ulong opaque)
|
||||
return SBI_EFAIL;
|
||||
|
||||
spin_lock(&dom->assigned_harts_lock);
|
||||
sbi_hartmask_for_each_hartindex(j, &dom->assigned_harts) {
|
||||
i = sbi_hartindex_to_hartid(j);
|
||||
if (i == hartid)
|
||||
sbi_hartmask_for_each_hartindex(i, &dom->assigned_harts) {
|
||||
if (i == hartindex)
|
||||
continue;
|
||||
if (__sbi_hsm_hart_get_state(i) != SBI_HSM_STATE_STOPPED) {
|
||||
spin_unlock(&dom->assigned_harts_lock);
|
||||
|
Reference in New Issue
Block a user