Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754799AbeAOMY3 (ORCPT + 1 other); Mon, 15 Jan 2018 07:24:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45294 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753741AbeAOMY1 (ORCPT ); Mon, 15 Jan 2018 07:24:27 -0500 Date: Mon, 15 Jan 2018 13:24:22 +0100 From: Cornelia Huck To: Pierre Morel Cc: Dong Jia Shi , linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, qemu-devel@nongnu.org, qemu-s390x@nongnu.org, borntraeger@de.ibm.com, pasic@linux.vnet.ibm.com Subject: Re: [RFC PATCH 1/3] vfio: ccw: introduce schib region Message-ID: <20180115132422.6a1a805d.cohuck@redhat.com> In-Reply-To: <82e00fe3-22be-c4df-60c9-8348906d8c45@linux.vnet.ibm.com> References: <20180111030421.31418-1-bjsdjshi@linux.vnet.ibm.com> <20180111030421.31418-2-bjsdjshi@linux.vnet.ibm.com> <82e00fe3-22be-c4df-60c9-8348906d8c45@linux.vnet.ibm.com> Organization: Red Hat GmbH MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 15 Jan 2018 12:24:27 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Mon, 15 Jan 2018 10:50:00 +0100 Pierre Morel wrote: > On 11/01/2018 04:04, Dong Jia Shi wrote: > > This introduces a new region for vfio-ccw to provide subchannel > > information for user space. > > > > Signed-off-by: Dong Jia Shi > > --- > > drivers/s390/cio/vfio_ccw_fsm.c | 21 ++++++++++ > > drivers/s390/cio/vfio_ccw_ops.c | 79 +++++++++++++++++++++++++++---------- > > drivers/s390/cio/vfio_ccw_private.h | 3 ++ > > include/uapi/linux/vfio.h | 1 + > > include/uapi/linux/vfio_ccw.h | 6 +++ > > 5 files changed, 90 insertions(+), 20 deletions(-) > > > > diff --git a/drivers/s390/cio/vfio_ccw_private.h b/drivers/s390/cio/vfio_ccw_private.h > > index 78a66d96756b..460c8b90d834 100644 > > --- a/drivers/s390/cio/vfio_ccw_private.h > > +++ b/drivers/s390/cio/vfio_ccw_private.h > > @@ -28,6 +28,7 @@ > > * @mdev: pointer to the mediated device > > * @nb: notifier for vfio events > > * @io_region: MMIO region to input/output I/O arguments/results > > + * @schib_region: MMIO region of subchannel information > > * @cp: channel program for the current I/O operation > > * @irb: irb info received from interrupt > > * @scsw: scsw info > > @@ -42,6 +43,7 @@ struct vfio_ccw_private { > > struct mdev_device *mdev; > > struct notifier_block nb; > > struct ccw_io_region io_region; > > + struct ccw_schib_region schib_region; > > > > struct channel_program cp; > > struct irb irb; > > Hi, > > I have a problem with these patches: you have 3 definitions for the > subchannel status word: > 1: direct in the scsw entry of the vfio_ccw_private structure > 2: indirect in the IRB structure irb > 3: now in the scsw of the schib_region > > How do you keep them all in sync? > > The direct scsw in io region seems to only serve as a trigger used by > userland, while > the IRB in the io region and the SCHIB in the schib region are updated > asynchronously, > from hardware, one by polling (scsw in schib region), one by IRQ (scsw > in irb in io region). > > I find this at least a source for obfuscation. I agree that this wants some more documentation. However, some of this structure duplication is a consequence of the hardware design, because the scsw is present in both the schib (updated by stsch) and the irb (updated by tsch). There are cases where the irb is simply not enough (it does not contain a pmcw, and you can only do tsch on an enabled subchannel). So I think that we really need two structures for those two distinct operations (and everything interfacing with this needs to keep synced on the scsw, as current users of stsch/tsch already need to do now). The direct scsw entry is used for initiating the different functions (only start right now), I don't really see a good alternative for that (and I also don't really see any problem with needed syncing.)