vfio-ccw: support hsch/csch (QEMU part)
v2 cover vfio-ccw: support hsch/csch (QEMU part)
[This is the QEMU part, git tree is available at
https://github.com/cohuck/qemu vfio-ccw-caps
The companion Linux kernel patches are available at
https://git.kernel.org/pub/scm/linux/kernel/git/kvms390/vfio-ccw.git vfio-ccw-eagain-caps]
Currently, vfio-ccw only relays START SUBCHANNEL requests to the real device. This tends to work well for the most common 'good path' scenarios; however, as we emulate {HALT,CLEAR} SUBCHANNEL in QEMU, things like clearing pending requests at the device is currently not supported. This may be a problem for e.g. error recovery.
This patch series makes use of the newly introduced async command region to issue hsch/csch; if it is not present, continue to emulate hsch/csch, as before.
Note that the kernel side now returns -EAGAIN to trigger a retry in more cases; QEMU should already be fine with that.
[I'm not quite happy with how this async processing hooks up in css.c; ideas welcome.]
Lightly tested (I can interact with a dasd as before, and reserve/release seems to work well.) Not sure if there is a better way to test this, ideas welcome.
Changes v1->v2:
- update kernel header to v2 of kernel patches
- rebased on master
Cornelia Huck (2):
vfio-ccw: new capability chain support
vfio-ccw: support async command subregion
hw/s390x/css.c | 27 ++++++-- hw/vfio/ccw.c | 109 ++++++++++++++++++++++++++++++++- include/hw/s390x/s390-ccw.h | 3 + linux-headers/linux/vfio.h | 4 ++ linux-headers/linux/vfio_ccw.h | 12 ++++ 5 files changed, 149 insertions(+), 6 deletions(-)
Signature · 1 line
2.17.2
PATCH v2 1/2 vfio-ccw: new capability chain support
To be replaced with a real linux-headers update.
--- linux-headers/linux/vfio.h | 4 ++++ linux-headers/linux/vfio_ccw.h | 12 ++++++++++++ 2 files changed, 16 insertions(+)
linux-headers/linux/vfio.h +4 -0
@@ -303,6 +303,10 @@ struct vfio_region_info_cap_type {#define VFIO_REGION_SUBTYPE_INTEL_IGD_HOST_CFG (2)#define VFIO_REGION_SUBTYPE_INTEL_IGD_LPC_CFG (3) +#define VFIO_REGION_TYPE_CCW (2) +/* ccw sub-types */ +#define VFIO_REGION_SUBTYPE_CCW_ASYNC_CMD (1) +/* * The MSIX mappable capability informs that MSIX data of a BAR can be mmapped * which allows direct access to non-MSIX registers which happened to be within
linux-headers/linux/vfio_ccw.h +12 -0
@@ -12,6 +12,7 @@#include <linux/types.h> +/* used for START SUBCHANNEL, always present */ struct ccw_io_region {#define ORB_AREA_SIZE 12__u8 orb_area[ORB_AREA_SIZE ];
@@ -22,4 +23,15 @@ struct ccw_io_region {__u32 ret_code; } __attribute__((packed)); +/* +* used for processing commands that trigger asynchronous actions +* Note: this is controlled by a capability +*/ +#define VFIO_CCW_ASYNC_CMD_HSCH (1 << 0) +#define VFIO_CCW_ASYNC_CMD_CSCH (1 << 1) +struct ccw_cmd_region { +__u32 command; +__u32 ret_code; +} __attribute__((packed)); +#endif
Signature · 1 line
2.17.2
PATCH v2 2/2 vfio-ccw: support async command subregion
In reply to Cornelia HuckA vfio-ccw device may provide an async command subregion for issuing halt/clear subchannel requests. If it is present, use it for sending halt/clear request to the device; if not, fall back to emulation (as done today).
--- hw/s390x/css.c | 27 +++++++-- hw/vfio/ccw.c | 109 +++++++++++++++++++++++++++++++++++- include/hw/s390x/s390-ccw.h | 3 + 3 files changed, 133 insertions(+), 6 deletions(-)
hw/s390x/css.c +23 -4
@@ -22,6 +22,7 @@#include "trace.h" #include "hw/s390x/s390_flic.h" #include "hw/s390x/s390-virtio-ccw.h" +#include "hw/s390x/s390-ccw.h" typedef struct CrwContainer { CRW crw;
@@ -1194,6 +1195,26 @@ static void sch_handle_start_func_virtual(SubchDev *sch) } +static void sch_handle_halt_func_passthrough (SubchDev *sch) +{ +int ret; + + ret =vfio_ccw_handle_halt (sch); +if (ret == -ENOSYS ) { +sch_handle_halt_func (sch); + } +} + +static void sch_handle_clear_func_passthrough (SubchDev *sch) +{ +int ret; + + ret =vfio_ccw_handle_clear (sch); +if (ret == -ENOSYS ) { +sch_handle_clear_func (sch); + } +} +static IOInstEnding sch_handle_start_func_passthrough (SubchDev *sch) {
@@ -1237,11 +1258,9 @@ IOInstEnding do_subchannel_work_passthrough(SubchDev *sch)SCSW *s = &sch->curr_status.scsw;if (s->ctrl &SCSW_FCTL_CLEAR_FUNC ) { -/* TODO: Clear handling */ -sch_handle_clear_func (sch); +sch_handle_clear_func_passthrough (sch); }else if (s->ctrl &SCSW_FCTL_HALT_FUNC ) { -/* TODO: Halt handling */ -sch_handle_halt_func (sch); +sch_handle_halt_func_passthrough (sch); }else if (s->ctrl &SCSW_FCTL_START_FUNC ) {return sch_handle_start_func_passthrough (sch); }
hw/vfio/ccw.c +107 -2
143 lines not on this page · raw message
include/hw/s390x/s390-ccw.h +3 -0
@@ -36,4 +36,7 @@ typedef struct S390CCWDeviceClass { IOInstEnding (*handle_request) (SubchDev *sch); } S390CCWDeviceClass; +int vfio_ccw_handle_clear (SubchDev *sch); +int vfio_ccw_handle_halt (SubchDev *sch); +#endif
Signature · 1 line
2.17.2