ARM: Default to using optimized memset and memcpy routines
authorTom Rini <trini@konsulko.com>
Thu, 12 Jan 2017 18:16:02 +0000 (13:16 -0500)
committerTom Rini <trini@konsulko.com>
Fri, 20 Jan 2017 20:38:01 +0000 (15:38 -0500)
We have long had available optimized versions of the memset and memcpy
functions that are borrowed from the Linux kernel.  We should use these
in normal conditions as the speed wins in many workflows outweigh the
relatively minor size increase.  However, we have a number of places
where we're simply too close to size limits in SPL and must be able to
make the size vs performance trade-off in those cases.

Cc: Philippe Reynes <tremyfr@yahoo.fr>
Cc: Eric Jarrige <eric.jarrige@armadeus.org>
Cc: Heiko Schocher <hs@denx.de>
Cc: Magnus Lilja <lilja.magnus@gmail.com>
Cc: Lokesh Vutla <lokeshvutla@ti.com>
Cc: Chander Kashyap <k.chander@samsung.com>
Cc: Akshay Saraswat <akshay.s@samsung.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Stefan Roese <sr@denx.de>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Stefan Roese <sr@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
15 files changed:
arch/arm/Kconfig
arch/arm/lib/Makefile
common/init/board_init.c
configs/apf27_defconfig
configs/axm_defconfig
configs/corvus_defconfig
configs/mx31pdk_defconfig
configs/omap4_sdp4430_defconfig
configs/smartweb_defconfig
configs/smdk5250_defconfig
configs/snow_defconfig
configs/spring_defconfig
configs/taurus_defconfig
configs/x600_defconfig
examples/api/Makefile

index 80038ecb2472b71178a5dd3b3beb937dd9683867..855871c64f41785e92930aed3a304be6fe3de382 100644 (file)
@@ -128,7 +128,16 @@ config ENABLE_ARM_SOC_BOOT0_HOOK
 
 config USE_ARCH_MEMCPY
        bool "Use an assembly optimized implementation of memcpy"
-       default y if CPU_V7
+       default y
+       depends on !ARM64
+       help
+         Enable the generation of an optimized version of memcpy.
+         Such implementation may be faster under some conditions
+         but may increase the binary size.
+
+config SPL_USE_ARCH_MEMCPY
+       bool "Use an assembly optimized implementation of memcpy"
+       default y if USE_ARCH_MEMCPY
        depends on !ARM64
        help
          Enable the generation of an optimized version of memcpy.
@@ -137,7 +146,16 @@ config USE_ARCH_MEMCPY
 
 config USE_ARCH_MEMSET
        bool "Use an assembly optimized implementation of memset"
-       default y if CPU_V7
+       default y
+       depends on !ARM64
+       help
+         Enable the generation of an optimized version of memset.
+         Such implementation may be faster under some conditions
+         but may increase the binary size.
+
+config SPL_USE_ARCH_MEMSET
+       bool "Use an assembly optimized implementation of memset"
+       default y if USE_ARCH_MEMSET
        depends on !ARM64
        help
          Enable the generation of an optimized version of memset.
index 024139da25fa76a73cd67c81bb4f135ebbc4ce1a..166fa9e3dad0bf160dca4feaa62b11b0f7baddaf 100644 (file)
@@ -30,12 +30,12 @@ obj-$(CONFIG_CMD_BOOTI) += bootm.o
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
 obj-$(CONFIG_CMD_BOOTZ) += bootm.o zimage.o
 obj-$(CONFIG_SYS_L2_PL310) += cache-pl310.o
-obj-$(CONFIG_USE_ARCH_MEMSET) += memset.o
-obj-$(CONFIG_USE_ARCH_MEMCPY) += memcpy.o
 else
 obj-$(CONFIG_SPL_FRAMEWORK) += spl.o
 obj-$(CONFIG_SPL_FRAMEWORK) += zimage.o
 endif
+obj-$(CONFIG_$(SPL_)USE_ARCH_MEMSET) += memset.o
+obj-$(CONFIG_$(SPL_)USE_ARCH_MEMCPY) += memcpy.o
 obj-$(CONFIG_SEMIHOSTING) += semihosting.o
 
 obj-y  += sections.o
index ef01a9aeaad901978ac9a436021a5921127fd397..193d8180a9c5aab632d7917e79ee5f35ef2aa789 100644 (file)
@@ -17,7 +17,7 @@ DECLARE_GLOBAL_DATA_PTR;
  */
 #if !defined(CONFIG_SPL_BUILD) || \
                (defined(CONFIG_SPL_LIBGENERIC_SUPPORT) && \
-               !defined(CONFIG_USE_ARCH_MEMSET))
+               !defined(CONFIG_SPL_USE_ARCH_MEMCPY))
 #define _USE_MEMCPY
 #endif
 
index 2da500aec64366d360d9e9834786a5f797aba78e..64040aa3210264122af0c2283c51ac5aa5e48ae5 100644 (file)
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+# CONFIG_SPL_USE_ARCH_MEMCPY is not set
 CONFIG_TARGET_APF27=y
 CONFIG_SPL_NAND_SUPPORT=y
 CONFIG_SPL_SERIAL_SUPPORT=y
index db988c8be7c2658f1d49855894f232d159a180cb..539e77659288ec8c9944c8446dd09da01a95b76a 100644 (file)
@@ -1,4 +1,6 @@
 CONFIG_ARM=y
+# CONFIG_SPL_USE_ARCH_MEMCPY is not set
+# CONFIG_SPL_USE_ARCH_MEMSET is not set
 CONFIG_ARCH_AT91=y
 CONFIG_TARGET_TAURUS=y
 CONFIG_SPL_GPIO_SUPPORT=y
index e33d3719b9df3986cbb2ed186df989fed433cab2..fc10399844c15a11ed68ac621f4ffb0d870b6d00 100644 (file)
@@ -1,4 +1,6 @@
 CONFIG_ARM=y
+# CONFIG_SPL_USE_ARCH_MEMCPY is not set
+# CONFIG_SPL_USE_ARCH_MEMSET is not set
 CONFIG_ARCH_AT91=y
 CONFIG_TARGET_CORVUS=y
 CONFIG_SPL_GPIO_SUPPORT=y
index bb1f121f3f4ef7d4606b59e515fcfc9c9840dc77..59084d7b65d407401629e7cc503b4f470627cb63 100644 (file)
@@ -1,4 +1,6 @@
 CONFIG_ARM=y
+# CONFIG_SPL_USE_ARCH_MEMCPY is not set
+# CONFIG_SPL_USE_ARCH_MEMSET is not set
 CONFIG_TARGET_MX31PDK=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
 CONFIG_SPL_NAND_SUPPORT=y
index f3a8b0c8d22784b9501d7bf24c6bdee87b888ea3..862f3f01a397929cdc1f360d22eed007e881788c 100644 (file)
@@ -1,4 +1,6 @@
 CONFIG_ARM=y
+# CONFIG_SPL_USE_ARCH_MEMCPY is not set
+# CONFIG_SPL_USE_ARCH_MEMSET is not set
 CONFIG_OMAP44XX=y
 # CONFIG_SPL_I2C_SUPPORT is not set
 # CONFIG_SPL_NAND_SUPPORT is not set
index eab598e41faedb71a6b7fc6374ff40175235b151..a0d31666e8d834b0874f05067fb2b4f8581f9046 100644 (file)
@@ -1,4 +1,6 @@
 CONFIG_ARM=y
+# CONFIG_SPL_USE_ARCH_MEMCPY is not set
+# CONFIG_SPL_USE_ARCH_MEMSET is not set
 CONFIG_ARCH_AT91=y
 CONFIG_TARGET_SMARTWEB=y
 CONFIG_SPL_GPIO_SUPPORT=y
index a34f915d5580d56ad3f38278634d6105462832f7..ff52a3757ab3c5fd135aa20313a17c437851a66d 100644 (file)
@@ -1,4 +1,6 @@
 CONFIG_ARM=y
+# CONFIG_SPL_USE_ARCH_MEMCPY is not set
+# CONFIG_SPL_USE_ARCH_MEMSET is not set
 CONFIG_ARCH_EXYNOS=y
 CONFIG_ARCH_EXYNOS5=y
 CONFIG_TARGET_SMDK5250=y
index 2ef3774041da703a72403b5c5d9bcf825e0f711a..d6a48cb12ca86156f02b97198ca72d369614dccd 100644 (file)
@@ -1,4 +1,6 @@
 CONFIG_ARM=y
+# CONFIG_SPL_USE_ARCH_MEMCPY is not set
+# CONFIG_SPL_USE_ARCH_MEMSET is not set
 CONFIG_ARCH_EXYNOS=y
 CONFIG_ARCH_EXYNOS5=y
 CONFIG_TARGET_SNOW=y
index 243a9ec54022dd6e3d1d6667ff58294c79d1e094..a64e648b67276a82436aab429d84c8bdc5234314 100644 (file)
@@ -1,4 +1,6 @@
 CONFIG_ARM=y
+# CONFIG_SPL_USE_ARCH_MEMCPY is not set
+# CONFIG_SPL_USE_ARCH_MEMSET is not set
 CONFIG_ARCH_EXYNOS=y
 CONFIG_ARCH_EXYNOS5=y
 CONFIG_TARGET_SPRING=y
index 793de2909f68aceac023abf150bca6de97a52e6f..0f6841b21f2eaab89262a8ada2dedf800c817c1e 100644 (file)
@@ -1,4 +1,6 @@
 CONFIG_ARM=y
+# CONFIG_SPL_USE_ARCH_MEMCPY is not set
+# CONFIG_SPL_USE_ARCH_MEMSET is not set
 CONFIG_ARCH_AT91=y
 CONFIG_TARGET_TAURUS=y
 CONFIG_SPL_GPIO_SUPPORT=y
index 4b47fc68f658ee983c186579987555ee511206fc..28e268e19b08180cd46b0e1696a1c063b113bed2 100644 (file)
@@ -1,4 +1,6 @@
 CONFIG_ARM=y
+# CONFIG_SPL_USE_ARCH_MEMCPY is not set
+# CONFIG_SPL_USE_ARCH_MEMSET is not set
 CONFIG_TARGET_X600=y
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
index 6cffee74652f944d9d9bc9ed812b4177432f98af..dab6398bab824d83f4b90674cec10ddf55ec9f64 100644 (file)
@@ -35,6 +35,9 @@ EXT_COBJ-y += lib/string.o
 EXT_COBJ-y += lib/time.o
 EXT_COBJ-y += lib/vsprintf.o
 EXT_SOBJ-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o
+ifeq ($(ARCH),arm)
+EXT_SOBJ-$(CONFIG_USE_ARCH_MEMSET) += arch/arm/lib/memset.o
+endif
 
 # Create a list of object files to be compiled
 OBJS := $(OBJ-y) $(notdir $(EXT_COBJ-y) $(EXT_SOBJ-y))
@@ -60,5 +63,5 @@ $(addprefix $(obj)/,$(notdir $(EXT_COBJ-y))): $(obj)/%.o: lib/%.c FORCE
        $(call if_changed_rule,cc_o_c)
 
 # Rule to build architecture-specific library assembly files
-$(addprefix $(obj)/,$(notdir $(EXT_SOBJ-y))): $(obj)/%.o: arch/powerpc/lib/%.S FORCE
+$(addprefix $(obj)/,$(notdir $(EXT_SOBJ-y))): $(obj)/%.o: arch/$(ARCH)/lib/%.S FORCE
        $(call if_changed_dep,as_o_S)