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 */
|
2016-01-16 08:56:19 +08:00
|
|
|
#ifndef _LINUX_MEMREMAP_H_
|
|
|
|
#define _LINUX_MEMREMAP_H_
|
2016-01-16 08:56:49 +08:00
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/percpu-refcount.h>
|
2016-01-16 08:56:19 +08:00
|
|
|
|
2017-09-09 07:11:43 +08:00
|
|
|
#include <asm/pgtable.h>
|
|
|
|
|
2016-01-16 08:56:19 +08:00
|
|
|
struct resource;
|
|
|
|
struct device;
|
2016-01-16 08:56:22 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* struct vmem_altmap - pre-allocated storage for vmemmap_populate
|
|
|
|
* @base_pfn: base of the entire dev_pagemap mapping
|
|
|
|
* @reserve: pages mapped, but reserved for driver use (relative to @base)
|
|
|
|
* @free: free pages set aside in the mapping for memmap storage
|
|
|
|
* @align: pages reserved to meet allocation alignments
|
|
|
|
* @alloc: track pages consumed, private to vmemmap_populate()
|
|
|
|
*/
|
|
|
|
struct vmem_altmap {
|
|
|
|
const unsigned long base_pfn;
|
|
|
|
const unsigned long reserve;
|
|
|
|
unsigned long free;
|
|
|
|
unsigned long align;
|
|
|
|
unsigned long alloc;
|
|
|
|
};
|
|
|
|
|
2017-09-09 07:11:43 +08:00
|
|
|
/*
|
|
|
|
* Specialize ZONE_DEVICE memory into multiple types each having differents
|
|
|
|
* usage.
|
|
|
|
*
|
|
|
|
* MEMORY_DEVICE_PRIVATE:
|
|
|
|
* Device memory that is not directly addressable by the CPU: CPU can neither
|
|
|
|
* read nor write private memory. In this case, we do still have struct pages
|
|
|
|
* backing the device memory. Doing so simplifies the implementation, but it is
|
|
|
|
* important to remember that there are certain points at which the struct page
|
|
|
|
* must be treated as an opaque object, rather than a "normal" struct page.
|
|
|
|
*
|
|
|
|
* A more complete discussion of unaddressable memory may be found in
|
2018-03-22 03:22:47 +08:00
|
|
|
* include/linux/hmm.h and Documentation/vm/hmm.rst.
|
2017-09-09 07:12:24 +08:00
|
|
|
*
|
|
|
|
* MEMORY_DEVICE_PUBLIC:
|
|
|
|
* Device memory that is cache coherent from device and CPU point of view. This
|
|
|
|
* is use on platform that have an advance system bus (like CAPI or CCIX). A
|
|
|
|
* driver can hotplug the device memory using ZONE_DEVICE and with that memory
|
|
|
|
* type. Any page of a process can be migrated to such memory. However no one
|
|
|
|
* should be allow to pin such memory so that it can always be evicted.
|
2018-05-17 02:46:08 +08:00
|
|
|
*
|
|
|
|
* MEMORY_DEVICE_FS_DAX:
|
|
|
|
* Host memory that has similar access semantics as System RAM i.e. DMA
|
|
|
|
* coherent and supports page pinning. In support of coordinating page
|
|
|
|
* pinning vs other operations MEMORY_DEVICE_FS_DAX arranges for a
|
|
|
|
* wakeup event whenever a page is unpinned and becomes idle. This
|
|
|
|
* wakeup is used to coordinate physical address space management (ex:
|
|
|
|
* fs truncate/hole punch) vs pinned pages (ex: device dma).
|
2017-09-09 07:11:43 +08:00
|
|
|
*/
|
|
|
|
enum memory_type {
|
2018-05-17 02:46:08 +08:00
|
|
|
MEMORY_DEVICE_PRIVATE = 1,
|
2017-09-09 07:12:24 +08:00
|
|
|
MEMORY_DEVICE_PUBLIC,
|
2018-05-17 02:46:08 +08:00
|
|
|
MEMORY_DEVICE_FS_DAX,
|
2017-09-09 07:11:43 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For MEMORY_DEVICE_PRIVATE we use ZONE_DEVICE and extend it with two
|
|
|
|
* callbacks:
|
|
|
|
* page_fault()
|
|
|
|
* page_free()
|
|
|
|
*
|
|
|
|
* Additional notes about MEMORY_DEVICE_PRIVATE may be found in
|
2018-03-22 03:22:47 +08:00
|
|
|
* include/linux/hmm.h and Documentation/vm/hmm.rst. There is also a brief
|
2017-09-09 07:11:43 +08:00
|
|
|
* explanation in include/linux/memory_hotplug.h.
|
|
|
|
*
|
|
|
|
* The page_fault() callback must migrate page back, from device memory to
|
|
|
|
* system memory, so that the CPU can access it. This might fail for various
|
|
|
|
* reasons (device issues, device have been unplugged, ...). When such error
|
|
|
|
* conditions happen, the page_fault() callback must return VM_FAULT_SIGBUS and
|
|
|
|
* set the CPU page table entry to "poisoned".
|
|
|
|
*
|
|
|
|
* Note that because memory cgroup charges are transferred to the device memory,
|
|
|
|
* this should never fail due to memory restrictions. However, allocation
|
|
|
|
* of a regular system page might still fail because we are out of memory. If
|
|
|
|
* that happens, the page_fault() callback must return VM_FAULT_OOM.
|
|
|
|
*
|
|
|
|
* The page_fault() callback can also try to migrate back multiple pages in one
|
|
|
|
* chunk, as an optimization. It must, however, prioritize the faulting address
|
|
|
|
* over all the others.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* The page_free() callback is called once the page refcount reaches 1
|
|
|
|
* (ZONE_DEVICE pages never reach 0 refcount unless there is a refcount bug.
|
|
|
|
* This allows the device driver to implement its own memory management.)
|
2017-09-09 07:12:24 +08:00
|
|
|
*
|
|
|
|
* For MEMORY_DEVICE_PUBLIC only the page_free() callback matter.
|
2017-09-09 07:11:43 +08:00
|
|
|
*/
|
|
|
|
typedef int (*dev_page_fault_t)(struct vm_area_struct *vma,
|
|
|
|
unsigned long addr,
|
|
|
|
const struct page *page,
|
|
|
|
unsigned int flags,
|
|
|
|
pmd_t *pmdp);
|
|
|
|
typedef void (*dev_page_free_t)(struct page *page, void *data);
|
|
|
|
|
2016-01-16 08:56:19 +08:00
|
|
|
/**
|
|
|
|
* struct dev_pagemap - metadata for ZONE_DEVICE mappings
|
2017-09-09 07:11:43 +08:00
|
|
|
* @page_fault: callback when CPU fault on an unaddressable device page
|
|
|
|
* @page_free: free page callback when page refcount reaches 1
|
2016-01-16 08:56:22 +08:00
|
|
|
* @altmap: pre-allocated/reserved memory for vmemmap allocations
|
2016-01-16 08:56:49 +08:00
|
|
|
* @res: physical address range covered by @ref
|
|
|
|
* @ref: reference count that pins the devm_memremap_pages() mapping
|
2016-01-16 08:56:19 +08:00
|
|
|
* @dev: host device of the mapping for debug
|
2017-09-09 07:11:43 +08:00
|
|
|
* @data: private data pointer for page_free()
|
|
|
|
* @type: memory type: see MEMORY_* in memory_hotplug.h
|
2016-01-16 08:56:19 +08:00
|
|
|
*/
|
|
|
|
struct dev_pagemap {
|
2017-09-09 07:11:43 +08:00
|
|
|
dev_page_fault_t page_fault;
|
|
|
|
dev_page_free_t page_free;
|
2017-12-29 15:54:04 +08:00
|
|
|
struct vmem_altmap altmap;
|
|
|
|
bool altmap_valid;
|
|
|
|
struct resource res;
|
2016-01-16 08:56:49 +08:00
|
|
|
struct percpu_ref *ref;
|
2016-01-16 08:56:19 +08:00
|
|
|
struct device *dev;
|
2017-09-09 07:11:43 +08:00
|
|
|
void *data;
|
|
|
|
enum memory_type type;
|
2016-01-16 08:56:19 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef CONFIG_ZONE_DEVICE
|
2017-12-29 15:54:05 +08:00
|
|
|
void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap);
|
2017-12-29 15:54:00 +08:00
|
|
|
struct dev_pagemap *get_dev_pagemap(unsigned long pfn,
|
|
|
|
struct dev_pagemap *pgmap);
|
2017-09-09 07:11:46 +08:00
|
|
|
|
2017-12-29 15:53:50 +08:00
|
|
|
unsigned long vmem_altmap_offset(struct vmem_altmap *altmap);
|
|
|
|
void vmem_altmap_free(struct vmem_altmap *altmap, unsigned long nr_pfns);
|
2016-01-16 08:56:19 +08:00
|
|
|
#else
|
|
|
|
static inline void *devm_memremap_pages(struct device *dev,
|
2017-12-29 15:54:05 +08:00
|
|
|
struct dev_pagemap *pgmap)
|
2016-01-16 08:56:19 +08:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Fail attempts to call devm_memremap_pages() without
|
|
|
|
* ZONE_DEVICE support enabled, this requires callers to fall
|
|
|
|
* back to plain devm_memremap() based on config
|
|
|
|
*/
|
|
|
|
WARN_ON_ONCE(1);
|
|
|
|
return ERR_PTR(-ENXIO);
|
|
|
|
}
|
|
|
|
|
2017-12-29 15:54:00 +08:00
|
|
|
static inline struct dev_pagemap *get_dev_pagemap(unsigned long pfn,
|
|
|
|
struct dev_pagemap *pgmap)
|
2016-01-16 08:56:19 +08:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2017-12-29 15:53:50 +08:00
|
|
|
|
|
|
|
static inline unsigned long vmem_altmap_offset(struct vmem_altmap *altmap)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void vmem_altmap_free(struct vmem_altmap *altmap,
|
|
|
|
unsigned long nr_pfns)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_ZONE_DEVICE */
|
2017-09-09 07:11:46 +08:00
|
|
|
|
2016-01-16 08:56:49 +08:00
|
|
|
static inline void put_dev_pagemap(struct dev_pagemap *pgmap)
|
|
|
|
{
|
|
|
|
if (pgmap)
|
|
|
|
percpu_ref_put(pgmap->ref);
|
|
|
|
}
|
2016-01-16 08:56:19 +08:00
|
|
|
#endif /* _LINUX_MEMREMAP_H_ */
|