Re: [PATCH RFC] riscv: introduce asm/swab.h

From: Ignacio Encinas Rubio
Date: Mon Mar 17 2025 - 16:29:37 EST


On 17/3/25 17:36, Alexandre Ghiti wrote:
>> We need a default implementation to fall back on, but there isn't any in
>> `asm-generic/swab.h`. Should I introduce a first patch moving
>> ___constant_swab<XX> into include/uapi/asm-generic/swab.h?
>
> Yes, that or something else to avoid the code duplication.

Thanks for double checking. I figured as much but I ended up getting a
bit confused with the include directories.

>> +#if defined(CONFIG_RISCV_ISA_ZBB) && !defined(NO_ALTERNATIVE)
>
> NO_ALTERNATIVE does not exist to my knowledge, and you don't need to check for ALTERNATIVE as alternative-macros.h will do the right thing in that case.

It's a define hardcoded into drivers/firmware/efi/libstub/Makefile. It
was introduced in [1]. It helps avoid these types of warnings [2]:

riscv64-unknown-linux-gnu-ld: warning: orphan section
`.init.alternative' from `./drivers/firmware/efi/libstub/riscv.stub.o'
being placed in section `.init.alternative'

Let me know if you think I should drop it.

[1] https://lore.kernel.org/all/20231031064553.2319688-3-xiao.w.wang@xxxxxxxxx/
[2] https://lore.kernel.org/all/DM8PR11MB5751DA69DEEAAC9B06623E0BB80FA@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/

> It would be nice to have some perf numbers too, maybe Bjorn will chime in :)
>
> Thanks for your patch, looking forward the v2,

Thank you!