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
|
2012-11-29 11:55:21 +00:00
|
|
|
/*
|
|
|
|
* Copyright IBM Corp. 2012
|
|
|
|
*
|
|
|
|
* Author(s):
|
|
|
|
* Jan Glauber <jang@linux.vnet.ibm.com>
|
|
|
|
*/
|
|
|
|
|
2014-07-16 15:21:01 +00:00
|
|
|
#define KMSG_COMPONENT "zpci"
|
|
|
|
#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
|
2012-11-29 11:55:21 +00:00
|
|
|
|
2016-01-13 11:54:28 +00:00
|
|
|
#include <linux/compat.h>
|
2012-11-29 11:55:21 +00:00
|
|
|
#include <linux/kernel.h>
|
2016-01-13 11:54:28 +00:00
|
|
|
#include <linux/miscdevice.h>
|
2012-11-29 11:55:21 +00:00
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/err.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/pci.h>
|
2016-01-13 11:54:28 +00:00
|
|
|
#include <linux/uaccess.h>
|
2013-04-16 12:11:14 +00:00
|
|
|
#include <asm/pci_debug.h>
|
2012-11-29 11:55:21 +00:00
|
|
|
#include <asm/pci_clp.h>
|
2016-01-13 11:54:28 +00:00
|
|
|
#include <asm/clp.h>
|
|
|
|
#include <uapi/asm/clp.h>
|
2012-11-29 11:55:21 +00:00
|
|
|
|
2016-01-27 12:33:30 +00:00
|
|
|
bool zpci_unique_uid;
|
|
|
|
|
2020-03-18 12:53:16 +00:00
|
|
|
void update_uid_checking(bool new)
|
2017-07-03 13:32:23 +00:00
|
|
|
{
|
|
|
|
if (zpci_unique_uid != new)
|
|
|
|
zpci_dbg(1, "uid checking:%d\n", new);
|
|
|
|
|
|
|
|
zpci_unique_uid = new;
|
|
|
|
}
|
|
|
|
|
2013-10-22 13:17:19 +00:00
|
|
|
static inline void zpci_err_clp(unsigned int rsp, int rc)
|
|
|
|
{
|
|
|
|
struct {
|
|
|
|
unsigned int rsp;
|
|
|
|
int rc;
|
|
|
|
} __packed data = {rsp, rc};
|
|
|
|
|
|
|
|
zpci_err_hex(&data, sizeof(data));
|
|
|
|
}
|
|
|
|
|
2012-11-29 11:55:21 +00:00
|
|
|
/*
|
2016-01-13 11:54:28 +00:00
|
|
|
* Call Logical Processor with c=1, lps=0 and command 1
|
|
|
|
* to get the bit mask of installed logical processors
|
2012-11-29 11:55:21 +00:00
|
|
|
*/
|
2016-01-13 11:54:28 +00:00
|
|
|
static inline int clp_get_ilp(unsigned long *ilp)
|
|
|
|
{
|
|
|
|
unsigned long mask;
|
|
|
|
int cc = 3;
|
|
|
|
|
|
|
|
asm volatile (
|
|
|
|
" .insn rrf,0xb9a00000,%[mask],%[cmd],8,0\n"
|
|
|
|
"0: ipm %[cc]\n"
|
|
|
|
" srl %[cc],28\n"
|
|
|
|
"1:\n"
|
|
|
|
EX_TABLE(0b, 1b)
|
|
|
|
: [cc] "+d" (cc), [mask] "=d" (mask) : [cmd] "a" (1)
|
|
|
|
: "cc");
|
|
|
|
*ilp = mask;
|
|
|
|
return cc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Call Logical Processor with c=0, the give constant lps and an lpcb request.
|
|
|
|
*/
|
2019-10-04 10:29:43 +00:00
|
|
|
static __always_inline int clp_req(void *data, unsigned int lps)
|
2012-11-29 11:55:21 +00:00
|
|
|
{
|
2013-01-31 18:53:12 +00:00
|
|
|
struct { u8 _[CLP_BLK_SIZE]; } *req = data;
|
|
|
|
u64 ignored;
|
2016-01-13 11:54:28 +00:00
|
|
|
int cc = 3;
|
2012-11-29 11:55:21 +00:00
|
|
|
|
|
|
|
asm volatile (
|
2016-01-13 11:54:28 +00:00
|
|
|
" .insn rrf,0xb9a00000,%[ign],%[req],0,%[lps]\n"
|
|
|
|
"0: ipm %[cc]\n"
|
2012-11-29 11:55:21 +00:00
|
|
|
" srl %[cc],28\n"
|
2016-01-13 11:54:28 +00:00
|
|
|
"1:\n"
|
|
|
|
EX_TABLE(0b, 1b)
|
|
|
|
: [cc] "+d" (cc), [ign] "=d" (ignored), "+m" (*req)
|
|
|
|
: [req] "a" (req), [lps] "i" (lps)
|
2013-01-31 18:53:12 +00:00
|
|
|
: "cc");
|
2012-11-29 11:55:21 +00:00
|
|
|
return cc;
|
|
|
|
}
|
|
|
|
|
2013-08-29 17:37:28 +00:00
|
|
|
static void *clp_alloc_block(gfp_t gfp_mask)
|
2012-11-29 11:55:21 +00:00
|
|
|
{
|
2013-08-29 17:37:28 +00:00
|
|
|
return (void *) __get_free_pages(gfp_mask, get_order(CLP_BLK_SIZE));
|
2012-11-29 11:55:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void clp_free_block(void *ptr)
|
|
|
|
{
|
|
|
|
free_pages((unsigned long) ptr, get_order(CLP_BLK_SIZE));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void clp_store_query_pci_fngrp(struct zpci_dev *zdev,
|
|
|
|
struct clp_rsp_query_pci_grp *response)
|
|
|
|
{
|
2012-11-29 13:33:30 +00:00
|
|
|
zdev->tlb_refresh = response->refresh;
|
|
|
|
zdev->dma_mask = response->dasm;
|
2012-11-29 12:05:05 +00:00
|
|
|
zdev->msi_addr = response->msia;
|
2014-10-29 18:12:04 +00:00
|
|
|
zdev->max_msi = response->noi;
|
2012-12-11 13:53:35 +00:00
|
|
|
zdev->fmb_update = response->mui;
|
2020-10-07 18:56:20 +00:00
|
|
|
zdev->version = response->version;
|
2012-11-29 12:05:05 +00:00
|
|
|
|
2012-11-29 11:55:21 +00:00
|
|
|
switch (response->version) {
|
|
|
|
case 1:
|
|
|
|
zdev->max_bus_speed = PCIE_SPEED_5_0GT;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
zdev->max_bus_speed = PCI_SPEED_UNKNOWN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int clp_query_pci_fngrp(struct zpci_dev *zdev, u8 pfgid)
|
|
|
|
{
|
|
|
|
struct clp_req_rsp_query_pci_grp *rrb;
|
|
|
|
int rc;
|
|
|
|
|
2013-08-29 17:37:28 +00:00
|
|
|
rrb = clp_alloc_block(GFP_KERNEL);
|
2012-11-29 11:55:21 +00:00
|
|
|
if (!rrb)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
memset(rrb, 0, sizeof(*rrb));
|
|
|
|
rrb->request.hdr.len = sizeof(rrb->request);
|
|
|
|
rrb->request.hdr.cmd = CLP_QUERY_PCI_FNGRP;
|
|
|
|
rrb->response.hdr.len = sizeof(rrb->response);
|
|
|
|
rrb->request.pfgid = pfgid;
|
|
|
|
|
2016-01-13 11:54:28 +00:00
|
|
|
rc = clp_req(rrb, CLP_LPS_PCI);
|
2012-11-29 11:55:21 +00:00
|
|
|
if (!rc && rrb->response.hdr.rsp == CLP_RC_OK)
|
|
|
|
clp_store_query_pci_fngrp(zdev, &rrb->response);
|
|
|
|
else {
|
2013-10-22 13:17:19 +00:00
|
|
|
zpci_err("Q PCI FGRP:\n");
|
|
|
|
zpci_err_clp(rrb->response.hdr.rsp, rc);
|
2012-11-29 11:55:21 +00:00
|
|
|
rc = -EIO;
|
|
|
|
}
|
|
|
|
clp_free_block(rrb);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int clp_store_query_pci_fn(struct zpci_dev *zdev,
|
|
|
|
struct clp_rsp_query_pci *response)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2019-09-27 23:43:08 +00:00
|
|
|
for (i = 0; i < PCI_STD_NUM_BARS; i++) {
|
2012-11-29 11:55:21 +00:00
|
|
|
zdev->bars[i].val = le32_to_cpu(response->bar[i]);
|
|
|
|
zdev->bars[i].size = response->bar_size[i];
|
|
|
|
}
|
2012-11-29 13:33:30 +00:00
|
|
|
zdev->start_dma = response->sdma;
|
|
|
|
zdev->end_dma = response->edma;
|
2012-11-29 11:55:21 +00:00
|
|
|
zdev->pchid = response->pchid;
|
|
|
|
zdev->pfgid = response->pfgid;
|
2014-04-16 14:12:05 +00:00
|
|
|
zdev->pft = response->pft;
|
|
|
|
zdev->vfn = response->vfn;
|
2020-02-28 15:31:13 +00:00
|
|
|
zdev->port = response->port;
|
2014-04-16 14:12:05 +00:00
|
|
|
zdev->uid = response->uid;
|
2016-06-15 11:07:51 +00:00
|
|
|
zdev->fmb_length = sizeof(u32) * response->fmb_len;
|
2020-02-21 09:06:38 +00:00
|
|
|
zdev->rid_available = response->rid_avail;
|
2020-04-28 09:54:46 +00:00
|
|
|
zdev->is_physfn = response->is_physfn;
|
2020-02-21 09:06:38 +00:00
|
|
|
if (!s390_pci_no_rid && zdev->rid_available)
|
|
|
|
zdev->devfn = response->rid & ZPCI_RID_MASK_DEVFN;
|
2014-04-16 14:12:05 +00:00
|
|
|
|
|
|
|
memcpy(zdev->pfip, response->pfip, sizeof(zdev->pfip));
|
|
|
|
if (response->util_str_avail) {
|
|
|
|
memcpy(zdev->util_str, response->util_str,
|
|
|
|
sizeof(zdev->util_str));
|
2020-10-07 18:56:21 +00:00
|
|
|
zdev->util_str_avail = 1;
|
2014-04-16 14:12:05 +00:00
|
|
|
}
|
2019-04-14 13:38:01 +00:00
|
|
|
zdev->mio_capable = response->mio_addr_avail;
|
2019-09-27 23:43:08 +00:00
|
|
|
for (i = 0; i < PCI_STD_NUM_BARS; i++) {
|
|
|
|
if (!(response->mio.valid & (1 << (PCI_STD_NUM_BARS - i - 1))))
|
2019-04-14 13:38:01 +00:00
|
|
|
continue;
|
2014-04-16 14:12:05 +00:00
|
|
|
|
2019-05-16 11:28:17 +00:00
|
|
|
zdev->bars[i].mio_wb = (void __iomem *) response->mio.addr[i].wb;
|
|
|
|
zdev->bars[i].mio_wt = (void __iomem *) response->mio.addr[i].wt;
|
2019-04-14 13:38:01 +00:00
|
|
|
}
|
2012-11-29 11:55:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-07-22 14:53:54 +00:00
|
|
|
int clp_query_pci_fn(struct zpci_dev *zdev)
|
2012-11-29 11:55:21 +00:00
|
|
|
{
|
|
|
|
struct clp_req_rsp_query_pci *rrb;
|
|
|
|
int rc;
|
|
|
|
|
2013-08-29 17:37:28 +00:00
|
|
|
rrb = clp_alloc_block(GFP_KERNEL);
|
2012-11-29 11:55:21 +00:00
|
|
|
if (!rrb)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
memset(rrb, 0, sizeof(*rrb));
|
|
|
|
rrb->request.hdr.len = sizeof(rrb->request);
|
|
|
|
rrb->request.hdr.cmd = CLP_QUERY_PCI_FN;
|
|
|
|
rrb->response.hdr.len = sizeof(rrb->response);
|
2020-07-22 14:53:54 +00:00
|
|
|
rrb->request.fh = zdev->fh;
|
2012-11-29 11:55:21 +00:00
|
|
|
|
2016-01-13 11:54:28 +00:00
|
|
|
rc = clp_req(rrb, CLP_LPS_PCI);
|
2012-11-29 11:55:21 +00:00
|
|
|
if (!rc && rrb->response.hdr.rsp == CLP_RC_OK) {
|
|
|
|
rc = clp_store_query_pci_fn(zdev, &rrb->response);
|
|
|
|
if (rc)
|
|
|
|
goto out;
|
2016-03-16 12:56:35 +00:00
|
|
|
rc = clp_query_pci_fngrp(zdev, rrb->response.pfgid);
|
2012-11-29 11:55:21 +00:00
|
|
|
} else {
|
2013-10-22 13:17:19 +00:00
|
|
|
zpci_err("Q PCI FN:\n");
|
|
|
|
zpci_err_clp(rrb->response.hdr.rsp, rc);
|
2012-11-29 11:55:21 +00:00
|
|
|
rc = -EIO;
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
clp_free_block(rrb);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2021-07-21 17:58:54 +00:00
|
|
|
/**
|
|
|
|
* clp_set_pci_fn() - Execute a command on a PCI function
|
|
|
|
* @zdev: Function that will be affected
|
2021-07-22 09:44:08 +00:00
|
|
|
* @fh: Out parameter for updated function handle
|
2021-07-21 17:58:54 +00:00
|
|
|
* @nr_dma_as: DMA address space number
|
|
|
|
* @command: The command code to execute
|
|
|
|
*
|
|
|
|
* Returns: 0 on success, < 0 for Linux errors (e.g. -ENOMEM), and
|
|
|
|
* > 0 for non-success platform responses
|
2012-11-29 11:55:21 +00:00
|
|
|
*/
|
2021-07-22 09:44:08 +00:00
|
|
|
static int clp_set_pci_fn(struct zpci_dev *zdev, u32 *fh, u8 nr_dma_as, u8 command)
|
2012-11-29 11:55:21 +00:00
|
|
|
{
|
|
|
|
struct clp_req_rsp_set_pci *rrb;
|
2013-08-29 17:38:33 +00:00
|
|
|
int rc, retries = 100;
|
2012-11-29 11:55:21 +00:00
|
|
|
|
2021-07-22 09:44:08 +00:00
|
|
|
*fh = 0;
|
2013-08-29 17:37:28 +00:00
|
|
|
rrb = clp_alloc_block(GFP_KERNEL);
|
2012-11-29 11:55:21 +00:00
|
|
|
if (!rrb)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
do {
|
|
|
|
memset(rrb, 0, sizeof(*rrb));
|
|
|
|
rrb->request.hdr.len = sizeof(rrb->request);
|
|
|
|
rrb->request.hdr.cmd = CLP_SET_PCI_FN;
|
|
|
|
rrb->response.hdr.len = sizeof(rrb->response);
|
2019-12-17 08:34:46 +00:00
|
|
|
rrb->request.fh = zdev->fh;
|
2012-11-29 11:55:21 +00:00
|
|
|
rrb->request.oc = command;
|
|
|
|
rrb->request.ndas = nr_dma_as;
|
|
|
|
|
2016-01-13 11:54:28 +00:00
|
|
|
rc = clp_req(rrb, CLP_LPS_PCI);
|
2012-11-29 11:55:21 +00:00
|
|
|
if (rrb->response.hdr.rsp == CLP_RC_SETPCIFN_BUSY) {
|
|
|
|
retries--;
|
|
|
|
if (retries < 0)
|
|
|
|
break;
|
2013-08-29 17:38:33 +00:00
|
|
|
msleep(20);
|
2012-11-29 11:55:21 +00:00
|
|
|
}
|
|
|
|
} while (rrb->response.hdr.rsp == CLP_RC_SETPCIFN_BUSY);
|
|
|
|
|
2019-12-17 08:34:46 +00:00
|
|
|
if (!rc && rrb->response.hdr.rsp == CLP_RC_OK) {
|
2021-07-22 09:44:08 +00:00
|
|
|
*fh = rrb->response.fh;
|
2021-07-21 17:58:54 +00:00
|
|
|
} else {
|
|
|
|
zpci_err("Set PCI FN:\n");
|
|
|
|
zpci_err_clp(rrb->response.hdr.rsp, rc);
|
|
|
|
if (!rc)
|
|
|
|
rc = rrb->response.hdr.rsp;
|
2012-11-29 11:55:21 +00:00
|
|
|
}
|
|
|
|
clp_free_block(rrb);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2020-07-13 12:12:49 +00:00
|
|
|
int clp_setup_writeback_mio(void)
|
|
|
|
{
|
|
|
|
struct clp_req_rsp_slpc_pci *rrb;
|
|
|
|
u8 wb_bit_pos;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rrb = clp_alloc_block(GFP_KERNEL);
|
|
|
|
if (!rrb)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
memset(rrb, 0, sizeof(*rrb));
|
|
|
|
rrb->request.hdr.len = sizeof(rrb->request);
|
|
|
|
rrb->request.hdr.cmd = CLP_SLPC;
|
|
|
|
rrb->response.hdr.len = sizeof(rrb->response);
|
|
|
|
|
|
|
|
rc = clp_req(rrb, CLP_LPS_PCI);
|
|
|
|
if (!rc && rrb->response.hdr.rsp == CLP_RC_OK) {
|
|
|
|
if (rrb->response.vwb) {
|
|
|
|
wb_bit_pos = rrb->response.mio_wb;
|
|
|
|
set_bit_inv(wb_bit_pos, &mio_wb_bit_mask);
|
|
|
|
zpci_dbg(3, "wb bit: %d\n", wb_bit_pos);
|
|
|
|
} else {
|
|
|
|
zpci_dbg(3, "wb bit: n.a.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
zpci_err("SLPC PCI:\n");
|
|
|
|
zpci_err_clp(rrb->response.hdr.rsp, rc);
|
|
|
|
rc = -EIO;
|
|
|
|
}
|
|
|
|
clp_free_block(rrb);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2021-07-22 09:44:08 +00:00
|
|
|
int clp_enable_fh(struct zpci_dev *zdev, u32 *fh, u8 nr_dma_as)
|
2012-11-29 11:55:21 +00:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
2021-07-22 09:44:08 +00:00
|
|
|
rc = clp_set_pci_fn(zdev, fh, nr_dma_as, CLP_SET_ENABLE_PCI_FN);
|
|
|
|
zpci_dbg(3, "ena fid:%x, fh:%x, rc:%d\n", zdev->fid, *fh, rc);
|
2021-07-21 17:58:54 +00:00
|
|
|
if (!rc && zpci_use_mio(zdev)) {
|
2021-07-22 09:44:08 +00:00
|
|
|
rc = clp_set_pci_fn(zdev, fh, nr_dma_as, CLP_SET_ENABLE_MIO);
|
2019-12-17 08:34:46 +00:00
|
|
|
zpci_dbg(3, "ena mio fid:%x, fh:%x, rc:%d\n",
|
2021-07-22 09:44:08 +00:00
|
|
|
zdev->fid, *fh, rc);
|
2019-04-14 13:38:01 +00:00
|
|
|
if (rc)
|
2021-07-22 09:44:08 +00:00
|
|
|
clp_disable_fh(zdev, fh);
|
2019-04-14 13:38:01 +00:00
|
|
|
}
|
2012-11-29 11:55:21 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2021-07-22 09:44:08 +00:00
|
|
|
int clp_disable_fh(struct zpci_dev *zdev, u32 *fh)
|
2012-11-29 11:55:21 +00:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (!zdev_enabled(zdev))
|
|
|
|
return 0;
|
|
|
|
|
2021-07-22 09:44:08 +00:00
|
|
|
rc = clp_set_pci_fn(zdev, fh, 0, CLP_SET_DISABLE_PCI_FN);
|
|
|
|
zpci_dbg(3, "dis fid:%x, fh:%x, rc:%d\n", zdev->fid, *fh, rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int clp_list_pci_req(struct clp_req_rsp_list_pci *rrb,
|
|
|
|
u64 *resume_token, int *nentries)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
memset(rrb, 0, sizeof(*rrb));
|
|
|
|
rrb->request.hdr.len = sizeof(rrb->request);
|
|
|
|
rrb->request.hdr.cmd = CLP_LIST_PCI;
|
|
|
|
/* store as many entries as possible */
|
|
|
|
rrb->response.hdr.len = CLP_BLK_SIZE - LIST_PCI_HDR_LEN;
|
|
|
|
rrb->request.resume_token = *resume_token;
|
|
|
|
|
|
|
|
/* Get PCI function handle list */
|
|
|
|
rc = clp_req(rrb, CLP_LPS_PCI);
|
|
|
|
if (rc || rrb->response.hdr.rsp != CLP_RC_OK) {
|
|
|
|
zpci_err("List PCI FN:\n");
|
|
|
|
zpci_err_clp(rrb->response.hdr.rsp, rc);
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
update_uid_checking(rrb->response.uid_checking);
|
|
|
|
WARN_ON_ONCE(rrb->response.entry_size !=
|
|
|
|
sizeof(struct clp_fh_list_entry));
|
|
|
|
|
|
|
|
*nentries = (rrb->response.hdr.len - LIST_PCI_HDR_LEN) /
|
|
|
|
rrb->response.entry_size;
|
|
|
|
*resume_token = rrb->response.resume_token;
|
|
|
|
|
2012-11-29 11:55:21 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2017-04-26 16:59:52 +00:00
|
|
|
static int clp_list_pci(struct clp_req_rsp_list_pci *rrb, void *data,
|
|
|
|
void (*cb)(struct clp_fh_list_entry *, void *))
|
2012-11-29 11:55:21 +00:00
|
|
|
{
|
|
|
|
u64 resume_token = 0;
|
2021-07-22 09:44:08 +00:00
|
|
|
int nentries, i, rc;
|
2012-11-29 11:55:21 +00:00
|
|
|
|
|
|
|
do {
|
2021-07-22 09:44:08 +00:00
|
|
|
rc = clp_list_pci_req(rrb, &resume_token, &nentries);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
for (i = 0; i < nentries; i++)
|
|
|
|
cb(&rrb->response.fh_list[i], data);
|
|
|
|
} while (resume_token);
|
2012-11-29 11:55:21 +00:00
|
|
|
|
2021-07-22 09:44:08 +00:00
|
|
|
return rc;
|
|
|
|
}
|
2012-11-29 11:55:21 +00:00
|
|
|
|
2021-07-22 09:44:08 +00:00
|
|
|
static int clp_find_pci(struct clp_req_rsp_list_pci *rrb, u32 fid,
|
|
|
|
struct clp_fh_list_entry *entry)
|
|
|
|
{
|
|
|
|
struct clp_fh_list_entry *fh_list;
|
|
|
|
u64 resume_token = 0;
|
|
|
|
int nentries, i, rc;
|
2012-11-29 11:55:21 +00:00
|
|
|
|
2021-07-22 09:44:08 +00:00
|
|
|
do {
|
|
|
|
rc = clp_list_pci_req(rrb, &resume_token, &nentries);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
2021-09-06 06:49:44 +00:00
|
|
|
fh_list = rrb->response.fh_list;
|
2021-07-22 09:44:08 +00:00
|
|
|
for (i = 0; i < nentries; i++) {
|
|
|
|
if (fh_list[i].fid == fid) {
|
|
|
|
*entry = fh_list[i];
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2012-11-29 11:55:21 +00:00
|
|
|
} while (resume_token);
|
2021-07-22 09:44:08 +00:00
|
|
|
|
|
|
|
return -ENODEV;
|
2013-08-29 17:37:28 +00:00
|
|
|
}
|
|
|
|
|
2017-04-26 16:59:52 +00:00
|
|
|
static void __clp_add(struct clp_fh_list_entry *entry, void *data)
|
2013-08-29 17:37:28 +00:00
|
|
|
{
|
|
|
|
struct zpci_dev *zdev;
|
|
|
|
|
|
|
|
if (!entry->vendor_id)
|
|
|
|
return;
|
|
|
|
|
|
|
|
zdev = get_zdev_by_fid(entry->fid);
|
2017-06-20 13:56:05 +00:00
|
|
|
if (!zdev)
|
2020-07-22 14:53:54 +00:00
|
|
|
zpci_create_device(entry->fid, entry->fh, entry->config_state);
|
2013-08-29 17:37:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int clp_scan_pci_devices(void)
|
|
|
|
{
|
|
|
|
struct clp_req_rsp_list_pci *rrb;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rrb = clp_alloc_block(GFP_KERNEL);
|
|
|
|
if (!rrb)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2017-04-26 16:59:52 +00:00
|
|
|
rc = clp_list_pci(rrb, NULL, __clp_add);
|
2013-08-29 17:37:28 +00:00
|
|
|
|
|
|
|
clp_free_block(rrb);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2020-08-21 09:16:48 +00:00
|
|
|
/*
|
2021-07-22 09:44:08 +00:00
|
|
|
* Get the current function handle of the function matching @fid
|
2019-12-17 08:34:46 +00:00
|
|
|
*/
|
2021-07-22 09:44:08 +00:00
|
|
|
int clp_refresh_fh(u32 fid, u32 *fh)
|
2013-08-29 17:40:01 +00:00
|
|
|
{
|
|
|
|
struct clp_req_rsp_list_pci *rrb;
|
2021-07-22 09:44:08 +00:00
|
|
|
struct clp_fh_list_entry entry;
|
2013-08-29 17:40:01 +00:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
rrb = clp_alloc_block(GFP_NOWAIT);
|
|
|
|
if (!rrb)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2021-07-22 09:44:08 +00:00
|
|
|
rc = clp_find_pci(rrb, fid, &entry);
|
|
|
|
if (!rc)
|
|
|
|
*fh = entry.fh;
|
2017-04-26 16:59:52 +00:00
|
|
|
|
|
|
|
clp_free_block(rrb);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
int clp_get_state(u32 fid, enum zpci_state *state)
|
|
|
|
{
|
|
|
|
struct clp_req_rsp_list_pci *rrb;
|
2021-07-22 09:44:08 +00:00
|
|
|
struct clp_fh_list_entry entry;
|
2017-04-26 16:59:52 +00:00
|
|
|
int rc;
|
|
|
|
|
2018-10-18 09:11:08 +00:00
|
|
|
rrb = clp_alloc_block(GFP_ATOMIC);
|
2017-04-26 16:59:52 +00:00
|
|
|
if (!rrb)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2021-07-22 09:44:08 +00:00
|
|
|
rc = clp_find_pci(rrb, fid, &entry);
|
2021-09-03 16:27:01 +00:00
|
|
|
if (!rc) {
|
2021-07-22 09:44:08 +00:00
|
|
|
*state = entry.config_state;
|
2021-09-03 16:27:01 +00:00
|
|
|
} else if (rc == -ENODEV) {
|
|
|
|
*state = ZPCI_FN_STATE_RESERVED;
|
|
|
|
rc = 0;
|
|
|
|
}
|
2013-08-29 17:40:01 +00:00
|
|
|
|
|
|
|
clp_free_block(rrb);
|
|
|
|
return rc;
|
|
|
|
}
|
2016-01-13 11:54:28 +00:00
|
|
|
|
|
|
|
static int clp_base_slpc(struct clp_req *req, struct clp_req_rsp_slpc *lpcb)
|
|
|
|
{
|
|
|
|
unsigned long limit = PAGE_SIZE - sizeof(lpcb->request);
|
|
|
|
|
|
|
|
if (lpcb->request.hdr.len != sizeof(lpcb->request) ||
|
|
|
|
lpcb->response.hdr.len > limit)
|
|
|
|
return -EINVAL;
|
|
|
|
return clp_req(lpcb, CLP_LPS_BASE) ? -EOPNOTSUPP : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int clp_base_command(struct clp_req *req, struct clp_req_hdr *lpcb)
|
|
|
|
{
|
|
|
|
switch (lpcb->cmd) {
|
|
|
|
case 0x0001: /* store logical-processor characteristics */
|
|
|
|
return clp_base_slpc(req, (void *) lpcb);
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-13 12:12:49 +00:00
|
|
|
static int clp_pci_slpc(struct clp_req *req, struct clp_req_rsp_slpc_pci *lpcb)
|
2016-01-13 11:54:28 +00:00
|
|
|
{
|
|
|
|
unsigned long limit = PAGE_SIZE - sizeof(lpcb->request);
|
|
|
|
|
|
|
|
if (lpcb->request.hdr.len != sizeof(lpcb->request) ||
|
|
|
|
lpcb->response.hdr.len > limit)
|
|
|
|
return -EINVAL;
|
|
|
|
return clp_req(lpcb, CLP_LPS_PCI) ? -EOPNOTSUPP : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int clp_pci_list(struct clp_req *req, struct clp_req_rsp_list_pci *lpcb)
|
|
|
|
{
|
|
|
|
unsigned long limit = PAGE_SIZE - sizeof(lpcb->request);
|
|
|
|
|
|
|
|
if (lpcb->request.hdr.len != sizeof(lpcb->request) ||
|
|
|
|
lpcb->response.hdr.len > limit)
|
|
|
|
return -EINVAL;
|
|
|
|
if (lpcb->request.reserved2 != 0)
|
|
|
|
return -EINVAL;
|
|
|
|
return clp_req(lpcb, CLP_LPS_PCI) ? -EOPNOTSUPP : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int clp_pci_query(struct clp_req *req,
|
|
|
|
struct clp_req_rsp_query_pci *lpcb)
|
|
|
|
{
|
|
|
|
unsigned long limit = PAGE_SIZE - sizeof(lpcb->request);
|
|
|
|
|
|
|
|
if (lpcb->request.hdr.len != sizeof(lpcb->request) ||
|
|
|
|
lpcb->response.hdr.len > limit)
|
|
|
|
return -EINVAL;
|
|
|
|
if (lpcb->request.reserved2 != 0 || lpcb->request.reserved3 != 0)
|
|
|
|
return -EINVAL;
|
|
|
|
return clp_req(lpcb, CLP_LPS_PCI) ? -EOPNOTSUPP : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int clp_pci_query_grp(struct clp_req *req,
|
|
|
|
struct clp_req_rsp_query_pci_grp *lpcb)
|
|
|
|
{
|
|
|
|
unsigned long limit = PAGE_SIZE - sizeof(lpcb->request);
|
|
|
|
|
|
|
|
if (lpcb->request.hdr.len != sizeof(lpcb->request) ||
|
|
|
|
lpcb->response.hdr.len > limit)
|
|
|
|
return -EINVAL;
|
|
|
|
if (lpcb->request.reserved2 != 0 || lpcb->request.reserved3 != 0 ||
|
|
|
|
lpcb->request.reserved4 != 0)
|
|
|
|
return -EINVAL;
|
|
|
|
return clp_req(lpcb, CLP_LPS_PCI) ? -EOPNOTSUPP : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int clp_pci_command(struct clp_req *req, struct clp_req_hdr *lpcb)
|
|
|
|
{
|
|
|
|
switch (lpcb->cmd) {
|
|
|
|
case 0x0001: /* store logical-processor characteristics */
|
|
|
|
return clp_pci_slpc(req, (void *) lpcb);
|
|
|
|
case 0x0002: /* list PCI functions */
|
|
|
|
return clp_pci_list(req, (void *) lpcb);
|
|
|
|
case 0x0003: /* query PCI function */
|
|
|
|
return clp_pci_query(req, (void *) lpcb);
|
|
|
|
case 0x0004: /* query PCI function group */
|
|
|
|
return clp_pci_query_grp(req, (void *) lpcb);
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int clp_normal_command(struct clp_req *req)
|
|
|
|
{
|
|
|
|
struct clp_req_hdr *lpcb;
|
|
|
|
void __user *uptr;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = -EINVAL;
|
|
|
|
if (req->lps != 0 && req->lps != 2)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
rc = -ENOMEM;
|
|
|
|
lpcb = clp_alloc_block(GFP_KERNEL);
|
|
|
|
if (!lpcb)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
rc = -EFAULT;
|
|
|
|
uptr = (void __force __user *)(unsigned long) req->data_p;
|
|
|
|
if (copy_from_user(lpcb, uptr, PAGE_SIZE) != 0)
|
|
|
|
goto out_free;
|
|
|
|
|
|
|
|
rc = -EINVAL;
|
|
|
|
if (lpcb->fmt != 0 || lpcb->reserved1 != 0 || lpcb->reserved2 != 0)
|
|
|
|
goto out_free;
|
|
|
|
|
|
|
|
switch (req->lps) {
|
|
|
|
case 0:
|
|
|
|
rc = clp_base_command(req, lpcb);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
rc = clp_pci_command(req, lpcb);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (rc)
|
|
|
|
goto out_free;
|
|
|
|
|
|
|
|
rc = -EFAULT;
|
|
|
|
if (copy_to_user(uptr, lpcb, PAGE_SIZE) != 0)
|
|
|
|
goto out_free;
|
|
|
|
|
|
|
|
rc = 0;
|
|
|
|
|
|
|
|
out_free:
|
|
|
|
clp_free_block(lpcb);
|
|
|
|
out:
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int clp_immediate_command(struct clp_req *req)
|
|
|
|
{
|
|
|
|
void __user *uptr;
|
|
|
|
unsigned long ilp;
|
|
|
|
int exists;
|
|
|
|
|
|
|
|
if (req->cmd > 1 || clp_get_ilp(&ilp) != 0)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
uptr = (void __force __user *)(unsigned long) req->data_p;
|
|
|
|
if (req->cmd == 0) {
|
|
|
|
/* Command code 0: test for a specific processor */
|
|
|
|
exists = test_bit_inv(req->lps, &ilp);
|
|
|
|
return put_user(exists, (int __user *) uptr);
|
|
|
|
}
|
|
|
|
/* Command code 1: return bit mask of installed processors */
|
|
|
|
return put_user(ilp, (unsigned long __user *) uptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static long clp_misc_ioctl(struct file *filp, unsigned int cmd,
|
|
|
|
unsigned long arg)
|
|
|
|
{
|
|
|
|
struct clp_req req;
|
|
|
|
void __user *argp;
|
|
|
|
|
|
|
|
if (cmd != CLP_SYNC)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
argp = is_compat_task() ? compat_ptr(arg) : (void __user *) arg;
|
|
|
|
if (copy_from_user(&req, argp, sizeof(req)))
|
|
|
|
return -EFAULT;
|
|
|
|
if (req.r != 0)
|
|
|
|
return -EINVAL;
|
|
|
|
return req.c ? clp_immediate_command(&req) : clp_normal_command(&req);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int clp_misc_release(struct inode *inode, struct file *filp)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct file_operations clp_misc_fops = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.open = nonseekable_open,
|
|
|
|
.release = clp_misc_release,
|
|
|
|
.unlocked_ioctl = clp_misc_ioctl,
|
|
|
|
.compat_ioctl = clp_misc_ioctl,
|
|
|
|
.llseek = no_llseek,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct miscdevice clp_misc_device = {
|
|
|
|
.minor = MISC_DYNAMIC_MINOR,
|
|
|
|
.name = "clp",
|
|
|
|
.fops = &clp_misc_fops,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init clp_misc_init(void)
|
|
|
|
{
|
|
|
|
return misc_register(&clp_misc_device);
|
|
|
|
}
|
|
|
|
|
|
|
|
device_initcall(clp_misc_init);
|