2005-06-22 00:15:49 +00:00
|
|
|
/*
|
|
|
|
* This module supports the iSeries PCI bus interrupt handling
|
|
|
|
* Copyright (C) 20yy <Robert L Holtorf> <IBM Corp>
|
2005-06-22 00:15:50 +00:00
|
|
|
* Copyright (C) 2004-2005 IBM Corporation
|
2005-06-22 00:15:49 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This 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.,
|
|
|
|
* 59 Temple Place, Suite 330,
|
|
|
|
* Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
* Change Activity:
|
|
|
|
* Created, December 13, 2000 by Wayne Holm
|
|
|
|
* End Change Activity
|
|
|
|
*/
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/threads.h>
|
|
|
|
#include <linux/smp.h>
|
|
|
|
#include <linux/param.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/bootmem.h>
|
|
|
|
#include <linux/irq.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
|
2005-11-16 07:53:29 +00:00
|
|
|
#include <asm/paca.h>
|
2005-11-02 02:46:07 +00:00
|
|
|
#include <asm/iseries/hv_types.h>
|
2005-11-02 01:08:31 +00:00
|
|
|
#include <asm/iseries/hv_lp_event.h>
|
2005-11-02 00:41:12 +00:00
|
|
|
#include <asm/iseries/hv_call_xm.h>
|
2005-11-16 07:53:29 +00:00
|
|
|
#include <asm/iseries/it_lp_queue.h>
|
2005-09-28 13:37:01 +00:00
|
|
|
|
|
|
|
#include "irq.h"
|
2006-05-19 06:46:28 +00:00
|
|
|
#include "pci.h"
|
2005-10-14 07:16:17 +00:00
|
|
|
#include "call_pci.h"
|
2006-10-06 03:55:26 +00:00
|
|
|
#include "smp.h"
|
2005-11-16 07:53:29 +00:00
|
|
|
|
2006-01-12 02:54:20 +00:00
|
|
|
#ifdef CONFIG_PCI
|
|
|
|
|
2005-11-16 06:47:43 +00:00
|
|
|
enum pci_event_type {
|
|
|
|
pe_bus_created = 0, /* PHB has been created */
|
|
|
|
pe_bus_error = 1, /* PHB has failed */
|
|
|
|
pe_bus_failed = 2, /* Msg to Secondary, Primary failed bus */
|
|
|
|
pe_node_failed = 4, /* Multi-adapter bridge has failed */
|
|
|
|
pe_node_recovered = 5, /* Multi-adapter bridge has recovered */
|
|
|
|
pe_bus_recovered = 12, /* PHB has been recovered */
|
|
|
|
pe_unquiese_bus = 18, /* Secondary bus unqiescing */
|
|
|
|
pe_bridge_error = 21, /* Bridge Error */
|
|
|
|
pe_slot_interrupt = 22 /* Slot interrupt */
|
2005-06-22 00:15:50 +00:00
|
|
|
};
|
|
|
|
|
2005-11-16 06:47:43 +00:00
|
|
|
struct pci_event {
|
|
|
|
struct HvLpEvent event;
|
2005-06-22 00:15:50 +00:00
|
|
|
union {
|
2005-11-16 06:47:43 +00:00
|
|
|
u64 __align; /* Align on an 8-byte boundary */
|
2005-06-22 00:15:50 +00:00
|
|
|
struct {
|
|
|
|
u32 fisr;
|
2005-11-16 06:47:43 +00:00
|
|
|
HvBusNumber bus_number;
|
|
|
|
HvSubBusNumber sub_bus_number;
|
|
|
|
HvAgentId dev_id;
|
|
|
|
} slot;
|
|
|
|
struct {
|
|
|
|
HvBusNumber bus_number;
|
|
|
|
HvSubBusNumber sub_bus_number;
|
|
|
|
} bus;
|
|
|
|
struct {
|
|
|
|
HvBusNumber bus_number;
|
|
|
|
HvSubBusNumber sub_bus_number;
|
|
|
|
HvAgentId dev_id;
|
|
|
|
} node;
|
|
|
|
} data;
|
2005-06-22 00:15:50 +00:00
|
|
|
};
|
|
|
|
|
2005-11-17 07:04:37 +00:00
|
|
|
static DEFINE_SPINLOCK(pending_irqs_lock);
|
|
|
|
static int num_pending_irqs;
|
|
|
|
static int pending_irqs[NR_IRQS];
|
|
|
|
|
2006-10-07 12:08:26 +00:00
|
|
|
static void int_received(struct pci_event *event)
|
2005-06-22 00:15:50 +00:00
|
|
|
{
|
|
|
|
int irq;
|
|
|
|
|
2005-11-16 06:47:43 +00:00
|
|
|
switch (event->event.xSubtype) {
|
|
|
|
case pe_slot_interrupt:
|
|
|
|
irq = event->event.xCorrelationToken;
|
2005-11-17 07:04:37 +00:00
|
|
|
if (irq < NR_IRQS) {
|
|
|
|
spin_lock(&pending_irqs_lock);
|
|
|
|
pending_irqs[irq]++;
|
|
|
|
num_pending_irqs++;
|
|
|
|
spin_unlock(&pending_irqs_lock);
|
|
|
|
} else {
|
|
|
|
printk(KERN_WARNING "int_received: bad irq number %d\n",
|
|
|
|
irq);
|
|
|
|
HvCallPci_eoi(event->data.slot.bus_number,
|
|
|
|
event->data.slot.sub_bus_number,
|
|
|
|
event->data.slot.dev_id);
|
|
|
|
}
|
2005-06-22 00:15:50 +00:00
|
|
|
break;
|
|
|
|
/* Ignore error recovery events for now */
|
2005-11-16 06:47:43 +00:00
|
|
|
case pe_bus_created:
|
|
|
|
printk(KERN_INFO "int_received: system bus %d created\n",
|
|
|
|
event->data.bus.bus_number);
|
2005-06-22 00:15:50 +00:00
|
|
|
break;
|
2005-11-16 06:47:43 +00:00
|
|
|
case pe_bus_error:
|
|
|
|
case pe_bus_failed:
|
|
|
|
printk(KERN_INFO "int_received: system bus %d failed\n",
|
|
|
|
event->data.bus.bus_number);
|
2005-06-22 00:15:50 +00:00
|
|
|
break;
|
2005-11-16 06:47:43 +00:00
|
|
|
case pe_bus_recovered:
|
|
|
|
case pe_unquiese_bus:
|
|
|
|
printk(KERN_INFO "int_received: system bus %d recovered\n",
|
|
|
|
event->data.bus.bus_number);
|
2005-06-22 00:15:50 +00:00
|
|
|
break;
|
2005-11-16 06:47:43 +00:00
|
|
|
case pe_node_failed:
|
|
|
|
case pe_bridge_error:
|
2005-06-22 00:15:50 +00:00
|
|
|
printk(KERN_INFO
|
2005-11-16 06:47:43 +00:00
|
|
|
"int_received: multi-adapter bridge %d/%d/%d failed\n",
|
|
|
|
event->data.node.bus_number,
|
|
|
|
event->data.node.sub_bus_number,
|
|
|
|
event->data.node.dev_id);
|
2005-06-22 00:15:50 +00:00
|
|
|
break;
|
2005-11-16 06:47:43 +00:00
|
|
|
case pe_node_recovered:
|
2005-06-22 00:15:50 +00:00
|
|
|
printk(KERN_INFO
|
2005-11-16 06:47:43 +00:00
|
|
|
"int_received: multi-adapter bridge %d/%d/%d recovered\n",
|
|
|
|
event->data.node.bus_number,
|
|
|
|
event->data.node.sub_bus_number,
|
|
|
|
event->data.node.dev_id);
|
2005-06-22 00:15:50 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printk(KERN_ERR
|
2005-11-16 06:47:43 +00:00
|
|
|
"int_received: unrecognized event subtype 0x%x\n",
|
|
|
|
event->event.xSubtype);
|
2005-06-22 00:15:50 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-07 12:08:26 +00:00
|
|
|
static void pci_event_handler(struct HvLpEvent *event)
|
2005-06-22 00:15:50 +00:00
|
|
|
{
|
2005-11-16 06:47:43 +00:00
|
|
|
if (event && (event->xType == HvLpEvent_Type_PciIo)) {
|
2006-01-12 02:47:43 +00:00
|
|
|
if (hvlpevent_is_int(event))
|
2006-10-07 12:08:26 +00:00
|
|
|
int_received((struct pci_event *)event);
|
2006-01-12 02:47:43 +00:00
|
|
|
else
|
2005-06-22 00:15:50 +00:00
|
|
|
printk(KERN_ERR
|
2005-11-16 06:47:43 +00:00
|
|
|
"pci_event_handler: unexpected ack received\n");
|
|
|
|
} else if (event)
|
2005-06-22 00:15:50 +00:00
|
|
|
printk(KERN_ERR
|
2005-11-16 06:47:43 +00:00
|
|
|
"pci_event_handler: Unrecognized PCI event type 0x%x\n",
|
|
|
|
(int)event->xType);
|
2005-06-22 00:15:50 +00:00
|
|
|
else
|
2005-11-16 06:47:43 +00:00
|
|
|
printk(KERN_ERR "pci_event_handler: NULL event received\n");
|
2005-06-22 00:15:50 +00:00
|
|
|
}
|
|
|
|
|
2005-11-16 07:10:40 +00:00
|
|
|
#define REAL_IRQ_TO_SUBBUS(irq) (((irq) >> 14) & 0xff)
|
2005-06-22 00:15:49 +00:00
|
|
|
#define REAL_IRQ_TO_BUS(irq) ((((irq) >> 6) & 0xff) + 1)
|
|
|
|
#define REAL_IRQ_TO_IDSEL(irq) ((((irq) >> 3) & 7) + 1)
|
|
|
|
#define REAL_IRQ_TO_FUNC(irq) ((irq) & 7)
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
2005-06-22 00:15:49 +00:00
|
|
|
* This will be called by device drivers (via enable_IRQ)
|
|
|
|
* to enable INTA in the bridge interrupt status register.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2005-11-16 06:47:43 +00:00
|
|
|
static void iseries_enable_IRQ(unsigned int irq)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2005-11-16 06:47:43 +00:00
|
|
|
u32 bus, dev_id, function, mask;
|
|
|
|
const u32 sub_bus = 0;
|
2006-07-03 11:36:01 +00:00
|
|
|
unsigned int rirq = (unsigned int)irq_map[irq].hwirq;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-06-22 00:15:49 +00:00
|
|
|
/* The IRQ has already been locked by the caller */
|
|
|
|
bus = REAL_IRQ_TO_BUS(rirq);
|
|
|
|
function = REAL_IRQ_TO_FUNC(rirq);
|
2005-11-16 06:47:43 +00:00
|
|
|
dev_id = (REAL_IRQ_TO_IDSEL(rirq) << 4) + function;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-06-22 00:15:49 +00:00
|
|
|
/* Unmask secondary INTA */
|
|
|
|
mask = 0x80000000;
|
2005-11-16 06:47:43 +00:00
|
|
|
HvCallPci_unmaskInterrupts(bus, sub_bus, dev_id, mask);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2005-11-16 06:47:43 +00:00
|
|
|
/* This is called by iseries_activate_IRQs */
|
|
|
|
static unsigned int iseries_startup_IRQ(unsigned int irq)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2005-11-16 06:47:43 +00:00
|
|
|
u32 bus, dev_id, function, mask;
|
|
|
|
const u32 sub_bus = 0;
|
2006-07-03 11:36:01 +00:00
|
|
|
unsigned int rirq = (unsigned int)irq_map[irq].hwirq;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
bus = REAL_IRQ_TO_BUS(rirq);
|
|
|
|
function = REAL_IRQ_TO_FUNC(rirq);
|
2005-11-16 06:47:43 +00:00
|
|
|
dev_id = (REAL_IRQ_TO_IDSEL(rirq) << 4) + function;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Link the IRQ number to the bridge */
|
2005-11-16 06:47:43 +00:00
|
|
|
HvCallXm_connectBusUnit(bus, sub_bus, dev_id, irq);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Unmask bridge interrupts in the FISR */
|
|
|
|
mask = 0x01010000 << function;
|
2005-11-16 06:47:43 +00:00
|
|
|
HvCallPci_unmaskFisr(bus, sub_bus, dev_id, mask);
|
|
|
|
iseries_enable_IRQ(irq);
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is called out of iSeries_fixup to activate interrupt
|
|
|
|
* generation for usable slots
|
|
|
|
*/
|
|
|
|
void __init iSeries_activate_IRQs()
|
|
|
|
{
|
|
|
|
int irq;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
for_each_irq (irq) {
|
|
|
|
irq_desc_t *desc = get_irq_desc(irq);
|
|
|
|
|
[PATCH] genirq: rename desc->handler to desc->chip
This patch-queue improves the generic IRQ layer to be truly generic, by adding
various abstractions and features to it, without impacting existing
functionality.
While the queue can be best described as "fix and improve everything in the
generic IRQ layer that we could think of", and thus it consists of many
smaller features and lots of cleanups, the one feature that stands out most is
the new 'irq chip' abstraction.
The irq-chip abstraction is about describing and coding and IRQ controller
driver by mapping its raw hardware capabilities [and quirks, if needed] in a
straightforward way, without having to think about "IRQ flow"
(level/edge/etc.) type of details.
This stands in contrast with the current 'irq-type' model of genirq
architectures, which 'mixes' raw hardware capabilities with 'flow' details.
The patchset supports both types of irq controller designs at once, and
converts i386 and x86_64 to the new irq-chip design.
As a bonus side-effect of the irq-chip approach, chained interrupt controllers
(master/slave PIC constructs, etc.) are now supported by design as well.
The end result of this patchset intends to be simpler architecture-level code
and more consolidation between architectures.
We reused many bits of code and many concepts from Russell King's ARM IRQ
layer, the merging of which was one of the motivations for this patchset.
This patch:
rename desc->handler to desc->chip.
Originally i did not want to do this, because it's a big patch. But having
both "desc->handler", "desc->handle_irq" and "action->handler" caused a
large degree of confusion and made the code appear alot less clean than it
truly is.
I have also attempted a dual approach as well by introducing a
desc->chip alias - but that just wasnt robust enough and broke
frequently.
So lets get over with this quickly. The conversion was done automatically
via scripts and converts all the code in the kernel.
This renaming patch is the first one amongst the patches, so that the
remaining patches can stay flexible and can be merged and split up
without having some big monolithic patch act as a merge barrier.
[akpm@osdl.org: build fix]
[akpm@osdl.org: another build fix]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-29 09:24:36 +00:00
|
|
|
if (desc && desc->chip && desc->chip->startup) {
|
2005-04-16 22:20:36 +00:00
|
|
|
spin_lock_irqsave(&desc->lock, flags);
|
[PATCH] genirq: rename desc->handler to desc->chip
This patch-queue improves the generic IRQ layer to be truly generic, by adding
various abstractions and features to it, without impacting existing
functionality.
While the queue can be best described as "fix and improve everything in the
generic IRQ layer that we could think of", and thus it consists of many
smaller features and lots of cleanups, the one feature that stands out most is
the new 'irq chip' abstraction.
The irq-chip abstraction is about describing and coding and IRQ controller
driver by mapping its raw hardware capabilities [and quirks, if needed] in a
straightforward way, without having to think about "IRQ flow"
(level/edge/etc.) type of details.
This stands in contrast with the current 'irq-type' model of genirq
architectures, which 'mixes' raw hardware capabilities with 'flow' details.
The patchset supports both types of irq controller designs at once, and
converts i386 and x86_64 to the new irq-chip design.
As a bonus side-effect of the irq-chip approach, chained interrupt controllers
(master/slave PIC constructs, etc.) are now supported by design as well.
The end result of this patchset intends to be simpler architecture-level code
and more consolidation between architectures.
We reused many bits of code and many concepts from Russell King's ARM IRQ
layer, the merging of which was one of the motivations for this patchset.
This patch:
rename desc->handler to desc->chip.
Originally i did not want to do this, because it's a big patch. But having
both "desc->handler", "desc->handle_irq" and "action->handler" caused a
large degree of confusion and made the code appear alot less clean than it
truly is.
I have also attempted a dual approach as well by introducing a
desc->chip alias - but that just wasnt robust enough and broke
frequently.
So lets get over with this quickly. The conversion was done automatically
via scripts and converts all the code in the kernel.
This renaming patch is the first one amongst the patches, so that the
remaining patches can stay flexible and can be merged and split up
without having some big monolithic patch act as a merge barrier.
[akpm@osdl.org: build fix]
[akpm@osdl.org: another build fix]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-29 09:24:36 +00:00
|
|
|
desc->chip->startup(irq);
|
2005-04-16 22:20:36 +00:00
|
|
|
spin_unlock_irqrestore(&desc->lock, flags);
|
|
|
|
}
|
2005-06-22 00:15:49 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* this is not called anywhere currently */
|
2005-11-16 06:47:43 +00:00
|
|
|
static void iseries_shutdown_IRQ(unsigned int irq)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2005-11-16 06:47:43 +00:00
|
|
|
u32 bus, dev_id, function, mask;
|
|
|
|
const u32 sub_bus = 0;
|
2006-07-03 11:36:01 +00:00
|
|
|
unsigned int rirq = (unsigned int)irq_map[irq].hwirq;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* irq should be locked by the caller */
|
|
|
|
bus = REAL_IRQ_TO_BUS(rirq);
|
|
|
|
function = REAL_IRQ_TO_FUNC(rirq);
|
2005-11-16 06:47:43 +00:00
|
|
|
dev_id = (REAL_IRQ_TO_IDSEL(rirq) << 4) + function;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Invalidate the IRQ number in the bridge */
|
2005-11-16 06:47:43 +00:00
|
|
|
HvCallXm_connectBusUnit(bus, sub_bus, dev_id, 0);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Mask bridge interrupts in the FISR */
|
|
|
|
mask = 0x01010000 << function;
|
2005-11-16 06:47:43 +00:00
|
|
|
HvCallPci_maskFisr(bus, sub_bus, dev_id, mask);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This will be called by device drivers (via disable_IRQ)
|
|
|
|
* to disable INTA in the bridge interrupt status register.
|
|
|
|
*/
|
2005-11-16 06:47:43 +00:00
|
|
|
static void iseries_disable_IRQ(unsigned int irq)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2005-11-16 06:47:43 +00:00
|
|
|
u32 bus, dev_id, function, mask;
|
|
|
|
const u32 sub_bus = 0;
|
2006-07-03 11:36:01 +00:00
|
|
|
unsigned int rirq = (unsigned int)irq_map[irq].hwirq;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* The IRQ has already been locked by the caller */
|
|
|
|
bus = REAL_IRQ_TO_BUS(rirq);
|
|
|
|
function = REAL_IRQ_TO_FUNC(rirq);
|
2005-11-16 06:47:43 +00:00
|
|
|
dev_id = (REAL_IRQ_TO_IDSEL(rirq) << 4) + function;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Mask secondary INTA */
|
|
|
|
mask = 0x80000000;
|
2005-11-16 06:47:43 +00:00
|
|
|
HvCallPci_maskInterrupts(bus, sub_bus, dev_id, mask);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2005-11-16 06:47:43 +00:00
|
|
|
static void iseries_end_IRQ(unsigned int irq)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2006-07-03 11:36:01 +00:00
|
|
|
unsigned int rirq = (unsigned int)irq_map[irq].hwirq;
|
2005-11-16 07:10:40 +00:00
|
|
|
|
|
|
|
HvCallPci_eoi(REAL_IRQ_TO_BUS(rirq), REAL_IRQ_TO_SUBBUS(rirq),
|
|
|
|
(REAL_IRQ_TO_IDSEL(rirq) << 4) + REAL_IRQ_TO_FUNC(rirq));
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2005-06-22 00:15:49 +00:00
|
|
|
|
2006-07-03 09:32:51 +00:00
|
|
|
static struct irq_chip iseries_pic = {
|
|
|
|
.typename = "iSeries irq controller",
|
|
|
|
.startup = iseries_startup_IRQ,
|
|
|
|
.shutdown = iseries_shutdown_IRQ,
|
|
|
|
.unmask = iseries_enable_IRQ,
|
|
|
|
.mask = iseries_disable_IRQ,
|
|
|
|
.eoi = iseries_end_IRQ
|
2005-06-22 00:15:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is called out of iSeries_scan_slot to allocate an IRQ for an EADS slot
|
|
|
|
* It calculates the irq value for the slot.
|
2005-11-16 07:10:40 +00:00
|
|
|
* Note that sub_bus is always 0 (at the moment at least).
|
2005-06-22 00:15:49 +00:00
|
|
|
*/
|
2005-11-16 07:10:40 +00:00
|
|
|
int __init iSeries_allocate_IRQ(HvBusNumber bus,
|
2006-05-19 06:46:28 +00:00
|
|
|
HvSubBusNumber sub_bus, u32 bsubbus)
|
2005-06-22 00:15:49 +00:00
|
|
|
{
|
2005-11-10 07:11:19 +00:00
|
|
|
unsigned int realirq;
|
2006-05-19 06:46:28 +00:00
|
|
|
u8 idsel = ISERIES_GET_DEVICE_FROM_SUBBUS(bsubbus);
|
|
|
|
u8 function = ISERIES_GET_FUNCTION_FROM_SUBBUS(bsubbus);
|
2005-06-22 00:15:49 +00:00
|
|
|
|
2005-11-16 07:10:40 +00:00
|
|
|
realirq = (((((sub_bus << 8) + (bus - 1)) << 3) + (idsel - 1)) << 3)
|
|
|
|
+ function;
|
2006-07-03 11:36:01 +00:00
|
|
|
|
[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
|
|
|
return irq_create_mapping(NULL, realirq);
|
2005-06-22 00:15:49 +00:00
|
|
|
}
|
2005-11-16 07:53:29 +00:00
|
|
|
|
2006-01-12 02:54:20 +00:00
|
|
|
#endif /* CONFIG_PCI */
|
|
|
|
|
2005-11-16 07:53:29 +00:00
|
|
|
/*
|
|
|
|
* Get the next pending IRQ.
|
|
|
|
*/
|
2006-10-07 12:08:26 +00:00
|
|
|
unsigned int iSeries_get_irq(void)
|
2005-11-16 07:53:29 +00:00
|
|
|
{
|
2006-07-03 11:36:01 +00:00
|
|
|
int irq = NO_IRQ_IGNORE;
|
2005-11-16 07:53:29 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
2006-01-12 23:26:42 +00:00
|
|
|
if (get_lppaca()->int_dword.fields.ipi_cnt) {
|
|
|
|
get_lppaca()->int_dword.fields.ipi_cnt = 0;
|
2006-10-06 03:55:26 +00:00
|
|
|
iSeries_smp_message_recv();
|
2005-11-16 07:53:29 +00:00
|
|
|
}
|
|
|
|
#endif /* CONFIG_SMP */
|
|
|
|
if (hvlpevent_is_pending())
|
2006-10-07 12:08:26 +00:00
|
|
|
process_hvlpevents();
|
2005-11-16 07:53:29 +00:00
|
|
|
|
2006-01-12 02:54:20 +00:00
|
|
|
#ifdef CONFIG_PCI
|
2005-11-17 07:04:37 +00:00
|
|
|
if (num_pending_irqs) {
|
|
|
|
spin_lock(&pending_irqs_lock);
|
|
|
|
for (irq = 0; irq < NR_IRQS; irq++) {
|
|
|
|
if (pending_irqs[irq]) {
|
|
|
|
pending_irqs[irq]--;
|
|
|
|
num_pending_irqs--;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
spin_unlock(&pending_irqs_lock);
|
|
|
|
if (irq >= NR_IRQS)
|
2006-07-03 11:36:01 +00:00
|
|
|
irq = NO_IRQ_IGNORE;
|
2005-11-17 07:04:37 +00:00
|
|
|
}
|
2006-01-12 02:54:20 +00:00
|
|
|
#endif
|
2005-11-17 07:04:37 +00:00
|
|
|
|
|
|
|
return irq;
|
2005-11-16 07:53:29 +00:00
|
|
|
}
|
2006-07-03 11:36:01 +00:00
|
|
|
|
2007-03-04 06:03:48 +00:00
|
|
|
#ifdef CONFIG_PCI
|
|
|
|
|
2006-07-03 11:36:01 +00:00
|
|
|
static int iseries_irq_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
|
|
|
{
|
|
|
|
set_irq_chip_and_handler(virq, &iseries_pic, handle_fasteoi_irq);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct irq_host_ops iseries_irq_host_ops = {
|
|
|
|
.map = iseries_irq_host_map,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is called by init_IRQ. set in ppc_md.init_IRQ by iSeries_setup.c
|
|
|
|
* It must be called before the bus walk.
|
|
|
|
*/
|
|
|
|
void __init iSeries_init_IRQ(void)
|
|
|
|
{
|
|
|
|
/* Register PCI event handler and open an event path */
|
|
|
|
struct irq_host *host;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The Hypervisor only allows us up to 256 interrupt
|
|
|
|
* sources (the irq number is passed in a u8).
|
|
|
|
*/
|
|
|
|
irq_set_virq_count(256);
|
|
|
|
|
|
|
|
/* Create irq host. No need for a revmap since HV will give us
|
|
|
|
* back our virtual irq number
|
|
|
|
*/
|
|
|
|
host = irq_alloc_host(IRQ_HOST_MAP_NOMAP, 0, &iseries_irq_host_ops, 0);
|
|
|
|
BUG_ON(host == NULL);
|
|
|
|
irq_set_default_host(host);
|
|
|
|
|
|
|
|
ret = HvLpEvent_registerHandler(HvLpEvent_Type_PciIo,
|
|
|
|
&pci_event_handler);
|
|
|
|
if (ret == 0) {
|
|
|
|
ret = HvLpEvent_openPath(HvLpEvent_Type_PciIo, 0);
|
|
|
|
if (ret != 0)
|
|
|
|
printk(KERN_ERR "iseries_init_IRQ: open event path "
|
|
|
|
"failed with rc 0x%x\n", ret);
|
|
|
|
} else
|
|
|
|
printk(KERN_ERR "iseries_init_IRQ: register handler "
|
|
|
|
"failed with rc 0x%x\n", ret);
|
|
|
|
}
|
|
|
|
|
2007-03-04 06:03:48 +00:00
|
|
|
#endif /* CONFIG_PCI */
|