[PATCH] riscv: sbi: fix errno mapping for SBI_ERR_ALREADY_* error codes

Paul Sherman shermanpauldylan at gmail.com
Wed Jul 29 17:01:25 PDT 2026


Hi,

On Wed, Jul 29, 2026 at 12:43:30PM -0600, Paul Walmsley wrote:

> It looks like -EALREADY is defined as "connection already in progress," 
> which doesn't quite map to the meaning of these errors, here.
> 
> https://en.cppreference.com/cpp/error/errno_macros

You're right that the POSIX description is networking-specific. My
reasoning was that it was the closest existing errno expressing "the
requested operation was unnecessary because the target was already in
the requested state." If you think another errno is a better fit I'm
happy to respin with that mapping.

> Does this patch fix anything or change any behavior?

Yes, concretely. Today SBI_ERR_ALREADY_STARTED falls through to
-ENOTSUPP, so callers cannot distinguish "already running" from an
unsupported SBI implementation. The companion patch updates
cpu_ops_sbi.c to recognize the translated errno and treat the
"already started" response as success, which fixes the boot-hart
bringup path on many-hart multi-node platforms like SG2042 where
firmware releases all harts simultaneously before SBI HSM state
is established.

> I don't think the comment is a good idea; it creates one more artifact 
> that can get out of sync with the code.  We'd just expect people to read 
> the code, I think.

Agreed, dropping it in v2.

Thanks,
Paul



More information about the linux-riscv mailing list