Re: [PATCH] LoongArch: Handle fp, lsx, lasx and lbt assembly symbols
From: Huacai Chen
Date: Sat Apr 12 2025 - 22:17:56 EST
Hi, Tiezhu,
On Fri, Apr 11, 2025 at 10:47 AM Tiezhu Yang <yangtiezhu@xxxxxxxxxxx> wrote:
>
> On 04/09/2025 12:12 AM, Wentao Guan wrote:
> > Hello Yang,
> >
> > I don`t know why change it defination remove "asmlinkage",
> > why not explain it in commit message?
>
> $ grep -rnw "define asmlinkage" .
> ./arch/x86/include/asm/linkage.h:20:#define asmlinkage CPP_ASMLINKAGE
> __attribute__((regparm(0)))
> ./include/linux/linkage.h:22:#define asmlinkage CPP_ASMLINKAGE
>
> include/linux/linkage.h
>
> #ifdef __cplusplus
> #define CPP_ASMLINKAGE extern "C"
> #else
> #define CPP_ASMLINKAGE
> #endif
>
> #ifndef asmlinkage
> #define asmlinkage CPP_ASMLINKAGE
> #endif
>
> So for LoongArch, asmlinkage means extern "C" or NULL, there is no
> need to use asmlinkage for these prototypes because they are not put
> in uapi headers, that is to say, they will be called and built only
> by C compiler rather than C++ compiler, so asmlinkage is actually
> NULL in this case.
>
> Furthermore, there are no asmlinkage for the other exist prototypes
> such as _save_fp, _restore_fp in arch/loongarch/include/asm/fpu.h,
> so in my opinion, just keep them consistent.
>
> But according to Documentation/process/coding-style.rst, it seems
> asmlinkage should be used.
>
> "Large, non-trivial assembly functions should go in .S files, with
> corresponding
> C prototypes defined in C header files. The C prototypes for assembly
> functions should use ``asmlinkage``."
>
> There are two ways:
> (1) no need to use asmlinkage for these new added prototypes for
> assembly functions in asm/fpu.h and asm/lbt.h to keep consistent.
>
> (2) use asmlinkage for these new added prototypes for assembly functions
> in asm/fpu.h and asm/lbt.h according to Documentation, and then add
> asmlinkage for the other exist prototypes if necessary.
I think this way is better, especially you have CCed stable, it should
really fix something.
Huacai
>
> That's up to the arch maintainer Huacai.
>
> Thanks,
> Tiezhu
>