2005-04-16 15:20:36 -07:00
|
|
|
/*
|
|
|
|
* Derived from arch/i386/kernel/irq.c
|
|
|
|
* Copyright (C) 1992 Linus Torvalds
|
|
|
|
* Adapted from arch/i386 by Gary Thomas
|
|
|
|
* Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
|
2005-11-09 18:07:45 +11:00
|
|
|
* Updated and modified by Cort Dougan <cort@fsmlabs.com>
|
|
|
|
* Copyright (C) 1996-2001 Cort Dougan
|
2005-04-16 15:20:36 -07:00
|
|
|
* Adapted for Power Macintosh by Paul Mackerras
|
|
|
|
* Copyright (C) 1996 Paul Mackerras (paulus@cs.anu.edu.au)
|
2005-11-09 18:07:45 +11:00
|
|
|
*
|
2005-04-16 15:20:36 -07:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This file contains the code used by various IRQ handling routines:
|
|
|
|
* asking for different IRQ's should be done through these routines
|
|
|
|
* instead of just grabbing them. Thus setups with different IRQ numbers
|
|
|
|
* shouldn't result in any weird surprises, and installing new handlers
|
|
|
|
* should be easier.
|
2005-11-09 18:07:45 +11:00
|
|
|
*
|
|
|
|
* The MPC8xx has an interrupt mask in the SIU. If a bit is set, the
|
|
|
|
* interrupt is _enabled_. As expected, IRQ0 is bit 0 in the 32-bit
|
|
|
|
* mask register (of which only 16 are defined), hence the weird shifting
|
|
|
|
* and complement of the cached_irq_mask. I want to be able to stuff
|
|
|
|
* this right into the SIU SMASK register.
|
|
|
|
* Many of the prep/chrp functions are conditional compiled on CONFIG_8xx
|
|
|
|
* to reduce code space and undefined function references.
|
2005-04-16 15:20:36 -07:00
|
|
|
*/
|
|
|
|
|
2006-07-03 21:36:01 +10:00
|
|
|
#undef DEBUG
|
|
|
|
|
2011-07-22 18:24:23 -04:00
|
|
|
#include <linux/export.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <linux/threads.h>
|
|
|
|
#include <linux/kernel_stat.h>
|
|
|
|
#include <linux/signal.h>
|
|
|
|
#include <linux/sched.h>
|
2005-11-09 18:07:45 +11:00
|
|
|
#include <linux/ptrace.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/timex.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/irq.h>
|
2005-11-09 18:07:45 +11:00
|
|
|
#include <linux/seq_file.h>
|
|
|
|
#include <linux/cpumask.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <linux/profile.h>
|
|
|
|
#include <linux/bitops.h>
|
2006-07-03 21:36:01 +10:00
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/radix-tree.h>
|
|
|
|
#include <linux/mutex.h>
|
|
|
|
#include <linux/bootmem.h>
|
2006-07-27 13:17:25 -05:00
|
|
|
#include <linux/pci.h>
|
2007-08-28 18:47:57 +10:00
|
|
|
#include <linux/debugfs.h>
|
2010-06-18 11:09:59 -06:00
|
|
|
#include <linux/of.h>
|
|
|
|
#include <linux/of_irq.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
#include <asm/system.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/pgtable.h>
|
|
|
|
#include <asm/irq.h>
|
|
|
|
#include <asm/cache.h>
|
|
|
|
#include <asm/prom.h>
|
|
|
|
#include <asm/ptrace.h>
|
|
|
|
#include <asm/machdep.h>
|
2006-07-03 21:36:01 +10:00
|
|
|
#include <asm/udbg.h>
|
2010-08-18 06:44:25 +00:00
|
|
|
#include <asm/smp.h>
|
2010-07-09 15:31:28 +10:00
|
|
|
|
[POWERPC] Lazy interrupt disabling for 64-bit machines
This implements a lazy strategy for disabling interrupts. This means
that local_irq_disable() et al. just clear the 'interrupts are
enabled' flag in the paca. If an interrupt comes along, the interrupt
entry code notices that interrupts are supposed to be disabled, and
clears the EE bit in SRR1, clears the 'interrupts are hard-enabled'
flag in the paca, and returns. This means that interrupts only
actually get disabled in the processor when an interrupt comes along.
When interrupts are enabled by local_irq_enable() et al., the code
sets the interrupts-enabled flag in the paca, and then checks whether
interrupts got hard-disabled. If so, it also sets the EE bit in the
MSR to hard-enable the interrupts.
This has the potential to improve performance, and also makes it
easier to make a kernel that can boot on iSeries and on other 64-bit
machines, since this lazy-disable strategy is very similar to the
soft-disable strategy that iSeries already uses.
This version renames paca->proc_enabled to paca->soft_enabled, and
changes a couple of soft-disables in the kexec code to hard-disables,
which should fix the crash that Michael Ellerman saw. This doesn't
yet use a reserved CR field for the soft_enabled and hard_enabled
flags. This applies on top of Stephen Rothwell's patches to make it
possible to build a combined iSeries/other kernel.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-10-04 16:47:49 +10:00
|
|
|
#ifdef CONFIG_PPC64
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <asm/paca.h>
|
[POWERPC] Lazy interrupt disabling for 64-bit machines
This implements a lazy strategy for disabling interrupts. This means
that local_irq_disable() et al. just clear the 'interrupts are
enabled' flag in the paca. If an interrupt comes along, the interrupt
entry code notices that interrupts are supposed to be disabled, and
clears the EE bit in SRR1, clears the 'interrupts are hard-enabled'
flag in the paca, and returns. This means that interrupts only
actually get disabled in the processor when an interrupt comes along.
When interrupts are enabled by local_irq_enable() et al., the code
sets the interrupts-enabled flag in the paca, and then checks whether
interrupts got hard-disabled. If so, it also sets the EE bit in the
MSR to hard-enable the interrupts.
This has the potential to improve performance, and also makes it
easier to make a kernel that can boot on iSeries and on other 64-bit
machines, since this lazy-disable strategy is very similar to the
soft-disable strategy that iSeries already uses.
This version renames paca->proc_enabled to paca->soft_enabled, and
changes a couple of soft-disables in the kexec code to hard-disables,
which should fix the crash that Michael Ellerman saw. This doesn't
yet use a reserved CR field for the soft_enabled and hard_enabled
flags. This applies on top of Stephen Rothwell's patches to make it
possible to build a combined iSeries/other kernel.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-10-04 16:47:49 +10:00
|
|
|
#include <asm/firmware.h>
|
2007-05-01 07:01:07 +10:00
|
|
|
#include <asm/lv1call.h>
|
2005-11-09 18:07:45 +11:00
|
|
|
#endif
|
2009-10-26 18:47:42 +00:00
|
|
|
#define CREATE_TRACE_POINTS
|
|
|
|
#include <asm/trace.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2010-01-31 20:30:23 +00:00
|
|
|
DEFINE_PER_CPU_SHARED_ALIGNED(irq_cpustat_t, irq_stat);
|
|
|
|
EXPORT_PER_CPU_SYMBOL(irq_stat);
|
|
|
|
|
2005-11-10 18:38:46 +11:00
|
|
|
int __irq_offset_value;
|
2005-11-09 18:07:45 +11:00
|
|
|
|
|
|
|
#ifdef CONFIG_PPC32
|
2006-07-03 19:32:51 +10:00
|
|
|
EXPORT_SYMBOL(__irq_offset_value);
|
|
|
|
atomic_t ppc_n_lost_interrupts;
|
2005-11-09 18:07:45 +11:00
|
|
|
|
|
|
|
#ifdef CONFIG_TAU_INT
|
|
|
|
extern int tau_initialized;
|
|
|
|
extern int tau_interrupts(int);
|
|
|
|
#endif
|
2006-07-03 19:32:51 +10:00
|
|
|
#endif /* CONFIG_PPC32 */
|
2005-11-09 18:07:45 +11:00
|
|
|
|
|
|
|
#ifdef CONFIG_PPC64
|
2009-10-13 19:45:03 +00:00
|
|
|
|
|
|
|
#ifndef CONFIG_SPARSE_IRQ
|
2005-04-16 15:20:36 -07:00
|
|
|
EXPORT_SYMBOL(irq_desc);
|
2009-10-13 19:45:03 +00:00
|
|
|
#endif
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
int distribute_irqs = 1;
|
[POWERPC] Lazy interrupt disabling for 64-bit machines
This implements a lazy strategy for disabling interrupts. This means
that local_irq_disable() et al. just clear the 'interrupts are
enabled' flag in the paca. If an interrupt comes along, the interrupt
entry code notices that interrupts are supposed to be disabled, and
clears the EE bit in SRR1, clears the 'interrupts are hard-enabled'
flag in the paca, and returns. This means that interrupts only
actually get disabled in the processor when an interrupt comes along.
When interrupts are enabled by local_irq_enable() et al., the code
sets the interrupts-enabled flag in the paca, and then checks whether
interrupts got hard-disabled. If so, it also sets the EE bit in the
MSR to hard-enable the interrupts.
This has the potential to improve performance, and also makes it
easier to make a kernel that can boot on iSeries and on other 64-bit
machines, since this lazy-disable strategy is very similar to the
soft-disable strategy that iSeries already uses.
This version renames paca->proc_enabled to paca->soft_enabled, and
changes a couple of soft-disables in the kexec code to hard-disables,
which should fix the crash that Michael Ellerman saw. This doesn't
yet use a reserved CR field for the soft_enabled and hard_enabled
flags. This applies on top of Stephen Rothwell's patches to make it
possible to build a combined iSeries/other kernel.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-10-04 16:47:49 +10:00
|
|
|
|
2008-05-14 23:49:44 -04:00
|
|
|
static inline notrace unsigned long get_hard_enabled(void)
|
2006-11-10 21:32:40 +00:00
|
|
|
{
|
|
|
|
unsigned long enabled;
|
|
|
|
|
|
|
|
__asm__ __volatile__("lbz %0,%1(13)"
|
|
|
|
: "=r" (enabled) : "i" (offsetof(struct paca_struct, hard_enabled)));
|
|
|
|
|
|
|
|
return enabled;
|
|
|
|
}
|
|
|
|
|
2008-05-14 23:49:44 -04:00
|
|
|
static inline notrace void set_soft_enabled(unsigned long enable)
|
2006-11-10 21:32:40 +00:00
|
|
|
{
|
|
|
|
__asm__ __volatile__("stb %0,%1(13)"
|
|
|
|
: : "r" (enable), "i" (offsetof(struct paca_struct, soft_enabled)));
|
|
|
|
}
|
|
|
|
|
powerpc/time: Optimise decrementer_check_overflow
decrementer_check_overflow is called from arch_local_irq_restore so
we want to make it as light weight as possible. As such, turn
decrementer_check_overflow into an inline function.
To avoid a circular mess of includes, separate out the two components
of struct decrementer_clock and keep the struct clock_event_device
part local to time.c.
The fast path improves from:
arch_local_irq_restore
0: mflr r0
4: std r0,16(r1)
8: stdu r1,-112(r1)
c: stb r3,578(r13)
10: cmpdi cr7,r3,0
14: beq- cr7,24 <.arch_local_irq_restore+0x24>
...
24: addi r1,r1,112
28: ld r0,16(r1)
2c: mtlr r0
30: blr
to:
arch_local_irq_restore
0: std r30,-16(r1)
4: ld r30,0(r2)
8: stb r3,578(r13)
c: cmpdi cr7,r3,0
10: beq- cr7,6c <.arch_local_irq_restore+0x6c>
...
6c: ld r30,-16(r1)
70: blr
Unfortunately we still setup a local TOC (due to -mminimal-toc). Yet
another sign we should be moving to -mcmodel=medium.
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2011-11-23 20:07:22 +00:00
|
|
|
static inline notrace void decrementer_check_overflow(void)
|
|
|
|
{
|
|
|
|
u64 now = get_tb_or_rtc();
|
2012-02-08 19:34:13 +00:00
|
|
|
u64 *next_tb;
|
|
|
|
|
|
|
|
preempt_disable();
|
|
|
|
next_tb = &__get_cpu_var(decrementers_next_tb);
|
powerpc/time: Optimise decrementer_check_overflow
decrementer_check_overflow is called from arch_local_irq_restore so
we want to make it as light weight as possible. As such, turn
decrementer_check_overflow into an inline function.
To avoid a circular mess of includes, separate out the two components
of struct decrementer_clock and keep the struct clock_event_device
part local to time.c.
The fast path improves from:
arch_local_irq_restore
0: mflr r0
4: std r0,16(r1)
8: stdu r1,-112(r1)
c: stb r3,578(r13)
10: cmpdi cr7,r3,0
14: beq- cr7,24 <.arch_local_irq_restore+0x24>
...
24: addi r1,r1,112
28: ld r0,16(r1)
2c: mtlr r0
30: blr
to:
arch_local_irq_restore
0: std r30,-16(r1)
4: ld r30,0(r2)
8: stb r3,578(r13)
c: cmpdi cr7,r3,0
10: beq- cr7,6c <.arch_local_irq_restore+0x6c>
...
6c: ld r30,-16(r1)
70: blr
Unfortunately we still setup a local TOC (due to -mminimal-toc). Yet
another sign we should be moving to -mcmodel=medium.
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2011-11-23 20:07:22 +00:00
|
|
|
|
|
|
|
if (now >= *next_tb)
|
|
|
|
set_dec(1);
|
2012-02-08 19:34:13 +00:00
|
|
|
preempt_enable();
|
powerpc/time: Optimise decrementer_check_overflow
decrementer_check_overflow is called from arch_local_irq_restore so
we want to make it as light weight as possible. As such, turn
decrementer_check_overflow into an inline function.
To avoid a circular mess of includes, separate out the two components
of struct decrementer_clock and keep the struct clock_event_device
part local to time.c.
The fast path improves from:
arch_local_irq_restore
0: mflr r0
4: std r0,16(r1)
8: stdu r1,-112(r1)
c: stb r3,578(r13)
10: cmpdi cr7,r3,0
14: beq- cr7,24 <.arch_local_irq_restore+0x24>
...
24: addi r1,r1,112
28: ld r0,16(r1)
2c: mtlr r0
30: blr
to:
arch_local_irq_restore
0: std r30,-16(r1)
4: ld r30,0(r2)
8: stb r3,578(r13)
c: cmpdi cr7,r3,0
10: beq- cr7,6c <.arch_local_irq_restore+0x6c>
...
6c: ld r30,-16(r1)
70: blr
Unfortunately we still setup a local TOC (due to -mminimal-toc). Yet
another sign we should be moving to -mcmodel=medium.
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2011-11-23 20:07:22 +00:00
|
|
|
}
|
|
|
|
|
2010-10-07 14:08:55 +01:00
|
|
|
notrace void arch_local_irq_restore(unsigned long en)
|
[POWERPC] Lazy interrupt disabling for 64-bit machines
This implements a lazy strategy for disabling interrupts. This means
that local_irq_disable() et al. just clear the 'interrupts are
enabled' flag in the paca. If an interrupt comes along, the interrupt
entry code notices that interrupts are supposed to be disabled, and
clears the EE bit in SRR1, clears the 'interrupts are hard-enabled'
flag in the paca, and returns. This means that interrupts only
actually get disabled in the processor when an interrupt comes along.
When interrupts are enabled by local_irq_enable() et al., the code
sets the interrupts-enabled flag in the paca, and then checks whether
interrupts got hard-disabled. If so, it also sets the EE bit in the
MSR to hard-enable the interrupts.
This has the potential to improve performance, and also makes it
easier to make a kernel that can boot on iSeries and on other 64-bit
machines, since this lazy-disable strategy is very similar to the
soft-disable strategy that iSeries already uses.
This version renames paca->proc_enabled to paca->soft_enabled, and
changes a couple of soft-disables in the kexec code to hard-disables,
which should fix the crash that Michael Ellerman saw. This doesn't
yet use a reserved CR field for the soft_enabled and hard_enabled
flags. This applies on top of Stephen Rothwell's patches to make it
possible to build a combined iSeries/other kernel.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-10-04 16:47:49 +10:00
|
|
|
{
|
2006-11-10 21:32:40 +00:00
|
|
|
/*
|
|
|
|
* get_paca()->soft_enabled = en;
|
|
|
|
* Is it ever valid to use local_irq_restore(0) when soft_enabled is 1?
|
|
|
|
* That was allowed before, and in such a case we do need to take care
|
|
|
|
* that gcc will set soft_enabled directly via r13, not choose to use
|
|
|
|
* an intermediate register, lest we're preempted to a different cpu.
|
|
|
|
*/
|
|
|
|
set_soft_enabled(en);
|
[POWERPC] Lazy interrupt disabling for 64-bit machines
This implements a lazy strategy for disabling interrupts. This means
that local_irq_disable() et al. just clear the 'interrupts are
enabled' flag in the paca. If an interrupt comes along, the interrupt
entry code notices that interrupts are supposed to be disabled, and
clears the EE bit in SRR1, clears the 'interrupts are hard-enabled'
flag in the paca, and returns. This means that interrupts only
actually get disabled in the processor when an interrupt comes along.
When interrupts are enabled by local_irq_enable() et al., the code
sets the interrupts-enabled flag in the paca, and then checks whether
interrupts got hard-disabled. If so, it also sets the EE bit in the
MSR to hard-enable the interrupts.
This has the potential to improve performance, and also makes it
easier to make a kernel that can boot on iSeries and on other 64-bit
machines, since this lazy-disable strategy is very similar to the
soft-disable strategy that iSeries already uses.
This version renames paca->proc_enabled to paca->soft_enabled, and
changes a couple of soft-disables in the kexec code to hard-disables,
which should fix the crash that Michael Ellerman saw. This doesn't
yet use a reserved CR field for the soft_enabled and hard_enabled
flags. This applies on top of Stephen Rothwell's patches to make it
possible to build a combined iSeries/other kernel.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-10-04 16:47:49 +10:00
|
|
|
if (!en)
|
|
|
|
return;
|
|
|
|
|
2009-06-02 21:17:45 +00:00
|
|
|
#ifdef CONFIG_PPC_STD_MMU_64
|
[POWERPC] Lazy interrupt disabling for 64-bit machines
This implements a lazy strategy for disabling interrupts. This means
that local_irq_disable() et al. just clear the 'interrupts are
enabled' flag in the paca. If an interrupt comes along, the interrupt
entry code notices that interrupts are supposed to be disabled, and
clears the EE bit in SRR1, clears the 'interrupts are hard-enabled'
flag in the paca, and returns. This means that interrupts only
actually get disabled in the processor when an interrupt comes along.
When interrupts are enabled by local_irq_enable() et al., the code
sets the interrupts-enabled flag in the paca, and then checks whether
interrupts got hard-disabled. If so, it also sets the EE bit in the
MSR to hard-enable the interrupts.
This has the potential to improve performance, and also makes it
easier to make a kernel that can boot on iSeries and on other 64-bit
machines, since this lazy-disable strategy is very similar to the
soft-disable strategy that iSeries already uses.
This version renames paca->proc_enabled to paca->soft_enabled, and
changes a couple of soft-disables in the kexec code to hard-disables,
which should fix the crash that Michael Ellerman saw. This doesn't
yet use a reserved CR field for the soft_enabled and hard_enabled
flags. This applies on top of Stephen Rothwell's patches to make it
possible to build a combined iSeries/other kernel.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-10-04 16:47:49 +10:00
|
|
|
if (firmware_has_feature(FW_FEATURE_ISERIES)) {
|
2006-11-10 21:32:40 +00:00
|
|
|
/*
|
|
|
|
* Do we need to disable preemption here? Not really: in the
|
|
|
|
* unlikely event that we're preempted to a different cpu in
|
|
|
|
* between getting r13, loading its lppaca_ptr, and loading
|
|
|
|
* its any_int, we might call iseries_handle_interrupts without
|
|
|
|
* an interrupt pending on the new cpu, but that's no disaster,
|
|
|
|
* is it? And the business of preempting us off the old cpu
|
|
|
|
* would itself involve a local_irq_restore which handles the
|
|
|
|
* interrupt to that cpu.
|
|
|
|
*
|
|
|
|
* But use "local_paca->lppaca_ptr" instead of "get_lppaca()"
|
|
|
|
* to avoid any preemption checking added into get_paca().
|
|
|
|
*/
|
|
|
|
if (local_paca->lppaca_ptr->int_dword.any_int)
|
[POWERPC] Lazy interrupt disabling for 64-bit machines
This implements a lazy strategy for disabling interrupts. This means
that local_irq_disable() et al. just clear the 'interrupts are
enabled' flag in the paca. If an interrupt comes along, the interrupt
entry code notices that interrupts are supposed to be disabled, and
clears the EE bit in SRR1, clears the 'interrupts are hard-enabled'
flag in the paca, and returns. This means that interrupts only
actually get disabled in the processor when an interrupt comes along.
When interrupts are enabled by local_irq_enable() et al., the code
sets the interrupts-enabled flag in the paca, and then checks whether
interrupts got hard-disabled. If so, it also sets the EE bit in the
MSR to hard-enable the interrupts.
This has the potential to improve performance, and also makes it
easier to make a kernel that can boot on iSeries and on other 64-bit
machines, since this lazy-disable strategy is very similar to the
soft-disable strategy that iSeries already uses.
This version renames paca->proc_enabled to paca->soft_enabled, and
changes a couple of soft-disables in the kexec code to hard-disables,
which should fix the crash that Michael Ellerman saw. This doesn't
yet use a reserved CR field for the soft_enabled and hard_enabled
flags. This applies on top of Stephen Rothwell's patches to make it
possible to build a combined iSeries/other kernel.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-10-04 16:47:49 +10:00
|
|
|
iseries_handle_interrupts();
|
|
|
|
}
|
2009-06-02 21:17:45 +00:00
|
|
|
#endif /* CONFIG_PPC_STD_MMU_64 */
|
[POWERPC] Lazy interrupt disabling for 64-bit machines
This implements a lazy strategy for disabling interrupts. This means
that local_irq_disable() et al. just clear the 'interrupts are
enabled' flag in the paca. If an interrupt comes along, the interrupt
entry code notices that interrupts are supposed to be disabled, and
clears the EE bit in SRR1, clears the 'interrupts are hard-enabled'
flag in the paca, and returns. This means that interrupts only
actually get disabled in the processor when an interrupt comes along.
When interrupts are enabled by local_irq_enable() et al., the code
sets the interrupts-enabled flag in the paca, and then checks whether
interrupts got hard-disabled. If so, it also sets the EE bit in the
MSR to hard-enable the interrupts.
This has the potential to improve performance, and also makes it
easier to make a kernel that can boot on iSeries and on other 64-bit
machines, since this lazy-disable strategy is very similar to the
soft-disable strategy that iSeries already uses.
This version renames paca->proc_enabled to paca->soft_enabled, and
changes a couple of soft-disables in the kexec code to hard-disables,
which should fix the crash that Michael Ellerman saw. This doesn't
yet use a reserved CR field for the soft_enabled and hard_enabled
flags. This applies on top of Stephen Rothwell's patches to make it
possible to build a combined iSeries/other kernel.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-10-04 16:47:49 +10:00
|
|
|
|
2006-11-10 21:32:40 +00:00
|
|
|
/*
|
|
|
|
* if (get_paca()->hard_enabled) return;
|
|
|
|
* But again we need to take care that gcc gets hard_enabled directly
|
|
|
|
* via r13, not choose to use an intermediate register, lest we're
|
|
|
|
* preempted to a different cpu in between the two instructions.
|
|
|
|
*/
|
|
|
|
if (get_hard_enabled())
|
[POWERPC] Lazy interrupt disabling for 64-bit machines
This implements a lazy strategy for disabling interrupts. This means
that local_irq_disable() et al. just clear the 'interrupts are
enabled' flag in the paca. If an interrupt comes along, the interrupt
entry code notices that interrupts are supposed to be disabled, and
clears the EE bit in SRR1, clears the 'interrupts are hard-enabled'
flag in the paca, and returns. This means that interrupts only
actually get disabled in the processor when an interrupt comes along.
When interrupts are enabled by local_irq_enable() et al., the code
sets the interrupts-enabled flag in the paca, and then checks whether
interrupts got hard-disabled. If so, it also sets the EE bit in the
MSR to hard-enable the interrupts.
This has the potential to improve performance, and also makes it
easier to make a kernel that can boot on iSeries and on other 64-bit
machines, since this lazy-disable strategy is very similar to the
soft-disable strategy that iSeries already uses.
This version renames paca->proc_enabled to paca->soft_enabled, and
changes a couple of soft-disables in the kexec code to hard-disables,
which should fix the crash that Michael Ellerman saw. This doesn't
yet use a reserved CR field for the soft_enabled and hard_enabled
flags. This applies on top of Stephen Rothwell's patches to make it
possible to build a combined iSeries/other kernel.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-10-04 16:47:49 +10:00
|
|
|
return;
|
2006-11-10 21:32:40 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Need to hard-enable interrupts here. Since currently disabled,
|
|
|
|
* no need to take further asm precautions against preemption; but
|
|
|
|
* use local_paca instead of get_paca() to avoid preemption checking.
|
|
|
|
*/
|
|
|
|
local_paca->hard_enabled = en;
|
2010-07-09 15:30:22 +10:00
|
|
|
|
2011-11-23 20:07:17 +00:00
|
|
|
/*
|
|
|
|
* Trigger the decrementer if we have a pending event. Some processors
|
|
|
|
* only trigger on edge transitions of the sign bit. We might also
|
|
|
|
* have disabled interrupts long enough that the decrementer wrapped
|
|
|
|
* to positive.
|
2010-07-09 15:30:22 +10:00
|
|
|
*/
|
2011-11-23 20:07:17 +00:00
|
|
|
decrementer_check_overflow();
|
2007-05-01 07:01:07 +10:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Force the delivery of pending soft-disabled interrupts on PS3.
|
|
|
|
* Any HV call will have this side effect.
|
|
|
|
*/
|
|
|
|
if (firmware_has_feature(FW_FEATURE_PS3_LV1)) {
|
2011-11-29 15:38:50 +00:00
|
|
|
u64 tmp, tmp2;
|
|
|
|
lv1_get_version_info(&tmp, &tmp2);
|
2007-05-01 07:01:07 +10:00
|
|
|
}
|
|
|
|
|
2007-05-10 22:22:45 -07:00
|
|
|
__hard_irq_enable();
|
[POWERPC] Lazy interrupt disabling for 64-bit machines
This implements a lazy strategy for disabling interrupts. This means
that local_irq_disable() et al. just clear the 'interrupts are
enabled' flag in the paca. If an interrupt comes along, the interrupt
entry code notices that interrupts are supposed to be disabled, and
clears the EE bit in SRR1, clears the 'interrupts are hard-enabled'
flag in the paca, and returns. This means that interrupts only
actually get disabled in the processor when an interrupt comes along.
When interrupts are enabled by local_irq_enable() et al., the code
sets the interrupts-enabled flag in the paca, and then checks whether
interrupts got hard-disabled. If so, it also sets the EE bit in the
MSR to hard-enable the interrupts.
This has the potential to improve performance, and also makes it
easier to make a kernel that can boot on iSeries and on other 64-bit
machines, since this lazy-disable strategy is very similar to the
soft-disable strategy that iSeries already uses.
This version renames paca->proc_enabled to paca->soft_enabled, and
changes a couple of soft-disables in the kexec code to hard-disables,
which should fix the crash that Michael Ellerman saw. This doesn't
yet use a reserved CR field for the soft_enabled and hard_enabled
flags. This applies on top of Stephen Rothwell's patches to make it
possible to build a combined iSeries/other kernel.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-10-04 16:47:49 +10:00
|
|
|
}
|
2010-10-07 14:08:55 +01:00
|
|
|
EXPORT_SYMBOL(arch_local_irq_restore);
|
2005-11-09 18:07:45 +11:00
|
|
|
#endif /* CONFIG_PPC64 */
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2011-03-25 17:04:59 +01:00
|
|
|
int arch_show_interrupts(struct seq_file *p, int prec)
|
2010-01-31 20:33:18 +00:00
|
|
|
{
|
|
|
|
int j;
|
|
|
|
|
|
|
|
#if defined(CONFIG_PPC32) && defined(CONFIG_TAU_INT)
|
|
|
|
if (tau_initialized) {
|
|
|
|
seq_printf(p, "%*s: ", prec, "TAU");
|
|
|
|
for_each_online_cpu(j)
|
|
|
|
seq_printf(p, "%10u ", tau_interrupts(j));
|
|
|
|
seq_puts(p, " PowerPC Thermal Assist (cpu temp)\n");
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_PPC32 && CONFIG_TAU_INT */
|
|
|
|
|
2010-01-31 20:34:06 +00:00
|
|
|
seq_printf(p, "%*s: ", prec, "LOC");
|
|
|
|
for_each_online_cpu(j)
|
|
|
|
seq_printf(p, "%10u ", per_cpu(irq_stat, j).timer_irqs);
|
|
|
|
seq_printf(p, " Local timer interrupts\n");
|
|
|
|
|
2010-01-31 20:34:36 +00:00
|
|
|
seq_printf(p, "%*s: ", prec, "SPU");
|
|
|
|
for_each_online_cpu(j)
|
|
|
|
seq_printf(p, "%10u ", per_cpu(irq_stat, j).spurious_irqs);
|
|
|
|
seq_printf(p, " Spurious interrupts\n");
|
|
|
|
|
2010-01-31 20:34:06 +00:00
|
|
|
seq_printf(p, "%*s: ", prec, "CNT");
|
|
|
|
for_each_online_cpu(j)
|
|
|
|
seq_printf(p, "%10u ", per_cpu(irq_stat, j).pmu_irqs);
|
|
|
|
seq_printf(p, " Performance monitoring interrupts\n");
|
|
|
|
|
|
|
|
seq_printf(p, "%*s: ", prec, "MCE");
|
|
|
|
for_each_online_cpu(j)
|
|
|
|
seq_printf(p, "%10u ", per_cpu(irq_stat, j).mce_exceptions);
|
|
|
|
seq_printf(p, " Machine check exceptions\n");
|
|
|
|
|
2010-01-31 20:33:18 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-01-31 20:34:06 +00:00
|
|
|
/*
|
|
|
|
* /proc/stat helpers
|
|
|
|
*/
|
|
|
|
u64 arch_irq_stat_cpu(unsigned int cpu)
|
|
|
|
{
|
|
|
|
u64 sum = per_cpu(irq_stat, cpu).timer_irqs;
|
|
|
|
|
|
|
|
sum += per_cpu(irq_stat, cpu).pmu_irqs;
|
|
|
|
sum += per_cpu(irq_stat, cpu).mce_exceptions;
|
2010-01-31 20:34:36 +00:00
|
|
|
sum += per_cpu(irq_stat, cpu).spurious_irqs;
|
2010-01-31 20:34:06 +00:00
|
|
|
|
|
|
|
return sum;
|
|
|
|
}
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
2011-02-11 13:05:17 +11:00
|
|
|
void migrate_irqs(void)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2009-10-13 19:44:51 +00:00
|
|
|
struct irq_desc *desc;
|
2005-04-16 15:20:36 -07:00
|
|
|
unsigned int irq;
|
|
|
|
static int warned;
|
2010-04-26 15:32:35 +00:00
|
|
|
cpumask_var_t mask;
|
2011-02-11 13:05:17 +11:00
|
|
|
const struct cpumask *map = cpu_online_mask;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2010-04-26 15:32:35 +00:00
|
|
|
alloc_cpumask_var(&mask, GFP_KERNEL);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2010-04-26 15:32:35 +00:00
|
|
|
for_each_irq(irq) {
|
2011-03-25 16:36:35 +01:00
|
|
|
struct irq_data *data;
|
2011-03-07 14:00:20 +00:00
|
|
|
struct irq_chip *chip;
|
|
|
|
|
2009-10-13 19:44:51 +00:00
|
|
|
desc = irq_to_desc(irq);
|
2010-06-16 00:09:35 +00:00
|
|
|
if (!desc)
|
|
|
|
continue;
|
|
|
|
|
2011-03-25 16:36:35 +01:00
|
|
|
data = irq_desc_get_irq_data(desc);
|
|
|
|
if (irqd_is_per_cpu(data))
|
2005-04-16 15:20:36 -07:00
|
|
|
continue;
|
|
|
|
|
2011-03-25 16:36:35 +01:00
|
|
|
chip = irq_data_get_irq_chip(data);
|
2011-03-07 14:00:20 +00:00
|
|
|
|
2011-03-25 16:36:35 +01:00
|
|
|
cpumask_and(mask, data->affinity, map);
|
2010-04-26 15:32:35 +00:00
|
|
|
if (cpumask_any(mask) >= nr_cpu_ids) {
|
2005-04-16 15:20:36 -07:00
|
|
|
printk("Breaking affinity for irq %i\n", irq);
|
2010-04-26 15:32:35 +00:00
|
|
|
cpumask_copy(mask, map);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
2011-03-07 14:00:20 +00:00
|
|
|
if (chip->irq_set_affinity)
|
2011-03-25 16:36:35 +01:00
|
|
|
chip->irq_set_affinity(data, mask, true);
|
2009-10-13 19:44:51 +00:00
|
|
|
else if (desc->action && !(warned++))
|
2005-04-16 15:20:36 -07:00
|
|
|
printk("Cannot set affinity for irq %i\n", irq);
|
|
|
|
}
|
|
|
|
|
2010-04-26 15:32:35 +00:00
|
|
|
free_cpumask_var(mask);
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
local_irq_enable();
|
|
|
|
mdelay(1);
|
|
|
|
local_irq_disable();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-04-28 01:57:43 +00:00
|
|
|
static inline void handle_one_irq(unsigned int irq)
|
|
|
|
{
|
|
|
|
struct thread_info *curtp, *irqtp;
|
|
|
|
unsigned long saved_sp_limit;
|
|
|
|
struct irq_desc *desc;
|
|
|
|
|
2011-05-24 20:34:18 +00:00
|
|
|
desc = irq_to_desc(irq);
|
|
|
|
if (!desc)
|
|
|
|
return;
|
|
|
|
|
2009-04-28 01:57:43 +00:00
|
|
|
/* Switch to the irq stack to handle this */
|
|
|
|
curtp = current_thread_info();
|
|
|
|
irqtp = hardirq_ctx[smp_processor_id()];
|
|
|
|
|
|
|
|
if (curtp == irqtp) {
|
|
|
|
/* We're already on the irq stack, just handle it */
|
2011-05-24 20:34:18 +00:00
|
|
|
desc->handle_irq(irq, desc);
|
2009-04-28 01:57:43 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
saved_sp_limit = current->thread.ksp_limit;
|
|
|
|
|
|
|
|
irqtp->task = curtp->task;
|
|
|
|
irqtp->flags = 0;
|
|
|
|
|
|
|
|
/* Copy the softirq bits in preempt_count so that the
|
|
|
|
* softirq checks work in the hardirq context. */
|
|
|
|
irqtp->preempt_count = (irqtp->preempt_count & ~SOFTIRQ_MASK) |
|
|
|
|
(curtp->preempt_count & SOFTIRQ_MASK);
|
|
|
|
|
|
|
|
current->thread.ksp_limit = (unsigned long)irqtp +
|
|
|
|
_ALIGN_UP(sizeof(struct thread_info), 16);
|
|
|
|
|
2009-04-22 15:31:43 +00:00
|
|
|
call_handle_irq(irq, desc, irqtp, desc->handle_irq);
|
2009-04-28 01:57:43 +00:00
|
|
|
current->thread.ksp_limit = saved_sp_limit;
|
|
|
|
irqtp->task = NULL;
|
|
|
|
|
|
|
|
/* Set any flag that may have been set on the
|
|
|
|
* alternate stack
|
|
|
|
*/
|
|
|
|
if (irqtp->flags)
|
|
|
|
set_bits(irqtp->flags, &curtp->flags);
|
|
|
|
}
|
|
|
|
|
2009-04-22 15:31:37 +00:00
|
|
|
static inline void check_stack_overflow(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_DEBUG_STACKOVERFLOW
|
|
|
|
long sp;
|
|
|
|
|
|
|
|
sp = __get_SP() & (THREAD_SIZE-1);
|
|
|
|
|
|
|
|
/* check for stack overflow: is there less than 2KB free? */
|
|
|
|
if (unlikely(sp < (sizeof(struct thread_info) + 2048))) {
|
|
|
|
printk("do_IRQ: stack overflow: %ld\n",
|
|
|
|
sp - sizeof(struct thread_info));
|
|
|
|
dump_stack();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
void do_IRQ(struct pt_regs *regs)
|
|
|
|
{
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 14:55:46 +01:00
|
|
|
struct pt_regs *old_regs = set_irq_regs(regs);
|
2006-07-03 21:36:01 +10:00
|
|
|
unsigned int irq;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2009-10-26 18:47:42 +00:00
|
|
|
trace_irq_entry(regs);
|
|
|
|
|
2007-08-21 02:36:19 +10:00
|
|
|
irq_enter();
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2009-04-22 15:31:37 +00:00
|
|
|
check_stack_overflow();
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-10-07 22:08:26 +10:00
|
|
|
irq = ppc_md.get_irq();
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2009-04-28 01:57:43 +00:00
|
|
|
if (irq != NO_IRQ && irq != NO_IRQ_IGNORE)
|
|
|
|
handle_one_irq(irq);
|
|
|
|
else if (irq != NO_IRQ_IGNORE)
|
2010-01-31 20:34:36 +00:00
|
|
|
__get_cpu_var(irq_stat).spurious_irqs++;
|
2005-11-16 18:53:29 +11:00
|
|
|
|
2007-08-21 02:36:19 +10:00
|
|
|
irq_exit();
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 14:55:46 +01:00
|
|
|
set_irq_regs(old_regs);
|
2005-11-09 18:07:45 +11:00
|
|
|
|
2005-11-16 18:53:29 +11:00
|
|
|
#ifdef CONFIG_PPC_ISERIES
|
2006-11-21 14:16:13 +11:00
|
|
|
if (firmware_has_feature(FW_FEATURE_ISERIES) &&
|
|
|
|
get_lppaca()->int_dword.fields.decr_int) {
|
2006-01-13 10:26:42 +11:00
|
|
|
get_lppaca()->int_dword.fields.decr_int = 0;
|
|
|
|
/* Signal a fake decrementer interrupt */
|
|
|
|
timer_interrupt(regs);
|
2005-11-16 18:53:29 +11:00
|
|
|
}
|
|
|
|
#endif
|
2009-10-26 18:47:42 +00:00
|
|
|
|
|
|
|
trace_irq_exit(regs);
|
2005-11-16 18:53:29 +11:00
|
|
|
}
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
void __init init_IRQ(void)
|
|
|
|
{
|
2007-07-10 03:31:44 +10:00
|
|
|
if (ppc_md.init_IRQ)
|
|
|
|
ppc_md.init_IRQ();
|
2008-04-30 03:49:55 -05:00
|
|
|
|
|
|
|
exc_lvl_ctx_init();
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
irq_ctx_init();
|
|
|
|
}
|
|
|
|
|
2008-04-30 03:49:55 -05:00
|
|
|
#if defined(CONFIG_BOOKE) || defined(CONFIG_40x)
|
|
|
|
struct thread_info *critirq_ctx[NR_CPUS] __read_mostly;
|
|
|
|
struct thread_info *dbgirq_ctx[NR_CPUS] __read_mostly;
|
|
|
|
struct thread_info *mcheckirq_ctx[NR_CPUS] __read_mostly;
|
|
|
|
|
|
|
|
void exc_lvl_ctx_init(void)
|
|
|
|
{
|
|
|
|
struct thread_info *tp;
|
2011-04-14 22:32:04 +00:00
|
|
|
int i, cpu_nr;
|
2008-04-30 03:49:55 -05:00
|
|
|
|
|
|
|
for_each_possible_cpu(i) {
|
2011-04-14 22:32:04 +00:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
cpu_nr = i;
|
|
|
|
#else
|
|
|
|
cpu_nr = get_hard_smp_processor_id(i);
|
|
|
|
#endif
|
|
|
|
memset((void *)critirq_ctx[cpu_nr], 0, THREAD_SIZE);
|
|
|
|
tp = critirq_ctx[cpu_nr];
|
|
|
|
tp->cpu = cpu_nr;
|
2008-04-30 03:49:55 -05:00
|
|
|
tp->preempt_count = 0;
|
|
|
|
|
|
|
|
#ifdef CONFIG_BOOKE
|
2011-04-14 22:32:04 +00:00
|
|
|
memset((void *)dbgirq_ctx[cpu_nr], 0, THREAD_SIZE);
|
|
|
|
tp = dbgirq_ctx[cpu_nr];
|
|
|
|
tp->cpu = cpu_nr;
|
2008-04-30 03:49:55 -05:00
|
|
|
tp->preempt_count = 0;
|
|
|
|
|
2011-04-14 22:32:04 +00:00
|
|
|
memset((void *)mcheckirq_ctx[cpu_nr], 0, THREAD_SIZE);
|
|
|
|
tp = mcheckirq_ctx[cpu_nr];
|
|
|
|
tp->cpu = cpu_nr;
|
2008-04-30 03:49:55 -05:00
|
|
|
tp->preempt_count = HARDIRQ_OFFSET;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-06-23 02:05:30 -07:00
|
|
|
struct thread_info *softirq_ctx[NR_CPUS] __read_mostly;
|
|
|
|
struct thread_info *hardirq_ctx[NR_CPUS] __read_mostly;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
void irq_ctx_init(void)
|
|
|
|
{
|
|
|
|
struct thread_info *tp;
|
|
|
|
int i;
|
|
|
|
|
2006-03-28 14:50:51 -08:00
|
|
|
for_each_possible_cpu(i) {
|
2005-04-16 15:20:36 -07:00
|
|
|
memset((void *)softirq_ctx[i], 0, THREAD_SIZE);
|
|
|
|
tp = softirq_ctx[i];
|
|
|
|
tp->cpu = i;
|
2008-04-09 17:21:28 +10:00
|
|
|
tp->preempt_count = 0;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
memset((void *)hardirq_ctx[i], 0, THREAD_SIZE);
|
|
|
|
tp = hardirq_ctx[i];
|
|
|
|
tp->cpu = i;
|
|
|
|
tp->preempt_count = HARDIRQ_OFFSET;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
powerpc: Implement accurate task and CPU time accounting
This implements accurate task and cpu time accounting for 64-bit
powerpc kernels. Instead of accounting a whole jiffy of time to a
task on a timer interrupt because that task happened to be running at
the time, we now account time in units of timebase ticks according to
the actual time spent by the task in user mode and kernel mode. We
also count the time spent processing hardware and software interrupts
accurately. This is conditional on CONFIG_VIRT_CPU_ACCOUNTING. If
that is not set, we do tick-based approximate accounting as before.
To get this accurate information, we read either the PURR (processor
utilization of resources register) on POWER5 machines, or the timebase
on other machines on
* each entry to the kernel from usermode
* each exit to usermode
* transitions between process context, hard irq context and soft irq
context in kernel mode
* context switches.
On POWER5 systems with shared-processor logical partitioning we also
read both the PURR and the timebase at each timer interrupt and
context switch in order to determine how much time has been taken by
the hypervisor to run other partitions ("steal" time). Unfortunately,
since we need values of the PURR on both threads at the same time to
accurately calculate the steal time, and since we can only calculate
steal time on a per-core basis, the apportioning of the steal time
between idle time (time which we ceded to the hypervisor in the idle
loop) and actual stolen time is somewhat approximate at the moment.
This is all based quite heavily on what s390 does, and it uses the
generic interfaces that were added by the s390 developers,
i.e. account_system_time(), account_user_time(), etc.
This patch doesn't add any new interfaces between the kernel and
userspace, and doesn't change the units in which time is reported to
userspace by things such as /proc/stat, /proc/<pid>/stat, getrusage(),
times(), etc. Internally the various task and cpu times are stored in
timebase units, but they are converted to USER_HZ units (1/100th of a
second) when reported to userspace. Some precision is therefore lost
but there should not be any accumulating error, since the internal
accumulation is at full precision.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-02-24 10:06:59 +11:00
|
|
|
static inline void do_softirq_onstack(void)
|
|
|
|
{
|
|
|
|
struct thread_info *curtp, *irqtp;
|
2008-04-28 16:21:22 +10:00
|
|
|
unsigned long saved_sp_limit = current->thread.ksp_limit;
|
powerpc: Implement accurate task and CPU time accounting
This implements accurate task and cpu time accounting for 64-bit
powerpc kernels. Instead of accounting a whole jiffy of time to a
task on a timer interrupt because that task happened to be running at
the time, we now account time in units of timebase ticks according to
the actual time spent by the task in user mode and kernel mode. We
also count the time spent processing hardware and software interrupts
accurately. This is conditional on CONFIG_VIRT_CPU_ACCOUNTING. If
that is not set, we do tick-based approximate accounting as before.
To get this accurate information, we read either the PURR (processor
utilization of resources register) on POWER5 machines, or the timebase
on other machines on
* each entry to the kernel from usermode
* each exit to usermode
* transitions between process context, hard irq context and soft irq
context in kernel mode
* context switches.
On POWER5 systems with shared-processor logical partitioning we also
read both the PURR and the timebase at each timer interrupt and
context switch in order to determine how much time has been taken by
the hypervisor to run other partitions ("steal" time). Unfortunately,
since we need values of the PURR on both threads at the same time to
accurately calculate the steal time, and since we can only calculate
steal time on a per-core basis, the apportioning of the steal time
between idle time (time which we ceded to the hypervisor in the idle
loop) and actual stolen time is somewhat approximate at the moment.
This is all based quite heavily on what s390 does, and it uses the
generic interfaces that were added by the s390 developers,
i.e. account_system_time(), account_user_time(), etc.
This patch doesn't add any new interfaces between the kernel and
userspace, and doesn't change the units in which time is reported to
userspace by things such as /proc/stat, /proc/<pid>/stat, getrusage(),
times(), etc. Internally the various task and cpu times are stored in
timebase units, but they are converted to USER_HZ units (1/100th of a
second) when reported to userspace. Some precision is therefore lost
but there should not be any accumulating error, since the internal
accumulation is at full precision.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-02-24 10:06:59 +11:00
|
|
|
|
|
|
|
curtp = current_thread_info();
|
|
|
|
irqtp = softirq_ctx[smp_processor_id()];
|
|
|
|
irqtp->task = curtp->task;
|
2011-07-18 17:17:22 +00:00
|
|
|
irqtp->flags = 0;
|
2008-04-28 16:21:22 +10:00
|
|
|
current->thread.ksp_limit = (unsigned long)irqtp +
|
|
|
|
_ALIGN_UP(sizeof(struct thread_info), 16);
|
powerpc: Implement accurate task and CPU time accounting
This implements accurate task and cpu time accounting for 64-bit
powerpc kernels. Instead of accounting a whole jiffy of time to a
task on a timer interrupt because that task happened to be running at
the time, we now account time in units of timebase ticks according to
the actual time spent by the task in user mode and kernel mode. We
also count the time spent processing hardware and software interrupts
accurately. This is conditional on CONFIG_VIRT_CPU_ACCOUNTING. If
that is not set, we do tick-based approximate accounting as before.
To get this accurate information, we read either the PURR (processor
utilization of resources register) on POWER5 machines, or the timebase
on other machines on
* each entry to the kernel from usermode
* each exit to usermode
* transitions between process context, hard irq context and soft irq
context in kernel mode
* context switches.
On POWER5 systems with shared-processor logical partitioning we also
read both the PURR and the timebase at each timer interrupt and
context switch in order to determine how much time has been taken by
the hypervisor to run other partitions ("steal" time). Unfortunately,
since we need values of the PURR on both threads at the same time to
accurately calculate the steal time, and since we can only calculate
steal time on a per-core basis, the apportioning of the steal time
between idle time (time which we ceded to the hypervisor in the idle
loop) and actual stolen time is somewhat approximate at the moment.
This is all based quite heavily on what s390 does, and it uses the
generic interfaces that were added by the s390 developers,
i.e. account_system_time(), account_user_time(), etc.
This patch doesn't add any new interfaces between the kernel and
userspace, and doesn't change the units in which time is reported to
userspace by things such as /proc/stat, /proc/<pid>/stat, getrusage(),
times(), etc. Internally the various task and cpu times are stored in
timebase units, but they are converted to USER_HZ units (1/100th of a
second) when reported to userspace. Some precision is therefore lost
but there should not be any accumulating error, since the internal
accumulation is at full precision.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-02-24 10:06:59 +11:00
|
|
|
call_do_softirq(irqtp);
|
2008-04-28 16:21:22 +10:00
|
|
|
current->thread.ksp_limit = saved_sp_limit;
|
powerpc: Implement accurate task and CPU time accounting
This implements accurate task and cpu time accounting for 64-bit
powerpc kernels. Instead of accounting a whole jiffy of time to a
task on a timer interrupt because that task happened to be running at
the time, we now account time in units of timebase ticks according to
the actual time spent by the task in user mode and kernel mode. We
also count the time spent processing hardware and software interrupts
accurately. This is conditional on CONFIG_VIRT_CPU_ACCOUNTING. If
that is not set, we do tick-based approximate accounting as before.
To get this accurate information, we read either the PURR (processor
utilization of resources register) on POWER5 machines, or the timebase
on other machines on
* each entry to the kernel from usermode
* each exit to usermode
* transitions between process context, hard irq context and soft irq
context in kernel mode
* context switches.
On POWER5 systems with shared-processor logical partitioning we also
read both the PURR and the timebase at each timer interrupt and
context switch in order to determine how much time has been taken by
the hypervisor to run other partitions ("steal" time). Unfortunately,
since we need values of the PURR on both threads at the same time to
accurately calculate the steal time, and since we can only calculate
steal time on a per-core basis, the apportioning of the steal time
between idle time (time which we ceded to the hypervisor in the idle
loop) and actual stolen time is somewhat approximate at the moment.
This is all based quite heavily on what s390 does, and it uses the
generic interfaces that were added by the s390 developers,
i.e. account_system_time(), account_user_time(), etc.
This patch doesn't add any new interfaces between the kernel and
userspace, and doesn't change the units in which time is reported to
userspace by things such as /proc/stat, /proc/<pid>/stat, getrusage(),
times(), etc. Internally the various task and cpu times are stored in
timebase units, but they are converted to USER_HZ units (1/100th of a
second) when reported to userspace. Some precision is therefore lost
but there should not be any accumulating error, since the internal
accumulation is at full precision.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-02-24 10:06:59 +11:00
|
|
|
irqtp->task = NULL;
|
2011-07-18 17:17:22 +00:00
|
|
|
|
|
|
|
/* Set any flag that may have been set on the
|
|
|
|
* alternate stack
|
|
|
|
*/
|
|
|
|
if (irqtp->flags)
|
|
|
|
set_bits(irqtp->flags, &curtp->flags);
|
powerpc: Implement accurate task and CPU time accounting
This implements accurate task and cpu time accounting for 64-bit
powerpc kernels. Instead of accounting a whole jiffy of time to a
task on a timer interrupt because that task happened to be running at
the time, we now account time in units of timebase ticks according to
the actual time spent by the task in user mode and kernel mode. We
also count the time spent processing hardware and software interrupts
accurately. This is conditional on CONFIG_VIRT_CPU_ACCOUNTING. If
that is not set, we do tick-based approximate accounting as before.
To get this accurate information, we read either the PURR (processor
utilization of resources register) on POWER5 machines, or the timebase
on other machines on
* each entry to the kernel from usermode
* each exit to usermode
* transitions between process context, hard irq context and soft irq
context in kernel mode
* context switches.
On POWER5 systems with shared-processor logical partitioning we also
read both the PURR and the timebase at each timer interrupt and
context switch in order to determine how much time has been taken by
the hypervisor to run other partitions ("steal" time). Unfortunately,
since we need values of the PURR on both threads at the same time to
accurately calculate the steal time, and since we can only calculate
steal time on a per-core basis, the apportioning of the steal time
between idle time (time which we ceded to the hypervisor in the idle
loop) and actual stolen time is somewhat approximate at the moment.
This is all based quite heavily on what s390 does, and it uses the
generic interfaces that were added by the s390 developers,
i.e. account_system_time(), account_user_time(), etc.
This patch doesn't add any new interfaces between the kernel and
userspace, and doesn't change the units in which time is reported to
userspace by things such as /proc/stat, /proc/<pid>/stat, getrusage(),
times(), etc. Internally the various task and cpu times are stored in
timebase units, but they are converted to USER_HZ units (1/100th of a
second) when reported to userspace. Some precision is therefore lost
but there should not be any accumulating error, since the internal
accumulation is at full precision.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-02-24 10:06:59 +11:00
|
|
|
}
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
void do_softirq(void)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (in_interrupt())
|
|
|
|
return;
|
|
|
|
|
|
|
|
local_irq_save(flags);
|
|
|
|
|
2006-07-03 15:28:34 -07:00
|
|
|
if (local_softirq_pending())
|
powerpc: Implement accurate task and CPU time accounting
This implements accurate task and cpu time accounting for 64-bit
powerpc kernels. Instead of accounting a whole jiffy of time to a
task on a timer interrupt because that task happened to be running at
the time, we now account time in units of timebase ticks according to
the actual time spent by the task in user mode and kernel mode. We
also count the time spent processing hardware and software interrupts
accurately. This is conditional on CONFIG_VIRT_CPU_ACCOUNTING. If
that is not set, we do tick-based approximate accounting as before.
To get this accurate information, we read either the PURR (processor
utilization of resources register) on POWER5 machines, or the timebase
on other machines on
* each entry to the kernel from usermode
* each exit to usermode
* transitions between process context, hard irq context and soft irq
context in kernel mode
* context switches.
On POWER5 systems with shared-processor logical partitioning we also
read both the PURR and the timebase at each timer interrupt and
context switch in order to determine how much time has been taken by
the hypervisor to run other partitions ("steal" time). Unfortunately,
since we need values of the PURR on both threads at the same time to
accurately calculate the steal time, and since we can only calculate
steal time on a per-core basis, the apportioning of the steal time
between idle time (time which we ceded to the hypervisor in the idle
loop) and actual stolen time is somewhat approximate at the moment.
This is all based quite heavily on what s390 does, and it uses the
generic interfaces that were added by the s390 developers,
i.e. account_system_time(), account_user_time(), etc.
This patch doesn't add any new interfaces between the kernel and
userspace, and doesn't change the units in which time is reported to
userspace by things such as /proc/stat, /proc/<pid>/stat, getrusage(),
times(), etc. Internally the various task and cpu times are stored in
timebase units, but they are converted to USER_HZ units (1/100th of a
second) when reported to userspace. Some precision is therefore lost
but there should not be any accumulating error, since the internal
accumulation is at full precision.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-02-24 10:06:59 +11:00
|
|
|
do_softirq_onstack();
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
local_irq_restore(flags);
|
|
|
|
}
|
|
|
|
|
2011-05-04 15:02:15 +10:00
|
|
|
irq_hw_number_t irqd_to_hwirq(struct irq_data *d)
|
|
|
|
{
|
2012-02-14 14:06:51 -07:00
|
|
|
return d->hwirq;
|
2011-05-04 15:02:15 +10:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(irqd_to_hwirq);
|
|
|
|
|
2007-06-04 14:47:04 +10:00
|
|
|
irq_hw_number_t virq_to_hw(unsigned int virq)
|
|
|
|
{
|
2012-02-14 14:06:51 -07:00
|
|
|
struct irq_data *irq_data = irq_get_irq_data(virq);
|
|
|
|
return WARN_ON(!irq_data) ? 0 : irq_data->hwirq;
|
2007-06-04 14:47:04 +10:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(virq_to_hw);
|
|
|
|
|
2011-05-19 08:54:26 -05:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
int irq_choose_cpu(const struct cpumask *mask)
|
|
|
|
{
|
|
|
|
int cpuid;
|
|
|
|
|
|
|
|
if (cpumask_equal(mask, cpu_all_mask)) {
|
|
|
|
static int irq_rover;
|
|
|
|
static DEFINE_RAW_SPINLOCK(irq_rover_lock);
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
/* Round-robin distribution... */
|
|
|
|
do_round_robin:
|
|
|
|
raw_spin_lock_irqsave(&irq_rover_lock, flags);
|
|
|
|
|
|
|
|
irq_rover = cpumask_next(irq_rover, cpu_online_mask);
|
|
|
|
if (irq_rover >= nr_cpu_ids)
|
|
|
|
irq_rover = cpumask_first(cpu_online_mask);
|
|
|
|
|
|
|
|
cpuid = irq_rover;
|
|
|
|
|
|
|
|
raw_spin_unlock_irqrestore(&irq_rover_lock, flags);
|
|
|
|
} else {
|
|
|
|
cpuid = cpumask_first_and(mask, cpu_online_mask);
|
|
|
|
if (cpuid >= nr_cpu_ids)
|
|
|
|
goto do_round_robin;
|
|
|
|
}
|
|
|
|
|
|
|
|
return get_hard_smp_processor_id(cpuid);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
int irq_choose_cpu(const struct cpumask *mask)
|
|
|
|
{
|
|
|
|
return hard_smp_processor_id();
|
|
|
|
}
|
|
|
|
#endif
|
2006-07-03 21:36:01 +10:00
|
|
|
|
2009-10-13 19:45:03 +00:00
|
|
|
int arch_early_irq_init(void)
|
2006-07-03 21:36:01 +10:00
|
|
|
{
|
2009-10-13 19:45:03 +00:00
|
|
|
return 0;
|
2006-07-03 21:36:01 +10:00
|
|
|
}
|
|
|
|
|
powerpc: Implement accurate task and CPU time accounting
This implements accurate task and cpu time accounting for 64-bit
powerpc kernels. Instead of accounting a whole jiffy of time to a
task on a timer interrupt because that task happened to be running at
the time, we now account time in units of timebase ticks according to
the actual time spent by the task in user mode and kernel mode. We
also count the time spent processing hardware and software interrupts
accurately. This is conditional on CONFIG_VIRT_CPU_ACCOUNTING. If
that is not set, we do tick-based approximate accounting as before.
To get this accurate information, we read either the PURR (processor
utilization of resources register) on POWER5 machines, or the timebase
on other machines on
* each entry to the kernel from usermode
* each exit to usermode
* transitions between process context, hard irq context and soft irq
context in kernel mode
* context switches.
On POWER5 systems with shared-processor logical partitioning we also
read both the PURR and the timebase at each timer interrupt and
context switch in order to determine how much time has been taken by
the hypervisor to run other partitions ("steal" time). Unfortunately,
since we need values of the PURR on both threads at the same time to
accurately calculate the steal time, and since we can only calculate
steal time on a per-core basis, the apportioning of the steal time
between idle time (time which we ceded to the hypervisor in the idle
loop) and actual stolen time is somewhat approximate at the moment.
This is all based quite heavily on what s390 does, and it uses the
generic interfaces that were added by the s390 developers,
i.e. account_system_time(), account_user_time(), etc.
This patch doesn't add any new interfaces between the kernel and
userspace, and doesn't change the units in which time is reported to
userspace by things such as /proc/stat, /proc/<pid>/stat, getrusage(),
times(), etc. Internally the various task and cpu times are stored in
timebase units, but they are converted to USER_HZ units (1/100th of a
second) when reported to userspace. Some precision is therefore lost
but there should not be any accumulating error, since the internal
accumulation is at full precision.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-02-24 10:06:59 +11:00
|
|
|
#ifdef CONFIG_PPC64
|
2005-04-16 15:20:36 -07:00
|
|
|
static int __init setup_noirqdistrib(char *str)
|
|
|
|
{
|
|
|
|
distribute_irqs = 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
__setup("noirqdistrib", setup_noirqdistrib);
|
2005-11-09 18:07:45 +11:00
|
|
|
#endif /* CONFIG_PPC64 */
|