diff options
author | Samuel Holland <samuel.holland@sifive.com> | 2024-10-25 11:59:46 -0700 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2024-11-11 18:17:15 +0530 |
commit | be9752a071475ae1d9e58a2dfcb8e83185fb7ae5 (patch) | |
tree | b4a3fb641c70ae2933956fb5a0134c186898a139 /lib/utils | |
parent | db8f03e51237168c7fcff3d6aaa9058d6675b017 (diff) | |
download | opensbi-be9752a071475ae1d9e58a2dfcb8e83185fb7ae5.zip opensbi-be9752a071475ae1d9e58a2dfcb8e83185fb7ae5.tar.gz opensbi-be9752a071475ae1d9e58a2dfcb8e83185fb7ae5.tar.bz2 |
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 78c667b6fc07 ("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: 78c667b6fc07 ("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>
Diffstat (limited to 'lib/utils')
-rw-r--r-- | lib/utils/ipi/aclint_mswi.c | 13 | ||||
-rw-r--r-- | lib/utils/ipi/andes_plicsw.c | 6 |
2 files changed, 7 insertions, 12 deletions
diff --git a/lib/utils/ipi/aclint_mswi.c b/lib/utils/ipi/aclint_mswi.c index 0ef3d00..2cd7a53 100644 --- a/lib/utils/ipi/aclint_mswi.c +++ b/lib/utils/ipi/aclint_mswi.c @@ -45,24 +45,19 @@ static void mswi_ipi_send(u32 hart_index) mswi->first_hartid]); } -static void mswi_ipi_clear(u32 hart_index) +static void mswi_ipi_clear(void) { u32 *msip; - struct sbi_scratch *scratch; + struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); struct aclint_mswi_data *mswi; - scratch = sbi_hartindex_to_scratch(hart_index); - if (!scratch) - return; - mswi = mswi_get_hart_data_ptr(scratch); if (!mswi) return; /* Clear ACLINT IPI */ msip = (void *)mswi->addr; - writel_relaxed(0, &msip[sbi_hartindex_to_hartid(hart_index) - - mswi->first_hartid]); + writel_relaxed(0, &msip[current_hartid() - mswi->first_hartid]); } static struct sbi_ipi_device aclint_mswi = { @@ -74,7 +69,7 @@ static struct sbi_ipi_device aclint_mswi = { int aclint_mswi_warm_init(void) { /* Clear IPI for current HART */ - mswi_ipi_clear(current_hartindex()); + mswi_ipi_clear(); return 0; } diff --git a/lib/utils/ipi/andes_plicsw.c b/lib/utils/ipi/andes_plicsw.c index 18c79e2..626699f 100644 --- a/lib/utils/ipi/andes_plicsw.c +++ b/lib/utils/ipi/andes_plicsw.c @@ -41,9 +41,9 @@ static void plicsw_ipi_send(u32 hart_index) writel_relaxed(BIT(pending_bit), (void *)pending_reg); } -static void plicsw_ipi_clear(u32 hart_index) +static void plicsw_ipi_clear(void) { - u32 target_hart = sbi_hartindex_to_hartid(hart_index); + u32 target_hart = current_hartid(); ulong reg = plicsw.addr + PLICSW_CONTEXT_BASE + PLICSW_CONTEXT_CLAIM + PLICSW_CONTEXT_STRIDE * target_hart; @@ -68,7 +68,7 @@ static struct sbi_ipi_device plicsw_ipi = { int plicsw_warm_ipi_init(void) { /* Clear PLICSW IPI */ - plicsw_ipi_clear(current_hartindex()); + plicsw_ipi_clear(); return 0; } |