From 686320e94da368f5efc2003ba5de9353cf774602 Mon Sep 17 00:00:00 2001 From: Yoshinori Sato Date: Thu, 12 Jul 2018 23:31:45 +0900 Subject: [PATCH 01/12] h8300: Add missing output register. Signed-off-by: Yoshinori Sato --- arch/h8300/include/asm/bitops.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/h8300/include/asm/bitops.h b/arch/h8300/include/asm/bitops.h index ea0cb0cf6a8b..b7ac7cf6f0de 100644 --- a/arch/h8300/include/asm/bitops.h +++ b/arch/h8300/include/asm/bitops.h @@ -29,11 +29,11 @@ static inline unsigned long ffz(unsigned long word) result = -1; __asm__("1:\n\t" - "shlr.l %2\n\t" + "shlr.l %1\n\t" "adds #1,%0\n\t" "bcs 1b" - : "=r"(result) - : "0"(result), "r"(word)); + : "=r"(result),"=r"(word) + : "0"(result), "1"(word)); return result; } @@ -162,11 +162,11 @@ static inline unsigned long __ffs(unsigned long word) result = -1; __asm__("1:\n\t" - "shlr.l %2\n\t" + "shlr.l %1\n\t" "adds #1,%0\n\t" "bcc 1b" - : "=r" (result) - : "0"(result), "r"(word)); + : "=r" (result),"=r"(word) + : "0"(result), "1"(word)); return result; } From 811d1b0e65bed442050d62a48c39263f4c5b2d68 Mon Sep 17 00:00:00 2001 From: Yoshinori Sato Date: Fri, 13 Jul 2018 16:36:21 +0900 Subject: [PATCH 02/12] h8300: gcc-8.1 fix Since gcc 8.1 does not generate an assignment statement to er 0, we had to explicitly write it. Signed-off-by: Yoshinori Sato --- arch/h8300/kernel/sim-console.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/h8300/kernel/sim-console.c b/arch/h8300/kernel/sim-console.c index 46138f55a9ea..03aa35b1a08c 100644 --- a/arch/h8300/kernel/sim-console.c +++ b/arch/h8300/kernel/sim-console.c @@ -13,12 +13,13 @@ static void sim_write(struct console *con, const char *s, unsigned n) { - register const int fd __asm__("er0") = 1; /* stdout */ register const char *_ptr __asm__("er1") = s; register const unsigned _len __asm__("er2") = n; - __asm__(".byte 0x5e,0x00,0x00,0xc7\n\t" /* jsr @0xc7 (sys_write) */ - : : "g"(fd), "g"(_ptr), "g"(_len)); + __asm__("sub.l er0,er0\n\t" /* er0 = 1 (stdout) */ + "inc.l #1,er0\n\t" + ".byte 0x5e,0x00,0x00,0xc7\n\t" /* jsr @0xc7 (sys_write) */ + : : "g"(_ptr), "g"(_len):"er0"); } static int __init sim_setup(struct earlycon_device *device, const char *opt) From c489dfefe739d37dde1cd7b26cd324607cedd934 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Fri, 16 Mar 2018 16:33:06 -0500 Subject: [PATCH 03/12] h8300: switch to NO_BOOTMEM Commit 0fa1c579349f ("of/fdt: use memblock_virt_alloc for early alloc") inadvertently switched the DT unflattening allocations from memblock to bootmem which doesn't work because the unflattening happens before bootmem is initialized. Swapping the order of bootmem init and unflattening could also fix this, but removing bootmem is desired. So enable NO_BOOTMEM on h8300 like other architectures have done. Fixes: 0fa1c579349f ("of/fdt: use memblock_virt_alloc for early alloc") Cc: Yoshinori Sato Cc: uclinux-h8-devel@lists.sourceforge.jp Signed-off-by: Rob Herring Signed-off-by: Yoshinori Sato --- arch/h8300/Kconfig | 1 + arch/h8300/kernel/setup.c | 36 ++++++++---------------------------- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig index 091d6d04b5e5..efc602634064 100644 --- a/arch/h8300/Kconfig +++ b/arch/h8300/Kconfig @@ -16,6 +16,7 @@ config H8300 select OF_IRQ select OF_EARLY_FLATTREE select HAVE_MEMBLOCK + select NO_BOOTMEM select TIMER_OF select H8300_TMR8 select HAVE_KERNEL_GZIP diff --git a/arch/h8300/kernel/setup.c b/arch/h8300/kernel/setup.c index a4d0470c10a9..33ed980e7aea 100644 --- a/arch/h8300/kernel/setup.c +++ b/arch/h8300/kernel/setup.c @@ -71,10 +71,6 @@ void __init h8300_fdt_init(void *fdt, char *bootargs) static void __init bootmem_init(void) { - int bootmap_size; - unsigned long ram_start_pfn; - unsigned long free_ram_start_pfn; - unsigned long ram_end_pfn; struct memblock_region *region; memory_end = memory_start = 0; @@ -88,33 +84,17 @@ static void __init bootmem_init(void) if (!memory_end) panic("No memory!"); - ram_start_pfn = PFN_UP(memory_start); - /* free_ram_start_pfn is first page after kernel */ - free_ram_start_pfn = PFN_UP(__pa(_end)); - ram_end_pfn = PFN_DOWN(memblock_end_of_DRAM()); + /* setup bootmem globals (we use no_bootmem, but mm still depends on this) */ + min_low_pfn = PFN_UP(memory_start); + max_low_pfn = PFN_DOWN(memblock_end_of_DRAM()); + max_pfn = max_low_pfn; - max_pfn = ram_end_pfn; + memblock_reserve(__pa(_stext), _end - _stext); - /* - * give all the memory to the bootmap allocator, tell it to put the - * boot mem_map at the start of memory - */ - bootmap_size = init_bootmem_node(NODE_DATA(0), - free_ram_start_pfn, - 0, - ram_end_pfn); - /* - * free the usable memory, we have to make sure we do not free - * the bootmem bitmap so we then reserve it after freeing it :-) - */ - free_bootmem(PFN_PHYS(free_ram_start_pfn), - (ram_end_pfn - free_ram_start_pfn) << PAGE_SHIFT); - reserve_bootmem(PFN_PHYS(free_ram_start_pfn), bootmap_size, - BOOTMEM_DEFAULT); + early_init_fdt_reserve_self(); + early_init_fdt_scan_reserved_mem(); - for_each_memblock(reserved, region) { - reserve_bootmem(region->base, region->size, BOOTMEM_DEFAULT); - } + memblock_dump_all(); } void __init setup_arch(char **cmdline_p) From 558e6694cd4da8db31c2d4850c4823efa5dc77e9 Mon Sep 17 00:00:00 2001 From: Yoshinori Sato Date: Mon, 13 Aug 2018 10:07:46 +0900 Subject: [PATCH 04/12] h8300: irqchip: fix warning Var "addr" type incorrect. It have interrupt controler register address. Type of void __iomem is correct. Signed-off-by: Yoshinori Sato --- drivers/irqchip/irq-renesas-h8s.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-renesas-h8s.c b/drivers/irqchip/irq-renesas-h8s.c index aed31afb0216..85234d456638 100644 --- a/drivers/irqchip/irq-renesas-h8s.c +++ b/drivers/irqchip/irq-renesas-h8s.c @@ -12,7 +12,7 @@ #include static void *intc_baseaddr; -#define IPRA ((unsigned long)intc_baseaddr) +#define IPRA (intc_baseaddr) static const unsigned char ipr_table[] = { 0x03, 0x02, 0x01, 0x00, 0x13, 0x12, 0x11, 0x10, /* 16 - 23 */ @@ -34,7 +34,7 @@ static const unsigned char ipr_table[] = { static void h8s_disable_irq(struct irq_data *data) { int pos; - unsigned int addr; + void __iomem *addr; unsigned short pri; int irq = data->irq; @@ -48,7 +48,7 @@ static void h8s_disable_irq(struct irq_data *data) static void h8s_enable_irq(struct irq_data *data) { int pos; - unsigned int addr; + void __iomem *addr; unsigned short pri; int irq = data->irq; From 5743ee22bf3f8842f2330925434a727e1044e2a1 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Thu, 21 Jun 2018 21:24:44 +0200 Subject: [PATCH 05/12] h8300: Correct signature of test_bit() mm/filemap.c: In function 'clear_bit_unlock_is_negative_byte': mm/filemap.c:1181:30: warning: passing argument 2 of 'test_bit' discards 'volatile' qualifier from pointer target type [-Wdiscarded-qualifiers] return test_bit(PG_waiters, mem); ^~~ In file included from include/linux/bitops.h:38, from include/linux/kernel.h:11, from include/linux/list.h:9, from include/linux/wait.h:7, from include/linux/wait_bit.h:8, from include/linux/fs.h:6, from include/linux/dax.h:5, from mm/filemap.c:14: arch/h8300/include/asm/bitops.h:69:57: note: expected 'const long unsigned int *' but argument is of type 'volatile void *' static inline int test_bit(int nr, const unsigned long *addr) ~~~~~~~~~~~~~~~~~~~~~^~~~ Make the bitmask pointed to by the "addr" parameter volatile to fix this, like is done on other architectures. Signed-off-by: Geert Uytterhoeven Signed-off-by: Yoshinori Sato --- arch/h8300/include/asm/bitops.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/h8300/include/asm/bitops.h b/arch/h8300/include/asm/bitops.h index b7ac7cf6f0de..647a83bd40b7 100644 --- a/arch/h8300/include/asm/bitops.h +++ b/arch/h8300/include/asm/bitops.h @@ -66,7 +66,7 @@ H8300_GEN_BITOP(change_bit, "bnot") #undef H8300_GEN_BITOP -static inline int test_bit(int nr, const unsigned long *addr) +static inline int test_bit(int nr, const volatile unsigned long *addr) { int ret = 0; unsigned char *b_addr; From ec3d5f1658f44538907b149d6396453e0ceedc60 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Tue, 19 Jun 2018 15:40:54 -0600 Subject: [PATCH 06/12] h8300: remove unnecessary of_platform_populate call The DT core will call of_platform_populate, so it is not necessary for arch specific code to call it unless there are custom match entries, auxdata or parent device. Neither of those apply here, so remove the call. Cc: Yoshinori Sato Cc: uclinux-h8-devel@lists.sourceforge.jp Signed-off-by: Rob Herring Signed-off-by: Yoshinori Sato --- arch/h8300/kernel/setup.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/arch/h8300/kernel/setup.c b/arch/h8300/kernel/setup.c index 33ed980e7aea..34e2df5c0d6d 100644 --- a/arch/h8300/kernel/setup.c +++ b/arch/h8300/kernel/setup.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -168,15 +167,6 @@ const struct seq_operations cpuinfo_op = { .show = show_cpuinfo, }; -static int __init device_probe(void) -{ - of_platform_populate(NULL, NULL, NULL, NULL); - - return 0; -} - -device_initcall(device_probe); - #if defined(CONFIG_CPU_H8300H) #define get_wait(base, addr) ({ \ int baddr; \ From 9819d4e47e88af3d7f082af61b55cb381f23f1a1 Mon Sep 17 00:00:00 2001 From: Will Deacon Date: Fri, 1 Jun 2018 17:06:21 +0100 Subject: [PATCH 07/12] h8300: Don't include linux/kernel.h in asm/atomic.h linux/kernel.h isn't needed by asm/atomic.h and will result in circular dependencies when the asm-generic atomic bitops are built around the tomic_long_t interface. Remove the broad include and replace it with linux/compiler.h for READ_ONCE etc and asm/irqflags.h for arch_local_irq_save etc. Cc: Yoshinori Sato Signed-off-by: Will Deacon Signed-off-by: Yoshinori Sato --- arch/h8300/include/asm/atomic.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/h8300/include/asm/atomic.h b/arch/h8300/include/asm/atomic.h index 941e7554e886..b174dec099bf 100644 --- a/arch/h8300/include/asm/atomic.h +++ b/arch/h8300/include/asm/atomic.h @@ -2,8 +2,10 @@ #ifndef __ARCH_H8300_ATOMIC__ #define __ARCH_H8300_ATOMIC__ +#include #include #include +#include /* * Atomic operations that C can't guarantee us. Useful for @@ -15,8 +17,6 @@ #define atomic_read(v) READ_ONCE((v)->counter) #define atomic_set(v, i) WRITE_ONCE(((v)->counter), (i)) -#include - #define ATOMIC_OP_RETURN(op, c_op) \ static inline int atomic_##op##_return(int i, atomic_t *v) \ { \ From 1b803a357d520164404c6262710049b09b93ed5a Mon Sep 17 00:00:00 2001 From: Luc Van Oostenryck Date: Wed, 30 May 2018 23:03:43 +0200 Subject: [PATCH 08/12] h8300:let the checker know that size_t is ulong All 64bit archs use unsigned long for size_t and most 32bit archs use 'unsigned int'. By default, this is what is assumed by sparse. However, on h8300 (a 32bit arch) size_t is unsigned long which can led sparse to emit wrong warnings. Fix this by passing to sparse the flag -msize-long, telling it that size_t is unsigned long. Signed-off-by: Luc Van Oostenryck Signed-off-by: Yoshinori Sato --- arch/h8300/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/h8300/Makefile b/arch/h8300/Makefile index e1c02ca230cb..eaac6685fe89 100644 --- a/arch/h8300/Makefile +++ b/arch/h8300/Makefile @@ -22,6 +22,8 @@ KBUILD_CFLAGS += -DUTS_SYSNAME=\"uClinux\" KBUILD_AFLAGS += $(aflags-y) LDFLAGS += $(ldflags-y) +CHECKFLAGS += -msize-long + ifeq ($(CROSS_COMPILE),) CROSS_COMPILE := h8300-unknown-linux- endif From cfa2d688e2cc286e97cf134e7f1c1ebb697c1c74 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Thu, 19 Jul 2018 19:34:53 -0700 Subject: [PATCH 09/12] arch/h8300: eliminate ptrace.h warnings Add a "struct task_struct;" stub to arch/h8300's ptrace.h header to eliminate gcc warnings (gcc version is 8.1.0). ../arch/h8300/include/asm/ptrace.h:32:34: warning: 'struct task_struct' declared inside parameter list will not be visible outside of this definition or declaration extern long h8300_get_reg(struct task_struct *task, int regno); ../arch/h8300/include/asm/ptrace.h:33:33: warning: 'struct task_struct' declared inside parameter list will not be visible outside of this definition or declaration extern int h8300_put_reg(struct task_struct *task, int regno, Signed-off-by: Randy Dunlap Cc: Yoshinori Sato Cc: uclinux-h8-devel@lists.sourceforge.jp Signed-off-by: Yoshinori Sato --- arch/h8300/include/asm/ptrace.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/h8300/include/asm/ptrace.h b/arch/h8300/include/asm/ptrace.h index 313cafa85380..66d383848ff1 100644 --- a/arch/h8300/include/asm/ptrace.h +++ b/arch/h8300/include/asm/ptrace.h @@ -4,6 +4,8 @@ #include +struct task_struct; + #ifndef __ASSEMBLY__ #ifndef PS_S #define PS_S (0x10) From ce156febeed1d2731fe6e325a842cb4640931d22 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Thu, 19 Jul 2018 19:36:06 -0700 Subject: [PATCH 10/12] arch/h8300: eliminate kgbd.c warning Drop the "const" qualifier from arch_kgdb_ops to eliminate the gcc warning (gcc version is 8.1.0). arch/h8300/kernel/kgdb.c:132:24: error: conflicting type qualifiers for 'arch_kgdb_ops' const struct kgdb_arch arch_kgdb_ops = { In file included from ../arch/h8300/kernel/kgdb.c:12: ../include/linux/kgdb.h:284:26: note: previous declaration of 'arch_kgdb_ops' was here extern struct kgdb_arch arch_kgdb_ops; Signed-off-by: Randy Dunlap Cc: Yoshinori Sato Cc: uclinux-h8-devel@lists.sourceforge.jp Signed-off-by: Yoshinori Sato --- arch/h8300/kernel/kgdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/h8300/kernel/kgdb.c b/arch/h8300/kernel/kgdb.c index 602e478afbd5..1a1d30cb0609 100644 --- a/arch/h8300/kernel/kgdb.c +++ b/arch/h8300/kernel/kgdb.c @@ -129,7 +129,7 @@ void kgdb_arch_exit(void) /* Nothing to do */ } -const struct kgdb_arch arch_kgdb_ops = { +struct kgdb_arch arch_kgdb_ops = { /* Breakpoint instruction: trapa #2 */ .gdb_bpt_instr = { 0x57, 0x20 }, }; From 7b291be81fde312868b9fd2f6a0419b76737f230 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Wed, 18 Jul 2018 23:04:29 -0700 Subject: [PATCH 11/12] arch/h8300: add a defconfig target Make the "defconfig" target valid for arch/h8300. Currently "make ARCH=h8300 defconfig" produces: *** Can't find default configuration "arch/h8300/defconfig"! ../scripts/kconfig/Makefile:87: recipe for target 'defconfig' failed By adding a value for KBUILD_DEFCONFIG, "make ARCH=h8300 defconfig" successfully produces a kernel .config file: *** Default configuration is based on 'edosk2674_defconfig' This is useful for Kconfig editing/testing. Signed-off-by: Randy Dunlap Cc: Yoshinori Sato Cc: uclinux-h8-devel@lists.sourceforge.jp (moderated for non-subscribers) Signed-off-by: Yoshinori Sato --- arch/h8300/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/h8300/Makefile b/arch/h8300/Makefile index eaac6685fe89..cc12b162c222 100644 --- a/arch/h8300/Makefile +++ b/arch/h8300/Makefile @@ -8,6 +8,8 @@ # (C) Copyright 2002-2015 Yoshinori Sato # +KBUILD_DEFCONFIG := edosk2674_defconfig + cflags-$(CONFIG_CPU_H8300H) := -mh aflags-$(CONFIG_CPU_H8300H) := -mh -Wa,--mach=h8300h ldflags-$(CONFIG_CPU_H8300H) := -mh8300helf_linux From 4bdf61ccbe76ee0c14bf228e7277072179b36ba3 Mon Sep 17 00:00:00 2001 From: Yoshinori Sato Date: Wed, 11 Jul 2018 18:39:09 +0900 Subject: [PATCH 12/12] h8300: fix IRQ no Old timer handler use 24 (Compare match A). But current timer handler use 26 (Overflow). Signed-off-by: Yoshinori Sato --- arch/h8300/boot/dts/h8300h_sim.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/h8300/boot/dts/h8300h_sim.dts b/arch/h8300/boot/dts/h8300h_sim.dts index f1c31cecdec8..595398b9d018 100644 --- a/arch/h8300/boot/dts/h8300h_sim.dts +++ b/arch/h8300/boot/dts/h8300h_sim.dts @@ -73,7 +73,7 @@ timer16: timer@ffff68 { compatible = "renesas,16bit-timer"; reg = <0xffff68 8>, <0xffff60 8>; - interrupts = <24 0>; + interrupts = <26 0>; renesas,channel = <0>; clocks = <&fclk>; clock-names = "fck";