![Greg Kroah-Hartman](/assets/img/avatar_default.png)
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>
294 lines
6.7 KiB
C
294 lines
6.7 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Linux/Meta general interrupt handling code
|
|
*
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/init.h>
|
|
#include <linux/irqchip/metag-ext.h>
|
|
#include <linux/irqchip/metag.h>
|
|
#include <linux/irqdomain.h>
|
|
#include <linux/ratelimit.h>
|
|
|
|
#include <asm/core_reg.h>
|
|
#include <asm/mach/arch.h>
|
|
#include <linux/uaccess.h>
|
|
|
|
#ifdef CONFIG_4KSTACKS
|
|
union irq_ctx {
|
|
struct thread_info tinfo;
|
|
u32 stack[THREAD_SIZE/sizeof(u32)];
|
|
};
|
|
|
|
static union irq_ctx *hardirq_ctx[NR_CPUS] __read_mostly;
|
|
static union irq_ctx *softirq_ctx[NR_CPUS] __read_mostly;
|
|
#endif
|
|
|
|
static struct irq_domain *root_domain;
|
|
|
|
static unsigned int startup_meta_irq(struct irq_data *data)
|
|
{
|
|
tbi_startup_interrupt(data->hwirq);
|
|
return 0;
|
|
}
|
|
|
|
static void shutdown_meta_irq(struct irq_data *data)
|
|
{
|
|
tbi_shutdown_interrupt(data->hwirq);
|
|
}
|
|
|
|
void do_IRQ(int irq, struct pt_regs *regs)
|
|
{
|
|
struct pt_regs *old_regs = set_irq_regs(regs);
|
|
#ifdef CONFIG_4KSTACKS
|
|
struct irq_desc *desc;
|
|
union irq_ctx *curctx, *irqctx;
|
|
u32 *isp;
|
|
#endif
|
|
|
|
irq_enter();
|
|
|
|
irq = irq_linear_revmap(root_domain, irq);
|
|
|
|
#ifdef CONFIG_DEBUG_STACKOVERFLOW
|
|
/* Debugging check for stack overflow: is there less than 1KB free? */
|
|
{
|
|
unsigned long sp;
|
|
|
|
sp = __core_reg_get(A0StP);
|
|
sp &= THREAD_SIZE - 1;
|
|
|
|
if (unlikely(sp > (THREAD_SIZE - 1024)))
|
|
pr_err("Stack overflow in do_IRQ: %ld\n", sp);
|
|
}
|
|
#endif
|
|
|
|
|
|
#ifdef CONFIG_4KSTACKS
|
|
curctx = (union irq_ctx *) current_thread_info();
|
|
irqctx = hardirq_ctx[smp_processor_id()];
|
|
|
|
/*
|
|
* this is where we switch to the IRQ stack. However, if we are
|
|
* already using the IRQ stack (because we interrupted a hardirq
|
|
* handler) we can't do that and just have to keep using the
|
|
* current stack (which is the irq stack already after all)
|
|
*/
|
|
if (curctx != irqctx) {
|
|
/* build the stack frame on the IRQ stack */
|
|
isp = (u32 *) ((char *)irqctx + sizeof(struct thread_info));
|
|
irqctx->tinfo.task = curctx->tinfo.task;
|
|
|
|
/*
|
|
* Copy the softirq bits in preempt_count so that the
|
|
* softirq checks work in the hardirq context.
|
|
*/
|
|
irqctx->tinfo.preempt_count =
|
|
(irqctx->tinfo.preempt_count & ~SOFTIRQ_MASK) |
|
|
(curctx->tinfo.preempt_count & SOFTIRQ_MASK);
|
|
|
|
desc = irq_to_desc(irq);
|
|
|
|
asm volatile (
|
|
"MOV D0.5,%0\n"
|
|
"MOV D1Ar1,%1\n"
|
|
"MOV D1RtP,%2\n"
|
|
"SWAP A0StP,D0.5\n"
|
|
"SWAP PC,D1RtP\n"
|
|
"MOV A0StP,D0.5\n"
|
|
:
|
|
: "r" (isp), "r" (desc), "r" (desc->handle_irq)
|
|
: "memory", "cc", "D1Ar1", "D0Ar2", "D1Ar3", "D0Ar4",
|
|
"D1Ar5", "D0Ar6", "D0Re0", "D1Re0", "D0.4", "D1RtP",
|
|
"D0.5"
|
|
);
|
|
} else
|
|
#endif
|
|
generic_handle_irq(irq);
|
|
|
|
irq_exit();
|
|
|
|
set_irq_regs(old_regs);
|
|
}
|
|
|
|
#ifdef CONFIG_4KSTACKS
|
|
|
|
static char softirq_stack[NR_CPUS * THREAD_SIZE] __page_aligned_bss;
|
|
|
|
static char hardirq_stack[NR_CPUS * THREAD_SIZE] __page_aligned_bss;
|
|
|
|
/*
|
|
* allocate per-cpu stacks for hardirq and for softirq processing
|
|
*/
|
|
void irq_ctx_init(int cpu)
|
|
{
|
|
union irq_ctx *irqctx;
|
|
|
|
if (hardirq_ctx[cpu])
|
|
return;
|
|
|
|
irqctx = (union irq_ctx *) &hardirq_stack[cpu * THREAD_SIZE];
|
|
irqctx->tinfo.task = NULL;
|
|
irqctx->tinfo.cpu = cpu;
|
|
irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
|
|
irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
|
|
|
|
hardirq_ctx[cpu] = irqctx;
|
|
|
|
irqctx = (union irq_ctx *) &softirq_stack[cpu * THREAD_SIZE];
|
|
irqctx->tinfo.task = NULL;
|
|
irqctx->tinfo.cpu = cpu;
|
|
irqctx->tinfo.preempt_count = 0;
|
|
irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
|
|
|
|
softirq_ctx[cpu] = irqctx;
|
|
|
|
pr_info("CPU %u irqstacks, hard=%p soft=%p\n",
|
|
cpu, hardirq_ctx[cpu], softirq_ctx[cpu]);
|
|
}
|
|
|
|
void irq_ctx_exit(int cpu)
|
|
{
|
|
hardirq_ctx[smp_processor_id()] = NULL;
|
|
}
|
|
|
|
extern asmlinkage void __do_softirq(void);
|
|
|
|
void do_softirq_own_stack(void)
|
|
{
|
|
struct thread_info *curctx;
|
|
union irq_ctx *irqctx;
|
|
u32 *isp;
|
|
|
|
curctx = current_thread_info();
|
|
irqctx = softirq_ctx[smp_processor_id()];
|
|
irqctx->tinfo.task = curctx->task;
|
|
|
|
/* build the stack frame on the softirq stack */
|
|
isp = (u32 *) ((char *)irqctx + sizeof(struct thread_info));
|
|
|
|
asm volatile (
|
|
"MOV D0.5,%0\n"
|
|
"SWAP A0StP,D0.5\n"
|
|
"CALLR D1RtP,___do_softirq\n"
|
|
"MOV A0StP,D0.5\n"
|
|
:
|
|
: "r" (isp)
|
|
: "memory", "cc", "D1Ar1", "D0Ar2", "D1Ar3", "D0Ar4",
|
|
"D1Ar5", "D0Ar6", "D0Re0", "D1Re0", "D0.4", "D1RtP",
|
|
"D0.5"
|
|
);
|
|
}
|
|
#endif
|
|
|
|
static struct irq_chip meta_irq_type = {
|
|
.name = "META-IRQ",
|
|
.irq_startup = startup_meta_irq,
|
|
.irq_shutdown = shutdown_meta_irq,
|
|
};
|
|
|
|
/**
|
|
* tbisig_map() - Map a TBI signal number to a virtual IRQ number.
|
|
* @hw: Number of the TBI signal. Must be in range.
|
|
*
|
|
* Returns: The virtual IRQ number of the TBI signal number IRQ specified by
|
|
* @hw.
|
|
*/
|
|
int tbisig_map(unsigned int hw)
|
|
{
|
|
return irq_create_mapping(root_domain, hw);
|
|
}
|
|
|
|
/**
|
|
* metag_tbisig_map() - map a tbi signal to a Linux virtual IRQ number
|
|
* @d: root irq domain
|
|
* @irq: virtual irq number
|
|
* @hw: hardware irq number (TBI signal number)
|
|
*
|
|
* This sets up a virtual irq for a specified TBI signal number.
|
|
*/
|
|
static int metag_tbisig_map(struct irq_domain *d, unsigned int irq,
|
|
irq_hw_number_t hw)
|
|
{
|
|
#ifdef CONFIG_SMP
|
|
irq_set_chip_and_handler(irq, &meta_irq_type, handle_percpu_irq);
|
|
#else
|
|
irq_set_chip_and_handler(irq, &meta_irq_type, handle_simple_irq);
|
|
#endif
|
|
return 0;
|
|
}
|
|
|
|
static const struct irq_domain_ops metag_tbisig_domain_ops = {
|
|
.map = metag_tbisig_map,
|
|
};
|
|
|
|
/*
|
|
* void init_IRQ(void)
|
|
*
|
|
* Parameters: None
|
|
*
|
|
* Returns: Nothing
|
|
*
|
|
* This function should be called during kernel startup to initialize
|
|
* the IRQ handling routines.
|
|
*/
|
|
void __init init_IRQ(void)
|
|
{
|
|
root_domain = irq_domain_add_linear(NULL, 32,
|
|
&metag_tbisig_domain_ops, NULL);
|
|
if (unlikely(!root_domain))
|
|
panic("init_IRQ: cannot add root IRQ domain");
|
|
|
|
irq_ctx_init(smp_processor_id());
|
|
|
|
init_internal_IRQ();
|
|
init_external_IRQ();
|
|
|
|
if (machine_desc->init_irq)
|
|
machine_desc->init_irq();
|
|
}
|
|
|
|
int __init arch_probe_nr_irqs(void)
|
|
{
|
|
if (machine_desc->nr_irqs)
|
|
nr_irqs = machine_desc->nr_irqs;
|
|
return 0;
|
|
}
|
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
|
/*
|
|
* The CPU has been marked offline. Migrate IRQs off this CPU. If
|
|
* the affinity settings do not allow other CPUs, force them onto any
|
|
* available CPU.
|
|
*/
|
|
void migrate_irqs(void)
|
|
{
|
|
unsigned int i, cpu = smp_processor_id();
|
|
|
|
for_each_active_irq(i) {
|
|
struct irq_data *data = irq_get_irq_data(i);
|
|
struct cpumask *mask;
|
|
unsigned int newcpu;
|
|
|
|
if (irqd_is_per_cpu(data))
|
|
continue;
|
|
|
|
mask = irq_data_get_affinity_mask(data);
|
|
if (!cpumask_test_cpu(cpu, mask))
|
|
continue;
|
|
|
|
newcpu = cpumask_any_and(mask, cpu_online_mask);
|
|
|
|
if (newcpu >= nr_cpu_ids) {
|
|
pr_info_ratelimited("IRQ%u no longer affine to CPU%u\n",
|
|
i, cpu);
|
|
|
|
cpumask_setall(mask);
|
|
}
|
|
irq_set_affinity(i, mask);
|
|
}
|
|
}
|
|
#endif /* CONFIG_HOTPLUG_CPU */
|