2005-04-17 00:20:36 +02:00
|
|
|
/* -*- mode: c; c-basic-offset: 8 -*- */
|
|
|
|
|
|
|
|
/* Copyright (C) 1999,2001
|
|
|
|
*
|
|
|
|
* Author: J.E.J.Bottomley@HansenPartnership.com
|
|
|
|
*
|
|
|
|
* This file provides all the same external entries as smp.c but uses
|
|
|
|
* the voyager hal to provide the functionality
|
|
|
|
*/
|
2008-11-09 18:53:14 +01:00
|
|
|
#include <linux/cpu.h>
|
2005-07-13 15:38:05 +02:00
|
|
|
#include <linux/module.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/kernel_stat.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/mc146818rtc.h>
|
|
|
|
#include <linux/cache.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/bootmem.h>
|
|
|
|
#include <linux/completion.h>
|
|
|
|
#include <asm/desc.h>
|
|
|
|
#include <asm/voyager.h>
|
|
|
|
#include <asm/vic.h>
|
|
|
|
#include <asm/mtrr.h>
|
|
|
|
#include <asm/pgalloc.h>
|
|
|
|
#include <asm/tlbflush.h>
|
|
|
|
#include <asm/arch_hooks.h>
|
2008-04-10 23:28:10 +02:00
|
|
|
#include <asm/trampoline.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* TLB state -- visible externally, indexed physically */
|
2007-10-26 19:17:19 +02:00
|
|
|
DEFINE_PER_CPU_SHARED_ALIGNED(struct tlb_state, cpu_tlbstate) = { &init_mm, 0 };
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* CPU IRQ affinity -- set to all ones initially */
|
2008-01-30 13:30:10 +01:00
|
|
|
static unsigned long cpu_irq_affinity[NR_CPUS] __cacheline_aligned =
|
|
|
|
{[0 ... NR_CPUS-1] = ~0UL };
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* per CPU data structure (for /proc/cpuinfo et al), visible externally
|
|
|
|
* indexed physically */
|
2007-10-26 19:17:19 +02:00
|
|
|
DEFINE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info);
|
2007-10-19 20:35:04 +02:00
|
|
|
EXPORT_PER_CPU_SYMBOL(cpu_info);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* physical ID of the CPU used to boot the system */
|
|
|
|
unsigned char boot_cpu_id;
|
|
|
|
|
|
|
|
/* The memory line addresses for the Quad CPIs */
|
|
|
|
struct voyager_qic_cpi *voyager_quad_cpi_addr[NR_CPUS] __cacheline_aligned;
|
|
|
|
|
|
|
|
/* The masks for the Extended VIC processors, filled in by cat_init */
|
|
|
|
__u32 voyager_extended_vic_processors = 0;
|
|
|
|
|
|
|
|
/* Masks for the extended Quad processors which cannot be VIC booted */
|
|
|
|
__u32 voyager_allowed_boot_processors = 0;
|
|
|
|
|
|
|
|
/* The mask for the Quad Processors (both extended and non-extended) */
|
|
|
|
__u32 voyager_quad_processors = 0;
|
|
|
|
|
|
|
|
/* Total count of live CPUs, used in process.c to display
|
|
|
|
* the CPU information and in irq.c for the per CPU irq
|
|
|
|
* activity count. Finally exported by i386_ksyms.c */
|
|
|
|
static int voyager_extended_cpus = 1;
|
|
|
|
|
|
|
|
/* Used for the invalidate map that's also checked in the spinlock */
|
|
|
|
static volatile unsigned long smp_invalidate_needed;
|
|
|
|
|
|
|
|
/* Bitmask of CPUs present in the system - exported by i386_syms.c, used
|
|
|
|
* by scheduler but indexed physically */
|
|
|
|
cpumask_t phys_cpu_present_map = CPU_MASK_NONE;
|
|
|
|
|
|
|
|
/* The internal functions */
|
|
|
|
static void send_CPI(__u32 cpuset, __u8 cpi);
|
|
|
|
static void ack_CPI(__u8 cpi);
|
|
|
|
static int ack_QIC_CPI(__u8 cpi);
|
|
|
|
static void ack_special_QIC_CPI(__u8 cpi);
|
|
|
|
static void ack_VIC_CPI(__u8 cpi);
|
|
|
|
static void send_CPI_allbutself(__u8 cpi);
|
2006-10-13 05:21:16 +02:00
|
|
|
static void mask_vic_irq(unsigned int irq);
|
|
|
|
static void unmask_vic_irq(unsigned int irq);
|
2005-04-17 00:20:36 +02:00
|
|
|
static unsigned int startup_vic_irq(unsigned int irq);
|
|
|
|
static void enable_local_vic_irq(unsigned int irq);
|
|
|
|
static void disable_local_vic_irq(unsigned int irq);
|
|
|
|
static void before_handle_vic_irq(unsigned int irq);
|
|
|
|
static void after_handle_vic_irq(unsigned int irq);
|
|
|
|
static void set_vic_irq_affinity(unsigned int irq, cpumask_t mask);
|
|
|
|
static void ack_vic_irq(unsigned int irq);
|
|
|
|
static void vic_enable_cpi(void);
|
|
|
|
static void do_boot_cpu(__u8 cpuid);
|
|
|
|
static void do_quad_bootstrap(void);
|
2008-10-30 22:08:38 +01:00
|
|
|
static void initialize_secondary(void);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
int hard_smp_processor_id(void);
|
2006-10-01 08:29:08 +02:00
|
|
|
int safe_smp_processor_id(void);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Inline functions */
|
2008-01-30 13:30:10 +01:00
|
|
|
static inline void send_one_QIC_CPI(__u8 cpu, __u8 cpi)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
voyager_quad_cpi_addr[cpu]->qic_cpi[cpi].cpi =
|
2008-01-30 13:30:10 +01:00
|
|
|
(smp_processor_id() << 16) + cpi;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
static inline void send_QIC_CPI(__u32 cpuset, __u8 cpi)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
int cpu;
|
|
|
|
|
|
|
|
for_each_online_cpu(cpu) {
|
2008-01-30 13:30:10 +01:00
|
|
|
if (cpuset & (1 << cpu)) {
|
2005-04-17 00:20:36 +02:00
|
|
|
#ifdef VOYAGER_DEBUG
|
2008-04-19 16:55:17 +02:00
|
|
|
if (!cpu_online(cpu))
|
2008-01-30 13:30:10 +01:00
|
|
|
VDEBUG(("CPU%d sending cpi %d to CPU%d not in "
|
|
|
|
"cpu_online_map\n",
|
|
|
|
hard_smp_processor_id(), cpi, cpu));
|
2005-04-17 00:20:36 +02:00
|
|
|
#endif
|
|
|
|
send_one_QIC_CPI(cpu, cpi - QIC_CPI_OFFSET);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
static inline void wrapper_smp_local_timer_interrupt(void)
|
2005-05-25 04:29:46 +02:00
|
|
|
{
|
|
|
|
irq_enter();
|
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 15:55:46 +02:00
|
|
|
smp_local_timer_interrupt();
|
2005-05-25 04:29:46 +02:00
|
|
|
irq_exit();
|
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
static inline void send_one_CPI(__u8 cpu, __u8 cpi)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2008-01-30 13:30:10 +01:00
|
|
|
if (voyager_quad_processors & (1 << cpu))
|
2005-04-17 00:20:36 +02:00
|
|
|
send_one_QIC_CPI(cpu, cpi - QIC_CPI_OFFSET);
|
|
|
|
else
|
2008-01-30 13:30:10 +01:00
|
|
|
send_CPI(1 << cpu, cpi);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
static inline void send_CPI_allbutself(__u8 cpi)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
__u8 cpu = smp_processor_id();
|
|
|
|
__u32 mask = cpus_addr(cpu_online_map)[0] & ~(1 << cpu);
|
|
|
|
send_CPI(mask, cpi);
|
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
static inline int is_cpu_quad(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
__u8 cpumask = inb(VIC_PROC_WHO_AM_I);
|
|
|
|
return ((cpumask & QUAD_IDENTIFIER) == QUAD_IDENTIFIER);
|
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
static inline int is_cpu_extended(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
__u8 cpu = hard_smp_processor_id();
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
return (voyager_extended_vic_processors & (1 << cpu));
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
static inline int is_cpu_vic_boot(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
__u8 cpu = hard_smp_processor_id();
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
return (voyager_extended_vic_processors
|
|
|
|
& voyager_allowed_boot_processors & (1 << cpu));
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
static inline void ack_CPI(__u8 cpi)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2008-01-30 13:30:10 +01:00
|
|
|
switch (cpi) {
|
2005-04-17 00:20:36 +02:00
|
|
|
case VIC_CPU_BOOT_CPI:
|
2008-01-30 13:30:10 +01:00
|
|
|
if (is_cpu_quad() && !is_cpu_vic_boot())
|
2005-04-17 00:20:36 +02:00
|
|
|
ack_QIC_CPI(cpi);
|
|
|
|
else
|
|
|
|
ack_VIC_CPI(cpi);
|
|
|
|
break;
|
|
|
|
case VIC_SYS_INT:
|
2008-01-30 13:30:10 +01:00
|
|
|
case VIC_CMN_INT:
|
2005-04-17 00:20:36 +02:00
|
|
|
/* These are slightly strange. Even on the Quad card,
|
|
|
|
* They are vectored as VIC CPIs */
|
2008-01-30 13:30:10 +01:00
|
|
|
if (is_cpu_quad())
|
2005-04-17 00:20:36 +02:00
|
|
|
ack_special_QIC_CPI(cpi);
|
|
|
|
else
|
|
|
|
ack_VIC_CPI(cpi);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printk("VOYAGER ERROR: CPI%d is in common CPI code\n", cpi);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* local variables */
|
|
|
|
|
|
|
|
/* The VIC IRQ descriptors -- these look almost identical to the
|
|
|
|
* 8259 IRQs except that masks and things must be kept per processor
|
|
|
|
*/
|
2006-10-13 05:21:16 +02:00
|
|
|
static struct irq_chip vic_chip = {
|
2008-01-30 13:30:10 +01:00
|
|
|
.name = "VIC",
|
|
|
|
.startup = startup_vic_irq,
|
|
|
|
.mask = mask_vic_irq,
|
|
|
|
.unmask = unmask_vic_irq,
|
|
|
|
.set_affinity = set_vic_irq_affinity,
|
2005-04-17 00:20:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/* used to count up as CPUs are brought on line (starts at 0) */
|
|
|
|
static int cpucount = 0;
|
|
|
|
|
|
|
|
/* The per cpu profile stuff - used in smp_local_timer_interrupt */
|
|
|
|
static DEFINE_PER_CPU(int, prof_multiplier) = 1;
|
|
|
|
static DEFINE_PER_CPU(int, prof_old_multiplier) = 1;
|
2008-01-30 13:30:10 +01:00
|
|
|
static DEFINE_PER_CPU(int, prof_counter) = 1;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* the map used to check if a CPU has booted */
|
|
|
|
static __u32 cpu_booted_map;
|
|
|
|
|
|
|
|
/* the synchronize flag used to hold all secondary CPUs spinning in
|
|
|
|
* a tight loop until the boot sequence is ready for them */
|
|
|
|
static cpumask_t smp_commenced_mask = CPU_MASK_NONE;
|
|
|
|
|
|
|
|
/* This is for the new dynamic CPU boot code */
|
|
|
|
cpumask_t cpu_callin_map = CPU_MASK_NONE;
|
|
|
|
cpumask_t cpu_callout_map = CPU_MASK_NONE;
|
|
|
|
|
|
|
|
/* The per processor IRQ masks (these are usually kept in sync) */
|
|
|
|
static __u16 vic_irq_mask[NR_CPUS] __cacheline_aligned;
|
|
|
|
|
|
|
|
/* the list of IRQs to be enabled by the VIC_ENABLE_IRQ_CPI */
|
|
|
|
static __u16 vic_irq_enable_mask[NR_CPUS] __cacheline_aligned = { 0 };
|
|
|
|
|
|
|
|
/* Lock for enable/disable of VIC interrupts */
|
2008-01-30 13:30:10 +01:00
|
|
|
static __cacheline_aligned DEFINE_SPINLOCK(vic_irq_lock);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
/* The boot processor is correctly set up in PC mode when it
|
2005-04-17 00:20:36 +02:00
|
|
|
* comes up, but the secondaries need their master/slave 8259
|
|
|
|
* pairs initializing correctly */
|
|
|
|
|
|
|
|
/* Interrupt counters (per cpu) and total - used to try to
|
|
|
|
* even up the interrupt handling routines */
|
|
|
|
static long vic_intr_total = 0;
|
|
|
|
static long vic_intr_count[NR_CPUS] __cacheline_aligned = { 0 };
|
|
|
|
static unsigned long vic_tick[NR_CPUS] __cacheline_aligned = { 0 };
|
|
|
|
|
|
|
|
/* Since we can only use CPI0, we fake all the other CPIs */
|
|
|
|
static unsigned long vic_cpi_mailbox[NR_CPUS] __cacheline_aligned;
|
|
|
|
|
|
|
|
/* debugging routine to read the isr of the cpu's pic */
|
2008-01-30 13:30:10 +01:00
|
|
|
static inline __u16 vic_read_isr(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
__u16 isr;
|
|
|
|
|
|
|
|
outb(0x0b, 0xa0);
|
|
|
|
isr = inb(0xa0) << 8;
|
|
|
|
outb(0x0b, 0x20);
|
|
|
|
isr |= inb(0x20);
|
|
|
|
|
|
|
|
return isr;
|
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
static __init void qic_setup(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2008-01-30 13:30:10 +01:00
|
|
|
if (!is_cpu_quad()) {
|
2005-04-17 00:20:36 +02:00
|
|
|
/* not a quad, no setup */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
outb(QIC_DEFAULT_MASK0, QIC_MASK_REGISTER0);
|
|
|
|
outb(QIC_CPI_ENABLE, QIC_MASK_REGISTER1);
|
2008-01-30 13:30:10 +01:00
|
|
|
|
|
|
|
if (is_cpu_extended()) {
|
2005-04-17 00:20:36 +02:00
|
|
|
/* the QIC duplicate of the VIC base register */
|
|
|
|
outb(VIC_DEFAULT_CPI_BASE, QIC_VIC_CPI_BASE_REGISTER);
|
|
|
|
outb(QIC_DEFAULT_CPI_BASE, QIC_CPI_BASE_REGISTER);
|
|
|
|
|
|
|
|
/* FIXME: should set up the QIC timer and memory parity
|
|
|
|
* error vectors here */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
static __init void vic_setup_pic(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
outb(1, VIC_REDIRECT_REGISTER_1);
|
|
|
|
/* clear the claim registers for dynamic routing */
|
|
|
|
outb(0, VIC_CLAIM_REGISTER_0);
|
|
|
|
outb(0, VIC_CLAIM_REGISTER_1);
|
|
|
|
|
|
|
|
outb(0, VIC_PRIORITY_REGISTER);
|
|
|
|
/* Set the Primary and Secondary Microchannel vector
|
|
|
|
* bases to be the same as the ordinary interrupts
|
|
|
|
*
|
|
|
|
* FIXME: This would be more efficient using separate
|
|
|
|
* vectors. */
|
|
|
|
outb(FIRST_EXTERNAL_VECTOR, VIC_PRIMARY_MC_BASE);
|
|
|
|
outb(FIRST_EXTERNAL_VECTOR, VIC_SECONDARY_MC_BASE);
|
|
|
|
/* Now initiallise the master PIC belonging to this CPU by
|
|
|
|
* sending the four ICWs */
|
|
|
|
|
|
|
|
/* ICW1: level triggered, ICW4 needed */
|
|
|
|
outb(0x19, 0x20);
|
|
|
|
|
|
|
|
/* ICW2: vector base */
|
|
|
|
outb(FIRST_EXTERNAL_VECTOR, 0x21);
|
|
|
|
|
|
|
|
/* ICW3: slave at line 2 */
|
|
|
|
outb(0x04, 0x21);
|
|
|
|
|
|
|
|
/* ICW4: 8086 mode */
|
|
|
|
outb(0x01, 0x21);
|
|
|
|
|
|
|
|
/* now the same for the slave PIC */
|
|
|
|
|
|
|
|
/* ICW1: level trigger, ICW4 needed */
|
|
|
|
outb(0x19, 0xA0);
|
|
|
|
|
|
|
|
/* ICW2: slave vector base */
|
|
|
|
outb(FIRST_EXTERNAL_VECTOR + 8, 0xA1);
|
2008-01-30 13:30:10 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* ICW3: slave ID */
|
|
|
|
outb(0x02, 0xA1);
|
|
|
|
|
|
|
|
/* ICW4: 8086 mode */
|
|
|
|
outb(0x01, 0xA1);
|
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
static void do_quad_bootstrap(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2008-01-30 13:30:10 +01:00
|
|
|
if (is_cpu_quad() && is_cpu_vic_boot()) {
|
2005-04-17 00:20:36 +02:00
|
|
|
int i;
|
|
|
|
unsigned long flags;
|
|
|
|
__u8 cpuid = hard_smp_processor_id();
|
|
|
|
|
|
|
|
local_irq_save(flags);
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
for (i = 0; i < 4; i++) {
|
2005-04-17 00:20:36 +02:00
|
|
|
/* FIXME: this would be >>3 &0x7 on the 32 way */
|
2008-01-30 13:30:10 +01:00
|
|
|
if (((cpuid >> 2) & 0x03) == i)
|
2005-04-17 00:20:36 +02:00
|
|
|
/* don't lower our own mask! */
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* masquerade as local Quad CPU */
|
|
|
|
outb(QIC_CPUID_ENABLE | i, QIC_PROCESSOR_ID);
|
|
|
|
/* enable the startup CPI */
|
|
|
|
outb(QIC_BOOT_CPI_MASK, QIC_MASK_REGISTER1);
|
|
|
|
/* restore cpu id */
|
|
|
|
outb(0, QIC_PROCESSOR_ID);
|
|
|
|
}
|
|
|
|
local_irq_restore(flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-30 22:28:35 +01:00
|
|
|
void prefill_possible_map(void)
|
|
|
|
{
|
|
|
|
/* This is empty on voyager because we need a much
|
|
|
|
* earlier detection which is done in find_smp_config */
|
|
|
|
}
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Set up all the basic stuff: read the SMP config and make all the
|
|
|
|
* SMP information reflect only the boot cpu. All others will be
|
|
|
|
* brought on-line later. */
|
2008-01-30 13:30:10 +01:00
|
|
|
void __init find_smp_config(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
boot_cpu_id = hard_smp_processor_id();
|
|
|
|
|
|
|
|
printk("VOYAGER SMP: Boot cpu is %d\n", boot_cpu_id);
|
|
|
|
|
|
|
|
/* initialize the CPU structures (moved from smp_boot_cpus) */
|
2008-01-30 13:30:10 +01:00
|
|
|
for (i = 0; i < NR_CPUS; i++) {
|
2005-04-17 00:20:36 +02:00
|
|
|
cpu_irq_affinity[i] = ~0;
|
|
|
|
}
|
|
|
|
cpu_online_map = cpumask_of_cpu(boot_cpu_id);
|
|
|
|
|
|
|
|
/* The boot CPU must be extended */
|
2008-01-30 13:30:10 +01:00
|
|
|
voyager_extended_vic_processors = 1 << boot_cpu_id;
|
2007-10-20 01:13:56 +02:00
|
|
|
/* initially, all of the first 8 CPUs can boot */
|
2005-04-17 00:20:36 +02:00
|
|
|
voyager_allowed_boot_processors = 0xff;
|
|
|
|
/* set up everything for just this CPU, we can alter
|
|
|
|
* this as we start the other CPUs later */
|
|
|
|
/* now get the CPU disposition from the extended CMOS */
|
2008-01-30 13:30:10 +01:00
|
|
|
cpus_addr(phys_cpu_present_map)[0] =
|
|
|
|
voyager_extended_cmos_read(VOYAGER_PROCESSOR_PRESENT_MASK);
|
|
|
|
cpus_addr(phys_cpu_present_map)[0] |=
|
|
|
|
voyager_extended_cmos_read(VOYAGER_PROCESSOR_PRESENT_MASK + 1) << 8;
|
|
|
|
cpus_addr(phys_cpu_present_map)[0] |=
|
|
|
|
voyager_extended_cmos_read(VOYAGER_PROCESSOR_PRESENT_MASK +
|
|
|
|
2) << 16;
|
|
|
|
cpus_addr(phys_cpu_present_map)[0] |=
|
|
|
|
voyager_extended_cmos_read(VOYAGER_PROCESSOR_PRESENT_MASK +
|
|
|
|
3) << 24;
|
2006-02-24 22:04:11 +01:00
|
|
|
cpu_possible_map = phys_cpu_present_map;
|
2008-01-30 13:30:10 +01:00
|
|
|
printk("VOYAGER SMP: phys_cpu_present_map = 0x%lx\n",
|
|
|
|
cpus_addr(phys_cpu_present_map)[0]);
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Here we set up the VIC to enable SMP */
|
|
|
|
/* enable the CPIs by writing the base vector to their register */
|
|
|
|
outb(VIC_DEFAULT_CPI_BASE, VIC_CPI_BASE_REGISTER);
|
|
|
|
outb(1, VIC_REDIRECT_REGISTER_1);
|
|
|
|
/* set the claim registers for static routing --- Boot CPU gets
|
|
|
|
* all interrupts untill all other CPUs started */
|
|
|
|
outb(0xff, VIC_CLAIM_REGISTER_0);
|
|
|
|
outb(0xff, VIC_CLAIM_REGISTER_1);
|
|
|
|
/* Set the Primary and Secondary Microchannel vector
|
|
|
|
* bases to be the same as the ordinary interrupts
|
|
|
|
*
|
|
|
|
* FIXME: This would be more efficient using separate
|
|
|
|
* vectors. */
|
|
|
|
outb(FIRST_EXTERNAL_VECTOR, VIC_PRIMARY_MC_BASE);
|
|
|
|
outb(FIRST_EXTERNAL_VECTOR, VIC_SECONDARY_MC_BASE);
|
|
|
|
|
|
|
|
/* Finally tell the firmware that we're driving */
|
|
|
|
outb(inb(VOYAGER_SUS_IN_CONTROL_PORT) | VOYAGER_IN_CONTROL_FLAG,
|
|
|
|
VOYAGER_SUS_IN_CONTROL_PORT);
|
|
|
|
|
|
|
|
current_thread_info()->cpu = boot_cpu_id;
|
2007-05-15 10:41:59 +02:00
|
|
|
x86_write_percpu(cpu_number, boot_cpu_id);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The bootstrap kernel entry code has set these up. Save them
|
|
|
|
* for a given CPU, id is physical */
|
2008-01-30 13:30:10 +01:00
|
|
|
void __init smp_store_cpu_info(int id)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2007-10-19 20:35:04 +02:00
|
|
|
struct cpuinfo_x86 *c = &cpu_data(id);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
*c = boot_cpu_data;
|
2008-10-30 22:13:37 +01:00
|
|
|
c->cpu_index = id;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2007-05-15 10:41:59 +02:00
|
|
|
identify_secondary_cpu(c);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Routine initially called when a non-boot CPU is brought online */
|
2008-01-30 13:30:10 +01:00
|
|
|
static void __init start_secondary(void *unused)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
__u8 cpuid = hard_smp_processor_id();
|
|
|
|
|
2007-05-15 10:41:59 +02:00
|
|
|
cpu_init();
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* OK, we're in the routine */
|
|
|
|
ack_CPI(VIC_CPU_BOOT_CPI);
|
|
|
|
|
|
|
|
/* setup the 8259 master slave pair belonging to this CPU ---
|
2008-01-30 13:30:10 +01:00
|
|
|
* we won't actually receive any until the boot CPU
|
|
|
|
* relinquishes it's static routing mask */
|
2005-04-17 00:20:36 +02:00
|
|
|
vic_setup_pic();
|
|
|
|
|
|
|
|
qic_setup();
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
if (is_cpu_quad() && !is_cpu_vic_boot()) {
|
2005-04-17 00:20:36 +02:00
|
|
|
/* clear the boot CPI */
|
|
|
|
__u8 dummy;
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
dummy =
|
|
|
|
voyager_quad_cpi_addr[cpuid]->qic_cpi[VIC_CPU_BOOT_CPI].cpi;
|
2005-04-17 00:20:36 +02:00
|
|
|
printk("read dummy %d\n", dummy);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* lower the mask to receive CPIs */
|
|
|
|
vic_enable_cpi();
|
|
|
|
|
|
|
|
VDEBUG(("VOYAGER SMP: CPU%d, stack at about %p\n", cpuid, &cpuid));
|
|
|
|
|
2008-09-07 16:57:22 +02:00
|
|
|
notify_cpu_starting(cpuid);
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* enable interrupts */
|
|
|
|
local_irq_enable();
|
|
|
|
|
|
|
|
/* get our bogomips */
|
|
|
|
calibrate_delay();
|
|
|
|
|
|
|
|
/* save our processor parameters */
|
|
|
|
smp_store_cpu_info(cpuid);
|
|
|
|
|
|
|
|
/* if we're a quad, we may need to bootstrap other CPUs */
|
|
|
|
do_quad_bootstrap();
|
|
|
|
|
|
|
|
/* FIXME: this is rather a poor hack to prevent the CPU
|
|
|
|
* activating softirqs while it's supposed to be waiting for
|
|
|
|
* permission to proceed. Without this, the new per CPU stuff
|
|
|
|
* in the softirqs will fail */
|
|
|
|
local_irq_disable();
|
|
|
|
cpu_set(cpuid, cpu_callin_map);
|
|
|
|
|
|
|
|
/* signal that we're done */
|
|
|
|
cpu_booted_map = 1;
|
|
|
|
|
|
|
|
while (!cpu_isset(cpuid, smp_commenced_mask))
|
|
|
|
rep_nop();
|
|
|
|
local_irq_enable();
|
|
|
|
|
|
|
|
local_flush_tlb();
|
|
|
|
|
|
|
|
cpu_set(cpuid, cpu_online_map);
|
|
|
|
wmb();
|
|
|
|
cpu_idle();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Routine to kick start the given CPU and wait for it to report ready
|
|
|
|
* (or timeout in startup). When this routine returns, the requested
|
|
|
|
* CPU is either fully running and configured or known to be dead.
|
|
|
|
*
|
|
|
|
* We call this routine sequentially 1 CPU at a time, so no need for
|
|
|
|
* locking */
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
static void __init do_boot_cpu(__u8 cpu)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
struct task_struct *idle;
|
|
|
|
int timeout;
|
|
|
|
unsigned long flags;
|
2008-01-30 13:30:10 +01:00
|
|
|
int quad_boot = (1 << cpu) & voyager_quad_processors
|
|
|
|
& ~(voyager_extended_vic_processors
|
|
|
|
& voyager_allowed_boot_processors);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* This is the format of the CPI IDT gate (in real mode) which
|
|
|
|
* we're hijacking to boot the CPU */
|
2008-01-30 13:30:10 +01:00
|
|
|
union IDTFormat {
|
2005-04-17 00:20:36 +02:00
|
|
|
struct seg {
|
2008-01-30 13:30:10 +01:00
|
|
|
__u16 Offset;
|
|
|
|
__u16 Segment;
|
2005-04-17 00:20:36 +02:00
|
|
|
} idt;
|
|
|
|
__u32 val;
|
|
|
|
} hijack_source;
|
|
|
|
|
|
|
|
__u32 *hijack_vector;
|
|
|
|
__u32 start_phys_address = setup_trampoline();
|
|
|
|
|
|
|
|
/* There's a clever trick to this: The linux trampoline is
|
|
|
|
* compiled to begin at absolute location zero, so make the
|
|
|
|
* address zero but have the data segment selector compensate
|
|
|
|
* for the actual address */
|
|
|
|
hijack_source.idt.Offset = start_phys_address & 0x000F;
|
|
|
|
hijack_source.idt.Segment = (start_phys_address >> 4) & 0xFFFF;
|
|
|
|
|
|
|
|
cpucount++;
|
2007-05-01 17:13:46 +02:00
|
|
|
alternatives_smp_switch(1);
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
idle = fork_idle(cpu);
|
2008-01-30 13:30:10 +01:00
|
|
|
if (IS_ERR(idle))
|
2005-04-17 00:20:36 +02:00
|
|
|
panic("failed fork for CPU%d", cpu);
|
2008-01-30 13:30:56 +01:00
|
|
|
idle->thread.ip = (unsigned long)start_secondary;
|
2005-04-17 00:20:36 +02:00
|
|
|
/* init_tasks (in sched.c) is indexed logically */
|
2008-01-30 13:30:56 +01:00
|
|
|
stack_start.sp = (void *)idle->thread.sp;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2007-05-15 10:41:59 +02:00
|
|
|
init_gdt(cpu);
|
2008-01-30 13:30:10 +01:00
|
|
|
per_cpu(current_task, cpu) = idle;
|
2007-05-15 10:41:59 +02:00
|
|
|
early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
|
2005-04-17 00:20:36 +02:00
|
|
|
irq_ctx_init(cpu);
|
|
|
|
|
|
|
|
/* Note: Don't modify initial ss override */
|
2008-01-30 13:30:10 +01:00
|
|
|
VDEBUG(("VOYAGER SMP: Booting CPU%d at 0x%lx[%x:%x], stack %p\n", cpu,
|
2005-04-17 00:20:36 +02:00
|
|
|
(unsigned long)hijack_source.val, hijack_source.idt.Segment,
|
2008-01-30 13:30:56 +01:00
|
|
|
hijack_source.idt.Offset, stack_start.sp));
|
2007-04-30 17:57:40 +02:00
|
|
|
|
|
|
|
/* init lowmem identity mapping */
|
2008-03-18 00:37:13 +01:00
|
|
|
clone_pgd_range(swapper_pg_dir, swapper_pg_dir + KERNEL_PGD_BOUNDARY,
|
|
|
|
min_t(unsigned long, KERNEL_PGD_PTRS, KERNEL_PGD_BOUNDARY));
|
2007-04-30 17:57:40 +02:00
|
|
|
flush_tlb_all();
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
if (quad_boot) {
|
2005-04-17 00:20:36 +02:00
|
|
|
printk("CPU %d: non extended Quad boot\n", cpu);
|
2008-01-30 13:30:10 +01:00
|
|
|
hijack_vector =
|
|
|
|
(__u32 *)
|
|
|
|
phys_to_virt((VIC_CPU_BOOT_CPI + QIC_DEFAULT_CPI_BASE) * 4);
|
2005-04-17 00:20:36 +02:00
|
|
|
*hijack_vector = hijack_source.val;
|
|
|
|
} else {
|
|
|
|
printk("CPU%d: extended VIC boot\n", cpu);
|
2008-01-30 13:30:10 +01:00
|
|
|
hijack_vector =
|
|
|
|
(__u32 *)
|
|
|
|
phys_to_virt((VIC_CPU_BOOT_CPI + VIC_DEFAULT_CPI_BASE) * 4);
|
2005-04-17 00:20:36 +02:00
|
|
|
*hijack_vector = hijack_source.val;
|
|
|
|
/* VIC errata, may also receive interrupt at this address */
|
2008-01-30 13:30:10 +01:00
|
|
|
hijack_vector =
|
|
|
|
(__u32 *)
|
|
|
|
phys_to_virt((VIC_CPU_BOOT_ERRATA_CPI +
|
|
|
|
VIC_DEFAULT_CPI_BASE) * 4);
|
2005-04-17 00:20:36 +02:00
|
|
|
*hijack_vector = hijack_source.val;
|
|
|
|
}
|
|
|
|
/* All non-boot CPUs start with interrupts fully masked. Need
|
|
|
|
* to lower the mask of the CPI we're about to send. We do
|
|
|
|
* this in the VIC by masquerading as the processor we're
|
|
|
|
* about to boot and lowering its interrupt mask */
|
|
|
|
local_irq_save(flags);
|
2008-01-30 13:30:10 +01:00
|
|
|
if (quad_boot) {
|
2005-04-17 00:20:36 +02:00
|
|
|
send_one_QIC_CPI(cpu, VIC_CPU_BOOT_CPI);
|
|
|
|
} else {
|
|
|
|
outb(VIC_CPU_MASQUERADE_ENABLE | cpu, VIC_PROCESSOR_ID);
|
|
|
|
/* here we're altering registers belonging to `cpu' */
|
2008-01-30 13:30:10 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
outb(VIC_BOOT_INTERRUPT_MASK, 0x21);
|
|
|
|
/* now go back to our original identity */
|
|
|
|
outb(boot_cpu_id, VIC_PROCESSOR_ID);
|
|
|
|
|
|
|
|
/* and boot the CPU */
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
send_CPI((1 << cpu), VIC_CPU_BOOT_CPI);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
cpu_booted_map = 0;
|
|
|
|
local_irq_restore(flags);
|
|
|
|
|
|
|
|
/* now wait for it to become ready (or timeout) */
|
2008-01-30 13:30:10 +01:00
|
|
|
for (timeout = 0; timeout < 50000; timeout++) {
|
|
|
|
if (cpu_booted_map)
|
2005-04-17 00:20:36 +02:00
|
|
|
break;
|
|
|
|
udelay(100);
|
|
|
|
}
|
|
|
|
/* reset the page table */
|
2007-04-30 17:57:40 +02:00
|
|
|
zap_low_mappings();
|
2008-01-30 13:30:10 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
if (cpu_booted_map) {
|
|
|
|
VDEBUG(("CPU%d: Booted successfully, back in CPU %d\n",
|
|
|
|
cpu, smp_processor_id()));
|
2008-01-30 13:30:10 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
printk("CPU%d: ", cpu);
|
2007-10-19 20:35:04 +02:00
|
|
|
print_cpu_info(&cpu_data(cpu));
|
2005-04-17 00:20:36 +02:00
|
|
|
wmb();
|
|
|
|
cpu_set(cpu, cpu_callout_map);
|
2006-06-27 04:33:09 +02:00
|
|
|
cpu_set(cpu, cpu_present_map);
|
2008-01-30 13:30:10 +01:00
|
|
|
} else {
|
2005-04-17 00:20:36 +02:00
|
|
|
printk("CPU%d FAILED TO BOOT: ", cpu);
|
2008-01-30 13:30:10 +01:00
|
|
|
if (*
|
|
|
|
((volatile unsigned char *)phys_to_virt(start_phys_address))
|
|
|
|
== 0xA5)
|
2005-04-17 00:20:36 +02:00
|
|
|
printk("Stuck.\n");
|
|
|
|
else
|
|
|
|
printk("Not responding.\n");
|
2008-01-30 13:30:10 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
cpucount--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
void __init smp_boot_cpus(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* CAT BUS initialisation must be done after the memory */
|
|
|
|
/* FIXME: The L4 has a catbus too, it just needs to be
|
|
|
|
* accessed in a totally different way */
|
2008-01-30 13:30:10 +01:00
|
|
|
if (voyager_level == 5) {
|
2005-04-17 00:20:36 +02:00
|
|
|
voyager_cat_init();
|
|
|
|
|
|
|
|
/* now that the cat has probed the Voyager System Bus, sanity
|
|
|
|
* check the cpu map */
|
2008-01-30 13:30:10 +01:00
|
|
|
if (((voyager_quad_processors | voyager_extended_vic_processors)
|
|
|
|
& cpus_addr(phys_cpu_present_map)[0]) !=
|
|
|
|
cpus_addr(phys_cpu_present_map)[0]) {
|
2005-04-17 00:20:36 +02:00
|
|
|
/* should panic */
|
2008-01-30 13:30:10 +01:00
|
|
|
printk("\n\n***WARNING*** "
|
|
|
|
"Sanity check of CPU present map FAILED\n");
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
2008-01-30 13:30:10 +01:00
|
|
|
} else if (voyager_level == 4)
|
|
|
|
voyager_extended_vic_processors =
|
|
|
|
cpus_addr(phys_cpu_present_map)[0];
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* this sets up the idle task to run on the current cpu */
|
|
|
|
voyager_extended_cpus = 1;
|
|
|
|
/* Remove the global_irq_holder setting, it triggers a BUG() on
|
|
|
|
* schedule at the moment */
|
|
|
|
//global_irq_holder = boot_cpu_id;
|
|
|
|
|
|
|
|
/* FIXME: Need to do something about this but currently only works
|
2008-01-30 13:30:10 +01:00
|
|
|
* on CPUs with a tsc which none of mine have.
|
|
|
|
smp_tune_scheduling();
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
|
|
|
smp_store_cpu_info(boot_cpu_id);
|
2008-10-30 22:08:38 +01:00
|
|
|
/* setup the jump vector */
|
|
|
|
initial_code = (unsigned long)initialize_secondary;
|
2005-04-17 00:20:36 +02:00
|
|
|
printk("CPU%d: ", boot_cpu_id);
|
2007-10-19 20:35:04 +02:00
|
|
|
print_cpu_info(&cpu_data(boot_cpu_id));
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
if (is_cpu_quad()) {
|
2005-04-17 00:20:36 +02:00
|
|
|
/* booting on a Quad CPU */
|
|
|
|
printk("VOYAGER SMP: Boot CPU is Quad\n");
|
|
|
|
qic_setup();
|
|
|
|
do_quad_bootstrap();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* enable our own CPIs */
|
|
|
|
vic_enable_cpi();
|
|
|
|
|
|
|
|
cpu_set(boot_cpu_id, cpu_online_map);
|
|
|
|
cpu_set(boot_cpu_id, cpu_callout_map);
|
2008-01-30 13:30:10 +01:00
|
|
|
|
|
|
|
/* loop over all the extended VIC CPUs and boot them. The
|
2005-04-17 00:20:36 +02:00
|
|
|
* Quad CPUs must be bootstrapped by their extended VIC cpu */
|
2008-12-17 02:34:01 +01:00
|
|
|
for (i = 0; i < nr_cpu_ids; i++) {
|
2008-01-30 13:30:10 +01:00
|
|
|
if (i == boot_cpu_id || !cpu_isset(i, phys_cpu_present_map))
|
2005-04-17 00:20:36 +02:00
|
|
|
continue;
|
|
|
|
do_boot_cpu(i);
|
|
|
|
/* This udelay seems to be needed for the Quad boots
|
|
|
|
* don't remove unless you know what you're doing */
|
|
|
|
udelay(1000);
|
|
|
|
}
|
|
|
|
/* we could compute the total bogomips here, but why bother?,
|
|
|
|
* Code added from smpboot.c */
|
|
|
|
{
|
|
|
|
unsigned long bogosum = 0;
|
2008-04-19 16:55:17 +02:00
|
|
|
|
|
|
|
for_each_online_cpu(i)
|
|
|
|
bogosum += cpu_data(i).loops_per_jiffy;
|
2008-01-30 13:30:10 +01:00
|
|
|
printk(KERN_INFO "Total of %d processors activated "
|
|
|
|
"(%lu.%02lu BogoMIPS).\n",
|
|
|
|
cpucount + 1, bogosum / (500000 / HZ),
|
|
|
|
(bogosum / (5000 / HZ)) % 100);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
voyager_extended_cpus = hweight32(voyager_extended_vic_processors);
|
2008-01-30 13:30:10 +01:00
|
|
|
printk("VOYAGER: Extended (interrupt handling CPUs): "
|
|
|
|
"%d, non-extended: %d\n", voyager_extended_cpus,
|
|
|
|
num_booting_cpus() - voyager_extended_cpus);
|
2005-04-17 00:20:36 +02:00
|
|
|
/* that's it, switch to symmetric mode */
|
|
|
|
outb(0, VIC_PRIORITY_REGISTER);
|
|
|
|
outb(0, VIC_CLAIM_REGISTER_0);
|
|
|
|
outb(0, VIC_CLAIM_REGISTER_1);
|
2008-01-30 13:30:10 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
VDEBUG(("VOYAGER SMP: Booted with %d CPUs\n", num_booting_cpus()));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Reload the secondary CPUs task structure (this function does not
|
|
|
|
* return ) */
|
2008-10-30 22:08:38 +01:00
|
|
|
static void __init initialize_secondary(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
// AC kernels only
|
|
|
|
set_current(hard_get_current());
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We don't actually need to load the full TSS,
|
|
|
|
* basically just the stack pointer and the eip.
|
|
|
|
*/
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
asm volatile ("movl %0,%%esp\n\t"
|
2008-01-30 13:30:56 +01:00
|
|
|
"jmp *%1"::"r" (current->thread.sp),
|
|
|
|
"r"(current->thread.ip));
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* handle a Voyager SYS_INT -- If we don't, the base board will
|
|
|
|
* panic the system.
|
|
|
|
*
|
|
|
|
* System interrupts occur because some problem was detected on the
|
|
|
|
* various busses. To find out what you have to probe all the
|
|
|
|
* hardware via the CAT bus. FIXME: At the moment we do nothing. */
|
2008-01-30 13:31:17 +01:00
|
|
|
void smp_vic_sys_interrupt(struct pt_regs *regs)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
ack_CPI(VIC_SYS_INT);
|
2008-01-30 13:30:10 +01:00
|
|
|
printk("Voyager SYSTEM INTERRUPT\n");
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle a voyager CMN_INT; These interrupts occur either because of
|
|
|
|
* a system status change or because a single bit memory error
|
|
|
|
* occurred. FIXME: At the moment, ignore all this. */
|
2008-01-30 13:31:17 +01:00
|
|
|
void smp_vic_cmn_interrupt(struct pt_regs *regs)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
static __u8 in_cmn_int = 0;
|
|
|
|
static DEFINE_SPINLOCK(cmn_int_lock);
|
|
|
|
|
|
|
|
/* common ints are broadcast, so make sure we only do this once */
|
|
|
|
_raw_spin_lock(&cmn_int_lock);
|
2008-01-30 13:30:10 +01:00
|
|
|
if (in_cmn_int)
|
2005-04-17 00:20:36 +02:00
|
|
|
goto unlock_end;
|
|
|
|
|
|
|
|
in_cmn_int++;
|
|
|
|
_raw_spin_unlock(&cmn_int_lock);
|
|
|
|
|
|
|
|
VDEBUG(("Voyager COMMON INTERRUPT\n"));
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
if (voyager_level == 5)
|
2005-04-17 00:20:36 +02:00
|
|
|
voyager_cat_do_common_interrupt();
|
|
|
|
|
|
|
|
_raw_spin_lock(&cmn_int_lock);
|
|
|
|
in_cmn_int = 0;
|
2008-01-30 13:30:10 +01:00
|
|
|
unlock_end:
|
2005-04-17 00:20:36 +02:00
|
|
|
_raw_spin_unlock(&cmn_int_lock);
|
|
|
|
ack_CPI(VIC_CMN_INT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reschedule call back. Nothing to do, all the work is done
|
|
|
|
* automatically when we return from the interrupt. */
|
2008-01-30 13:30:10 +01:00
|
|
|
static void smp_reschedule_interrupt(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
/* do nothing */
|
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
static struct mm_struct *flush_mm;
|
2005-04-17 00:20:36 +02:00
|
|
|
static unsigned long flush_va;
|
|
|
|
static DEFINE_SPINLOCK(tlbstate_lock);
|
|
|
|
|
|
|
|
/*
|
2008-01-30 13:30:10 +01:00
|
|
|
* We cannot call mmdrop() because we are in interrupt context,
|
2005-04-17 00:20:36 +02:00
|
|
|
* instead update mm->cpu_vm_mask.
|
|
|
|
*
|
|
|
|
* We need to reload %cr3 since the page tables may be going
|
|
|
|
* away from under us..
|
|
|
|
*/
|
2008-01-30 13:32:55 +01:00
|
|
|
static inline void voyager_leave_mm(unsigned long cpu)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
if (per_cpu(cpu_tlbstate, cpu).state == TLBSTATE_OK)
|
|
|
|
BUG();
|
|
|
|
cpu_clear(cpu, per_cpu(cpu_tlbstate, cpu).active_mm->cpu_vm_mask);
|
|
|
|
load_cr3(swapper_pg_dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Invalidate call-back
|
|
|
|
*/
|
2008-01-30 13:30:10 +01:00
|
|
|
static void smp_invalidate_interrupt(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
__u8 cpu = smp_processor_id();
|
|
|
|
|
|
|
|
if (!test_bit(cpu, &smp_invalidate_needed))
|
|
|
|
return;
|
|
|
|
/* This will flood messages. Don't uncomment unless you see
|
|
|
|
* Problems with cross cpu invalidation
|
2008-01-30 13:30:10 +01:00
|
|
|
VDEBUG(("VOYAGER SMP: CPU%d received INVALIDATE_CPI\n",
|
|
|
|
smp_processor_id()));
|
|
|
|
*/
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
if (flush_mm == per_cpu(cpu_tlbstate, cpu).active_mm) {
|
|
|
|
if (per_cpu(cpu_tlbstate, cpu).state == TLBSTATE_OK) {
|
2008-01-30 13:30:35 +01:00
|
|
|
if (flush_va == TLB_FLUSH_ALL)
|
2005-04-17 00:20:36 +02:00
|
|
|
local_flush_tlb();
|
|
|
|
else
|
|
|
|
__flush_tlb_one(flush_va);
|
|
|
|
} else
|
2008-01-30 13:32:55 +01:00
|
|
|
voyager_leave_mm(cpu);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
smp_mb__before_clear_bit();
|
|
|
|
clear_bit(cpu, &smp_invalidate_needed);
|
|
|
|
smp_mb__after_clear_bit();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* All the new flush operations for 2.4 */
|
|
|
|
|
|
|
|
/* This routine is called with a physical cpu mask */
|
|
|
|
static void
|
2008-01-30 13:30:10 +01:00
|
|
|
voyager_flush_tlb_others(unsigned long cpumask, struct mm_struct *mm,
|
|
|
|
unsigned long va)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
int stuck = 50000;
|
|
|
|
|
|
|
|
if (!cpumask)
|
|
|
|
BUG();
|
|
|
|
if ((cpumask & cpus_addr(cpu_online_map)[0]) != cpumask)
|
|
|
|
BUG();
|
|
|
|
if (cpumask & (1 << smp_processor_id()))
|
|
|
|
BUG();
|
|
|
|
if (!mm)
|
|
|
|
BUG();
|
|
|
|
|
|
|
|
spin_lock(&tlbstate_lock);
|
2008-01-30 13:30:10 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
flush_mm = mm;
|
|
|
|
flush_va = va;
|
|
|
|
atomic_set_mask(cpumask, &smp_invalidate_needed);
|
|
|
|
/*
|
|
|
|
* We have to send the CPI only to
|
|
|
|
* CPUs affected.
|
|
|
|
*/
|
|
|
|
send_CPI(cpumask, VIC_INVALIDATE_CPI);
|
|
|
|
|
|
|
|
while (smp_invalidate_needed) {
|
|
|
|
mb();
|
2008-01-30 13:30:10 +01:00
|
|
|
if (--stuck == 0) {
|
|
|
|
printk("***WARNING*** Stuck doing invalidate CPI "
|
|
|
|
"(CPU%d)\n", smp_processor_id());
|
2005-04-17 00:20:36 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Uncomment only to debug invalidation problems
|
2008-01-30 13:30:10 +01:00
|
|
|
VDEBUG(("VOYAGER SMP: Completed invalidate CPI (CPU%d)\n", cpu));
|
|
|
|
*/
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
flush_mm = NULL;
|
|
|
|
flush_va = 0;
|
|
|
|
spin_unlock(&tlbstate_lock);
|
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
void flush_tlb_current_task(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
struct mm_struct *mm = current->mm;
|
|
|
|
unsigned long cpu_mask;
|
|
|
|
|
|
|
|
preempt_disable();
|
|
|
|
|
|
|
|
cpu_mask = cpus_addr(mm->cpu_vm_mask)[0] & ~(1 << smp_processor_id());
|
|
|
|
local_flush_tlb();
|
|
|
|
if (cpu_mask)
|
2008-01-30 13:30:35 +01:00
|
|
|
voyager_flush_tlb_others(cpu_mask, mm, TLB_FLUSH_ALL);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
preempt_enable();
|
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
void flush_tlb_mm(struct mm_struct *mm)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
unsigned long cpu_mask;
|
|
|
|
|
|
|
|
preempt_disable();
|
|
|
|
|
|
|
|
cpu_mask = cpus_addr(mm->cpu_vm_mask)[0] & ~(1 << smp_processor_id());
|
|
|
|
|
|
|
|
if (current->active_mm == mm) {
|
|
|
|
if (current->mm)
|
|
|
|
local_flush_tlb();
|
|
|
|
else
|
2008-01-30 13:32:55 +01:00
|
|
|
voyager_leave_mm(smp_processor_id());
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
if (cpu_mask)
|
2008-01-30 13:30:35 +01:00
|
|
|
voyager_flush_tlb_others(cpu_mask, mm, TLB_FLUSH_ALL);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
preempt_enable();
|
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
void flush_tlb_page(struct vm_area_struct *vma, unsigned long va)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
struct mm_struct *mm = vma->vm_mm;
|
|
|
|
unsigned long cpu_mask;
|
|
|
|
|
|
|
|
preempt_disable();
|
|
|
|
|
|
|
|
cpu_mask = cpus_addr(mm->cpu_vm_mask)[0] & ~(1 << smp_processor_id());
|
|
|
|
if (current->active_mm == mm) {
|
2008-01-30 13:30:10 +01:00
|
|
|
if (current->mm)
|
2005-04-17 00:20:36 +02:00
|
|
|
__flush_tlb_one(va);
|
2008-01-30 13:30:10 +01:00
|
|
|
else
|
2008-01-30 13:32:55 +01:00
|
|
|
voyager_leave_mm(smp_processor_id());
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (cpu_mask)
|
2007-05-15 10:41:59 +02:00
|
|
|
voyager_flush_tlb_others(cpu_mask, mm, va);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
preempt_enable();
|
|
|
|
}
|
2008-01-30 13:30:10 +01:00
|
|
|
|
2005-07-13 15:38:05 +02:00
|
|
|
EXPORT_SYMBOL(flush_tlb_page);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* enable the requested IRQs */
|
2008-01-30 13:30:10 +01:00
|
|
|
static void smp_enable_irq_interrupt(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
__u8 irq;
|
|
|
|
__u8 cpu = get_cpu();
|
|
|
|
|
|
|
|
VDEBUG(("VOYAGER SMP: CPU%d enabling irq mask 0x%x\n", cpu,
|
2008-01-30 13:30:10 +01:00
|
|
|
vic_irq_enable_mask[cpu]));
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
spin_lock(&vic_irq_lock);
|
2008-01-30 13:30:10 +01:00
|
|
|
for (irq = 0; irq < 16; irq++) {
|
|
|
|
if (vic_irq_enable_mask[cpu] & (1 << irq))
|
2005-04-17 00:20:36 +02:00
|
|
|
enable_local_vic_irq(irq);
|
|
|
|
}
|
|
|
|
vic_irq_enable_mask[cpu] = 0;
|
|
|
|
spin_unlock(&vic_irq_lock);
|
|
|
|
|
|
|
|
put_cpu_no_resched();
|
|
|
|
}
|
2008-01-30 13:30:10 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* CPU halt call-back
|
|
|
|
*/
|
2008-01-30 13:30:10 +01:00
|
|
|
static void smp_stop_cpu_function(void *dummy)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
VDEBUG(("VOYAGER SMP: CPU%d is STOPPING\n", smp_processor_id()));
|
|
|
|
cpu_clear(smp_processor_id(), cpu_online_map);
|
|
|
|
local_irq_disable();
|
2008-01-30 13:30:10 +01:00
|
|
|
for (;;)
|
2005-09-04 00:56:42 +02:00
|
|
|
halt();
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* execute a thread on a new CPU. The function to be called must be
|
|
|
|
* previously set up. This is used to schedule a function for
|
2007-10-20 01:13:56 +02:00
|
|
|
* execution on all CPUs - set up the function then broadcast a
|
2005-04-17 00:20:36 +02:00
|
|
|
* function_interrupt CPI to come here on each CPU */
|
2008-01-30 13:30:10 +01:00
|
|
|
static void smp_call_function_interrupt(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
irq_enter();
|
2008-06-26 11:21:54 +02:00
|
|
|
generic_smp_call_function_interrupt();
|
2007-10-17 18:04:40 +02:00
|
|
|
__get_cpu_var(irq_stat).irq_call_count++;
|
2005-04-17 00:20:36 +02:00
|
|
|
irq_exit();
|
|
|
|
}
|
|
|
|
|
2008-06-26 11:21:54 +02:00
|
|
|
static void smp_call_function_single_interrupt(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2008-06-26 11:21:54 +02:00
|
|
|
irq_enter();
|
|
|
|
generic_smp_call_function_single_interrupt();
|
|
|
|
__get_cpu_var(irq_stat).irq_call_count++;
|
|
|
|
irq_exit();
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
2007-04-30 18:24:05 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Sorry about the name. In an APIC based system, the APICs
|
|
|
|
* themselves are programmed to send a timer interrupt. This is used
|
|
|
|
* by linux to reschedule the processor. Voyager doesn't have this,
|
|
|
|
* so we use the system clock to interrupt one processor, which in
|
|
|
|
* turn, broadcasts a timer CPI to all the others --- we receive that
|
|
|
|
* CPI here. We don't use this actually for counting so losing
|
2008-01-30 13:30:10 +01:00
|
|
|
* ticks doesn't matter
|
2005-04-17 00:20:36 +02:00
|
|
|
*
|
2007-10-20 01:13:56 +02:00
|
|
|
* FIXME: For those CPUs which actually have a local APIC, we could
|
2005-04-17 00:20:36 +02:00
|
|
|
* try to use it to trigger this interrupt instead of having to
|
|
|
|
* broadcast the timer tick. Unfortunately, all my pentium DYADs have
|
|
|
|
* no local APIC, so I can't do this
|
|
|
|
*
|
|
|
|
* This function is currently a placeholder and is unused in the code */
|
2008-01-30 13:31:17 +01:00
|
|
|
void smp_apic_timer_interrupt(struct pt_regs *regs)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
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 15:55:46 +02:00
|
|
|
struct pt_regs *old_regs = set_irq_regs(regs);
|
|
|
|
wrapper_smp_local_timer_interrupt();
|
|
|
|
set_irq_regs(old_regs);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* All of the QUAD interrupt GATES */
|
2008-01-30 13:31:17 +01:00
|
|
|
void smp_qic_timer_interrupt(struct pt_regs *regs)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
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 15:55:46 +02:00
|
|
|
struct pt_regs *old_regs = set_irq_regs(regs);
|
2006-10-13 05:25:03 +02:00
|
|
|
ack_QIC_CPI(QIC_TIMER_CPI);
|
|
|
|
wrapper_smp_local_timer_interrupt();
|
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 15:55:46 +02:00
|
|
|
set_irq_regs(old_regs);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2008-01-30 13:31:17 +01:00
|
|
|
void smp_qic_invalidate_interrupt(struct pt_regs *regs)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
ack_QIC_CPI(QIC_INVALIDATE_CPI);
|
|
|
|
smp_invalidate_interrupt();
|
|
|
|
}
|
|
|
|
|
2008-01-30 13:31:17 +01:00
|
|
|
void smp_qic_reschedule_interrupt(struct pt_regs *regs)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
ack_QIC_CPI(QIC_RESCHEDULE_CPI);
|
|
|
|
smp_reschedule_interrupt();
|
|
|
|
}
|
|
|
|
|
2008-01-30 13:31:17 +01:00
|
|
|
void smp_qic_enable_irq_interrupt(struct pt_regs *regs)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
ack_QIC_CPI(QIC_ENABLE_IRQ_CPI);
|
|
|
|
smp_enable_irq_interrupt();
|
|
|
|
}
|
|
|
|
|
2008-01-30 13:31:17 +01:00
|
|
|
void smp_qic_call_function_interrupt(struct pt_regs *regs)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
ack_QIC_CPI(QIC_CALL_FUNCTION_CPI);
|
|
|
|
smp_call_function_interrupt();
|
|
|
|
}
|
|
|
|
|
2008-06-26 11:21:54 +02:00
|
|
|
void smp_qic_call_function_single_interrupt(struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
ack_QIC_CPI(QIC_CALL_FUNCTION_SINGLE_CPI);
|
|
|
|
smp_call_function_single_interrupt();
|
|
|
|
}
|
|
|
|
|
2008-01-30 13:31:17 +01:00
|
|
|
void smp_vic_cpi_interrupt(struct pt_regs *regs)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
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 15:55:46 +02:00
|
|
|
struct pt_regs *old_regs = set_irq_regs(regs);
|
2005-04-17 00:20:36 +02:00
|
|
|
__u8 cpu = smp_processor_id();
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
if (is_cpu_quad())
|
2005-04-17 00:20:36 +02:00
|
|
|
ack_QIC_CPI(VIC_CPI_LEVEL0);
|
|
|
|
else
|
|
|
|
ack_VIC_CPI(VIC_CPI_LEVEL0);
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
if (test_and_clear_bit(VIC_TIMER_CPI, &vic_cpi_mailbox[cpu]))
|
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 15:55:46 +02:00
|
|
|
wrapper_smp_local_timer_interrupt();
|
2008-01-30 13:30:10 +01:00
|
|
|
if (test_and_clear_bit(VIC_INVALIDATE_CPI, &vic_cpi_mailbox[cpu]))
|
2005-04-17 00:20:36 +02:00
|
|
|
smp_invalidate_interrupt();
|
2008-01-30 13:30:10 +01:00
|
|
|
if (test_and_clear_bit(VIC_RESCHEDULE_CPI, &vic_cpi_mailbox[cpu]))
|
2005-04-17 00:20:36 +02:00
|
|
|
smp_reschedule_interrupt();
|
2008-01-30 13:30:10 +01:00
|
|
|
if (test_and_clear_bit(VIC_ENABLE_IRQ_CPI, &vic_cpi_mailbox[cpu]))
|
2005-04-17 00:20:36 +02:00
|
|
|
smp_enable_irq_interrupt();
|
2008-01-30 13:30:10 +01:00
|
|
|
if (test_and_clear_bit(VIC_CALL_FUNCTION_CPI, &vic_cpi_mailbox[cpu]))
|
2005-04-17 00:20:36 +02:00
|
|
|
smp_call_function_interrupt();
|
2008-06-26 11:21:54 +02:00
|
|
|
if (test_and_clear_bit(VIC_CALL_FUNCTION_SINGLE_CPI, &vic_cpi_mailbox[cpu]))
|
|
|
|
smp_call_function_single_interrupt();
|
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 15:55:46 +02:00
|
|
|
set_irq_regs(old_regs);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
static void do_flush_tlb_all(void *info)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
unsigned long cpu = smp_processor_id();
|
|
|
|
|
|
|
|
__flush_tlb_all();
|
|
|
|
if (per_cpu(cpu_tlbstate, cpu).state == TLBSTATE_LAZY)
|
2008-01-30 13:32:55 +01:00
|
|
|
voyager_leave_mm(cpu);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* flush the TLB of every active CPU in the system */
|
2008-01-30 13:30:10 +01:00
|
|
|
void flush_tlb_all(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2008-05-09 09:39:44 +02:00
|
|
|
on_each_cpu(do_flush_tlb_all, 0, 1);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* send a reschedule CPI to one CPU by physical CPU number*/
|
2008-01-30 13:30:10 +01:00
|
|
|
static void voyager_smp_send_reschedule(int cpu)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
send_one_CPI(cpu, VIC_RESCHEDULE_CPI);
|
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
int hard_smp_processor_id(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
__u8 i;
|
|
|
|
__u8 cpumask = inb(VIC_PROC_WHO_AM_I);
|
2008-01-30 13:30:10 +01:00
|
|
|
if ((cpumask & QUAD_IDENTIFIER) == QUAD_IDENTIFIER)
|
2005-04-17 00:20:36 +02:00
|
|
|
return cpumask & 0x1F;
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
if (cpumask & (1 << i))
|
2005-04-17 00:20:36 +02:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
printk("** WARNING ** Illegal cpuid returned by VIC: %d", cpumask);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
int safe_smp_processor_id(void)
|
2006-10-01 08:29:08 +02:00
|
|
|
{
|
|
|
|
return hard_smp_processor_id();
|
|
|
|
}
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* broadcast a halt to all other CPUs */
|
2008-01-30 13:30:10 +01:00
|
|
|
static void voyager_smp_send_stop(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2008-06-06 11:18:06 +02:00
|
|
|
smp_call_function(smp_stop_cpu_function, NULL, 1);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* this function is triggered in time.c when a clock tick fires
|
|
|
|
* we need to re-broadcast the tick to all CPUs */
|
2008-01-30 13:30:10 +01:00
|
|
|
void smp_vic_timer_interrupt(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
send_CPI_allbutself(VIC_TIMER_CPI);
|
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 15:55:46 +02:00
|
|
|
smp_local_timer_interrupt();
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* local (per CPU) timer interrupt. It does both profiling and
|
|
|
|
* process statistics/rescheduling.
|
|
|
|
*
|
|
|
|
* We do profiling in every local tick, statistics/rescheduling
|
|
|
|
* happen only every 'profiling multiplier' ticks. The default
|
|
|
|
* multiplier is 1 and it can be changed by writing the new multiplier
|
|
|
|
* value into /proc/profile.
|
|
|
|
*/
|
2008-01-30 13:30:10 +01:00
|
|
|
void smp_local_timer_interrupt(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
int cpu = smp_processor_id();
|
|
|
|
long weight;
|
|
|
|
|
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 15:55:46 +02:00
|
|
|
profile_tick(CPU_PROFILING);
|
2005-04-17 00:20:36 +02:00
|
|
|
if (--per_cpu(prof_counter, cpu) <= 0) {
|
|
|
|
/*
|
|
|
|
* The multiplier may have changed since the last time we got
|
|
|
|
* to this point as a result of the user writing to
|
|
|
|
* /proc/profile. In this case we need to adjust the APIC
|
|
|
|
* timer accordingly.
|
|
|
|
*
|
|
|
|
* Interrupts are already masked off at this point.
|
|
|
|
*/
|
2008-01-30 13:30:10 +01:00
|
|
|
per_cpu(prof_counter, cpu) = per_cpu(prof_multiplier, cpu);
|
2005-04-17 00:20:36 +02:00
|
|
|
if (per_cpu(prof_counter, cpu) !=
|
2008-01-30 13:30:10 +01:00
|
|
|
per_cpu(prof_old_multiplier, cpu)) {
|
2005-04-17 00:20:36 +02:00
|
|
|
/* FIXME: need to update the vic timer tick here */
|
|
|
|
per_cpu(prof_old_multiplier, cpu) =
|
2008-01-30 13:30:10 +01:00
|
|
|
per_cpu(prof_counter, cpu);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2006-10-13 05:25:03 +02:00
|
|
|
update_process_times(user_mode_vm(get_irq_regs()));
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
if (((1 << cpu) & voyager_extended_vic_processors) == 0)
|
2005-04-17 00:20:36 +02:00
|
|
|
/* only extended VIC processors participate in
|
|
|
|
* interrupt distribution */
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We take the 'long' return path, and there every subsystem
|
2007-10-20 01:13:56 +02:00
|
|
|
* grabs the appropriate locks (kernel lock/ irq lock).
|
2005-04-17 00:20:36 +02:00
|
|
|
*
|
|
|
|
* we might want to decouple profiling from the 'long path',
|
|
|
|
* and do the profiling totally in assembly.
|
|
|
|
*
|
|
|
|
* Currently this isn't too much of an issue (performance wise),
|
|
|
|
* we can take more than 100K local irqs per second on a 100 MHz P5.
|
|
|
|
*/
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
if ((++vic_tick[cpu] & 0x7) != 0)
|
2005-04-17 00:20:36 +02:00
|
|
|
return;
|
|
|
|
/* get here every 16 ticks (about every 1/6 of a second) */
|
|
|
|
|
|
|
|
/* Change our priority to give someone else a chance at getting
|
2008-01-30 13:30:10 +01:00
|
|
|
* the IRQ. The algorithm goes like this:
|
2005-04-17 00:20:36 +02:00
|
|
|
*
|
|
|
|
* In the VIC, the dynamically routed interrupt is always
|
|
|
|
* handled by the lowest priority eligible (i.e. receiving
|
|
|
|
* interrupts) CPU. If >1 eligible CPUs are equal lowest, the
|
|
|
|
* lowest processor number gets it.
|
|
|
|
*
|
|
|
|
* The priority of a CPU is controlled by a special per-CPU
|
|
|
|
* VIC priority register which is 3 bits wide 0 being lowest
|
|
|
|
* and 7 highest priority..
|
|
|
|
*
|
|
|
|
* Therefore we subtract the average number of interrupts from
|
|
|
|
* the number we've fielded. If this number is negative, we
|
|
|
|
* lower the activity count and if it is positive, we raise
|
|
|
|
* it.
|
|
|
|
*
|
|
|
|
* I'm afraid this still leads to odd looking interrupt counts:
|
|
|
|
* the totals are all roughly equal, but the individual ones
|
|
|
|
* look rather skewed.
|
|
|
|
*
|
|
|
|
* FIXME: This algorithm is total crap when mixed with SMP
|
|
|
|
* affinity code since we now try to even up the interrupt
|
|
|
|
* counts when an affinity binding is keeping them on a
|
|
|
|
* particular CPU*/
|
2008-01-30 13:30:10 +01:00
|
|
|
weight = (vic_intr_count[cpu] * voyager_extended_cpus
|
2005-04-17 00:20:36 +02:00
|
|
|
- vic_intr_total) >> 4;
|
|
|
|
weight += 4;
|
2008-01-30 13:30:10 +01:00
|
|
|
if (weight > 7)
|
2005-04-17 00:20:36 +02:00
|
|
|
weight = 7;
|
2008-01-30 13:30:10 +01:00
|
|
|
if (weight < 0)
|
2005-04-17 00:20:36 +02:00
|
|
|
weight = 0;
|
2008-01-30 13:30:10 +01:00
|
|
|
|
|
|
|
outb((__u8) weight, VIC_PRIORITY_REGISTER);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
#ifdef VOYAGER_DEBUG
|
2008-01-30 13:30:10 +01:00
|
|
|
if ((vic_tick[cpu] & 0xFFF) == 0) {
|
2005-04-17 00:20:36 +02:00
|
|
|
/* print this message roughly every 25 secs */
|
|
|
|
printk("VOYAGER SMP: vic_tick[%d] = %lu, weight = %ld\n",
|
|
|
|
cpu, vic_tick[cpu], weight);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* setup the profiling timer */
|
2008-01-30 13:30:10 +01:00
|
|
|
int setup_profiling_timer(unsigned int multiplier)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
if ((!multiplier))
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EINVAL;
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
/*
|
2005-04-17 00:20:36 +02:00
|
|
|
* Set the new multiplier for each CPU. CPUs don't start using the
|
|
|
|
* new values until the next timer interrupt in which they do process
|
|
|
|
* accounting.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < NR_CPUS; ++i)
|
|
|
|
per_cpu(prof_multiplier, i) = multiplier;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-10-13 05:21:16 +02:00
|
|
|
/* This is a bit of a mess, but forced on us by the genirq changes
|
|
|
|
* there's no genirq handler that really does what voyager wants
|
|
|
|
* so hack it up with the simple IRQ handler */
|
2008-01-30 13:31:17 +01:00
|
|
|
static void handle_vic_irq(unsigned int irq, struct irq_desc *desc)
|
2006-10-13 05:21:16 +02:00
|
|
|
{
|
|
|
|
before_handle_vic_irq(irq);
|
|
|
|
handle_simple_irq(irq, desc);
|
|
|
|
after_handle_vic_irq(irq);
|
|
|
|
}
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* The CPIs are handled in the per cpu 8259s, so they must be
|
|
|
|
* enabled to be received: FIX: enabling the CPIs in the early
|
|
|
|
* boot sequence interferes with bug checking; enable them later
|
|
|
|
* on in smp_init */
|
|
|
|
#define VIC_SET_GATE(cpi, vector) \
|
|
|
|
set_intr_gate((cpi) + VIC_DEFAULT_CPI_BASE, (vector))
|
|
|
|
#define QIC_SET_GATE(cpi, vector) \
|
|
|
|
set_intr_gate((cpi) + QIC_DEFAULT_CPI_BASE, (vector))
|
|
|
|
|
2008-10-31 18:59:49 +01:00
|
|
|
void __init voyager_smp_intr_init(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* initialize the per cpu irq mask to all disabled */
|
2008-01-30 13:30:10 +01:00
|
|
|
for (i = 0; i < NR_CPUS; i++)
|
2005-04-17 00:20:36 +02:00
|
|
|
vic_irq_mask[i] = 0xFFFF;
|
|
|
|
|
|
|
|
VIC_SET_GATE(VIC_CPI_LEVEL0, vic_cpi_interrupt);
|
|
|
|
|
|
|
|
VIC_SET_GATE(VIC_SYS_INT, vic_sys_interrupt);
|
|
|
|
VIC_SET_GATE(VIC_CMN_INT, vic_cmn_interrupt);
|
|
|
|
|
|
|
|
QIC_SET_GATE(QIC_TIMER_CPI, qic_timer_interrupt);
|
|
|
|
QIC_SET_GATE(QIC_INVALIDATE_CPI, qic_invalidate_interrupt);
|
|
|
|
QIC_SET_GATE(QIC_RESCHEDULE_CPI, qic_reschedule_interrupt);
|
|
|
|
QIC_SET_GATE(QIC_ENABLE_IRQ_CPI, qic_enable_irq_interrupt);
|
|
|
|
QIC_SET_GATE(QIC_CALL_FUNCTION_CPI, qic_call_function_interrupt);
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
/* now put the VIC descriptor into the first 48 IRQs
|
2005-04-17 00:20:36 +02:00
|
|
|
*
|
|
|
|
* This is for later: first 16 correspond to PC IRQs; next 16
|
|
|
|
* are Primary MC IRQs and final 16 are Secondary MC IRQs */
|
2008-01-30 13:30:10 +01:00
|
|
|
for (i = 0; i < 48; i++)
|
2006-10-13 05:21:16 +02:00
|
|
|
set_irq_chip_and_handler(i, &vic_chip, handle_vic_irq);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* send a CPI at level cpi to a set of cpus in cpuset (set 1 bit per
|
|
|
|
* processor to receive CPI */
|
2008-01-30 13:30:10 +01:00
|
|
|
static void send_CPI(__u32 cpuset, __u8 cpi)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
int cpu;
|
|
|
|
__u32 quad_cpuset = (cpuset & voyager_quad_processors);
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
if (cpi < VIC_START_FAKE_CPI) {
|
|
|
|
/* fake CPI are only used for booting, so send to the
|
2005-04-17 00:20:36 +02:00
|
|
|
* extended quads as well---Quads must be VIC booted */
|
2008-01-30 13:30:10 +01:00
|
|
|
outb((__u8) (cpuset), VIC_CPI_Registers[cpi]);
|
2005-04-17 00:20:36 +02:00
|
|
|
return;
|
|
|
|
}
|
2008-01-30 13:30:10 +01:00
|
|
|
if (quad_cpuset)
|
2005-04-17 00:20:36 +02:00
|
|
|
send_QIC_CPI(quad_cpuset, cpi);
|
|
|
|
cpuset &= ~quad_cpuset;
|
|
|
|
cpuset &= 0xff; /* only first 8 CPUs vaild for VIC CPI */
|
2008-01-30 13:30:10 +01:00
|
|
|
if (cpuset == 0)
|
2005-04-17 00:20:36 +02:00
|
|
|
return;
|
|
|
|
for_each_online_cpu(cpu) {
|
2008-01-30 13:30:10 +01:00
|
|
|
if (cpuset & (1 << cpu))
|
2005-04-17 00:20:36 +02:00
|
|
|
set_bit(cpi, &vic_cpi_mailbox[cpu]);
|
|
|
|
}
|
2008-01-30 13:30:10 +01:00
|
|
|
if (cpuset)
|
|
|
|
outb((__u8) cpuset, VIC_CPI_Registers[VIC_CPI_LEVEL0]);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Acknowledge receipt of CPI in the QIC, clear in QIC hardware and
|
|
|
|
* set the cache line to shared by reading it.
|
|
|
|
*
|
|
|
|
* DON'T make this inline otherwise the cache line read will be
|
|
|
|
* optimised away
|
|
|
|
* */
|
2008-01-30 13:30:10 +01:00
|
|
|
static int ack_QIC_CPI(__u8 cpi)
|
|
|
|
{
|
2005-04-17 00:20:36 +02:00
|
|
|
__u8 cpu = hard_smp_processor_id();
|
|
|
|
|
|
|
|
cpi &= 7;
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
outb(1 << cpi, QIC_INTERRUPT_CLEAR1);
|
2005-04-17 00:20:36 +02:00
|
|
|
return voyager_quad_cpi_addr[cpu]->qic_cpi[cpi].cpi;
|
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
static void ack_special_QIC_CPI(__u8 cpi)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2008-01-30 13:30:10 +01:00
|
|
|
switch (cpi) {
|
2005-04-17 00:20:36 +02:00
|
|
|
case VIC_CMN_INT:
|
|
|
|
outb(QIC_CMN_INT, QIC_INTERRUPT_CLEAR0);
|
|
|
|
break;
|
|
|
|
case VIC_SYS_INT:
|
|
|
|
outb(QIC_SYS_INT, QIC_INTERRUPT_CLEAR0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* also clear at the VIC, just in case (nop for non-extended proc) */
|
|
|
|
ack_VIC_CPI(cpi);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Acknowledge receipt of CPI in the VIC (essentially an EOI) */
|
2008-01-30 13:30:10 +01:00
|
|
|
static void ack_VIC_CPI(__u8 cpi)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
#ifdef VOYAGER_DEBUG
|
|
|
|
unsigned long flags;
|
|
|
|
__u16 isr;
|
|
|
|
__u8 cpu = smp_processor_id();
|
|
|
|
|
|
|
|
local_irq_save(flags);
|
|
|
|
isr = vic_read_isr();
|
2008-01-30 13:30:10 +01:00
|
|
|
if ((isr & (1 << (cpi & 7))) == 0) {
|
2005-04-17 00:20:36 +02:00
|
|
|
printk("VOYAGER SMP: CPU%d lost CPI%d\n", cpu, cpi);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
/* send specific EOI; the two system interrupts have
|
|
|
|
* bit 4 set for a separate vector but behave as the
|
|
|
|
* corresponding 3 bit intr */
|
2008-01-30 13:30:10 +01:00
|
|
|
outb_p(0x60 | (cpi & 7), 0x20);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
#ifdef VOYAGER_DEBUG
|
2008-01-30 13:30:10 +01:00
|
|
|
if ((vic_read_isr() & (1 << (cpi & 7))) != 0) {
|
2005-04-17 00:20:36 +02:00
|
|
|
printk("VOYAGER SMP: CPU%d still asserting CPI%d\n", cpu, cpi);
|
|
|
|
}
|
|
|
|
local_irq_restore(flags);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cribbed with thanks from irq.c */
|
2008-01-30 13:30:10 +01:00
|
|
|
#define __byte(x,y) (((unsigned char *)&(y))[x])
|
2005-04-17 00:20:36 +02:00
|
|
|
#define cached_21(cpu) (__byte(0,vic_irq_mask[cpu]))
|
|
|
|
#define cached_A1(cpu) (__byte(1,vic_irq_mask[cpu]))
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
static unsigned int startup_vic_irq(unsigned int irq)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2006-10-13 05:21:16 +02:00
|
|
|
unmask_vic_irq(irq);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The enable and disable routines. This is where we run into
|
|
|
|
* conflicting architectural philosophy. Fundamentally, the voyager
|
|
|
|
* architecture does not expect to have to disable interrupts globally
|
|
|
|
* (the IRQ controllers belong to each CPU). The processor masquerade
|
|
|
|
* which is used to start the system shouldn't be used in a running OS
|
|
|
|
* since it will cause great confusion if two separate CPUs drive to
|
|
|
|
* the same IRQ controller (I know, I've tried it).
|
|
|
|
*
|
|
|
|
* The solution is a variant on the NCR lazy SPL design:
|
|
|
|
*
|
|
|
|
* 1) To disable an interrupt, do nothing (other than set the
|
|
|
|
* IRQ_DISABLED flag). This dares the interrupt actually to arrive.
|
|
|
|
*
|
|
|
|
* 2) If the interrupt dares to come in, raise the local mask against
|
|
|
|
* it (this will result in all the CPU masks being raised
|
|
|
|
* eventually).
|
|
|
|
*
|
|
|
|
* 3) To enable the interrupt, lower the mask on the local CPU and
|
|
|
|
* broadcast an Interrupt enable CPI which causes all other CPUs to
|
|
|
|
* adjust their masks accordingly. */
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
static void unmask_vic_irq(unsigned int irq)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
/* linux doesn't to processor-irq affinity, so enable on
|
|
|
|
* all CPUs we know about */
|
|
|
|
int cpu = smp_processor_id(), real_cpu;
|
2008-01-30 13:30:10 +01:00
|
|
|
__u16 mask = (1 << irq);
|
2005-04-17 00:20:36 +02:00
|
|
|
__u32 processorList = 0;
|
|
|
|
unsigned long flags;
|
|
|
|
|
2006-10-13 05:21:16 +02:00
|
|
|
VDEBUG(("VOYAGER: unmask_vic_irq(%d) CPU%d affinity 0x%lx\n",
|
2005-04-17 00:20:36 +02:00
|
|
|
irq, cpu, cpu_irq_affinity[cpu]));
|
|
|
|
spin_lock_irqsave(&vic_irq_lock, flags);
|
|
|
|
for_each_online_cpu(real_cpu) {
|
2008-01-30 13:30:10 +01:00
|
|
|
if (!(voyager_extended_vic_processors & (1 << real_cpu)))
|
2005-04-17 00:20:36 +02:00
|
|
|
continue;
|
2008-01-30 13:30:10 +01:00
|
|
|
if (!(cpu_irq_affinity[real_cpu] & mask)) {
|
2005-04-17 00:20:36 +02:00
|
|
|
/* irq has no affinity for this CPU, ignore */
|
|
|
|
continue;
|
|
|
|
}
|
2008-01-30 13:30:10 +01:00
|
|
|
if (real_cpu == cpu) {
|
2005-04-17 00:20:36 +02:00
|
|
|
enable_local_vic_irq(irq);
|
2008-01-30 13:30:10 +01:00
|
|
|
} else if (vic_irq_mask[real_cpu] & mask) {
|
2005-04-17 00:20:36 +02:00
|
|
|
vic_irq_enable_mask[real_cpu] |= mask;
|
2008-01-30 13:30:10 +01:00
|
|
|
processorList |= (1 << real_cpu);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&vic_irq_lock, flags);
|
2008-01-30 13:30:10 +01:00
|
|
|
if (processorList)
|
2005-04-17 00:20:36 +02:00
|
|
|
send_CPI(processorList, VIC_ENABLE_IRQ_CPI);
|
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
static void mask_vic_irq(unsigned int irq)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
/* lazy disable, do nothing */
|
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
static void enable_local_vic_irq(unsigned int irq)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
__u8 cpu = smp_processor_id();
|
|
|
|
__u16 mask = ~(1 << irq);
|
|
|
|
__u16 old_mask = vic_irq_mask[cpu];
|
|
|
|
|
|
|
|
vic_irq_mask[cpu] &= mask;
|
2008-01-30 13:30:10 +01:00
|
|
|
if (vic_irq_mask[cpu] == old_mask)
|
2005-04-17 00:20:36 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
VDEBUG(("VOYAGER DEBUG: Enabling irq %d in hardware on CPU %d\n",
|
|
|
|
irq, cpu));
|
|
|
|
|
|
|
|
if (irq & 8) {
|
2008-01-30 13:30:10 +01:00
|
|
|
outb_p(cached_A1(cpu), 0xA1);
|
2005-04-17 00:20:36 +02:00
|
|
|
(void)inb_p(0xA1);
|
2008-01-30 13:30:10 +01:00
|
|
|
} else {
|
|
|
|
outb_p(cached_21(cpu), 0x21);
|
2005-04-17 00:20:36 +02:00
|
|
|
(void)inb_p(0x21);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
static void disable_local_vic_irq(unsigned int irq)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
__u8 cpu = smp_processor_id();
|
|
|
|
__u16 mask = (1 << irq);
|
|
|
|
__u16 old_mask = vic_irq_mask[cpu];
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
if (irq == 7)
|
2005-04-17 00:20:36 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
vic_irq_mask[cpu] |= mask;
|
2008-01-30 13:30:10 +01:00
|
|
|
if (old_mask == vic_irq_mask[cpu])
|
2005-04-17 00:20:36 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
VDEBUG(("VOYAGER DEBUG: Disabling irq %d in hardware on CPU %d\n",
|
|
|
|
irq, cpu));
|
|
|
|
|
|
|
|
if (irq & 8) {
|
2008-01-30 13:30:10 +01:00
|
|
|
outb_p(cached_A1(cpu), 0xA1);
|
2005-04-17 00:20:36 +02:00
|
|
|
(void)inb_p(0xA1);
|
2008-01-30 13:30:10 +01:00
|
|
|
} else {
|
|
|
|
outb_p(cached_21(cpu), 0x21);
|
2005-04-17 00:20:36 +02:00
|
|
|
(void)inb_p(0x21);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The VIC is level triggered, so the ack can only be issued after the
|
|
|
|
* interrupt completes. However, we do Voyager lazy interrupt
|
|
|
|
* handling here: It is an extremely expensive operation to mask an
|
|
|
|
* interrupt in the vic, so we merely set a flag (IRQ_DISABLED). If
|
|
|
|
* this interrupt actually comes in, then we mask and ack here to push
|
|
|
|
* the interrupt off to another CPU */
|
2008-01-30 13:30:10 +01:00
|
|
|
static void before_handle_vic_irq(unsigned int irq)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2008-08-20 05:50:05 +02:00
|
|
|
irq_desc_t *desc = irq_to_desc(irq);
|
2005-04-17 00:20:36 +02:00
|
|
|
__u8 cpu = smp_processor_id();
|
|
|
|
|
|
|
|
_raw_spin_lock(&vic_irq_lock);
|
|
|
|
vic_intr_total++;
|
|
|
|
vic_intr_count[cpu]++;
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
if (!(cpu_irq_affinity[cpu] & (1 << irq))) {
|
2005-04-17 00:20:36 +02:00
|
|
|
/* The irq is not in our affinity mask, push it off
|
|
|
|
* onto another CPU */
|
2008-01-30 13:30:10 +01:00
|
|
|
VDEBUG(("VOYAGER DEBUG: affinity triggered disable of irq %d "
|
|
|
|
"on cpu %d\n", irq, cpu));
|
2005-04-17 00:20:36 +02:00
|
|
|
disable_local_vic_irq(irq);
|
|
|
|
/* set IRQ_INPROGRESS to prevent the handler in irq.c from
|
|
|
|
* actually calling the interrupt routine */
|
|
|
|
desc->status |= IRQ_REPLAY | IRQ_INPROGRESS;
|
2008-01-30 13:30:10 +01:00
|
|
|
} else if (desc->status & IRQ_DISABLED) {
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Damn, the interrupt actually arrived, do the lazy
|
|
|
|
* disable thing. The interrupt routine in irq.c will
|
|
|
|
* not handle a IRQ_DISABLED interrupt, so nothing more
|
|
|
|
* need be done here */
|
|
|
|
VDEBUG(("VOYAGER DEBUG: lazy disable of irq %d on CPU %d\n",
|
|
|
|
irq, cpu));
|
|
|
|
disable_local_vic_irq(irq);
|
|
|
|
desc->status |= IRQ_REPLAY;
|
|
|
|
} else {
|
|
|
|
desc->status &= ~IRQ_REPLAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
_raw_spin_unlock(&vic_irq_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Finish the VIC interrupt: basically mask */
|
2008-01-30 13:30:10 +01:00
|
|
|
static void after_handle_vic_irq(unsigned int irq)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2008-08-20 05:50:05 +02:00
|
|
|
irq_desc_t *desc = irq_to_desc(irq);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
_raw_spin_lock(&vic_irq_lock);
|
|
|
|
{
|
|
|
|
unsigned int status = desc->status & ~IRQ_INPROGRESS;
|
|
|
|
#ifdef VOYAGER_DEBUG
|
|
|
|
__u16 isr;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
desc->status = status;
|
|
|
|
if ((status & IRQ_DISABLED))
|
|
|
|
disable_local_vic_irq(irq);
|
|
|
|
#ifdef VOYAGER_DEBUG
|
|
|
|
/* DEBUG: before we ack, check what's in progress */
|
|
|
|
isr = vic_read_isr();
|
2008-01-30 13:30:10 +01:00
|
|
|
if ((isr & (1 << irq) && !(status & IRQ_REPLAY)) == 0) {
|
2005-04-17 00:20:36 +02:00
|
|
|
int i;
|
|
|
|
__u8 cpu = smp_processor_id();
|
|
|
|
__u8 real_cpu;
|
2008-01-30 13:30:10 +01:00
|
|
|
int mask; /* Um... initialize me??? --RR */
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
printk("VOYAGER SMP: CPU%d lost interrupt %d\n",
|
|
|
|
cpu, irq);
|
2006-03-28 11:56:39 +02:00
|
|
|
for_each_possible_cpu(real_cpu, mask) {
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
outb(VIC_CPU_MASQUERADE_ENABLE | real_cpu,
|
|
|
|
VIC_PROCESSOR_ID);
|
|
|
|
isr = vic_read_isr();
|
2008-01-30 13:30:10 +01:00
|
|
|
if (isr & (1 << irq)) {
|
|
|
|
printk
|
|
|
|
("VOYAGER SMP: CPU%d ack irq %d\n",
|
|
|
|
real_cpu, irq);
|
2005-04-17 00:20:36 +02:00
|
|
|
ack_vic_irq(irq);
|
|
|
|
}
|
|
|
|
outb(cpu, VIC_PROCESSOR_ID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* VOYAGER_DEBUG */
|
|
|
|
/* as soon as we ack, the interrupt is eligible for
|
|
|
|
* receipt by another CPU so everything must be in
|
|
|
|
* order here */
|
|
|
|
ack_vic_irq(irq);
|
2008-01-30 13:30:10 +01:00
|
|
|
if (status & IRQ_REPLAY) {
|
2005-04-17 00:20:36 +02:00
|
|
|
/* replay is set if we disable the interrupt
|
|
|
|
* in the before_handle_vic_irq() routine, so
|
|
|
|
* clear the in progress bit here to allow the
|
|
|
|
* next CPU to handle this correctly */
|
|
|
|
desc->status &= ~(IRQ_REPLAY | IRQ_INPROGRESS);
|
|
|
|
}
|
|
|
|
#ifdef VOYAGER_DEBUG
|
|
|
|
isr = vic_read_isr();
|
2008-01-30 13:30:10 +01:00
|
|
|
if ((isr & (1 << irq)) != 0)
|
|
|
|
printk("VOYAGER SMP: after_handle_vic_irq() after "
|
|
|
|
"ack irq=%d, isr=0x%x\n", irq, isr);
|
2005-04-17 00:20:36 +02:00
|
|
|
#endif /* VOYAGER_DEBUG */
|
|
|
|
}
|
|
|
|
_raw_spin_unlock(&vic_irq_lock);
|
|
|
|
|
|
|
|
/* All code after this point is out of the main path - the IRQ
|
|
|
|
* may be intercepted by another CPU if reasserted */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Linux processor - interrupt affinity manipulations.
|
|
|
|
*
|
|
|
|
* For each processor, we maintain a 32 bit irq affinity mask.
|
|
|
|
* Initially it is set to all 1's so every processor accepts every
|
|
|
|
* interrupt. In this call, we change the processor's affinity mask:
|
|
|
|
*
|
|
|
|
* Change from enable to disable:
|
|
|
|
*
|
|
|
|
* If the interrupt ever comes in to the processor, we will disable it
|
|
|
|
* and ack it to push it off to another CPU, so just accept the mask here.
|
|
|
|
*
|
|
|
|
* Change from disable to enable:
|
|
|
|
*
|
|
|
|
* change the mask and then do an interrupt enable CPI to re-enable on
|
|
|
|
* the selected processors */
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
void set_vic_irq_affinity(unsigned int irq, cpumask_t mask)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
/* Only extended processors handle interrupts */
|
|
|
|
unsigned long real_mask;
|
|
|
|
unsigned long irq_mask = 1 << irq;
|
|
|
|
int cpu;
|
|
|
|
|
|
|
|
real_mask = cpus_addr(mask)[0] & voyager_extended_vic_processors;
|
2008-01-30 13:30:10 +01:00
|
|
|
|
|
|
|
if (cpus_addr(mask)[0] == 0)
|
2007-10-20 01:13:56 +02:00
|
|
|
/* can't have no CPUs to accept the interrupt -- extremely
|
2005-04-17 00:20:36 +02:00
|
|
|
* bad things will happen */
|
|
|
|
return;
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
if (irq == 0)
|
2005-04-17 00:20:36 +02:00
|
|
|
/* can't change the affinity of the timer IRQ. This
|
|
|
|
* is due to the constraint in the voyager
|
|
|
|
* architecture that the CPI also comes in on and IRQ
|
|
|
|
* line and we have chosen IRQ0 for this. If you
|
|
|
|
* raise the mask on this interrupt, the processor
|
|
|
|
* will no-longer be able to accept VIC CPIs */
|
|
|
|
return;
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
if (irq >= 32)
|
2005-04-17 00:20:36 +02:00
|
|
|
/* You can only have 32 interrupts in a voyager system
|
|
|
|
* (and 32 only if you have a secondary microchannel
|
|
|
|
* bus) */
|
|
|
|
return;
|
|
|
|
|
|
|
|
for_each_online_cpu(cpu) {
|
|
|
|
unsigned long cpu_mask = 1 << cpu;
|
2008-01-30 13:30:10 +01:00
|
|
|
|
|
|
|
if (cpu_mask & real_mask) {
|
2005-04-17 00:20:36 +02:00
|
|
|
/* enable the interrupt for this cpu */
|
|
|
|
cpu_irq_affinity[cpu] |= irq_mask;
|
|
|
|
} else {
|
|
|
|
/* disable the interrupt for this cpu */
|
|
|
|
cpu_irq_affinity[cpu] &= ~irq_mask;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* this is magic, we now have the correct affinity maps, so
|
|
|
|
* enable the interrupt. This will send an enable CPI to
|
2007-10-20 01:13:56 +02:00
|
|
|
* those CPUs who need to enable it in their local masks,
|
2005-04-17 00:20:36 +02:00
|
|
|
* causing them to correct for the new affinity . If the
|
|
|
|
* interrupt is currently globally disabled, it will simply be
|
|
|
|
* disabled again as it comes in (voyager lazy disable). If
|
|
|
|
* the affinity map is tightened to disable the interrupt on a
|
|
|
|
* cpu, it will be pushed off when it comes in */
|
2006-10-13 05:21:16 +02:00
|
|
|
unmask_vic_irq(irq);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
static void ack_vic_irq(unsigned int irq)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
if (irq & 8) {
|
2008-01-30 13:30:10 +01:00
|
|
|
outb(0x62, 0x20); /* Specific EOI to cascade */
|
|
|
|
outb(0x60 | (irq & 7), 0xA0);
|
2005-04-17 00:20:36 +02:00
|
|
|
} else {
|
2008-01-30 13:30:10 +01:00
|
|
|
outb(0x60 | (irq & 7), 0x20);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* enable the CPIs. In the VIC, the CPIs are delivered by the 8259
|
|
|
|
* but are not vectored by it. This means that the 8259 mask must be
|
|
|
|
* lowered to receive them */
|
2008-01-30 13:30:10 +01:00
|
|
|
static __init void vic_enable_cpi(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
__u8 cpu = smp_processor_id();
|
2008-01-30 13:30:10 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* just take a copy of the current mask (nop for boot cpu) */
|
|
|
|
vic_irq_mask[cpu] = vic_irq_mask[boot_cpu_id];
|
|
|
|
|
|
|
|
enable_local_vic_irq(VIC_CPI_LEVEL0);
|
|
|
|
enable_local_vic_irq(VIC_CPI_LEVEL1);
|
|
|
|
/* for sys int and cmn int */
|
|
|
|
enable_local_vic_irq(7);
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
if (is_cpu_quad()) {
|
2005-04-17 00:20:36 +02:00
|
|
|
outb(QIC_DEFAULT_MASK0, QIC_MASK_REGISTER0);
|
|
|
|
outb(QIC_CPI_ENABLE, QIC_MASK_REGISTER1);
|
|
|
|
VDEBUG(("VOYAGER SMP: QIC ENABLE CPI: CPU%d: MASK 0x%x\n",
|
|
|
|
cpu, QIC_CPI_ENABLE));
|
|
|
|
}
|
|
|
|
|
|
|
|
VDEBUG(("VOYAGER SMP: ENABLE CPI: CPU%d: MASK 0x%x\n",
|
|
|
|
cpu, vic_irq_mask[cpu]));
|
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
void voyager_smp_dump()
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
int old_cpu = smp_processor_id(), cpu;
|
|
|
|
|
|
|
|
/* dump the interrupt masks of each processor */
|
|
|
|
for_each_online_cpu(cpu) {
|
|
|
|
__u16 imr, isr, irr;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
local_irq_save(flags);
|
|
|
|
outb(VIC_CPU_MASQUERADE_ENABLE | cpu, VIC_PROCESSOR_ID);
|
|
|
|
imr = (inb(0xa1) << 8) | inb(0x21);
|
|
|
|
outb(0x0a, 0xa0);
|
|
|
|
irr = inb(0xa0) << 8;
|
|
|
|
outb(0x0a, 0x20);
|
|
|
|
irr |= inb(0x20);
|
|
|
|
outb(0x0b, 0xa0);
|
|
|
|
isr = inb(0xa0) << 8;
|
|
|
|
outb(0x0b, 0x20);
|
|
|
|
isr |= inb(0x20);
|
|
|
|
outb(old_cpu, VIC_PROCESSOR_ID);
|
|
|
|
local_irq_restore(flags);
|
|
|
|
printk("\tCPU%d: mask=0x%x, IMR=0x%x, IRR=0x%x, ISR=0x%x\n",
|
|
|
|
cpu, vic_irq_mask[cpu], imr, irr, isr);
|
|
|
|
#if 0
|
|
|
|
/* These lines are put in to try to unstick an un ack'd irq */
|
2008-01-30 13:30:10 +01:00
|
|
|
if (isr != 0) {
|
2005-04-17 00:20:36 +02:00
|
|
|
int irq;
|
2008-01-30 13:30:10 +01:00
|
|
|
for (irq = 0; irq < 16; irq++) {
|
|
|
|
if (isr & (1 << irq)) {
|
2005-04-17 00:20:36 +02:00
|
|
|
printk("\tCPU%d: ack irq %d\n",
|
|
|
|
cpu, irq);
|
|
|
|
local_irq_save(flags);
|
|
|
|
outb(VIC_CPU_MASQUERADE_ENABLE | cpu,
|
|
|
|
VIC_PROCESSOR_ID);
|
|
|
|
ack_vic_irq(irq);
|
|
|
|
outb(old_cpu, VIC_PROCESSOR_ID);
|
|
|
|
local_irq_restore(flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
void smp_voyager_power_off(void *dummy)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2008-01-30 13:30:10 +01:00
|
|
|
if (smp_processor_id() == boot_cpu_id)
|
2005-04-17 00:20:36 +02:00
|
|
|
voyager_power_off();
|
|
|
|
else
|
|
|
|
smp_stop_cpu_function(NULL);
|
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
static void __init voyager_smp_prepare_cpus(unsigned int max_cpus)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
/* FIXME: ignore max_cpus for now */
|
|
|
|
smp_boot_cpus();
|
|
|
|
}
|
|
|
|
|
2007-11-12 06:06:45 +01:00
|
|
|
static void __cpuinit voyager_smp_prepare_boot_cpu(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2007-05-15 10:41:59 +02:00
|
|
|
init_gdt(smp_processor_id());
|
|
|
|
switch_to_new_gdt();
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
cpu_set(smp_processor_id(), cpu_online_map);
|
|
|
|
cpu_set(smp_processor_id(), cpu_callout_map);
|
2005-09-04 00:56:51 +02:00
|
|
|
cpu_set(smp_processor_id(), cpu_possible_map);
|
2006-06-27 04:33:09 +02:00
|
|
|
cpu_set(smp_processor_id(), cpu_present_map);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
static int __cpuinit voyager_cpu_up(unsigned int cpu)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
/* This only works at boot for x86. See "rewrite" above. */
|
|
|
|
if (cpu_isset(cpu, smp_commenced_mask))
|
|
|
|
return -ENOSYS;
|
|
|
|
|
|
|
|
/* In case one didn't come up */
|
|
|
|
if (!cpu_isset(cpu, cpu_callin_map))
|
|
|
|
return -EIO;
|
|
|
|
/* Unleash the CPU! */
|
|
|
|
cpu_set(cpu, smp_commenced_mask);
|
2008-04-19 16:55:17 +02:00
|
|
|
while (!cpu_online(cpu))
|
2005-04-17 00:20:36 +02:00
|
|
|
mb();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
static void __init voyager_smp_cpus_done(unsigned int max_cpus)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
zap_low_mappings();
|
|
|
|
}
|
2006-06-30 10:55:50 +02:00
|
|
|
|
2008-01-30 13:30:10 +01:00
|
|
|
void __init smp_setup_processor_id(void)
|
2006-06-30 10:55:50 +02:00
|
|
|
{
|
|
|
|
current_thread_info()->cpu = hard_smp_processor_id();
|
2007-05-15 10:41:59 +02:00
|
|
|
x86_write_percpu(cpu_number, hard_smp_processor_id());
|
2006-06-30 10:55:50 +02:00
|
|
|
}
|
2007-05-15 10:41:59 +02:00
|
|
|
|
2008-11-09 18:53:14 +01:00
|
|
|
static void voyager_send_call_func(cpumask_t callmask)
|
|
|
|
{
|
|
|
|
__u32 mask = cpus_addr(callmask)[0] & ~(1 << smp_processor_id());
|
|
|
|
send_CPI(mask, VIC_CALL_FUNCTION_CPI);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void voyager_send_call_func_single(int cpu)
|
|
|
|
{
|
|
|
|
send_CPI(1 << cpu, VIC_CALL_FUNCTION_SINGLE_CPI);
|
|
|
|
}
|
|
|
|
|
2007-05-15 10:41:59 +02:00
|
|
|
struct smp_ops smp_ops = {
|
|
|
|
.smp_prepare_boot_cpu = voyager_smp_prepare_boot_cpu,
|
|
|
|
.smp_prepare_cpus = voyager_smp_prepare_cpus,
|
|
|
|
.cpu_up = voyager_cpu_up,
|
|
|
|
.smp_cpus_done = voyager_smp_cpus_done,
|
|
|
|
|
|
|
|
.smp_send_stop = voyager_smp_send_stop,
|
|
|
|
.smp_send_reschedule = voyager_smp_send_reschedule,
|
2008-06-26 11:21:54 +02:00
|
|
|
|
2008-11-09 18:53:14 +01:00
|
|
|
.send_call_func_ipi = voyager_send_call_func,
|
|
|
|
.send_call_func_single_ipi = voyager_send_call_func_single,
|
2007-05-15 10:41:59 +02:00
|
|
|
};
|