* [PATCH v3 0/3] OpenSBI IPI device rating
@ 2025-09-04 5:24 Anup Patel
2025-09-04 5:24 ` [PATCH v3 1/3] lib: sbi: Introduce " Anup Patel
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Anup Patel @ 2025-09-04 5:24 UTC (permalink / raw)
To: Atish Patra; +Cc: Andrew Jones, Anup Patel, opensbi, Anup Patel
Introduce IPI device rating which further allows us to remove platform
specific IPI init and convert IPI drivers as early drivers.
These patches can also found in sbi_ipi_rating_v3 branch at:
https://github.com/avpatel/opensbi.git
Changes since v2:
- Rename sbi_ipi_set_device() to sbi_ipi_add_device()
in PATCH1
Changes since v1:
- Use linked-list in PATCH1 instead of array
- Initialize aclint_msw after serial port in PATCH2
Anup Patel (3):
lib: sbi: Introduce IPI device rating
include: sbi: Remove platform specific IPI init
lib: utils/ipi: Convert IPI drivers as early drivers
include/sbi/sbi_ipi.h | 7 +++-
include/sbi/sbi_platform.h | 17 ---------
include/sbi_utils/ipi/fdt_ipi.h | 26 -------------
lib/sbi/sbi_init.c | 2 +-
lib/sbi/sbi_ipi.c | 48 +++++++++++++++++-------
lib/utils/ipi/aclint_mswi.c | 3 +-
lib/utils/ipi/andes_plicsw.c | 3 +-
lib/utils/ipi/fdt_ipi.c | 22 -----------
lib/utils/ipi/fdt_ipi_drivers.carray | 3 --
lib/utils/ipi/fdt_ipi_mswi.c | 2 +-
lib/utils/ipi/fdt_ipi_plicsw.c | 2 +-
lib/utils/ipi/objects.mk | 7 +---
lib/utils/irqchip/imsic.c | 3 +-
platform/fpga/ariane/platform.c | 29 +++++++-------
platform/generic/openhwgroup/openpiton.c | 23 +++++-------
platform/generic/platform.c | 2 -
platform/kendryte/k210/platform.c | 17 ++++-----
platform/nuclei/ux600/platform.c | 15 ++++----
platform/template/platform.c | 20 ++++------
19 files changed, 96 insertions(+), 155 deletions(-)
delete mode 100644 include/sbi_utils/ipi/fdt_ipi.h
delete mode 100644 lib/utils/ipi/fdt_ipi.c
delete mode 100644 lib/utils/ipi/fdt_ipi_drivers.carray
--
2.43.0
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3 1/3] lib: sbi: Introduce IPI device rating
2025-09-04 5:24 [PATCH v3 0/3] OpenSBI IPI device rating Anup Patel
@ 2025-09-04 5:24 ` Anup Patel
2025-09-04 5:24 ` [PATCH v3 2/3] include: sbi: Remove platform specific IPI init Anup Patel
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Anup Patel @ 2025-09-04 5:24 UTC (permalink / raw)
To: Atish Patra; +Cc: Andrew Jones, Anup Patel, opensbi, Anup Patel, Nick Hu
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>
---
include/sbi/sbi_ipi.h | 7 ++++--
lib/sbi/sbi_init.c | 2 +-
lib/sbi/sbi_ipi.c | 43 +++++++++++++++++++++++++++++-------
lib/utils/ipi/aclint_mswi.c | 3 ++-
lib/utils/ipi/andes_plicsw.c | 3 ++-
lib/utils/irqchip/imsic.c | 3 ++-
6 files changed, 47 insertions(+), 14 deletions(-)
diff --git a/include/sbi/sbi_ipi.h b/include/sbi/sbi_ipi.h
index 62d61304..26d1b66b 100644
--- a/include/sbi/sbi_ipi.h
+++ b/include/sbi/sbi_ipi.h
@@ -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);
diff --git a/lib/sbi/sbi_init.c b/lib/sbi/sbi_init.c
index 84a63748..663b486b 100644
--- a/lib/sbi/sbi_init.c
+++ b/lib/sbi/sbi_init.c
@@ -507,7 +507,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_ipi_raw_clear(true);
init_warm_startup(scratch, hartid);
}
}
diff --git a/lib/sbi/sbi_ipi.c b/lib/sbi/sbi_ipi.c
index 2de459b0..93018fe6 100644
--- a/lib/sbi/sbi_ipi.c
+++ b/lib/sbi/sbi_ipi.c
@@ -15,9 +15,11 @@
#include <sbi/sbi_domain.h>
#include <sbi/sbi_error.h>
#include <sbi/sbi_hart.h>
+#include <sbi/sbi_heap.h>
#include <sbi/sbi_hsm.h>
#include <sbi/sbi_init.h>
#include <sbi/sbi_ipi.h>
+#include <sbi/sbi_list.h>
#include <sbi/sbi_platform.h>
#include <sbi/sbi_pmu.h>
#include <sbi/sbi_string.h>
@@ -32,8 +34,14 @@ _Static_assert(
"type of sbi_ipi_data.ipi_type has changed, please redefine SBI_IPI_EVENT_MAX"
);
+struct sbi_ipi_device_node {
+ struct sbi_dlist head;
+ const struct sbi_ipi_device *dev;
+};
+
static unsigned long ipi_data_off;
static const struct sbi_ipi_device *ipi_dev = NULL;
+static SBI_LIST_HEAD(ipi_dev_node_list);
static const struct sbi_ipi_event_ops *ipi_ops_array[SBI_IPI_EVENT_MAX];
static int sbi_ipi_send(struct sbi_scratch *scratch, u32 remote_hartindex,
@@ -248,7 +256,7 @@ void sbi_ipi_process(void)
sbi_scratch_offset_ptr(scratch, ipi_data_off);
sbi_pmu_ctr_incr_fw(SBI_PMU_FW_IPI_RECVD);
- sbi_ipi_raw_clear();
+ sbi_ipi_raw_clear(false);
ipi_type = atomic_raw_xchg_ulong(&ipi_data->ipi_type, 0);
ipi_event = 0;
@@ -283,10 +291,19 @@ int sbi_ipi_raw_send(u32 hartindex)
return 0;
}
-void sbi_ipi_raw_clear(void)
+void sbi_ipi_raw_clear(bool all_devices)
{
- if (ipi_dev && ipi_dev->ipi_clear)
- ipi_dev->ipi_clear();
+ struct sbi_ipi_device_node *entry;
+
+ if (all_devices) {
+ sbi_list_for_each_entry(entry, &ipi_dev_node_list, head) {
+ if (entry->dev->ipi_clear)
+ entry->dev->ipi_clear();
+ }
+ } else {
+ if (ipi_dev && ipi_dev->ipi_clear)
+ ipi_dev->ipi_clear();
+ }
/*
* Ensure that memory or MMIO writes after this
@@ -305,12 +322,22 @@ const struct sbi_ipi_device *sbi_ipi_get_device(void)
return ipi_dev;
}
-void sbi_ipi_set_device(const struct sbi_ipi_device *dev)
+void sbi_ipi_add_device(const struct sbi_ipi_device *dev)
{
- if (!dev || ipi_dev)
+ struct sbi_ipi_device_node *entry;
+
+ if (!dev)
+ return;
+
+ entry = sbi_zalloc(sizeof(*entry));
+ if (!entry)
return;
+ SBI_INIT_LIST_HEAD(&entry->head);
+ entry->dev = dev;
+ sbi_list_add_tail(&entry->head, &ipi_dev_node_list);
- ipi_dev = dev;
+ if (!ipi_dev || ipi_dev->rating < dev->rating)
+ ipi_dev = dev;
}
int sbi_ipi_init(struct sbi_scratch *scratch, bool cold_boot)
@@ -347,7 +374,7 @@ int sbi_ipi_init(struct sbi_scratch *scratch, bool cold_boot)
ipi_data->ipi_type = 0x00;
/* Clear any pending IPIs for the current hart */
- sbi_ipi_raw_clear();
+ sbi_ipi_raw_clear(true);
/* Enable software interrupts */
csr_set(CSR_MIE, MIP_MSIP);
diff --git a/lib/utils/ipi/aclint_mswi.c b/lib/utils/ipi/aclint_mswi.c
index 9e55078a..d4acacf0 100644
--- a/lib/utils/ipi/aclint_mswi.c
+++ b/lib/utils/ipi/aclint_mswi.c
@@ -62,6 +62,7 @@ static void mswi_ipi_clear(void)
static struct sbi_ipi_device aclint_mswi = {
.name = "aclint-mswi",
+ .rating = 100,
.ipi_send = mswi_ipi_send,
.ipi_clear = mswi_ipi_clear
};
@@ -106,7 +107,7 @@ int aclint_mswi_cold_init(struct aclint_mswi_data *mswi)
if (rc)
return rc;
- sbi_ipi_set_device(&aclint_mswi);
+ sbi_ipi_add_device(&aclint_mswi);
return 0;
}
diff --git a/lib/utils/ipi/andes_plicsw.c b/lib/utils/ipi/andes_plicsw.c
index 5d085d85..3621e3cb 100644
--- a/lib/utils/ipi/andes_plicsw.c
+++ b/lib/utils/ipi/andes_plicsw.c
@@ -61,6 +61,7 @@ static void plicsw_ipi_clear(void)
static struct sbi_ipi_device plicsw_ipi = {
.name = "andes_plicsw",
+ .rating = 200,
.ipi_send = plicsw_ipi_send,
.ipi_clear = plicsw_ipi_clear
};
@@ -99,7 +100,7 @@ int plicsw_cold_ipi_init(struct plicsw_data *plicsw)
if (rc)
return rc;
- sbi_ipi_set_device(&plicsw_ipi);
+ sbi_ipi_add_device(&plicsw_ipi);
return 0;
}
diff --git a/lib/utils/irqchip/imsic.c b/lib/utils/irqchip/imsic.c
index 057b9fa7..d72ef794 100644
--- a/lib/utils/irqchip/imsic.c
+++ b/lib/utils/irqchip/imsic.c
@@ -199,6 +199,7 @@ static void imsic_ipi_send(u32 hart_index)
static struct sbi_ipi_device imsic_ipi_device = {
.name = "aia-imsic",
+ .rating = 300,
.ipi_send = imsic_ipi_send
};
@@ -393,7 +394,7 @@ int imsic_cold_irqchip_init(struct imsic_data *imsic)
sbi_irqchip_add_device(&imsic_device);
/* Register IPI device */
- sbi_ipi_set_device(&imsic_ipi_device);
+ sbi_ipi_add_device(&imsic_ipi_device);
return 0;
}
--
2.43.0
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 2/3] include: sbi: Remove platform specific IPI init
2025-09-04 5:24 [PATCH v3 0/3] OpenSBI IPI device rating Anup Patel
2025-09-04 5:24 ` [PATCH v3 1/3] lib: sbi: Introduce " Anup Patel
@ 2025-09-04 5:24 ` Anup Patel
2025-09-04 5:24 ` [PATCH v3 3/3] lib: utils/ipi: Convert IPI drivers as early drivers Anup Patel
2025-09-16 4:27 ` [PATCH v3 0/3] OpenSBI IPI device rating Anup Patel
3 siblings, 0 replies; 5+ messages in thread
From: Anup Patel @ 2025-09-04 5:24 UTC (permalink / raw)
To: Atish Patra; +Cc: Anup Patel, Anup Patel, opensbi, Nick Hu, Andrew Jones
The platform specfic IPI init is not need anymore because using
IPI device rating multiple IPI devices can be registered in any
order as part of the platform specific early init.
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Reviewed-by: Samuel Holland <samuel.holland@sifive.com>
Tested-by: Nick Hu <nick.hu@sifive.com>
---
include/sbi/sbi_platform.h | 17 --------------
lib/sbi/sbi_ipi.c | 5 ----
platform/fpga/ariane/platform.c | 29 +++++++++++-------------
platform/generic/openhwgroup/openpiton.c | 23 ++++++++-----------
platform/generic/platform.c | 5 +++-
platform/kendryte/k210/platform.c | 17 +++++++-------
platform/nuclei/ux600/platform.c | 15 ++++++------
platform/template/platform.c | 20 +++++++---------
8 files changed, 49 insertions(+), 82 deletions(-)
diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h
index c6d30080..d75c12de 100644
--- a/include/sbi/sbi_platform.h
+++ b/include/sbi/sbi_platform.h
@@ -116,9 +116,6 @@ struct sbi_platform_operations {
/** Initialize the platform interrupt controller during cold boot */
int (*irqchip_init)(void);
- /** Initialize IPI during cold boot */
- int (*ipi_init)(void);
-
/** Get tlb flush limit value **/
u64 (*get_tlbr_flush_limit)(void);
@@ -528,20 +525,6 @@ static inline int sbi_platform_irqchip_init(const struct sbi_platform *plat)
return 0;
}
-/**
- * Initialize the platform IPI support during cold boot
- *
- * @param plat pointer to struct sbi_platform
- *
- * @return 0 on success and negative error code on failure
- */
-static inline int sbi_platform_ipi_init(const struct sbi_platform *plat)
-{
- if (plat && sbi_platform_ops(plat)->ipi_init)
- return sbi_platform_ops(plat)->ipi_init();
- return 0;
-}
-
/**
* Initialize the platform timer during cold boot
*
diff --git a/lib/sbi/sbi_ipi.c b/lib/sbi/sbi_ipi.c
index 93018fe6..ed9ccffb 100644
--- a/lib/sbi/sbi_ipi.c
+++ b/lib/sbi/sbi_ipi.c
@@ -357,11 +357,6 @@ int sbi_ipi_init(struct sbi_scratch *scratch, bool cold_boot)
if (ret < 0)
return ret;
ipi_halt_event = ret;
-
- /* Initialize platform IPI support */
- ret = sbi_platform_ipi_init(sbi_platform_ptr(scratch));
- if (ret)
- return ret;
} else {
if (!ipi_data_off)
return SBI_ENOMEM;
diff --git a/platform/fpga/ariane/platform.c b/platform/fpga/ariane/platform.c
index 4bc1c5be..1b6b052f 100644
--- a/platform/fpga/ariane/platform.c
+++ b/platform/fpga/ariane/platform.c
@@ -71,16 +71,22 @@ static struct aclint_mtimer_data mtimer = {
*/
static int ariane_early_init(bool cold_boot)
{
+ int rc;
+
if (!cold_boot)
return 0;
- return uart8250_init(ARIANE_UART_ADDR,
- ARIANE_UART_FREQ,
- ARIANE_UART_BAUDRATE,
- ARIANE_UART_REG_SHIFT,
- ARIANE_UART_REG_WIDTH,
- ARIANE_UART_REG_OFFSET,
- ARIANE_UART_CAPS);
+ rc = uart8250_init(ARIANE_UART_ADDR,
+ ARIANE_UART_FREQ,
+ ARIANE_UART_BAUDRATE,
+ ARIANE_UART_REG_SHIFT,
+ ARIANE_UART_REG_WIDTH,
+ ARIANE_UART_REG_OFFSET,
+ ARIANE_UART_CAPS);
+ if (rc)
+ return rc;
+
+ return aclint_mswi_cold_init(&mswi);
}
/*
@@ -107,14 +113,6 @@ static int ariane_irqchip_init(void)
return plic_cold_irqchip_init(&plic);
}
-/*
- * Initialize IPI during cold boot.
- */
-static int ariane_ipi_init(void)
-{
- return aclint_mswi_cold_init(&mswi);
-}
-
/*
* Initialize ariane timer during cold boot.
*/
@@ -130,7 +128,6 @@ const struct sbi_platform_operations platform_ops = {
.early_init = ariane_early_init,
.final_init = ariane_final_init,
.irqchip_init = ariane_irqchip_init,
- .ipi_init = ariane_ipi_init,
.timer_init = ariane_timer_init,
};
diff --git a/platform/generic/openhwgroup/openpiton.c b/platform/generic/openhwgroup/openpiton.c
index 9be7f9a4..3be66de6 100644
--- a/platform/generic/openhwgroup/openpiton.c
+++ b/platform/generic/openhwgroup/openpiton.c
@@ -104,11 +104,15 @@ static int openpiton_early_init(bool cold_boot)
ACLINT_DEFAULT_MTIMECMP_OFFSET;
}
- return uart8250_init(uart.addr, uart.freq, uart.baud,
- OPENPITON_DEFAULT_UART_REG_SHIFT,
- OPENPITON_DEFAULT_UART_REG_WIDTH,
- OPENPITON_DEFAULT_UART_REG_OFFSET,
- OPENPITON_DEFAULT_UART_CAPS);
+ rc = uart8250_init(uart.addr, uart.freq, uart.baud,
+ OPENPITON_DEFAULT_UART_REG_SHIFT,
+ OPENPITON_DEFAULT_UART_REG_WIDTH,
+ OPENPITON_DEFAULT_UART_REG_OFFSET,
+ OPENPITON_DEFAULT_UART_CAPS);
+ if (rc)
+ return rc;
+
+ return aclint_mswi_cold_init(&mswi);
}
/*
@@ -135,14 +139,6 @@ static int openpiton_irqchip_init(void)
return plic_cold_irqchip_init(&plic);
}
-/*
- * Initialize IPI during cold boot.
- */
-static int openpiton_ipi_init(void)
-{
- return aclint_mswi_cold_init(&mswi);
-}
-
/*
* Initialize openpiton timer during cold boot.
*/
@@ -155,7 +151,6 @@ static int openhwgroup_openpiton_platform_init(const void *fdt, int nodeoff, con
{
generic_platform_ops.early_init = openpiton_early_init;
generic_platform_ops.timer_init = openpiton_timer_init;
- generic_platform_ops.ipi_init = openpiton_ipi_init;
generic_platform_ops.irqchip_init = openpiton_irqchip_init;
generic_platform_ops.final_init = openpiton_final_init;
diff --git a/platform/generic/platform.c b/platform/generic/platform.c
index 889d6905..8ba6bc11 100644
--- a/platform/generic/platform.c
+++ b/platform/generic/platform.c
@@ -229,6 +229,10 @@ int generic_early_init(bool cold_boot)
return rc;
fdt_driver_init_all(fdt, fdt_early_drivers);
+
+ rc = fdt_ipi_init();
+ if (rc)
+ return rc;
}
return 0;
@@ -337,7 +341,6 @@ struct sbi_platform_operations generic_platform_ops = {
.extensions_init = generic_extensions_init,
.domains_init = generic_domains_init,
.irqchip_init = fdt_irqchip_init,
- .ipi_init = fdt_ipi_init,
.pmu_init = generic_pmu_init,
.pmu_xlate_to_mhpmevent = generic_pmu_xlate_to_mhpmevent,
.get_tlbr_flush_limit = generic_tlbr_flush_limit,
diff --git a/platform/kendryte/k210/platform.c b/platform/kendryte/k210/platform.c
index aff133c6..65f5d497 100644
--- a/platform/kendryte/k210/platform.c
+++ b/platform/kendryte/k210/platform.c
@@ -112,13 +112,19 @@ static struct sbi_system_reset_device k210_reset = {
static int k210_early_init(bool cold_boot)
{
+ int rc;
+
if (!cold_boot)
return 0;
sbi_system_reset_add_device(&k210_reset);
- return sifive_uart_init(K210_UART_BASE_ADDR, k210_get_clk_freq(),
- K210_UART_BAUDRATE);
+ rc = sifive_uart_init(K210_UART_BASE_ADDR, k210_get_clk_freq(),
+ K210_UART_BAUDRATE);
+ if (rc)
+ return rc;
+
+ return aclint_mswi_cold_init(&mswi);
}
static int k210_final_init(bool cold_boot)
@@ -141,11 +147,6 @@ static int k210_irqchip_init(void)
return plic_cold_irqchip_init(&plic);
}
-static int k210_ipi_init(void)
-{
- return aclint_mswi_cold_init(&mswi);
-}
-
static int k210_timer_init(void)
{
return aclint_mtimer_cold_init(&mtimer, NULL);
@@ -158,8 +159,6 @@ const struct sbi_platform_operations platform_ops = {
.irqchip_init = k210_irqchip_init,
- .ipi_init = k210_ipi_init,
-
.timer_init = k210_timer_init,
};
diff --git a/platform/nuclei/ux600/platform.c b/platform/nuclei/ux600/platform.c
index 1b67b644..14fbaeb6 100644
--- a/platform/nuclei/ux600/platform.c
+++ b/platform/nuclei/ux600/platform.c
@@ -151,6 +151,7 @@ static struct sbi_system_reset_device ux600_reset = {
static int ux600_early_init(bool cold_boot)
{
u32 regval;
+ int rc;
if (!cold_boot)
return 0;
@@ -168,8 +169,12 @@ static int ux600_early_init(bool cold_boot)
UX600_GPIO_IOF_UART0_MASK;
writel(regval, (void *)(UX600_GPIO_ADDR + UX600_GPIO_IOF_EN_OFS));
- return sifive_uart_init(UX600_DEBUG_UART, ux600_clk_freq,
- UX600_UART_BAUDRATE);
+ rc = sifive_uart_init(UX600_DEBUG_UART, ux600_clk_freq,
+ UX600_UART_BAUDRATE);
+ if (rc)
+ return rc;
+
+ return aclint_mswi_cold_init(&mswi);
}
static void ux600_modify_dt(void *fdt)
@@ -195,11 +200,6 @@ static int ux600_irqchip_init(void)
return plic_cold_irqchip_init(&plic);
}
-static int ux600_ipi_init(void)
-{
- return aclint_mswi_cold_init(&mswi);
-}
-
static int ux600_timer_init(void)
{
return aclint_mtimer_cold_init(&mtimer, NULL);
@@ -209,7 +209,6 @@ const struct sbi_platform_operations platform_ops = {
.early_init = ux600_early_init,
.final_init = ux600_final_init,
.irqchip_init = ux600_irqchip_init,
- .ipi_init = ux600_ipi_init,
.timer_init = ux600_timer_init,
};
diff --git a/platform/template/platform.c b/platform/template/platform.c
index 292889d2..38be1b5c 100644
--- a/platform/template/platform.c
+++ b/platform/template/platform.c
@@ -70,12 +70,18 @@ static struct aclint_mtimer_data mtimer = {
*/
static int platform_early_init(bool cold_boot)
{
+ int rc;
+
if (!cold_boot)
return 0;
/* Example if the generic UART8250 driver is used */
- return uart8250_init(PLATFORM_UART_ADDR, PLATFORM_UART_INPUT_FREQ,
- PLATFORM_UART_BAUDRATE, 0, 1, 0, 0);
+ rc = uart8250_init(PLATFORM_UART_ADDR, PLATFORM_UART_INPUT_FREQ,
+ PLATFORM_UART_BAUDRATE, 0, 1, 0, 0);
+ if (rc)
+ return rc;
+
+ return aclint_mswi_cold_init(&mswi);
}
/*
@@ -95,15 +101,6 @@ static int platform_irqchip_init(void)
return plic_cold_irqchip_init(&plic);
}
-/*
- * Initialize IPI during cold boot.
- */
-static int platform_ipi_init(void)
-{
- /* Example if the generic ACLINT driver is used */
- return aclint_mswi_cold_init(&mswi);
-}
-
/*
* Initialize platform timer during cold boot.
*/
@@ -120,7 +117,6 @@ const struct sbi_platform_operations platform_ops = {
.early_init = platform_early_init,
.final_init = platform_final_init,
.irqchip_init = platform_irqchip_init,
- .ipi_init = platform_ipi_init,
.timer_init = platform_timer_init
};
const struct sbi_platform platform = {
--
2.43.0
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 3/3] lib: utils/ipi: Convert IPI drivers as early drivers
2025-09-04 5:24 [PATCH v3 0/3] OpenSBI IPI device rating Anup Patel
2025-09-04 5:24 ` [PATCH v3 1/3] lib: sbi: Introduce " Anup Patel
2025-09-04 5:24 ` [PATCH v3 2/3] include: sbi: Remove platform specific IPI init Anup Patel
@ 2025-09-04 5:24 ` Anup Patel
2025-09-16 4:27 ` [PATCH v3 0/3] OpenSBI IPI device rating Anup Patel
3 siblings, 0 replies; 5+ messages in thread
From: Anup Patel @ 2025-09-04 5:24 UTC (permalink / raw)
To: Atish Patra; +Cc: Anup Patel, Anup Patel, opensbi, Nick Hu, Andrew Jones
The fdt_ipi_init() is already called from generic_early_init() so
let's convert IPI drivers as early drivers.
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Reviewed-by: Samuel Holland <samuel.holland@sifive.com>
Tested-by: Nick Hu <nick.hu@sifive.com>
---
include/sbi_utils/ipi/fdt_ipi.h | 26 --------------------------
lib/utils/ipi/fdt_ipi.c | 22 ----------------------
lib/utils/ipi/fdt_ipi_drivers.carray | 3 ---
lib/utils/ipi/fdt_ipi_mswi.c | 2 +-
lib/utils/ipi/fdt_ipi_plicsw.c | 2 +-
lib/utils/ipi/objects.mk | 7 ++-----
platform/generic/platform.c | 5 -----
7 files changed, 4 insertions(+), 63 deletions(-)
delete mode 100644 include/sbi_utils/ipi/fdt_ipi.h
delete mode 100644 lib/utils/ipi/fdt_ipi.c
delete mode 100644 lib/utils/ipi/fdt_ipi_drivers.carray
diff --git a/include/sbi_utils/ipi/fdt_ipi.h b/include/sbi_utils/ipi/fdt_ipi.h
deleted file mode 100644
index 9b014470..00000000
--- a/include/sbi_utils/ipi/fdt_ipi.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2020 Western Digital Corporation or its affiliates.
- *
- * Authors:
- * Anup Patel <anup.patel@wdc.com>
- */
-
-#ifndef __FDT_IPI_H__
-#define __FDT_IPI_H__
-
-#include <sbi/sbi_types.h>
-#include <sbi_utils/fdt/fdt_driver.h>
-
-#ifdef CONFIG_FDT_IPI
-
-int fdt_ipi_init(void);
-
-#else
-
-static inline int fdt_ipi_init(void) { return 0; }
-
-#endif
-
-#endif
diff --git a/lib/utils/ipi/fdt_ipi.c b/lib/utils/ipi/fdt_ipi.c
deleted file mode 100644
index 644c9c1c..00000000
--- a/lib/utils/ipi/fdt_ipi.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2020 Western Digital Corporation or its affiliates.
- *
- * Authors:
- * Anup Patel <anup.patel@wdc.com>
- */
-
-#include <sbi_utils/ipi/fdt_ipi.h>
-
-/* List of FDT ipi drivers generated at compile time */
-extern const struct fdt_driver *const fdt_ipi_drivers[];
-
-int fdt_ipi_init(void)
-{
- /*
- * On some single-hart system there is no need for IPIs,
- * so do not return a failure if no device is found.
- */
- return fdt_driver_init_all(fdt_get_address(), fdt_ipi_drivers);
-}
diff --git a/lib/utils/ipi/fdt_ipi_drivers.carray b/lib/utils/ipi/fdt_ipi_drivers.carray
deleted file mode 100644
index 006b0fd9..00000000
--- a/lib/utils/ipi/fdt_ipi_drivers.carray
+++ /dev/null
@@ -1,3 +0,0 @@
-HEADER: sbi_utils/ipi/fdt_ipi.h
-TYPE: const struct fdt_driver
-NAME: fdt_ipi_drivers
diff --git a/lib/utils/ipi/fdt_ipi_mswi.c b/lib/utils/ipi/fdt_ipi_mswi.c
index aa37d0d0..20f6fbcc 100644
--- a/lib/utils/ipi/fdt_ipi_mswi.c
+++ b/lib/utils/ipi/fdt_ipi_mswi.c
@@ -9,8 +9,8 @@
#include <sbi/sbi_error.h>
#include <sbi/sbi_heap.h>
+#include <sbi_utils/fdt/fdt_driver.h>
#include <sbi_utils/fdt/fdt_helper.h>
-#include <sbi_utils/ipi/fdt_ipi.h>
#include <sbi_utils/ipi/aclint_mswi.h>
static int ipi_mswi_cold_init(const void *fdt, int nodeoff,
diff --git a/lib/utils/ipi/fdt_ipi_plicsw.c b/lib/utils/ipi/fdt_ipi_plicsw.c
index be669980..e15a6b76 100644
--- a/lib/utils/ipi/fdt_ipi_plicsw.c
+++ b/lib/utils/ipi/fdt_ipi_plicsw.c
@@ -11,8 +11,8 @@
*/
#include <sbi/riscv_io.h>
+#include <sbi_utils/fdt/fdt_driver.h>
#include <sbi_utils/fdt/fdt_helper.h>
-#include <sbi_utils/ipi/fdt_ipi.h>
#include <sbi_utils/ipi/andes_plicsw.h>
extern struct plicsw_data plicsw;
diff --git a/lib/utils/ipi/objects.mk b/lib/utils/ipi/objects.mk
index d1c94af2..9ba8affb 100644
--- a/lib/utils/ipi/objects.mk
+++ b/lib/utils/ipi/objects.mk
@@ -10,11 +10,8 @@
libsbiutils-objs-$(CONFIG_IPI_MSWI) += ipi/aclint_mswi.o
libsbiutils-objs-$(CONFIG_IPI_PLICSW) += ipi/andes_plicsw.o
-libsbiutils-objs-$(CONFIG_FDT_IPI) += ipi/fdt_ipi.o
-libsbiutils-objs-$(CONFIG_FDT_IPI) += ipi/fdt_ipi_drivers.carray.o
-
-carray-fdt_ipi_drivers-$(CONFIG_FDT_IPI_MSWI) += fdt_ipi_mswi
+carray-fdt_early_drivers-$(CONFIG_FDT_IPI_MSWI) += fdt_ipi_mswi
libsbiutils-objs-$(CONFIG_FDT_IPI_MSWI) += ipi/fdt_ipi_mswi.o
-carray-fdt_ipi_drivers-$(CONFIG_FDT_IPI_PLICSW) += fdt_ipi_plicsw
+carray-fdt_early_drivers-$(CONFIG_FDT_IPI_PLICSW) += fdt_ipi_plicsw
libsbiutils-objs-$(CONFIG_FDT_IPI_PLICSW) += ipi/fdt_ipi_plicsw.o
diff --git a/platform/generic/platform.c b/platform/generic/platform.c
index 8ba6bc11..91140958 100644
--- a/platform/generic/platform.c
+++ b/platform/generic/platform.c
@@ -22,7 +22,6 @@
#include <sbi_utils/fdt/fdt_fixup.h>
#include <sbi_utils/fdt/fdt_helper.h>
#include <sbi_utils/fdt/fdt_pmu.h>
-#include <sbi_utils/ipi/fdt_ipi.h>
#include <sbi_utils/irqchip/fdt_irqchip.h>
#include <sbi_utils/irqchip/imsic.h>
#include <sbi_utils/mpxy/fdt_mpxy.h>
@@ -229,10 +228,6 @@ int generic_early_init(bool cold_boot)
return rc;
fdt_driver_init_all(fdt, fdt_early_drivers);
-
- rc = fdt_ipi_init();
- if (rc)
- return rc;
}
return 0;
--
2.43.0
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3 0/3] OpenSBI IPI device rating
2025-09-04 5:24 [PATCH v3 0/3] OpenSBI IPI device rating Anup Patel
` (2 preceding siblings ...)
2025-09-04 5:24 ` [PATCH v3 3/3] lib: utils/ipi: Convert IPI drivers as early drivers Anup Patel
@ 2025-09-16 4:27 ` Anup Patel
3 siblings, 0 replies; 5+ messages in thread
From: Anup Patel @ 2025-09-16 4:27 UTC (permalink / raw)
To: Anup Patel; +Cc: Atish Patra, Andrew Jones, opensbi
On Thu, Sep 4, 2025 at 10:54 AM Anup Patel <apatel@ventanamicro.com> wrote:
>
> Introduce IPI device rating which further allows us to remove platform
> specific IPI init and convert IPI drivers as early drivers.
>
> These patches can also found in sbi_ipi_rating_v3 branch at:
> https://github.com/avpatel/opensbi.git
>
> Changes since v2:
> - Rename sbi_ipi_set_device() to sbi_ipi_add_device()
> in PATCH1
>
> Changes since v1:
> - Use linked-list in PATCH1 instead of array
> - Initialize aclint_msw after serial port in PATCH2
>
> Anup Patel (3):
> lib: sbi: Introduce IPI device rating
> include: sbi: Remove platform specific IPI init
> lib: utils/ipi: Convert IPI drivers as early drivers
>
> include/sbi/sbi_ipi.h | 7 +++-
> include/sbi/sbi_platform.h | 17 ---------
> include/sbi_utils/ipi/fdt_ipi.h | 26 -------------
> lib/sbi/sbi_init.c | 2 +-
> lib/sbi/sbi_ipi.c | 48 +++++++++++++++++-------
> lib/utils/ipi/aclint_mswi.c | 3 +-
> lib/utils/ipi/andes_plicsw.c | 3 +-
> lib/utils/ipi/fdt_ipi.c | 22 -----------
> lib/utils/ipi/fdt_ipi_drivers.carray | 3 --
> lib/utils/ipi/fdt_ipi_mswi.c | 2 +-
> lib/utils/ipi/fdt_ipi_plicsw.c | 2 +-
> lib/utils/ipi/objects.mk | 7 +---
> lib/utils/irqchip/imsic.c | 3 +-
> platform/fpga/ariane/platform.c | 29 +++++++-------
> platform/generic/openhwgroup/openpiton.c | 23 +++++-------
> platform/generic/platform.c | 2 -
> platform/kendryte/k210/platform.c | 17 ++++-----
> platform/nuclei/ux600/platform.c | 15 ++++----
> platform/template/platform.c | 20 ++++------
> 19 files changed, 96 insertions(+), 155 deletions(-)
> delete mode 100644 include/sbi_utils/ipi/fdt_ipi.h
> delete mode 100644 lib/utils/ipi/fdt_ipi.c
> delete mode 100644 lib/utils/ipi/fdt_ipi_drivers.carray
>
Applied this series to the riscv/opensbi repo.
Thanks,
Anup
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-09-16 4:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-04 5:24 [PATCH v3 0/3] OpenSBI IPI device rating Anup Patel
2025-09-04 5:24 ` [PATCH v3 1/3] lib: sbi: Introduce " Anup Patel
2025-09-04 5:24 ` [PATCH v3 2/3] include: sbi: Remove platform specific IPI init Anup Patel
2025-09-04 5:24 ` [PATCH v3 3/3] lib: utils/ipi: Convert IPI drivers as early drivers Anup Patel
2025-09-16 4:27 ` [PATCH v3 0/3] OpenSBI IPI device rating Anup Patel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox