From: Cornelia Huck <cohuck@redhat.com>
To: Eric Farman <farman@linux.ibm.com>
Cc: Halil Pasic <pasic@linux.ibm.com>,
Matthew Rosato <mjrosato@linux.ibm.com>,
Jared Rossi <jrossi@linux.ibm.com>,
linux-s390@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [RFC PATCH v4 4/4] vfio-ccw: Reset FSM state to IDLE before io_mutex
Date: Wed, 21 Apr 2021 12:25:29 +0200 [thread overview]
Message-ID: <20210421122529.6e373a39.cohuck@redhat.com> (raw)
In-Reply-To: <20210413182410.1396170-5-farman@linux.ibm.com>
On Tue, 13 Apr 2021 20:24:10 +0200
Eric Farman <farman@linux.ibm.com> wrote:
> Today, the stacked call to vfio_ccw_sch_io_todo() does three things:
>
> 1) Update a solicited IRB with CP information, and release the CP
> if the interrupt was the end of a START operation.
> 2) Copy the IRB data into the io_region, under the protection of
> the io_mutex
> 3) Reset the vfio-ccw FSM state to IDLE to acknowledge that
> vfio-ccw can accept more work.
>
> The trouble is that step 3 is (A) invoked for both solicited and
> unsolicited interrupts, and (B) sitting after the mutex for step 2.
> This second piece becomes a problem if it processes an interrupt
> for a CLEAR SUBCHANNEL while another thread initiates a START,
> thus allowing the CP and FSM states to get out of sync. That is:
>
> CPU 1 CPU 2
> fsm_do_clear()
> fsm_irq()
> fsm_io_request()
> fsm_io_helper()
> vfio_ccw_sch_io_todo()
> fsm_irq()
> vfio_ccw_sch_io_todo()
>
> Let's move the reset of the FSM state to the point where the
> channel_program struct is cleaned up, which is only done for
> solicited interrupts anyway.
>
> Signed-off-by: Eric Farman <farman@linux.ibm.com>
> ---
> drivers/s390/cio/vfio_ccw_drv.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/s390/cio/vfio_ccw_drv.c b/drivers/s390/cio/vfio_ccw_drv.c
> index 8c625b530035..e51318f23ca8 100644
> --- a/drivers/s390/cio/vfio_ccw_drv.c
> +++ b/drivers/s390/cio/vfio_ccw_drv.c
> @@ -94,16 +94,15 @@ static void vfio_ccw_sch_io_todo(struct work_struct *work)
> (SCSW_ACTL_DEVACT | SCSW_ACTL_SCHACT));
> if (scsw_is_solicited(&irb->scsw)) {
> cp_update_scsw(&private->cp, &irb->scsw);
> - if (is_final && private->state == VFIO_CCW_STATE_CP_PENDING)
> + if (is_final && private->state == VFIO_CCW_STATE_CP_PENDING) {
> cp_free(&private->cp);
> + private->state = VFIO_CCW_STATE_IDLE;
> + }
> }
> mutex_lock(&private->io_mutex);
> memcpy(private->io_region->irb_area, irb, sizeof(*irb));
> mutex_unlock(&private->io_mutex);
>
> - if (private->mdev && is_final)
> - private->state = VFIO_CCW_STATE_IDLE;
Isn't that re-allowing new I/O requests a bit too early? Maybe remember
that we had a final I/O interrupt for an I/O request and only change
the state in this case?
> -
> if (private->io_trigger)
> eventfd_signal(private->io_trigger, 1);
> }
next prev parent reply other threads:[~2021-04-21 10:26 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-13 18:24 [RFC PATCH v4 0/4] vfio-ccw: Fix interrupt handling for HALT/CLEAR Eric Farman
2021-04-13 18:24 ` [RFC PATCH v4 1/4] vfio-ccw: Check initialized flag in cp_init() Eric Farman
2021-04-14 16:30 ` Cornelia Huck
2021-04-13 18:24 ` [RFC PATCH v4 2/4] vfio-ccw: Check workqueue before doing START Eric Farman
2021-04-15 10:51 ` Cornelia Huck
2021-04-15 13:48 ` Eric Farman
2021-04-15 16:19 ` Cornelia Huck
2021-04-15 18:42 ` Eric Farman
2021-04-16 14:41 ` Cornelia Huck
2021-04-13 18:24 ` [RFC PATCH v4 3/4] vfio-ccw: Reset FSM state to IDLE inside FSM Eric Farman
2021-04-15 10:54 ` Cornelia Huck
2021-04-13 18:24 ` [RFC PATCH v4 4/4] vfio-ccw: Reset FSM state to IDLE before io_mutex Eric Farman
2021-04-21 10:25 ` Cornelia Huck [this message]
2021-04-21 12:58 ` Eric Farman
2021-04-22 16:16 ` Eric Farman
2021-04-22 0:52 ` [RFC PATCH v4 0/4] vfio-ccw: Fix interrupt handling for HALT/CLEAR Halil Pasic
2021-04-22 20:49 ` Eric Farman
2021-04-23 11:06 ` Cornelia Huck
2021-04-23 13:23 ` Halil Pasic
2021-04-23 13:28 ` Niklas Schnelle
2021-04-23 15:53 ` Eric Farman
2021-04-23 11:50 ` Halil Pasic
2021-04-23 15:53 ` Eric Farman
2021-04-23 17:08 ` Halil Pasic
2021-04-23 19:07 ` Eric Farman
2021-04-24 0:18 ` Halil Pasic
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=20210421122529.6e373a39.cohuck@redhat.com \
--to=cohuck@redhat.com \
--cc=farman@linux.ibm.com \
--cc=jrossi@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mjrosato@linux.ibm.com \
--cc=pasic@linux.ibm.com \
/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).