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 21:07:57 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2017-04-11 15:39:53 +07:00
|
|
|
/*
|
|
|
|
* platform_device probing code for ARM performance counters.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 picoChip Designs, Ltd., Jamie Iles
|
|
|
|
* Copyright (C) 2010 ARM Ltd., Will Deacon <will.deacon@arm.com>
|
|
|
|
*/
|
|
|
|
#define pr_fmt(fmt) "hw perfevents: " fmt
|
|
|
|
|
|
|
|
#include <linux/bug.h>
|
|
|
|
#include <linux/cpumask.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/irq.h>
|
|
|
|
#include <linux/irqdesc.h>
|
|
|
|
#include <linux/kconfig.h>
|
|
|
|
#include <linux/of.h>
|
|
|
|
#include <linux/of_device.h>
|
|
|
|
#include <linux/percpu.h>
|
|
|
|
#include <linux/perf/arm_pmu.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/printk.h>
|
|
|
|
#include <linux/smp.h>
|
|
|
|
|
|
|
|
static int probe_current_pmu(struct arm_pmu *pmu,
|
|
|
|
const struct pmu_probe_info *info)
|
|
|
|
{
|
|
|
|
int cpu = get_cpu();
|
|
|
|
unsigned int cpuid = read_cpuid_id();
|
|
|
|
int ret = -ENODEV;
|
|
|
|
|
|
|
|
pr_info("probing PMU on CPU %d\n", cpu);
|
|
|
|
|
|
|
|
for (; info->init != NULL; info++) {
|
|
|
|
if ((cpuid & info->mask) != info->cpuid)
|
|
|
|
continue;
|
|
|
|
ret = info->init(pmu);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
put_cpu();
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pmu_parse_percpu_irq(struct arm_pmu *pmu, int irq)
|
|
|
|
{
|
|
|
|
int cpu, ret;
|
|
|
|
struct pmu_hw_events __percpu *hw_events = pmu->hw_events;
|
|
|
|
|
|
|
|
ret = irq_get_percpu_devid_partition(irq, &pmu->supported_cpus);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
for_each_cpu(cpu, &pmu->supported_cpus)
|
|
|
|
per_cpu(hw_events->irq, cpu) = irq;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool pmu_has_irq_affinity(struct device_node *node)
|
|
|
|
{
|
|
|
|
return !!of_find_property(node, "interrupt-affinity", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pmu_parse_irq_affinity(struct device_node *node, int i)
|
|
|
|
{
|
|
|
|
struct device_node *dn;
|
|
|
|
int cpu;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we don't have an interrupt-affinity property, we guess irq
|
|
|
|
* affinity matches our logical CPU order, as we used to assume.
|
|
|
|
* This is fragile, so we'll warn in pmu_parse_irqs().
|
|
|
|
*/
|
|
|
|
if (!pmu_has_irq_affinity(node))
|
|
|
|
return i;
|
|
|
|
|
|
|
|
dn = of_parse_phandle(node, "interrupt-affinity", i);
|
|
|
|
if (!dn) {
|
|
|
|
pr_warn("failed to parse interrupt-affinity[%d] for %s\n",
|
|
|
|
i, node->name);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now look up the logical CPU number */
|
|
|
|
for_each_possible_cpu(cpu) {
|
|
|
|
struct device_node *cpu_dn;
|
|
|
|
|
|
|
|
cpu_dn = of_cpu_device_node_get(cpu);
|
|
|
|
of_node_put(cpu_dn);
|
|
|
|
|
|
|
|
if (dn == cpu_dn)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cpu >= nr_cpu_ids) {
|
|
|
|
pr_warn("failed to find logical CPU for %s\n", dn->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
of_node_put(dn);
|
|
|
|
|
|
|
|
return cpu;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pmu_parse_irqs(struct arm_pmu *pmu)
|
|
|
|
{
|
|
|
|
int i = 0, num_irqs;
|
|
|
|
struct platform_device *pdev = pmu->plat_device;
|
|
|
|
struct pmu_hw_events __percpu *hw_events = pmu->hw_events;
|
|
|
|
|
|
|
|
num_irqs = platform_irq_count(pdev);
|
|
|
|
if (num_irqs < 0) {
|
|
|
|
pr_err("unable to count PMU IRQs\n");
|
|
|
|
return num_irqs;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* In this case we have no idea which CPUs are covered by the PMU.
|
|
|
|
* To match our prior behaviour, we assume all CPUs in this case.
|
|
|
|
*/
|
|
|
|
if (num_irqs == 0) {
|
|
|
|
pr_warn("no irqs for PMU, sampling events not supported\n");
|
|
|
|
pmu->pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT;
|
|
|
|
cpumask_setall(&pmu->supported_cpus);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (num_irqs == 1) {
|
|
|
|
int irq = platform_get_irq(pdev, 0);
|
2017-10-13 18:26:45 +07:00
|
|
|
if (irq && irq_is_percpu_devid(irq))
|
2017-04-11 15:39:53 +07:00
|
|
|
return pmu_parse_percpu_irq(pmu, irq);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pmu_has_irq_affinity(pdev->dev.of_node)) {
|
2017-07-19 04:43:22 +07:00
|
|
|
pr_warn("no interrupt-affinity property for %pOF, guessing.\n",
|
|
|
|
pdev->dev.of_node);
|
2017-04-11 15:39:53 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Some platforms have all PMU IRQs OR'd into a single IRQ, with a
|
|
|
|
* special platdata function that attempts to demux them.
|
|
|
|
*/
|
|
|
|
if (dev_get_platdata(&pdev->dev))
|
|
|
|
cpumask_setall(&pmu->supported_cpus);
|
|
|
|
|
|
|
|
for (i = 0; i < num_irqs; i++) {
|
|
|
|
int cpu, irq;
|
|
|
|
|
|
|
|
irq = platform_get_irq(pdev, i);
|
|
|
|
if (WARN_ON(irq <= 0))
|
|
|
|
continue;
|
|
|
|
|
2017-10-13 18:26:45 +07:00
|
|
|
if (irq_is_percpu_devid(irq)) {
|
2017-04-11 15:39:53 +07:00
|
|
|
pr_warn("multiple PPIs or mismatched SPI/PPI detected\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
cpu = pmu_parse_irq_affinity(pdev->dev.of_node, i);
|
|
|
|
if (cpu < 0)
|
|
|
|
return cpu;
|
|
|
|
if (cpu >= nr_cpu_ids)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (per_cpu(hw_events->irq, cpu)) {
|
|
|
|
pr_warn("multiple PMU IRQs for the same CPU detected\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
per_cpu(hw_events->irq, cpu) = irq;
|
|
|
|
cpumask_set_cpu(cpu, &pmu->supported_cpus);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int arm_pmu_device_probe(struct platform_device *pdev,
|
|
|
|
const struct of_device_id *of_table,
|
|
|
|
const struct pmu_probe_info *probe_table)
|
|
|
|
{
|
|
|
|
const struct of_device_id *of_id;
|
|
|
|
armpmu_init_fn init_fn;
|
|
|
|
struct device_node *node = pdev->dev.of_node;
|
|
|
|
struct arm_pmu *pmu;
|
|
|
|
int ret = -ENODEV;
|
|
|
|
|
|
|
|
pmu = armpmu_alloc();
|
|
|
|
if (!pmu)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
pmu->plat_device = pdev;
|
|
|
|
|
|
|
|
ret = pmu_parse_irqs(pmu);
|
|
|
|
if (ret)
|
|
|
|
goto out_free;
|
|
|
|
|
|
|
|
if (node && (of_id = of_match_node(of_table, pdev->dev.of_node))) {
|
|
|
|
init_fn = of_id->data;
|
|
|
|
|
|
|
|
pmu->secure_access = of_property_read_bool(pdev->dev.of_node,
|
|
|
|
"secure-reg-access");
|
|
|
|
|
|
|
|
/* arm64 systems boot only as non-secure */
|
|
|
|
if (IS_ENABLED(CONFIG_ARM64) && pmu->secure_access) {
|
|
|
|
pr_warn("ignoring \"secure-reg-access\" property for arm64\n");
|
|
|
|
pmu->secure_access = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = init_fn(pmu);
|
|
|
|
} else if (probe_table) {
|
|
|
|
cpumask_setall(&pmu->supported_cpus);
|
|
|
|
ret = probe_current_pmu(pmu, probe_table);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret) {
|
2017-07-19 04:43:22 +07:00
|
|
|
pr_info("%pOF: failed to probe PMU!\n", node);
|
2017-04-11 15:39:53 +07:00
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = armpmu_request_irqs(pmu);
|
|
|
|
if (ret)
|
|
|
|
goto out_free_irqs;
|
|
|
|
|
|
|
|
ret = armpmu_register(pmu);
|
|
|
|
if (ret)
|
|
|
|
goto out_free;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
out_free_irqs:
|
|
|
|
armpmu_free_irqs(pmu);
|
|
|
|
out_free:
|
2017-07-19 04:43:22 +07:00
|
|
|
pr_info("%pOF: failed to register PMU devices!\n", node);
|
2017-04-11 15:39:53 +07:00
|
|
|
armpmu_free(pmu);
|
|
|
|
return ret;
|
|
|
|
}
|