2005-04-16 16:20:36 -06:00
|
|
|
#ifdef __KERNEL__
|
2005-10-10 06:54:57 -06:00
|
|
|
#ifndef _ASM_POWERPC_IRQ_H
|
|
|
|
#define _ASM_POWERPC_IRQ_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2012-02-14 14:06:50 -07:00
|
|
|
#include <linux/irqdomain.h>
|
2005-10-10 06:54:57 -06:00
|
|
|
#include <linux/threads.h>
|
2006-07-03 05:36:01 -06:00
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/radix-tree.h>
|
2005-10-10 06:54:57 -06:00
|
|
|
|
|
|
|
#include <asm/types.h>
|
2011-07-26 17:09:06 -06:00
|
|
|
#include <linux/atomic.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
|
2006-07-03 05:36:01 -06:00
|
|
|
extern atomic_t ppc_n_lost_interrupts;
|
2005-10-10 06:54:57 -06:00
|
|
|
|
2006-07-03 05:36:01 -06:00
|
|
|
/* This number is used when no interrupt has been assigned */
|
|
|
|
#define NO_IRQ (0)
|
|
|
|
|
2009-10-13 13:44:44 -06:00
|
|
|
/* Total number of virq in the platform */
|
|
|
|
#define NR_IRQS CONFIG_NR_IRQS
|
2005-10-10 06:54:57 -06:00
|
|
|
|
2009-10-13 13:45:03 -06:00
|
|
|
/* Same thing, used by the generic IRQ code */
|
|
|
|
#define NR_IRQS_LEGACY NUM_ISA_INTERRUPTS
|
|
|
|
|
2007-06-03 22:47:04 -06:00
|
|
|
extern irq_hw_number_t virq_to_hw(unsigned int virq);
|
2011-04-03 21:46:58 -06:00
|
|
|
|
2006-08-01 19:13:50 -06:00
|
|
|
/**
|
2006-07-03 05:36:01 -06:00
|
|
|
* irq_early_init - Init irq remapping subsystem
|
|
|
|
*/
|
|
|
|
extern void irq_early_init(void);
|
|
|
|
|
|
|
|
static __inline__ int irq_canonicalize(int irq)
|
2005-10-10 06:54:57 -06:00
|
|
|
{
|
2006-07-03 05:36:01 -06:00
|
|
|
return irq;
|
2005-10-10 06:54:57 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
extern int distribute_irqs;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-10-10 06:54:57 -06:00
|
|
|
struct irqaction;
|
|
|
|
struct pt_regs;
|
|
|
|
|
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-23 16:06:59 -07:00
|
|
|
#define __ARCH_HAS_DO_SOFTIRQ
|
|
|
|
|
2008-04-30 02:49:55 -06:00
|
|
|
#if defined(CONFIG_BOOKE) || defined(CONFIG_40x)
|
|
|
|
/*
|
|
|
|
* Per-cpu stacks for handling critical, debug and machine check
|
|
|
|
* level interrupts.
|
|
|
|
*/
|
|
|
|
extern struct thread_info *critirq_ctx[NR_CPUS];
|
|
|
|
extern struct thread_info *dbgirq_ctx[NR_CPUS];
|
|
|
|
extern struct thread_info *mcheckirq_ctx[NR_CPUS];
|
|
|
|
extern void exc_lvl_ctx_init(void);
|
|
|
|
#else
|
|
|
|
#define exc_lvl_ctx_init()
|
|
|
|
#endif
|
|
|
|
|
2005-10-10 06:54:57 -06:00
|
|
|
/*
|
|
|
|
* Per-cpu stacks for handling hard and soft interrupts.
|
|
|
|
*/
|
|
|
|
extern struct thread_info *hardirq_ctx[NR_CPUS];
|
|
|
|
extern struct thread_info *softirq_ctx[NR_CPUS];
|
|
|
|
|
|
|
|
extern void irq_ctx_init(void);
|
|
|
|
extern void call_do_softirq(struct thread_info *tp);
|
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 07:55:46 -06:00
|
|
|
extern int call_handle_irq(int irq, void *p1,
|
2006-07-03 03:32:51 -06:00
|
|
|
struct thread_info *tp, void *func);
|
2005-10-19 17:23:26 -06:00
|
|
|
extern void do_IRQ(struct pt_regs *regs);
|
|
|
|
|
2011-05-19 07:54:26 -06:00
|
|
|
int irq_choose_cpu(const struct cpumask *mask);
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
#endif /* _ASM_IRQ_H */
|
|
|
|
#endif /* __KERNEL__ */
|