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 14:07:57 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2008-10-16 05:01:03 +00:00
|
|
|
#ifndef __LINUX_SWIOTLB_H
|
|
|
|
#define __LINUX_SWIOTLB_H
|
|
|
|
|
2021-06-19 03:40:35 +00:00
|
|
|
#include <linux/device.h>
|
2015-07-01 12:17:58 +00:00
|
|
|
#include <linux/dma-direction.h>
|
|
|
|
#include <linux/init.h>
|
2008-10-16 05:01:03 +00:00
|
|
|
#include <linux/types.h>
|
2020-11-02 01:43:27 +00:00
|
|
|
#include <linux/limits.h>
|
2021-03-18 16:14:22 +00:00
|
|
|
#include <linux/spinlock.h>
|
2008-10-16 05:01:03 +00:00
|
|
|
|
|
|
|
struct device;
|
2015-07-01 12:17:58 +00:00
|
|
|
struct page;
|
2008-10-16 05:01:03 +00:00
|
|
|
struct scatterlist;
|
|
|
|
|
2022-03-29 15:27:33 +00:00
|
|
|
#define SWIOTLB_VERBOSE (1 << 0) /* verbose initialization */
|
|
|
|
#define SWIOTLB_FORCE (1 << 1) /* force bounce buffering */
|
2022-02-28 11:36:57 +00:00
|
|
|
#define SWIOTLB_ANY (1 << 2) /* allow any memory for the buffer */
|
2016-12-16 13:28:41 +00:00
|
|
|
|
2008-12-16 20:17:27 +00:00
|
|
|
/*
|
|
|
|
* Maximum allowable number of contiguous slabs to map,
|
|
|
|
* must be a power of 2. What is the appropriate value ?
|
|
|
|
* The complexity of {map,unmap}_single is linearly dependent on this value.
|
|
|
|
*/
|
|
|
|
#define IO_TLB_SEGSIZE 128
|
|
|
|
|
|
|
|
/*
|
|
|
|
* log of the size of each IO TLB slab. The number of slabs is command line
|
|
|
|
* controllable.
|
|
|
|
*/
|
|
|
|
#define IO_TLB_SHIFT 11
|
2021-02-05 10:18:40 +00:00
|
|
|
#define IO_TLB_SIZE (1 << IO_TLB_SHIFT)
|
2008-12-16 20:17:27 +00:00
|
|
|
|
2020-12-10 01:25:15 +00:00
|
|
|
/* default to 64MB */
|
|
|
|
#define IO_TLB_DEFAULT_SIZE (64UL<<20)
|
|
|
|
|
2013-04-16 05:23:45 +00:00
|
|
|
unsigned long swiotlb_size_or_default(void);
|
2022-03-14 07:02:57 +00:00
|
|
|
void __init swiotlb_init_remap(bool addressing_limit, unsigned int flags,
|
|
|
|
int (*remap)(void *tlb, unsigned long nslabs));
|
|
|
|
int swiotlb_init_late(size_t size, gfp_t gfp_mask,
|
|
|
|
int (*remap)(void *tlb, unsigned long nslabs));
|
2017-07-17 21:10:21 +00:00
|
|
|
extern void __init swiotlb_update_mem_attributes(void);
|
2008-10-16 05:01:03 +00:00
|
|
|
|
2020-10-23 06:33:09 +00:00
|
|
|
phys_addr_t swiotlb_tbl_map_single(struct device *hwdev, phys_addr_t phys,
|
|
|
|
size_t mapping_size, size_t alloc_size,
|
2021-09-29 02:32:59 +00:00
|
|
|
unsigned int alloc_aligned_mask, enum dma_data_direction dir,
|
|
|
|
unsigned long attrs);
|
2010-05-28 15:37:10 +00:00
|
|
|
|
2012-10-15 17:19:44 +00:00
|
|
|
extern void swiotlb_tbl_unmap_single(struct device *hwdev,
|
|
|
|
phys_addr_t tlb_addr,
|
2019-09-06 06:14:48 +00:00
|
|
|
size_t mapping_size,
|
|
|
|
enum dma_data_direction dir,
|
2016-11-02 11:13:02 +00:00
|
|
|
unsigned long attrs);
|
2010-05-28 15:37:10 +00:00
|
|
|
|
2021-03-01 07:44:26 +00:00
|
|
|
void swiotlb_sync_single_for_device(struct device *dev, phys_addr_t tlb_addr,
|
|
|
|
size_t size, enum dma_data_direction dir);
|
|
|
|
void swiotlb_sync_single_for_cpu(struct device *dev, phys_addr_t tlb_addr,
|
|
|
|
size_t size, enum dma_data_direction dir);
|
2020-02-03 13:44:38 +00:00
|
|
|
dma_addr_t swiotlb_map(struct device *dev, phys_addr_t phys,
|
|
|
|
size_t size, enum dma_data_direction dir, unsigned long attrs);
|
|
|
|
|
2009-11-10 10:46:18 +00:00
|
|
|
#ifdef CONFIG_SWIOTLB
|
2018-12-03 10:43:54 +00:00
|
|
|
extern enum swiotlb_force swiotlb_force;
|
2021-03-18 16:14:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* struct io_tlb_mem - IO TLB Memory Pool Descriptor
|
|
|
|
*
|
|
|
|
* @start: The start address of the swiotlb memory pool. Used to do a quick
|
|
|
|
* range check to see if the memory was in fact allocated by this
|
|
|
|
* API.
|
|
|
|
* @end: The end address of the swiotlb memory pool. Used to do a quick
|
|
|
|
* range check to see if the memory was in fact allocated by this
|
|
|
|
* API.
|
2021-12-13 07:14:02 +00:00
|
|
|
* @vaddr: The vaddr of the swiotlb memory pool. The swiotlb memory pool
|
|
|
|
* may be remapped in the memory encrypted case and store virtual
|
|
|
|
* address for bounce buffer operation.
|
2021-03-18 16:14:22 +00:00
|
|
|
* @nslabs: The number of IO TLB blocks (in groups of 64) between @start and
|
2021-06-19 03:40:41 +00:00
|
|
|
* @end. For default swiotlb, this is command line adjustable via
|
|
|
|
* setup_io_tlb_npages.
|
2021-03-18 16:14:22 +00:00
|
|
|
* @used: The number of used IO TLB block.
|
|
|
|
* @list: The free list describing the number of free entries available
|
|
|
|
* from each index.
|
|
|
|
* @index: The index to start searching in the next round.
|
|
|
|
* @orig_addr: The original address corresponding to a mapped entry.
|
|
|
|
* @alloc_size: Size of the allocated buffer.
|
|
|
|
* @lock: The lock to protect the above data structures in the map and
|
|
|
|
* unmap calls.
|
|
|
|
* @debugfs: The dentry to debugfs.
|
|
|
|
* @late_alloc: %true if allocated using the page allocator
|
2021-06-24 15:55:20 +00:00
|
|
|
* @force_bounce: %true if swiotlb bouncing is forced
|
2021-06-19 03:40:40 +00:00
|
|
|
* @for_alloc: %true if the pool is used for memory allocation
|
2021-03-18 16:14:22 +00:00
|
|
|
*/
|
|
|
|
struct io_tlb_mem {
|
|
|
|
phys_addr_t start;
|
|
|
|
phys_addr_t end;
|
2021-12-13 07:14:02 +00:00
|
|
|
void *vaddr;
|
2021-03-18 16:14:22 +00:00
|
|
|
unsigned long nslabs;
|
|
|
|
unsigned long used;
|
|
|
|
unsigned int index;
|
|
|
|
spinlock_t lock;
|
|
|
|
struct dentry *debugfs;
|
|
|
|
bool late_alloc;
|
2021-06-24 15:55:20 +00:00
|
|
|
bool force_bounce;
|
2021-06-19 03:40:40 +00:00
|
|
|
bool for_alloc;
|
2021-03-18 16:14:23 +00:00
|
|
|
struct io_tlb_slot {
|
|
|
|
phys_addr_t orig_addr;
|
|
|
|
size_t alloc_size;
|
|
|
|
unsigned int list;
|
2021-07-20 13:38:24 +00:00
|
|
|
} *slots;
|
2021-03-18 16:14:22 +00:00
|
|
|
};
|
2021-07-20 13:38:24 +00:00
|
|
|
extern struct io_tlb_mem io_tlb_default_mem;
|
2018-12-03 10:43:54 +00:00
|
|
|
|
2021-06-19 03:40:35 +00:00
|
|
|
static inline bool is_swiotlb_buffer(struct device *dev, phys_addr_t paddr)
|
2018-12-03 10:43:54 +00:00
|
|
|
{
|
2021-06-19 03:40:35 +00:00
|
|
|
struct io_tlb_mem *mem = dev->dma_io_tlb_mem;
|
2021-03-18 16:14:22 +00:00
|
|
|
|
2021-03-18 16:14:23 +00:00
|
|
|
return mem && paddr >= mem->start && paddr < mem->end;
|
2018-12-03 10:43:54 +00:00
|
|
|
}
|
|
|
|
|
2021-06-24 15:55:20 +00:00
|
|
|
static inline bool is_swiotlb_force_bounce(struct device *dev)
|
|
|
|
{
|
|
|
|
struct io_tlb_mem *mem = dev->dma_io_tlb_mem;
|
|
|
|
|
|
|
|
return mem && mem->force_bounce;
|
|
|
|
}
|
|
|
|
|
2022-03-29 15:27:33 +00:00
|
|
|
void swiotlb_init(bool addressing_limited, unsigned int flags);
|
2018-12-03 10:43:54 +00:00
|
|
|
void __init swiotlb_exit(void);
|
2016-12-20 15:02:02 +00:00
|
|
|
unsigned int swiotlb_max_segment(void);
|
2019-02-07 11:59:13 +00:00
|
|
|
size_t swiotlb_max_mapping_size(struct device *dev);
|
2021-06-19 03:40:36 +00:00
|
|
|
bool is_swiotlb_active(struct device *dev);
|
2021-03-18 16:14:23 +00:00
|
|
|
void __init swiotlb_adjust_size(unsigned long size);
|
2009-11-10 10:46:18 +00:00
|
|
|
#else
|
2022-03-29 15:27:33 +00:00
|
|
|
static inline void swiotlb_init(bool addressing_limited, unsigned int flags)
|
|
|
|
{
|
|
|
|
}
|
2021-06-19 03:40:35 +00:00
|
|
|
static inline bool is_swiotlb_buffer(struct device *dev, phys_addr_t paddr)
|
2018-12-03 10:43:54 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2021-06-24 15:55:20 +00:00
|
|
|
static inline bool is_swiotlb_force_bounce(struct device *dev)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2018-12-03 10:43:54 +00:00
|
|
|
static inline void swiotlb_exit(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static inline unsigned int swiotlb_max_segment(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2019-02-07 11:59:13 +00:00
|
|
|
static inline size_t swiotlb_max_mapping_size(struct device *dev)
|
|
|
|
{
|
|
|
|
return SIZE_MAX;
|
|
|
|
}
|
2019-02-07 11:59:14 +00:00
|
|
|
|
2021-06-19 03:40:36 +00:00
|
|
|
static inline bool is_swiotlb_active(struct device *dev)
|
2019-02-07 11:59:14 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2020-12-10 01:25:15 +00:00
|
|
|
|
2021-03-18 16:14:23 +00:00
|
|
|
static inline void swiotlb_adjust_size(unsigned long size)
|
2020-12-10 01:25:15 +00:00
|
|
|
{
|
|
|
|
}
|
2018-12-03 10:43:54 +00:00
|
|
|
#endif /* CONFIG_SWIOTLB */
|
2009-11-10 10:46:18 +00:00
|
|
|
|
2009-11-10 10:46:19 +00:00
|
|
|
extern void swiotlb_print_info(void);
|
2014-06-04 23:06:50 +00:00
|
|
|
|
2021-06-19 03:40:40 +00:00
|
|
|
#ifdef CONFIG_DMA_RESTRICTED_POOL
|
|
|
|
struct page *swiotlb_alloc(struct device *dev, size_t size);
|
|
|
|
bool swiotlb_free(struct device *dev, struct page *page, size_t size);
|
|
|
|
|
|
|
|
static inline bool is_swiotlb_for_alloc(struct device *dev)
|
|
|
|
{
|
|
|
|
return dev->dma_io_tlb_mem->for_alloc;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static inline struct page *swiotlb_alloc(struct device *dev, size_t size)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
static inline bool swiotlb_free(struct device *dev, struct page *page,
|
|
|
|
size_t size)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
static inline bool is_swiotlb_for_alloc(struct device *dev)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_DMA_RESTRICTED_POOL */
|
|
|
|
|
2021-12-13 07:14:02 +00:00
|
|
|
extern phys_addr_t swiotlb_unencrypted_base;
|
|
|
|
|
2008-10-16 05:01:03 +00:00
|
|
|
#endif /* __LINUX_SWIOTLB_H */
|