Small fixups for the Zbb string functions
cover Small fixups for the Zbb string functions
From: Heiko Stuebner <[email protected]>
I didn't manage to address Andrews comments on v5 [0] in time before the series got applied, so here are two addon comments that hopefully do his comments justice now.
[0] https://lore.kernel.org/r/20230117122447.y6tdsmsxqdwf76ri@orel
Heiko Stuebner (2):
RISC-V: fix ordering of Zbb extension
RISC-V: improve string-function assembly
arch/riscv/kernel/cpu.c | 2 +- arch/riscv/lib/strcmp.S | 6 ++++-- arch/riscv/lib/strlen.S | 10 +++++----- arch/riscv/lib/strncmp.S | 16 +++++++--------- 4 files changed, 17 insertions(+), 17 deletions(-)
Signature · 1 line
2.39.0
PATCH 1/2 RISC-V: fix ordering of Zbb extension
From: Heiko Stuebner <[email protected]>
As Andrew reported,
Zb* comes after Zi* according 27.11 "Subset Naming Convention"
so fix the ordering accordingly.
--- arch/riscv/kernel/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/kernel/cpu.c +1 -1
@@ -185,9 +185,9 @@ arch_initcall(riscv_cpuinfo_init);* New entries to this struct should follow the ordering rules described above. */ static struct riscv_isa_ext_data isa_ext_arr[] = { -__RISCV_ISA_EXT_DATA (zbb,RISCV_ISA_EXT_ZBB ),__RISCV_ISA_EXT_DATA (zicbom,RISCV_ISA_EXT_ZICBOM ),__RISCV_ISA_EXT_DATA (zihintpause,RISCV_ISA_EXT_ZIHINTPAUSE ), +__RISCV_ISA_EXT_DATA (zbb,RISCV_ISA_EXT_ZBB ),__RISCV_ISA_EXT_DATA (sscofpmf,RISCV_ISA_EXT_SSCOFPMF ),__RISCV_ISA_EXT_DATA (sstc,RISCV_ISA_EXT_SSTC ),__RISCV_ISA_EXT_DATA (svinval,RISCV_ISA_EXT_SVINVAL ),
Signature · 1 line
2.39.0
Re: [PATCH 1/2] RISC-V: fix ordering of Zbb extension
Hey Heiko,
Quoted 8 lines · Heiko Stuebner
From: Heiko Stuebner <[email protected]>
As Andrew reported,
Zb* comes after Zi* according 27.11 "Subset Naming Convention"
so fix the ordering accordingly.Reported-by Andrew Jones <[email protected]>Signed-off-by Heiko Stuebner <[email protected]>
The whole "getting it wrong immediately after fixing it up" ;)
Quoted 19 lines
---
arch/riscv/kernel/cpu.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)arch/riscv/kernel/cpu.c +1
-1@@ -185,9 +185,9 @@ arch_initcall(riscv_cpuinfo_init);* New entries to this struct should follow the ordering rules described above. */ static struct riscv_isa_ext_data isa_ext_arr[] = { -__RISCV_ISA_EXT_DATA (zbb,RISCV_ISA_EXT_ZBB ),__RISCV_ISA_EXT_DATA (zicbom,RISCV_ISA_EXT_ZICBOM ),__RISCV_ISA_EXT_DATA (zihintpause,RISCV_ISA_EXT_ZIHINTPAUSE ), +__RISCV_ISA_EXT_DATA (zbb,RISCV_ISA_EXT_ZBB ),__RISCV_ISA_EXT_DATA (sscofpmf,RISCV_ISA_EXT_SSCOFPMF ),__RISCV_ISA_EXT_DATA (sstc,RISCV_ISA_EXT_SSTC ),__RISCV_ISA_EXT_DATA (svinval,RISCV_ISA_EXT_SVINVAL ),
Re: [PATCH 1/2] RISC-V: fix ordering of Zbb extension
Am Donnerstag, 9. Februar 2023, 00:20:10 CET schrieb Conor Dooley:
Quoted 9 lines
Hey Heiko,
Quoted 6 lines · Heiko Stuebner
From: Heiko Stuebner <[email protected]>
As Andrew reported,
Zb* comes after Zi* according 27.11 "Subset Naming Convention"
so fix the ordering accordingly.
Quoted 6 lines
Quoted 2 lines
Reported-by Andrew Jones <[email protected]>Signed-off-by Heiko Stuebner <[email protected]>The whole "getting it wrong immediately after fixing it up" ;)
Reviewed-by Conor Dooley <[email protected]>
I'm still hopefully that I'll learn at some point that "b" comes after "i", at least with riscv extensions. Decades of sorting the other way around are hard to break :-D .
Quoted 20 lines
Quoted 19 lines
---
arch/riscv/kernel/cpu.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)arch/riscv/kernel/cpu.c +1
-1@@ -185,9 +185,9 @@ arch_initcall(riscv_cpuinfo_init);* New entries to this struct should follow the ordering rules described above. */ static struct riscv_isa_ext_data isa_ext_arr[] = { -__RISCV_ISA_EXT_DATA (zbb,RISCV_ISA_EXT_ZBB ),__RISCV_ISA_EXT_DATA (zicbom,RISCV_ISA_EXT_ZICBOM ),__RISCV_ISA_EXT_DATA (zihintpause,RISCV_ISA_EXT_ZIHINTPAUSE ), +__RISCV_ISA_EXT_DATA (zbb,RISCV_ISA_EXT_ZBB ),__RISCV_ISA_EXT_DATA (sscofpmf,RISCV_ISA_EXT_SSCOFPMF ),__RISCV_ISA_EXT_DATA (sstc,RISCV_ISA_EXT_SSTC ),__RISCV_ISA_EXT_DATA (svinval,RISCV_ISA_EXT_SVINVAL ),
Re: [PATCH 1/2] RISC-V: fix ordering of Zbb extension
In reply to Conor DooleyQuoted 5 lines · Conor Dooley
Hey Heiko,
Quoted 2 lines · Heiko Stuebner
From: Heiko Stuebner <[email protected]>
Quoted 8 lines
Quoted 6 lines
As Andrew reported,
Zb* comes after Zi* according 27.11 "Subset Naming Convention"
so fix the ordering accordingly.Reported-by Andrew Jones <[email protected]>Signed-off-by Heiko Stuebner <[email protected]>The whole "getting it wrong immediately after fixing it up" ;)
Hi Conor,
Do you know any patchwork savvy people that could whip up a check for this array? :-)
drew
Re: [PATCH 1/2] RISC-V: fix ordering of Zbb extension
Quoted 13 lines · Andrew Jones
Quoted 12 lines · Conor Dooley
Hey Heiko,
Quoted 8 lines · Heiko Stuebner
From: Heiko Stuebner <[email protected]>
As Andrew reported,
Zb* comes after Zi* according 27.11 "Subset Naming Convention"
so fix the ordering accordingly.Reported-by Andrew Jones <[email protected]>Signed-off-by Heiko Stuebner <[email protected]>
Quoted 6 lines
Quoted 1 line
The whole "getting it wrong immediately after fixing it up" ;)
Hi Conor,
Do you know any patchwork savvy people that could whip up a check for this array? :-)
Maybe that is more of a checkpatch type thing?
Either way, I'll put it on the todo list I suppose!
Re: [PATCH 1/2] RISC-V: fix ordering of Zbb extension
Quoted 14 lines · Conor Dooley
Quoted 13 lines · Andrew Jones
Quoted 12 lines · Conor Dooley
Hey Heiko,
Quoted 8 lines · Heiko Stuebner
From: Heiko Stuebner <[email protected]>
As Andrew reported,
Zb* comes after Zi* according 27.11 "Subset Naming Convention"
so fix the ordering accordingly.Reported-by Andrew Jones <[email protected]>Signed-off-by Heiko Stuebner <[email protected]>
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
The whole "getting it wrong immediately after fixing it up" ;)
Hi Conor,
Do you know any patchwork savvy people that could whip up a check for this array? :-)
Maybe that is more of a checkpatch type thing?
I think this is too specific for general checkpatch. I once proposed on the KVM mailing list that checkpatch should gain support for plugins, allowing specific directories to provide a .checkpatch script, or whatever, where it puts its own checks. I never followed-up by actually proposing that to checkpatch maintainers though.
Quoted 2 lines
Either way, I'll put it on the todo list I suppose!
In the absence of checkpatch plugins, I think subsystem-specific patch management tools, like patchwork, are the next best place to put specific checks. But, I agree it's a bit late. It'd be better if the developers could run the checks themselves before posting.
Thanks,
drew
Re: [PATCH 1/2] RISC-V: fix ordering of Zbb extension
In reply to Heiko StuebnerQuoted 30 lines · Heiko Stuebner
From: Heiko Stuebner <[email protected]>
As Andrew reported,
Zb* comes after Zi* according 27.11 "Subset Naming Convention"
so fix the ordering accordingly.Reported-by Andrew Jones <[email protected]>Signed-off-by Heiko Stuebner <[email protected]>--- arch/riscv/kernel/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/riscv/kernel/cpu.c +1
-1@@ -185,9 +185,9 @@ arch_initcall(riscv_cpuinfo_init);* New entries to this struct should follow the ordering rules described above. */ static struct riscv_isa_ext_data isa_ext_arr[] = { -__RISCV_ISA_EXT_DATA (zbb,RISCV_ISA_EXT_ZBB ),__RISCV_ISA_EXT_DATA (zicbom,RISCV_ISA_EXT_ZICBOM ),__RISCV_ISA_EXT_DATA (zihintpause,RISCV_ISA_EXT_ZIHINTPAUSE ), +__RISCV_ISA_EXT_DATA (zbb,RISCV_ISA_EXT_ZBB ),__RISCV_ISA_EXT_DATA (sscofpmf,RISCV_ISA_EXT_SSCOFPMF ),__RISCV_ISA_EXT_DATA (sstc,RISCV_ISA_EXT_SSTC ),__RISCV_ISA_EXT_DATA (svinval,RISCV_ISA_EXT_SVINVAL ),Signature · 1 line
2.39.0
PATCH 2/2 RISC-V: improve string-function assembly
In reply to Heiko StuebnerFrom: Heiko Stuebner <[email protected]>
Adapt the suggestions for the assembly string functions that Andrew suggested but that I didn't manage to include into the series that got applied.
This includes improvements to two comments, removal of unneeded labels and moving one instruction slightly higher to contradict an explanatory comment.
--- arch/riscv/lib/strcmp.S | 6 ++++-- arch/riscv/lib/strlen.S | 10 +++++----- arch/riscv/lib/strncmp.S | 16 +++++++--------- 3 files changed, 16 insertions(+), 16 deletions(-)
arch/riscv/lib/strcmp.S +4 -2
@@ -40,7 +40,9 @@ SYM_FUNC_START(strcmp) ret /* - * Variant of strcmp using the ZBB extension if available + * Variant of strcmp using the ZBB extension if available. + * The code was published as part of the bitmanip manual + * in Appendix A. */ #ifdef CONFIG_RISCV_ISA_ZBB strcmp_zbb:
@@ -57,7 +59,7 @@ strcmp_zbb: * a1 - string2 * * Clobbers - * t0, t1, t2, t3, t4, t5 + * t0, t1, t2, t3, t4 */ or t2, a0, a1
arch/riscv/lib/strlen.S +5 -5
@@ -96,7 +96,7 @@ strlen_zbb: * of valid bytes in this chunk. */ srli a0, t1, 3 - bgtu t3, a0, 3f + bgtu t3, a0, 2f /* Prepare for the word comparison loop. */ addi t2, t0, SZREG
@@ -112,20 +112,20 @@ strlen_zbb: addi t0, t0, SZREG orc.b t1, t1 beq t1, t3, 1b -2: + not t1, t1 CZ t1, t1 + srli t1, t1, 3 - /* Get number of processed words. */ + /* Get number of processed bytes. */ sub t2, t0, t2 /* Add number of characters in the first word. */ add a0, a0, t2 - srli t1, t1, 3 /* Add number of characters in the last word. */ add a0, a0, t1 -3: +2: ret .option pop
arch/riscv/lib/strncmp.S +7 -9
@@ -70,7 +70,7 @@ strncmp_zbb: li t5, -1 and t2, t2, SZREG-1 add t4, a0, a2 - bnez t2, 4f + bnez t2, 3f /* Adjust limit for fast-path. */ andi t6, t4, -SZREG
@@ -114,23 +114,21 @@ strncmp_zbb: ret /* Simple loop for misaligned strings. */ -3: - /* Restore limit for slow-path. */ .p2align 3 -4: - bge a0, t4, 6f +3: + bge a0, t4, 5f lbu t0, 0(a0) lbu t1, 0(a1) addi a0, a0, 1 addi a1, a1, 1 - bne t0, t1, 5f - bnez t0, 4b + bne t0, t1, 4f + bnez t0, 3b -5: +4: sub a0, t0, t1 ret -6: +5: li a0, 0 ret
Signature · 1 line
2.39.0
Re: [PATCH 2/2] RISC-V: improve string-function assembly
Quoted 10 lines · Heiko Stuebner
From: Heiko Stuebner <[email protected]>
Adapt the suggestions for the assembly string functions that Andrew suggested but that I didn't manage to include into the series that got applied.
This includes improvements to two comments, removal of unneeded labels and moving one instruction slightly higher to contradict an explanatory comment.
Quoted 8 lines
Suggested-by Andrew Jones <[email protected]>Signed-off-by Heiko Stuebner <[email protected]>--- arch/riscv/lib/strcmp.S | 6 ++++-- arch/riscv/lib/strlen.S | 10 +++++----- arch/riscv/lib/strncmp.S | 16 +++++++--------- 3 files changed, 16 insertions(+), 16 deletions(-)
Quoted 5 lines · Heiko Stuebner
From: Heiko Stuebner <[email protected]>
I didn't manage to address Andrews comments on v5 [0] in time before the series got applied, so here are two addon comments that hopefully do his comments justice now.
Running this on my jh7110 at the moment, so I suppose this is:
;)
This series was applied to riscv/linux.git (for-next) by Palmer Dabbelt <[email protected]>:
Hello:
This series was applied to riscv/linux.git (for-next) by Palmer Dabbelt <[email protected]>:
Quoted 8 lines · On Wed, 8 Feb 2023 23:53:26 +0100 you wrote:
From: Heiko Stuebner <[email protected]>
I didn't manage to address Andrews comments on v5 [0] in time before the series got applied, so here are two addon comments that hopefully do his comments justice now.
[...]
Here is the summary with links:
- [1/2] RISC-V: fix ordering of Zbb extension
https://git.kernel.org/riscv/c/1eac28201ac0
- [2/2] RISC-V: improve string-function assembly (no matching commit)
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Palmer Dabbelt
AppliedRe: (subset) [PATCH 0/2] Small fixups for the Zbb string functions
In reply to Heiko StuebnerQuoted 8 lines · Heiko Stuebner
From: Heiko Stuebner <[email protected]>
I didn't manage to address Andrews comments on v5 [0] in time before the series got applied, so here are two addon comments that hopefully do his comments justice now.
[...]
Applied, thanks!
[2/2] RISC-V: improve string-function assembly
https://git.kernel.org/palmer/c/6934cf8a3e0b
Best regards,
Signature · 1 line
Palmer Dabbelt <[email protected]>
This series was applied to riscv/linux.git (for-next) by Palmer Dabbelt <[email protected]>:
Hello:
This series was applied to riscv/linux.git (for-next) by Palmer Dabbelt <[email protected]>:
Quoted 8 lines · On Wed, 8 Feb 2023 23:53:26 +0100 you wrote:
From: Heiko Stuebner <[email protected]>
I didn't manage to address Andrews comments on v5 [0] in time before the series got applied, so here are two addon comments that hopefully do his comments justice now.
[...]
Here is the summary with links:
- [1/2] RISC-V: fix ordering of Zbb extension (no matching commit)
- [2/2] RISC-V: improve string-function assembly
https://git.kernel.org/riscv/c/6934cf8a3e0b
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html