mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +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>
373 lines
8.6 KiB
C
373 lines
8.6 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Simulated SCSI driver.
|
|
*
|
|
* Copyright (C) 1999, 2001-2003 Hewlett-Packard Co
|
|
* David Mosberger-Tang <davidm@hpl.hp.com>
|
|
* Stephane Eranian <eranian@hpl.hp.com>
|
|
*
|
|
* 02/01/15 David Mosberger Updated for v2.5.1
|
|
* 99/12/18 David Mosberger Added support for READ10/WRITE10 needed by linux v2.3.33
|
|
*/
|
|
#include <linux/blkdev.h>
|
|
#include <linux/init.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/timer.h>
|
|
#include <asm/irq.h>
|
|
#include "hpsim_ssc.h"
|
|
|
|
#include <scsi/scsi.h>
|
|
#include <scsi/scsi_cmnd.h>
|
|
#include <scsi/scsi_device.h>
|
|
#include <scsi/scsi_host.h>
|
|
|
|
#define DEBUG_SIMSCSI 0
|
|
|
|
#define SIMSCSI_REQ_QUEUE_LEN 64
|
|
#define DEFAULT_SIMSCSI_ROOT "/var/ski-disks/sd"
|
|
|
|
/* Simulator system calls: */
|
|
|
|
#define SSC_OPEN 50
|
|
#define SSC_CLOSE 51
|
|
#define SSC_READ 52
|
|
#define SSC_WRITE 53
|
|
#define SSC_GET_COMPLETION 54
|
|
#define SSC_WAIT_COMPLETION 55
|
|
|
|
#define SSC_WRITE_ACCESS 2
|
|
#define SSC_READ_ACCESS 1
|
|
|
|
#if DEBUG_SIMSCSI
|
|
int simscsi_debug;
|
|
# define DBG simscsi_debug
|
|
#else
|
|
# define DBG 0
|
|
#endif
|
|
|
|
static struct Scsi_Host *host;
|
|
|
|
static void simscsi_interrupt (unsigned long val);
|
|
static DECLARE_TASKLET(simscsi_tasklet, simscsi_interrupt, 0);
|
|
|
|
struct disk_req {
|
|
unsigned long addr;
|
|
unsigned len;
|
|
};
|
|
|
|
struct disk_stat {
|
|
int fd;
|
|
unsigned count;
|
|
};
|
|
|
|
static int desc[16] = {
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
|
|
};
|
|
|
|
static struct queue_entry {
|
|
struct scsi_cmnd *sc;
|
|
} queue[SIMSCSI_REQ_QUEUE_LEN];
|
|
|
|
static int rd, wr;
|
|
static atomic_t num_reqs = ATOMIC_INIT(0);
|
|
|
|
/* base name for default disks */
|
|
static char *simscsi_root = DEFAULT_SIMSCSI_ROOT;
|
|
|
|
#define MAX_ROOT_LEN 128
|
|
|
|
/*
|
|
* used to setup a new base for disk images
|
|
* to use /foo/bar/disk[a-z] as disk images
|
|
* you have to specify simscsi=/foo/bar/disk on the command line
|
|
*/
|
|
static int __init
|
|
simscsi_setup (char *s)
|
|
{
|
|
/* XXX Fix me we may need to strcpy() ? */
|
|
if (strlen(s) > MAX_ROOT_LEN) {
|
|
printk(KERN_ERR "simscsi_setup: prefix too long---using default %s\n",
|
|
simscsi_root);
|
|
} else
|
|
simscsi_root = s;
|
|
return 1;
|
|
}
|
|
|
|
__setup("simscsi=", simscsi_setup);
|
|
|
|
static void
|
|
simscsi_interrupt (unsigned long val)
|
|
{
|
|
struct scsi_cmnd *sc;
|
|
|
|
while ((sc = queue[rd].sc) != NULL) {
|
|
atomic_dec(&num_reqs);
|
|
queue[rd].sc = NULL;
|
|
if (DBG)
|
|
printk("simscsi_interrupt: done with %ld\n", sc->serial_number);
|
|
(*sc->scsi_done)(sc);
|
|
rd = (rd + 1) % SIMSCSI_REQ_QUEUE_LEN;
|
|
}
|
|
}
|
|
|
|
static int
|
|
simscsi_biosparam (struct scsi_device *sdev, struct block_device *n,
|
|
sector_t capacity, int ip[])
|
|
{
|
|
ip[0] = 64; /* heads */
|
|
ip[1] = 32; /* sectors */
|
|
ip[2] = capacity >> 11; /* cylinders */
|
|
return 0;
|
|
}
|
|
|
|
static void
|
|
simscsi_sg_readwrite (struct scsi_cmnd *sc, int mode, unsigned long offset)
|
|
{
|
|
int i;
|
|
struct scatterlist *sl;
|
|
struct disk_stat stat;
|
|
struct disk_req req;
|
|
|
|
stat.fd = desc[sc->device->id];
|
|
|
|
scsi_for_each_sg(sc, sl, scsi_sg_count(sc), i) {
|
|
req.addr = __pa(sg_virt(sl));
|
|
req.len = sl->length;
|
|
if (DBG)
|
|
printk("simscsi_sg_%s @ %lx (off %lx) use_sg=%d len=%d\n",
|
|
mode == SSC_READ ? "read":"write", req.addr, offset,
|
|
scsi_sg_count(sc) - i, sl->length);
|
|
ia64_ssc(stat.fd, 1, __pa(&req), offset, mode);
|
|
ia64_ssc(__pa(&stat), 0, 0, 0, SSC_WAIT_COMPLETION);
|
|
|
|
/* should not happen in our case */
|
|
if (stat.count != req.len) {
|
|
sc->result = DID_ERROR << 16;
|
|
return;
|
|
}
|
|
offset += sl->length;
|
|
}
|
|
sc->result = GOOD;
|
|
}
|
|
|
|
/*
|
|
* function handling both READ_6/WRITE_6 (non-scatter/gather mode)
|
|
* commands.
|
|
* Added 02/26/99 S.Eranian
|
|
*/
|
|
static void
|
|
simscsi_readwrite6 (struct scsi_cmnd *sc, int mode)
|
|
{
|
|
unsigned long offset;
|
|
|
|
offset = (((sc->cmnd[1] & 0x1f) << 16) | (sc->cmnd[2] << 8) | sc->cmnd[3])*512;
|
|
simscsi_sg_readwrite(sc, mode, offset);
|
|
}
|
|
|
|
static size_t
|
|
simscsi_get_disk_size (int fd)
|
|
{
|
|
struct disk_stat stat;
|
|
size_t bit, sectors = 0;
|
|
struct disk_req req;
|
|
char buf[512];
|
|
|
|
/*
|
|
* This is a bit kludgey: the simulator doesn't provide a
|
|
* direct way of determining the disk size, so we do a binary
|
|
* search, assuming a maximum disk size of 128GB.
|
|
*/
|
|
for (bit = (128UL << 30)/512; bit != 0; bit >>= 1) {
|
|
req.addr = __pa(&buf);
|
|
req.len = sizeof(buf);
|
|
ia64_ssc(fd, 1, __pa(&req), ((sectors | bit) - 1)*512, SSC_READ);
|
|
stat.fd = fd;
|
|
ia64_ssc(__pa(&stat), 0, 0, 0, SSC_WAIT_COMPLETION);
|
|
if (stat.count == sizeof(buf))
|
|
sectors |= bit;
|
|
}
|
|
return sectors - 1; /* return last valid sector number */
|
|
}
|
|
|
|
static void
|
|
simscsi_readwrite10 (struct scsi_cmnd *sc, int mode)
|
|
{
|
|
unsigned long offset;
|
|
|
|
offset = (((unsigned long)sc->cmnd[2] << 24)
|
|
| ((unsigned long)sc->cmnd[3] << 16)
|
|
| ((unsigned long)sc->cmnd[4] << 8)
|
|
| ((unsigned long)sc->cmnd[5] << 0))*512UL;
|
|
simscsi_sg_readwrite(sc, mode, offset);
|
|
}
|
|
|
|
static int
|
|
simscsi_queuecommand_lck (struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
|
|
{
|
|
unsigned int target_id = sc->device->id;
|
|
char fname[MAX_ROOT_LEN+16];
|
|
size_t disk_size;
|
|
char *buf;
|
|
char localbuf[36];
|
|
#if DEBUG_SIMSCSI
|
|
register long sp asm ("sp");
|
|
|
|
if (DBG)
|
|
printk("simscsi_queuecommand: target=%d,cmnd=%u,sc=%lu,sp=%lx,done=%p\n",
|
|
target_id, sc->cmnd[0], sc->serial_number, sp, done);
|
|
#endif
|
|
|
|
sc->result = DID_BAD_TARGET << 16;
|
|
sc->scsi_done = done;
|
|
if (target_id <= 15 && sc->device->lun == 0) {
|
|
switch (sc->cmnd[0]) {
|
|
case INQUIRY:
|
|
if (scsi_bufflen(sc) < 35) {
|
|
break;
|
|
}
|
|
sprintf (fname, "%s%c", simscsi_root, 'a' + target_id);
|
|
desc[target_id] = ia64_ssc(__pa(fname), SSC_READ_ACCESS|SSC_WRITE_ACCESS,
|
|
0, 0, SSC_OPEN);
|
|
if (desc[target_id] < 0) {
|
|
/* disk doesn't exist... */
|
|
break;
|
|
}
|
|
buf = localbuf;
|
|
buf[0] = 0; /* magnetic disk */
|
|
buf[1] = 0; /* not a removable medium */
|
|
buf[2] = 2; /* SCSI-2 compliant device */
|
|
buf[3] = 2; /* SCSI-2 response data format */
|
|
buf[4] = 31; /* additional length (bytes) */
|
|
buf[5] = 0; /* reserved */
|
|
buf[6] = 0; /* reserved */
|
|
buf[7] = 0; /* various flags */
|
|
memcpy(buf + 8, "HP SIMULATED DISK 0.00", 28);
|
|
scsi_sg_copy_from_buffer(sc, buf, 36);
|
|
sc->result = GOOD;
|
|
break;
|
|
|
|
case TEST_UNIT_READY:
|
|
sc->result = GOOD;
|
|
break;
|
|
|
|
case READ_6:
|
|
if (desc[target_id] < 0 )
|
|
break;
|
|
simscsi_readwrite6(sc, SSC_READ);
|
|
break;
|
|
|
|
case READ_10:
|
|
if (desc[target_id] < 0 )
|
|
break;
|
|
simscsi_readwrite10(sc, SSC_READ);
|
|
break;
|
|
|
|
case WRITE_6:
|
|
if (desc[target_id] < 0)
|
|
break;
|
|
simscsi_readwrite6(sc, SSC_WRITE);
|
|
break;
|
|
|
|
case WRITE_10:
|
|
if (desc[target_id] < 0)
|
|
break;
|
|
simscsi_readwrite10(sc, SSC_WRITE);
|
|
break;
|
|
|
|
case READ_CAPACITY:
|
|
if (desc[target_id] < 0 || scsi_bufflen(sc) < 8) {
|
|
break;
|
|
}
|
|
buf = localbuf;
|
|
disk_size = simscsi_get_disk_size(desc[target_id]);
|
|
|
|
buf[0] = (disk_size >> 24) & 0xff;
|
|
buf[1] = (disk_size >> 16) & 0xff;
|
|
buf[2] = (disk_size >> 8) & 0xff;
|
|
buf[3] = (disk_size >> 0) & 0xff;
|
|
/* set block size of 512 bytes: */
|
|
buf[4] = 0;
|
|
buf[5] = 0;
|
|
buf[6] = 2;
|
|
buf[7] = 0;
|
|
scsi_sg_copy_from_buffer(sc, buf, 8);
|
|
sc->result = GOOD;
|
|
break;
|
|
|
|
case MODE_SENSE:
|
|
case MODE_SENSE_10:
|
|
/* sd.c uses this to determine whether disk does write-caching. */
|
|
scsi_sg_copy_from_buffer(sc, (char *)empty_zero_page,
|
|
PAGE_SIZE);
|
|
sc->result = GOOD;
|
|
break;
|
|
|
|
case START_STOP:
|
|
printk(KERN_ERR "START_STOP\n");
|
|
break;
|
|
|
|
default:
|
|
panic("simscsi: unknown SCSI command %u\n", sc->cmnd[0]);
|
|
}
|
|
}
|
|
if (sc->result == DID_BAD_TARGET) {
|
|
sc->result |= DRIVER_SENSE << 24;
|
|
sc->sense_buffer[0] = 0x70;
|
|
sc->sense_buffer[2] = 0x00;
|
|
}
|
|
if (atomic_read(&num_reqs) >= SIMSCSI_REQ_QUEUE_LEN) {
|
|
panic("Attempt to queue command while command is pending!!");
|
|
}
|
|
atomic_inc(&num_reqs);
|
|
queue[wr].sc = sc;
|
|
wr = (wr + 1) % SIMSCSI_REQ_QUEUE_LEN;
|
|
|
|
tasklet_schedule(&simscsi_tasklet);
|
|
return 0;
|
|
}
|
|
|
|
static DEF_SCSI_QCMD(simscsi_queuecommand)
|
|
|
|
static int
|
|
simscsi_host_reset (struct scsi_cmnd *sc)
|
|
{
|
|
printk(KERN_ERR "simscsi_host_reset: not implemented\n");
|
|
return 0;
|
|
}
|
|
|
|
static struct scsi_host_template driver_template = {
|
|
.name = "simulated SCSI host adapter",
|
|
.proc_name = "simscsi",
|
|
.queuecommand = simscsi_queuecommand,
|
|
.eh_host_reset_handler = simscsi_host_reset,
|
|
.bios_param = simscsi_biosparam,
|
|
.can_queue = SIMSCSI_REQ_QUEUE_LEN,
|
|
.this_id = -1,
|
|
.sg_tablesize = SG_ALL,
|
|
.max_sectors = 1024,
|
|
.cmd_per_lun = SIMSCSI_REQ_QUEUE_LEN,
|
|
.use_clustering = DISABLE_CLUSTERING,
|
|
};
|
|
|
|
static int __init
|
|
simscsi_init(void)
|
|
{
|
|
int error;
|
|
|
|
host = scsi_host_alloc(&driver_template, 0);
|
|
if (!host)
|
|
return -ENOMEM;
|
|
|
|
error = scsi_add_host(host, NULL);
|
|
if (error)
|
|
goto free_host;
|
|
scsi_scan_host(host);
|
|
return 0;
|
|
|
|
free_host:
|
|
scsi_host_put(host);
|
|
return error;
|
|
}
|
|
device_initcall(simscsi_init);
|