2005-06-22 23:43:43 +00:00
|
|
|
/*
|
2005-11-01 01:08:37 +00:00
|
|
|
* Cell Internal Interrupt Controller
|
2005-06-22 23:43:43 +00:00
|
|
|
*
|
2006-07-03 11:36:01 +00:00
|
|
|
* Copyright (C) 2006 Benjamin Herrenschmidt (benh@kernel.crashing.org)
|
|
|
|
* IBM, Corp.
|
|
|
|
*
|
2005-06-22 23:43:43 +00:00
|
|
|
* (C) Copyright IBM Deutschland Entwicklung GmbH 2005
|
|
|
|
*
|
|
|
|
* Author: Arnd Bergmann <arndb@de.ibm.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
2006-09-29 05:00:29 +00:00
|
|
|
*
|
|
|
|
* TODO:
|
|
|
|
* - Fix various assumptions related to HW CPU numbers vs. linux CPU numbers
|
|
|
|
* vs node numbers in the setup code
|
|
|
|
* - Implement proper handling of maxcpus=1/2 (that is, routing of irqs from
|
|
|
|
* a non-active node to the active node)
|
2005-06-22 23:43:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/irq.h>
|
2006-01-05 14:05:29 +00:00
|
|
|
#include <linux/module.h>
|
2005-06-22 23:43:43 +00:00
|
|
|
#include <linux/percpu.h>
|
|
|
|
#include <linux/types.h>
|
2006-07-03 11:36:01 +00:00
|
|
|
#include <linux/ioport.h>
|
2008-04-04 06:55:28 +00:00
|
|
|
#include <linux/kernel_stat.h>
|
2005-06-22 23:43:43 +00:00
|
|
|
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/pgtable.h>
|
|
|
|
#include <asm/prom.h>
|
|
|
|
#include <asm/ptrace.h>
|
2006-07-03 11:36:01 +00:00
|
|
|
#include <asm/machdep.h>
|
2007-10-04 05:40:42 +00:00
|
|
|
#include <asm/cell-regs.h>
|
2005-06-22 23:43:43 +00:00
|
|
|
|
2005-11-01 01:08:37 +00:00
|
|
|
#include "interrupt.h"
|
2005-06-22 23:43:43 +00:00
|
|
|
|
|
|
|
struct iic {
|
2006-06-19 18:33:16 +00:00
|
|
|
struct cbe_iic_thread_regs __iomem *regs;
|
2006-01-05 14:05:29 +00:00
|
|
|
u8 target_id;
|
2006-07-03 09:32:51 +00:00
|
|
|
u8 eoi_stack[16];
|
|
|
|
int eoi_ptr;
|
2006-09-29 05:00:29 +00:00
|
|
|
struct device_node *node;
|
2005-06-22 23:43:43 +00:00
|
|
|
};
|
|
|
|
|
2009-10-29 13:34:14 +00:00
|
|
|
static DEFINE_PER_CPU(struct iic, cpu_iic);
|
2006-07-03 11:36:01 +00:00
|
|
|
#define IIC_NODE_COUNT 2
|
2006-09-29 05:00:29 +00:00
|
|
|
static struct irq_host *iic_host;
|
2006-07-03 11:36:01 +00:00
|
|
|
|
|
|
|
/* Convert between "pending" bits and hw irq number */
|
|
|
|
static irq_hw_number_t iic_pending_to_hwnum(struct cbe_iic_pending_bits bits)
|
|
|
|
{
|
|
|
|
unsigned char unit = bits.source & 0xf;
|
2006-09-29 05:00:29 +00:00
|
|
|
unsigned char node = bits.source >> 4;
|
|
|
|
unsigned char class = bits.class & 3;
|
2006-07-03 11:36:01 +00:00
|
|
|
|
2006-09-29 05:00:29 +00:00
|
|
|
/* Decode IPIs */
|
2006-07-03 11:36:01 +00:00
|
|
|
if (bits.flags & CBE_IIC_IRQ_IPI)
|
2006-09-29 05:00:29 +00:00
|
|
|
return IIC_IRQ_TYPE_IPI | (bits.prio >> 4);
|
2006-07-03 11:36:01 +00:00
|
|
|
else
|
2006-09-29 05:00:29 +00:00
|
|
|
return (node << IIC_IRQ_NODE_SHIFT) | (class << 4) | unit;
|
2006-07-03 11:36:01 +00:00
|
|
|
}
|
2005-06-22 23:43:43 +00:00
|
|
|
|
2006-07-03 09:32:51 +00:00
|
|
|
static void iic_mask(unsigned int irq)
|
2005-06-22 23:43:43 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-07-03 09:32:51 +00:00
|
|
|
static void iic_unmask(unsigned int irq)
|
2005-06-22 23:43:43 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-07-03 09:32:51 +00:00
|
|
|
static void iic_eoi(unsigned int irq)
|
2005-06-22 23:43:43 +00:00
|
|
|
{
|
2009-10-29 13:34:14 +00:00
|
|
|
struct iic *iic = &__get_cpu_var(cpu_iic);
|
2006-07-03 09:32:51 +00:00
|
|
|
out_be64(&iic->regs->prio, iic->eoi_stack[--iic->eoi_ptr]);
|
|
|
|
BUG_ON(iic->eoi_ptr < 0);
|
2005-06-22 23:43:43 +00:00
|
|
|
}
|
|
|
|
|
2006-07-03 09:32:51 +00:00
|
|
|
static struct irq_chip iic_chip = {
|
2010-01-31 20:33:41 +00:00
|
|
|
.name = "CELL-IIC",
|
2006-07-03 09:32:51 +00:00
|
|
|
.mask = iic_mask,
|
|
|
|
.unmask = iic_unmask,
|
|
|
|
.eoi = iic_eoi,
|
2005-06-22 23:43:43 +00:00
|
|
|
};
|
|
|
|
|
2006-09-29 05:00:29 +00:00
|
|
|
|
|
|
|
static void iic_ioexc_eoi(unsigned int irq)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-10-07 12:08:26 +00:00
|
|
|
static void iic_ioexc_cascade(unsigned int irq, struct irq_desc *desc)
|
2006-09-29 05:00:29 +00:00
|
|
|
{
|
2006-10-04 15:26:24 +00:00
|
|
|
struct cbe_iic_regs __iomem *node_iic = (void __iomem *)desc->handler_data;
|
2006-09-29 05:00:29 +00:00
|
|
|
unsigned int base = (irq & 0xffffff00) | IIC_IRQ_TYPE_IOEXC;
|
|
|
|
unsigned long bits, ack;
|
|
|
|
int cascade;
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
bits = in_be64(&node_iic->iic_is);
|
|
|
|
if (bits == 0)
|
|
|
|
break;
|
|
|
|
/* pre-ack edge interrupts */
|
|
|
|
ack = bits & IIC_ISR_EDGE_MASK;
|
|
|
|
if (ack)
|
|
|
|
out_be64(&node_iic->iic_is, ack);
|
|
|
|
/* handle them */
|
|
|
|
for (cascade = 63; cascade >= 0; cascade--)
|
|
|
|
if (bits & (0x8000000000000000UL >> cascade)) {
|
|
|
|
unsigned int cirq =
|
|
|
|
irq_linear_revmap(iic_host,
|
|
|
|
base | cascade);
|
|
|
|
if (cirq != NO_IRQ)
|
2006-10-06 01:31:10 +00:00
|
|
|
generic_handle_irq(cirq);
|
2006-09-29 05:00:29 +00:00
|
|
|
}
|
|
|
|
/* post-ack level interrupts */
|
|
|
|
ack = bits & ~IIC_ISR_EDGE_MASK;
|
|
|
|
if (ack)
|
|
|
|
out_be64(&node_iic->iic_is, ack);
|
|
|
|
}
|
|
|
|
desc->chip->eoi(irq);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static struct irq_chip iic_ioexc_chip = {
|
2010-01-31 20:33:41 +00:00
|
|
|
.name = "CELL-IOEX",
|
2006-09-29 05:00:29 +00:00
|
|
|
.mask = iic_mask,
|
|
|
|
.unmask = iic_unmask,
|
|
|
|
.eoi = iic_ioexc_eoi,
|
|
|
|
};
|
|
|
|
|
2005-06-22 23:43:43 +00:00
|
|
|
/* Get an IRQ number from the pending state register of the IIC */
|
2006-10-07 12:08:26 +00:00
|
|
|
static unsigned int iic_get_irq(void)
|
2006-03-22 23:00:06 +00:00
|
|
|
{
|
2006-08-09 22:28:13 +00:00
|
|
|
struct cbe_iic_pending_bits pending;
|
|
|
|
struct iic *iic;
|
2006-09-29 05:00:29 +00:00
|
|
|
unsigned int virq;
|
2006-08-09 22:28:13 +00:00
|
|
|
|
2009-10-29 13:34:14 +00:00
|
|
|
iic = &__get_cpu_var(cpu_iic);
|
2006-08-09 22:28:13 +00:00
|
|
|
*(unsigned long *) &pending =
|
2009-01-06 14:03:44 +00:00
|
|
|
in_be64((u64 __iomem *) &iic->regs->pending_destr);
|
2006-09-29 05:00:29 +00:00
|
|
|
if (!(pending.flags & CBE_IIC_IRQ_VALID))
|
|
|
|
return NO_IRQ;
|
|
|
|
virq = irq_linear_revmap(iic_host, iic_pending_to_hwnum(pending));
|
|
|
|
if (virq == NO_IRQ)
|
|
|
|
return NO_IRQ;
|
2006-08-09 22:28:13 +00:00
|
|
|
iic->eoi_stack[++iic->eoi_ptr] = pending.prio;
|
|
|
|
BUG_ON(iic->eoi_ptr > 15);
|
2006-09-29 05:00:29 +00:00
|
|
|
return virq;
|
2005-06-22 23:43:43 +00:00
|
|
|
}
|
|
|
|
|
2007-10-27 17:28:51 +00:00
|
|
|
void iic_setup_cpu(void)
|
|
|
|
{
|
2009-10-29 13:34:14 +00:00
|
|
|
out_be64(&__get_cpu_var(cpu_iic).regs->prio, 0xff);
|
2007-10-27 17:28:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
u8 iic_get_target_id(int cpu)
|
|
|
|
{
|
2009-10-29 13:34:14 +00:00
|
|
|
return per_cpu(cpu_iic, cpu).target_id;
|
2007-10-27 17:28:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_SYMBOL_GPL(iic_get_target_id);
|
|
|
|
|
2005-06-22 23:43:43 +00:00
|
|
|
#ifdef CONFIG_SMP
|
2005-08-18 17:35:21 +00:00
|
|
|
|
|
|
|
/* Use the highest interrupt priorities for IPI */
|
|
|
|
static inline int iic_ipi_to_irq(int ipi)
|
|
|
|
{
|
2006-09-29 05:00:29 +00:00
|
|
|
return IIC_IRQ_TYPE_IPI + 0xf - ipi;
|
2005-08-18 17:35:21 +00:00
|
|
|
}
|
|
|
|
|
2005-06-22 23:43:43 +00:00
|
|
|
void iic_cause_IPI(int cpu, int mesg)
|
|
|
|
{
|
2009-10-29 13:34:14 +00:00
|
|
|
out_be64(&per_cpu(cpu_iic, cpu).regs->generate, (0xf - mesg) << 4);
|
2005-06-22 23:43:43 +00:00
|
|
|
}
|
|
|
|
|
2006-07-03 11:36:01 +00:00
|
|
|
struct irq_host *iic_get_irq_host(int node)
|
|
|
|
{
|
2006-09-29 05:00:29 +00:00
|
|
|
return iic_host;
|
2006-07-03 11:36:01 +00:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(iic_get_irq_host);
|
|
|
|
|
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 13:55:46 +00:00
|
|
|
static irqreturn_t iic_ipi_action(int irq, void *dev_id)
|
2005-06-22 23:43:43 +00:00
|
|
|
{
|
2006-07-03 11:36:01 +00:00
|
|
|
int ipi = (int)(long)dev_id;
|
|
|
|
|
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 13:55:46 +00:00
|
|
|
smp_message_recv(ipi);
|
2006-07-03 11:36:01 +00:00
|
|
|
|
2005-06-22 23:43:43 +00:00
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
2005-08-18 17:35:21 +00:00
|
|
|
static void iic_request_ipi(int ipi, const char *name)
|
2005-06-22 23:43:43 +00:00
|
|
|
{
|
2006-09-29 05:00:29 +00:00
|
|
|
int virq;
|
2005-08-18 17:35:21 +00:00
|
|
|
|
2006-09-29 05:00:29 +00:00
|
|
|
virq = irq_create_mapping(iic_host, iic_ipi_to_irq(ipi));
|
|
|
|
if (virq == NO_IRQ) {
|
|
|
|
printk(KERN_ERR
|
|
|
|
"iic: failed to map IPI %s\n", name);
|
|
|
|
return;
|
2006-07-03 11:36:01 +00:00
|
|
|
}
|
2006-09-29 05:00:29 +00:00
|
|
|
if (request_irq(virq, iic_ipi_action, IRQF_DISABLED, name,
|
|
|
|
(void *)(long)ipi))
|
|
|
|
printk(KERN_ERR
|
|
|
|
"iic: failed to request IPI %s\n", name);
|
2005-06-22 23:43:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void iic_request_IPIs(void)
|
|
|
|
{
|
2005-08-18 17:35:21 +00:00
|
|
|
iic_request_ipi(PPC_MSG_CALL_FUNCTION, "IPI-call");
|
|
|
|
iic_request_ipi(PPC_MSG_RESCHEDULE, "IPI-resched");
|
2008-06-26 09:22:13 +00:00
|
|
|
iic_request_ipi(PPC_MSG_CALL_FUNC_SINGLE, "IPI-call-single");
|
2005-06-22 23:43:43 +00:00
|
|
|
#ifdef CONFIG_DEBUGGER
|
2005-08-18 17:35:21 +00:00
|
|
|
iic_request_ipi(PPC_MSG_DEBUGGER_BREAK, "IPI-debug");
|
2005-06-22 23:43:43 +00:00
|
|
|
#endif /* CONFIG_DEBUGGER */
|
|
|
|
}
|
2006-07-03 11:36:01 +00:00
|
|
|
|
2005-06-22 23:43:43 +00:00
|
|
|
#endif /* CONFIG_SMP */
|
|
|
|
|
2006-07-03 11:36:01 +00:00
|
|
|
|
|
|
|
static int iic_host_match(struct irq_host *h, struct device_node *node)
|
|
|
|
{
|
2007-05-03 07:26:52 +00:00
|
|
|
return of_device_is_compatible(node,
|
2006-09-29 05:00:29 +00:00
|
|
|
"IBM,CBEA-Internal-Interrupt-Controller");
|
2006-07-03 11:36:01 +00:00
|
|
|
}
|
|
|
|
|
2008-04-04 06:55:28 +00:00
|
|
|
extern int noirqdebug;
|
|
|
|
|
|
|
|
static void handle_iic_irq(unsigned int irq, struct irq_desc *desc)
|
|
|
|
{
|
2009-11-17 15:46:45 +00:00
|
|
|
raw_spin_lock(&desc->lock);
|
2008-04-04 06:55:28 +00:00
|
|
|
|
|
|
|
desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we're currently running this IRQ, or its disabled,
|
|
|
|
* we shouldn't process the IRQ. Mark it pending, handle
|
|
|
|
* the necessary masking and go out
|
|
|
|
*/
|
|
|
|
if (unlikely((desc->status & (IRQ_INPROGRESS | IRQ_DISABLED)) ||
|
|
|
|
!desc->action)) {
|
|
|
|
desc->status |= IRQ_PENDING;
|
|
|
|
goto out_eoi;
|
|
|
|
}
|
|
|
|
|
2009-01-11 08:29:15 +00:00
|
|
|
kstat_incr_irqs_this_cpu(irq, desc);
|
2008-04-04 06:55:28 +00:00
|
|
|
|
|
|
|
/* Mark the IRQ currently in progress.*/
|
|
|
|
desc->status |= IRQ_INPROGRESS;
|
|
|
|
|
|
|
|
do {
|
|
|
|
struct irqaction *action = desc->action;
|
|
|
|
irqreturn_t action_ret;
|
|
|
|
|
|
|
|
if (unlikely(!action))
|
|
|
|
goto out_eoi;
|
|
|
|
|
|
|
|
desc->status &= ~IRQ_PENDING;
|
2009-11-17 15:46:45 +00:00
|
|
|
raw_spin_unlock(&desc->lock);
|
2008-04-04 06:55:28 +00:00
|
|
|
action_ret = handle_IRQ_event(irq, action);
|
|
|
|
if (!noirqdebug)
|
|
|
|
note_interrupt(irq, desc, action_ret);
|
2009-11-17 15:46:45 +00:00
|
|
|
raw_spin_lock(&desc->lock);
|
2008-04-04 06:55:28 +00:00
|
|
|
|
|
|
|
} while ((desc->status & (IRQ_PENDING | IRQ_DISABLED)) == IRQ_PENDING);
|
|
|
|
|
|
|
|
desc->status &= ~IRQ_INPROGRESS;
|
|
|
|
out_eoi:
|
|
|
|
desc->chip->eoi(irq);
|
2009-11-17 15:46:45 +00:00
|
|
|
raw_spin_unlock(&desc->lock);
|
2008-04-04 06:55:28 +00:00
|
|
|
}
|
|
|
|
|
2006-07-03 11:36:01 +00:00
|
|
|
static int iic_host_map(struct irq_host *h, unsigned int virq,
|
[PATCH] powerpc: fix trigger handling in the new irq code
This patch slightly reworks the new irq code to fix a small design error. I
removed the passing of the trigger to the map() calls entirely, it was not a
good idea to have one call do two different things. It also fixes a couple of
corner cases.
Mapping a linux virtual irq to a physical irq now does only that. Setting the
trigger is a different action which has a different call.
The main changes are:
- I no longer call host->ops->map() for an already mapped irq, I just return
the virtual number that was already mapped. It was called before to give an
opportunity to change the trigger, but that was causing issues as that could
happen while the interrupt was in use by a device, and because of the
trigger change, map would potentially muck around with things in a racy way.
That was causing much burden on a given's controller implementation of
map() to get it right. This is much simpler now. map() is only called on
the initial mapping of an irq, meaning that you know that this irq is _not_
being used. You can initialize the hardware if you want (though you don't
have to).
- Controllers that can handle different type of triggers (level/edge/etc...)
now implement the standard irq_chip->set_type() call as defined by the
generic code. That means that you can use the standard set_irq_type() to
configure an irq line manually if you wish or (though I don't like that
interface), pass explicit trigger flags to request_irq() as defined by the
generic kernel interfaces. Also, using those interfaces guarantees that
your controller set_type callback is called with the descriptor lock held,
thus providing locking against activity on the same interrupt (including
mask/unmask/etc...) automatically. A result is that, for example, MPIC's
own map() implementation calls irq_set_type(NONE) to configure the hardware
to the default triggers.
- To allow the above, the irq_map array entry for the new mapped interrupt
is now set before map() callback is called for the controller.
- The irq_create_of_mapping() (also used by irq_of_parse_and_map()) function
for mapping interrupts from the device-tree now also call the separate
set_irq_type(), and only does so if there is a change in the trigger type.
- While I was at it, I changed pci_read_irq_line() (which is the helper I
would expect most archs to use in their pcibios_fixup() to get the PCI
interrupt routing from the device tree) to also handle a fallback when the
DT mapping fails consisting of reading the PCI_INTERRUPT_PIN to know wether
the device has an interrupt at all, and the the PCI_INTERRUPT_LINE to get an
interrupt number from the device. That number is then mapped using the
default controller, and the trigger is set to level low. That default
behaviour works for several platforms that don't have a proper interrupt
tree like Pegasos. If it doesn't work for your platform, then either
provide a proper interrupt tree from the firmware so that fallback isn't
needed, or don't call pci_read_irq_line()
- Add back a bit that got dropped by my main rework patch for properly
clearing pending IPIs on pSeries when using a kexec
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-07-10 11:44:42 +00:00
|
|
|
irq_hw_number_t hw)
|
2006-07-03 11:36:01 +00:00
|
|
|
{
|
2006-09-29 05:00:29 +00:00
|
|
|
switch (hw & IIC_IRQ_TYPE_MASK) {
|
|
|
|
case IIC_IRQ_TYPE_IPI:
|
2006-07-03 11:36:01 +00:00
|
|
|
set_irq_chip_and_handler(virq, &iic_chip, handle_percpu_irq);
|
2006-09-29 05:00:29 +00:00
|
|
|
break;
|
|
|
|
case IIC_IRQ_TYPE_IOEXC:
|
|
|
|
set_irq_chip_and_handler(virq, &iic_ioexc_chip,
|
2008-04-04 06:55:28 +00:00
|
|
|
handle_iic_irq);
|
2006-09-29 05:00:29 +00:00
|
|
|
break;
|
|
|
|
default:
|
2008-04-04 06:55:28 +00:00
|
|
|
set_irq_chip_and_handler(virq, &iic_chip, handle_iic_irq);
|
2006-09-29 05:00:29 +00:00
|
|
|
}
|
2006-07-03 11:36:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int iic_host_xlate(struct irq_host *h, struct device_node *ct,
|
2009-12-08 02:39:50 +00:00
|
|
|
const u32 *intspec, unsigned int intsize,
|
2006-07-03 11:36:01 +00:00
|
|
|
irq_hw_number_t *out_hwirq, unsigned int *out_flags)
|
|
|
|
|
2005-06-22 23:43:43 +00:00
|
|
|
{
|
2006-09-29 05:00:29 +00:00
|
|
|
unsigned int node, ext, unit, class;
|
|
|
|
const u32 *val;
|
|
|
|
|
2007-05-03 07:26:52 +00:00
|
|
|
if (!of_device_is_compatible(ct,
|
2006-09-29 05:00:29 +00:00
|
|
|
"IBM,CBEA-Internal-Interrupt-Controller"))
|
|
|
|
return -ENODEV;
|
|
|
|
if (intsize != 1)
|
|
|
|
return -ENODEV;
|
2007-04-03 12:26:41 +00:00
|
|
|
val = of_get_property(ct, "#interrupt-cells", NULL);
|
2006-09-29 05:00:29 +00:00
|
|
|
if (val == NULL || *val != 1)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
node = intspec[0] >> 24;
|
|
|
|
ext = (intspec[0] >> 16) & 0xff;
|
|
|
|
class = (intspec[0] >> 8) & 0xff;
|
|
|
|
unit = intspec[0] & 0xff;
|
|
|
|
|
|
|
|
/* Check if node is in supported range */
|
|
|
|
if (node > 1)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* Build up interrupt number, special case for IO exceptions */
|
|
|
|
*out_hwirq = (node << IIC_IRQ_NODE_SHIFT);
|
|
|
|
if (unit == IIC_UNIT_IIC && class == 1)
|
|
|
|
*out_hwirq |= IIC_IRQ_TYPE_IOEXC | ext;
|
|
|
|
else
|
|
|
|
*out_hwirq |= IIC_IRQ_TYPE_NORMAL |
|
|
|
|
(class << IIC_IRQ_CLASS_SHIFT) | unit;
|
|
|
|
|
|
|
|
/* Dummy flags, ignored by iic code */
|
|
|
|
*out_flags = IRQ_TYPE_EDGE_RISING;
|
|
|
|
|
|
|
|
return 0;
|
2006-07-03 11:36:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct irq_host_ops iic_host_ops = {
|
|
|
|
.match = iic_host_match,
|
|
|
|
.map = iic_host_map,
|
|
|
|
.xlate = iic_host_xlate,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void __init init_one_iic(unsigned int hw_cpu, unsigned long addr,
|
2006-09-29 05:00:29 +00:00
|
|
|
struct device_node *node)
|
2006-07-03 11:36:01 +00:00
|
|
|
{
|
|
|
|
/* XXX FIXME: should locate the linux CPU number from the HW cpu
|
|
|
|
* number properly. We are lucky for now
|
|
|
|
*/
|
2009-10-29 13:34:14 +00:00
|
|
|
struct iic *iic = &per_cpu(cpu_iic, hw_cpu);
|
2005-06-22 23:43:43 +00:00
|
|
|
|
2006-07-03 11:36:01 +00:00
|
|
|
iic->regs = ioremap(addr, sizeof(struct cbe_iic_thread_regs));
|
|
|
|
BUG_ON(iic->regs == NULL);
|
2006-07-03 09:32:51 +00:00
|
|
|
|
2006-07-03 11:36:01 +00:00
|
|
|
iic->target_id = ((hw_cpu & 2) << 3) | ((hw_cpu & 1) ? 0xf : 0xe);
|
|
|
|
iic->eoi_stack[0] = 0xff;
|
2006-09-29 05:00:29 +00:00
|
|
|
iic->node = of_node_get(node);
|
2006-07-03 11:36:01 +00:00
|
|
|
out_be64(&iic->regs->prio, 0);
|
|
|
|
|
2006-09-29 05:00:29 +00:00
|
|
|
printk(KERN_INFO "IIC for CPU %d target id 0x%x : %s\n",
|
|
|
|
hw_cpu, iic->target_id, node->full_name);
|
2006-07-03 11:36:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int __init setup_iic(void)
|
|
|
|
{
|
|
|
|
struct device_node *dn;
|
|
|
|
struct resource r0, r1;
|
2006-09-29 05:00:29 +00:00
|
|
|
unsigned int node, cascade, found = 0;
|
2006-10-04 15:26:24 +00:00
|
|
|
struct cbe_iic_regs __iomem *node_iic;
|
2006-08-09 22:28:13 +00:00
|
|
|
const u32 *np;
|
2006-07-03 11:36:01 +00:00
|
|
|
|
|
|
|
for (dn = NULL;
|
|
|
|
(dn = of_find_node_by_name(dn,"interrupt-controller")) != NULL;) {
|
2007-05-03 07:26:52 +00:00
|
|
|
if (!of_device_is_compatible(dn,
|
2006-07-03 11:36:01 +00:00
|
|
|
"IBM,CBEA-Internal-Interrupt-Controller"))
|
|
|
|
continue;
|
2007-04-03 12:26:41 +00:00
|
|
|
np = of_get_property(dn, "ibm,interrupt-server-ranges", NULL);
|
2006-08-09 22:28:13 +00:00
|
|
|
if (np == NULL) {
|
2006-07-03 11:36:01 +00:00
|
|
|
printk(KERN_WARNING "IIC: CPU association not found\n");
|
|
|
|
of_node_put(dn);
|
|
|
|
return -ENODEV;
|
2005-06-22 23:43:43 +00:00
|
|
|
}
|
2006-07-03 11:36:01 +00:00
|
|
|
if (of_address_to_resource(dn, 0, &r0) ||
|
|
|
|
of_address_to_resource(dn, 1, &r1)) {
|
|
|
|
printk(KERN_WARNING "IIC: Can't resolve addresses\n");
|
|
|
|
of_node_put(dn);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
2006-09-29 05:00:29 +00:00
|
|
|
found++;
|
|
|
|
init_one_iic(np[0], r0.start, dn);
|
|
|
|
init_one_iic(np[1], r1.start, dn);
|
|
|
|
|
|
|
|
/* Setup cascade for IO exceptions. XXX cleanup tricks to get
|
|
|
|
* node vs CPU etc...
|
|
|
|
* Note that we configure the IIC_IRR here with a hard coded
|
|
|
|
* priority of 1. We might want to improve that later.
|
|
|
|
*/
|
|
|
|
node = np[0] >> 1;
|
|
|
|
node_iic = cbe_get_cpu_iic_regs(np[0]);
|
|
|
|
cascade = node << IIC_IRQ_NODE_SHIFT;
|
|
|
|
cascade |= 1 << IIC_IRQ_CLASS_SHIFT;
|
|
|
|
cascade |= IIC_UNIT_IIC;
|
|
|
|
cascade = irq_create_mapping(iic_host, cascade);
|
|
|
|
if (cascade == NO_IRQ)
|
|
|
|
continue;
|
2006-10-04 15:26:24 +00:00
|
|
|
/*
|
|
|
|
* irq_data is a generic pointer that gets passed back
|
|
|
|
* to us later, so the forced cast is fine.
|
|
|
|
*/
|
|
|
|
set_irq_data(cascade, (void __force *)node_iic);
|
2006-09-29 05:00:29 +00:00
|
|
|
set_irq_chained_handler(cascade , iic_ioexc_cascade);
|
|
|
|
out_be64(&node_iic->iic_ir,
|
|
|
|
(1 << 12) /* priority */ |
|
|
|
|
(node << 4) /* dest node */ |
|
|
|
|
IIC_UNIT_THREAD_0 /* route them to thread 0 */);
|
|
|
|
/* Flush pending (make sure it triggers if there is
|
|
|
|
* anything pending
|
|
|
|
*/
|
|
|
|
out_be64(&node_iic->iic_is, 0xfffffffffffffffful);
|
2005-06-22 23:43:43 +00:00
|
|
|
}
|
2006-07-03 11:36:01 +00:00
|
|
|
|
|
|
|
if (found)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return -ENODEV;
|
2005-06-22 23:43:43 +00:00
|
|
|
}
|
|
|
|
|
2006-07-03 09:32:51 +00:00
|
|
|
void __init iic_init_IRQ(void)
|
2005-06-22 23:43:43 +00:00
|
|
|
{
|
2006-09-29 05:00:29 +00:00
|
|
|
/* Setup an irq host data structure */
|
2007-08-28 08:47:54 +00:00
|
|
|
iic_host = irq_alloc_host(NULL, IRQ_HOST_MAP_LINEAR, IIC_SOURCE_COUNT,
|
2006-09-29 05:00:29 +00:00
|
|
|
&iic_host_ops, IIC_IRQ_INVALID);
|
|
|
|
BUG_ON(iic_host == NULL);
|
|
|
|
irq_set_default_host(iic_host);
|
|
|
|
|
2006-07-03 11:36:01 +00:00
|
|
|
/* Discover and initialize iics */
|
2006-03-22 23:00:06 +00:00
|
|
|
if (setup_iic() < 0)
|
2006-07-03 11:36:01 +00:00
|
|
|
panic("IIC: Failed to initialize !\n");
|
2006-03-22 23:00:06 +00:00
|
|
|
|
2006-07-03 11:36:01 +00:00
|
|
|
/* Set master interrupt handling function */
|
|
|
|
ppc_md.get_irq = iic_get_irq;
|
2006-07-03 09:32:51 +00:00
|
|
|
|
2006-07-03 11:36:01 +00:00
|
|
|
/* Enable on current CPU */
|
|
|
|
iic_setup_cpu();
|
2005-06-22 23:43:43 +00:00
|
|
|
}
|
2006-11-20 17:45:15 +00:00
|
|
|
|
|
|
|
void iic_set_interrupt_routing(int cpu, int thread, int priority)
|
|
|
|
{
|
|
|
|
struct cbe_iic_regs __iomem *iic_regs = cbe_get_cpu_iic_regs(cpu);
|
|
|
|
u64 iic_ir = 0;
|
|
|
|
int node = cpu >> 1;
|
|
|
|
|
|
|
|
/* Set which node and thread will handle the next interrupt */
|
|
|
|
iic_ir |= CBE_IIC_IR_PRIO(priority) |
|
|
|
|
CBE_IIC_IR_DEST_NODE(node);
|
|
|
|
if (thread == 0)
|
|
|
|
iic_ir |= CBE_IIC_IR_DEST_UNIT(CBE_IIC_IR_PT_0);
|
|
|
|
else
|
|
|
|
iic_ir |= CBE_IIC_IR_DEST_UNIT(CBE_IIC_IR_PT_1);
|
|
|
|
out_be64(&iic_regs->iic_ir, iic_ir);
|
|
|
|
}
|