[PATCH] lib: sbi: Refactor sbi_ipi_raw_send/clear interface

Anup Patel anup at brainfault.org
Sun Sep 13 21:34:15 PDT 2026


On Sun, Sep 13, 2026 at 3:31 PM Bo Gan <ganboing at gmail.com> wrote:
>
> Commit 94f0f8465622 ("lib: sbi: Extends sbi_ipi_raw_send() to use all
> available IPI devices") changed the `sbi_ipi_raw_send` interface to
> allow sending IPI via all registered IPI devices. The intention was to
> address specific use cases on some Sifive platforms, where the default
> IMSIC IPI device is not usable for hart wakeup in HSM start function.
> Sending IPI via all devices does seem to have "fixed" the problem, as
> it's utilizing the CLINT as well.
>
> However this approach is problematic:
>
>  a. If a platform has > 1 IPI devices, and all are functional for HSM
>     wakups, then multiple IPIs would be triggered for the waking hart.
>  b. These IPIs could arrive at the target hart at any time, and later
>     ones can even arrive after the hart's fully woken up, initialized
>     everything, and returned to the next privilege mode. a call to
>     `sbi_ipi_raw_clear(true)` is thus not enough to clear all pending
>     IPIs, because others are still in-flight.
>
> It's exactly what we are observing on SpacemiT's K3 platform.
> (both IMSIC and ACLINT are available).
>
> To fix the issue without making it too complicated, first, establish
> a general rule that there can be only 1 active IPI device for a IPI
> user (e.g., HSM) at any given time. If the user of IPI needs sending
> IPIs via the non-default device, specify it explicitly, instead of
> invoking all devices, and hoping some of them work. Specifically:
>
>  1. Each IPI device is assigned a type tag.
>  2. No more sending IPI via all devices. Either use
>       `sbi_ipi_raw_send` for the default IPI device, or
>       `sbi_ipi_device_raw_send` for the specific type of device
>  3. `sbi_ipi_raw_clear(true)` is now `sbi_ipi_raw_clear_all()`

Clearly, this patch has multiple changes which can be broken down
into separate patches.

Create a series with smaller patches which preserve git bisectability.

Regards,
Anup



More information about the opensbi mailing list