Skip to contentSkip to conversation

csky: Add C based string functions

PATCH New [email protected] 1 participant 1 message Apr 18, 2022

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH v3 1/1 csky: Add C based string functions

From: Matteo Croce <[email protected]>

Try to access RAM with the largest bit width possible, but without doing unaligned accesses.

A further improvement could be to use multiple read and writes as the assembly version was trying to do.

Tested on a BeagleV Starlight with a SiFive U74 core, where the improvement is noticeable.

---
Changes in V3:
- Fixup conflict Kconfig name

Changes in V2:
- Fixup compile warning with __weak definition

---
 arch/csky/Kconfig          |   8 +
 arch/csky/abiv1/Makefile   |   2 -
 arch/csky/abiv1/memcpy.S   | 347 -------------------------------------
 arch/csky/abiv1/strksyms.c |   6 -
 arch/csky/abiv2/Makefile   |   2 +
 arch/csky/abiv2/strksyms.c |   4 +-
 arch/csky/lib/Makefile     |   3 +
 arch/csky/lib/string.c     | 134 ++++++++++++++
 8 files changed, 150 insertions(+), 356 deletions(-)
 delete mode 100644 arch/csky/abiv1/memcpy.S
 delete mode 100644 arch/csky/abiv1/strksyms.c
 create mode 100644 arch/csky/lib/string.c
arch/csky/Kconfig +8 -0
index 75ef86605d69..21d72b078eef 100644
@@ -320,6 +320,14 @@ config HOTPLUG_CPU
 	  controlled through /sys/devices/system/cpu/cpu1/hotplug/target.
 
 	  Say N if you want to disable CPU hotplug.
+
+config HAVE_EFFICIENT_UNALIGNED_STRING_OPS
+	bool "Enable EFFICIENT_UNALIGNED_STRING_OPS for abiv2"
+	depends on CPU_CK807 || CPU_CK810 || CPU_CK860
+	help
+	  Say Y here to enable EFFICIENT_UNALIGNED_STRING_OPS. Some CPU models could
+	  deal with unaligned access by hardware.
+
 endmenu
 
 source "arch/csky/Kconfig.platforms"
arch/csky/abiv1/Makefile +0 -2
index 601ce3b2fb85..a4b2ade0fc67 100644
@@ -4,5 +4,3 @@ obj-y					+= bswapdi.o
 obj-y					+= bswapsi.o
 obj-y					+= cacheflush.o
 obj-y					+= mmap.o
-obj-y					+= memcpy.o
-obj-y					+= strksyms.o
arch/csky/abiv1/memcpy.S deleted +0 -347

347 lines not on this page · raw message

arch/csky/abiv1/strksyms.c deleted +0 -6
deleted file mode 100644
index c7ccbb27e8d7..000000000000
@@ -1,6 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
-
-#include <linux/module.h>
-
-EXPORT_SYMBOL(memcpy);
arch/csky/abiv2/Makefile +2 -0
index c561efa5533c..ea8005fe01a8 100644
@@ -2,9 +2,11 @@
 obj-y				+= cacheflush.o
 obj-$(CONFIG_CPU_HAS_FPU)	+= fpu.o
 obj-y				+= memcmp.o
+ifeq ($(CONFIG_HAVE_EFFICIENT_UNALIGNED_STRING_OPS), y)
 obj-y				+= memcpy.o
 obj-y				+= memmove.o
 obj-y				+= memset.o
+endif
 obj-y				+= strcmp.o
 obj-y				+= strcpy.o
 obj-y				+= strlen.o
arch/csky/abiv2/strksyms.c +3 -1
index 06da723d8202..8d1fd28c6cf9 100644
@@ -3,10 +3,12 @@
 
 #include <linux/module.h>
 
+#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_STRING_OPS
 EXPORT_SYMBOL(memcpy);
 EXPORT_SYMBOL(memset);
-EXPORT_SYMBOL(memcmp);
 EXPORT_SYMBOL(memmove);
+#endif
+EXPORT_SYMBOL(memcmp);
 EXPORT_SYMBOL(strcmp);
 EXPORT_SYMBOL(strcpy);
 EXPORT_SYMBOL(strlen);
arch/csky/lib/Makefile +3 -0
index 7fbdbb2c4d12..d0ce6e2d7ab2 100644
@@ -1,3 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 lib-y  := usercopy.o delay.o
 obj-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o
+ifneq ($(CONFIG_HAVE_EFFICIENT_UNALIGNED_STRING_OPS), y)
+lib-y  += string.o
+endif
arch/csky/lib/string.c new file +134 -0

134 lines not on this page · raw message

Signature · 1 line
2.25.1