Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'nios2-v4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/lftan/nios2

Pull nios2 updates from Ley Foon Tan:
"nios2 fixes/enhancements and adding nios2 R2 support"

* tag 'nios2-v4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/lftan/nios2:
nios2: remove custom early console implementation
nios2: use generic strncpy_from_user() and strnlen_user()
nios2: Add CDX support
nios2: Add BMX support
nios2: Add NIOS2_ARCH_REVISION to select between R1 and R2
nios2: implement flush_dcache_mmap_lock/unlock
nios2: enable earlycon support
nios2: constify irq_domain_ops
nios2: remove wrapper header for cmpxchg.h
nios2: add .gitignore entries for auto-generated files

+69 -252
+2
arch/nios2/Kconfig
··· 6 6 select GENERIC_CPU_DEVICES 7 7 select GENERIC_IRQ_PROBE 8 8 select GENERIC_IRQ_SHOW 9 + select GENERIC_STRNCPY_FROM_USER 10 + select GENERIC_STRNLEN_USER 9 11 select HAVE_ARCH_TRACEHOOK 10 12 select HAVE_ARCH_KGDB 11 13 select IRQ_DOMAIN
-1
arch/nios2/Kconfig.debug
··· 18 18 bool "Activate early kernel debugging" 19 19 default y 20 20 select SERIAL_CORE_CONSOLE 21 - depends on SERIAL_ALTERA_JTAGUART_CONSOLE || SERIAL_ALTERA_UART_CONSOLE 22 21 help 23 22 Enable early printk on console 24 23 This is useful for kernel debugging when your machine crashes very
+5
arch/nios2/Makefile
··· 22 22 23 23 LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) $(KCFLAGS) -print-libgcc-file-name) 24 24 25 + KBUILD_AFLAGS += -march=r$(CONFIG_NIOS2_ARCH_REVISION) 26 + 25 27 KBUILD_CFLAGS += -pipe -D__linux__ -D__ELF__ 28 + KBUILD_CFLAGS += -march=r$(CONFIG_NIOS2_ARCH_REVISION) 26 29 KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_HW_MUL_SUPPORT),-mhw-mul,-mno-hw-mul) 27 30 KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_HW_MULX_SUPPORT),-mhw-mulx,-mno-hw-mulx) 28 31 KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_HW_DIV_SUPPORT),-mhw-div,-mno-hw-div) 32 + KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_BMX_SUPPORT),-mbmx,-mno-bmx) 33 + KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_CDX_SUPPORT),-mcdx,-mno-cdx) 29 34 KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_FPU_SUPPORT),-mcustom-fpu-cfg=60-1,) 30 35 31 36 KBUILD_CFLAGS += -fno-optimize-sibling-calls
+2
arch/nios2/boot/.gitignore
··· 1 + *.dtb 2 + vmImage
+2 -1
arch/nios2/boot/dts/10m50_devboard.dts
··· 244 244 }; 245 245 246 246 chosen { 247 - bootargs = "debug console=ttyS0,115200"; 247 + bootargs = "debug earlycon console=ttyS0,115200"; 248 + stdout-path = &a_16550_uart_0; 248 249 }; 249 250 };
+1
arch/nios2/include/asm/Kbuild
··· 6 6 generic-y += bug.h 7 7 generic-y += bugs.h 8 8 generic-y += clkdev.h 9 + generic-y += cmpxchg.h 9 10 generic-y += current.h 10 11 generic-y += device.h 11 12 generic-y += div64.h
+4 -2
arch/nios2/include/asm/cacheflush.h
··· 46 46 extern void flush_dcache_range(unsigned long start, unsigned long end); 47 47 extern void invalidate_dcache_range(unsigned long start, unsigned long end); 48 48 49 - #define flush_dcache_mmap_lock(mapping) do { } while (0) 50 - #define flush_dcache_mmap_unlock(mapping) do { } while (0) 49 + #define flush_dcache_mmap_lock(mapping) \ 50 + spin_lock_irq(&(mapping)->tree_lock) 51 + #define flush_dcache_mmap_unlock(mapping) \ 52 + spin_unlock_irq(&(mapping)->tree_lock) 51 53 52 54 #endif /* _ASM_NIOS2_CACHEFLUSH_H */
-14
arch/nios2/include/asm/cmpxchg.h
··· 1 - /* 2 - * Copyright (C) 2004 Microtronix Datacom Ltd. 3 - * 4 - * This file is subject to the terms and conditions of the GNU General Public 5 - * License. See the file "COPYING" in the main directory of this archive 6 - * for more details. 7 - */ 8 - 9 - #ifndef _ASM_NIOS2_CMPXCHG_H 10 - #define _ASM_NIOS2_CMPXCHG_H 11 - 12 - #include <asm-generic/cmpxchg.h> 13 - 14 - #endif /* _ASM_NIOS2_CMPXCHG_H */
+2
arch/nios2/include/asm/cpuinfo.h
··· 29 29 bool has_div; 30 30 bool has_mul; 31 31 bool has_mulx; 32 + bool has_bmx; 33 + bool has_cdx; 32 34 33 35 /* CPU caches */ 34 36 u32 icache_line_size;
-22
arch/nios2/include/asm/prom.h
··· 1 - /* 2 - * Copyright Altera Corporation (C) <2015>. All rights reserved 3 - * 4 - * This program is free software; you can redistribute it and/or modify it 5 - * under the terms and conditions of the GNU General Public License, 6 - * version 2, as published by the Free Software Foundation. 7 - * 8 - * This program is distributed in the hope it will be useful, but WITHOUT 9 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 - * more details. 12 - * 13 - * You should have received a copy of the GNU General Public License along with 14 - * this program. If not, see <http://www.gnu.org/licenses/>. 15 - */ 16 - 17 - #ifndef __ASM_NIOS2_PROM_H__ 18 - #define __ASM_NIOS2_PROM_H__ 19 - 20 - extern unsigned long __init of_early_console(void); 21 - 22 - #endif
-2
arch/nios2/include/asm/setup.h
··· 30 30 31 31 extern void pagetable_init(void); 32 32 33 - extern void setup_early_printk(void); 34 - 35 33 #endif/* __KERNEL__ */ 36 34 #endif /* __ASSEMBLY__ */ 37 35
+5 -2
arch/nios2/include/asm/uaccess.h
··· 42 42 43 43 # define __EX_TABLE_SECTION ".section __ex_table,\"a\"\n" 44 44 45 + #define user_addr_max() (uaccess_kernel() ? ~0UL : TASK_SIZE) 46 + 45 47 /* 46 48 * Zero Userspace 47 49 */ ··· 83 81 #define INLINE_COPY_TO_USER 84 82 85 83 extern long strncpy_from_user(char *__to, const char __user *__from, 86 - long __len); 87 - extern long strnlen_user(const char __user *s, long n); 84 + long __len); 85 + extern __must_check long strlen_user(const char __user *str); 86 + extern __must_check long strnlen_user(const char __user *s, long n); 88 87 89 88 /* Optimized macros */ 90 89 #define __get_user_asm(val, insn, addr, err) \
+1
arch/nios2/kernel/.gitignore
··· 1 + vmlinux.lds
-1
arch/nios2/kernel/Makefile
··· 20 20 obj-y += time.o 21 21 obj-y += traps.o 22 22 23 - obj-$(CONFIG_EARLY_PRINTK) += early_printk.o 24 23 obj-$(CONFIG_KGDB) += kgdb.o 25 24 obj-$(CONFIG_MODULES) += module.o 26 25 obj-$(CONFIG_NIOS2_ALIGNMENT_TRAP) += misaligned.o
+16 -2
arch/nios2/kernel/cpuinfo.c
··· 67 67 cpuinfo.has_div = of_property_read_bool(cpu, "altr,has-div"); 68 68 cpuinfo.has_mul = of_property_read_bool(cpu, "altr,has-mul"); 69 69 cpuinfo.has_mulx = of_property_read_bool(cpu, "altr,has-mulx"); 70 + cpuinfo.has_bmx = of_property_read_bool(cpu, "altr,has-bmx"); 71 + cpuinfo.has_cdx = of_property_read_bool(cpu, "altr,has-cdx"); 70 72 cpuinfo.mmu = of_property_read_bool(cpu, "altr,has-mmu"); 71 73 72 74 if (IS_ENABLED(CONFIG_NIOS2_HW_DIV_SUPPORT) && !cpuinfo.has_div) ··· 79 77 80 78 if (IS_ENABLED(CONFIG_NIOS2_HW_MULX_SUPPORT) && !cpuinfo.has_mulx) 81 79 err_cpu("MULX"); 80 + 81 + if (IS_ENABLED(CONFIG_NIOS2_BMX_SUPPORT) && !cpuinfo.has_bmx) 82 + err_cpu("BMX"); 83 + 84 + if (IS_ENABLED(CONFIG_NIOS2_CDX_SUPPORT) && !cpuinfo.has_cdx) 85 + err_cpu("CDX"); 82 86 83 87 cpuinfo.tlb_num_ways = fcpu(cpu, "altr,tlb-num-ways"); 84 88 if (!cpuinfo.tlb_num_ways) ··· 133 125 134 126 seq_printf(m, 135 127 "CPU:\t\tNios II/%s\n" 128 + "REV:\t\t%i\n" 136 129 "MMU:\t\t%s\n" 137 130 "FPU:\t\tnone\n" 138 131 "Clocking:\t%u.%02u MHz\n" 139 132 "BogoMips:\t%lu.%02lu\n" 140 133 "Calibration:\t%lu loops\n", 141 134 cpuinfo.cpu_impl, 135 + CONFIG_NIOS2_ARCH_REVISION, 142 136 cpuinfo.mmu ? "present" : "none", 143 137 clockfreq / 1000000, (clockfreq / 100000) % 10, 144 138 (loops_per_jiffy * HZ) / 500000, ··· 151 141 "HW:\n" 152 142 " MUL:\t\t%s\n" 153 143 " MULX:\t\t%s\n" 154 - " DIV:\t\t%s\n", 144 + " DIV:\t\t%s\n" 145 + " BMX:\t\t%s\n" 146 + " CDX:\t\t%s\n", 155 147 cpuinfo.has_mul ? "yes" : "no", 156 148 cpuinfo.has_mulx ? "yes" : "no", 157 - cpuinfo.has_div ? "yes" : "no"); 149 + cpuinfo.has_div ? "yes" : "no", 150 + cpuinfo.has_bmx ? "yes" : "no", 151 + cpuinfo.has_cdx ? "yes" : "no"); 158 152 159 153 seq_printf(m, 160 154 "Icache:\t\t%ukB, line length: %u\n",
-118
arch/nios2/kernel/early_printk.c
··· 1 - /* 2 - * Early printk for Nios2. 3 - * 4 - * Copyright (C) 2015, Altera Corporation 5 - * Copyright (C) 2010, Tobias Klauser <tklauser@distanz.ch> 6 - * Copyright (C) 2009, Wind River Systems Inc 7 - * Implemented by fredrik.markstrom@gmail.com and ivarholmqvist@gmail.com 8 - * 9 - * This file is subject to the terms and conditions of the GNU General Public 10 - * License. See the file "COPYING" in the main directory of this archive 11 - * for more details. 12 - */ 13 - 14 - #include <linux/console.h> 15 - #include <linux/init.h> 16 - #include <linux/kernel.h> 17 - #include <linux/io.h> 18 - 19 - #include <asm/prom.h> 20 - 21 - static unsigned long base_addr; 22 - 23 - #if defined(CONFIG_SERIAL_ALTERA_JTAGUART_CONSOLE) 24 - 25 - #define ALTERA_JTAGUART_DATA_REG 0 26 - #define ALTERA_JTAGUART_CONTROL_REG 4 27 - #define ALTERA_JTAGUART_CONTROL_WSPACE_MSK 0xFFFF0000 28 - #define ALTERA_JTAGUART_CONTROL_AC_MSK 0x00000400 29 - 30 - #define JUART_GET_CR() \ 31 - __builtin_ldwio((void *)(base_addr + ALTERA_JTAGUART_CONTROL_REG)) 32 - #define JUART_SET_CR(v) \ 33 - __builtin_stwio((void *)(base_addr + ALTERA_JTAGUART_CONTROL_REG), v) 34 - #define JUART_SET_TX(v) \ 35 - __builtin_stwio((void *)(base_addr + ALTERA_JTAGUART_DATA_REG), v) 36 - 37 - static void early_console_write(struct console *con, const char *s, unsigned n) 38 - { 39 - unsigned long status; 40 - 41 - while (n-- && *s) { 42 - while (((status = JUART_GET_CR()) 43 - & ALTERA_JTAGUART_CONTROL_WSPACE_MSK) == 0) { 44 - #if defined(CONFIG_SERIAL_ALTERA_JTAGUART_CONSOLE_BYPASS) 45 - if ((status & ALTERA_JTAGUART_CONTROL_AC_MSK) == 0) 46 - return; /* no connection activity */ 47 - #endif 48 - } 49 - JUART_SET_TX(*s); 50 - s++; 51 - } 52 - } 53 - 54 - #elif defined(CONFIG_SERIAL_ALTERA_UART_CONSOLE) 55 - 56 - #define ALTERA_UART_TXDATA_REG 4 57 - #define ALTERA_UART_STATUS_REG 8 58 - #define ALTERA_UART_STATUS_TRDY 0x0040 59 - 60 - #define UART_GET_SR() \ 61 - __builtin_ldwio((void *)(base_addr + ALTERA_UART_STATUS_REG)) 62 - #define UART_SET_TX(v) \ 63 - __builtin_stwio((void *)(base_addr + ALTERA_UART_TXDATA_REG), v) 64 - 65 - static void early_console_putc(char c) 66 - { 67 - while (!(UART_GET_SR() & ALTERA_UART_STATUS_TRDY)) 68 - ; 69 - 70 - UART_SET_TX(c); 71 - } 72 - 73 - static void early_console_write(struct console *con, const char *s, unsigned n) 74 - { 75 - while (n-- && *s) { 76 - early_console_putc(*s); 77 - if (*s == '\n') 78 - early_console_putc('\r'); 79 - s++; 80 - } 81 - } 82 - 83 - #else 84 - # error Neither SERIAL_ALTERA_JTAGUART_CONSOLE nor SERIAL_ALTERA_UART_CONSOLE \ 85 - selected 86 - #endif 87 - 88 - static struct console early_console_prom = { 89 - .name = "early", 90 - .write = early_console_write, 91 - .flags = CON_PRINTBUFFER | CON_BOOT, 92 - .index = -1 93 - }; 94 - 95 - void __init setup_early_printk(void) 96 - { 97 - #if defined(CONFIG_SERIAL_ALTERA_JTAGUART_CONSOLE) || \ 98 - defined(CONFIG_SERIAL_ALTERA_UART_CONSOLE) 99 - base_addr = of_early_console(); 100 - #else 101 - base_addr = 0; 102 - #endif 103 - 104 - if (!base_addr) 105 - return; 106 - 107 - #if defined(CONFIG_SERIAL_ALTERA_JTAGUART_CONSOLE_BYPASS) 108 - /* Clear activity bit so BYPASS doesn't stall if we've used JTAG for 109 - * downloading the kernel. This might cause early data to be lost even 110 - * if the JTAG terminal is running. 111 - */ 112 - JUART_SET_CR(JUART_GET_CR() | ALTERA_JTAGUART_CONTROL_AC_MSK); 113 - #endif 114 - 115 - early_console = &early_console_prom; 116 - register_console(early_console); 117 - pr_info("early_console initialized at 0x%08lx\n", base_addr); 118 - }
+1 -1
arch/nios2/kernel/irq.c
··· 67 67 return 0; 68 68 } 69 69 70 - static struct irq_domain_ops irq_ops = { 70 + static const struct irq_domain_ops irq_ops = { 71 71 .map = irq_map, 72 72 .xlate = irq_domain_xlate_onecell, 73 73 };
-49
arch/nios2/kernel/prom.c
··· 30 30 #include <linux/of_fdt.h> 31 31 #include <linux/io.h> 32 32 33 - #include <asm/prom.h> 34 33 #include <asm/sections.h> 35 34 36 35 void __init early_init_dt_add_memory_arch(u64 base, u64 size) ··· 70 71 71 72 early_init_dt_scan(params); 72 73 } 73 - 74 - #ifdef CONFIG_EARLY_PRINTK 75 - static int __init early_init_dt_scan_serial(unsigned long node, 76 - const char *uname, int depth, void *data) 77 - { 78 - u64 *addr64 = (u64 *) data; 79 - const char *p; 80 - 81 - /* only consider serial nodes */ 82 - if (strncmp(uname, "serial", 6) != 0) 83 - return 0; 84 - 85 - p = of_get_flat_dt_prop(node, "compatible", NULL); 86 - if (!p) 87 - return 0; 88 - 89 - /* 90 - * We found an altera_jtaguart but it wasn't configured for console, so 91 - * skip it. 92 - */ 93 - #ifndef CONFIG_SERIAL_ALTERA_JTAGUART_CONSOLE 94 - if (strncmp(p, "altr,juart", 10) == 0) 95 - return 0; 96 - #endif 97 - 98 - /* 99 - * Same for altera_uart. 100 - */ 101 - #ifndef CONFIG_SERIAL_ALTERA_UART_CONSOLE 102 - if (strncmp(p, "altr,uart", 9) == 0) 103 - return 0; 104 - #endif 105 - 106 - *addr64 = of_flat_dt_translate_address(node); 107 - 108 - return *addr64 == OF_BAD_ADDR ? 0 : 1; 109 - } 110 - 111 - unsigned long __init of_early_console(void) 112 - { 113 - u64 base = 0; 114 - 115 - if (of_scan_flat_dt(early_init_dt_scan_serial, &base)) 116 - return (u32)ioremap(base, 32); 117 - else 118 - return 0; 119 - } 120 - #endif /* CONFIG_EARLY_PRINTK */
+2 -4
arch/nios2/kernel/setup.c
··· 137 137 strncpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE); 138 138 #endif 139 139 #endif 140 + 141 + parse_early_param(); 140 142 } 141 143 142 144 void __init setup_arch(char **cmdline_p) ··· 146 144 int bootmap_size; 147 145 148 146 console_verbose(); 149 - 150 - #ifdef CONFIG_EARLY_PRINTK 151 - setup_early_printk(); 152 - #endif 153 147 154 148 memory_start = PAGE_ALIGN((unsigned long)__pa(_end)); 155 149 memory_end = (unsigned long) CONFIG_NIOS2_MEM_BASE + memory_size;
-33
arch/nios2/mm/uaccess.c
··· 128 128 ".word 12b,13b\n" 129 129 ".previous\n"); 130 130 EXPORT_SYMBOL(raw_copy_to_user); 131 - 132 - long strncpy_from_user(char *__to, const char __user *__from, long __len) 133 - { 134 - int l = strnlen_user(__from, __len); 135 - int is_zt = 1; 136 - 137 - if (l > __len) { 138 - is_zt = 0; 139 - l = __len; 140 - } 141 - 142 - if (l == 0 || copy_from_user(__to, __from, l)) 143 - return -EFAULT; 144 - 145 - if (is_zt) 146 - l--; 147 - return l; 148 - } 149 - 150 - long strnlen_user(const char __user *s, long n) 151 - { 152 - long i; 153 - 154 - for (i = 0; i < n; i++) { 155 - char c; 156 - 157 - if (get_user(c, s + i) == -EFAULT) 158 - return 0; 159 - if (c == 0) 160 - return i + 1; 161 - } 162 - return n + 1; 163 - }
+26
arch/nios2/platform/Kconfig.platform
··· 52 52 53 53 comment "Nios II instructions" 54 54 55 + config NIOS2_ARCH_REVISION 56 + int "Select Nios II architecture revision" 57 + range 1 2 58 + default 1 59 + help 60 + Select between Nios II R1 and Nios II R2 . The architectures 61 + are binary incompatible. Default is R1 . 62 + 55 63 config NIOS2_HW_MUL_SUPPORT 56 64 bool "Enable MUL instruction" 57 65 default n ··· 80 72 help 81 73 Set to true if you configured the Nios II to include the DIV 82 74 instruction. Enables the -mhw-div compiler flag. 75 + 76 + config NIOS2_BMX_SUPPORT 77 + bool "Enable BMX instructions" 78 + depends on NIOS2_ARCH_REVISION = 2 79 + default n 80 + help 81 + Set to true if you configured the Nios II R2 to include 82 + the BMX Bit Manipulation Extension instructions. Enables 83 + the -mbmx compiler flag. 84 + 85 + config NIOS2_CDX_SUPPORT 86 + bool "Enable CDX instructions" 87 + depends on NIOS2_ARCH_REVISION = 2 88 + default n 89 + help 90 + Set to true if you configured the Nios II R2 to include 91 + the CDX Bit Manipulation Extension instructions. Enables 92 + the -mcdx compiler flag. 83 93 84 94 config NIOS2_FPU_SUPPORT 85 95 bool "Custom floating point instr support"