[PATCH v2 12/16] s390/vfio-ap: Transition device migration state from STOP to RUNNING and vice versa

From: Anthony Krowiak

Date: Tue Apr 07 2026 - 16:57:43 EST


The transition from STOP to RUNNING and vice versa indicates that
the vfio device is operating normally and migration is not
currently taking place. In this case, just set the new state and
if there are any migrations files used to help facilitate migration
hanging around, release them.

Signed-off-by: Anthony Krowiak <akrowiak@xxxxxxxxxxxxx>
---
drivers/s390/crypto/vfio_ap_migration.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/s390/crypto/vfio_ap_migration.c b/drivers/s390/crypto/vfio_ap_migration.c
index 6074ccfb9240..28209d8476d9 100644
--- a/drivers/s390/crypto/vfio_ap_migration.c
+++ b/drivers/s390/crypto/vfio_ap_migration.c
@@ -945,12 +945,18 @@ vfio_ap_transition_to_state(struct ap_matrix_mdev *matrix_mdev,
return NULL;
}

+ /*
+ * These states indicates migration has either not been initiated or
+ * has completed and the vfio-ap device is operating normally; so
+ * just set the new migration state. Just in case, release the
+ * migration files used to facilitate migration if any are hanging
+ * around.
+ */
if ((cur_state == VFIO_DEVICE_STATE_STOP &&
new_state == VFIO_DEVICE_STATE_RUNNING) ||
(cur_state == VFIO_DEVICE_STATE_RUNNING &&
new_state == VFIO_DEVICE_STATE_STOP)) {
- /* TODO */
- return ERR_PTR(-EOPNOTSUPP);
+ return NULL;
}

/* vfio_mig_get_next_state() does not use arcs other than the above */
--
2.52.0