2006-04-11 02:17:48 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Silicon Graphics, Inc. All Rights Reserved.
|
|
|
|
*/
|
|
|
|
|
2006-04-14 21:03:54 +00:00
|
|
|
#include <linux/types.h>
|
2006-10-04 09:16:59 +00:00
|
|
|
#include <linux/irq.h>
|
2006-04-14 21:03:54 +00:00
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/cpumask.h>
|
2006-10-04 09:16:59 +00:00
|
|
|
#include <linux/msi.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 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2006-04-14 21:03:54 +00:00
|
|
|
|
|
|
|
#include <asm/sn/addrs.h>
|
|
|
|
#include <asm/sn/intr.h>
|
|
|
|
#include <asm/sn/pcibus_provider_defs.h>
|
|
|
|
#include <asm/sn/pcidev.h>
|
|
|
|
#include <asm/sn/nodepda.h>
|
|
|
|
|
|
|
|
struct sn_msi_info {
|
|
|
|
u64 pci_addr;
|
|
|
|
struct sn_irq_info *sn_irq_info;
|
|
|
|
};
|
|
|
|
|
2006-10-04 09:16:59 +00:00
|
|
|
static struct sn_msi_info sn_msi_info[NR_IRQS];
|
|
|
|
|
|
|
|
static struct irq_chip sn_msi_chip;
|
2006-04-14 21:03:54 +00:00
|
|
|
|
2006-10-04 09:16:59 +00:00
|
|
|
void sn_teardown_msi_irq(unsigned int irq)
|
2006-04-14 21:03:54 +00:00
|
|
|
{
|
|
|
|
nasid_t nasid;
|
|
|
|
int widget;
|
|
|
|
struct pci_dev *pdev;
|
|
|
|
struct pcidev_info *sn_pdev;
|
|
|
|
struct sn_irq_info *sn_irq_info;
|
|
|
|
struct pcibus_bussoft *bussoft;
|
|
|
|
struct sn_pcibus_provider *provider;
|
|
|
|
|
2006-10-04 09:16:34 +00:00
|
|
|
sn_irq_info = sn_msi_info[irq].sn_irq_info;
|
2006-04-14 21:03:54 +00:00
|
|
|
if (sn_irq_info == NULL || sn_irq_info->irq_int_bit >= 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
sn_pdev = (struct pcidev_info *)sn_irq_info->irq_pciioinfo;
|
|
|
|
pdev = sn_pdev->pdi_linux_pcidev;
|
|
|
|
provider = SN_PCIDEV_BUSPROVIDER(pdev);
|
|
|
|
|
|
|
|
(*provider->dma_unmap)(pdev,
|
2006-10-04 09:16:34 +00:00
|
|
|
sn_msi_info[irq].pci_addr,
|
2006-04-14 21:03:54 +00:00
|
|
|
PCI_DMA_FROMDEVICE);
|
2006-10-04 09:16:34 +00:00
|
|
|
sn_msi_info[irq].pci_addr = 0;
|
2006-04-14 21:03:54 +00:00
|
|
|
|
|
|
|
bussoft = SN_PCIDEV_BUSSOFT(pdev);
|
|
|
|
nasid = NASID_GET(bussoft->bs_base);
|
|
|
|
widget = (nasid & 1) ?
|
|
|
|
TIO_SWIN_WIDGETNUM(bussoft->bs_base) :
|
|
|
|
SWIN_WIDGETNUM(bussoft->bs_base);
|
|
|
|
|
|
|
|
sn_intr_free(nasid, widget, sn_irq_info);
|
2006-10-04 09:16:34 +00:00
|
|
|
sn_msi_info[irq].sn_irq_info = NULL;
|
2006-04-14 21:03:54 +00:00
|
|
|
|
2007-01-28 19:56:37 +00:00
|
|
|
destroy_irq(irq);
|
2006-04-14 21:03:54 +00:00
|
|
|
}
|
2006-04-11 02:17:48 +00:00
|
|
|
|
2007-01-28 19:56:37 +00:00
|
|
|
int sn_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *entry)
|
2006-04-11 02:17:48 +00:00
|
|
|
{
|
2006-10-04 09:16:59 +00:00
|
|
|
struct msi_msg msg;
|
2006-04-14 21:03:54 +00:00
|
|
|
int widget;
|
|
|
|
int status;
|
|
|
|
nasid_t nasid;
|
|
|
|
u64 bus_addr;
|
|
|
|
struct sn_irq_info *sn_irq_info;
|
|
|
|
struct pcibus_bussoft *bussoft = SN_PCIDEV_BUSSOFT(pdev);
|
|
|
|
struct sn_pcibus_provider *provider = SN_PCIDEV_BUSPROVIDER(pdev);
|
2007-01-28 19:56:37 +00:00
|
|
|
int irq;
|
2006-04-14 21:03:54 +00:00
|
|
|
|
2006-10-04 09:16:59 +00:00
|
|
|
if (!entry->msi_attrib.is_64)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2006-04-14 21:03:54 +00:00
|
|
|
if (bussoft == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (provider == NULL || provider->dma_map_consistent == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2007-01-28 19:56:37 +00:00
|
|
|
irq = create_irq();
|
|
|
|
if (irq < 0)
|
|
|
|
return irq;
|
|
|
|
|
2006-04-14 21:03:54 +00:00
|
|
|
/*
|
|
|
|
* Set up the vector plumbing. Let the prom (via sn_intr_alloc)
|
|
|
|
* decide which cpu to direct this msi at by default.
|
|
|
|
*/
|
|
|
|
|
|
|
|
nasid = NASID_GET(bussoft->bs_base);
|
|
|
|
widget = (nasid & 1) ?
|
|
|
|
TIO_SWIN_WIDGETNUM(bussoft->bs_base) :
|
|
|
|
SWIN_WIDGETNUM(bussoft->bs_base);
|
|
|
|
|
|
|
|
sn_irq_info = kzalloc(sizeof(struct sn_irq_info), GFP_KERNEL);
|
2007-01-28 19:56:37 +00:00
|
|
|
if (! sn_irq_info) {
|
|
|
|
destroy_irq(irq);
|
2006-04-14 21:03:54 +00:00
|
|
|
return -ENOMEM;
|
2007-01-28 19:56:37 +00:00
|
|
|
}
|
2006-04-14 21:03:54 +00:00
|
|
|
|
2006-10-04 09:16:34 +00:00
|
|
|
status = sn_intr_alloc(nasid, widget, sn_irq_info, irq, -1, -1);
|
2006-04-14 21:03:54 +00:00
|
|
|
if (status) {
|
|
|
|
kfree(sn_irq_info);
|
2007-01-28 19:56:37 +00:00
|
|
|
destroy_irq(irq);
|
2006-04-14 21:03:54 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
sn_irq_info->irq_int_bit = -1; /* mark this as an MSI irq */
|
|
|
|
sn_irq_fixup(pdev, sn_irq_info);
|
|
|
|
|
|
|
|
/* Prom probably should fill these in, but doesn't ... */
|
|
|
|
sn_irq_info->irq_bridge_type = bussoft->bs_asic_type;
|
|
|
|
sn_irq_info->irq_bridge = (void *)bussoft->bs_base;
|
|
|
|
|
2006-04-11 02:17:48 +00:00
|
|
|
/*
|
2006-04-14 21:03:54 +00:00
|
|
|
* Map the xio address into bus space
|
2006-04-11 02:17:48 +00:00
|
|
|
*/
|
2006-04-14 21:03:54 +00:00
|
|
|
bus_addr = (*provider->dma_map_consistent)(pdev,
|
|
|
|
sn_irq_info->irq_xtalkaddr,
|
|
|
|
sizeof(sn_irq_info->irq_xtalkaddr),
|
|
|
|
SN_DMA_MSI|SN_DMA_ADDR_XIO);
|
|
|
|
if (! bus_addr) {
|
|
|
|
sn_intr_free(nasid, widget, sn_irq_info);
|
|
|
|
kfree(sn_irq_info);
|
2007-01-28 19:56:37 +00:00
|
|
|
destroy_irq(irq);
|
2006-04-14 21:03:54 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2006-10-04 09:16:34 +00:00
|
|
|
sn_msi_info[irq].sn_irq_info = sn_irq_info;
|
|
|
|
sn_msi_info[irq].pci_addr = bus_addr;
|
2006-04-14 21:03:54 +00:00
|
|
|
|
2006-10-04 09:16:59 +00:00
|
|
|
msg.address_hi = (u32)(bus_addr >> 32);
|
|
|
|
msg.address_lo = (u32)(bus_addr & 0x00000000ffffffff);
|
2006-04-14 21:03:54 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* In the SN platform, bit 16 is a "send vector" bit which
|
|
|
|
* must be present in order to move the vector through the system.
|
|
|
|
*/
|
2006-10-04 09:16:59 +00:00
|
|
|
msg.data = 0x100 + irq;
|
2006-04-14 21:03:54 +00:00
|
|
|
|
2011-03-25 20:06:09 +00:00
|
|
|
irq_set_msi_desc(irq, entry);
|
2014-11-09 15:10:34 +00:00
|
|
|
pci_write_msi_msg(irq, &msg);
|
2011-03-25 20:06:09 +00:00
|
|
|
irq_set_chip_and_handler(irq, &sn_msi_chip, handle_edge_irq);
|
2006-10-04 09:16:59 +00:00
|
|
|
|
2007-04-18 09:39:21 +00:00
|
|
|
return 0;
|
2006-04-14 21:03:54 +00:00
|
|
|
}
|
|
|
|
|
2006-10-04 09:16:59 +00:00
|
|
|
#ifdef CONFIG_SMP
|
2011-02-04 19:02:09 +00:00
|
|
|
static int sn_set_msi_irq_affinity(struct irq_data *data,
|
|
|
|
const struct cpumask *cpu_mask, bool force)
|
2006-04-14 21:03:54 +00:00
|
|
|
{
|
2006-10-04 09:16:59 +00:00
|
|
|
struct msi_msg msg;
|
2006-04-14 21:03:54 +00:00
|
|
|
int slice;
|
|
|
|
nasid_t nasid;
|
|
|
|
u64 bus_addr;
|
|
|
|
struct pci_dev *pdev;
|
|
|
|
struct pcidev_info *sn_pdev;
|
|
|
|
struct sn_irq_info *sn_irq_info;
|
|
|
|
struct sn_irq_info *new_irq_info;
|
|
|
|
struct sn_pcibus_provider *provider;
|
2011-02-04 19:02:09 +00:00
|
|
|
unsigned int cpu, irq = data->irq;
|
2006-04-14 21:03:54 +00:00
|
|
|
|
2014-03-04 20:43:38 +00:00
|
|
|
cpu = cpumask_first_and(cpu_mask, cpu_online_mask);
|
2006-10-04 09:16:34 +00:00
|
|
|
sn_irq_info = sn_msi_info[irq].sn_irq_info;
|
2006-04-14 21:03:54 +00:00
|
|
|
if (sn_irq_info == NULL || sn_irq_info->irq_int_bit >= 0)
|
2009-04-28 00:59:21 +00:00
|
|
|
return -1;
|
2006-04-14 21:03:54 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Release XIO resources for the old MSI PCI address
|
|
|
|
*/
|
|
|
|
|
2015-06-01 08:05:42 +00:00
|
|
|
__get_cached_msi_msg(irq_data_get_msi_desc(data), &msg);
|
2014-09-23 05:27:25 +00:00
|
|
|
sn_pdev = (struct pcidev_info *)sn_irq_info->irq_pciioinfo;
|
2006-04-14 21:03:54 +00:00
|
|
|
pdev = sn_pdev->pdi_linux_pcidev;
|
|
|
|
provider = SN_PCIDEV_BUSPROVIDER(pdev);
|
|
|
|
|
2006-10-04 09:16:59 +00:00
|
|
|
bus_addr = (u64)(msg.address_hi) << 32 | (u64)(msg.address_lo);
|
2006-04-14 21:03:54 +00:00
|
|
|
(*provider->dma_unmap)(pdev, bus_addr, PCI_DMA_FROMDEVICE);
|
2006-10-04 09:16:34 +00:00
|
|
|
sn_msi_info[irq].pci_addr = 0;
|
2006-04-14 21:03:54 +00:00
|
|
|
|
|
|
|
nasid = cpuid_to_nasid(cpu);
|
|
|
|
slice = cpuid_to_slice(cpu);
|
|
|
|
|
|
|
|
new_irq_info = sn_retarget_vector(sn_irq_info, nasid, slice);
|
2006-10-04 09:16:34 +00:00
|
|
|
sn_msi_info[irq].sn_irq_info = new_irq_info;
|
2006-04-14 21:03:54 +00:00
|
|
|
if (new_irq_info == NULL)
|
2009-04-28 00:59:21 +00:00
|
|
|
return -1;
|
2006-04-14 21:03:54 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Map the xio address into bus space
|
|
|
|
*/
|
|
|
|
|
|
|
|
bus_addr = (*provider->dma_map_consistent)(pdev,
|
|
|
|
new_irq_info->irq_xtalkaddr,
|
|
|
|
sizeof(new_irq_info->irq_xtalkaddr),
|
|
|
|
SN_DMA_MSI|SN_DMA_ADDR_XIO);
|
|
|
|
|
2006-10-04 09:16:34 +00:00
|
|
|
sn_msi_info[irq].pci_addr = bus_addr;
|
2006-10-04 09:16:59 +00:00
|
|
|
msg.address_hi = (u32)(bus_addr >> 32);
|
|
|
|
msg.address_lo = (u32)(bus_addr & 0x00000000ffffffff);
|
|
|
|
|
2014-11-09 15:10:34 +00:00
|
|
|
pci_write_msi_msg(irq, &msg);
|
2011-02-04 19:02:09 +00:00
|
|
|
cpumask_copy(data->affinity, cpu_mask);
|
2009-04-28 00:59:21 +00:00
|
|
|
|
|
|
|
return 0;
|
2006-04-14 21:03:54 +00:00
|
|
|
}
|
2006-10-04 09:16:59 +00:00
|
|
|
#endif /* CONFIG_SMP */
|
2006-04-14 21:03:54 +00:00
|
|
|
|
2011-02-04 19:02:09 +00:00
|
|
|
static void sn_ack_msi_irq(struct irq_data *data)
|
2006-10-04 09:16:59 +00:00
|
|
|
{
|
2011-03-25 19:35:17 +00:00
|
|
|
irq_move_irq(data);
|
2006-10-04 09:16:59 +00:00
|
|
|
ia64_eoi();
|
|
|
|
}
|
2006-04-14 21:03:54 +00:00
|
|
|
|
2011-02-04 19:02:09 +00:00
|
|
|
static int sn_msi_retrigger_irq(struct irq_data *data)
|
2006-04-14 21:03:54 +00:00
|
|
|
{
|
2011-02-04 19:02:09 +00:00
|
|
|
unsigned int vector = data->irq;
|
2006-10-04 09:16:59 +00:00
|
|
|
ia64_resend_irq(vector);
|
2006-04-14 21:03:54 +00:00
|
|
|
|
2006-10-04 09:16:59 +00:00
|
|
|
return 1;
|
2006-04-11 02:17:48 +00:00
|
|
|
}
|
2006-10-04 09:16:59 +00:00
|
|
|
|
|
|
|
static struct irq_chip sn_msi_chip = {
|
2011-02-04 19:02:09 +00:00
|
|
|
.name = "PCI-MSI",
|
2014-11-23 11:23:20 +00:00
|
|
|
.irq_mask = pci_msi_mask_irq,
|
|
|
|
.irq_unmask = pci_msi_unmask_irq,
|
2011-02-04 19:02:09 +00:00
|
|
|
.irq_ack = sn_ack_msi_irq,
|
2006-10-04 09:16:59 +00:00
|
|
|
#ifdef CONFIG_SMP
|
2011-02-04 19:02:09 +00:00
|
|
|
.irq_set_affinity = sn_set_msi_irq_affinity,
|
2006-10-04 09:16:59 +00:00
|
|
|
#endif
|
2011-02-04 19:02:09 +00:00
|
|
|
.irq_retrigger = sn_msi_retrigger_irq,
|
2006-10-04 09:16:59 +00:00
|
|
|
};
|