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

Merge tag 'for-4.5' of git://git.osdn.jp/gitroot/uclinux-h8/linux

Pull h8300 updates from Yoshinori Sato:
- Add KGDB support
- zImage fix
- various cleanup

* tag 'for-4.5' of git://git.osdn.jp/gitroot/uclinux-h8/linux:
h8300: System call entry enable interrupt.
h8300: show_stack cleanup
h8300: Restraint of warning.
h8300: Add KGDB support.
irqchip: renesas-h8s: Replace ctrl_outw/ctrl_inw with writew/readw
h8300: signal stack fix
h8300: Add LZO compression
h8300: zImage alignment fix
clk: h8300: Remove "sh73a0-" part from compatible value
h8300: zImage alignment fix

+244 -31
+1 -1
Documentation/devicetree/bindings/clock/renesas,h8300-div-clock.txt
··· 2 2 3 3 Required Properties: 4 4 5 - - compatible: Must be "renesas,sh73a0-h8300-div-clock" 5 + - compatible: Must be "renesas,h8300-div-clock" 6 6 7 7 - clocks: Reference to the parent clocks ("extal1" and "extal2") 8 8
+3
arch/h8300/Kconfig
··· 18 18 select HAVE_DMA_ATTRS 19 19 select CLKSRC_OF 20 20 select H8300_TMR8 21 + select HAVE_KERNEL_GZIP 22 + select HAVE_KERNEL_LZO 23 + select HAVE_ARCH_KGDB 21 24 22 25 config RWSEM_GENERIC_SPINLOCK 23 26 def_bool y
+8 -3
arch/h8300/boot/compressed/Makefile
··· 28 28 $(obj)/vmlinux.bin: vmlinux FORCE 29 29 $(call if_changed,objcopy) 30 30 31 - $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE 32 - $(call if_changed,gzip) 31 + suffix-$(CONFIG_KERNEL_GZIP) := gzip 32 + suffix-$(CONFIG_KERNEL_LZO) := lzo 33 + 34 + $(obj)/vmlinux.bin.$(suffix-y): $(obj)/vmlinux.bin FORCE 35 + $(call if_changed,$(suffix-y)) 33 36 34 37 LDFLAGS_piggy.o := -r --format binary --oformat elf32-h8300-linux -T 35 38 OBJCOPYFLAGS := -O binary 36 39 37 - $(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE 40 + $(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.$(suffix-y) FORCE 38 41 $(call if_changed,ld) 42 + 43 + CFLAGS_misc.o = -O0
+6
arch/h8300/boot/compressed/misc.c
··· 32 32 33 33 #define HEAP_SIZE 0x10000 34 34 35 + #ifdef CONFIG_KERNEL_GZIP 35 36 #include "../../../../lib/decompress_inflate.c" 37 + #endif 38 + 39 + #ifdef CONFIG_KERNEL_LZO 40 + #include "../../../../lib/decompress_unlzo.c" 41 + #endif 36 42 37 43 void *memset(void *s, int c, size_t n) 38 44 {
+3 -1
arch/h8300/boot/compressed/vmlinux.lds
··· 13 13 { 14 14 *(.rodata) 15 15 } 16 + . = ALIGN(0x4) ; 16 17 .data : 17 18 18 19 { 20 + . = ALIGN(0x4) ; 19 21 __sdata = . ; 20 22 ___data_start = . ; 21 23 *(.data.*) 22 24 } 25 + . = ALIGN(0x4) ; 23 26 .bss : 24 27 { 25 - . = ALIGN(0x4) ; 26 28 __sbss = . ; 27 29 *(.bss*) 28 30 . = ALIGN(0x4) ;
+4 -4
arch/h8300/include/asm/io.h
··· 44 44 static inline void ctrl_bclr(int b, void __iomem *addr) 45 45 { 46 46 if (__builtin_constant_p(b)) 47 - __asm__("bclr %1,%0" : "+WU"(*addr): "i"(b)); 47 + __asm__("bclr %1,%0" : "+WU"(*(u8 *)addr): "i"(b)); 48 48 else 49 - __asm__("bclr %w1,%0" : "+WU"(*addr): "r"(b)); 49 + __asm__("bclr %w1,%0" : "+WU"(*(u8 *)addr): "r"(b)); 50 50 } 51 51 52 52 static inline void ctrl_bset(int b, void __iomem *addr) 53 53 { 54 54 if (__builtin_constant_p(b)) 55 - __asm__("bset %1,%0" : "+WU"(*addr): "i"(b)); 55 + __asm__("bset %1,%0" : "+WU"(*(u8 *)addr): "i"(b)); 56 56 else 57 - __asm__("bset %w1,%0" : "+WU"(*addr): "r"(b)); 57 + __asm__("bset %w1,%0" : "+WU"(*(u8 *)addr): "r"(b)); 58 58 } 59 59 60 60 #include <asm-generic/io.h>
+45
arch/h8300/include/asm/kgdb.h
··· 1 + /* 2 + * Copyright (C) 2015 Yoshinori Sato <ysato@users.sourceforge.jp> 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_H8300_KGDB_H 10 + #define _ASM_H8300_KGDB_H 11 + 12 + #define CACHE_FLUSH_IS_SAFE 1 13 + #define BUFMAX 2048 14 + 15 + enum regnames { 16 + GDB_ER0, GDB_ER1, GDB_ER2, GDB_ER3, 17 + GDB_ER4, GDB_ER5, GDB_ER6, GDB_SP, 18 + GDB_CCR, GDB_PC, 19 + GDB_CYCLLE, 20 + #if defined(CONFIG_CPU_H8S) 21 + GDB_EXR, 22 + #endif 23 + GDB_TICK, GDB_INST, 24 + #if defined(CONFIG_CPU_H8S) 25 + GDB_MACH, GDB_MACL, 26 + #endif 27 + /* do not change the last entry or anything below! */ 28 + GDB_NUMREGBYTES, /* number of registers */ 29 + }; 30 + 31 + #define GDB_SIZEOF_REG sizeof(u32) 32 + #if defined(CONFIG_CPU_H8300H) 33 + #define DBG_MAX_REG_NUM (13) 34 + #elif defined(CONFIG_CPU_H8S) 35 + #define DBG_MAX_REG_NUM (14) 36 + #endif 37 + #define NUMREGBYTES (DBG_MAX_REG_NUM * GDB_SIZEOF_REG) 38 + 39 + #define BREAK_INSTR_SIZE 2 40 + static inline void arch_kgdb_breakpoint(void) 41 + { 42 + __asm__ __volatile__("trapa #2"); 43 + } 44 + 45 + #endif /* _ASM_H8300_KGDB_H */
+1 -1
arch/h8300/include/asm/traps.h
··· 36 36 extern char _start, _etext; 37 37 #define check_kernel_text(addr) \ 38 38 ((addr >= (unsigned long)(&_start)) && \ 39 - (addr < (unsigned long)(&_etext))) 39 + (addr < (unsigned long)(&_etext)) && !(addr & 1)) 40 40 41 41 #endif /* _H8300_TRAPS_H */
+2
arch/h8300/kernel/Makefile
··· 17 17 18 18 obj-$(CONFIG_CPU_H8300H) += ptrace_h.o 19 19 obj-$(CONFIG_CPU_H8S) += ptrace_s.o 20 + 21 + obj-$(CONFIG_KGDB) += kgdb.o
+19
arch/h8300/kernel/entry.S
··· 188 188 jsr @_interrupt_entry /* NMI */ 189 189 jmp @_system_call /* TRAPA #0 (System call) */ 190 190 .long 0 191 + #if defined(CONFIG_KGDB) 192 + jmp @_kgdb_trap 193 + #else 191 194 .long 0 195 + #endif 192 196 jmp @_trace_break /* TRAPA #3 (breakpoint) */ 193 197 .rept INTERRUPTS-12 194 198 jsr @_interrupt_entry ··· 246 242 /* save top of frame */ 247 243 mov.l sp,er0 248 244 jsr @set_esp0 245 + andc #0x3f,ccr 249 246 mov.l sp,er2 250 247 and.w #0xe000,r2 251 248 mov.l @(TI_FLAGS:16,er2),er2 ··· 409 404 mov.l er0, @(4,sp) 410 405 mov.l @sp+, er0 411 406 jmp @_interrupt_entry 407 + 408 + #if defined(CONFIG_KGDB) 409 + _kgdb_trap: 410 + subs #4,sp 411 + SAVE_ALL 412 + mov.l sp,er0 413 + add.l #LRET,er0 414 + mov.l er0,@(LSP,sp) 415 + jsr @set_esp0 416 + mov.l sp,er0 417 + subs #4,er0 418 + jsr @h8300_kgdb_trap 419 + jmp @ret_from_exception 420 + #endif 412 421 413 422 .section .bss 414 423 _sw_ksp:
+135
arch/h8300/kernel/kgdb.c
··· 1 + /* 2 + * H8/300 KGDB support 3 + * 4 + * Copyright (C) 2015 Yoshinori Sato <ysato@users.sourceforge.jp> 5 + * 6 + * This file is subject to the terms and conditions of the GNU General Public 7 + * License. See the file "COPYING" in the main directory of this archive 8 + * for more details. 9 + */ 10 + 11 + #include <linux/ptrace.h> 12 + #include <linux/kgdb.h> 13 + #include <linux/kdebug.h> 14 + #include <linux/io.h> 15 + 16 + struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] = { 17 + { "er0", GDB_SIZEOF_REG, offsetof(struct pt_regs, er0) }, 18 + { "er1", GDB_SIZEOF_REG, offsetof(struct pt_regs, er1) }, 19 + { "er2", GDB_SIZEOF_REG, offsetof(struct pt_regs, er2) }, 20 + { "er3", GDB_SIZEOF_REG, offsetof(struct pt_regs, er3) }, 21 + { "er4", GDB_SIZEOF_REG, offsetof(struct pt_regs, er4) }, 22 + { "er5", GDB_SIZEOF_REG, offsetof(struct pt_regs, er5) }, 23 + { "er6", GDB_SIZEOF_REG, offsetof(struct pt_regs, er6) }, 24 + { "sp", GDB_SIZEOF_REG, offsetof(struct pt_regs, sp) }, 25 + { "ccr", GDB_SIZEOF_REG, offsetof(struct pt_regs, ccr) }, 26 + { "pc", GDB_SIZEOF_REG, offsetof(struct pt_regs, pc) }, 27 + { "cycles", GDB_SIZEOF_REG, -1 }, 28 + #if defined(CONFIG_CPU_H8S) 29 + { "exr", GDB_SIZEOF_REG, offsetof(struct pt_regs, exr) }, 30 + #endif 31 + { "tick", GDB_SIZEOF_REG, -1 }, 32 + { "inst", GDB_SIZEOF_REG, -1 }, 33 + }; 34 + 35 + char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs) 36 + { 37 + if (regno >= DBG_MAX_REG_NUM || regno < 0) 38 + return NULL; 39 + 40 + switch (regno) { 41 + case GDB_CCR: 42 + #if defined(CONFIG_CPU_H8S) 43 + case GDB_EXR: 44 + #endif 45 + *(u32 *)mem = *(u16 *)((void *)regs + 46 + dbg_reg_def[regno].offset); 47 + break; 48 + default: 49 + if (dbg_reg_def[regno].offset >= 0) 50 + memcpy(mem, (void *)regs + dbg_reg_def[regno].offset, 51 + dbg_reg_def[regno].size); 52 + else 53 + memset(mem, 0, dbg_reg_def[regno].size); 54 + break; 55 + } 56 + return dbg_reg_def[regno].name; 57 + } 58 + 59 + int dbg_set_reg(int regno, void *mem, struct pt_regs *regs) 60 + { 61 + if (regno >= DBG_MAX_REG_NUM || regno < 0) 62 + return -EINVAL; 63 + 64 + switch (regno) { 65 + case GDB_CCR: 66 + #if defined(CONFIG_CPU_H8S) 67 + case GDB_EXR: 68 + #endif 69 + *(u16 *)((void *)regs + 70 + dbg_reg_def[regno].offset) = *(u32 *)mem; 71 + break; 72 + default: 73 + memcpy((void *)regs + dbg_reg_def[regno].offset, mem, 74 + dbg_reg_def[regno].size); 75 + } 76 + return 0; 77 + } 78 + 79 + asmlinkage void h8300_kgdb_trap(struct pt_regs *regs) 80 + { 81 + regs->pc &= 0x00ffffff; 82 + if (kgdb_handle_exception(10, SIGTRAP, 0, regs)) 83 + return; 84 + if (*(u16 *)(regs->pc) == *(u16 *)&arch_kgdb_ops.gdb_bpt_instr) 85 + regs->pc += BREAK_INSTR_SIZE; 86 + regs->pc |= regs->ccr << 24; 87 + } 88 + 89 + void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p) 90 + { 91 + memset((char *)gdb_regs, 0, NUMREGBYTES); 92 + gdb_regs[GDB_SP] = p->thread.ksp; 93 + gdb_regs[GDB_PC] = KSTK_EIP(p); 94 + } 95 + 96 + void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long pc) 97 + { 98 + regs->pc = pc; 99 + } 100 + 101 + int kgdb_arch_handle_exception(int vector, int signo, int err_code, 102 + char *remcom_in_buffer, char *remcom_out_buffer, 103 + struct pt_regs *regs) 104 + { 105 + char *ptr; 106 + unsigned long addr; 107 + 108 + switch (remcom_in_buffer[0]) { 109 + case 's': 110 + case 'c': 111 + /* handle the optional parameters */ 112 + ptr = &remcom_in_buffer[1]; 113 + if (kgdb_hex2long(&ptr, &addr)) 114 + regs->pc = addr; 115 + 116 + return 0; 117 + } 118 + 119 + return -1; /* this means that we do not want to exit from the handler */ 120 + } 121 + 122 + int kgdb_arch_init(void) 123 + { 124 + return 0; 125 + } 126 + 127 + void kgdb_arch_exit(void) 128 + { 129 + /* Nothing to do */ 130 + } 131 + 132 + const struct kgdb_arch arch_kgdb_ops = { 133 + /* Breakpoint instruction: trapa #2 */ 134 + .gdb_bpt_instr = { 0x57, 0x20 }, 135 + };
+4 -4
arch/h8300/kernel/signal.c
··· 95 95 regs->ccr |= ccr; 96 96 regs->orig_er0 = -1; /* disable syscall checks */ 97 97 err |= __get_user(usp, &usc->sc_usp); 98 - wrusp(usp); 98 + regs->sp = usp; 99 99 100 100 err |= __get_user(er0, &usc->sc_er0); 101 101 *pd0 = er0; ··· 180 180 return -EFAULT; 181 181 182 182 /* Set up to return from userspace. */ 183 - ret = frame->retcode; 183 + ret = (unsigned char *)&frame->retcode; 184 184 if (ksig->ka.sa.sa_flags & SA_RESTORER) 185 185 ret = (unsigned char *)(ksig->ka.sa.sa_restorer); 186 186 else { ··· 196 196 return -EFAULT; 197 197 198 198 /* Set up registers for signal handler */ 199 - wrusp((unsigned long) frame); 200 - regs->pc = (unsigned long) ksig->ka.sa.sa_handler; 199 + regs->sp = (unsigned long)frame; 200 + regs->pc = (unsigned long)ksig->ka.sa.sa_handler; 201 201 regs->er0 = ksig->sig; 202 202 regs->er1 = (unsigned long)&(frame->info); 203 203 regs->er2 = (unsigned long)&frame->uc;
+8 -12
arch/h8300/kernel/traps.c
··· 125 125 126 126 pr_info("Stack from %08lx:", (unsigned long)stack); 127 127 for (i = 0; i < kstack_depth_to_print; i++) { 128 - if (((unsigned long)stack & (THREAD_SIZE - 1)) == 0) 128 + if (((unsigned long)stack & (THREAD_SIZE - 1)) >= 129 + THREAD_SIZE-4) 129 130 break; 130 131 if (i % 8 == 0) 131 - pr_info("\n "); 132 - pr_info(" %08lx", *stack++); 132 + pr_info(" "); 133 + pr_cont(" %08lx", *stack++); 133 134 } 134 135 135 - pr_info("\nCall Trace:"); 136 + pr_info("\nCall Trace:\n"); 136 137 i = 0; 137 138 stack = esp; 138 - while (((unsigned long)stack & (THREAD_SIZE - 1)) != 0) { 139 + while (((unsigned long)stack & (THREAD_SIZE - 1)) < THREAD_SIZE-4) { 139 140 addr = *stack++; 140 141 /* 141 142 * If the address is either in the text segment of the ··· 148 147 */ 149 148 if (check_kernel_text(addr)) { 150 149 if (i % 4 == 0) 151 - pr_info("\n "); 152 - pr_info(" [<%08lx>]", addr); 150 + pr_info(" "); 151 + pr_cont(" [<%08lx>]", addr); 153 152 i++; 154 153 } 155 154 } 156 155 pr_info("\n"); 157 - } 158 - 159 - void show_trace_task(struct task_struct *tsk) 160 - { 161 - show_stack(tsk, (unsigned long *)tsk->thread.esp0); 162 156 }
+5 -5
drivers/irqchip/irq-renesas-h8s.c
··· 40 40 addr = IPRA + ((ipr_table[irq - 16] & 0xf0) >> 3); 41 41 pos = (ipr_table[irq - 16] & 0x0f) * 4; 42 42 pri = ~(0x000f << pos); 43 - pri &= ctrl_inw(addr); 44 - ctrl_outw(pri, addr); 43 + pri &= readw(addr); 44 + writew(pri, addr); 45 45 } 46 46 47 47 static void h8s_enable_irq(struct irq_data *data) ··· 54 54 addr = IPRA + ((ipr_table[irq - 16] & 0xf0) >> 3); 55 55 pos = (ipr_table[irq - 16] & 0x0f) * 4; 56 56 pri = ~(0x000f << pos); 57 - pri &= ctrl_inw(addr); 57 + pri &= readw(addr); 58 58 pri |= 1 << pos; 59 - ctrl_outw(pri, addr); 59 + writew(pri, addr); 60 60 } 61 61 62 62 struct irq_chip h8s_irq_chip = { ··· 90 90 /* All interrupt priority is 0 (disable) */ 91 91 /* IPRA to IPRK */ 92 92 for (n = 0; n <= 'k' - 'a'; n++) 93 - ctrl_outw(0x0000, IPRA + (n * 2)); 93 + writew(0x0000, IPRA + (n * 2)); 94 94 95 95 domain = irq_domain_add_linear(intc, NR_IRQS, &irq_ops, NULL); 96 96 BUG_ON(!domain);