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
|
2012-11-29 21:34:48 +08:00
|
|
|
/*
|
|
|
|
* Copyright IBM Corp. 2012
|
|
|
|
*
|
|
|
|
* Author(s):
|
|
|
|
* Jan Glauber <jang@linux.vnet.ibm.com>
|
|
|
|
*/
|
|
|
|
|
2014-07-16 23:21:01 +08:00
|
|
|
#define KMSG_COMPONENT "zpci"
|
|
|
|
#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
|
2012-11-29 21:34:48 +08:00
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/pci.h>
|
2013-10-22 21:17:19 +08:00
|
|
|
#include <asm/pci_debug.h>
|
2021-03-24 18:21:21 +08:00
|
|
|
#include <asm/pci_dma.h>
|
2013-11-15 20:56:08 +08:00
|
|
|
#include <asm/sclp.h>
|
2012-11-29 21:34:48 +08:00
|
|
|
|
2020-03-23 17:45:43 +08:00
|
|
|
#include "pci_bus.h"
|
|
|
|
|
2012-11-29 21:34:48 +08:00
|
|
|
/* Content Code Description for PCI Function Error */
|
|
|
|
struct zpci_ccdf_err {
|
|
|
|
u32 reserved1;
|
|
|
|
u32 fh; /* function handle */
|
|
|
|
u32 fid; /* function id */
|
|
|
|
u32 ett : 4; /* expected table type */
|
|
|
|
u32 mvn : 12; /* MSI vector number */
|
|
|
|
u32 dmaas : 8; /* DMA address space */
|
|
|
|
u32 : 6;
|
|
|
|
u32 q : 1; /* event qualifier */
|
|
|
|
u32 rw : 1; /* read/write */
|
|
|
|
u64 faddr; /* failing address */
|
|
|
|
u32 reserved3;
|
|
|
|
u16 reserved4;
|
|
|
|
u16 pec; /* PCI event code */
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
/* Content Code Description for PCI Function Availability */
|
|
|
|
struct zpci_ccdf_avail {
|
|
|
|
u32 reserved1;
|
|
|
|
u32 fh; /* function handle */
|
|
|
|
u32 fid; /* function id */
|
|
|
|
u32 reserved2;
|
|
|
|
u32 reserved3;
|
|
|
|
u32 reserved4;
|
|
|
|
u32 reserved5;
|
|
|
|
u16 reserved6;
|
|
|
|
u16 pec; /* PCI event code */
|
|
|
|
} __packed;
|
|
|
|
|
2021-07-07 17:00:01 +08:00
|
|
|
static inline bool ers_result_indicates_abort(pci_ers_result_t ers_res)
|
|
|
|
{
|
|
|
|
switch (ers_res) {
|
|
|
|
case PCI_ERS_RESULT_CAN_RECOVER:
|
|
|
|
case PCI_ERS_RESULT_RECOVERED:
|
|
|
|
case PCI_ERS_RESULT_NEED_RESET:
|
|
|
|
return false;
|
|
|
|
default:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool is_passed_through(struct zpci_dev *zdev)
|
|
|
|
{
|
|
|
|
return zdev->s390_domain;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool is_driver_supported(struct pci_driver *driver)
|
|
|
|
{
|
|
|
|
if (!driver || !driver->err_handler)
|
|
|
|
return false;
|
|
|
|
if (!driver->err_handler->error_detected)
|
|
|
|
return false;
|
|
|
|
if (!driver->err_handler->slot_reset)
|
|
|
|
return false;
|
|
|
|
if (!driver->err_handler->resume)
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static pci_ers_result_t zpci_event_notify_error_detected(struct pci_dev *pdev,
|
|
|
|
struct pci_driver *driver)
|
|
|
|
{
|
|
|
|
pci_ers_result_t ers_res = PCI_ERS_RESULT_DISCONNECT;
|
|
|
|
|
|
|
|
ers_res = driver->err_handler->error_detected(pdev, pdev->error_state);
|
|
|
|
if (ers_result_indicates_abort(ers_res))
|
|
|
|
pr_info("%s: Automatic recovery failed after initial reporting\n", pci_name(pdev));
|
|
|
|
else if (ers_res == PCI_ERS_RESULT_NEED_RESET)
|
|
|
|
pr_debug("%s: Driver needs reset to recover\n", pci_name(pdev));
|
|
|
|
|
|
|
|
return ers_res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static pci_ers_result_t zpci_event_do_error_state_clear(struct pci_dev *pdev,
|
|
|
|
struct pci_driver *driver)
|
|
|
|
{
|
|
|
|
pci_ers_result_t ers_res = PCI_ERS_RESULT_DISCONNECT;
|
|
|
|
struct zpci_dev *zdev = to_zpci(pdev);
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
pr_info("%s: Unblocking device access for examination\n", pci_name(pdev));
|
|
|
|
rc = zpci_reset_load_store_blocked(zdev);
|
|
|
|
if (rc) {
|
|
|
|
pr_err("%s: Unblocking device access failed\n", pci_name(pdev));
|
|
|
|
/* Let's try a full reset instead */
|
|
|
|
return PCI_ERS_RESULT_NEED_RESET;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (driver->err_handler->mmio_enabled) {
|
|
|
|
ers_res = driver->err_handler->mmio_enabled(pdev);
|
|
|
|
if (ers_result_indicates_abort(ers_res)) {
|
|
|
|
pr_info("%s: Automatic recovery failed after MMIO re-enable\n",
|
|
|
|
pci_name(pdev));
|
|
|
|
return ers_res;
|
|
|
|
} else if (ers_res == PCI_ERS_RESULT_NEED_RESET) {
|
|
|
|
pr_debug("%s: Driver needs reset to recover\n", pci_name(pdev));
|
|
|
|
return ers_res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pr_debug("%s: Unblocking DMA\n", pci_name(pdev));
|
|
|
|
rc = zpci_clear_error_state(zdev);
|
|
|
|
if (!rc) {
|
|
|
|
pdev->error_state = pci_channel_io_normal;
|
|
|
|
} else {
|
|
|
|
pr_err("%s: Unblocking DMA failed\n", pci_name(pdev));
|
|
|
|
/* Let's try a full reset instead */
|
|
|
|
return PCI_ERS_RESULT_NEED_RESET;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ers_res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static pci_ers_result_t zpci_event_do_reset(struct pci_dev *pdev,
|
|
|
|
struct pci_driver *driver)
|
|
|
|
{
|
|
|
|
pci_ers_result_t ers_res = PCI_ERS_RESULT_DISCONNECT;
|
|
|
|
|
|
|
|
pr_info("%s: Initiating reset\n", pci_name(pdev));
|
|
|
|
if (zpci_hot_reset_device(to_zpci(pdev))) {
|
|
|
|
pr_err("%s: The reset request failed\n", pci_name(pdev));
|
|
|
|
return ers_res;
|
|
|
|
}
|
|
|
|
pdev->error_state = pci_channel_io_normal;
|
|
|
|
ers_res = driver->err_handler->slot_reset(pdev);
|
|
|
|
if (ers_result_indicates_abort(ers_res)) {
|
|
|
|
pr_info("%s: Automatic recovery failed after slot reset\n", pci_name(pdev));
|
|
|
|
return ers_res;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ers_res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* zpci_event_attempt_error_recovery - Try to recover the given PCI function
|
|
|
|
* @pdev: PCI function to recover currently in the error state
|
|
|
|
*
|
|
|
|
* We follow the scheme outlined in Documentation/PCI/pci-error-recovery.rst.
|
|
|
|
* With the simplification that recovery always happens per function
|
|
|
|
* and the platform determines which functions are affected for
|
|
|
|
* multi-function devices.
|
|
|
|
*/
|
|
|
|
static pci_ers_result_t zpci_event_attempt_error_recovery(struct pci_dev *pdev)
|
|
|
|
{
|
|
|
|
pci_ers_result_t ers_res = PCI_ERS_RESULT_DISCONNECT;
|
|
|
|
struct pci_driver *driver;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ensure that the PCI function is not removed concurrently, no driver
|
|
|
|
* is unbound or probed and that userspace can't access its
|
|
|
|
* configuration space while we perform recovery.
|
|
|
|
*/
|
|
|
|
pci_dev_lock(pdev);
|
|
|
|
if (pdev->error_state == pci_channel_io_perm_failure) {
|
|
|
|
ers_res = PCI_ERS_RESULT_DISCONNECT;
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
pdev->error_state = pci_channel_io_frozen;
|
|
|
|
|
|
|
|
if (is_passed_through(to_zpci(pdev))) {
|
|
|
|
pr_info("%s: Cannot be recovered in the host because it is a pass-through device\n",
|
|
|
|
pci_name(pdev));
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
driver = to_pci_driver(pdev->dev.driver);
|
|
|
|
if (!is_driver_supported(driver)) {
|
|
|
|
if (!driver)
|
|
|
|
pr_info("%s: Cannot be recovered because no driver is bound to the device\n",
|
|
|
|
pci_name(pdev));
|
|
|
|
else
|
|
|
|
pr_info("%s: The %s driver bound to the device does not support error recovery\n",
|
|
|
|
pci_name(pdev),
|
|
|
|
driver->name);
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
ers_res = zpci_event_notify_error_detected(pdev, driver);
|
|
|
|
if (ers_result_indicates_abort(ers_res))
|
|
|
|
goto out_unlock;
|
|
|
|
|
|
|
|
if (ers_res == PCI_ERS_RESULT_CAN_RECOVER) {
|
|
|
|
ers_res = zpci_event_do_error_state_clear(pdev, driver);
|
|
|
|
if (ers_result_indicates_abort(ers_res))
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ers_res == PCI_ERS_RESULT_NEED_RESET)
|
|
|
|
ers_res = zpci_event_do_reset(pdev, driver);
|
|
|
|
|
|
|
|
if (ers_res != PCI_ERS_RESULT_RECOVERED) {
|
|
|
|
pr_err("%s: Automatic recovery failed; operator intervention is required\n",
|
|
|
|
pci_name(pdev));
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
pr_info("%s: The device is ready to resume operations\n", pci_name(pdev));
|
|
|
|
if (driver->err_handler->resume)
|
|
|
|
driver->err_handler->resume(pdev);
|
|
|
|
out_unlock:
|
|
|
|
pci_dev_unlock(pdev);
|
|
|
|
|
|
|
|
return ers_res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* zpci_event_io_failure - Report PCI channel failure state to driver
|
|
|
|
* @pdev: PCI function for which to report
|
|
|
|
* @es: PCI channel failure state to report
|
|
|
|
*/
|
|
|
|
static void zpci_event_io_failure(struct pci_dev *pdev, pci_channel_state_t es)
|
|
|
|
{
|
|
|
|
struct pci_driver *driver;
|
|
|
|
|
|
|
|
pci_dev_lock(pdev);
|
|
|
|
pdev->error_state = es;
|
|
|
|
/**
|
|
|
|
* While vfio-pci's error_detected callback notifies user-space QEMU
|
|
|
|
* reacts to this by freezing the guest. In an s390 environment PCI
|
|
|
|
* errors are rarely fatal so this is overkill. Instead in the future
|
|
|
|
* we will inject the error event and let the guest recover the device
|
|
|
|
* itself.
|
|
|
|
*/
|
|
|
|
if (is_passed_through(to_zpci(pdev)))
|
|
|
|
goto out;
|
|
|
|
driver = to_pci_driver(pdev->dev.driver);
|
|
|
|
if (driver && driver->err_handler && driver->err_handler->error_detected)
|
|
|
|
driver->err_handler->error_detected(pdev, pdev->error_state);
|
|
|
|
out:
|
|
|
|
pci_dev_unlock(pdev);
|
|
|
|
}
|
|
|
|
|
2013-12-13 00:48:32 +08:00
|
|
|
static void __zpci_event_error(struct zpci_ccdf_err *ccdf)
|
2012-11-29 21:34:48 +08:00
|
|
|
{
|
2013-11-15 20:56:08 +08:00
|
|
|
struct zpci_dev *zdev = get_zdev_by_fid(ccdf->fid);
|
2016-01-29 22:13:30 +08:00
|
|
|
struct pci_dev *pdev = NULL;
|
2021-07-07 17:00:01 +08:00
|
|
|
pci_ers_result_t ers_res;
|
2013-11-15 20:56:08 +08:00
|
|
|
|
2021-09-15 23:08:44 +08:00
|
|
|
zpci_dbg(3, "err fid:%x, fh:%x, pec:%x\n",
|
|
|
|
ccdf->fid, ccdf->fh, ccdf->pec);
|
2013-11-15 20:56:08 +08:00
|
|
|
zpci_err("error CCDF:\n");
|
|
|
|
zpci_err_hex(ccdf, sizeof(*ccdf));
|
|
|
|
|
2021-07-07 17:00:01 +08:00
|
|
|
if (zdev) {
|
|
|
|
zpci_update_fh(zdev, ccdf->fh);
|
|
|
|
if (zdev->zbus->bus)
|
|
|
|
pdev = pci_get_slot(zdev->zbus->bus, zdev->devfn);
|
|
|
|
}
|
2016-01-29 22:13:30 +08:00
|
|
|
|
2013-11-15 20:56:08 +08:00
|
|
|
pr_err("%s: Event 0x%x reports an error for PCI function 0x%x\n",
|
2015-07-29 01:11:40 +08:00
|
|
|
pdev ? pci_name(pdev) : "n/a", ccdf->pec, ccdf->fid);
|
2016-01-22 21:04:18 +08:00
|
|
|
|
|
|
|
if (!pdev)
|
2021-09-20 15:32:21 +08:00
|
|
|
goto no_pdev;
|
2016-01-22 21:04:18 +08:00
|
|
|
|
2021-07-07 17:00:01 +08:00
|
|
|
switch (ccdf->pec) {
|
|
|
|
case 0x003a: /* Service Action or Error Recovery Successful */
|
|
|
|
ers_res = zpci_event_attempt_error_recovery(pdev);
|
|
|
|
if (ers_res != PCI_ERS_RESULT_RECOVERED)
|
|
|
|
zpci_event_io_failure(pdev, pci_channel_io_perm_failure);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/*
|
|
|
|
* Mark as frozen not permanently failed because the device
|
|
|
|
* could be subsequently recovered by the platform.
|
|
|
|
*/
|
|
|
|
zpci_event_io_failure(pdev, pci_channel_io_frozen);
|
|
|
|
break;
|
|
|
|
}
|
2016-01-29 22:13:30 +08:00
|
|
|
pci_dev_put(pdev);
|
2021-09-20 15:32:21 +08:00
|
|
|
no_pdev:
|
|
|
|
zpci_zdev_put(zdev);
|
2013-11-15 20:56:08 +08:00
|
|
|
}
|
|
|
|
|
2013-12-13 00:48:32 +08:00
|
|
|
void zpci_event_error(void *data)
|
|
|
|
{
|
|
|
|
if (zpci_is_enabled())
|
|
|
|
__zpci_event_error(data);
|
|
|
|
}
|
|
|
|
|
2020-09-16 16:52:35 +08:00
|
|
|
static void zpci_event_hard_deconfigured(struct zpci_dev *zdev, u32 fh)
|
|
|
|
{
|
2021-07-07 16:42:43 +08:00
|
|
|
zpci_update_fh(zdev, fh);
|
2020-09-16 16:52:35 +08:00
|
|
|
/* Give the driver a hint that the function is
|
|
|
|
* already unusable.
|
|
|
|
*/
|
2021-01-26 20:58:28 +08:00
|
|
|
zpci_bus_remove_device(zdev, true);
|
2021-03-24 18:21:21 +08:00
|
|
|
/* Even though the device is already gone we still
|
|
|
|
* need to free zPCI resources as part of the disable.
|
|
|
|
*/
|
2021-07-16 17:53:37 +08:00
|
|
|
if (zdev->dma_table)
|
|
|
|
zpci_dma_exit_device(zdev);
|
|
|
|
if (zdev_enabled(zdev))
|
|
|
|
zpci_disable_device(zdev);
|
2020-09-16 16:52:35 +08:00
|
|
|
zdev->state = ZPCI_FN_STATE_STANDBY;
|
|
|
|
}
|
|
|
|
|
2013-12-13 00:48:32 +08:00
|
|
|
static void __zpci_event_availability(struct zpci_ccdf_avail *ccdf)
|
2013-11-15 20:56:08 +08:00
|
|
|
{
|
2012-11-29 21:34:48 +08:00
|
|
|
struct zpci_dev *zdev = get_zdev_by_fid(ccdf->fid);
|
2021-09-20 15:32:21 +08:00
|
|
|
bool existing_zdev = !!zdev;
|
2021-04-09 19:51:46 +08:00
|
|
|
enum zpci_state state;
|
2012-11-29 21:34:48 +08:00
|
|
|
|
2021-09-15 23:08:44 +08:00
|
|
|
zpci_dbg(3, "avl fid:%x, fh:%x, pec:%x\n",
|
|
|
|
ccdf->fid, ccdf->fh, ccdf->pec);
|
2012-11-29 21:34:48 +08:00
|
|
|
switch (ccdf->pec) {
|
2015-06-17 00:58:37 +08:00
|
|
|
case 0x0301: /* Reserved|Standby -> Configured */
|
|
|
|
if (!zdev) {
|
2021-02-12 18:57:58 +08:00
|
|
|
zdev = zpci_create_device(ccdf->fid, ccdf->fh, ZPCI_FN_STATE_CONFIGURED);
|
|
|
|
if (IS_ERR(zdev))
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
/* the configuration request may be stale */
|
|
|
|
if (zdev->state != ZPCI_FN_STATE_STANDBY)
|
|
|
|
break;
|
|
|
|
zdev->state = ZPCI_FN_STATE_CONFIGURED;
|
2020-03-26 00:55:55 +08:00
|
|
|
}
|
2021-04-09 20:08:50 +08:00
|
|
|
zpci_scan_configured_device(zdev, ccdf->fh);
|
2012-11-29 21:34:48 +08:00
|
|
|
break;
|
2013-11-15 20:56:08 +08:00
|
|
|
case 0x0302: /* Reserved -> Standby */
|
2020-11-03 17:41:20 +08:00
|
|
|
if (!zdev)
|
2020-07-22 22:53:54 +08:00
|
|
|
zpci_create_device(ccdf->fid, ccdf->fh, ZPCI_FN_STATE_STANDBY);
|
2020-11-03 17:41:20 +08:00
|
|
|
else
|
2021-07-07 16:42:43 +08:00
|
|
|
zpci_update_fh(zdev, ccdf->fh);
|
2012-11-29 21:34:48 +08:00
|
|
|
break;
|
2013-11-15 20:56:08 +08:00
|
|
|
case 0x0303: /* Deconfiguration requested */
|
2020-11-03 17:41:20 +08:00
|
|
|
if (zdev) {
|
2021-04-09 19:51:46 +08:00
|
|
|
/* The event may have been queued before we confirgured
|
|
|
|
* the device.
|
|
|
|
*/
|
|
|
|
if (zdev->state != ZPCI_FN_STATE_CONFIGURED)
|
|
|
|
break;
|
2021-07-07 16:42:43 +08:00
|
|
|
zpci_update_fh(zdev, ccdf->fh);
|
2020-11-03 17:41:20 +08:00
|
|
|
zpci_deconfigure_device(zdev);
|
|
|
|
}
|
2013-11-15 20:56:08 +08:00
|
|
|
break;
|
2017-05-09 18:27:30 +08:00
|
|
|
case 0x0304: /* Configured -> Standby|Reserved */
|
2021-04-09 19:51:46 +08:00
|
|
|
if (zdev) {
|
|
|
|
/* The event may have been queued before we confirgured
|
|
|
|
* the device.:
|
|
|
|
*/
|
|
|
|
if (zdev->state == ZPCI_FN_STATE_CONFIGURED)
|
|
|
|
zpci_event_hard_deconfigured(zdev, ccdf->fh);
|
|
|
|
/* The 0x0304 event may immediately reserve the device */
|
|
|
|
if (!clp_get_state(zdev->fid, &state) &&
|
|
|
|
state == ZPCI_FN_STATE_RESERVED) {
|
2021-09-22 21:55:12 +08:00
|
|
|
zpci_device_reserved(zdev);
|
2021-04-09 19:51:46 +08:00
|
|
|
}
|
|
|
|
}
|
2013-11-15 20:56:08 +08:00
|
|
|
break;
|
|
|
|
case 0x0306: /* 0x308 or 0x302 for multiple devices */
|
2020-08-21 17:01:54 +08:00
|
|
|
zpci_remove_reserved_devices();
|
|
|
|
clp_scan_pci_devices();
|
2012-11-29 21:34:48 +08:00
|
|
|
break;
|
2013-11-15 20:56:08 +08:00
|
|
|
case 0x0308: /* Standby -> Reserved */
|
2013-12-13 00:50:53 +08:00
|
|
|
if (!zdev)
|
|
|
|
break;
|
2021-09-22 21:55:12 +08:00
|
|
|
zpci_device_reserved(zdev);
|
2013-11-15 20:56:08 +08:00
|
|
|
break;
|
2012-11-29 21:34:48 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2021-09-20 15:32:21 +08:00
|
|
|
if (existing_zdev)
|
|
|
|
zpci_zdev_put(zdev);
|
2012-11-29 21:34:48 +08:00
|
|
|
}
|
2013-12-13 00:48:32 +08:00
|
|
|
|
|
|
|
void zpci_event_availability(void *data)
|
|
|
|
{
|
|
|
|
if (zpci_is_enabled())
|
|
|
|
__zpci_event_availability(data);
|
|
|
|
}
|