2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Platform dependent support for SGI SN
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*
|
2008-12-09 01:44:11 +08:00
|
|
|
* Copyright (c) 2000-2008 Silicon Graphics, Inc. All Rights Reserved.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/irq.h>
|
2005-07-07 05:59:44 +08:00
|
|
|
#include <linux/spinlock.h>
|
2006-02-02 18:15:51 +08:00
|
|
|
#include <linux/init.h>
|
2008-05-13 03:21:05 +08:00
|
|
|
#include <linux/rculist.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/sn/addrs.h>
|
|
|
|
#include <asm/sn/arch.h>
|
2005-07-07 06:26:51 +08:00
|
|
|
#include <asm/sn/intr.h>
|
|
|
|
#include <asm/sn/pcibr_provider.h>
|
2005-04-26 02:32:16 +08:00
|
|
|
#include <asm/sn/pcibus_provider_defs.h>
|
|
|
|
#include <asm/sn/pcidev.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/sn/shub_mmr.h>
|
|
|
|
#include <asm/sn/sn_sal.h>
|
2007-08-23 08:32:06 +08:00
|
|
|
#include <asm/sn/sn_feature_sets.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static void register_intr_pda(struct sn_irq_info *sn_irq_info);
|
|
|
|
static void unregister_intr_pda(struct sn_irq_info *sn_irq_info);
|
|
|
|
|
|
|
|
extern int sn_ioif_inited;
|
2006-04-15 05:03:54 +08:00
|
|
|
struct list_head **sn_irq_lh;
|
2006-06-27 17:53:55 +08:00
|
|
|
static DEFINE_SPINLOCK(sn_irq_info_lock); /* non-IRQ lock */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-04-15 05:03:54 +08:00
|
|
|
u64 sn_intr_alloc(nasid_t local_nasid, int local_widget,
|
|
|
|
struct sn_irq_info *sn_irq_info,
|
2005-04-17 06:20:36 +08:00
|
|
|
int req_irq, nasid_t req_nasid,
|
|
|
|
int req_slice)
|
|
|
|
{
|
|
|
|
struct ia64_sal_retval ret_stuff;
|
|
|
|
ret_stuff.status = 0;
|
|
|
|
ret_stuff.v0 = 0;
|
|
|
|
|
|
|
|
SAL_CALL_NOLOCK(ret_stuff, (u64) SN_SAL_IOIF_INTERRUPT,
|
|
|
|
(u64) SAL_INTR_ALLOC, (u64) local_nasid,
|
2006-04-15 05:03:54 +08:00
|
|
|
(u64) local_widget, __pa(sn_irq_info), (u64) req_irq,
|
2005-04-17 06:20:36 +08:00
|
|
|
(u64) req_nasid, (u64) req_slice);
|
2006-04-15 05:03:54 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
return ret_stuff.status;
|
|
|
|
}
|
|
|
|
|
2006-04-15 05:03:54 +08:00
|
|
|
void sn_intr_free(nasid_t local_nasid, int local_widget,
|
2005-04-17 06:20:36 +08:00
|
|
|
struct sn_irq_info *sn_irq_info)
|
|
|
|
{
|
|
|
|
struct ia64_sal_retval ret_stuff;
|
|
|
|
ret_stuff.status = 0;
|
|
|
|
ret_stuff.v0 = 0;
|
|
|
|
|
|
|
|
SAL_CALL_NOLOCK(ret_stuff, (u64) SN_SAL_IOIF_INTERRUPT,
|
|
|
|
(u64) SAL_INTR_FREE, (u64) local_nasid,
|
|
|
|
(u64) local_widget, (u64) sn_irq_info->irq_irq,
|
|
|
|
(u64) sn_irq_info->irq_cookie, 0, 0);
|
|
|
|
}
|
|
|
|
|
2007-05-02 22:09:18 +08:00
|
|
|
u64 sn_intr_redirect(nasid_t local_nasid, int local_widget,
|
|
|
|
struct sn_irq_info *sn_irq_info,
|
|
|
|
nasid_t req_nasid, int req_slice)
|
|
|
|
{
|
|
|
|
struct ia64_sal_retval ret_stuff;
|
|
|
|
ret_stuff.status = 0;
|
|
|
|
ret_stuff.v0 = 0;
|
|
|
|
|
|
|
|
SAL_CALL_NOLOCK(ret_stuff, (u64) SN_SAL_IOIF_INTERRUPT,
|
|
|
|
(u64) SAL_INTR_REDIRECT, (u64) local_nasid,
|
|
|
|
(u64) local_widget, __pa(sn_irq_info),
|
|
|
|
(u64) req_nasid, (u64) req_slice, 0);
|
|
|
|
|
|
|
|
return ret_stuff.status;
|
|
|
|
}
|
|
|
|
|
2011-02-05 03:08:36 +08:00
|
|
|
static unsigned int sn_startup_irq(struct irq_data *data)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-02-05 03:08:36 +08:00
|
|
|
static void sn_shutdown_irq(struct irq_data *data)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-11-01 00:10:38 +08:00
|
|
|
extern void ia64_mca_register_cpev(int);
|
|
|
|
|
2011-02-05 03:08:36 +08:00
|
|
|
static void sn_disable_irq(struct irq_data *data)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2011-02-05 03:08:36 +08:00
|
|
|
if (data->irq == local_vector_to_irq(IA64_CPE_VECTOR))
|
2007-11-01 00:10:38 +08:00
|
|
|
ia64_mca_register_cpev(0);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2011-02-05 03:08:36 +08:00
|
|
|
static void sn_enable_irq(struct irq_data *data)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2011-02-05 03:08:36 +08:00
|
|
|
if (data->irq == local_vector_to_irq(IA64_CPE_VECTOR))
|
|
|
|
ia64_mca_register_cpev(data->irq);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2011-02-05 03:08:36 +08:00
|
|
|
static void sn_ack_irq(struct irq_data *data)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2006-02-02 18:15:51 +08:00
|
|
|
u64 event_occurred, mask;
|
2011-02-05 03:08:36 +08:00
|
|
|
unsigned int irq = data->irq & 0xff;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-02-02 18:15:51 +08:00
|
|
|
event_occurred = HUB_L((u64*)LOCAL_MMR_ADDR(SH_EVENT_OCCURRED));
|
2005-04-26 04:06:28 +08:00
|
|
|
mask = event_occurred & SH_ALL_INT_MASK;
|
2006-02-02 18:15:51 +08:00
|
|
|
HUB_S((u64*)LOCAL_MMR_ADDR(SH_EVENT_OCCURRED_ALIAS), mask);
|
2005-04-17 06:20:36 +08:00
|
|
|
__set_bit(irq, (volatile void *)pda->sn_in_service_ivecs);
|
|
|
|
|
2011-03-26 03:35:17 +08:00
|
|
|
irq_move_irq(data);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2006-04-15 05:03:54 +08:00
|
|
|
struct sn_irq_info *sn_retarget_vector(struct sn_irq_info *sn_irq_info,
|
|
|
|
nasid_t nasid, int slice)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2006-04-15 05:03:54 +08:00
|
|
|
int vector;
|
2006-11-07 04:10:50 +08:00
|
|
|
int cpuid;
|
|
|
|
#ifdef CONFIG_SMP
|
2006-04-15 05:03:54 +08:00
|
|
|
int cpuphys;
|
2006-11-07 04:10:50 +08:00
|
|
|
#endif
|
2006-04-15 05:03:54 +08:00
|
|
|
int64_t bridge;
|
|
|
|
int local_widget, status;
|
|
|
|
nasid_t local_nasid;
|
|
|
|
struct sn_irq_info *new_irq_info;
|
|
|
|
struct sn_pcibus_provider *pci_provider;
|
|
|
|
|
2007-05-02 22:09:18 +08:00
|
|
|
bridge = (u64) sn_irq_info->irq_bridge;
|
2006-04-15 05:03:54 +08:00
|
|
|
if (!bridge) {
|
|
|
|
return NULL; /* irq is not a device interrupt */
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-04-15 05:03:54 +08:00
|
|
|
local_nasid = NASID_GET(bridge);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-04-15 05:03:54 +08:00
|
|
|
if (local_nasid & 1)
|
|
|
|
local_widget = TIO_SWIN_WIDGETNUM(bridge);
|
|
|
|
else
|
|
|
|
local_widget = SWIN_WIDGETNUM(bridge);
|
|
|
|
vector = sn_irq_info->irq_irq;
|
2007-05-02 22:09:18 +08:00
|
|
|
|
|
|
|
/* Make use of SAL_INTR_REDIRECT if PROM supports it */
|
|
|
|
status = sn_intr_redirect(local_nasid, local_widget, sn_irq_info, nasid, slice);
|
|
|
|
if (!status) {
|
|
|
|
new_irq_info = sn_irq_info;
|
|
|
|
goto finish_up;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PROM does not support SAL_INTR_REDIRECT, or it failed.
|
|
|
|
* Revert to old method.
|
|
|
|
*/
|
2011-11-18 06:43:40 +08:00
|
|
|
new_irq_info = kmemdup(sn_irq_info, sizeof(struct sn_irq_info),
|
|
|
|
GFP_ATOMIC);
|
2007-05-02 22:09:18 +08:00
|
|
|
if (new_irq_info == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2006-04-15 05:03:54 +08:00
|
|
|
/* Free the old PROM new_irq_info structure */
|
|
|
|
sn_intr_free(local_nasid, local_widget, new_irq_info);
|
|
|
|
unregister_intr_pda(new_irq_info);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-04-15 05:03:54 +08:00
|
|
|
/* allocate a new PROM new_irq_info struct */
|
|
|
|
status = sn_intr_alloc(local_nasid, local_widget,
|
|
|
|
new_irq_info, vector,
|
|
|
|
nasid, slice);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-04-15 05:03:54 +08:00
|
|
|
/* SAL call failed */
|
|
|
|
if (status) {
|
|
|
|
kfree(new_irq_info);
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-07-07 05:59:44 +08:00
|
|
|
|
2007-05-02 22:09:18 +08:00
|
|
|
register_intr_pda(new_irq_info);
|
|
|
|
spin_lock(&sn_irq_info_lock);
|
|
|
|
list_replace_rcu(&sn_irq_info->list, &new_irq_info->list);
|
|
|
|
spin_unlock(&sn_irq_info_lock);
|
2011-03-18 11:48:01 +08:00
|
|
|
kfree_rcu(sn_irq_info, rcu);
|
2007-05-02 22:09:18 +08:00
|
|
|
|
|
|
|
|
|
|
|
finish_up:
|
2006-11-07 04:10:50 +08:00
|
|
|
/* Update kernels new_irq_info with new target info */
|
|
|
|
cpuid = nasid_slice_to_cpuid(new_irq_info->irq_nasid,
|
|
|
|
new_irq_info->irq_slice);
|
|
|
|
new_irq_info->irq_cpuid = cpuid;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-04-15 05:03:54 +08:00
|
|
|
pci_provider = sn_pci_provider[new_irq_info->irq_bridge_type];
|
2005-07-07 05:59:44 +08:00
|
|
|
|
2006-04-15 05:03:54 +08:00
|
|
|
/*
|
|
|
|
* If this represents a line interrupt, target it. If it's
|
|
|
|
* an msi (irq_int_bit < 0), it's already targeted.
|
|
|
|
*/
|
|
|
|
if (new_irq_info->irq_int_bit >= 0 &&
|
|
|
|
pci_provider && pci_provider->target_interrupt)
|
|
|
|
(pci_provider->target_interrupt)(new_irq_info);
|
2005-07-07 05:59:44 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#ifdef CONFIG_SMP
|
2006-11-07 04:10:50 +08:00
|
|
|
cpuphys = cpu_physical_id(cpuid);
|
2006-04-15 05:03:54 +08:00
|
|
|
set_irq_affinity_info((vector & 0xff), cpuphys, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
2006-04-15 05:03:54 +08:00
|
|
|
|
|
|
|
return new_irq_info;
|
|
|
|
}
|
|
|
|
|
2011-02-05 03:08:36 +08:00
|
|
|
static int sn_set_affinity_irq(struct irq_data *data,
|
|
|
|
const struct cpumask *mask, bool force)
|
2006-04-15 05:03:54 +08:00
|
|
|
{
|
|
|
|
struct sn_irq_info *sn_irq_info, *sn_irq_info_safe;
|
2011-02-05 03:08:36 +08:00
|
|
|
unsigned int irq = data->irq;
|
2006-04-15 05:03:54 +08:00
|
|
|
nasid_t nasid;
|
|
|
|
int slice;
|
|
|
|
|
2008-12-13 18:50:26 +08:00
|
|
|
nasid = cpuid_to_nasid(cpumask_first(mask));
|
|
|
|
slice = cpuid_to_slice(cpumask_first(mask));
|
2006-04-15 05:03:54 +08:00
|
|
|
|
|
|
|
list_for_each_entry_safe(sn_irq_info, sn_irq_info_safe,
|
|
|
|
sn_irq_lh[irq], list)
|
|
|
|
(void)sn_retarget_vector(sn_irq_info, nasid, slice);
|
2009-04-28 08:59:21 +08:00
|
|
|
|
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-08-23 08:32:06 +08:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
void sn_set_err_irq_affinity(unsigned int irq)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* On systems which support CPU disabling (SHub2), all error interrupts
|
2011-03-31 09:57:33 +08:00
|
|
|
* are targeted at the boot CPU.
|
2007-08-23 08:32:06 +08:00
|
|
|
*/
|
|
|
|
if (is_shub2() && sn_prom_feature_available(PRF_CPU_DISABLE_SUPPORT))
|
|
|
|
set_irq_affinity_info(irq, cpu_physical_id(0), 0);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
void sn_set_err_irq_affinity(unsigned int irq) { }
|
|
|
|
#endif
|
|
|
|
|
2007-03-08 06:57:35 +08:00
|
|
|
static void
|
2011-02-05 03:08:36 +08:00
|
|
|
sn_mask_irq(struct irq_data *data)
|
2007-03-08 06:57:35 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-02-05 03:08:36 +08:00
|
|
|
sn_unmask_irq(struct irq_data *data)
|
2007-03-08 06:57:35 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
struct irq_chip irq_type_sn = {
|
2011-02-05 03:08:36 +08:00
|
|
|
.name = "SN hub",
|
|
|
|
.irq_startup = sn_startup_irq,
|
|
|
|
.irq_shutdown = sn_shutdown_irq,
|
|
|
|
.irq_enable = sn_enable_irq,
|
|
|
|
.irq_disable = sn_disable_irq,
|
|
|
|
.irq_ack = sn_ack_irq,
|
|
|
|
.irq_mask = sn_mask_irq,
|
|
|
|
.irq_unmask = sn_unmask_irq,
|
|
|
|
.irq_set_affinity = sn_set_affinity_irq
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2007-08-14 01:31:26 +08:00
|
|
|
ia64_vector sn_irq_to_vector(int irq)
|
|
|
|
{
|
|
|
|
if (irq >= IA64_NUM_VECTORS)
|
|
|
|
return 0;
|
|
|
|
return (ia64_vector)irq;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned int sn_local_vector_to_irq(u8 vector)
|
|
|
|
{
|
|
|
|
return (CPU_VECTOR_TO_IRQ(smp_processor_id(), vector));
|
|
|
|
}
|
|
|
|
|
|
|
|
void sn_irq_init(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2006-04-15 05:03:49 +08:00
|
|
|
ia64_first_device_vector = IA64_SN2_FIRST_DEVICE_VECTOR;
|
|
|
|
ia64_last_device_vector = IA64_SN2_LAST_DEVICE_VECTOR;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
for (i = 0; i < NR_IRQS; i++) {
|
2011-03-24 23:44:38 +08:00
|
|
|
if (irq_get_chip(i) == &no_irq_chip)
|
|
|
|
irq_set_chip(i, &irq_type_sn);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void register_intr_pda(struct sn_irq_info *sn_irq_info)
|
|
|
|
{
|
|
|
|
int irq = sn_irq_info->irq_irq;
|
|
|
|
int cpu = sn_irq_info->irq_cpuid;
|
|
|
|
|
|
|
|
if (pdacpu(cpu)->sn_last_irq < irq) {
|
|
|
|
pdacpu(cpu)->sn_last_irq = irq;
|
|
|
|
}
|
|
|
|
|
2006-02-02 18:15:51 +08:00
|
|
|
if (pdacpu(cpu)->sn_first_irq == 0 || pdacpu(cpu)->sn_first_irq > irq)
|
2005-04-17 06:20:36 +08:00
|
|
|
pdacpu(cpu)->sn_first_irq = irq;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void unregister_intr_pda(struct sn_irq_info *sn_irq_info)
|
|
|
|
{
|
|
|
|
int irq = sn_irq_info->irq_irq;
|
|
|
|
int cpu = sn_irq_info->irq_cpuid;
|
|
|
|
struct sn_irq_info *tmp_irq_info;
|
|
|
|
int i, foundmatch;
|
|
|
|
|
2005-07-07 05:59:44 +08:00
|
|
|
rcu_read_lock();
|
2005-04-17 06:20:36 +08:00
|
|
|
if (pdacpu(cpu)->sn_last_irq == irq) {
|
|
|
|
foundmatch = 0;
|
2005-07-07 05:59:44 +08:00
|
|
|
for (i = pdacpu(cpu)->sn_last_irq - 1;
|
|
|
|
i && !foundmatch; i--) {
|
|
|
|
list_for_each_entry_rcu(tmp_irq_info,
|
|
|
|
sn_irq_lh[i],
|
|
|
|
list) {
|
2005-04-17 06:20:36 +08:00
|
|
|
if (tmp_irq_info->irq_cpuid == cpu) {
|
2005-07-07 05:59:44 +08:00
|
|
|
foundmatch = 1;
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pdacpu(cpu)->sn_last_irq = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pdacpu(cpu)->sn_first_irq == irq) {
|
|
|
|
foundmatch = 0;
|
2005-07-07 05:59:44 +08:00
|
|
|
for (i = pdacpu(cpu)->sn_first_irq + 1;
|
|
|
|
i < NR_IRQS && !foundmatch; i++) {
|
|
|
|
list_for_each_entry_rcu(tmp_irq_info,
|
|
|
|
sn_irq_lh[i],
|
|
|
|
list) {
|
2005-04-17 06:20:36 +08:00
|
|
|
if (tmp_irq_info->irq_cpuid == cpu) {
|
2005-07-07 05:59:44 +08:00
|
|
|
foundmatch = 1;
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pdacpu(cpu)->sn_first_irq = ((i == NR_IRQS) ? 0 : i);
|
|
|
|
}
|
2005-07-07 05:59:44 +08:00
|
|
|
rcu_read_unlock();
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void sn_irq_fixup(struct pci_dev *pci_dev, struct sn_irq_info *sn_irq_info)
|
|
|
|
{
|
|
|
|
nasid_t nasid = sn_irq_info->irq_nasid;
|
|
|
|
int slice = sn_irq_info->irq_slice;
|
|
|
|
int cpu = nasid_slice_to_cpuid(nasid, slice);
|
2006-11-07 04:10:50 +08:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
int cpuphys;
|
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-07-07 05:59:44 +08:00
|
|
|
pci_dev_get(pci_dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
sn_irq_info->irq_cpuid = cpu;
|
|
|
|
sn_irq_info->irq_pciioinfo = SN_PCIDEV_INFO(pci_dev);
|
|
|
|
|
|
|
|
/* link it into the sn_irq[irq] list */
|
2005-07-07 05:59:44 +08:00
|
|
|
spin_lock(&sn_irq_info_lock);
|
|
|
|
list_add_rcu(&sn_irq_info->list, sn_irq_lh[sn_irq_info->irq_irq]);
|
2006-04-15 05:03:49 +08:00
|
|
|
reserve_irq_vector(sn_irq_info->irq_irq);
|
2012-02-23 03:11:06 +08:00
|
|
|
if (sn_irq_info->irq_int_bit != -1)
|
|
|
|
irq_set_handler(sn_irq_info->irq_irq, handle_level_irq);
|
2005-07-07 05:59:44 +08:00
|
|
|
spin_unlock(&sn_irq_info_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-02-02 18:15:51 +08:00
|
|
|
register_intr_pda(sn_irq_info);
|
2006-11-07 04:10:50 +08:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
cpuphys = cpu_physical_id(cpu);
|
|
|
|
set_irq_affinity_info(sn_irq_info->irq_irq, cpuphys, 0);
|
2008-12-09 01:44:11 +08:00
|
|
|
/*
|
|
|
|
* Affinity was set by the PROM, prevent it from
|
|
|
|
* being reset by the request_irq() path.
|
|
|
|
*/
|
2011-03-26 03:43:34 +08:00
|
|
|
irqd_mark_affinity_was_set(irq_get_irq_data(sn_irq_info->irq_irq));
|
2006-11-07 04:10:50 +08:00
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-07-07 05:59:44 +08:00
|
|
|
void sn_irq_unfixup(struct pci_dev *pci_dev)
|
|
|
|
{
|
|
|
|
struct sn_irq_info *sn_irq_info;
|
|
|
|
|
|
|
|
/* Only cleanup IRQ stuff if this device has a host bus context */
|
|
|
|
if (!SN_PCIDEV_BUSSOFT(pci_dev))
|
|
|
|
return;
|
|
|
|
|
|
|
|
sn_irq_info = SN_PCIDEV_INFO(pci_dev)->pdi_sn_irq_info;
|
2006-02-10 06:12:24 +08:00
|
|
|
if (!sn_irq_info)
|
|
|
|
return;
|
|
|
|
if (!sn_irq_info->irq_irq) {
|
2005-07-07 06:29:53 +08:00
|
|
|
kfree(sn_irq_info);
|
2005-07-07 05:59:44 +08:00
|
|
|
return;
|
2005-07-07 06:29:53 +08:00
|
|
|
}
|
2005-07-07 05:59:44 +08:00
|
|
|
|
|
|
|
unregister_intr_pda(sn_irq_info);
|
|
|
|
spin_lock(&sn_irq_info_lock);
|
|
|
|
list_del_rcu(&sn_irq_info->list);
|
|
|
|
spin_unlock(&sn_irq_info_lock);
|
2006-04-15 05:03:49 +08:00
|
|
|
if (list_empty(sn_irq_lh[sn_irq_info->irq_irq]))
|
|
|
|
free_irq_vector(sn_irq_info->irq_irq);
|
2011-03-18 11:48:01 +08:00
|
|
|
kfree_rcu(sn_irq_info, rcu);
|
2005-07-07 05:59:44 +08:00
|
|
|
pci_dev_put(pci_dev);
|
2006-04-15 05:03:49 +08:00
|
|
|
|
2005-07-07 05:59:44 +08:00
|
|
|
}
|
|
|
|
|
2005-08-04 05:06:00 +08:00
|
|
|
static inline void
|
|
|
|
sn_call_force_intr_provider(struct sn_irq_info *sn_irq_info)
|
|
|
|
{
|
|
|
|
struct sn_pcibus_provider *pci_provider;
|
|
|
|
|
|
|
|
pci_provider = sn_pci_provider[sn_irq_info->irq_bridge_type];
|
2007-08-14 06:13:08 +08:00
|
|
|
|
|
|
|
/* Don't force an interrupt if the irq has been disabled */
|
2011-04-02 01:56:03 +08:00
|
|
|
if (!irqd_irq_disabled(irq_get_irq_data(sn_irq_info->irq_irq)) &&
|
2007-08-14 06:13:08 +08:00
|
|
|
pci_provider && pci_provider->force_interrupt)
|
2005-08-04 05:06:00 +08:00
|
|
|
(*pci_provider->force_interrupt)(sn_irq_info);
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Check for lost interrupts. If the PIC int_status reg. says that
|
|
|
|
* an interrupt has been sent, but not handled, and the interrupt
|
|
|
|
* is not pending in either the cpu irr regs or in the soft irr regs,
|
|
|
|
* and the interrupt is not in service, then the interrupt may have
|
|
|
|
* been lost. Force an interrupt on that pin. It is possible that
|
|
|
|
* the interrupt is in flight, so we may generate a spurious interrupt,
|
|
|
|
* but we should never miss a real lost interrupt.
|
|
|
|
*/
|
|
|
|
static void sn_check_intr(int irq, struct sn_irq_info *sn_irq_info)
|
|
|
|
{
|
2006-01-17 11:54:40 +08:00
|
|
|
u64 regval;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct pcidev_info *pcidev_info;
|
|
|
|
struct pcibus_info *pcibus_info;
|
|
|
|
|
2005-08-04 05:06:00 +08:00
|
|
|
/*
|
|
|
|
* Bridge types attached to TIO (anything but PIC) do not need this WAR
|
|
|
|
* since they do not target Shub II interrupt registers. If that
|
2011-03-31 09:57:33 +08:00
|
|
|
* ever changes, this check needs to accommodate.
|
2005-08-04 05:06:00 +08:00
|
|
|
*/
|
|
|
|
if (sn_irq_info->irq_bridge_type != PCIIO_ASIC_TYPE_PIC)
|
|
|
|
return;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
pcidev_info = (struct pcidev_info *)sn_irq_info->irq_pciioinfo;
|
|
|
|
if (!pcidev_info)
|
|
|
|
return;
|
|
|
|
|
|
|
|
pcibus_info =
|
|
|
|
(struct pcibus_info *)pcidev_info->pdi_host_pcidev_info->
|
|
|
|
pdi_pcibus_info;
|
|
|
|
regval = pcireg_intr_status_get(pcibus_info);
|
|
|
|
|
2006-03-22 01:44:07 +08:00
|
|
|
if (!ia64_get_irr(irq_to_vector(irq))) {
|
2005-08-04 05:06:00 +08:00
|
|
|
if (!test_bit(irq, pda->sn_in_service_ivecs)) {
|
|
|
|
regval &= 0xff;
|
|
|
|
if (sn_irq_info->irq_int_bit & regval &
|
|
|
|
sn_irq_info->irq_last_intr) {
|
|
|
|
regval &= ~(sn_irq_info->irq_int_bit & regval);
|
|
|
|
sn_call_force_intr_provider(sn_irq_info);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sn_irq_info->irq_last_intr = regval;
|
|
|
|
}
|
|
|
|
|
|
|
|
void sn_lb_int_war_check(void)
|
|
|
|
{
|
2005-07-07 05:59:44 +08:00
|
|
|
struct sn_irq_info *sn_irq_info;
|
2005-04-17 06:20:36 +08:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!sn_ioif_inited || pda->sn_first_irq == 0)
|
|
|
|
return;
|
2005-07-07 05:59:44 +08:00
|
|
|
|
|
|
|
rcu_read_lock();
|
2005-04-17 06:20:36 +08:00
|
|
|
for (i = pda->sn_first_irq; i <= pda->sn_last_irq; i++) {
|
2005-07-07 05:59:44 +08:00
|
|
|
list_for_each_entry_rcu(sn_irq_info, sn_irq_lh[i], list) {
|
2005-08-04 05:06:00 +08:00
|
|
|
sn_check_intr(i, sn_irq_info);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
2005-07-07 05:59:44 +08:00
|
|
|
rcu_read_unlock();
|
|
|
|
}
|
|
|
|
|
2006-02-02 18:15:51 +08:00
|
|
|
void __init sn_irq_lh_init(void)
|
2005-07-07 05:59:44 +08:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
sn_irq_lh = kmalloc(sizeof(struct list_head *) * NR_IRQS, GFP_KERNEL);
|
|
|
|
if (!sn_irq_lh)
|
|
|
|
panic("SN PCI INIT: Failed to allocate memory for PCI init\n");
|
|
|
|
|
|
|
|
for (i = 0; i < NR_IRQS; i++) {
|
|
|
|
sn_irq_lh[i] = kmalloc(sizeof(struct list_head), GFP_KERNEL);
|
|
|
|
if (!sn_irq_lh[i])
|
|
|
|
panic("SN PCI INIT: Failed IRQ memory allocation\n");
|
|
|
|
|
|
|
|
INIT_LIST_HEAD(sn_irq_lh[i]);
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|