]> git.baikalelectronics.ru Git - kernel.git/commitdiff
vfio/ccw: Fix FSM state if mdev probe fails
authorEric Farman <farman@linux.ibm.com>
Thu, 7 Jul 2022 13:57:28 +0000 (15:57 +0200)
committerAlex Williamson <alex.williamson@redhat.com>
Thu, 7 Jul 2022 20:06:12 +0000 (14:06 -0600)
The FSM is in STANDBY state when arriving in vfio_ccw_mdev_probe(),
and this routine converts it to IDLE as part of its processing.
The error exit sets it to IDLE (again) but clears the private->mdev
pointer.

The FSM should of course be managing the state itself, but the
correct thing for vfio_ccw_mdev_probe() to do would be to put
the state back the way it found it.

The corresponding check of private->mdev in vfio_ccw_sch_io_todo()
can be removed, since the distinction is unnecessary at this point.

Fixes: 3db21ed0fbba2 ("vfio/ccw: Convert to use vfio_register_emulated_iommu_dev()")
Signed-off-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
Link: https://lore.kernel.org/r/20220707135737.720765-3-farman@linux.ibm.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/s390/cio/vfio_ccw_drv.c
drivers/s390/cio/vfio_ccw_ops.c

index 35055eb9411500aab14071a916c2189c4e058904..179eb614fa5be458dea4497a3c8757bfd9033e0b 100644 (file)
@@ -106,9 +106,10 @@ static void vfio_ccw_sch_io_todo(struct work_struct *work)
        /*
         * Reset to IDLE only if processing of a channel program
         * has finished. Do not overwrite a possible processing
-        * state if the final interrupt was for HSCH or CSCH.
+        * state if the interrupt was unsolicited, or if the final
+        * interrupt was for HSCH or CSCH.
         */
-       if (private->mdev && cp_is_finished)
+       if (cp_is_finished)
                private->state = VFIO_CCW_STATE_IDLE;
 
        if (private->io_trigger)
index 0e05bff78b8e710eb020a3156f16c196aacea38f..9a05dadcbb7545298676fa6783cb4f6890054d61 100644 (file)
@@ -146,7 +146,7 @@ err_atomic:
        vfio_uninit_group_dev(&private->vdev);
        atomic_inc(&private->avail);
        private->mdev = NULL;
-       private->state = VFIO_CCW_STATE_IDLE;
+       private->state = VFIO_CCW_STATE_STANDBY;
        return ret;
 }