From 439164663e5d1753360ff84ea4d5c598459e5d50 Mon Sep 17 00:00:00 2001 From: Will Deacon Date: Tue, 7 Aug 2012 17:59:53 +0100 Subject: openrisc: delay: fix loops calculation for __const_udelay The openrisc implementation of __const_udelay casts the result of a 32-bit multiplication to 64 bits and passes the top 32 bits to __delay. Since there are no casts on the arguments, this results in a __delay of zero, regardless of the xloops parameter. This patch fixes the problem by casting xloops to (unsigned long long), ensuring that the multiplication is not truncated. Cc: Jon Masters Signed-off-by: Will Deacon Signed-off-by: Jonas Bonn --- arch/openrisc/lib/delay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch') diff --git a/arch/openrisc/lib/delay.c b/arch/openrisc/lib/delay.c index 01d9740ae6f..0c12407d3d5 100644 --- a/arch/openrisc/lib/delay.c +++ b/arch/openrisc/lib/delay.c @@ -41,7 +41,7 @@ inline void __const_udelay(unsigned long xloops) { unsigned long long loops; - loops = xloops * loops_per_jiffy * HZ; + loops = (unsigned long long)xloops * loops_per_jiffy * HZ; __delay(loops >> 32); } -- cgit v1.2.3-18-g5258 From 807607f79b9d0ed81561746e4e1121905e75cf0f Mon Sep 17 00:00:00 2001 From: Will Deacon Date: Tue, 7 Aug 2012 17:59:54 +0100 Subject: openrisc: delay: fix handling of counter overflow If the counter overflows during a __delay operation, we will exit the loop prematurely. For example, calling __delay(0x100) with the counter at 0xffffff00 gives us a target of 0x0. The unsigned comparison in the while loop will likely be false on the first iteration (if the counter is now anything other than 0) and we will return early. This patch fixes the problem by comparing deltas in the loop rather than absolute values. Cc: Jon Masters Signed-off-by: Will Deacon Signed-off-by: Jonas Bonn --- arch/openrisc/lib/delay.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'arch') diff --git a/arch/openrisc/lib/delay.c b/arch/openrisc/lib/delay.c index 0c12407d3d5..c330767c921 100644 --- a/arch/openrisc/lib/delay.c +++ b/arch/openrisc/lib/delay.c @@ -30,9 +30,9 @@ int __devinit read_current_timer(unsigned long *timer_value) void __delay(unsigned long cycles) { - cycles_t target = get_cycles() + cycles; + cycles_t start = get_cycles(); - while (get_cycles() < target) + while ((get_cycles() - start) < cycles) cpu_relax(); } EXPORT_SYMBOL(__delay); -- cgit v1.2.3-18-g5258 From e2bebb4ae6d9ac4ffc524db67f7ecb205a173f77 Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Thu, 20 Sep 2012 15:46:06 -0700 Subject: audit: define AUDIT_ARCH_OPENRISC When using audit on OpenRISC, an audit arch is needed. This defines it and fixes a compile-time bug uncovered in linux-next, likely from a cut/paste from an arch with 64/32-bit modes that defined arch_arch(): arch/openrisc/kernel/ptrace.c:190:2: error: implicit declaration of function 'audit_arch' This replaces it with the newly defined AUDIT_ARCH_OPENRISC, since it is only 32-bit, and currently only operates in big-endian mode. Reported-by: Geert Uytterhoeven Signed-off-by: Kees Cook Signed-off-by: Jonas Bonn --- arch/openrisc/kernel/ptrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch') diff --git a/arch/openrisc/kernel/ptrace.c b/arch/openrisc/kernel/ptrace.c index e71781d24b0..71a2a0c34c6 100644 --- a/arch/openrisc/kernel/ptrace.c +++ b/arch/openrisc/kernel/ptrace.c @@ -187,7 +187,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs) */ ret = -1L; - audit_syscall_entry(audit_arch(), regs->gpr[11], + audit_syscall_entry(AUDIT_ARCH_OPENRISC, regs->gpr[11], regs->gpr[3], regs->gpr[4], regs->gpr[5], regs->gpr[6]); -- cgit v1.2.3-18-g5258 From 9b76beb071be6fbfd0743feedfdd844f57d4f345 Mon Sep 17 00:00:00 2001 From: Vladimir Murzin Date: Mon, 17 Sep 2012 20:57:08 +0400 Subject: openrisc: Make cpu_relax() invoke barrier() Make cpu_relax() invoke barrier() to be the same as other arches. Signed-off-by: Vladimir Murzin Signed-off-by: Jonas Bonn --- arch/openrisc/include/asm/processor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch') diff --git a/arch/openrisc/include/asm/processor.h b/arch/openrisc/include/asm/processor.h index 30462f1fe95..43decdbdb2e 100644 --- a/arch/openrisc/include/asm/processor.h +++ b/arch/openrisc/include/asm/processor.h @@ -103,7 +103,7 @@ extern unsigned long thread_saved_pc(struct task_struct *t); #define init_stack (init_thread_union.stack) -#define cpu_relax() do { } while (0) +#define cpu_relax() barrier() #endif /* __ASSEMBLY__ */ #endif /* __ASM_OPENRISC_PROCESSOR_H */ -- cgit v1.2.3-18-g5258 From f248ef1cd39dc9900cca5bf0a51b1e80081ecc67 Mon Sep 17 00:00:00 2001 From: Jonas Bonn Date: Fri, 21 Sep 2012 09:17:32 +0200 Subject: openrisc: PIC should act on domain-local irqs Now that IRQ domains are in use, we should be acting on domain-local IRQ numbers (hwirq) instead of 'global' ones. Signed-off-by: Jonas Bonn --- arch/openrisc/kernel/irq.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'arch') diff --git a/arch/openrisc/kernel/irq.c b/arch/openrisc/kernel/irq.c index e935b9d8eee..094c394eee5 100644 --- a/arch/openrisc/kernel/irq.c +++ b/arch/openrisc/kernel/irq.c @@ -46,12 +46,12 @@ EXPORT_SYMBOL(arch_local_irq_restore); static void or1k_pic_mask(struct irq_data *data) { - mtspr(SPR_PICMR, mfspr(SPR_PICMR) & ~(1UL << data->irq)); + mtspr(SPR_PICMR, mfspr(SPR_PICMR) & ~(1UL << data->hwirq)); } static void or1k_pic_unmask(struct irq_data *data) { - mtspr(SPR_PICMR, mfspr(SPR_PICMR) | (1UL << data->irq)); + mtspr(SPR_PICMR, mfspr(SPR_PICMR) | (1UL << data->hwirq)); } static void or1k_pic_ack(struct irq_data *data) @@ -75,10 +75,10 @@ static void or1k_pic_ack(struct irq_data *data) * as opposed to a 1 as mandated by the spec */ - mtspr(SPR_PICSR, mfspr(SPR_PICSR) & ~(1UL << data->irq)); + mtspr(SPR_PICSR, mfspr(SPR_PICSR) & ~(1UL << data->hwirq)); #else WARN(1, "Interrupt handling possibily broken\n"); - mtspr(SPR_PICSR, (1UL << irq)); + mtspr(SPR_PICSR, (1UL << data->hwirq)); #endif } @@ -87,10 +87,10 @@ static void or1k_pic_mask_ack(struct irq_data *data) /* Comments for pic_ack apply here, too */ #ifdef CONFIG_OR1K_1200 - mtspr(SPR_PICSR, mfspr(SPR_PICSR) & ~(1UL << data->irq)); + mtspr(SPR_PICSR, mfspr(SPR_PICSR) & ~(1UL << data->hwirq)); #else WARN(1, "Interrupt handling possibily broken\n"); - mtspr(SPR_PICSR, (1UL << irq)); + mtspr(SPR_PICSR, (1UL << data->hwirq)); #endif } -- cgit v1.2.3-18-g5258 From 8eea8a6a9a2af067bd3006f7fefab66a4fb66451 Mon Sep 17 00:00:00 2001 From: Jonas Bonn Date: Fri, 21 Sep 2012 09:19:48 +0200 Subject: openrisc: fix typos in comments and warnings Signed-off-by: Jonas Bonn --- arch/openrisc/kernel/irq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'arch') diff --git a/arch/openrisc/kernel/irq.c b/arch/openrisc/kernel/irq.c index 094c394eee5..61327985f96 100644 --- a/arch/openrisc/kernel/irq.c +++ b/arch/openrisc/kernel/irq.c @@ -58,7 +58,7 @@ static void or1k_pic_ack(struct irq_data *data) { /* EDGE-triggered interrupts need to be ack'ed in order to clear * the latch. - * LEVER-triggered interrupts do not need to be ack'ed; however, + * LEVEL-triggered interrupts do not need to be ack'ed; however, * ack'ing the interrupt has no ill-effect and is quicker than * trying to figure out what type it is... */ @@ -77,7 +77,7 @@ static void or1k_pic_ack(struct irq_data *data) mtspr(SPR_PICSR, mfspr(SPR_PICSR) & ~(1UL << data->hwirq)); #else - WARN(1, "Interrupt handling possibily broken\n"); + WARN(1, "Interrupt handling possibly broken\n"); mtspr(SPR_PICSR, (1UL << data->hwirq)); #endif } @@ -89,7 +89,7 @@ static void or1k_pic_mask_ack(struct irq_data *data) #ifdef CONFIG_OR1K_1200 mtspr(SPR_PICSR, mfspr(SPR_PICSR) & ~(1UL << data->hwirq)); #else - WARN(1, "Interrupt handling possibily broken\n"); + WARN(1, "Interrupt handling possibly broken\n"); mtspr(SPR_PICSR, (1UL << data->hwirq)); #endif } -- cgit v1.2.3-18-g5258 From d23b5799b608112bb799c9b0e1e11ee1da692d76 Mon Sep 17 00:00:00 2001 From: Gong Tao Date: Fri, 21 Sep 2012 08:49:58 +0200 Subject: openrisc: mask interrupts in irq_mask_ack function or1k_pic_mask_ack was failing to actually mask the IRQ. Signed-off-by: Gong Tao Signed-off-by: Jonas Bonn --- arch/openrisc/kernel/irq.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'arch') diff --git a/arch/openrisc/kernel/irq.c b/arch/openrisc/kernel/irq.c index 61327985f96..8ec77bc9f1e 100644 --- a/arch/openrisc/kernel/irq.c +++ b/arch/openrisc/kernel/irq.c @@ -87,9 +87,11 @@ static void or1k_pic_mask_ack(struct irq_data *data) /* Comments for pic_ack apply here, too */ #ifdef CONFIG_OR1K_1200 + mtspr(SPR_PICMR, mfspr(SPR_PICMR) & ~(1UL << data->hwirq)); mtspr(SPR_PICSR, mfspr(SPR_PICSR) & ~(1UL << data->hwirq)); #else WARN(1, "Interrupt handling possibly broken\n"); + mtspr(SPR_PICMR, (1UL << data->hwirq)); mtspr(SPR_PICSR, (1UL << data->hwirq)); #endif } -- cgit v1.2.3-18-g5258