License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 22:07:57 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
2006-10-04 05:01:26 +08:00
|
|
|
* linux/arch/ia64/kernel/irq_ia64.c
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* Copyright (C) 1998-2001 Hewlett-Packard Co
|
|
|
|
* Stephane Eranian <eranian@hpl.hp.com>
|
|
|
|
* David Mosberger-Tang <davidm@hpl.hp.com>
|
|
|
|
*
|
|
|
|
* 6/10/99: Updated to bring in sync with x86 version to facilitate
|
|
|
|
* support for SMP and different interrupt controllers.
|
|
|
|
*
|
|
|
|
* 09/15/00 Goutham Rao <goutham.rao@intel.com> Implemented pci_irq_to_vector
|
|
|
|
* PCI to vector allocation routine.
|
|
|
|
* 04/14/2004 Ashok Raj <ashok.raj@intel.com>
|
|
|
|
* Added CPU Hotplug handling for IPF.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
2020-06-09 12:32:42 +08:00
|
|
|
#include <linux/pgtable.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#include <linux/jiffies.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/kernel_stat.h>
|
|
|
|
#include <linux/ptrace.h>
|
|
|
|
#include <linux/signal.h>
|
|
|
|
#include <linux/smp.h>
|
|
|
|
#include <linux/threads.h>
|
|
|
|
#include <linux/bitops.h>
|
2006-10-04 17:16:38 +08:00
|
|
|
#include <linux/irq.h>
|
2010-02-28 18:58:14 +08:00
|
|
|
#include <linux/ratelimit.h>
|
2010-10-06 06:41:25 +08:00
|
|
|
#include <linux/acpi.h>
|
2011-04-05 23:23:39 +08:00
|
|
|
#include <linux/sched.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#include <asm/delay.h>
|
|
|
|
#include <asm/intrinsics.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/hw_irq.h>
|
2007-05-09 05:50:43 +08:00
|
|
|
#include <asm/tlbflush.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define IRQ_DEBUG 0
|
|
|
|
|
2007-07-17 20:22:23 +08:00
|
|
|
#define IRQ_VECTOR_UNASSIGNED (0)
|
|
|
|
|
|
|
|
#define IRQ_UNUSED (0)
|
|
|
|
#define IRQ_USED (1)
|
|
|
|
#define IRQ_RSVD (2)
|
|
|
|
|
2006-04-15 05:03:49 +08:00
|
|
|
int ia64_first_device_vector = IA64_DEF_FIRST_DEVICE_VECTOR;
|
|
|
|
int ia64_last_device_vector = IA64_DEF_LAST_DEVICE_VECTOR;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* default base addr of IPI table */
|
|
|
|
void __iomem *ipi_base_addr = ((void __iomem *)
|
|
|
|
(__IA64_UNCACHED_OFFSET | IA64_IPI_DEFAULT_BASE_ADDR));
|
|
|
|
|
2007-07-17 20:22:33 +08:00
|
|
|
static cpumask_t vector_allocation_domain(int cpu);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Legacy IRQ to IA-64 vector translation table.
|
|
|
|
*/
|
|
|
|
__u8 isa_irq_to_vector_map[16] = {
|
|
|
|
/* 8259 IRQ translation, first 16 entries */
|
|
|
|
0x2f, 0x20, 0x2e, 0x2d, 0x2c, 0x2b, 0x2a, 0x29,
|
|
|
|
0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21
|
|
|
|
};
|
|
|
|
EXPORT_SYMBOL(isa_irq_to_vector_map);
|
|
|
|
|
2007-07-17 20:22:23 +08:00
|
|
|
DEFINE_SPINLOCK(vector_lock);
|
|
|
|
|
|
|
|
struct irq_cfg irq_cfg[NR_IRQS] __read_mostly = {
|
2007-07-17 20:22:33 +08:00
|
|
|
[0 ... NR_IRQS - 1] = {
|
|
|
|
.vector = IRQ_VECTOR_UNASSIGNED,
|
|
|
|
.domain = CPU_MASK_NONE
|
|
|
|
}
|
2007-07-17 20:22:23 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
DEFINE_PER_CPU(int[IA64_NUM_VECTORS], vector_irq) = {
|
2007-08-29 07:01:21 +08:00
|
|
|
[0 ... IA64_NUM_VECTORS - 1] = -1
|
2007-07-17 20:22:23 +08:00
|
|
|
};
|
|
|
|
|
2007-07-25 16:59:22 +08:00
|
|
|
static cpumask_t vector_table[IA64_NUM_VECTORS] = {
|
|
|
|
[0 ... IA64_NUM_VECTORS - 1] = CPU_MASK_NONE
|
2007-07-17 20:22:33 +08:00
|
|
|
};
|
|
|
|
|
2007-07-17 20:22:23 +08:00
|
|
|
static int irq_status[NR_IRQS] = {
|
|
|
|
[0 ... NR_IRQS -1] = IRQ_UNUSED
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline int find_unassigned_irq(void)
|
|
|
|
{
|
|
|
|
int irq;
|
|
|
|
|
|
|
|
for (irq = IA64_FIRST_DEVICE_VECTOR; irq < NR_IRQS; irq++)
|
|
|
|
if (irq_status[irq] == IRQ_UNUSED)
|
|
|
|
return irq;
|
|
|
|
return -ENOSPC;
|
|
|
|
}
|
|
|
|
|
2007-07-17 20:22:33 +08:00
|
|
|
static inline int find_unassigned_vector(cpumask_t domain)
|
2007-07-17 20:22:23 +08:00
|
|
|
{
|
2007-07-17 20:22:33 +08:00
|
|
|
cpumask_t mask;
|
2007-07-25 16:59:22 +08:00
|
|
|
int pos, vector;
|
2007-07-17 20:22:33 +08:00
|
|
|
|
2012-03-29 05:42:46 +08:00
|
|
|
cpumask_and(&mask, &domain, cpu_online_mask);
|
2015-03-05 08:19:16 +08:00
|
|
|
if (cpumask_empty(&mask))
|
2007-07-17 20:22:33 +08:00
|
|
|
return -EINVAL;
|
2007-07-17 20:22:23 +08:00
|
|
|
|
2007-07-17 20:22:33 +08:00
|
|
|
for (pos = 0; pos < IA64_NUM_DEVICE_VECTORS; pos++) {
|
2007-07-25 16:59:22 +08:00
|
|
|
vector = IA64_FIRST_DEVICE_VECTOR + pos;
|
2015-03-05 08:19:16 +08:00
|
|
|
cpumask_and(&mask, &domain, &vector_table[vector]);
|
|
|
|
if (!cpumask_empty(&mask))
|
2007-07-17 20:22:33 +08:00
|
|
|
continue;
|
2007-07-25 16:59:22 +08:00
|
|
|
return vector;
|
2007-07-17 20:22:33 +08:00
|
|
|
}
|
2007-07-17 20:22:23 +08:00
|
|
|
return -ENOSPC;
|
|
|
|
}
|
|
|
|
|
2007-07-17 20:22:33 +08:00
|
|
|
static int __bind_irq_vector(int irq, int vector, cpumask_t domain)
|
2007-07-17 20:22:23 +08:00
|
|
|
{
|
2007-07-17 20:22:33 +08:00
|
|
|
cpumask_t mask;
|
2007-07-25 16:59:22 +08:00
|
|
|
int cpu;
|
2007-07-17 20:22:33 +08:00
|
|
|
struct irq_cfg *cfg = &irq_cfg[irq];
|
2007-07-17 20:22:23 +08:00
|
|
|
|
2007-07-26 14:30:45 +08:00
|
|
|
BUG_ON((unsigned)irq >= NR_IRQS);
|
|
|
|
BUG_ON((unsigned)vector >= IA64_NUM_VECTORS);
|
|
|
|
|
2012-03-29 05:42:46 +08:00
|
|
|
cpumask_and(&mask, &domain, cpu_online_mask);
|
2015-03-05 08:19:16 +08:00
|
|
|
if (cpumask_empty(&mask))
|
2007-07-17 20:22:33 +08:00
|
|
|
return -EINVAL;
|
2015-03-05 08:19:16 +08:00
|
|
|
if ((cfg->vector == vector) && cpumask_equal(&cfg->domain, &domain))
|
2007-07-17 20:22:23 +08:00
|
|
|
return 0;
|
2007-07-17 20:22:33 +08:00
|
|
|
if (cfg->vector != IRQ_VECTOR_UNASSIGNED)
|
2007-07-17 20:22:23 +08:00
|
|
|
return -EBUSY;
|
2015-03-05 08:19:16 +08:00
|
|
|
for_each_cpu(cpu, &mask)
|
2007-07-17 20:22:23 +08:00
|
|
|
per_cpu(vector_irq, cpu)[vector] = irq;
|
2007-07-17 20:22:33 +08:00
|
|
|
cfg->vector = vector;
|
|
|
|
cfg->domain = domain;
|
2007-07-17 20:22:23 +08:00
|
|
|
irq_status[irq] = IRQ_USED;
|
2015-03-05 08:19:16 +08:00
|
|
|
cpumask_or(&vector_table[vector], &vector_table[vector], &domain);
|
2007-07-17 20:22:23 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-07-17 20:22:33 +08:00
|
|
|
int bind_irq_vector(int irq, int vector, cpumask_t domain)
|
2007-07-17 20:22:23 +08:00
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&vector_lock, flags);
|
2007-07-17 20:22:33 +08:00
|
|
|
ret = __bind_irq_vector(irq, vector, domain);
|
2007-07-17 20:22:23 +08:00
|
|
|
spin_unlock_irqrestore(&vector_lock, flags);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-07-17 20:22:48 +08:00
|
|
|
static void __clear_irq_vector(int irq)
|
2007-07-17 20:22:23 +08:00
|
|
|
{
|
2007-07-25 16:59:22 +08:00
|
|
|
int vector, cpu;
|
2007-07-17 20:22:33 +08:00
|
|
|
cpumask_t domain;
|
|
|
|
struct irq_cfg *cfg = &irq_cfg[irq];
|
2007-07-17 20:22:23 +08:00
|
|
|
|
|
|
|
BUG_ON((unsigned)irq >= NR_IRQS);
|
2007-07-17 20:22:33 +08:00
|
|
|
BUG_ON(cfg->vector == IRQ_VECTOR_UNASSIGNED);
|
|
|
|
vector = cfg->vector;
|
|
|
|
domain = cfg->domain;
|
2015-03-05 08:18:49 +08:00
|
|
|
for_each_cpu_and(cpu, &cfg->domain, cpu_online_mask)
|
2007-08-29 07:01:21 +08:00
|
|
|
per_cpu(vector_irq, cpu)[vector] = -1;
|
2007-07-17 20:22:33 +08:00
|
|
|
cfg->vector = IRQ_VECTOR_UNASSIGNED;
|
|
|
|
cfg->domain = CPU_MASK_NONE;
|
2007-07-17 20:22:23 +08:00
|
|
|
irq_status[irq] = IRQ_UNUSED;
|
2015-03-10 10:12:03 +08:00
|
|
|
cpumask_andnot(&vector_table[vector], &vector_table[vector], &domain);
|
2007-07-17 20:22:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void clear_irq_vector(int irq)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&vector_lock, flags);
|
|
|
|
__clear_irq_vector(irq);
|
2007-07-17 20:22:23 +08:00
|
|
|
spin_unlock_irqrestore(&vector_lock, flags);
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
int
|
2008-05-19 21:13:43 +08:00
|
|
|
ia64_native_assign_irq_vector (int irq)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-07-17 20:22:23 +08:00
|
|
|
unsigned long flags;
|
2007-07-17 20:22:33 +08:00
|
|
|
int vector, cpu;
|
2007-08-22 18:28:36 +08:00
|
|
|
cpumask_t domain = CPU_MASK_NONE;
|
2007-07-17 20:22:33 +08:00
|
|
|
|
|
|
|
vector = -ENOSPC;
|
2007-07-17 20:22:23 +08:00
|
|
|
|
2007-07-17 20:22:33 +08:00
|
|
|
spin_lock_irqsave(&vector_lock, flags);
|
|
|
|
for_each_online_cpu(cpu) {
|
|
|
|
domain = vector_allocation_domain(cpu);
|
|
|
|
vector = find_unassigned_vector(domain);
|
|
|
|
if (vector >= 0)
|
|
|
|
break;
|
|
|
|
}
|
2007-07-17 20:22:23 +08:00
|
|
|
if (vector < 0)
|
|
|
|
goto out;
|
2007-07-24 21:09:09 +08:00
|
|
|
if (irq == AUTO_ASSIGN)
|
|
|
|
irq = vector;
|
2007-07-17 20:22:33 +08:00
|
|
|
BUG_ON(__bind_irq_vector(irq, vector, domain));
|
2007-07-17 20:22:23 +08:00
|
|
|
out:
|
2007-07-17 20:22:33 +08:00
|
|
|
spin_unlock_irqrestore(&vector_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
return vector;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-05-19 21:13:43 +08:00
|
|
|
ia64_native_free_irq_vector (int vector)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-07-17 20:22:23 +08:00
|
|
|
if (vector < IA64_FIRST_DEVICE_VECTOR ||
|
|
|
|
vector > IA64_LAST_DEVICE_VECTOR)
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
2007-07-17 20:22:23 +08:00
|
|
|
clear_irq_vector(vector);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2006-04-15 05:03:49 +08:00
|
|
|
int
|
|
|
|
reserve_irq_vector (int vector)
|
|
|
|
{
|
|
|
|
if (vector < IA64_FIRST_DEVICE_VECTOR ||
|
|
|
|
vector > IA64_LAST_DEVICE_VECTOR)
|
|
|
|
return -EINVAL;
|
2007-07-17 20:22:33 +08:00
|
|
|
return !!bind_irq_vector(vector, vector, CPU_MASK_ALL);
|
2007-07-17 20:22:23 +08:00
|
|
|
}
|
2006-04-15 05:03:49 +08:00
|
|
|
|
2007-07-17 20:22:23 +08:00
|
|
|
/*
|
|
|
|
* Initialize vector_irq on a new cpu. This function must be called
|
|
|
|
* with vector_lock held.
|
|
|
|
*/
|
|
|
|
void __setup_vector_irq(int cpu)
|
|
|
|
{
|
|
|
|
int irq, vector;
|
|
|
|
|
|
|
|
/* Clear vector_irq */
|
|
|
|
for (vector = 0; vector < IA64_NUM_VECTORS; ++vector)
|
2007-08-29 07:01:21 +08:00
|
|
|
per_cpu(vector_irq, cpu)[vector] = -1;
|
2007-07-17 20:22:23 +08:00
|
|
|
/* Mark the inuse vectors */
|
|
|
|
for (irq = 0; irq < NR_IRQS; ++irq) {
|
2015-03-05 08:19:16 +08:00
|
|
|
if (!cpumask_test_cpu(cpu, &irq_cfg[irq].domain))
|
2007-07-17 20:22:33 +08:00
|
|
|
continue;
|
|
|
|
vector = irq_to_vector(irq);
|
|
|
|
per_cpu(vector_irq, cpu)[vector] = irq;
|
2007-07-17 20:22:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-13 15:25:12 +08:00
|
|
|
#ifdef CONFIG_SMP
|
2008-02-25 13:32:22 +08:00
|
|
|
|
2007-07-17 20:22:55 +08:00
|
|
|
static enum vector_domain_type {
|
|
|
|
VECTOR_DOMAIN_NONE,
|
|
|
|
VECTOR_DOMAIN_PERCPU
|
|
|
|
} vector_domain_type = VECTOR_DOMAIN_NONE;
|
|
|
|
|
2007-07-17 20:22:33 +08:00
|
|
|
static cpumask_t vector_allocation_domain(int cpu)
|
|
|
|
{
|
2007-07-17 20:22:55 +08:00
|
|
|
if (vector_domain_type == VECTOR_DOMAIN_PERCPU)
|
2015-03-10 10:12:03 +08:00
|
|
|
return *cpumask_of(cpu);
|
2007-07-17 20:22:33 +08:00
|
|
|
return CPU_MASK_ALL;
|
|
|
|
}
|
|
|
|
|
2008-02-25 13:32:22 +08:00
|
|
|
static int __irq_prepare_move(int irq, int cpu)
|
|
|
|
{
|
|
|
|
struct irq_cfg *cfg = &irq_cfg[irq];
|
|
|
|
int vector;
|
|
|
|
cpumask_t domain;
|
|
|
|
|
|
|
|
if (cfg->move_in_progress || cfg->move_cleanup_count)
|
|
|
|
return -EBUSY;
|
|
|
|
if (cfg->vector == IRQ_VECTOR_UNASSIGNED || !cpu_online(cpu))
|
|
|
|
return -EINVAL;
|
2015-03-05 08:19:16 +08:00
|
|
|
if (cpumask_test_cpu(cpu, &cfg->domain))
|
2008-02-25 13:32:22 +08:00
|
|
|
return 0;
|
|
|
|
domain = vector_allocation_domain(cpu);
|
|
|
|
vector = find_unassigned_vector(domain);
|
|
|
|
if (vector < 0)
|
|
|
|
return -ENOSPC;
|
|
|
|
cfg->move_in_progress = 1;
|
|
|
|
cfg->old_domain = cfg->domain;
|
|
|
|
cfg->vector = IRQ_VECTOR_UNASSIGNED;
|
|
|
|
cfg->domain = CPU_MASK_NONE;
|
|
|
|
BUG_ON(__bind_irq_vector(irq, vector, domain));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int irq_prepare_move(int irq, int cpu)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&vector_lock, flags);
|
|
|
|
ret = __irq_prepare_move(irq, cpu);
|
|
|
|
spin_unlock_irqrestore(&vector_lock, flags);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void irq_complete_move(unsigned irq)
|
|
|
|
{
|
|
|
|
struct irq_cfg *cfg = &irq_cfg[irq];
|
|
|
|
cpumask_t cleanup_mask;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (likely(!cfg->move_in_progress))
|
|
|
|
return;
|
|
|
|
|
2015-03-05 08:19:16 +08:00
|
|
|
if (unlikely(cpumask_test_cpu(smp_processor_id(), &cfg->old_domain)))
|
2008-02-25 13:32:22 +08:00
|
|
|
return;
|
|
|
|
|
2012-03-29 05:42:46 +08:00
|
|
|
cpumask_and(&cleanup_mask, &cfg->old_domain, cpu_online_mask);
|
2015-03-05 08:19:16 +08:00
|
|
|
cfg->move_cleanup_count = cpumask_weight(&cleanup_mask);
|
|
|
|
for_each_cpu(i, &cleanup_mask)
|
2019-08-13 15:25:02 +08:00
|
|
|
ia64_send_ipi(i, IA64_IRQ_MOVE_VECTOR, IA64_IPI_DM_INT, 0);
|
2008-02-25 13:32:22 +08:00
|
|
|
cfg->move_in_progress = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static irqreturn_t smp_irq_move_cleanup_interrupt(int irq, void *dev_id)
|
|
|
|
{
|
|
|
|
int me = smp_processor_id();
|
|
|
|
ia64_vector vector;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
for (vector = IA64_FIRST_DEVICE_VECTOR;
|
|
|
|
vector < IA64_LAST_DEVICE_VECTOR; vector++) {
|
|
|
|
int irq;
|
|
|
|
struct irq_desc *desc;
|
|
|
|
struct irq_cfg *cfg;
|
ia64: Replace __get_cpu_var uses
__get_cpu_var() is used for multiple purposes in the kernel source. One of
them is address calculation via the form &__get_cpu_var(x). This calculates
the address for the instance of the percpu variable of the current processor
based on an offset.
Other use cases are for storing and retrieving data from the current
processors percpu area. __get_cpu_var() can be used as an lvalue when
writing data or on the right side of an assignment.
__get_cpu_var() is defined as :
#define __get_cpu_var(var) (*this_cpu_ptr(&(var)))
__get_cpu_var() always only does an address determination. However, store
and retrieve operations could use a segment prefix (or global register on
other platforms) to avoid the address calculation.
this_cpu_write() and this_cpu_read() can directly take an offset into a
percpu area and use optimized assembly code to read and write per cpu
variables.
This patch converts __get_cpu_var into either an explicit address
calculation using this_cpu_ptr() or into a use of this_cpu operations that
use the offset. Thereby address calculations are avoided and less registers
are used when code is generated.
At the end of the patch set all uses of __get_cpu_var have been removed so
the macro is removed too.
The patch set includes passes over all arches as well. Once these operations
are used throughout then specialized macros can be defined in non -x86
arches as well in order to optimize per cpu access by f.e. using a global
register that may be set to the per cpu base.
Transformations done to __get_cpu_var()
1. Determine the address of the percpu instance of the current processor.
DEFINE_PER_CPU(int, y);
int *x = &__get_cpu_var(y);
Converts to
int *x = this_cpu_ptr(&y);
2. Same as #1 but this time an array structure is involved.
DEFINE_PER_CPU(int, y[20]);
int *x = __get_cpu_var(y);
Converts to
int *x = this_cpu_ptr(y);
3. Retrieve the content of the current processors instance of a per cpu
variable.
DEFINE_PER_CPU(int, y);
int x = __get_cpu_var(y)
Converts to
int x = __this_cpu_read(y);
4. Retrieve the content of a percpu struct
DEFINE_PER_CPU(struct mystruct, y);
struct mystruct x = __get_cpu_var(y);
Converts to
memcpy(&x, this_cpu_ptr(&y), sizeof(x));
5. Assignment to a per cpu variable
DEFINE_PER_CPU(int, y)
__get_cpu_var(y) = x;
Converts to
__this_cpu_write(y, x);
6. Increment/Decrement etc of a per cpu variable
DEFINE_PER_CPU(int, y);
__get_cpu_var(y)++
Converts to
__this_cpu_inc(y)
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64@vger.kernel.org
Signed-off-by: Christoph Lameter <cl@linux.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
2014-08-18 01:30:47 +08:00
|
|
|
irq = __this_cpu_read(vector_irq[vector]);
|
2008-02-25 13:32:22 +08:00
|
|
|
if (irq < 0)
|
|
|
|
continue;
|
|
|
|
|
2011-03-24 23:44:38 +08:00
|
|
|
desc = irq_to_desc(irq);
|
2008-02-25 13:32:22 +08:00
|
|
|
cfg = irq_cfg + irq;
|
2009-11-17 23:46:45 +08:00
|
|
|
raw_spin_lock(&desc->lock);
|
2008-02-25 13:32:22 +08:00
|
|
|
if (!cfg->move_cleanup_count)
|
|
|
|
goto unlock;
|
|
|
|
|
2015-03-05 08:19:16 +08:00
|
|
|
if (!cpumask_test_cpu(me, &cfg->old_domain))
|
2008-02-25 13:32:22 +08:00
|
|
|
goto unlock;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&vector_lock, flags);
|
ia64: Replace __get_cpu_var uses
__get_cpu_var() is used for multiple purposes in the kernel source. One of
them is address calculation via the form &__get_cpu_var(x). This calculates
the address for the instance of the percpu variable of the current processor
based on an offset.
Other use cases are for storing and retrieving data from the current
processors percpu area. __get_cpu_var() can be used as an lvalue when
writing data or on the right side of an assignment.
__get_cpu_var() is defined as :
#define __get_cpu_var(var) (*this_cpu_ptr(&(var)))
__get_cpu_var() always only does an address determination. However, store
and retrieve operations could use a segment prefix (or global register on
other platforms) to avoid the address calculation.
this_cpu_write() and this_cpu_read() can directly take an offset into a
percpu area and use optimized assembly code to read and write per cpu
variables.
This patch converts __get_cpu_var into either an explicit address
calculation using this_cpu_ptr() or into a use of this_cpu operations that
use the offset. Thereby address calculations are avoided and less registers
are used when code is generated.
At the end of the patch set all uses of __get_cpu_var have been removed so
the macro is removed too.
The patch set includes passes over all arches as well. Once these operations
are used throughout then specialized macros can be defined in non -x86
arches as well in order to optimize per cpu access by f.e. using a global
register that may be set to the per cpu base.
Transformations done to __get_cpu_var()
1. Determine the address of the percpu instance of the current processor.
DEFINE_PER_CPU(int, y);
int *x = &__get_cpu_var(y);
Converts to
int *x = this_cpu_ptr(&y);
2. Same as #1 but this time an array structure is involved.
DEFINE_PER_CPU(int, y[20]);
int *x = __get_cpu_var(y);
Converts to
int *x = this_cpu_ptr(y);
3. Retrieve the content of the current processors instance of a per cpu
variable.
DEFINE_PER_CPU(int, y);
int x = __get_cpu_var(y)
Converts to
int x = __this_cpu_read(y);
4. Retrieve the content of a percpu struct
DEFINE_PER_CPU(struct mystruct, y);
struct mystruct x = __get_cpu_var(y);
Converts to
memcpy(&x, this_cpu_ptr(&y), sizeof(x));
5. Assignment to a per cpu variable
DEFINE_PER_CPU(int, y)
__get_cpu_var(y) = x;
Converts to
__this_cpu_write(y, x);
6. Increment/Decrement etc of a per cpu variable
DEFINE_PER_CPU(int, y);
__get_cpu_var(y)++
Converts to
__this_cpu_inc(y)
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64@vger.kernel.org
Signed-off-by: Christoph Lameter <cl@linux.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
2014-08-18 01:30:47 +08:00
|
|
|
__this_cpu_write(vector_irq[vector], -1);
|
2015-03-05 08:19:16 +08:00
|
|
|
cpumask_clear_cpu(me, &vector_table[vector]);
|
2008-02-25 13:32:22 +08:00
|
|
|
spin_unlock_irqrestore(&vector_lock, flags);
|
|
|
|
cfg->move_cleanup_count--;
|
|
|
|
unlock:
|
2009-11-17 23:46:45 +08:00
|
|
|
raw_spin_unlock(&desc->lock);
|
2008-02-25 13:32:22 +08:00
|
|
|
}
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
2007-07-17 20:22:55 +08:00
|
|
|
static int __init parse_vector_domain(char *arg)
|
|
|
|
{
|
|
|
|
if (!arg)
|
|
|
|
return -EINVAL;
|
|
|
|
if (!strcmp(arg, "percpu")) {
|
|
|
|
vector_domain_type = VECTOR_DOMAIN_PERCPU;
|
|
|
|
no_int_routing = 1;
|
|
|
|
}
|
2007-07-26 14:32:38 +08:00
|
|
|
return 0;
|
2007-07-17 20:22:55 +08:00
|
|
|
}
|
|
|
|
early_param("vector", parse_vector_domain);
|
|
|
|
#else
|
|
|
|
static cpumask_t vector_allocation_domain(int cpu)
|
|
|
|
{
|
|
|
|
return CPU_MASK_ALL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-07-17 20:22:33 +08:00
|
|
|
|
2007-07-17 20:22:23 +08:00
|
|
|
void destroy_and_reserve_irq(unsigned int irq)
|
|
|
|
{
|
2007-07-30 10:56:30 +08:00
|
|
|
unsigned long flags;
|
|
|
|
|
2014-05-07 23:44:22 +08:00
|
|
|
irq_init_desc(irq);
|
2007-07-30 10:56:30 +08:00
|
|
|
spin_lock_irqsave(&vector_lock, flags);
|
|
|
|
__clear_irq_vector(irq);
|
|
|
|
irq_status[irq] = IRQ_RSVD;
|
|
|
|
spin_unlock_irqrestore(&vector_lock, flags);
|
2006-04-15 05:03:49 +08:00
|
|
|
}
|
|
|
|
|
2006-10-04 17:16:38 +08:00
|
|
|
/*
|
|
|
|
* Dynamic irq allocate and deallocation for MSI
|
|
|
|
*/
|
|
|
|
int create_irq(void)
|
|
|
|
{
|
2007-07-17 20:22:23 +08:00
|
|
|
unsigned long flags;
|
2007-07-17 20:22:33 +08:00
|
|
|
int irq, vector, cpu;
|
2007-08-22 18:28:36 +08:00
|
|
|
cpumask_t domain = CPU_MASK_NONE;
|
2007-07-17 20:22:23 +08:00
|
|
|
|
2007-07-17 20:22:33 +08:00
|
|
|
irq = vector = -ENOSPC;
|
2007-07-17 20:22:23 +08:00
|
|
|
spin_lock_irqsave(&vector_lock, flags);
|
2007-07-17 20:22:33 +08:00
|
|
|
for_each_online_cpu(cpu) {
|
|
|
|
domain = vector_allocation_domain(cpu);
|
|
|
|
vector = find_unassigned_vector(domain);
|
|
|
|
if (vector >= 0)
|
|
|
|
break;
|
|
|
|
}
|
2007-07-17 20:22:23 +08:00
|
|
|
if (vector < 0)
|
|
|
|
goto out;
|
|
|
|
irq = find_unassigned_irq();
|
|
|
|
if (irq < 0)
|
|
|
|
goto out;
|
2007-07-17 20:22:33 +08:00
|
|
|
BUG_ON(__bind_irq_vector(irq, vector, domain));
|
2007-07-17 20:22:23 +08:00
|
|
|
out:
|
|
|
|
spin_unlock_irqrestore(&vector_lock, flags);
|
|
|
|
if (irq >= 0)
|
2014-05-07 23:44:22 +08:00
|
|
|
irq_init_desc(irq);
|
2007-07-17 20:22:23 +08:00
|
|
|
return irq;
|
2006-10-04 17:16:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void destroy_irq(unsigned int irq)
|
|
|
|
{
|
2014-05-07 23:44:22 +08:00
|
|
|
irq_init_desc(irq);
|
2007-07-17 20:22:23 +08:00
|
|
|
clear_irq_vector(irq);
|
2006-10-04 17:16:38 +08:00
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
# define IS_RESCHEDULE(vec) (vec == IA64_IPI_RESCHEDULE)
|
2007-05-09 05:50:43 +08:00
|
|
|
# define IS_LOCAL_TLB_FLUSH(vec) (vec == IA64_IPI_LOCAL_TLB_FLUSH)
|
2005-04-17 06:20:36 +08:00
|
|
|
#else
|
|
|
|
# define IS_RESCHEDULE(vec) (0)
|
2007-05-09 05:50:43 +08:00
|
|
|
# define IS_LOCAL_TLB_FLUSH(vec) (0)
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
|
|
|
/*
|
|
|
|
* That's where the IVT branches when we get an external
|
|
|
|
* interrupt. This branches to the correct hardware IRQ handler via
|
|
|
|
* function ptr.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ia64_handle_irq (ia64_vector vector, struct pt_regs *regs)
|
|
|
|
{
|
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 21:55:46 +08:00
|
|
|
struct pt_regs *old_regs = set_irq_regs(regs);
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned long saved_tpr;
|
|
|
|
|
|
|
|
#if IRQ_DEBUG
|
|
|
|
{
|
|
|
|
unsigned long bsp, sp;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note: if the interrupt happened while executing in
|
|
|
|
* the context switch routine (ia64_switch_to), we may
|
|
|
|
* get a spurious stack overflow here. This is
|
|
|
|
* because the register and the memory stack are not
|
|
|
|
* switched atomically.
|
|
|
|
*/
|
|
|
|
bsp = ia64_getreg(_IA64_REG_AR_BSP);
|
|
|
|
sp = ia64_getreg(_IA64_REG_SP);
|
|
|
|
|
|
|
|
if ((sp - bsp) < 1024) {
|
2010-02-28 18:58:14 +08:00
|
|
|
static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-02-28 18:58:14 +08:00
|
|
|
if (__ratelimit(&ratelimit)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
printk("ia64_handle_irq: DANGER: less than "
|
|
|
|
"1KB of free stack space!!\n"
|
|
|
|
"(bsp=0x%lx, sp=%lx)\n", bsp, sp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* IRQ_DEBUG */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Always set TPR to limit maximum interrupt nesting depth to
|
|
|
|
* 16 (without this, it would be ~240, which could easily lead
|
|
|
|
* to kernel stack overflows).
|
|
|
|
*/
|
|
|
|
irq_enter();
|
|
|
|
saved_tpr = ia64_getreg(_IA64_REG_CR_TPR);
|
|
|
|
ia64_srlz_d();
|
|
|
|
while (vector != IA64_SPURIOUS_INT_VECTOR) {
|
2009-03-27 23:55:41 +08:00
|
|
|
int irq = local_vector_to_irq(vector);
|
|
|
|
|
2007-05-09 05:50:43 +08:00
|
|
|
if (unlikely(IS_LOCAL_TLB_FLUSH(vector))) {
|
|
|
|
smp_local_flush_tlb();
|
2014-02-24 05:40:17 +08:00
|
|
|
kstat_incr_irq_this_cpu(irq);
|
2009-03-29 04:40:20 +08:00
|
|
|
} else if (unlikely(IS_RESCHEDULE(vector))) {
|
2011-04-05 23:23:39 +08:00
|
|
|
scheduler_ipi();
|
2014-02-24 05:40:17 +08:00
|
|
|
kstat_incr_irq_this_cpu(irq);
|
2009-03-29 04:40:20 +08:00
|
|
|
} else {
|
2005-04-17 06:20:36 +08:00
|
|
|
ia64_setreg(_IA64_REG_CR_TPR, vector);
|
|
|
|
ia64_srlz_d();
|
|
|
|
|
2007-08-29 07:01:21 +08:00
|
|
|
if (unlikely(irq < 0)) {
|
|
|
|
printk(KERN_ERR "%s: Unexpected interrupt "
|
|
|
|
"vector %d on CPU %d is not mapped "
|
2008-03-05 07:15:00 +08:00
|
|
|
"to any IRQ!\n", __func__, vector,
|
2007-08-29 07:01:21 +08:00
|
|
|
smp_processor_id());
|
|
|
|
} else
|
|
|
|
generic_handle_irq(irq);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable interrupts and send EOI:
|
|
|
|
*/
|
|
|
|
local_irq_disable();
|
|
|
|
ia64_setreg(_IA64_REG_CR_TPR, saved_tpr);
|
|
|
|
}
|
|
|
|
ia64_eoi();
|
|
|
|
vector = ia64_get_ivr();
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* This must be done *after* the ia64_eoi(). For example, the keyboard softirq
|
|
|
|
* handler needs to be able to wait for further keyboard interrupts, which can't
|
|
|
|
* come through until ia64_eoi() has been done.
|
|
|
|
*/
|
|
|
|
irq_exit();
|
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 21:55:46 +08:00
|
|
|
set_irq_regs(old_regs);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
|
|
|
/*
|
|
|
|
* This function emulates a interrupt processing when a cpu is about to be
|
|
|
|
* brought down.
|
|
|
|
*/
|
|
|
|
void ia64_process_pending_intr(void)
|
|
|
|
{
|
|
|
|
ia64_vector vector;
|
|
|
|
unsigned long saved_tpr;
|
|
|
|
extern unsigned int vectors_in_migration[NR_IRQS];
|
|
|
|
|
|
|
|
vector = ia64_get_ivr();
|
|
|
|
|
2009-03-27 23:55:41 +08:00
|
|
|
irq_enter();
|
|
|
|
saved_tpr = ia64_getreg(_IA64_REG_CR_TPR);
|
|
|
|
ia64_srlz_d();
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Perform normal interrupt style processing
|
|
|
|
*/
|
|
|
|
while (vector != IA64_SPURIOUS_INT_VECTOR) {
|
2009-03-27 23:55:41 +08:00
|
|
|
int irq = local_vector_to_irq(vector);
|
|
|
|
|
2007-05-09 05:50:43 +08:00
|
|
|
if (unlikely(IS_LOCAL_TLB_FLUSH(vector))) {
|
|
|
|
smp_local_flush_tlb();
|
2014-02-24 05:40:17 +08:00
|
|
|
kstat_incr_irq_this_cpu(irq);
|
2009-03-29 04:40:20 +08:00
|
|
|
} else if (unlikely(IS_RESCHEDULE(vector))) {
|
2014-02-24 05:40:17 +08:00
|
|
|
kstat_incr_irq_this_cpu(irq);
|
2009-03-29 04:40:20 +08:00
|
|
|
} else {
|
2006-10-07 01:09:41 +08:00
|
|
|
struct pt_regs *old_regs = set_irq_regs(NULL);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
ia64_setreg(_IA64_REG_CR_TPR, vector);
|
|
|
|
ia64_srlz_d();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now try calling normal ia64_handle_irq as it would have got called
|
|
|
|
* from a real intr handler. Try passing null for pt_regs, hopefully
|
|
|
|
* it will work. I hope it works!.
|
|
|
|
* Probably could shared code.
|
|
|
|
*/
|
2007-08-29 07:01:21 +08:00
|
|
|
if (unlikely(irq < 0)) {
|
|
|
|
printk(KERN_ERR "%s: Unexpected interrupt "
|
|
|
|
"vector %d on CPU %d not being mapped "
|
2008-03-05 07:15:00 +08:00
|
|
|
"to any IRQ!!\n", __func__, vector,
|
2007-08-29 07:01:21 +08:00
|
|
|
smp_processor_id());
|
|
|
|
} else {
|
|
|
|
vectors_in_migration[irq]=0;
|
|
|
|
generic_handle_irq(irq);
|
|
|
|
}
|
2006-10-07 01:09:41 +08:00
|
|
|
set_irq_regs(old_regs);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable interrupts and send EOI
|
|
|
|
*/
|
|
|
|
local_irq_disable();
|
|
|
|
ia64_setreg(_IA64_REG_CR_TPR, saved_tpr);
|
|
|
|
}
|
|
|
|
ia64_eoi();
|
|
|
|
vector = ia64_get_ivr();
|
|
|
|
}
|
|
|
|
irq_exit();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
|
2006-10-17 05:17:43 +08:00
|
|
|
static irqreturn_t dummy_handler (int irq, void *dev_id)
|
|
|
|
{
|
|
|
|
BUG();
|
2019-09-25 02:45:34 +08:00
|
|
|
return IRQ_NONE;
|
2006-10-17 05:17:43 +08:00
|
|
|
}
|
|
|
|
|
2009-05-08 04:55:12 +08:00
|
|
|
/*
|
|
|
|
* KVM uses this interrupt to force a cpu out of guest mode
|
|
|
|
*/
|
2007-05-09 05:50:43 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
void
|
2020-03-08 20:03:49 +08:00
|
|
|
register_percpu_irq(ia64_vector vec, irq_handler_t handler, unsigned long flags,
|
|
|
|
const char *name)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
unsigned int irq;
|
|
|
|
|
2007-07-17 20:22:23 +08:00
|
|
|
irq = vec;
|
2007-07-17 20:22:33 +08:00
|
|
|
BUG_ON(bind_irq_vector(irq, vec, CPU_MASK_ALL));
|
2011-03-24 23:44:38 +08:00
|
|
|
irq_set_status_flags(irq, IRQ_PER_CPU);
|
2011-03-26 04:06:09 +08:00
|
|
|
irq_set_chip(irq, &irq_type_ia64_lsapic);
|
2020-03-08 20:03:49 +08:00
|
|
|
if (handler)
|
|
|
|
if (request_irq(irq, handler, flags, name, NULL))
|
|
|
|
pr_err("Failed to request irq %u (%s)\n", irq, name);
|
2011-03-26 04:06:09 +08:00
|
|
|
irq_set_handler(irq, handle_percpu_irq);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void __init
|
2008-05-19 21:13:43 +08:00
|
|
|
ia64_native_register_ipi(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
#ifdef CONFIG_SMP
|
2020-03-08 20:03:49 +08:00
|
|
|
register_percpu_irq(IA64_IPI_VECTOR, handle_IPI, 0, "IPI");
|
|
|
|
register_percpu_irq(IA64_IPI_RESCHEDULE, dummy_handler, 0, "resched");
|
|
|
|
register_percpu_irq(IA64_IPI_LOCAL_TLB_FLUSH, dummy_handler, 0,
|
|
|
|
"tlb_flush");
|
2008-05-19 21:13:43 +08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void __init
|
|
|
|
init_IRQ (void)
|
|
|
|
{
|
2010-10-06 06:41:25 +08:00
|
|
|
acpi_boot_init();
|
2008-05-19 21:13:43 +08:00
|
|
|
ia64_register_ipi();
|
2020-03-08 20:03:49 +08:00
|
|
|
register_percpu_irq(IA64_SPURIOUS_INT_VECTOR, NULL, 0, NULL);
|
2008-05-19 21:13:43 +08:00
|
|
|
#ifdef CONFIG_SMP
|
2020-03-08 20:03:49 +08:00
|
|
|
if (vector_domain_type != VECTOR_DOMAIN_NONE) {
|
|
|
|
register_percpu_irq(IA64_IRQ_MOVE_VECTOR,
|
|
|
|
smp_irq_move_cleanup_interrupt, 0,
|
|
|
|
"irq_move");
|
|
|
|
}
|
2008-02-25 13:32:22 +08:00
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ia64_send_ipi (int cpu, int vector, int delivery_mode, int redirect)
|
|
|
|
{
|
|
|
|
void __iomem *ipi_addr;
|
|
|
|
unsigned long ipi_data;
|
|
|
|
unsigned long phys_cpu_id;
|
|
|
|
|
|
|
|
phys_cpu_id = cpu_physical_id(cpu);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* cpu number is in 8bit ID and 8bit EID
|
|
|
|
*/
|
|
|
|
|
|
|
|
ipi_data = (delivery_mode << 8) | (vector & 0xff);
|
|
|
|
ipi_addr = ipi_base_addr + ((phys_cpu_id << 4) | ((redirect & 1) << 3));
|
|
|
|
|
|
|
|
writeq(ipi_data, ipi_addr);
|
|
|
|
}
|