mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-27 05:35:12 +07:00
b24413180f
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>
352 lines
9.3 KiB
C
352 lines
9.3 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Functions for assembling fcx enabled I/O control blocks.
|
|
*
|
|
* Copyright IBM Corp. 2008
|
|
* Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/types.h>
|
|
#include <linux/string.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/err.h>
|
|
#include <linux/module.h>
|
|
#include <asm/fcx.h>
|
|
#include "cio.h"
|
|
|
|
/**
|
|
* tcw_get_intrg - return pointer to associated interrogate tcw
|
|
* @tcw: pointer to the original tcw
|
|
*
|
|
* Return a pointer to the interrogate tcw associated with the specified tcw
|
|
* or %NULL if there is no associated interrogate tcw.
|
|
*/
|
|
struct tcw *tcw_get_intrg(struct tcw *tcw)
|
|
{
|
|
return (struct tcw *) ((addr_t) tcw->intrg);
|
|
}
|
|
EXPORT_SYMBOL(tcw_get_intrg);
|
|
|
|
/**
|
|
* tcw_get_data - return pointer to input/output data associated with tcw
|
|
* @tcw: pointer to the tcw
|
|
*
|
|
* Return the input or output data address specified in the tcw depending
|
|
* on whether the r-bit or the w-bit is set. If neither bit is set, return
|
|
* %NULL.
|
|
*/
|
|
void *tcw_get_data(struct tcw *tcw)
|
|
{
|
|
if (tcw->r)
|
|
return (void *) ((addr_t) tcw->input);
|
|
if (tcw->w)
|
|
return (void *) ((addr_t) tcw->output);
|
|
return NULL;
|
|
}
|
|
EXPORT_SYMBOL(tcw_get_data);
|
|
|
|
/**
|
|
* tcw_get_tccb - return pointer to tccb associated with tcw
|
|
* @tcw: pointer to the tcw
|
|
*
|
|
* Return pointer to the tccb associated with this tcw.
|
|
*/
|
|
struct tccb *tcw_get_tccb(struct tcw *tcw)
|
|
{
|
|
return (struct tccb *) ((addr_t) tcw->tccb);
|
|
}
|
|
EXPORT_SYMBOL(tcw_get_tccb);
|
|
|
|
/**
|
|
* tcw_get_tsb - return pointer to tsb associated with tcw
|
|
* @tcw: pointer to the tcw
|
|
*
|
|
* Return pointer to the tsb associated with this tcw.
|
|
*/
|
|
struct tsb *tcw_get_tsb(struct tcw *tcw)
|
|
{
|
|
return (struct tsb *) ((addr_t) tcw->tsb);
|
|
}
|
|
EXPORT_SYMBOL(tcw_get_tsb);
|
|
|
|
/**
|
|
* tcw_init - initialize tcw data structure
|
|
* @tcw: pointer to the tcw to be initialized
|
|
* @r: initial value of the r-bit
|
|
* @w: initial value of the w-bit
|
|
*
|
|
* Initialize all fields of the specified tcw data structure with zero and
|
|
* fill in the format, flags, r and w fields.
|
|
*/
|
|
void tcw_init(struct tcw *tcw, int r, int w)
|
|
{
|
|
memset(tcw, 0, sizeof(struct tcw));
|
|
tcw->format = TCW_FORMAT_DEFAULT;
|
|
tcw->flags = TCW_FLAGS_TIDAW_FORMAT(TCW_TIDAW_FORMAT_DEFAULT);
|
|
if (r)
|
|
tcw->r = 1;
|
|
if (w)
|
|
tcw->w = 1;
|
|
}
|
|
EXPORT_SYMBOL(tcw_init);
|
|
|
|
static inline size_t tca_size(struct tccb *tccb)
|
|
{
|
|
return tccb->tcah.tcal - 12;
|
|
}
|
|
|
|
static u32 calc_dcw_count(struct tccb *tccb)
|
|
{
|
|
int offset;
|
|
struct dcw *dcw;
|
|
u32 count = 0;
|
|
size_t size;
|
|
|
|
size = tca_size(tccb);
|
|
for (offset = 0; offset < size;) {
|
|
dcw = (struct dcw *) &tccb->tca[offset];
|
|
count += dcw->count;
|
|
if (!(dcw->flags & DCW_FLAGS_CC))
|
|
break;
|
|
offset += sizeof(struct dcw) + ALIGN((int) dcw->cd_count, 4);
|
|
}
|
|
return count;
|
|
}
|
|
|
|
static u32 calc_cbc_size(struct tidaw *tidaw, int num)
|
|
{
|
|
int i;
|
|
u32 cbc_data;
|
|
u32 cbc_count = 0;
|
|
u64 data_count = 0;
|
|
|
|
for (i = 0; i < num; i++) {
|
|
if (tidaw[i].flags & TIDAW_FLAGS_LAST)
|
|
break;
|
|
/* TODO: find out if padding applies to total of data
|
|
* transferred or data transferred by this tidaw. Assumption:
|
|
* applies to total. */
|
|
data_count += tidaw[i].count;
|
|
if (tidaw[i].flags & TIDAW_FLAGS_INSERT_CBC) {
|
|
cbc_data = 4 + ALIGN(data_count, 4) - data_count;
|
|
cbc_count += cbc_data;
|
|
data_count += cbc_data;
|
|
}
|
|
}
|
|
return cbc_count;
|
|
}
|
|
|
|
/**
|
|
* tcw_finalize - finalize tcw length fields and tidaw list
|
|
* @tcw: pointer to the tcw
|
|
* @num_tidaws: the number of tidaws used to address input/output data or zero
|
|
* if no tida is used
|
|
*
|
|
* Calculate the input-/output-count and tccbl field in the tcw, add a
|
|
* tcat the tccb and terminate the data tidaw list if used.
|
|
*
|
|
* Note: in case input- or output-tida is used, the tidaw-list must be stored
|
|
* in contiguous storage (no ttic). The tcal field in the tccb must be
|
|
* up-to-date.
|
|
*/
|
|
void tcw_finalize(struct tcw *tcw, int num_tidaws)
|
|
{
|
|
struct tidaw *tidaw;
|
|
struct tccb *tccb;
|
|
struct tccb_tcat *tcat;
|
|
u32 count;
|
|
|
|
/* Terminate tidaw list. */
|
|
tidaw = tcw_get_data(tcw);
|
|
if (num_tidaws > 0)
|
|
tidaw[num_tidaws - 1].flags |= TIDAW_FLAGS_LAST;
|
|
/* Add tcat to tccb. */
|
|
tccb = tcw_get_tccb(tcw);
|
|
tcat = (struct tccb_tcat *) &tccb->tca[tca_size(tccb)];
|
|
memset(tcat, 0, sizeof(*tcat));
|
|
/* Calculate tcw input/output count and tcat transport count. */
|
|
count = calc_dcw_count(tccb);
|
|
if (tcw->w && (tcw->flags & TCW_FLAGS_OUTPUT_TIDA))
|
|
count += calc_cbc_size(tidaw, num_tidaws);
|
|
if (tcw->r)
|
|
tcw->input_count = count;
|
|
else if (tcw->w)
|
|
tcw->output_count = count;
|
|
tcat->count = ALIGN(count, 4) + 4;
|
|
/* Calculate tccbl. */
|
|
tcw->tccbl = (sizeof(struct tccb) + tca_size(tccb) +
|
|
sizeof(struct tccb_tcat) - 20) >> 2;
|
|
}
|
|
EXPORT_SYMBOL(tcw_finalize);
|
|
|
|
/**
|
|
* tcw_set_intrg - set the interrogate tcw address of a tcw
|
|
* @tcw: the tcw address
|
|
* @intrg_tcw: the address of the interrogate tcw
|
|
*
|
|
* Set the address of the interrogate tcw in the specified tcw.
|
|
*/
|
|
void tcw_set_intrg(struct tcw *tcw, struct tcw *intrg_tcw)
|
|
{
|
|
tcw->intrg = (u32) ((addr_t) intrg_tcw);
|
|
}
|
|
EXPORT_SYMBOL(tcw_set_intrg);
|
|
|
|
/**
|
|
* tcw_set_data - set data address and tida flag of a tcw
|
|
* @tcw: the tcw address
|
|
* @data: the data address
|
|
* @use_tidal: zero of the data address specifies a contiguous block of data,
|
|
* non-zero if it specifies a list if tidaws.
|
|
*
|
|
* Set the input/output data address of a tcw (depending on the value of the
|
|
* r-flag and w-flag). If @use_tidal is non-zero, the corresponding tida flag
|
|
* is set as well.
|
|
*/
|
|
void tcw_set_data(struct tcw *tcw, void *data, int use_tidal)
|
|
{
|
|
if (tcw->r) {
|
|
tcw->input = (u64) ((addr_t) data);
|
|
if (use_tidal)
|
|
tcw->flags |= TCW_FLAGS_INPUT_TIDA;
|
|
} else if (tcw->w) {
|
|
tcw->output = (u64) ((addr_t) data);
|
|
if (use_tidal)
|
|
tcw->flags |= TCW_FLAGS_OUTPUT_TIDA;
|
|
}
|
|
}
|
|
EXPORT_SYMBOL(tcw_set_data);
|
|
|
|
/**
|
|
* tcw_set_tccb - set tccb address of a tcw
|
|
* @tcw: the tcw address
|
|
* @tccb: the tccb address
|
|
*
|
|
* Set the address of the tccb in the specified tcw.
|
|
*/
|
|
void tcw_set_tccb(struct tcw *tcw, struct tccb *tccb)
|
|
{
|
|
tcw->tccb = (u64) ((addr_t) tccb);
|
|
}
|
|
EXPORT_SYMBOL(tcw_set_tccb);
|
|
|
|
/**
|
|
* tcw_set_tsb - set tsb address of a tcw
|
|
* @tcw: the tcw address
|
|
* @tsb: the tsb address
|
|
*
|
|
* Set the address of the tsb in the specified tcw.
|
|
*/
|
|
void tcw_set_tsb(struct tcw *tcw, struct tsb *tsb)
|
|
{
|
|
tcw->tsb = (u64) ((addr_t) tsb);
|
|
}
|
|
EXPORT_SYMBOL(tcw_set_tsb);
|
|
|
|
/**
|
|
* tccb_init - initialize tccb
|
|
* @tccb: the tccb address
|
|
* @size: the maximum size of the tccb
|
|
* @sac: the service-action-code to be user
|
|
*
|
|
* Initialize the header of the specified tccb by resetting all values to zero
|
|
* and filling in defaults for format, sac and initial tcal fields.
|
|
*/
|
|
void tccb_init(struct tccb *tccb, size_t size, u32 sac)
|
|
{
|
|
memset(tccb, 0, size);
|
|
tccb->tcah.format = TCCB_FORMAT_DEFAULT;
|
|
tccb->tcah.sac = sac;
|
|
tccb->tcah.tcal = 12;
|
|
}
|
|
EXPORT_SYMBOL(tccb_init);
|
|
|
|
/**
|
|
* tsb_init - initialize tsb
|
|
* @tsb: the tsb address
|
|
*
|
|
* Initialize the specified tsb by resetting all values to zero.
|
|
*/
|
|
void tsb_init(struct tsb *tsb)
|
|
{
|
|
memset(tsb, 0, sizeof(*tsb));
|
|
}
|
|
EXPORT_SYMBOL(tsb_init);
|
|
|
|
/**
|
|
* tccb_add_dcw - add a dcw to the tccb
|
|
* @tccb: the tccb address
|
|
* @tccb_size: the maximum tccb size
|
|
* @cmd: the dcw command
|
|
* @flags: flags for the dcw
|
|
* @cd: pointer to control data for this dcw or NULL if none is required
|
|
* @cd_count: number of control data bytes for this dcw
|
|
* @count: number of data bytes for this dcw
|
|
*
|
|
* Add a new dcw to the specified tccb by writing the dcw information specified
|
|
* by @cmd, @flags, @cd, @cd_count and @count to the tca of the tccb. Return
|
|
* a pointer to the newly added dcw on success or -%ENOSPC if the new dcw
|
|
* would exceed the available space as defined by @tccb_size.
|
|
*
|
|
* Note: the tcal field of the tccb header will be updates to reflect added
|
|
* content.
|
|
*/
|
|
struct dcw *tccb_add_dcw(struct tccb *tccb, size_t tccb_size, u8 cmd, u8 flags,
|
|
void *cd, u8 cd_count, u32 count)
|
|
{
|
|
struct dcw *dcw;
|
|
int size;
|
|
int tca_offset;
|
|
|
|
/* Check for space. */
|
|
tca_offset = tca_size(tccb);
|
|
size = ALIGN(sizeof(struct dcw) + cd_count, 4);
|
|
if (sizeof(struct tccb_tcah) + tca_offset + size +
|
|
sizeof(struct tccb_tcat) > tccb_size)
|
|
return ERR_PTR(-ENOSPC);
|
|
/* Add dcw to tca. */
|
|
dcw = (struct dcw *) &tccb->tca[tca_offset];
|
|
memset(dcw, 0, size);
|
|
dcw->cmd = cmd;
|
|
dcw->flags = flags;
|
|
dcw->count = count;
|
|
dcw->cd_count = cd_count;
|
|
if (cd)
|
|
memcpy(&dcw->cd[0], cd, cd_count);
|
|
tccb->tcah.tcal += size;
|
|
return dcw;
|
|
}
|
|
EXPORT_SYMBOL(tccb_add_dcw);
|
|
|
|
/**
|
|
* tcw_add_tidaw - add a tidaw to a tcw
|
|
* @tcw: the tcw address
|
|
* @num_tidaws: the current number of tidaws
|
|
* @flags: flags for the new tidaw
|
|
* @addr: address value for the new tidaw
|
|
* @count: count value for the new tidaw
|
|
*
|
|
* Add a new tidaw to the input/output data tidaw-list of the specified tcw
|
|
* (depending on the value of the r-flag and w-flag) and return a pointer to
|
|
* the new tidaw.
|
|
*
|
|
* Note: the tidaw-list is assumed to be contiguous with no ttics. The caller
|
|
* must ensure that there is enough space for the new tidaw. The last-tidaw
|
|
* flag for the last tidaw in the list will be set by tcw_finalize.
|
|
*/
|
|
struct tidaw *tcw_add_tidaw(struct tcw *tcw, int num_tidaws, u8 flags,
|
|
void *addr, u32 count)
|
|
{
|
|
struct tidaw *tidaw;
|
|
|
|
/* Add tidaw to tidaw-list. */
|
|
tidaw = ((struct tidaw *) tcw_get_data(tcw)) + num_tidaws;
|
|
memset(tidaw, 0, sizeof(struct tidaw));
|
|
tidaw->flags = flags;
|
|
tidaw->count = count;
|
|
tidaw->addr = (u64) ((addr_t) addr);
|
|
return tidaw;
|
|
}
|
|
EXPORT_SYMBOL(tcw_add_tidaw);
|