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:
Samuel Holland
2024-08-30 08:49:12 -07:00
committed by Anup Patel
parent 97b8038916
commit ebe0f31446
3 changed files with 13 additions and 10 deletions

View File

@@ -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);