From 079a8834bb6596d74eca5356b0d0ea0529d4f60d Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 30 Jan 2020 20:21:29 +0100 Subject: xtensa: configs: Cleanup old Kconfig IO scheduler options CONFIG_IOSCHED_DEADLINE and CONFIG_IOSCHED_CFQ are gone since commit f382fb0bcef4 ("block: remove legacy IO schedulers"). The IOSCHED_DEADLINE was replaced by MQ_IOSCHED_DEADLINE and it will be now enabled by default (along with MQ_IOSCHED_KYBER). Signed-off-by: Krzysztof Kozlowski Message-Id: <20200130192129.2677-1-krzk@kernel.org> Signed-off-by: Max Filippov --- arch/xtensa/configs/audio_kc705_defconfig | 2 -- arch/xtensa/configs/cadence_csp_defconfig | 2 -- arch/xtensa/configs/generic_kc705_defconfig | 2 -- arch/xtensa/configs/iss_defconfig | 2 -- arch/xtensa/configs/nommu_kc705_defconfig | 2 -- arch/xtensa/configs/smp_lx200_defconfig | 2 -- 6 files changed, 12 deletions(-) diff --git a/arch/xtensa/configs/audio_kc705_defconfig b/arch/xtensa/configs/audio_kc705_defconfig index b6367af71d65..eeb4c5383c83 100644 --- a/arch/xtensa/configs/audio_kc705_defconfig +++ b/arch/xtensa/configs/audio_kc705_defconfig @@ -21,8 +21,6 @@ CONFIG_PROFILING=y CONFIG_OPROFILE=y CONFIG_MODULES=y CONFIG_MODULE_UNLOAD=y -# CONFIG_IOSCHED_DEADLINE is not set -# CONFIG_IOSCHED_CFQ is not set CONFIG_XTENSA_VARIANT_CUSTOM=y CONFIG_XTENSA_VARIANT_CUSTOM_NAME="test_kc705_hifi" CONFIG_XTENSA_UNALIGNED_USER=y diff --git a/arch/xtensa/configs/cadence_csp_defconfig b/arch/xtensa/configs/cadence_csp_defconfig index f4eef6decd2a..fc240737b14d 100644 --- a/arch/xtensa/configs/cadence_csp_defconfig +++ b/arch/xtensa/configs/cadence_csp_defconfig @@ -27,8 +27,6 @@ CONFIG_MODULES=y CONFIG_MODULE_FORCE_LOAD=y CONFIG_MODULE_UNLOAD=y CONFIG_MODULE_FORCE_UNLOAD=y -# CONFIG_IOSCHED_DEADLINE is not set -# CONFIG_IOSCHED_CFQ is not set CONFIG_XTENSA_VARIANT_CUSTOM=y CONFIG_XTENSA_VARIANT_CUSTOM_NAME="csp" CONFIG_XTENSA_UNALIGNED_USER=y diff --git a/arch/xtensa/configs/generic_kc705_defconfig b/arch/xtensa/configs/generic_kc705_defconfig index c925165cf760..412f611033cc 100644 --- a/arch/xtensa/configs/generic_kc705_defconfig +++ b/arch/xtensa/configs/generic_kc705_defconfig @@ -21,8 +21,6 @@ CONFIG_PROFILING=y CONFIG_OPROFILE=y CONFIG_MODULES=y CONFIG_MODULE_UNLOAD=y -# CONFIG_IOSCHED_DEADLINE is not set -# CONFIG_IOSCHED_CFQ is not set CONFIG_XTENSA_VARIANT_DC233C=y CONFIG_XTENSA_UNALIGNED_USER=y CONFIG_PREEMPT=y diff --git a/arch/xtensa/configs/iss_defconfig b/arch/xtensa/configs/iss_defconfig index d1c01742baf4..32ce8fb068f0 100644 --- a/arch/xtensa/configs/iss_defconfig +++ b/arch/xtensa/configs/iss_defconfig @@ -1,8 +1,6 @@ CONFIG_SYSVIPC=y CONFIG_LOG_BUF_SHIFT=14 CONFIG_EXPERT=y -# CONFIG_IOSCHED_DEADLINE is not set -# CONFIG_IOSCHED_CFQ is not set # CONFIG_PCI is not set CONFIG_CMDLINE_BOOL=y CONFIG_CMDLINE="console=ttyS0,38400 eth0=tuntap,,tap0 ip=192.168.168.5:192.168.168.1 root=nfs nfsroot=192.168.168.1:/opt/montavista/pro/devkit/xtensa/linux_be/target memmap=128M@0" diff --git a/arch/xtensa/configs/nommu_kc705_defconfig b/arch/xtensa/configs/nommu_kc705_defconfig index 380e366730d5..88b2e222d4bf 100644 --- a/arch/xtensa/configs/nommu_kc705_defconfig +++ b/arch/xtensa/configs/nommu_kc705_defconfig @@ -25,8 +25,6 @@ CONFIG_KALLSYMS_ALL=y CONFIG_PERF_EVENTS=y CONFIG_MODULES=y CONFIG_MODULE_UNLOAD=y -# CONFIG_IOSCHED_DEADLINE is not set -# CONFIG_IOSCHED_CFQ is not set CONFIG_XTENSA_VARIANT_CUSTOM=y CONFIG_XTENSA_VARIANT_CUSTOM_NAME="de212" # CONFIG_XTENSA_VARIANT_MMU is not set diff --git a/arch/xtensa/configs/smp_lx200_defconfig b/arch/xtensa/configs/smp_lx200_defconfig index d46b58f34098..8b3bc92a079c 100644 --- a/arch/xtensa/configs/smp_lx200_defconfig +++ b/arch/xtensa/configs/smp_lx200_defconfig @@ -21,8 +21,6 @@ CONFIG_PROFILING=y CONFIG_OPROFILE=y CONFIG_MODULES=y CONFIG_MODULE_UNLOAD=y -# CONFIG_IOSCHED_DEADLINE is not set -# CONFIG_IOSCHED_CFQ is not set CONFIG_XTENSA_VARIANT_CUSTOM=y CONFIG_XTENSA_VARIANT_CUSTOM_NAME="test_mmuhifi_c3" CONFIG_XTENSA_UNALIGNED_USER=y -- cgit v1.2.1 From 7da04e48798461f6598d2c0ef8c1bac3e5ea1dee Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Sun, 15 Dec 2019 02:55:58 -0800 Subject: xtensa: drop set_except_vector declaration There's no implementation for set_except_vector function in the xtensa code. Drop its declaration. Signed-off-by: Max Filippov --- arch/xtensa/include/uapi/asm/setup.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/xtensa/include/uapi/asm/setup.h b/arch/xtensa/include/uapi/asm/setup.h index 57e6c210e84f..5356a5fd4d17 100644 --- a/arch/xtensa/include/uapi/asm/setup.h +++ b/arch/xtensa/include/uapi/asm/setup.h @@ -14,6 +14,4 @@ #define COMMAND_LINE_SIZE 256 -extern void set_except_vector(int n, void *addr); - #endif -- cgit v1.2.1 From e725331354924b3f720c8bb7ca579d44cc63e574 Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Sun, 15 Dec 2019 02:44:59 -0800 Subject: xtensa: clean up platform headers Drop include directives for irrelevant headers in asm/platform.h and its users. Sort remaining headers. Signed-off-by: Max Filippov --- arch/xtensa/include/asm/platform.h | 2 -- arch/xtensa/kernel/platform.c | 4 +--- arch/xtensa/platforms/iss/setup.c | 16 +++------------- arch/xtensa/platforms/xtfpga/setup.c | 1 + 4 files changed, 5 insertions(+), 18 deletions(-) diff --git a/arch/xtensa/include/asm/platform.h b/arch/xtensa/include/asm/platform.h index f2c48522c5a1..354ca942de40 100644 --- a/arch/xtensa/include/asm/platform.h +++ b/arch/xtensa/include/asm/platform.h @@ -12,8 +12,6 @@ #define _XTENSA_PLATFORM_H #include -#include - #include /* diff --git a/arch/xtensa/kernel/platform.c b/arch/xtensa/kernel/platform.c index a95ba05b0abe..25fd2cf1fe08 100644 --- a/arch/xtensa/kernel/platform.c +++ b/arch/xtensa/kernel/platform.c @@ -12,12 +12,10 @@ * Chris Zankel */ +#include #include -#include -#include #include #include -#include /* HZ */ #define _F(r,f,a,b) \ r __platform_##f a b; \ diff --git a/arch/xtensa/platforms/iss/setup.c b/arch/xtensa/platforms/iss/setup.c index e28dd53d7df5..554758823ff5 100644 --- a/arch/xtensa/platforms/iss/setup.c +++ b/arch/xtensa/platforms/iss/setup.c @@ -11,23 +11,13 @@ * Copyright 2001 - 2005 Tensilica Inc. * Copyright 2017 Cadence Design Systems Inc. */ -#include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include +#include +#include #include -#include #include #include diff --git a/arch/xtensa/platforms/xtfpga/setup.c b/arch/xtensa/platforms/xtfpga/setup.c index 829115bb381f..b7e4580d3636 100644 --- a/arch/xtensa/platforms/xtfpga/setup.c +++ b/arch/xtensa/platforms/xtfpga/setup.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include -- cgit v1.2.1 From 64716b9ec5ba3342d3a9f0464d2abb48de65b327 Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Sun, 15 Dec 2019 02:48:51 -0800 Subject: xtensa: drop empty platform_* functions from platforms Provide missing default implementation for platform_init and drop copies of default platform_init, platform_setup and platform_heartbeet from platforms/*/setup.c Signed-off-by: Max Filippov --- arch/xtensa/kernel/platform.c | 1 + arch/xtensa/platforms/iss/setup.c | 9 +-------- arch/xtensa/platforms/xtfpga/setup.c | 16 ---------------- 3 files changed, 2 insertions(+), 24 deletions(-) diff --git a/arch/xtensa/kernel/platform.c b/arch/xtensa/kernel/platform.c index 25fd2cf1fe08..ac1e0e566995 100644 --- a/arch/xtensa/kernel/platform.c +++ b/arch/xtensa/kernel/platform.c @@ -26,6 +26,7 @@ * (Please, refer to include/asm-xtensa/platform.h for more information) */ +_F(void, init, (bp_tag_t *first), { }); _F(void, setup, (char** cmd), { }); _F(void, restart, (void), { while(1); }); _F(void, halt, (void), { while(1); }); diff --git a/arch/xtensa/platforms/iss/setup.c b/arch/xtensa/platforms/iss/setup.c index 554758823ff5..ed519aee0ec8 100644 --- a/arch/xtensa/platforms/iss/setup.c +++ b/arch/xtensa/platforms/iss/setup.c @@ -23,10 +23,6 @@ #include -void __init platform_init(bp_tag_t* bootparam) -{ -} - void platform_halt(void) { pr_info(" ** Called platform_halt() **\n"); @@ -38,6 +34,7 @@ void platform_power_off(void) pr_info(" ** Called platform_power_off() **\n"); simc_exit(0); } + void platform_restart(void) { /* Flush and reset the mmu, simulate a processor reset, and @@ -46,10 +43,6 @@ void platform_restart(void) /* control never gets here */ } -void platform_heartbeat(void) -{ -} - static int iss_panic_event(struct notifier_block *this, unsigned long event, void *ptr) { diff --git a/arch/xtensa/platforms/xtfpga/setup.c b/arch/xtensa/platforms/xtfpga/setup.c index b7e4580d3636..4f7d6142d41f 100644 --- a/arch/xtensa/platforms/xtfpga/setup.c +++ b/arch/xtensa/platforms/xtfpga/setup.c @@ -57,22 +57,6 @@ void platform_restart(void) /* control never gets here */ } -void __init platform_setup(char **cmdline) -{ -} - -/* early initialization */ - -void __init platform_init(bp_tag_t *first) -{ -} - -/* Heartbeat. */ - -void platform_heartbeat(void) -{ -} - #ifdef CONFIG_XTENSA_CALIBRATE_CCOUNT void __init platform_calibrate_ccount(void) -- cgit v1.2.1 From 5b787914408ed903d087ffc3281bd6d4e93f94b5 Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Fri, 31 Jan 2020 18:15:36 -0800 Subject: xtensa: drop unused function fast_coprocessor_double fast_coprocessor_double is not used since commit c658eac628aa ("[XTENSA] Add support for configurable registers and coprocessors"). Remove it. There should be no coprocessor exceptions generated in the exception handling paths while PS.EXCM is set. Signed-off-by: Max Filippov --- arch/xtensa/kernel/coprocessor.S | 7 ------- 1 file changed, 7 deletions(-) diff --git a/arch/xtensa/kernel/coprocessor.S b/arch/xtensa/kernel/coprocessor.S index bb8e499b9900..c53ce6d8794f 100644 --- a/arch/xtensa/kernel/coprocessor.S +++ b/arch/xtensa/kernel/coprocessor.S @@ -145,13 +145,6 @@ ENDPROC(coprocessor_flush) * < VALID_DOUBLE_EXCEPTION_ADDRESS: regular exception */ -ENTRY(fast_coprocessor_double) - - wsr a0, excsave1 - call0 unrecoverable_exception - -ENDPROC(fast_coprocessor_double) - ENTRY(fast_coprocessor) /* Save remaining registers a1-a3 and SAR */ -- cgit v1.2.1 From a922b1561137fc516e7c77c478779f7d198cc9cf Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Fri, 31 Jan 2020 21:20:58 -0800 Subject: xtensa: clean up optional XCHAL_* definitions Simplify users of XCHAL_HAVE_EXTERN_REGS and XCHAL_HAVE_VECBASE and always define them as 0 if they're not defined in the variant/core.h Signed-off-by: Max Filippov --- arch/xtensa/include/asm/core.h | 8 ++++++++ arch/xtensa/include/asm/processor.h | 4 ---- arch/xtensa/include/asm/vectors.h | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/arch/xtensa/include/asm/core.h b/arch/xtensa/include/asm/core.h index 5b4acb7d1c07..5590b0f68837 100644 --- a/arch/xtensa/include/asm/core.h +++ b/arch/xtensa/include/asm/core.h @@ -10,10 +10,18 @@ #define XCHAL_HAVE_EXCLUSIVE 0 #endif +#ifndef XCHAL_HAVE_EXTERN_REGS +#define XCHAL_HAVE_EXTERN_REGS 0 +#endif + #ifndef XCHAL_HAVE_MPU #define XCHAL_HAVE_MPU 0 #endif +#ifndef XCHAL_HAVE_VECBASE +#define XCHAL_HAVE_VECBASE 0 +#endif + #ifndef XCHAL_SPANNING_WAY #define XCHAL_SPANNING_WAY 0 #endif diff --git a/arch/xtensa/include/asm/processor.h b/arch/xtensa/include/asm/processor.h index 6fa903daf2a2..7f63aca6a0d3 100644 --- a/arch/xtensa/include/asm/processor.h +++ b/arch/xtensa/include/asm/processor.h @@ -237,10 +237,6 @@ extern unsigned long get_wchan(struct task_struct *p); v; \ }) -#ifndef XCHAL_HAVE_EXTERN_REGS -#define XCHAL_HAVE_EXTERN_REGS 0 -#endif - #if XCHAL_HAVE_EXTERN_REGS static inline void set_er(unsigned long value, unsigned long addr) diff --git a/arch/xtensa/include/asm/vectors.h b/arch/xtensa/include/asm/vectors.h index fd99b25037a7..140f30762cf9 100644 --- a/arch/xtensa/include/asm/vectors.h +++ b/arch/xtensa/include/asm/vectors.h @@ -40,7 +40,7 @@ #define VECBASE_VADDR _vecbase #endif -#if defined(XCHAL_HAVE_VECBASE) && XCHAL_HAVE_VECBASE +#if XCHAL_HAVE_VECBASE #define VECTOR_VADDR(offset) (VECBASE_VADDR + offset) -- cgit v1.2.1 From 58bc6c69afe51ed19d1294ab0bb319b7df1cf75a Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Fri, 31 Jan 2020 17:59:26 -0800 Subject: arch/xtensa: fix Kconfig typos for HAVE_SMP Fix typos in xtensa Kconfig help text for HAVE_SMP. Signed-off-by: Randy Dunlap Cc: Chris Zankel Cc: Max Filippov Cc: linux-xtensa@linux-xtensa.org Message-Id: <500b2132-ea3c-a385-1f37-05664de5f1dd@infradead.org> Signed-off-by: Max Filippov --- arch/xtensa/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index 296c5324dace..06e6161797fa 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig @@ -180,11 +180,11 @@ config HAVE_SMP depends on XTENSA_VARIANT_CUSTOM select XTENSA_MX help - This option is use to indicate that the system-on-a-chip (SOC) + This option is used to indicate that the system-on-a-chip (SOC) supports Multiprocessing. Multiprocessor support implemented above the CPU core definition and currently needs to be selected manually. - Multiprocessor support in implemented with external cache and + Multiprocessor support is implemented with external cache and interrupt controllers. The MX interrupt distributer adds Interprocessor Interrupts -- cgit v1.2.1 From 50722f0bf631cfcbcce18dac6b3fb5c2b6432628 Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Fri, 31 Jan 2020 18:48:43 -0800 Subject: xtensa: move fast exception handlers close to vectors On XIP kernels it makes sense to have exception vectors and fast exception handlers together (in a fast memory). In addition, with MTD XIP support both vectors and fast exception handlers must be outside of the FLASH. Add section .exception.text and move fast exception handlers to it. Put it together with vectors when vectors are outside of the .text. Signed-off-by: Max Filippov --- arch/xtensa/include/asm/asmmacro.h | 2 ++ arch/xtensa/kernel/coprocessor.S | 5 ++--- arch/xtensa/kernel/entry.S | 18 ++++++++++++------ arch/xtensa/kernel/setup.c | 4 ++++ arch/xtensa/kernel/vectors.S | 3 ++- arch/xtensa/kernel/vmlinux.lds.S | 19 ++++++++++++++++--- 6 files changed, 38 insertions(+), 13 deletions(-) diff --git a/arch/xtensa/include/asm/asmmacro.h b/arch/xtensa/include/asm/asmmacro.h index 71a7e846bc1f..bfc89e11f469 100644 --- a/arch/xtensa/include/asm/asmmacro.h +++ b/arch/xtensa/include/asm/asmmacro.h @@ -237,4 +237,6 @@ #error Unsupported Xtensa ABI #endif +#define __XTENSA_HANDLER .section ".exception.text", "ax" + #endif /* _XTENSA_ASMMACRO_H */ diff --git a/arch/xtensa/kernel/coprocessor.S b/arch/xtensa/kernel/coprocessor.S index c53ce6d8794f..c426b846beef 100644 --- a/arch/xtensa/kernel/coprocessor.S +++ b/arch/xtensa/kernel/coprocessor.S @@ -58,6 +58,8 @@ .endif; \ .long THREAD_XTREGS_CP##x + __XTENSA_HANDLER + SAVE_CP_REGS(0) SAVE_CP_REGS(1) SAVE_CP_REGS(2) @@ -76,7 +78,6 @@ LOAD_CP_REGS(6) LOAD_CP_REGS(7) - .section ".rodata", "a" .align 4 .Lsave_cp_regs_jump_table: SAVE_CP_REGS_TAB(0) @@ -98,8 +99,6 @@ LOAD_CP_REGS_TAB(6) LOAD_CP_REGS_TAB(7) - .previous - /* * coprocessor_flush(struct thread_info*, index) * a2 a3 diff --git a/arch/xtensa/kernel/entry.S b/arch/xtensa/kernel/entry.S index be897803834a..9d2e22d9f3c3 100644 --- a/arch/xtensa/kernel/entry.S +++ b/arch/xtensa/kernel/entry.S @@ -939,6 +939,9 @@ ENDPROC(unrecoverable_exception) /* -------------------------- FAST EXCEPTION HANDLERS ----------------------- */ + __XTENSA_HANDLER + .literal_position + /* * Fast-handler for alloca exceptions * @@ -1024,7 +1027,7 @@ ENDPROC(fast_alloca) ENTRY(fast_illegal_instruction_user) rsr a0, ps - bbsi.l a0, PS_WOE_BIT, user_exception + bbsi.l a0, PS_WOE_BIT, 1f s32i a3, a2, PT_AREG3 movi a3, PS_WOE_MASK or a0, a0, a3 @@ -1033,6 +1036,8 @@ ENTRY(fast_illegal_instruction_user) l32i a0, a2, PT_AREG0 rsr a2, depc rfe +1: + call0 user_exception ENDPROC(fast_illegal_instruction_user) #endif @@ -1071,7 +1076,7 @@ ENTRY(fast_syscall_user) _beqz a0, fast_syscall_spill_registers _beqi a0, __NR_xtensa, fast_syscall_xtensa - j user_exception + call0 user_exception ENDPROC(fast_syscall_user) @@ -1762,8 +1767,8 @@ ENTRY(fast_second_level_miss) rsr a2, ps bbsi.l a2, PS_UM_BIT, 1f - j _kernel_exception -1: j _user_exception + call0 _kernel_exception +1: call0 _user_exception ENDPROC(fast_second_level_miss) @@ -1859,13 +1864,14 @@ ENTRY(fast_store_prohibited) rsr a2, ps bbsi.l a2, PS_UM_BIT, 1f - j _kernel_exception -1: j _user_exception + call0 _kernel_exception +1: call0 _user_exception ENDPROC(fast_store_prohibited) #endif /* CONFIG_MMU */ + .text /* * System Calls. * diff --git a/arch/xtensa/kernel/setup.c b/arch/xtensa/kernel/setup.c index 0f93b67c7a5a..fefbdce1db99 100644 --- a/arch/xtensa/kernel/setup.c +++ b/arch/xtensa/kernel/setup.c @@ -284,6 +284,8 @@ extern char _UserExceptionVector_text_start; extern char _UserExceptionVector_text_end; extern char _DoubleExceptionVector_text_start; extern char _DoubleExceptionVector_text_end; +extern char _exception_text_start; +extern char _exception_text_end; #if XCHAL_EXCM_LEVEL >= 2 extern char _Level2InterruptVector_text_start; extern char _Level2InterruptVector_text_end; @@ -363,6 +365,8 @@ void __init setup_arch(char **cmdline_p) mem_reserve(__pa(&_DoubleExceptionVector_text_start), __pa(&_DoubleExceptionVector_text_end)); + mem_reserve(__pa(&_exception_text_start), + __pa(&_exception_text_end)); #if XCHAL_EXCM_LEVEL >= 2 mem_reserve(__pa(&_Level2InterruptVector_text_start), __pa(&_Level2InterruptVector_text_end)); diff --git a/arch/xtensa/kernel/vectors.S b/arch/xtensa/kernel/vectors.S index 841503d3307c..95ad1e773991 100644 --- a/arch/xtensa/kernel/vectors.S +++ b/arch/xtensa/kernel/vectors.S @@ -43,6 +43,7 @@ */ #include +#include #include #include #include @@ -477,7 +478,6 @@ _DoubleExceptionVector_handle_exception: ENDPROC(_DoubleExceptionVector) - .text /* * Fixup handler for TLB miss in double exception handler for window owerflow. * We get here with windowbase set to the window that was being spilled and @@ -505,6 +505,7 @@ ENDPROC(_DoubleExceptionVector) * a3: exctable, original value in excsave1 */ + __XTENSA_HANDLER .literal_position ENTRY(window_overflow_restore_a0_fixup) diff --git a/arch/xtensa/kernel/vmlinux.lds.S b/arch/xtensa/kernel/vmlinux.lds.S index 409c05cac15e..37a3205c404c 100644 --- a/arch/xtensa/kernel/vmlinux.lds.S +++ b/arch/xtensa/kernel/vmlinux.lds.S @@ -110,6 +110,8 @@ SECTIONS SECTION_VECTOR (.KernelExceptionVector.text, KERNEL_VECTOR_VADDR) SECTION_VECTOR (.UserExceptionVector.text, USER_VECTOR_VADDR) SECTION_VECTOR (.DoubleExceptionVector.text, DOUBLEEXC_VECTOR_VADDR) + + *(.exception.text) #endif IRQENTRY_TEXT @@ -190,6 +192,8 @@ SECTIONS .DoubleExceptionVector.text); RELOCATE_ENTRY(_DebugInterruptVector_text, .DebugInterruptVector.text); + RELOCATE_ENTRY(_exception_text, + .exception.text); #endif #ifdef CONFIG_XIP_KERNEL RELOCATE_ENTRY(_xip_data, .data); @@ -282,8 +286,7 @@ SECTIONS .DoubleExceptionVector.text, DOUBLEEXC_VECTOR_VADDR, .UserExceptionVector.text) - - . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3; +#define LAST .DoubleExceptionVector.text #endif #if !defined(CONFIG_XIP_KERNEL) && defined(CONFIG_SMP) @@ -292,10 +295,20 @@ SECTIONS .SecondaryResetVector.text, RESET_VECTOR1_VADDR, .DoubleExceptionVector.text) +#undef LAST +#define LAST .SecondaryResetVector.text - . = LOADADDR(.SecondaryResetVector.text)+SIZEOF(.SecondaryResetVector.text); +#endif +#ifdef CONFIG_VECTORS_OFFSET + SECTION_VECTOR (_exception_text, + .exception.text, + , + LAST) +#undef LAST +#define LAST .exception.text #endif + . = (LOADADDR(LAST) + SIZEOF(LAST) + 3) & ~ 3; . = ALIGN(PAGE_SIZE); -- cgit v1.2.1 From 4f17664a4407004f71dc76de01c89fdb6efc0776 Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Fri, 31 Jan 2020 21:25:03 -0800 Subject: xtensa: separate SMP and XIP support There's no real dependency between SMP and XIP, allow them to be selected together. Always define 2- and 4-argument SECTION_VECTOR macros, always use 4-argument macro for the secondary reset vector and always define relocation entry for it. Signed-off-by: Max Filippov --- arch/xtensa/kernel/vmlinux.lds.S | 68 ++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/arch/xtensa/kernel/vmlinux.lds.S b/arch/xtensa/kernel/vmlinux.lds.S index 37a3205c404c..d9e547810b6c 100644 --- a/arch/xtensa/kernel/vmlinux.lds.S +++ b/arch/xtensa/kernel/vmlinux.lds.S @@ -54,8 +54,7 @@ jiffies = jiffies_64; * to description recorded in the corresponding RELOCATE_ENTRY. */ -#ifdef CONFIG_VECTORS_OFFSET -#define SECTION_VECTOR(sym, section, addr, prevsec) \ +#define SECTION_VECTOR4(sym, section, addr, prevsec) \ section addr : AT(((LOADADDR(prevsec) + SIZEOF(prevsec)) + 3) & ~ 3) \ { \ . = ALIGN(4); \ @@ -63,11 +62,10 @@ jiffies = jiffies_64; *(section) \ sym ## _end = ABSOLUTE(.); \ } -#else -#define SECTION_VECTOR(section, addr) \ + +#define SECTION_VECTOR2(section, addr) \ . = addr; \ *(section) -#endif /* * Mapping of input sections to output sections when linking. @@ -87,31 +85,31 @@ SECTIONS HEAD_TEXT #ifndef CONFIG_VECTORS_OFFSET - . = ALIGN(PAGE_SIZE); - _vecbase = .; + . = ALIGN(PAGE_SIZE); + _vecbase = .; - SECTION_VECTOR (.WindowVectors.text, WINDOW_VECTORS_VADDR) + SECTION_VECTOR2 (.WindowVectors.text, WINDOW_VECTORS_VADDR) #if XCHAL_EXCM_LEVEL >= 2 - SECTION_VECTOR (.Level2InterruptVector.text, INTLEVEL2_VECTOR_VADDR) + SECTION_VECTOR2 (.Level2InterruptVector.text, INTLEVEL2_VECTOR_VADDR) #endif #if XCHAL_EXCM_LEVEL >= 3 - SECTION_VECTOR (.Level3InterruptVector.text, INTLEVEL3_VECTOR_VADDR) + SECTION_VECTOR2 (.Level3InterruptVector.text, INTLEVEL3_VECTOR_VADDR) #endif #if XCHAL_EXCM_LEVEL >= 4 - SECTION_VECTOR (.Level4InterruptVector.text, INTLEVEL4_VECTOR_VADDR) + SECTION_VECTOR2 (.Level4InterruptVector.text, INTLEVEL4_VECTOR_VADDR) #endif #if XCHAL_EXCM_LEVEL >= 5 - SECTION_VECTOR (.Level5InterruptVector.text, INTLEVEL5_VECTOR_VADDR) + SECTION_VECTOR2 (.Level5InterruptVector.text, INTLEVEL5_VECTOR_VADDR) #endif #if XCHAL_EXCM_LEVEL >= 6 - SECTION_VECTOR (.Level6InterruptVector.text, INTLEVEL6_VECTOR_VADDR) + SECTION_VECTOR2 (.Level6InterruptVector.text, INTLEVEL6_VECTOR_VADDR) #endif - SECTION_VECTOR (.DebugInterruptVector.text, DEBUG_VECTOR_VADDR) - SECTION_VECTOR (.KernelExceptionVector.text, KERNEL_VECTOR_VADDR) - SECTION_VECTOR (.UserExceptionVector.text, USER_VECTOR_VADDR) - SECTION_VECTOR (.DoubleExceptionVector.text, DOUBLEEXC_VECTOR_VADDR) + SECTION_VECTOR2 (.DebugInterruptVector.text, DEBUG_VECTOR_VADDR) + SECTION_VECTOR2 (.KernelExceptionVector.text, KERNEL_VECTOR_VADDR) + SECTION_VECTOR2 (.UserExceptionVector.text, USER_VECTOR_VADDR) + SECTION_VECTOR2 (.DoubleExceptionVector.text, DOUBLEEXC_VECTOR_VADDR) - *(.exception.text) + *(.exception.text) #endif IRQENTRY_TEXT @@ -198,11 +196,10 @@ SECTIONS #ifdef CONFIG_XIP_KERNEL RELOCATE_ENTRY(_xip_data, .data); RELOCATE_ENTRY(_xip_init_data, .init.data); -#else +#endif #if defined(CONFIG_SMP) RELOCATE_ENTRY(_SecondaryResetVector_text, .SecondaryResetVector.text); -#endif #endif __boot_reloc_table_end = ABSOLUTE(.) ; @@ -220,21 +217,24 @@ SECTIONS . = ALIGN(4); .dummy : { LONG(0) } +#undef LAST +#define LAST .dummy + #ifdef CONFIG_VECTORS_OFFSET /* The vectors are relocated to the real position at startup time */ - SECTION_VECTOR (_WindowVectors_text, + SECTION_VECTOR4 (_WindowVectors_text, .WindowVectors.text, WINDOW_VECTORS_VADDR, .dummy) - SECTION_VECTOR (_DebugInterruptVector_text, + SECTION_VECTOR4 (_DebugInterruptVector_text, .DebugInterruptVector.text, DEBUG_VECTOR_VADDR, .WindowVectors.text) #undef LAST #define LAST .DebugInterruptVector.text #if XCHAL_EXCM_LEVEL >= 2 - SECTION_VECTOR (_Level2InterruptVector_text, + SECTION_VECTOR4 (_Level2InterruptVector_text, .Level2InterruptVector.text, INTLEVEL2_VECTOR_VADDR, LAST) @@ -242,7 +242,7 @@ SECTIONS # define LAST .Level2InterruptVector.text #endif #if XCHAL_EXCM_LEVEL >= 3 - SECTION_VECTOR (_Level3InterruptVector_text, + SECTION_VECTOR4 (_Level3InterruptVector_text, .Level3InterruptVector.text, INTLEVEL3_VECTOR_VADDR, LAST) @@ -250,7 +250,7 @@ SECTIONS # define LAST .Level3InterruptVector.text #endif #if XCHAL_EXCM_LEVEL >= 4 - SECTION_VECTOR (_Level4InterruptVector_text, + SECTION_VECTOR4 (_Level4InterruptVector_text, .Level4InterruptVector.text, INTLEVEL4_VECTOR_VADDR, LAST) @@ -258,7 +258,7 @@ SECTIONS # define LAST .Level4InterruptVector.text #endif #if XCHAL_EXCM_LEVEL >= 5 - SECTION_VECTOR (_Level5InterruptVector_text, + SECTION_VECTOR4 (_Level5InterruptVector_text, .Level5InterruptVector.text, INTLEVEL5_VECTOR_VADDR, LAST) @@ -266,41 +266,41 @@ SECTIONS # define LAST .Level5InterruptVector.text #endif #if XCHAL_EXCM_LEVEL >= 6 - SECTION_VECTOR (_Level6InterruptVector_text, + SECTION_VECTOR4 (_Level6InterruptVector_text, .Level6InterruptVector.text, INTLEVEL6_VECTOR_VADDR, LAST) # undef LAST # define LAST .Level6InterruptVector.text #endif - SECTION_VECTOR (_KernelExceptionVector_text, + SECTION_VECTOR4 (_KernelExceptionVector_text, .KernelExceptionVector.text, KERNEL_VECTOR_VADDR, LAST) #undef LAST - SECTION_VECTOR (_UserExceptionVector_text, + SECTION_VECTOR4 (_UserExceptionVector_text, .UserExceptionVector.text, USER_VECTOR_VADDR, .KernelExceptionVector.text) - SECTION_VECTOR (_DoubleExceptionVector_text, + SECTION_VECTOR4 (_DoubleExceptionVector_text, .DoubleExceptionVector.text, DOUBLEEXC_VECTOR_VADDR, .UserExceptionVector.text) #define LAST .DoubleExceptionVector.text #endif -#if !defined(CONFIG_XIP_KERNEL) && defined(CONFIG_SMP) +#if defined(CONFIG_SMP) - SECTION_VECTOR (_SecondaryResetVector_text, + SECTION_VECTOR4 (_SecondaryResetVector_text, .SecondaryResetVector.text, RESET_VECTOR1_VADDR, - .DoubleExceptionVector.text) + LAST) #undef LAST #define LAST .SecondaryResetVector.text #endif #ifdef CONFIG_VECTORS_OFFSET - SECTION_VECTOR (_exception_text, + SECTION_VECTOR4 (_exception_text, .exception.text, , LAST) -- cgit v1.2.1 From 5e4417f921238b5acf101bfcd59a7b3463fb2dbd Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Fri, 31 Jan 2020 20:11:24 -0800 Subject: xtensa: reorganize vectors placement Allow vectors to be either merged into the kernel .text or put at a fixed virtual address independently of XIP option. Drop option that puts vectors at a fixed offset from the kernel text. Add choice to Kconfig. Vectors at fixed virtual address may be useful for XIP-aware MTD support and for noMMU configurations with available IRAM. Configurations without VECBASE register must put their vectors at specific locations regardless of the selected option. All other configurations should happily use merged vectors. Signed-off-by: Max Filippov --- arch/xtensa/Kconfig | 40 +++++++++++++++++++++++++++------ arch/xtensa/configs/smp_lx200_defconfig | 1 - arch/xtensa/configs/virt_defconfig | 1 - arch/xtensa/include/asm/vectors.h | 4 ++-- arch/xtensa/kernel/setup.c | 4 ++-- arch/xtensa/kernel/vmlinux.lds.S | 21 +++++++++++------ 6 files changed, 51 insertions(+), 20 deletions(-) diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index 06e6161797fa..133385d13c02 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig @@ -572,15 +572,41 @@ config KERNEL_LOAD_ADDRESS If unsure, leave the default value here. -config VECTORS_OFFSET - hex "Kernel vectors offset" - default 0x00003000 - depends on !XIP_KERNEL +choice + prompt "Relocatable vectors location" + default XTENSA_VECTORS_IN_TEXT help - This is the offset of the kernel image from the relocatable vectors - base. + Choose whether relocatable vectors are merged into the kernel .text + or placed separately at runtime. This option does not affect + configurations without VECBASE register where vectors are always + placed at their hardware-defined locations. - If unsure, leave the default value here. +config XTENSA_VECTORS_IN_TEXT + bool "Merge relocatable vectors into kernel text" + depends on !MTD_XIP + help + This option puts relocatable vectors into the kernel .text section + with proper alignment. + This is a safe choice for most configurations. + +config XTENSA_VECTORS_SEPARATE + bool "Put relocatable vectors at fixed address" + help + This option puts relocatable vectors at specific virtual address. + Vectors are merged with the .init data in the kernel image and + are copied into their designated location during kernel startup. + Use it to put vectors into IRAM or out of FLASH on kernels with + XIP-aware MTD support. + +endchoice + +config VECTORS_ADDR + hex "Kernel vectors virtual address" + default 0x00000000 + depends on XTENSA_VECTORS_SEPARATE + help + This is the virtual address of the (relocatable) vectors base. + It must be within KSEG if MMU is used. config XIP_DATA_ADDR hex "XIP kernel data virtual address" diff --git a/arch/xtensa/configs/smp_lx200_defconfig b/arch/xtensa/configs/smp_lx200_defconfig index 8b3bc92a079c..4f1c7998b030 100644 --- a/arch/xtensa/configs/smp_lx200_defconfig +++ b/arch/xtensa/configs/smp_lx200_defconfig @@ -30,7 +30,6 @@ CONFIG_SMP=y CONFIG_HOTPLUG_CPU=y # CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX is not set # CONFIG_PCI is not set -CONFIG_VECTORS_OFFSET=0x00002000 CONFIG_XTENSA_PLATFORM_XTFPGA=y CONFIG_CMDLINE_BOOL=y CONFIG_CMDLINE="earlycon=uart8250,mmio32native,0xfd050020,115200n8 console=ttyS0,115200n8 ip=dhcp root=/dev/nfs rw debug memmap=96M@0" diff --git a/arch/xtensa/configs/virt_defconfig b/arch/xtensa/configs/virt_defconfig index 4fddd8512350..6d1387dfa96f 100644 --- a/arch/xtensa/configs/virt_defconfig +++ b/arch/xtensa/configs/virt_defconfig @@ -19,7 +19,6 @@ CONFIG_KALLSYMS_ALL=y CONFIG_PERF_EVENTS=y CONFIG_XTENSA_VARIANT_DC233C=y CONFIG_XTENSA_UNALIGNED_USER=y -CONFIG_VECTORS_OFFSET=0x00002000 CONFIG_XTENSA_KSEG_512M=y CONFIG_HIGHMEM=y CONFIG_CMDLINE_BOOL=y diff --git a/arch/xtensa/include/asm/vectors.h b/arch/xtensa/include/asm/vectors.h index 140f30762cf9..704286c35640 100644 --- a/arch/xtensa/include/asm/vectors.h +++ b/arch/xtensa/include/asm/vectors.h @@ -34,8 +34,8 @@ #endif #define RESET_VECTOR1_VADDR (XCHAL_RESET_VECTOR1_VADDR) -#ifdef CONFIG_VECTORS_OFFSET -#define VECBASE_VADDR (KERNELOFFSET - CONFIG_VECTORS_OFFSET) +#ifdef CONFIG_VECTORS_ADDR +#define VECBASE_VADDR (CONFIG_VECTORS_ADDR) #else #define VECBASE_VADDR _vecbase #endif diff --git a/arch/xtensa/kernel/setup.c b/arch/xtensa/kernel/setup.c index fefbdce1db99..1e9b9e7d9583 100644 --- a/arch/xtensa/kernel/setup.c +++ b/arch/xtensa/kernel/setup.c @@ -349,7 +349,7 @@ void __init setup_arch(char **cmdline_p) mem_reserve(__pa(_xip_start), __pa(_xip_end)); #endif -#ifdef CONFIG_VECTORS_OFFSET +#ifdef CONFIG_VECTORS_ADDR mem_reserve(__pa(&_WindowVectors_text_start), __pa(&_WindowVectors_text_end)); @@ -388,7 +388,7 @@ void __init setup_arch(char **cmdline_p) __pa(&_Level6InterruptVector_text_end)); #endif -#endif /* CONFIG_VECTORS_OFFSET */ +#endif /* CONFIG_VECTORS_ADDR */ #ifdef CONFIG_SMP mem_reserve(__pa(&_SecondaryResetVector_text_start), diff --git a/arch/xtensa/kernel/vmlinux.lds.S b/arch/xtensa/kernel/vmlinux.lds.S index d9e547810b6c..d23a6e38f062 100644 --- a/arch/xtensa/kernel/vmlinux.lds.S +++ b/arch/xtensa/kernel/vmlinux.lds.S @@ -47,9 +47,15 @@ jiffies = jiffies_64; LONG(sym ## _end); \ LONG(LOADADDR(section)) +#if !defined(CONFIG_VECTORS_ADDR) && XCHAL_HAVE_VECBASE +#define MERGED_VECTORS 1 +#else +#define MERGED_VECTORS 0 +#endif + /* - * Macro to define a section for a vector. When CONFIG_VECTORS_OFFSET is - * defined code for every vector is located with other init data. At startup + * Macro to define a section for a vector. When MERGED_VECTORS is 0 + * code for every vector is located with other init data. At startup * time head.S copies code for every vector to its final position according * to description recorded in the corresponding RELOCATE_ENTRY. */ @@ -84,7 +90,7 @@ SECTIONS /* The HEAD_TEXT section must be the first section! */ HEAD_TEXT -#ifndef CONFIG_VECTORS_OFFSET +#if MERGED_VECTORS . = ALIGN(PAGE_SIZE); _vecbase = .; @@ -159,7 +165,7 @@ SECTIONS . = ALIGN(16); __boot_reloc_table_start = ABSOLUTE(.); -#ifdef CONFIG_VECTORS_OFFSET +#if !MERGED_VECTORS RELOCATE_ENTRY(_WindowVectors_text, .WindowVectors.text); #if XCHAL_EXCM_LEVEL >= 2 @@ -220,7 +226,7 @@ SECTIONS #undef LAST #define LAST .dummy -#ifdef CONFIG_VECTORS_OFFSET +#if !MERGED_VECTORS /* The vectors are relocated to the real position at startup time */ SECTION_VECTOR4 (_WindowVectors_text, @@ -299,7 +305,7 @@ SECTIONS #define LAST .SecondaryResetVector.text #endif -#ifdef CONFIG_VECTORS_OFFSET +#if !MERGED_VECTORS SECTION_VECTOR4 (_exception_text, .exception.text, , @@ -310,6 +316,7 @@ SECTIONS #endif . = (LOADADDR(LAST) + SIZEOF(LAST) + 3) & ~ 3; + .dummy1 : AT(ADDR(.dummy1)) { LONG(0) } . = ALIGN(PAGE_SIZE); #ifndef CONFIG_XIP_KERNEL @@ -327,7 +334,7 @@ SECTIONS #undef LOAD_OFFSET #define LOAD_OFFSET \ - (CONFIG_XIP_DATA_ADDR - (LOADADDR(.dummy) + SIZEOF(.dummy) + 3) & ~ 3) + (CONFIG_XIP_DATA_ADDR - (LOADADDR(.dummy1) + SIZEOF(.dummy1) + 3) & ~ 3) _xip_data_start = .; _sdata = .; -- cgit v1.2.1 From c74c0fd2282e0e3ce891cb571f325b9412cbaa3f Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Tue, 4 Feb 2020 12:51:21 -0800 Subject: xtensa: ISS: improve simcall assembly Drop redundant result moving from inline assembly, use a1 and b1 values as return value and errno value respectively. Signed-off-by: Max Filippov --- arch/xtensa/platforms/iss/include/platform/simcall.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/arch/xtensa/platforms/iss/include/platform/simcall.h b/arch/xtensa/platforms/iss/include/platform/simcall.h index 2ba45858e50a..111bcc5d0dc0 100644 --- a/arch/xtensa/platforms/iss/include/platform/simcall.h +++ b/arch/xtensa/platforms/iss/include/platform/simcall.h @@ -66,19 +66,17 @@ static int errno; static inline int __simc(int a, int b, int c, int d) { - int ret; register int a1 asm("a2") = a; register int b1 asm("a3") = b; register int c1 asm("a4") = c; register int d1 asm("a5") = d; __asm__ __volatile__ ( "simcall\n" - "mov %0, a2\n" - "mov %1, a3\n" - : "=a" (ret), "=a" (errno), "+r"(a1), "+r"(b1) + : "+r"(a1), "+r"(b1) : "r"(c1), "r"(d1) : "memory"); - return ret; + errno = b1; + return a1; } static inline int simc_exit(int exit_code) -- cgit v1.2.1