lib: sbi: Introduce IPI device rating

A platform can have multiple IPI devices (such as ACLINT MSWI,
AIA IMSIC, etc). Currently, OpenSBI rely on platform calling
the sbi_ipi_set_device() function in correct order and prefer
the first avaiable IPI device which is fragile.

Instead of the above, introduce IPI device rating and prefer
the highest rated IPI device. This further allows extending
the sbi_ipi_raw_clear() to clear all available IPI devices.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Tested-by: Nick Hu <nick.hu@sifive.com>
Link: https://lore.kernel.org/r/20250904052410.546818-2-apatel@ventanamicro.com
Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
Anup Patel
2025-09-04 10:54:08 +05:30
committed by Anup Patel
parent 17b8d1900d
commit ee92afa638
6 changed files with 47 additions and 14 deletions

View File

@@ -23,6 +23,9 @@ struct sbi_ipi_device {
/** Name of the IPI device */
char name[32];
/** Ratings of the IPI device (higher is better) */
unsigned long rating;
/** Send IPI to a target HART index */
void (*ipi_send)(u32 hart_index);
@@ -87,11 +90,11 @@ void sbi_ipi_process(void);
int sbi_ipi_raw_send(u32 hartindex);
void sbi_ipi_raw_clear(void);
void sbi_ipi_raw_clear(bool all_devices);
const struct sbi_ipi_device *sbi_ipi_get_device(void);
void sbi_ipi_set_device(const struct sbi_ipi_device *dev);
void sbi_ipi_add_device(const struct sbi_ipi_device *dev);
int sbi_ipi_init(struct sbi_scratch *scratch, bool cold_boot);