From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cornelia Huck Subject: Re: [PATCH 2/2] vfio-ccw: support async command subregion Date: Mon, 26 Nov 2018 10:58:43 +0100 Message-ID: <20181126105843.2efa2d06.cohuck@redhat.com> References: <20181122165457.4517-1-cohuck@redhat.com> <20181122165457.4517-3-cohuck@redhat.com> <8fbbe0b6-6924-ad61-1d94-26517765f346@linux.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: linux-s390@vger.kernel.org, Eric Farman , Alex Williamson , kvm@vger.kernel.org, Farhan Ali , qemu-devel@nongnu.org, Halil Pasic , qemu-s390x@nongnu.org To: Pierre Morel Return-path: In-Reply-To: <8fbbe0b6-6924-ad61-1d94-26517765f346@linux.ibm.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+gceq-qemu-devel2=m.gmane.org@nongnu.org Sender: "Qemu-devel" List-Id: kvm.vger.kernel.org On Fri, 23 Nov 2018 15:13:12 +0100 Pierre Morel wrote: > On 22/11/2018 17:54, Cornelia Huck wrote: > > A 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). > > > > Signed-off-by: Cornelia Huck > > --- > > hw/s390x/css.c | 27 +++++++-- > > hw/vfio/ccw.c | 109 +++++++++++++++++++++++++++++++++++- > > include/hw/s390x/s390-ccw.h | 3 + > > 3 files changed, 133 insertions(+), 6 deletions(-) > > > > @@ -114,6 +120,87 @@ again: > > } > > } > > > > +int vfio_ccw_handle_clear(SubchDev *sch) > > +{ > > + S390CCWDevice *cdev = sch->driver_data; > > + VFIOCCWDevice *vcdev = DO_UPCAST(VFIOCCWDevice, cdev, cdev); > > + struct ccw_cmd_region *region = vcdev->async_cmd_region; > > + int ret; > > + > > + if (!vcdev->async_cmd_region) { > > + /* Async command region not available, fall back to emulation */ > > + return -ENOSYS; > > + } > > + > > + memset(region, 0, sizeof(*region)); > > + region->command = VFIO_CCW_ASYNC_CMD_CSCH; > > + > > +again: > > + ret = pwrite(vcdev->vdev.fd, region, > > + vcdev->async_cmd_region_size, vcdev->async_cmd_region_offset); > > + if (ret != vcdev->async_cmd_region_size) { > > + if (errno == EAGAIN) { > > > Where do the EAGAIN come from? It might be set by pwrite. > > > > + goto again; > > + } > > + error_report("vfio-ccw: wirte I/O region failed with errno=%d", errno); I should also fix up this message here and for hsch as well :) > > + ret = -errno; > > + } else { > > + ret = region->ret_code; > > + } > > + switch (ret) { > > + case 0: > > + case -ENODEV: > > + case -EACCES: > > should never happen? It should not happen; but it can nevertheless be returned, so... > > > + return 0; > > + case -EFAULT: > > + default: > > + sch_gen_unit_exception(sch); > > + css_inject_io_interrupt(sch); > > + return 0; > > + } > > +} > > + > > otherwise LGTM Thanks!