-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'vfio-ccw-20200603-v2' of https://git.kernel.org/pub/scm/li…
…nux/kernel/git/kvms390/vfio-ccw into features vfio-ccw updates: - accept requests without the prefetch bit set - enable path handling via two new regions * tag 'vfio-ccw-20200603-v2' of https://git.kernel.org/pub/scm/linux/kernel/git/kvms390/vfio-ccw: vfio-ccw: Add trace for CRW event vfio-ccw: Wire up the CRW irq and CRW region vfio-ccw: Introduce a new CRW region vfio-ccw: Refactor IRQ handlers vfio-ccw: Introduce a new schib region vfio-ccw: Refactor the unregister of the async regions vfio-ccw: Register a chp_event callback for vfio-ccw vfio-ccw: Introduce new helper functions to free/destroy regions vfio-ccw: document possible errors vfio-ccw: Enable transparent CCW IPL from DASD Link: https://lkml.kernel.org/r/20200603112716.332801-1-cohuck@redhat.com Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
- Loading branch information
Showing
11 changed files
with
531 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* | ||
* Channel path related status regions for vfio_ccw | ||
* | ||
* Copyright IBM Corp. 2020 | ||
* | ||
* Author(s): Farhan Ali <alifm@linux.ibm.com> | ||
* Eric Farman <farman@linux.ibm.com> | ||
*/ | ||
|
||
#include <linux/vfio.h> | ||
#include "vfio_ccw_private.h" | ||
|
||
static ssize_t vfio_ccw_schib_region_read(struct vfio_ccw_private *private, | ||
char __user *buf, size_t count, | ||
loff_t *ppos) | ||
{ | ||
unsigned int i = VFIO_CCW_OFFSET_TO_INDEX(*ppos) - VFIO_CCW_NUM_REGIONS; | ||
loff_t pos = *ppos & VFIO_CCW_OFFSET_MASK; | ||
struct ccw_schib_region *region; | ||
int ret; | ||
|
||
if (pos + count > sizeof(*region)) | ||
return -EINVAL; | ||
|
||
mutex_lock(&private->io_mutex); | ||
region = private->region[i].data; | ||
|
||
if (cio_update_schib(private->sch)) { | ||
ret = -ENODEV; | ||
goto out; | ||
} | ||
|
||
memcpy(region, &private->sch->schib, sizeof(*region)); | ||
|
||
if (copy_to_user(buf, (void *)region + pos, count)) { | ||
ret = -EFAULT; | ||
goto out; | ||
} | ||
|
||
ret = count; | ||
|
||
out: | ||
mutex_unlock(&private->io_mutex); | ||
return ret; | ||
} | ||
|
||
static ssize_t vfio_ccw_schib_region_write(struct vfio_ccw_private *private, | ||
const char __user *buf, size_t count, | ||
loff_t *ppos) | ||
{ | ||
return -EINVAL; | ||
} | ||
|
||
|
||
static void vfio_ccw_schib_region_release(struct vfio_ccw_private *private, | ||
struct vfio_ccw_region *region) | ||
{ | ||
|
||
} | ||
|
||
const struct vfio_ccw_regops vfio_ccw_schib_region_ops = { | ||
.read = vfio_ccw_schib_region_read, | ||
.write = vfio_ccw_schib_region_write, | ||
.release = vfio_ccw_schib_region_release, | ||
}; | ||
|
||
int vfio_ccw_register_schib_dev_regions(struct vfio_ccw_private *private) | ||
{ | ||
return vfio_ccw_register_dev_region(private, | ||
VFIO_REGION_SUBTYPE_CCW_SCHIB, | ||
&vfio_ccw_schib_region_ops, | ||
sizeof(struct ccw_schib_region), | ||
VFIO_REGION_INFO_FLAG_READ, | ||
private->schib_region); | ||
} | ||
|
||
static ssize_t vfio_ccw_crw_region_read(struct vfio_ccw_private *private, | ||
char __user *buf, size_t count, | ||
loff_t *ppos) | ||
{ | ||
unsigned int i = VFIO_CCW_OFFSET_TO_INDEX(*ppos) - VFIO_CCW_NUM_REGIONS; | ||
loff_t pos = *ppos & VFIO_CCW_OFFSET_MASK; | ||
struct ccw_crw_region *region; | ||
struct vfio_ccw_crw *crw; | ||
int ret; | ||
|
||
if (pos + count > sizeof(*region)) | ||
return -EINVAL; | ||
|
||
crw = list_first_entry_or_null(&private->crw, | ||
struct vfio_ccw_crw, next); | ||
|
||
if (crw) | ||
list_del(&crw->next); | ||
|
||
mutex_lock(&private->io_mutex); | ||
region = private->region[i].data; | ||
|
||
if (crw) | ||
memcpy(®ion->crw, &crw->crw, sizeof(region->crw)); | ||
|
||
if (copy_to_user(buf, (void *)region + pos, count)) | ||
ret = -EFAULT; | ||
else | ||
ret = count; | ||
|
||
region->crw = 0; | ||
|
||
mutex_unlock(&private->io_mutex); | ||
|
||
kfree(crw); | ||
|
||
/* Notify the guest if more CRWs are on our queue */ | ||
if (!list_empty(&private->crw) && private->crw_trigger) | ||
eventfd_signal(private->crw_trigger, 1); | ||
|
||
return ret; | ||
} | ||
|
||
static ssize_t vfio_ccw_crw_region_write(struct vfio_ccw_private *private, | ||
const char __user *buf, size_t count, | ||
loff_t *ppos) | ||
{ | ||
return -EINVAL; | ||
} | ||
|
||
static void vfio_ccw_crw_region_release(struct vfio_ccw_private *private, | ||
struct vfio_ccw_region *region) | ||
{ | ||
|
||
} | ||
|
||
const struct vfio_ccw_regops vfio_ccw_crw_region_ops = { | ||
.read = vfio_ccw_crw_region_read, | ||
.write = vfio_ccw_crw_region_write, | ||
.release = vfio_ccw_crw_region_release, | ||
}; | ||
|
||
int vfio_ccw_register_crw_dev_regions(struct vfio_ccw_private *private) | ||
{ | ||
return vfio_ccw_register_dev_region(private, | ||
VFIO_REGION_SUBTYPE_CCW_CRW, | ||
&vfio_ccw_crw_region_ops, | ||
sizeof(struct ccw_crw_region), | ||
VFIO_REGION_INFO_FLAG_READ, | ||
private->crw_region); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.