5a0e3ad6af
percpu.h is included by sched.h and module.h and thus ends up being included when building most .c files. percpu.h includes slab.h which in turn includes gfp.h making everything defined by the two files universally available and complicating inclusion dependencies. percpu.h -> slab.h dependency is about to be removed. Prepare for this change by updating users of gfp and slab facilities include those headers directly instead of assuming availability. As this conversion needs to touch large number of source files, the following script is used as the basis of conversion. http://userweb.kernel.org/~tj/misc/slabh-sweep.py The script does the followings. * Scan files for gfp and slab usages and update includes such that only the necessary includes are there. ie. if only gfp is used, gfp.h, if slab is used, slab.h. * When the script inserts a new include, it looks at the include blocks and try to put the new include such that its order conforms to its surrounding. It's put in the include block which contains core kernel includes, in the same order that the rest are ordered - alphabetical, Christmas tree, rev-Xmas-tree or at the end if there doesn't seem to be any matching order. * If the script can't find a place to put a new include (mostly because the file doesn't have fitting include block), it prints out an error message indicating which .h file needs to be added to the file. The conversion was done in the following steps. 1. The initial automatic conversion of all .c files updated slightly over 4000 files, deleting around 700 includes and adding ~480 gfp.h and ~3000 slab.h inclusions. The script emitted errors for ~400 files. 2. Each error was manually checked. Some didn't need the inclusion, some needed manual addition while adding it to implementation .h or embedding .c file was more appropriate for others. This step added inclusions to around 150 files. 3. The script was run again and the output was compared to the edits from #2 to make sure no file was left behind. 4. Several build tests were done and a couple of problems were fixed. e.g. lib/decompress_*.c used malloc/free() wrappers around slab APIs requiring slab.h to be added manually. 5. The script was run on all .h files but without automatically editing them as sprinkling gfp.h and slab.h inclusions around .h files could easily lead to inclusion dependency hell. Most gfp.h inclusion directives were ignored as stuff from gfp.h was usually wildly available and often used in preprocessor macros. Each slab.h inclusion directive was examined and added manually as necessary. 6. percpu.h was updated not to include slab.h. 7. Build test were done on the following configurations and failures were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my distributed build env didn't work with gcov compiles) and a few more options had to be turned off depending on archs to make things build (like ipr on powerpc/64 which failed due to missing writeq). * x86 and x86_64 UP and SMP allmodconfig and a custom test config. * powerpc and powerpc64 SMP allmodconfig * sparc and sparc64 SMP allmodconfig * ia64 SMP allmodconfig * s390 SMP allmodconfig * alpha SMP allmodconfig * um on x86_64 SMP allmodconfig 8. percpu.h modifications were reverted so that it could be applied as a separate patch and serve as bisection point. Given the fact that I had only a couple of failures from tests on step 6, I'm fairly confident about the coverage of this conversion patch. If there is a breakage, it's likely to be something in one of the arch headers which should be easily discoverable easily on most builds of the specific arch. Signed-off-by: Tejun Heo <tj@kernel.org> Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
286 lines
7.2 KiB
C
286 lines
7.2 KiB
C
/*
|
|
* Copyright (C) 2009 Daniel Hellstrom (daniel@gaisler.com) Aeroflex Gaisler AB
|
|
* Copyright (C) 2009 Konrad Eisele (konrad@gaisler.com) Aeroflex Gaisler AB
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/module.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/mutex.h>
|
|
#include <linux/of.h>
|
|
#include <linux/of_platform.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/of_device.h>
|
|
|
|
#include <asm/oplib.h>
|
|
#include <asm/timer.h>
|
|
#include <asm/prom.h>
|
|
#include <asm/leon.h>
|
|
#include <asm/leon_amba.h>
|
|
#include <asm/traps.h>
|
|
#include <asm/cacheflush.h>
|
|
|
|
#include "prom.h"
|
|
#include "irq.h"
|
|
|
|
struct leon3_irqctrl_regs_map *leon3_irqctrl_regs; /* interrupt controller base address, initialized by amba_init() */
|
|
struct leon3_gptimer_regs_map *leon3_gptimer_regs; /* timer controller base address, initialized by amba_init() */
|
|
struct amba_apb_device leon_percpu_timer_dev[16];
|
|
|
|
int leondebug_irq_disable;
|
|
int leon_debug_irqout;
|
|
static int dummy_master_l10_counter;
|
|
|
|
unsigned long leon3_gptimer_irq; /* interrupt controller irq number, initialized by amba_init() */
|
|
unsigned int sparc_leon_eirq;
|
|
#define LEON_IMASK ((&leon3_irqctrl_regs->mask[0]))
|
|
|
|
/* Return the IRQ of the pending IRQ on the extended IRQ controller */
|
|
int sparc_leon_eirq_get(int eirq, int cpu)
|
|
{
|
|
return LEON3_BYPASS_LOAD_PA(&leon3_irqctrl_regs->intid[cpu]) & 0x1f;
|
|
}
|
|
|
|
irqreturn_t sparc_leon_eirq_isr(int dummy, void *dev_id)
|
|
{
|
|
printk(KERN_ERR "sparc_leon_eirq_isr: ERROR EXTENDED IRQ\n");
|
|
return IRQ_HANDLED;
|
|
}
|
|
|
|
/* The extended IRQ controller has been found, this function registers it */
|
|
void sparc_leon_eirq_register(int eirq)
|
|
{
|
|
int irq;
|
|
|
|
/* Register a "BAD" handler for this interrupt, it should never happen */
|
|
irq = request_irq(eirq, sparc_leon_eirq_isr,
|
|
(IRQF_DISABLED | SA_STATIC_ALLOC), "extirq", NULL);
|
|
|
|
if (irq) {
|
|
printk(KERN_ERR
|
|
"sparc_leon_eirq_register: unable to attach IRQ%d\n",
|
|
eirq);
|
|
} else {
|
|
sparc_leon_eirq = eirq;
|
|
}
|
|
|
|
}
|
|
|
|
static inline unsigned long get_irqmask(unsigned int irq)
|
|
{
|
|
unsigned long mask;
|
|
|
|
if (!irq || ((irq > 0xf) && !sparc_leon_eirq)
|
|
|| ((irq > 0x1f) && sparc_leon_eirq)) {
|
|
printk(KERN_ERR
|
|
"leon_get_irqmask: false irq number: %d\n", irq);
|
|
mask = 0;
|
|
} else {
|
|
mask = LEON_HARD_INT(irq);
|
|
}
|
|
return mask;
|
|
}
|
|
|
|
static void leon_enable_irq(unsigned int irq_nr)
|
|
{
|
|
unsigned long mask, flags;
|
|
mask = get_irqmask(irq_nr);
|
|
local_irq_save(flags);
|
|
LEON3_BYPASS_STORE_PA(LEON_IMASK,
|
|
(LEON3_BYPASS_LOAD_PA(LEON_IMASK) | (mask)));
|
|
local_irq_restore(flags);
|
|
}
|
|
|
|
static void leon_disable_irq(unsigned int irq_nr)
|
|
{
|
|
unsigned long mask, flags;
|
|
mask = get_irqmask(irq_nr);
|
|
local_irq_save(flags);
|
|
LEON3_BYPASS_STORE_PA(LEON_IMASK,
|
|
(LEON3_BYPASS_LOAD_PA(LEON_IMASK) & ~(mask)));
|
|
local_irq_restore(flags);
|
|
|
|
}
|
|
|
|
void __init leon_init_timers(irq_handler_t counter_fn)
|
|
{
|
|
int irq;
|
|
|
|
leondebug_irq_disable = 0;
|
|
leon_debug_irqout = 0;
|
|
master_l10_counter = (unsigned int *)&dummy_master_l10_counter;
|
|
dummy_master_l10_counter = 0;
|
|
|
|
if (leon3_gptimer_regs && leon3_irqctrl_regs) {
|
|
LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].val, 0);
|
|
LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].rld,
|
|
(((1000000 / 100) - 1)));
|
|
LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].ctrl, 0);
|
|
|
|
#ifdef CONFIG_SMP
|
|
leon_percpu_timer_dev[0].start = (int)leon3_gptimer_regs;
|
|
leon_percpu_timer_dev[0].irq = leon3_gptimer_irq+1;
|
|
|
|
if (!(LEON3_BYPASS_LOAD_PA(&leon3_gptimer_regs->config) &
|
|
(1<<LEON3_GPTIMER_SEPIRQ))) {
|
|
prom_printf("irq timer not configured with separate irqs\n");
|
|
BUG();
|
|
}
|
|
|
|
LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].val, 0);
|
|
LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].rld, (((1000000/100) - 1)));
|
|
LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].ctrl, 0);
|
|
# endif
|
|
|
|
} else {
|
|
printk(KERN_ERR "No Timer/irqctrl found\n");
|
|
BUG();
|
|
}
|
|
|
|
irq = request_irq(leon3_gptimer_irq,
|
|
counter_fn,
|
|
(IRQF_DISABLED | SA_STATIC_ALLOC), "timer", NULL);
|
|
|
|
if (irq) {
|
|
printk(KERN_ERR "leon_time_init: unable to attach IRQ%d\n",
|
|
LEON_INTERRUPT_TIMER1);
|
|
prom_halt();
|
|
}
|
|
|
|
# ifdef CONFIG_SMP
|
|
{
|
|
unsigned long flags;
|
|
struct tt_entry *trap_table = &sparc_ttable[SP_TRAP_IRQ1 + (leon_percpu_timer_dev[0].irq - 1)];
|
|
|
|
/* For SMP we use the level 14 ticker, however the bootup code
|
|
* has copied the firmwares level 14 vector into boot cpu's
|
|
* trap table, we must fix this now or we get squashed.
|
|
*/
|
|
local_irq_save(flags);
|
|
|
|
patchme_maybe_smp_msg[0] = 0x01000000; /* NOP out the branch */
|
|
|
|
/* Adjust so that we jump directly to smpleon_ticker */
|
|
trap_table->inst_three += smpleon_ticker - real_irq_entry;
|
|
|
|
local_flush_cache_all();
|
|
local_irq_restore(flags);
|
|
}
|
|
# endif
|
|
|
|
if (leon3_gptimer_regs) {
|
|
LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].ctrl,
|
|
LEON3_GPTIMER_EN |
|
|
LEON3_GPTIMER_RL |
|
|
LEON3_GPTIMER_LD | LEON3_GPTIMER_IRQEN);
|
|
|
|
#ifdef CONFIG_SMP
|
|
LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].ctrl,
|
|
LEON3_GPTIMER_EN |
|
|
LEON3_GPTIMER_RL |
|
|
LEON3_GPTIMER_LD |
|
|
LEON3_GPTIMER_IRQEN);
|
|
#endif
|
|
|
|
}
|
|
}
|
|
|
|
void leon_clear_clock_irq(void)
|
|
{
|
|
}
|
|
|
|
void leon_load_profile_irq(int cpu, unsigned int limit)
|
|
{
|
|
BUG();
|
|
}
|
|
|
|
|
|
|
|
|
|
void __init leon_trans_init(struct device_node *dp)
|
|
{
|
|
if (strcmp(dp->type, "cpu") == 0 && strcmp(dp->name, "<NULL>") == 0) {
|
|
struct property *p;
|
|
p = of_find_property(dp, "mid", (void *)0);
|
|
if (p) {
|
|
int mid;
|
|
dp->name = prom_early_alloc(5 + 1);
|
|
memcpy(&mid, p->value, p->length);
|
|
sprintf((char *)dp->name, "cpu%.2d", mid);
|
|
}
|
|
}
|
|
}
|
|
|
|
void __initdata (*prom_amba_init)(struct device_node *dp, struct device_node ***nextp) = 0;
|
|
|
|
void __init leon_node_init(struct device_node *dp, struct device_node ***nextp)
|
|
{
|
|
if (prom_amba_init &&
|
|
strcmp(dp->type, "ambapp") == 0 &&
|
|
strcmp(dp->name, "ambapp0") == 0) {
|
|
prom_amba_init(dp, nextp);
|
|
}
|
|
}
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
void leon_set_cpu_int(int cpu, int level)
|
|
{
|
|
unsigned long mask;
|
|
mask = get_irqmask(level);
|
|
LEON3_BYPASS_STORE_PA(&leon3_irqctrl_regs->force[cpu], mask);
|
|
}
|
|
|
|
static void leon_clear_ipi(int cpu, int level)
|
|
{
|
|
unsigned long mask;
|
|
mask = get_irqmask(level);
|
|
LEON3_BYPASS_STORE_PA(&leon3_irqctrl_regs->force[cpu], mask<<16);
|
|
}
|
|
|
|
static void leon_set_udt(int cpu)
|
|
{
|
|
}
|
|
|
|
void leon_clear_profile_irq(int cpu)
|
|
{
|
|
}
|
|
|
|
void leon_enable_irq_cpu(unsigned int irq_nr, unsigned int cpu)
|
|
{
|
|
unsigned long mask, flags, *addr;
|
|
mask = get_irqmask(irq_nr);
|
|
local_irq_save(flags);
|
|
addr = (unsigned long *)&(leon3_irqctrl_regs->mask[cpu]);
|
|
LEON3_BYPASS_STORE_PA(addr, (LEON3_BYPASS_LOAD_PA(addr) | (mask)));
|
|
local_irq_restore(flags);
|
|
}
|
|
|
|
#endif
|
|
|
|
void __init leon_init_IRQ(void)
|
|
{
|
|
sparc_init_timers = leon_init_timers;
|
|
|
|
BTFIXUPSET_CALL(enable_irq, leon_enable_irq, BTFIXUPCALL_NORM);
|
|
BTFIXUPSET_CALL(disable_irq, leon_disable_irq, BTFIXUPCALL_NORM);
|
|
BTFIXUPSET_CALL(enable_pil_irq, leon_enable_irq, BTFIXUPCALL_NORM);
|
|
BTFIXUPSET_CALL(disable_pil_irq, leon_disable_irq, BTFIXUPCALL_NORM);
|
|
|
|
BTFIXUPSET_CALL(clear_clock_irq, leon_clear_clock_irq,
|
|
BTFIXUPCALL_NORM);
|
|
BTFIXUPSET_CALL(load_profile_irq, leon_load_profile_irq,
|
|
BTFIXUPCALL_NOP);
|
|
|
|
#ifdef CONFIG_SMP
|
|
BTFIXUPSET_CALL(set_cpu_int, leon_set_cpu_int, BTFIXUPCALL_NORM);
|
|
BTFIXUPSET_CALL(clear_cpu_int, leon_clear_ipi, BTFIXUPCALL_NORM);
|
|
BTFIXUPSET_CALL(set_irq_udt, leon_set_udt, BTFIXUPCALL_NORM);
|
|
#endif
|
|
|
|
}
|
|
|
|
void __init leon_init(void)
|
|
{
|
|
prom_build_more = &leon_node_init;
|
|
}
|