From 4c86231c14a8a1e9838dcb013ded07ebd2f2a1a5 Mon Sep 17 00:00:00 2001 From: Vineet Gupta Date: Fri, 12 Dec 2014 10:05:03 +0530 Subject: ARC: fix /proc/cpuinfo for offline cpus Signed-off-by: Vineet Gupta --- arch/arc/kernel/setup.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c index 252bf60..900f68a 100644 --- a/arch/arc/kernel/setup.c +++ b/arch/arc/kernel/setup.c @@ -412,6 +412,11 @@ static int show_cpuinfo(struct seq_file *m, void *v) char *str; int cpu_id = ptr_to_cpu(v); + if (!cpu_online(cpu_id)) { + seq_printf(m, "processor [%d]\t: Offline\n", cpu_id); + goto done; + } + str = (char *)__get_free_page(GFP_TEMPORARY); if (!str) goto done; @@ -429,7 +434,7 @@ static int show_cpuinfo(struct seq_file *m, void *v) free_page((unsigned long)str); done: - seq_printf(m, "\n\n"); + seq_printf(m, "\n"); return 0; } -- cgit v1.1 From 98edfab4c10343bd3ba1ca47d000544b9f964886 Mon Sep 17 00:00:00 2001 From: Vineet Gupta Date: Mon, 15 Dec 2014 16:33:39 +0530 Subject: ARC: add some more comments to ret_from_fork Signed-off-by: Vineet Gupta --- arch/arc/kernel/entry.S | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S index 83a046a..d868289 100644 --- a/arch/arc/kernel/entry.S +++ b/arch/arc/kernel/entry.S @@ -736,16 +736,20 @@ ENTRY(ret_from_fork) ; put last task in scheduler queue bl @schedule_tail - ; If kernel thread, jump to its entry-point ld r9, [sp, PT_status32] brne r9, 0, 1f - jl.d [r14] - mov r0, r13 ; arg to payload + jl.d [r14] ; kernel thread entry point + mov r0, r13 ; (see PF_KTHREAD block in copy_thread) 1: - ; special case of kernel_thread entry point returning back due to - ; kernel_execve() - pretend return from syscall to ret to userland + ; Return to user space + ; 1. Any forked task (Reach here via BRne above) + ; 2. First ever init task (Reach here via return from JL above) + ; This is the historic "kernel_execve" use-case, to return to init + ; user mode, in a round about way since that is always done from + ; a kernel thread which is executed via JL above but always returns + ; out whenever kernel_execve (now inline do_fork()) is involved b ret_from_exception END(ret_from_fork) -- cgit v1.1 From 7082a29c22ac0ab276b346f2a5c1d24a2102f158 Mon Sep 17 00:00:00 2001 From: Vineet Gupta Date: Mon, 15 Dec 2014 18:42:24 +0530 Subject: ARC: use ACCESS_ONCE in cmpxchg loop Signed-off-by: Vineet Gupta --- arch/arc/kernel/smp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c index 20ebb60..6a400b1 100644 --- a/arch/arc/kernel/smp.c +++ b/arch/arc/kernel/smp.c @@ -221,7 +221,7 @@ static void ipi_send_msg_one(int cpu, enum ipi_msg_type msg) * and read back old value */ do { - new = old = *ipi_data_ptr; + new = old = ACCESS_ONCE(*ipi_data_ptr); new |= 1U << msg; } while (cmpxchg(ipi_data_ptr, old, new) != old); -- cgit v1.1 From 7bf6df575fd628fd7ec737789ae8bcb7081d77de Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 5 Jan 2015 15:24:18 +0100 Subject: arc: Remove unused prepare_to_copy() prepare_to_copy() was removed from all architectures supported at that time in commit 55ccf3fe3f9a ("fork: move the real prepare_to_copy() users to arch_dup_task_struct()"). Remove it from arc as well. Signed-off-by: Tobias Klauser Signed-off-by: Vineet Gupta --- arch/arc/include/asm/processor.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/arc/include/asm/processor.h b/arch/arc/include/asm/processor.h index 210fe97..4e54729 100644 --- a/arch/arc/include/asm/processor.h +++ b/arch/arc/include/asm/processor.h @@ -56,9 +56,6 @@ unsigned long thread_saved_pc(struct task_struct *t); /* Free all resources held by a thread */ #define release_thread(thread) do { } while (0) -/* Prepare to copy thread state - unlazy all lazy status */ -#define prepare_to_copy(tsk) do { } while (0) - /* * A lot of busy-wait loops in SMP are based off of non-volatile data otherwise * get optimised away by gcc -- cgit v1.1 From ffb7fcd66f14bc716b9fdf559e71909131fef39b Mon Sep 17 00:00:00 2001 From: Vineet Gupta Date: Tue, 28 Oct 2014 15:04:05 +0530 Subject: ARC: Dynamically determine BASE_BAUD from DeviceTree 8250 earlycon is broken on multi-platform ARC because the UART clk value (BASE_BAUD) is fixed at build time. Instead, determine the appropriate UART clk at runtime; parse the devicetree early for platforms requiring alternate UART clk values (currently only the TB10X platform). Cc: Jiri Slaby Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: Rob Herring Cc: Arnd Bergmann Reviewed-by: Peter Hurley Acked-by: Greg Kroah-Hartman Signed-off-by: Vineet Gupta --- arch/arc/include/asm/serial.h | 23 +++++------------------ arch/arc/kernel/devtree.c | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/arch/arc/include/asm/serial.h b/arch/arc/include/asm/serial.h index 602b097..744a6ae 100644 --- a/arch/arc/include/asm/serial.h +++ b/arch/arc/include/asm/serial.h @@ -10,26 +10,13 @@ #define _ASM_ARC_SERIAL_H /* - * early-8250 requires BASE_BAUD to be defined and includes this header. - * We put in a typical value: - * (core clk / 16) - i.e. UART samples 16 times per sec. - * Athough in multi-platform-image this might not work, specially if the - * clk driving the UART is different. - * We can't use DeviceTree as this is typically for early serial. + * early 8250 (now earlycon) requires BASE_BAUD to be defined in this header. + * However to still determine it dynamically (for multi-platform images) + * we do this in a helper by parsing the FDT early */ -#include +extern unsigned int __init arc_early_base_baud(void); -#define BASE_BAUD (arc_get_core_freq() / 16) - -/* - * This is definitely going to break early 8250 consoles on multi-platform - * images but hey, it won't add any code complexity for a debug feature of - * one broken driver. - */ -#ifdef CONFIG_ARC_PLAT_TB10X -#undef BASE_BAUD -#define BASE_BAUD (arc_get_core_freq() / 16 / 3) -#endif +#define BASE_BAUD arc_early_base_baud() #endif /* _ASM_ARC_SERIAL_H */ diff --git a/arch/arc/kernel/devtree.c b/arch/arc/kernel/devtree.c index fffdb5e..5036d4c 100644 --- a/arch/arc/kernel/devtree.c +++ b/arch/arc/kernel/devtree.c @@ -17,6 +17,28 @@ #include #include +#ifdef CONFIG_SERIAL_8250_CONSOLE + +static unsigned int __initdata arc_base_baud; + +unsigned int __init arc_early_base_baud(void) +{ + return arc_base_baud/16; +} + +static void __init arc_set_early_base_baud(unsigned long dt_root) +{ + unsigned int core_clk = arc_get_core_freq(); + + if (of_flat_dt_is_compatible(dt_root, "abilis,arc-tb10x")) + arc_base_baud = core_clk/3; + else + arc_base_baud = core_clk; +} +#else +#define arc_set_early_base_baud(dt_root) +#endif + static const void * __init arch_get_next_mach(const char *const **match) { static const struct machine_desc *mdesc = __arch_info_begin; @@ -56,5 +78,7 @@ const struct machine_desc * __init setup_machine_fdt(void *dt) if (clk) arc_set_core_freq(of_read_ulong(clk, len/4)); + arc_set_early_base_baud(dt_root); + return mdesc; } -- cgit v1.1 From 091f56be10efe8ac7c09d6368d885f41fa7eb809 Mon Sep 17 00:00:00 2001 From: Peter Hurley Date: Tue, 3 Feb 2015 20:08:52 -0500 Subject: ARC: Fix earlycon build breakage Commit ffb7fcd66f14 ("ARC: Dynamically determine BASE_BAUD from DeviceTree") breaks arc:defconfig build: drivers/built-in.o: In function `of_setup_earlycon': (.init.text+0xb3e): undefined reference to `arc_early_base_baud' drivers/built-in.o: In function `setup_earlycon': (.init.text+0xcd0): undefined reference to `arc_early_base_baud' make: *** [vmlinux] Error 1 BASE_BAUD is only required for earlycon, which should depend on CONFIG_SERIAL_EARLYCON. Reported-by: Guenter Roeck Tested-by: Guenter Roeck Signed-off-by: Peter Hurley Signed-off-by: Vineet Gupta --- arch/arc/kernel/devtree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arc/kernel/devtree.c b/arch/arc/kernel/devtree.c index 5036d4c..e32b54a 100644 --- a/arch/arc/kernel/devtree.c +++ b/arch/arc/kernel/devtree.c @@ -17,7 +17,7 @@ #include #include -#ifdef CONFIG_SERIAL_8250_CONSOLE +#ifdef CONFIG_SERIAL_EARLYCON static unsigned int __initdata arc_base_baud; -- cgit v1.1 From 06f34e1c28f3608b0ce5b310e41102d3fe7b65a1 Mon Sep 17 00:00:00 2001 From: Alexey Brodkin Date: Thu, 12 Feb 2015 21:10:11 +0300 Subject: ARC: fix page address calculation if PAGE_OFFSET != LINUX_LINK_BASE We used to calculate page address differently in 2 cases: 1. In virt_to_page(x) we do --->8--- mem_map + (x - CONFIG_LINUX_LINK_BASE) >> PAGE_SHIFT --->8--- 2. In in pte_page(x) we do --->8--- mem_map + (pte_val(x) - PAGE_OFFSET) >> PAGE_SHIFT --->8--- That leads to problems in case PAGE_OFFSET != CONFIG_LINUX_LINK_BASE - different pages will be selected depending on where and how we calculate page address. In particular in the STAR 9000853582 when gdb attempted to read memory of another process it got improper page in get_user_pages() because this is exactly one of the places where we search for a page by pte_page(). The fix is trivial - we need to calculate page address similarly in both cases. Cc: Signed-off-by: Alexey Brodkin Signed-off-by: Vineet Gupta --- arch/arc/include/asm/pgtable.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arc/include/asm/pgtable.h b/arch/arc/include/asm/pgtable.h index 6b0b7f7e..7670f33 100644 --- a/arch/arc/include/asm/pgtable.h +++ b/arch/arc/include/asm/pgtable.h @@ -259,7 +259,8 @@ static inline void pmd_set(pmd_t *pmdp, pte_t *ptep) #define pmd_clear(xp) do { pmd_val(*(xp)) = 0; } while (0) #define pte_page(x) (mem_map + \ - (unsigned long)(((pte_val(x) - PAGE_OFFSET) >> PAGE_SHIFT))) + (unsigned long)(((pte_val(x) - CONFIG_LINUX_LINK_BASE) >> \ + PAGE_SHIFT))) #define mk_pte(page, pgprot) \ ({ \ -- cgit v1.1