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
|
2017-03-17 11:17:33 +08:00
|
|
|
/*
|
|
|
|
* Physical device callbacks for vfio_ccw
|
|
|
|
*
|
|
|
|
* Copyright IBM Corp. 2017
|
2018-07-19 23:53:08 +08:00
|
|
|
* Copyright Red Hat, Inc. 2019
|
2017-03-17 11:17:33 +08:00
|
|
|
*
|
|
|
|
* Author(s): Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
|
|
|
|
* Xiao Feng Ren <renxiaof@linux.vnet.ibm.com>
|
2018-07-19 23:53:08 +08:00
|
|
|
* Cornelia Huck <cohuck@redhat.com>
|
2017-03-17 11:17:33 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/vfio.h>
|
|
|
|
#include <linux/mdev.h>
|
2018-07-19 23:53:08 +08:00
|
|
|
#include <linux/nospec.h>
|
|
|
|
#include <linux/slab.h>
|
2017-03-17 11:17:33 +08:00
|
|
|
|
|
|
|
#include "vfio_ccw_private.h"
|
|
|
|
|
2021-10-27 01:57:33 +08:00
|
|
|
static const struct vfio_device_ops vfio_ccw_dev_ops;
|
|
|
|
|
2021-10-27 01:57:32 +08:00
|
|
|
static int vfio_ccw_mdev_reset(struct vfio_ccw_private *private)
|
2017-03-17 11:17:37 +08:00
|
|
|
{
|
|
|
|
struct subchannel *sch;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
sch = private->sch;
|
|
|
|
/*
|
|
|
|
* TODO:
|
|
|
|
* In the cureent stage, some things like "no I/O running" and "no
|
|
|
|
* interrupt pending" are clear, but we are not sure what other state
|
|
|
|
* we need to care about.
|
|
|
|
* There are still a lot more instructions need to be handled. We
|
|
|
|
* should come back here later.
|
|
|
|
*/
|
|
|
|
ret = vfio_ccw_sch_quiesce(sch);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2017-03-17 11:17:40 +08:00
|
|
|
ret = cio_enable_subchannel(sch, (u32)(unsigned long)sch);
|
|
|
|
if (!ret)
|
|
|
|
private->state = VFIO_CCW_STATE_IDLE;
|
|
|
|
|
|
|
|
return ret;
|
2017-03-17 11:17:37 +08:00
|
|
|
}
|
|
|
|
|
2017-03-17 11:17:33 +08:00
|
|
|
static int vfio_ccw_mdev_notifier(struct notifier_block *nb,
|
|
|
|
unsigned long action,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
struct vfio_ccw_private *private =
|
|
|
|
container_of(nb, struct vfio_ccw_private, nb);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Vendor drivers MUST unpin pages in response to an
|
|
|
|
* invalidation.
|
|
|
|
*/
|
2017-03-17 11:17:35 +08:00
|
|
|
if (action == VFIO_IOMMU_NOTIFY_DMA_UNMAP) {
|
|
|
|
struct vfio_iommu_type1_dma_unmap *unmap = data;
|
|
|
|
|
|
|
|
if (!cp_iova_pinned(&private->cp, unmap->iova))
|
|
|
|
return NOTIFY_OK;
|
|
|
|
|
2021-10-27 01:57:32 +08:00
|
|
|
if (vfio_ccw_mdev_reset(private))
|
2017-03-17 11:17:35 +08:00
|
|
|
return NOTIFY_BAD;
|
|
|
|
|
|
|
|
cp_free(&private->cp);
|
|
|
|
return NOTIFY_OK;
|
|
|
|
}
|
2017-03-17 11:17:33 +08:00
|
|
|
|
|
|
|
return NOTIFY_DONE;
|
|
|
|
}
|
|
|
|
|
vfio/mdev: Correct the function signatures for the mdev_type_attributes
The driver core standard is to pass in the properly typed object, the
properly typed attribute and the buffer data. It stems from the root
kobject method:
ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr,..)
Each subclass of kobject should provide their own function with the same
signature but more specific types, eg struct device uses:
ssize_t (*show)(struct device *dev, struct device_attribute *attr,..)
In this case the existing signature is:
ssize_t (*show)(struct kobject *kobj, struct device *dev,..)
Where kobj is a 'struct mdev_type *' and dev is 'mdev_type->parent->dev'.
Change the mdev_type related sysfs attribute functions to:
ssize_t (*show)(struct mdev_type *mtype, struct mdev_type_attribute *attr,..)
In order to restore type safety and match the driver core standard
There are no current users of 'attr', but if it is ever needed it would be
hard to add in retroactively, so do it now.
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Message-Id: <18-v2-d36939638fc6+d54-vfio2_jgg@nvidia.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2021-04-07 03:40:41 +08:00
|
|
|
static ssize_t name_show(struct mdev_type *mtype,
|
|
|
|
struct mdev_type_attribute *attr, char *buf)
|
2017-03-17 11:17:33 +08:00
|
|
|
{
|
|
|
|
return sprintf(buf, "I/O subchannel (Non-QDIO)\n");
|
|
|
|
}
|
2017-05-15 23:28:34 +08:00
|
|
|
static MDEV_TYPE_ATTR_RO(name);
|
2017-03-17 11:17:33 +08:00
|
|
|
|
vfio/mdev: Correct the function signatures for the mdev_type_attributes
The driver core standard is to pass in the properly typed object, the
properly typed attribute and the buffer data. It stems from the root
kobject method:
ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr,..)
Each subclass of kobject should provide their own function with the same
signature but more specific types, eg struct device uses:
ssize_t (*show)(struct device *dev, struct device_attribute *attr,..)
In this case the existing signature is:
ssize_t (*show)(struct kobject *kobj, struct device *dev,..)
Where kobj is a 'struct mdev_type *' and dev is 'mdev_type->parent->dev'.
Change the mdev_type related sysfs attribute functions to:
ssize_t (*show)(struct mdev_type *mtype, struct mdev_type_attribute *attr,..)
In order to restore type safety and match the driver core standard
There are no current users of 'attr', but if it is ever needed it would be
hard to add in retroactively, so do it now.
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Message-Id: <18-v2-d36939638fc6+d54-vfio2_jgg@nvidia.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2021-04-07 03:40:41 +08:00
|
|
|
static ssize_t device_api_show(struct mdev_type *mtype,
|
|
|
|
struct mdev_type_attribute *attr, char *buf)
|
2017-03-17 11:17:33 +08:00
|
|
|
{
|
|
|
|
return sprintf(buf, "%s\n", VFIO_DEVICE_API_CCW_STRING);
|
|
|
|
}
|
2017-05-15 23:28:34 +08:00
|
|
|
static MDEV_TYPE_ATTR_RO(device_api);
|
2017-03-17 11:17:33 +08:00
|
|
|
|
vfio/mdev: Correct the function signatures for the mdev_type_attributes
The driver core standard is to pass in the properly typed object, the
properly typed attribute and the buffer data. It stems from the root
kobject method:
ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr,..)
Each subclass of kobject should provide their own function with the same
signature but more specific types, eg struct device uses:
ssize_t (*show)(struct device *dev, struct device_attribute *attr,..)
In this case the existing signature is:
ssize_t (*show)(struct kobject *kobj, struct device *dev,..)
Where kobj is a 'struct mdev_type *' and dev is 'mdev_type->parent->dev'.
Change the mdev_type related sysfs attribute functions to:
ssize_t (*show)(struct mdev_type *mtype, struct mdev_type_attribute *attr,..)
In order to restore type safety and match the driver core standard
There are no current users of 'attr', but if it is ever needed it would be
hard to add in retroactively, so do it now.
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Message-Id: <18-v2-d36939638fc6+d54-vfio2_jgg@nvidia.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2021-04-07 03:40:41 +08:00
|
|
|
static ssize_t available_instances_show(struct mdev_type *mtype,
|
|
|
|
struct mdev_type_attribute *attr,
|
|
|
|
char *buf)
|
2017-03-17 11:17:33 +08:00
|
|
|
{
|
vfio/mdev: Correct the function signatures for the mdev_type_attributes
The driver core standard is to pass in the properly typed object, the
properly typed attribute and the buffer data. It stems from the root
kobject method:
ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr,..)
Each subclass of kobject should provide their own function with the same
signature but more specific types, eg struct device uses:
ssize_t (*show)(struct device *dev, struct device_attribute *attr,..)
In this case the existing signature is:
ssize_t (*show)(struct kobject *kobj, struct device *dev,..)
Where kobj is a 'struct mdev_type *' and dev is 'mdev_type->parent->dev'.
Change the mdev_type related sysfs attribute functions to:
ssize_t (*show)(struct mdev_type *mtype, struct mdev_type_attribute *attr,..)
In order to restore type safety and match the driver core standard
There are no current users of 'attr', but if it is ever needed it would be
hard to add in retroactively, so do it now.
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Message-Id: <18-v2-d36939638fc6+d54-vfio2_jgg@nvidia.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2021-04-07 03:40:41 +08:00
|
|
|
struct vfio_ccw_private *private =
|
|
|
|
dev_get_drvdata(mtype_get_parent_dev(mtype));
|
2017-03-17 11:17:33 +08:00
|
|
|
|
|
|
|
return sprintf(buf, "%d\n", atomic_read(&private->avail));
|
|
|
|
}
|
2017-05-15 23:28:34 +08:00
|
|
|
static MDEV_TYPE_ATTR_RO(available_instances);
|
2017-03-17 11:17:33 +08:00
|
|
|
|
|
|
|
static struct attribute *mdev_types_attrs[] = {
|
|
|
|
&mdev_type_attr_name.attr,
|
|
|
|
&mdev_type_attr_device_api.attr,
|
|
|
|
&mdev_type_attr_available_instances.attr,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct attribute_group mdev_type_group = {
|
|
|
|
.name = "io",
|
|
|
|
.attrs = mdev_types_attrs,
|
|
|
|
};
|
|
|
|
|
2017-05-15 23:28:34 +08:00
|
|
|
static struct attribute_group *mdev_type_groups[] = {
|
2017-03-17 11:17:33 +08:00
|
|
|
&mdev_type_group,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2021-10-27 01:57:33 +08:00
|
|
|
static int vfio_ccw_mdev_probe(struct mdev_device *mdev)
|
2017-03-17 11:17:33 +08:00
|
|
|
{
|
2021-10-27 01:57:33 +08:00
|
|
|
struct vfio_ccw_private *private = dev_get_drvdata(mdev->dev.parent);
|
|
|
|
int ret;
|
2017-03-17 11:17:33 +08:00
|
|
|
|
2017-03-17 11:17:40 +08:00
|
|
|
if (private->state == VFIO_CCW_STATE_NOT_OPER)
|
|
|
|
return -ENODEV;
|
|
|
|
|
2017-03-17 11:17:33 +08:00
|
|
|
if (atomic_dec_if_positive(&private->avail) < 0)
|
|
|
|
return -EPERM;
|
|
|
|
|
2021-10-27 01:57:33 +08:00
|
|
|
memset(&private->vdev, 0, sizeof(private->vdev));
|
|
|
|
vfio_init_group_dev(&private->vdev, &mdev->dev,
|
|
|
|
&vfio_ccw_dev_ops);
|
|
|
|
|
2017-03-17 11:17:33 +08:00
|
|
|
private->mdev = mdev;
|
2017-03-17 11:17:40 +08:00
|
|
|
private->state = VFIO_CCW_STATE_IDLE;
|
2017-03-17 11:17:33 +08:00
|
|
|
|
2019-08-15 19:53:41 +08:00
|
|
|
VFIO_CCW_MSG_EVENT(2, "mdev %pUl, sch %x.%x.%04x: create\n",
|
|
|
|
mdev_uuid(mdev), private->sch->schid.cssid,
|
|
|
|
private->sch->schid.ssid,
|
|
|
|
private->sch->schid.sch_no);
|
|
|
|
|
2021-10-27 01:57:33 +08:00
|
|
|
ret = vfio_register_emulated_iommu_dev(&private->vdev);
|
|
|
|
if (ret)
|
|
|
|
goto err_atomic;
|
|
|
|
dev_set_drvdata(&mdev->dev, private);
|
2017-03-17 11:17:33 +08:00
|
|
|
return 0;
|
2021-10-27 01:57:33 +08:00
|
|
|
|
|
|
|
err_atomic:
|
|
|
|
vfio_uninit_group_dev(&private->vdev);
|
|
|
|
atomic_inc(&private->avail);
|
|
|
|
private->mdev = NULL;
|
|
|
|
private->state = VFIO_CCW_STATE_IDLE;
|
|
|
|
return ret;
|
2017-03-17 11:17:33 +08:00
|
|
|
}
|
|
|
|
|
2021-10-27 01:57:33 +08:00
|
|
|
static void vfio_ccw_mdev_remove(struct mdev_device *mdev)
|
2017-03-17 11:17:33 +08:00
|
|
|
{
|
2021-10-27 01:57:33 +08:00
|
|
|
struct vfio_ccw_private *private = dev_get_drvdata(mdev->dev.parent);
|
2017-03-17 11:17:33 +08:00
|
|
|
|
2019-08-15 19:53:41 +08:00
|
|
|
VFIO_CCW_MSG_EVENT(2, "mdev %pUl, sch %x.%x.%04x: remove\n",
|
|
|
|
mdev_uuid(mdev), private->sch->schid.cssid,
|
|
|
|
private->sch->schid.ssid,
|
|
|
|
private->sch->schid.sch_no);
|
|
|
|
|
2021-10-27 01:57:33 +08:00
|
|
|
vfio_unregister_group_dev(&private->vdev);
|
|
|
|
|
2017-04-12 17:08:16 +08:00
|
|
|
if ((private->state != VFIO_CCW_STATE_NOT_OPER) &&
|
|
|
|
(private->state != VFIO_CCW_STATE_STANDBY)) {
|
2019-04-09 05:05:33 +08:00
|
|
|
if (!vfio_ccw_sch_quiesce(private->sch))
|
2017-04-12 17:08:16 +08:00
|
|
|
private->state = VFIO_CCW_STATE_STANDBY;
|
|
|
|
/* The state will be NOT_OPER on error. */
|
|
|
|
}
|
2017-03-17 11:17:40 +08:00
|
|
|
|
2021-10-27 01:57:33 +08:00
|
|
|
vfio_uninit_group_dev(&private->vdev);
|
2019-04-09 05:05:33 +08:00
|
|
|
cp_free(&private->cp);
|
2017-03-17 11:17:33 +08:00
|
|
|
private->mdev = NULL;
|
|
|
|
atomic_inc(&private->avail);
|
|
|
|
}
|
|
|
|
|
2021-10-27 01:57:33 +08:00
|
|
|
static int vfio_ccw_mdev_open_device(struct vfio_device *vdev)
|
2017-03-17 11:17:33 +08:00
|
|
|
{
|
|
|
|
struct vfio_ccw_private *private =
|
2021-10-27 01:57:33 +08:00
|
|
|
container_of(vdev, struct vfio_ccw_private, vdev);
|
2017-03-17 11:17:33 +08:00
|
|
|
unsigned long events = VFIO_IOMMU_NOTIFY_DMA_UNMAP;
|
2018-07-23 22:03:27 +08:00
|
|
|
int ret;
|
2017-03-17 11:17:33 +08:00
|
|
|
|
|
|
|
private->nb.notifier_call = vfio_ccw_mdev_notifier;
|
|
|
|
|
2021-10-27 01:57:33 +08:00
|
|
|
ret = vfio_register_notifier(vdev->dev, VFIO_IOMMU_NOTIFY,
|
2018-07-23 22:03:27 +08:00
|
|
|
&events, &private->nb);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ret = vfio_ccw_register_async_dev_regions(private);
|
|
|
|
if (ret)
|
2020-05-05 20:27:41 +08:00
|
|
|
goto out_unregister;
|
|
|
|
|
|
|
|
ret = vfio_ccw_register_schib_dev_regions(private);
|
|
|
|
if (ret)
|
|
|
|
goto out_unregister;
|
|
|
|
|
2020-05-05 20:27:43 +08:00
|
|
|
ret = vfio_ccw_register_crw_dev_regions(private);
|
|
|
|
if (ret)
|
|
|
|
goto out_unregister;
|
|
|
|
|
2020-05-05 20:27:41 +08:00
|
|
|
return ret;
|
|
|
|
|
|
|
|
out_unregister:
|
|
|
|
vfio_ccw_unregister_dev_regions(private);
|
2021-10-27 01:57:33 +08:00
|
|
|
vfio_unregister_notifier(vdev->dev, VFIO_IOMMU_NOTIFY,
|
2020-05-05 20:27:41 +08:00
|
|
|
&private->nb);
|
2018-07-23 22:03:27 +08:00
|
|
|
return ret;
|
2017-03-17 11:17:33 +08:00
|
|
|
}
|
|
|
|
|
2021-10-27 01:57:33 +08:00
|
|
|
static void vfio_ccw_mdev_close_device(struct vfio_device *vdev)
|
2017-03-17 11:17:33 +08:00
|
|
|
{
|
|
|
|
struct vfio_ccw_private *private =
|
2021-10-27 01:57:33 +08:00
|
|
|
container_of(vdev, struct vfio_ccw_private, vdev);
|
2017-03-17 11:17:33 +08:00
|
|
|
|
2019-04-09 05:05:33 +08:00
|
|
|
if ((private->state != VFIO_CCW_STATE_NOT_OPER) &&
|
|
|
|
(private->state != VFIO_CCW_STATE_STANDBY)) {
|
2021-10-27 01:57:32 +08:00
|
|
|
if (!vfio_ccw_mdev_reset(private))
|
2019-04-09 05:05:33 +08:00
|
|
|
private->state = VFIO_CCW_STATE_STANDBY;
|
|
|
|
/* The state will be NOT_OPER on error. */
|
|
|
|
}
|
|
|
|
|
|
|
|
cp_free(&private->cp);
|
2020-05-05 20:27:40 +08:00
|
|
|
vfio_ccw_unregister_dev_regions(private);
|
2021-10-27 01:57:33 +08:00
|
|
|
vfio_unregister_notifier(vdev->dev, VFIO_IOMMU_NOTIFY, &private->nb);
|
2017-03-17 11:17:33 +08:00
|
|
|
}
|
|
|
|
|
2018-07-19 23:53:08 +08:00
|
|
|
static ssize_t vfio_ccw_mdev_read_io_region(struct vfio_ccw_private *private,
|
|
|
|
char __user *buf, size_t count,
|
|
|
|
loff_t *ppos)
|
2017-03-17 11:17:34 +08:00
|
|
|
{
|
2018-07-19 23:53:08 +08:00
|
|
|
loff_t pos = *ppos & VFIO_CCW_OFFSET_MASK;
|
2017-03-17 11:17:34 +08:00
|
|
|
struct ccw_io_region *region;
|
2019-01-08 22:53:03 +08:00
|
|
|
int ret;
|
2017-03-17 11:17:34 +08:00
|
|
|
|
2018-07-19 23:53:08 +08:00
|
|
|
if (pos + count > sizeof(*region))
|
2017-03-17 11:17:34 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
2019-01-08 22:53:03 +08:00
|
|
|
mutex_lock(&private->io_mutex);
|
2018-09-22 04:40:12 +08:00
|
|
|
region = private->io_region;
|
2018-07-19 23:53:08 +08:00
|
|
|
if (copy_to_user(buf, (void *)region + pos, count))
|
2019-01-08 22:53:03 +08:00
|
|
|
ret = -EFAULT;
|
|
|
|
else
|
|
|
|
ret = count;
|
|
|
|
mutex_unlock(&private->io_mutex);
|
|
|
|
return ret;
|
2017-03-17 11:17:34 +08:00
|
|
|
}
|
|
|
|
|
2021-10-27 01:57:33 +08:00
|
|
|
static ssize_t vfio_ccw_mdev_read(struct vfio_device *vdev,
|
2018-07-19 23:53:08 +08:00
|
|
|
char __user *buf,
|
|
|
|
size_t count,
|
|
|
|
loff_t *ppos)
|
2017-03-17 11:17:34 +08:00
|
|
|
{
|
2021-10-27 01:57:33 +08:00
|
|
|
struct vfio_ccw_private *private =
|
|
|
|
container_of(vdev, struct vfio_ccw_private, vdev);
|
2018-07-19 23:53:08 +08:00
|
|
|
unsigned int index = VFIO_CCW_OFFSET_TO_INDEX(*ppos);
|
|
|
|
|
|
|
|
if (index >= VFIO_CCW_NUM_REGIONS + private->num_regions)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
switch (index) {
|
|
|
|
case VFIO_CCW_CONFIG_REGION_INDEX:
|
|
|
|
return vfio_ccw_mdev_read_io_region(private, buf, count, ppos);
|
|
|
|
default:
|
|
|
|
index -= VFIO_CCW_NUM_REGIONS;
|
|
|
|
return private->region[index].ops->read(private, buf, count,
|
|
|
|
ppos);
|
|
|
|
}
|
|
|
|
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t vfio_ccw_mdev_write_io_region(struct vfio_ccw_private *private,
|
|
|
|
const char __user *buf,
|
|
|
|
size_t count, loff_t *ppos)
|
|
|
|
{
|
|
|
|
loff_t pos = *ppos & VFIO_CCW_OFFSET_MASK;
|
2017-03-17 11:17:34 +08:00
|
|
|
struct ccw_io_region *region;
|
2019-01-08 22:53:03 +08:00
|
|
|
int ret;
|
2017-03-17 11:17:34 +08:00
|
|
|
|
2018-07-19 23:53:08 +08:00
|
|
|
if (pos + count > sizeof(*region))
|
2017-03-17 11:17:34 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
2019-01-08 22:53:03 +08:00
|
|
|
if (!mutex_trylock(&private->io_mutex))
|
|
|
|
return -EAGAIN;
|
2017-03-17 11:17:34 +08:00
|
|
|
|
2018-09-22 04:40:12 +08:00
|
|
|
region = private->io_region;
|
2018-07-19 23:53:08 +08:00
|
|
|
if (copy_from_user((void *)region + pos, buf, count)) {
|
2019-01-08 22:53:03 +08:00
|
|
|
ret = -EFAULT;
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
2017-03-17 11:17:35 +08:00
|
|
|
|
2017-03-17 11:17:40 +08:00
|
|
|
vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_IO_REQ);
|
2019-01-08 22:53:03 +08:00
|
|
|
ret = (region->ret_code != 0) ? region->ret_code : count;
|
2017-03-17 11:17:34 +08:00
|
|
|
|
2019-01-08 22:53:03 +08:00
|
|
|
out_unlock:
|
|
|
|
mutex_unlock(&private->io_mutex);
|
|
|
|
return ret;
|
2017-03-17 11:17:34 +08:00
|
|
|
}
|
|
|
|
|
2021-10-27 01:57:33 +08:00
|
|
|
static ssize_t vfio_ccw_mdev_write(struct vfio_device *vdev,
|
2018-07-19 23:53:08 +08:00
|
|
|
const char __user *buf,
|
|
|
|
size_t count,
|
|
|
|
loff_t *ppos)
|
2017-03-17 11:17:36 +08:00
|
|
|
{
|
2021-10-27 01:57:33 +08:00
|
|
|
struct vfio_ccw_private *private =
|
|
|
|
container_of(vdev, struct vfio_ccw_private, vdev);
|
2018-07-19 23:53:08 +08:00
|
|
|
unsigned int index = VFIO_CCW_OFFSET_TO_INDEX(*ppos);
|
|
|
|
|
|
|
|
if (index >= VFIO_CCW_NUM_REGIONS + private->num_regions)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
switch (index) {
|
|
|
|
case VFIO_CCW_CONFIG_REGION_INDEX:
|
|
|
|
return vfio_ccw_mdev_write_io_region(private, buf, count, ppos);
|
|
|
|
default:
|
|
|
|
index -= VFIO_CCW_NUM_REGIONS;
|
|
|
|
return private->region[index].ops->write(private, buf, count,
|
|
|
|
ppos);
|
|
|
|
}
|
|
|
|
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2021-10-27 01:57:32 +08:00
|
|
|
static int vfio_ccw_mdev_get_device_info(struct vfio_ccw_private *private,
|
|
|
|
struct vfio_device_info *info)
|
2018-07-19 23:53:08 +08:00
|
|
|
{
|
2017-03-17 11:17:37 +08:00
|
|
|
info->flags = VFIO_DEVICE_FLAGS_CCW | VFIO_DEVICE_FLAGS_RESET;
|
2018-07-19 23:53:08 +08:00
|
|
|
info->num_regions = VFIO_CCW_NUM_REGIONS + private->num_regions;
|
2017-03-17 11:17:38 +08:00
|
|
|
info->num_irqs = VFIO_CCW_NUM_IRQS;
|
2017-03-17 11:17:36 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-10-27 01:57:32 +08:00
|
|
|
static int vfio_ccw_mdev_get_region_info(struct vfio_ccw_private *private,
|
|
|
|
struct vfio_region_info *info,
|
2018-07-19 23:53:08 +08:00
|
|
|
unsigned long arg)
|
2017-03-17 11:17:36 +08:00
|
|
|
{
|
2018-07-19 23:53:08 +08:00
|
|
|
int i;
|
|
|
|
|
2017-03-17 11:17:36 +08:00
|
|
|
switch (info->index) {
|
|
|
|
case VFIO_CCW_CONFIG_REGION_INDEX:
|
|
|
|
info->offset = 0;
|
|
|
|
info->size = sizeof(struct ccw_io_region);
|
|
|
|
info->flags = VFIO_REGION_INFO_FLAG_READ
|
|
|
|
| VFIO_REGION_INFO_FLAG_WRITE;
|
|
|
|
return 0;
|
2018-07-19 23:53:08 +08:00
|
|
|
default: /* all other regions are handled via capability chain */
|
|
|
|
{
|
|
|
|
struct vfio_info_cap caps = { .buf = NULL, .size = 0 };
|
|
|
|
struct vfio_region_info_cap_type cap_type = {
|
|
|
|
.header.id = VFIO_REGION_INFO_CAP_TYPE,
|
|
|
|
.header.version = 1 };
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (info->index >=
|
|
|
|
VFIO_CCW_NUM_REGIONS + private->num_regions)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
info->index = array_index_nospec(info->index,
|
|
|
|
VFIO_CCW_NUM_REGIONS +
|
|
|
|
private->num_regions);
|
|
|
|
|
|
|
|
i = info->index - VFIO_CCW_NUM_REGIONS;
|
|
|
|
|
|
|
|
info->offset = VFIO_CCW_INDEX_TO_OFFSET(info->index);
|
|
|
|
info->size = private->region[i].size;
|
|
|
|
info->flags = private->region[i].flags;
|
|
|
|
|
|
|
|
cap_type.type = private->region[i].type;
|
|
|
|
cap_type.subtype = private->region[i].subtype;
|
|
|
|
|
|
|
|
ret = vfio_info_add_capability(&caps, &cap_type.header,
|
|
|
|
sizeof(cap_type));
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
info->flags |= VFIO_REGION_INFO_FLAG_CAPS;
|
|
|
|
if (info->argsz < sizeof(*info) + caps.size) {
|
|
|
|
info->argsz = sizeof(*info) + caps.size;
|
|
|
|
info->cap_offset = 0;
|
|
|
|
} else {
|
|
|
|
vfio_info_cap_shift(&caps, sizeof(*info));
|
|
|
|
if (copy_to_user((void __user *)arg + sizeof(*info),
|
|
|
|
caps.buf, caps.size)) {
|
|
|
|
kfree(caps.buf);
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
info->cap_offset = sizeof(*info);
|
|
|
|
}
|
|
|
|
|
|
|
|
kfree(caps.buf);
|
|
|
|
|
|
|
|
}
|
2017-03-17 11:17:36 +08:00
|
|
|
}
|
2018-07-19 23:53:08 +08:00
|
|
|
return 0;
|
2017-03-17 11:17:36 +08:00
|
|
|
}
|
|
|
|
|
2017-05-15 23:28:34 +08:00
|
|
|
static int vfio_ccw_mdev_get_irq_info(struct vfio_irq_info *info)
|
2017-03-17 11:17:38 +08:00
|
|
|
{
|
2020-05-05 20:27:42 +08:00
|
|
|
switch (info->index) {
|
|
|
|
case VFIO_CCW_IO_IRQ_INDEX:
|
2020-05-05 20:27:43 +08:00
|
|
|
case VFIO_CCW_CRW_IRQ_INDEX:
|
2020-12-04 05:35:12 +08:00
|
|
|
case VFIO_CCW_REQ_IRQ_INDEX:
|
2020-05-05 20:27:42 +08:00
|
|
|
info->count = 1;
|
|
|
|
info->flags = VFIO_IRQ_INFO_EVENTFD;
|
|
|
|
break;
|
|
|
|
default:
|
2017-03-17 11:17:38 +08:00
|
|
|
return -EINVAL;
|
2020-05-05 20:27:42 +08:00
|
|
|
}
|
2017-03-17 11:17:38 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-10-27 01:57:32 +08:00
|
|
|
static int vfio_ccw_mdev_set_irqs(struct vfio_ccw_private *private,
|
2017-03-17 11:17:38 +08:00
|
|
|
uint32_t flags,
|
2020-05-05 20:27:42 +08:00
|
|
|
uint32_t index,
|
2017-03-17 11:17:38 +08:00
|
|
|
void __user *data)
|
|
|
|
{
|
|
|
|
struct eventfd_ctx **ctx;
|
|
|
|
|
|
|
|
if (!(flags & VFIO_IRQ_SET_ACTION_TRIGGER))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2020-05-05 20:27:42 +08:00
|
|
|
switch (index) {
|
|
|
|
case VFIO_CCW_IO_IRQ_INDEX:
|
|
|
|
ctx = &private->io_trigger;
|
|
|
|
break;
|
2020-05-05 20:27:43 +08:00
|
|
|
case VFIO_CCW_CRW_IRQ_INDEX:
|
|
|
|
ctx = &private->crw_trigger;
|
|
|
|
break;
|
2020-12-04 05:35:12 +08:00
|
|
|
case VFIO_CCW_REQ_IRQ_INDEX:
|
|
|
|
ctx = &private->req_trigger;
|
|
|
|
break;
|
2020-05-05 20:27:42 +08:00
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2017-03-17 11:17:38 +08:00
|
|
|
|
|
|
|
switch (flags & VFIO_IRQ_SET_DATA_TYPE_MASK) {
|
|
|
|
case VFIO_IRQ_SET_DATA_NONE:
|
|
|
|
{
|
|
|
|
if (*ctx)
|
|
|
|
eventfd_signal(*ctx, 1);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
case VFIO_IRQ_SET_DATA_BOOL:
|
|
|
|
{
|
|
|
|
uint8_t trigger;
|
|
|
|
|
|
|
|
if (get_user(trigger, (uint8_t __user *)data))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
if (trigger && *ctx)
|
|
|
|
eventfd_signal(*ctx, 1);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
case VFIO_IRQ_SET_DATA_EVENTFD:
|
|
|
|
{
|
|
|
|
int32_t fd;
|
|
|
|
|
|
|
|
if (get_user(fd, (int32_t __user *)data))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
if (fd == -1) {
|
|
|
|
if (*ctx)
|
|
|
|
eventfd_ctx_put(*ctx);
|
|
|
|
*ctx = NULL;
|
|
|
|
} else if (fd >= 0) {
|
|
|
|
struct eventfd_ctx *efdctx;
|
|
|
|
|
|
|
|
efdctx = eventfd_ctx_fdget(fd);
|
|
|
|
if (IS_ERR(efdctx))
|
|
|
|
return PTR_ERR(efdctx);
|
|
|
|
|
|
|
|
if (*ctx)
|
|
|
|
eventfd_ctx_put(*ctx);
|
|
|
|
|
|
|
|
*ctx = efdctx;
|
|
|
|
} else
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-19 23:53:08 +08:00
|
|
|
int vfio_ccw_register_dev_region(struct vfio_ccw_private *private,
|
|
|
|
unsigned int subtype,
|
|
|
|
const struct vfio_ccw_regops *ops,
|
|
|
|
size_t size, u32 flags, void *data)
|
|
|
|
{
|
|
|
|
struct vfio_ccw_region *region;
|
|
|
|
|
|
|
|
region = krealloc(private->region,
|
|
|
|
(private->num_regions + 1) * sizeof(*region),
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!region)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
private->region = region;
|
|
|
|
private->region[private->num_regions].type = VFIO_REGION_TYPE_CCW;
|
|
|
|
private->region[private->num_regions].subtype = subtype;
|
|
|
|
private->region[private->num_regions].ops = ops;
|
|
|
|
private->region[private->num_regions].size = size;
|
|
|
|
private->region[private->num_regions].flags = flags;
|
|
|
|
private->region[private->num_regions].data = data;
|
|
|
|
|
|
|
|
private->num_regions++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-05-05 20:27:40 +08:00
|
|
|
void vfio_ccw_unregister_dev_regions(struct vfio_ccw_private *private)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < private->num_regions; i++)
|
|
|
|
private->region[i].ops->release(private, &private->region[i]);
|
|
|
|
private->num_regions = 0;
|
|
|
|
kfree(private->region);
|
|
|
|
private->region = NULL;
|
|
|
|
}
|
|
|
|
|
2021-10-27 01:57:33 +08:00
|
|
|
static ssize_t vfio_ccw_mdev_ioctl(struct vfio_device *vdev,
|
2017-03-17 11:17:36 +08:00
|
|
|
unsigned int cmd,
|
|
|
|
unsigned long arg)
|
|
|
|
{
|
2021-10-27 01:57:32 +08:00
|
|
|
struct vfio_ccw_private *private =
|
2021-10-27 01:57:33 +08:00
|
|
|
container_of(vdev, struct vfio_ccw_private, vdev);
|
2017-03-17 11:17:36 +08:00
|
|
|
int ret = 0;
|
|
|
|
unsigned long minsz;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case VFIO_DEVICE_GET_INFO:
|
|
|
|
{
|
|
|
|
struct vfio_device_info info;
|
|
|
|
|
|
|
|
minsz = offsetofend(struct vfio_device_info, num_irqs);
|
|
|
|
|
|
|
|
if (copy_from_user(&info, (void __user *)arg, minsz))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
if (info.argsz < minsz)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2021-10-27 01:57:32 +08:00
|
|
|
ret = vfio_ccw_mdev_get_device_info(private, &info);
|
2017-03-17 11:17:36 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2021-03-01 20:01:33 +08:00
|
|
|
return copy_to_user((void __user *)arg, &info, minsz) ? -EFAULT : 0;
|
2017-03-17 11:17:36 +08:00
|
|
|
}
|
|
|
|
case VFIO_DEVICE_GET_REGION_INFO:
|
|
|
|
{
|
|
|
|
struct vfio_region_info info;
|
|
|
|
|
|
|
|
minsz = offsetofend(struct vfio_region_info, offset);
|
|
|
|
|
|
|
|
if (copy_from_user(&info, (void __user *)arg, minsz))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
if (info.argsz < minsz)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2021-10-27 01:57:32 +08:00
|
|
|
ret = vfio_ccw_mdev_get_region_info(private, &info, arg);
|
2017-03-17 11:17:36 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2021-03-01 20:01:33 +08:00
|
|
|
return copy_to_user((void __user *)arg, &info, minsz) ? -EFAULT : 0;
|
2017-03-17 11:17:36 +08:00
|
|
|
}
|
2017-03-17 11:17:38 +08:00
|
|
|
case VFIO_DEVICE_GET_IRQ_INFO:
|
|
|
|
{
|
|
|
|
struct vfio_irq_info info;
|
|
|
|
|
|
|
|
minsz = offsetofend(struct vfio_irq_info, count);
|
|
|
|
|
|
|
|
if (copy_from_user(&info, (void __user *)arg, minsz))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
if (info.argsz < minsz || info.index >= VFIO_CCW_NUM_IRQS)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
ret = vfio_ccw_mdev_get_irq_info(&info);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if (info.count == -1)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2021-03-02 02:33:24 +08:00
|
|
|
return copy_to_user((void __user *)arg, &info, minsz) ? -EFAULT : 0;
|
2017-03-17 11:17:38 +08:00
|
|
|
}
|
|
|
|
case VFIO_DEVICE_SET_IRQS:
|
|
|
|
{
|
|
|
|
struct vfio_irq_set hdr;
|
|
|
|
size_t data_size;
|
|
|
|
void __user *data;
|
|
|
|
|
|
|
|
minsz = offsetofend(struct vfio_irq_set, count);
|
|
|
|
|
|
|
|
if (copy_from_user(&hdr, (void __user *)arg, minsz))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
ret = vfio_set_irqs_validate_and_prepare(&hdr, 1,
|
|
|
|
VFIO_CCW_NUM_IRQS,
|
|
|
|
&data_size);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
data = (void __user *)(arg + minsz);
|
2021-10-27 01:57:32 +08:00
|
|
|
return vfio_ccw_mdev_set_irqs(private, hdr.flags, hdr.index,
|
|
|
|
data);
|
2017-03-17 11:17:38 +08:00
|
|
|
}
|
2017-03-17 11:17:37 +08:00
|
|
|
case VFIO_DEVICE_RESET:
|
2021-10-27 01:57:32 +08:00
|
|
|
return vfio_ccw_mdev_reset(private);
|
2017-03-17 11:17:36 +08:00
|
|
|
default:
|
|
|
|
return -ENOTTY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-04 05:35:12 +08:00
|
|
|
/* Request removal of the device*/
|
2021-10-27 01:57:33 +08:00
|
|
|
static void vfio_ccw_mdev_request(struct vfio_device *vdev, unsigned int count)
|
2020-12-04 05:35:12 +08:00
|
|
|
{
|
2021-10-27 01:57:33 +08:00
|
|
|
struct vfio_ccw_private *private =
|
|
|
|
container_of(vdev, struct vfio_ccw_private, vdev);
|
|
|
|
struct device *dev = vdev->dev;
|
2020-12-04 05:35:12 +08:00
|
|
|
|
|
|
|
if (private->req_trigger) {
|
|
|
|
if (!(count % 10))
|
2021-10-27 01:57:33 +08:00
|
|
|
dev_notice_ratelimited(dev,
|
2020-12-04 05:35:12 +08:00
|
|
|
"Relaying device request to user (#%u)\n",
|
|
|
|
count);
|
|
|
|
|
|
|
|
eventfd_signal(private->req_trigger, 1);
|
|
|
|
} else if (count == 0) {
|
2021-10-27 01:57:33 +08:00
|
|
|
dev_notice(dev,
|
2020-12-04 05:35:12 +08:00
|
|
|
"No device request channel registered, blocked until released by user\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-27 01:57:33 +08:00
|
|
|
static const struct vfio_device_ops vfio_ccw_dev_ops = {
|
|
|
|
.open_device = vfio_ccw_mdev_open_device,
|
|
|
|
.close_device = vfio_ccw_mdev_close_device,
|
|
|
|
.read = vfio_ccw_mdev_read,
|
|
|
|
.write = vfio_ccw_mdev_write,
|
|
|
|
.ioctl = vfio_ccw_mdev_ioctl,
|
|
|
|
.request = vfio_ccw_mdev_request,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mdev_driver vfio_ccw_mdev_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "vfio_ccw_mdev",
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.mod_name = KBUILD_MODNAME,
|
|
|
|
},
|
|
|
|
.probe = vfio_ccw_mdev_probe,
|
|
|
|
.remove = vfio_ccw_mdev_remove,
|
|
|
|
};
|
|
|
|
|
2017-03-17 11:17:33 +08:00
|
|
|
static const struct mdev_parent_ops vfio_ccw_mdev_ops = {
|
|
|
|
.owner = THIS_MODULE,
|
2021-10-27 01:57:33 +08:00
|
|
|
.device_driver = &vfio_ccw_mdev_driver,
|
2017-03-17 11:17:33 +08:00
|
|
|
.supported_type_groups = mdev_type_groups,
|
|
|
|
};
|
|
|
|
|
|
|
|
int vfio_ccw_mdev_reg(struct subchannel *sch)
|
|
|
|
{
|
|
|
|
return mdev_register_device(&sch->dev, &vfio_ccw_mdev_ops);
|
|
|
|
}
|
|
|
|
|
|
|
|
void vfio_ccw_mdev_unreg(struct subchannel *sch)
|
|
|
|
{
|
|
|
|
mdev_unregister_device(&sch->dev);
|
|
|
|
}
|