From: Cornelia Huck <cohuck@redhat.com>
To: Eric Farman <farman@linux.ibm.com>
Cc: Halil Pasic <pasic@linux.ibm.com>,
Farhan Ali <alifm@linux.ibm.com>,
Pierre Morel <pmorel@linux.ibm.com>,
linux-s390@vger.kernel.org, kvm@vger.kernel.org,
qemu-devel@nongnu.org, qemu-s390x@nongnu.org,
Alex Williamson <alex.williamson@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v3 2/6] vfio-ccw: rework ssch state handling
Date: Tue, 5 Feb 2019 13:10:47 +0100 [thread overview]
Message-ID: <20190205131047.32f7c7a1.cohuck@redhat.com> (raw)
In-Reply-To: <55d9fc3d-12ec-9ad7-cdaa-72c5dbb65aca@linux.ibm.com>
On Mon, 4 Feb 2019 16:29:40 -0500
Eric Farman <farman@linux.ibm.com> wrote:
> On 01/30/2019 08:22 AM, Cornelia Huck wrote:
> > The flow for processing ssch requests can be improved by splitting
> > the BUSY state:
> >
> > - CP_PROCESSING: We reject any user space requests while we are in
> > the process of translating a channel program and submitting it to
> > the hardware. Use -EAGAIN to signal user space that it should
> > retry the request.
> > - CP_PENDING: We have successfully submitted a request with ssch and
> > are now expecting an interrupt. As we can't handle more than one
> > channel program being processed, reject any further requests with
> > -EBUSY. A final interrupt will move us out of this state; this also
> > fixes a latent bug where a non-final interrupt might have freed up
> > a channel program that still was in progress.
> > By making this a separate state, we make it possible to issue a
> > halt or a clear while we're still waiting for the final interrupt
> > for the ssch (in a follow-on patch).
> >
> > It also makes a lot of sense not to preemptively filter out writes to
> > the io_region if we're in an incorrect state: the state machine will
> > handle this correctly.
> >
> > Signed-off-by: Cornelia Huck <cohuck@redhat.com>
> > ---
> > drivers/s390/cio/vfio_ccw_drv.c | 8 ++++++--
> > drivers/s390/cio/vfio_ccw_fsm.c | 19 ++++++++++++++-----
> > drivers/s390/cio/vfio_ccw_ops.c | 2 --
> > drivers/s390/cio/vfio_ccw_private.h | 3 ++-
> > 4 files changed, 22 insertions(+), 10 deletions(-)
> > diff --git a/drivers/s390/cio/vfio_ccw_fsm.c b/drivers/s390/cio/vfio_ccw_fsm.c
> > index e7c9877c9f1e..b4a141fbd1a8 100644
> > --- a/drivers/s390/cio/vfio_ccw_fsm.c
> > +++ b/drivers/s390/cio/vfio_ccw_fsm.c
> > @@ -28,7 +28,6 @@ static int fsm_io_helper(struct vfio_ccw_private *private)
> > sch = private->sch;
> >
> > spin_lock_irqsave(sch->lock, flags);
> > - private->state = VFIO_CCW_STATE_BUSY;
> >
> > orb = cp_get_orb(&private->cp, (u32)(addr_t)sch, sch->lpm);
> > if (!orb) {
> > @@ -46,6 +45,7 @@ static int fsm_io_helper(struct vfio_ccw_private *private)
> > */
> > sch->schib.scsw.cmd.actl |= SCSW_ACTL_START_PEND;
> > ret = 0;
> > + private->state = VFIO_CCW_STATE_CP_PENDING;
>
> [1]
>
> > break;
> > case 1: /* Status pending */
> > case 2: /* Busy */
> > @@ -107,6 +107,12 @@ static void fsm_io_busy(struct vfio_ccw_private *private,
> > private->io_region->ret_code = -EBUSY;
> > }
> >
> > +static void fsm_io_retry(struct vfio_ccw_private *private,
> > + enum vfio_ccw_event event)
> > +{
> > + private->io_region->ret_code = -EAGAIN;
> > +}
> > +
> > static void fsm_disabled_irq(struct vfio_ccw_private *private,
> > enum vfio_ccw_event event)
> > {
> > @@ -135,8 +141,7 @@ static void fsm_io_request(struct vfio_ccw_private *private,
> > struct mdev_device *mdev = private->mdev;
> > char *errstr = "request";
> >
> > - private->state = VFIO_CCW_STATE_BUSY;
> > -
> > + private->state = VFIO_CCW_STATE_CP_PROCESSING;
>
> [1]
>
> > memcpy(scsw, io_region->scsw_area, sizeof(*scsw));
> >
> > if (scsw->cmd.fctl & SCSW_FCTL_START_FUNC) {
> > @@ -181,7 +186,6 @@ static void fsm_io_request(struct vfio_ccw_private *private,
> > }
> >
> > err_out:
> > - private->state = VFIO_CCW_STATE_IDLE;
>
> [1] Revisiting these locations as from an earlier discussion [2]...
> These go IDLE->CP_PROCESSING->CP_PENDING if we get a cc=0 on the SSCH,
> but we stop in CP_PROCESSING if the SSCH gets a nonzero cc. Shouldn't
> we cleanup and go back to IDLE in this scenario, rather than forcing
> userspace to escalate to CSCH/HSCH after some number of retries (via FSM)?
>
> [2] https://patchwork.kernel.org/patch/10773611/#22447997
It does do that (in vfio_ccw_mdev_write), it was not needed here. Or do
you think doing it here would be more obvious?
>
> Besides that, I think this looks good to me.
Thanks!
next prev parent reply other threads:[~2019-02-05 12:12 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-30 13:22 [Qemu-devel] [PATCH v3 0/6] vfio-ccw: support hsch/csch (kernel part) Cornelia Huck
2019-01-30 13:22 ` [Qemu-devel] [PATCH v3 1/6] vfio-ccw: make it safe to access channel programs Cornelia Huck
2019-01-30 18:51 ` Halil Pasic
2019-01-31 11:52 ` Cornelia Huck
2019-01-31 12:34 ` Halil Pasic
2019-02-04 15:31 ` Cornelia Huck
2019-02-05 11:52 ` Halil Pasic
2019-02-05 12:35 ` Cornelia Huck
2019-02-05 14:48 ` Eric Farman
2019-02-05 15:14 ` Farhan Ali
2019-02-05 16:13 ` Cornelia Huck
2019-02-04 19:25 ` Eric Farman
2019-02-05 12:03 ` Cornelia Huck
2019-02-05 14:41 ` Eric Farman
2019-02-05 16:29 ` Cornelia Huck
2019-01-30 13:22 ` [Qemu-devel] [PATCH v3 2/6] vfio-ccw: rework ssch state handling Cornelia Huck
2019-02-04 21:29 ` Eric Farman
2019-02-05 12:10 ` Cornelia Huck [this message]
2019-02-05 14:31 ` Eric Farman
2019-02-05 16:32 ` Cornelia Huck
2019-01-30 13:22 ` [Qemu-devel] [PATCH v3 3/6] vfio-ccw: protect the I/O region Cornelia Huck
2019-02-08 21:26 ` Eric Farman
2019-02-11 15:57 ` Cornelia Huck
2019-01-30 13:22 ` [Qemu-devel] [PATCH v3 4/6] vfio-ccw: add capabilities chain Cornelia Huck
2019-02-15 15:46 ` Eric Farman
2019-02-19 11:06 ` Cornelia Huck
2019-01-30 13:22 ` [Qemu-devel] [PATCH v3 5/6] s390/cio: export hsch to modules Cornelia Huck
2019-01-30 13:22 ` [Qemu-devel] [PATCH v3 6/6] vfio-ccw: add handling for async channel instructions Cornelia Huck
2019-01-30 17:00 ` Halil Pasic
2019-01-30 17:09 ` Halil Pasic
2019-01-31 11:53 ` Cornelia Huck
2019-02-06 14:00 ` [Qemu-devel] [PATCH v3 0/6] vfio-ccw: support hsch/csch (kernel part) Cornelia Huck
2019-02-08 21:19 ` Eric Farman
2019-02-11 16:13 ` Cornelia Huck
2019-02-11 17:37 ` Eric Farman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190205131047.32f7c7a1.cohuck@redhat.com \
--to=cohuck@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=alifm@linux.ibm.com \
--cc=farman@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=pasic@linux.ibm.com \
--cc=pmorel@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).