lib: sbi_ipi: Make .ipi_clear always target the current hart

All existing users of this operation target the current hart, and it
seems unlikely that a future user will need to clear the pending IPI
status of a remote hart. Simplify the logic by changing .ipi_clear (and
its wrapper sbi_ipi_raw_clear()) to always operate on the current hart.

This incidentally fixes a bug introduced in commit 78c667b6fc ("lib:
sbi: Prefer hartindex over hartid in IPI framework"), which changed the
.ipi_clear parameter from a hartid to a hart index, but failed to update
the warm_init functions to match.

Fixes: 78c667b6fc ("lib: sbi: Prefer hartindex over hartid in IPI framework")
Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
Samuel Holland
2024-10-25 11:59:46 -07:00
committed by Anup Patel
parent db8f03e512
commit be9752a071
5 changed files with 14 additions and 20 deletions

View File

@@ -479,7 +479,7 @@ static void __noreturn init_warmboot(struct sbi_scratch *scratch, u32 hartid)
if (hstate == SBI_HSM_STATE_SUSPENDED) {
init_warm_resume(scratch, hartid);
} else {
sbi_ipi_raw_clear(sbi_hartid_to_hartindex(hartid));
sbi_ipi_raw_clear();
init_warm_startup(scratch, hartid);
}
}

View File

@@ -237,10 +237,9 @@ void sbi_ipi_process(void)
struct sbi_scratch *scratch = sbi_scratch_thishart_ptr();
struct sbi_ipi_data *ipi_data =
sbi_scratch_offset_ptr(scratch, ipi_data_off);
u32 hartindex = current_hartindex();
sbi_pmu_ctr_incr_fw(SBI_PMU_FW_IPI_RECVD);
sbi_ipi_raw_clear(hartindex);
sbi_ipi_raw_clear();
ipi_type = atomic_raw_xchg_ulong(&ipi_data->ipi_type, 0);
ipi_event = 0;
@@ -275,10 +274,10 @@ int sbi_ipi_raw_send(u32 hartindex)
return 0;
}
void sbi_ipi_raw_clear(u32 hartindex)
void sbi_ipi_raw_clear(void)
{
if (ipi_dev && ipi_dev->ipi_clear)
ipi_dev->ipi_clear(hartindex);
ipi_dev->ipi_clear();
/*
* Ensure that memory or MMIO writes after this