lib: sbi: Prefer hartindex over hartid in IPI framework

Let us prefer hartindex over hartid in IPI framework which in-turn
forces IPI users to also prefer hartindex.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
This commit is contained in:
Anup Patel
2023-09-01 17:41:07 +05:30
committed by Anup Patel
parent e632cd7c81
commit 78c667b6fc
9 changed files with 44 additions and 38 deletions

View File

@@ -25,13 +25,13 @@ static unsigned long mswi_ptr_offset;
#define mswi_set_hart_data_ptr(__scratch, __mswi) \
sbi_scratch_write_type((__scratch), void *, mswi_ptr_offset, (__mswi))
static void mswi_ipi_send(u32 target_hart)
static void mswi_ipi_send(u32 hart_index)
{
u32 *msip;
struct sbi_scratch *scratch;
struct aclint_mswi_data *mswi;
scratch = sbi_hartid_to_scratch(target_hart);
scratch = sbi_hartindex_to_scratch(hart_index);
if (!scratch)
return;
@@ -41,16 +41,17 @@ static void mswi_ipi_send(u32 target_hart)
/* Set ACLINT IPI */
msip = (void *)mswi->addr;
writel(1, &msip[target_hart - mswi->first_hartid]);
writel(1, &msip[sbi_hartindex_to_hartid(hart_index) -
mswi->first_hartid]);
}
static void mswi_ipi_clear(u32 target_hart)
static void mswi_ipi_clear(u32 hart_index)
{
u32 *msip;
struct sbi_scratch *scratch;
struct aclint_mswi_data *mswi;
scratch = sbi_hartid_to_scratch(target_hart);
scratch = sbi_hartindex_to_scratch(hart_index);
if (!scratch)
return;
@@ -60,7 +61,8 @@ static void mswi_ipi_clear(u32 target_hart)
/* Clear ACLINT IPI */
msip = (void *)mswi->addr;
writel(0, &msip[target_hart - mswi->first_hartid]);
writel(0, &msip[sbi_hartindex_to_hartid(hart_index) -
mswi->first_hartid]);
}
static struct sbi_ipi_device aclint_mswi = {

View File

@@ -68,8 +68,10 @@ static inline void plic_sw_pending(u32 target_hart)
writel(val, (void *)plicsw.addr + PLICSW_PENDING_BASE + word_index * 4);
}
static void plicsw_ipi_send(u32 target_hart)
static void plicsw_ipi_send(u32 hart_index)
{
u32 target_hart = sbi_hartindex_to_hartid(hart_index);
if (plicsw.hart_count <= target_hart)
ebreak();
@@ -77,8 +79,10 @@ static void plicsw_ipi_send(u32 target_hart)
plic_sw_pending(target_hart);
}
static void plicsw_ipi_clear(u32 target_hart)
static void plicsw_ipi_clear(u32 hart_index)
{
u32 target_hart = sbi_hartindex_to_hartid(hart_index);
if (plicsw.hart_count <= target_hart)
ebreak();

View File

@@ -161,7 +161,7 @@ static int imsic_external_irqfn(struct sbi_trap_regs *regs)
return 0;
}
static void imsic_ipi_send(u32 target_hart)
static void imsic_ipi_send(u32 hart_index)
{
unsigned long reloff;
struct imsic_regs *regs;
@@ -169,7 +169,7 @@ static void imsic_ipi_send(u32 target_hart)
struct sbi_scratch *scratch;
int file;
scratch = sbi_hartid_to_scratch(target_hart);
scratch = sbi_hartindex_to_scratch(hart_index);
if (!scratch)
return;