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 17:07:57 +03:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2014-06-04 00:04:07 +04:00
|
|
|
/*
|
|
|
|
* Thunderbolt Cactus Ridge driver - path/tunnel functionality
|
|
|
|
*
|
|
|
|
* Copyright (c) 2014 Andreas Noever <andreas.noever@gmail.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/errno.h>
|
2017-02-17 18:05:37 +03:00
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/ktime.h>
|
2014-06-04 00:04:07 +04:00
|
|
|
|
|
|
|
#include "tb.h"
|
|
|
|
|
|
|
|
|
|
|
|
static void tb_dump_hop(struct tb_port *port, struct tb_regs_hop *hop)
|
|
|
|
{
|
2018-10-01 12:31:19 +03:00
|
|
|
tb_port_dbg(port, " Hop through port %d to hop %d (%s)\n",
|
|
|
|
hop->out_port, hop->next_hop,
|
|
|
|
hop->enable ? "enabled" : "disabled");
|
|
|
|
tb_port_dbg(port, " Weight: %d Priority: %d Credits: %d Drop: %d\n",
|
|
|
|
hop->weight, hop->priority,
|
|
|
|
hop->initial_credits, hop->drop_packages);
|
|
|
|
tb_port_dbg(port, " Counter enabled: %d Counter index: %d\n",
|
|
|
|
hop->counter_enable, hop->counter);
|
|
|
|
tb_port_dbg(port, " Flow Control (In/Eg): %d/%d Shared Buffer (In/Eg): %d/%d\n",
|
|
|
|
hop->ingress_fc, hop->egress_fc,
|
|
|
|
hop->ingress_shared_buffer, hop->egress_shared_buffer);
|
|
|
|
tb_port_dbg(port, " Unknown1: %#x Unknown2: %#x Unknown3: %#x\n",
|
|
|
|
hop->unknown1, hop->unknown2, hop->unknown3);
|
2014-06-04 00:04:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* tb_path_alloc() - allocate a thunderbolt path
|
|
|
|
*
|
|
|
|
* Return: Returns a tb_path on success or NULL on failure.
|
|
|
|
*/
|
|
|
|
struct tb_path *tb_path_alloc(struct tb *tb, int num_hops)
|
|
|
|
{
|
|
|
|
struct tb_path *path = kzalloc(sizeof(*path), GFP_KERNEL);
|
|
|
|
if (!path)
|
|
|
|
return NULL;
|
|
|
|
path->hops = kcalloc(num_hops, sizeof(*path->hops), GFP_KERNEL);
|
|
|
|
if (!path->hops) {
|
|
|
|
kfree(path);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
path->tb = tb;
|
|
|
|
path->path_length = num_hops;
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* tb_path_free() - free a deactivated path
|
|
|
|
*/
|
|
|
|
void tb_path_free(struct tb_path *path)
|
|
|
|
{
|
|
|
|
if (path->activated) {
|
|
|
|
tb_WARN(path->tb, "trying to free an activated path\n")
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
kfree(path->hops);
|
|
|
|
kfree(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __tb_path_deallocate_nfc(struct tb_path *path, int first_hop)
|
|
|
|
{
|
|
|
|
int i, res;
|
|
|
|
for (i = first_hop; i < path->path_length; i++) {
|
|
|
|
res = tb_port_add_nfc_credits(path->hops[i].in_port,
|
|
|
|
-path->nfc_credits);
|
|
|
|
if (res)
|
|
|
|
tb_port_warn(path->hops[i].in_port,
|
|
|
|
"nfc credits deallocation failed for hop %d\n",
|
|
|
|
i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-17 18:05:37 +03:00
|
|
|
static int __tb_path_deactivate_hop(struct tb_port *port, int hop_index)
|
|
|
|
{
|
|
|
|
struct tb_regs_hop hop;
|
|
|
|
ktime_t timeout;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Disable the path */
|
|
|
|
ret = tb_port_read(port, &hop, TB_CFG_HOPS, 2 * hop_index, 2);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* Already disabled */
|
|
|
|
if (!hop.enable)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
hop.enable = 0;
|
|
|
|
|
|
|
|
ret = tb_port_write(port, &hop, TB_CFG_HOPS, 2 * hop_index, 2);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* Wait until it is drained */
|
|
|
|
timeout = ktime_add_ms(ktime_get(), 500);
|
|
|
|
do {
|
|
|
|
ret = tb_port_read(port, &hop, TB_CFG_HOPS, 2 * hop_index, 2);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if (!hop.pending)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
usleep_range(10, 20);
|
|
|
|
} while (ktime_before(ktime_get(), timeout));
|
|
|
|
|
|
|
|
return -ETIMEDOUT;
|
|
|
|
}
|
|
|
|
|
2014-06-04 00:04:07 +04:00
|
|
|
static void __tb_path_deactivate_hops(struct tb_path *path, int first_hop)
|
|
|
|
{
|
|
|
|
int i, res;
|
2017-02-17 18:05:37 +03:00
|
|
|
|
2014-06-04 00:04:07 +04:00
|
|
|
for (i = first_hop; i < path->path_length; i++) {
|
2017-02-17 18:05:37 +03:00
|
|
|
res = __tb_path_deactivate_hop(path->hops[i].in_port,
|
|
|
|
path->hops[i].in_hop_index);
|
|
|
|
if (res && res != -ENODEV)
|
2014-06-04 00:04:07 +04:00
|
|
|
tb_port_warn(path->hops[i].in_port,
|
|
|
|
"hop deactivation failed for hop %d, index %d\n",
|
|
|
|
i, path->hops[i].in_hop_index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void tb_path_deactivate(struct tb_path *path)
|
|
|
|
{
|
|
|
|
if (!path->activated) {
|
|
|
|
tb_WARN(path->tb, "trying to deactivate an inactive path\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
tb_info(path->tb,
|
|
|
|
"deactivating path from %llx:%x to %llx:%x\n",
|
|
|
|
tb_route(path->hops[0].in_port->sw),
|
|
|
|
path->hops[0].in_port->port,
|
|
|
|
tb_route(path->hops[path->path_length - 1].out_port->sw),
|
|
|
|
path->hops[path->path_length - 1].out_port->port);
|
|
|
|
__tb_path_deactivate_hops(path, 0);
|
|
|
|
__tb_path_deallocate_nfc(path, 0);
|
|
|
|
path->activated = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* tb_path_activate() - activate a path
|
|
|
|
*
|
|
|
|
* Activate a path starting with the last hop and iterating backwards. The
|
|
|
|
* caller must fill path->hops before calling tb_path_activate().
|
|
|
|
*
|
|
|
|
* Return: Returns 0 on success or an error code on failure.
|
|
|
|
*/
|
|
|
|
int tb_path_activate(struct tb_path *path)
|
|
|
|
{
|
|
|
|
int i, res;
|
|
|
|
enum tb_path_port out_mask, in_mask;
|
|
|
|
if (path->activated) {
|
|
|
|
tb_WARN(path->tb, "trying to activate already activated path\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
tb_info(path->tb,
|
|
|
|
"activating path from %llx:%x to %llx:%x\n",
|
|
|
|
tb_route(path->hops[0].in_port->sw),
|
|
|
|
path->hops[0].in_port->port,
|
|
|
|
tb_route(path->hops[path->path_length - 1].out_port->sw),
|
|
|
|
path->hops[path->path_length - 1].out_port->port);
|
|
|
|
|
|
|
|
/* Clear counters. */
|
|
|
|
for (i = path->path_length - 1; i >= 0; i--) {
|
|
|
|
if (path->hops[i].in_counter_index == -1)
|
|
|
|
continue;
|
|
|
|
res = tb_port_clear_counter(path->hops[i].in_port,
|
|
|
|
path->hops[i].in_counter_index);
|
|
|
|
if (res)
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add non flow controlled credits. */
|
|
|
|
for (i = path->path_length - 1; i >= 0; i--) {
|
|
|
|
res = tb_port_add_nfc_credits(path->hops[i].in_port,
|
|
|
|
path->nfc_credits);
|
|
|
|
if (res) {
|
|
|
|
__tb_path_deallocate_nfc(path, i);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Activate hops. */
|
|
|
|
for (i = path->path_length - 1; i >= 0; i--) {
|
2014-08-26 19:42:21 +04:00
|
|
|
struct tb_regs_hop hop = { 0 };
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We do (currently) not tear down paths setup by the firmeware.
|
|
|
|
* If a firmware device is unplugged and plugged in again then
|
|
|
|
* it can happen that we reuse some of the hops from the (now
|
|
|
|
* defunct) firmeware path. This causes the hotplug operation to
|
|
|
|
* fail (the pci device does not show up). Clearing the hop
|
|
|
|
* before overwriting it fixes the problem.
|
|
|
|
*
|
|
|
|
* Should be removed once we discover and tear down firmeware
|
|
|
|
* paths.
|
|
|
|
*/
|
|
|
|
res = tb_port_write(path->hops[i].in_port, &hop, TB_CFG_HOPS,
|
|
|
|
2 * path->hops[i].in_hop_index, 2);
|
|
|
|
if (res) {
|
|
|
|
__tb_path_deactivate_hops(path, i);
|
|
|
|
__tb_path_deallocate_nfc(path, 0);
|
|
|
|
goto err;
|
|
|
|
}
|
2014-06-04 00:04:07 +04:00
|
|
|
|
|
|
|
/* dword 0 */
|
|
|
|
hop.next_hop = path->hops[i].next_hop_index;
|
|
|
|
hop.out_port = path->hops[i].out_port->port;
|
|
|
|
/* TODO: figure out why these are good values */
|
|
|
|
hop.initial_credits = (i == path->path_length - 1) ? 16 : 7;
|
|
|
|
hop.unknown1 = 0;
|
|
|
|
hop.enable = 1;
|
|
|
|
|
|
|
|
/* dword 1 */
|
|
|
|
out_mask = (i == path->path_length - 1) ?
|
|
|
|
TB_PATH_DESTINATION : TB_PATH_INTERNAL;
|
|
|
|
in_mask = (i == 0) ? TB_PATH_SOURCE : TB_PATH_INTERNAL;
|
|
|
|
hop.weight = path->weight;
|
|
|
|
hop.unknown2 = 0;
|
|
|
|
hop.priority = path->priority;
|
|
|
|
hop.drop_packages = path->drop_packages;
|
|
|
|
hop.counter = path->hops[i].in_counter_index;
|
|
|
|
hop.counter_enable = path->hops[i].in_counter_index != -1;
|
|
|
|
hop.ingress_fc = path->ingress_fc_enable & in_mask;
|
|
|
|
hop.egress_fc = path->egress_fc_enable & out_mask;
|
|
|
|
hop.ingress_shared_buffer = path->ingress_shared_buffer
|
|
|
|
& in_mask;
|
|
|
|
hop.egress_shared_buffer = path->egress_shared_buffer
|
|
|
|
& out_mask;
|
|
|
|
hop.unknown3 = 0;
|
|
|
|
|
|
|
|
tb_port_info(path->hops[i].in_port, "Writing hop %d, index %d",
|
|
|
|
i, path->hops[i].in_hop_index);
|
|
|
|
tb_dump_hop(path->hops[i].in_port, &hop);
|
|
|
|
res = tb_port_write(path->hops[i].in_port, &hop, TB_CFG_HOPS,
|
|
|
|
2 * path->hops[i].in_hop_index, 2);
|
|
|
|
if (res) {
|
|
|
|
__tb_path_deactivate_hops(path, i);
|
|
|
|
__tb_path_deallocate_nfc(path, 0);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
path->activated = true;
|
|
|
|
tb_info(path->tb, "path activation complete\n");
|
|
|
|
return 0;
|
|
|
|
err:
|
|
|
|
tb_WARN(path->tb, "path activation failed\n");
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* tb_path_is_invalid() - check whether any ports on the path are invalid
|
|
|
|
*
|
|
|
|
* Return: Returns true if the path is invalid, false otherwise.
|
|
|
|
*/
|
|
|
|
bool tb_path_is_invalid(struct tb_path *path)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
for (i = 0; i < path->path_length; i++) {
|
|
|
|
if (path->hops[i].in_port->sw->is_unplugged)
|
|
|
|
return true;
|
|
|
|
if (path->hops[i].out_port->sw->is_unplugged)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|