Commit 3ba41768 authored by Tony Krowiak's avatar Tony Krowiak Committed by Heiko Carstens

s390/vfio_ap: use TAPQ to verify reset in progress completes

To eliminate the repeated calls to the PQAP(ZAPQ) function to verify that
a reset in progress completed successfully and ensure that error response
codes get appropriately logged, let's call the apq_reset_check() function
when the ZAPQ response code indicates that a reset that is already in
progress.
Signed-off-by: default avatarTony Krowiak <akrowiak@linux.ibm.com>
Reviewed-by: default avatarJason J. Herne <jjherne@linux.ibm.com>
Reviewed-by: default avatarHarald Freudenberger <freude@linux.ibm.com>
Link: https://lore.kernel.org/r/20230118203111.529766-4-akrowiak@linux.ibm.comSigned-off-by: default avatarChristian Borntraeger <borntraeger@linux.ibm.com>
Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
parent 0daf9878
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
static int vfio_ap_mdev_reset_queues(struct ap_queue_table *qtable); static int vfio_ap_mdev_reset_queues(struct ap_queue_table *qtable);
static struct vfio_ap_queue *vfio_ap_find_queue(int apqn); static struct vfio_ap_queue *vfio_ap_find_queue(int apqn);
static const struct vfio_device_ops vfio_ap_matrix_dev_ops; static const struct vfio_device_ops vfio_ap_matrix_dev_ops;
static int vfio_ap_mdev_reset_queue(struct vfio_ap_queue *q, unsigned int retry); static int vfio_ap_mdev_reset_queue(struct vfio_ap_queue *q);
/** /**
* get_update_locks_for_kvm: Acquire the locks required to dynamically update a * get_update_locks_for_kvm: Acquire the locks required to dynamically update a
...@@ -1643,8 +1643,7 @@ static int apq_reset_check(struct vfio_ap_queue *q) ...@@ -1643,8 +1643,7 @@ static int apq_reset_check(struct vfio_ap_queue *q)
return ret; return ret;
} }
static int vfio_ap_mdev_reset_queue(struct vfio_ap_queue *q, static int vfio_ap_mdev_reset_queue(struct vfio_ap_queue *q)
unsigned int retry)
{ {
struct ap_queue_status status; struct ap_queue_status status;
int ret; int ret;
...@@ -1659,12 +1658,15 @@ static int vfio_ap_mdev_reset_queue(struct vfio_ap_queue *q, ...@@ -1659,12 +1658,15 @@ static int vfio_ap_mdev_reset_queue(struct vfio_ap_queue *q,
ret = 0; ret = 0;
break; break;
case AP_RESPONSE_RESET_IN_PROGRESS: case AP_RESPONSE_RESET_IN_PROGRESS:
if (retry--) { /*
msleep(20); * There is a reset issued by another process in progress. Let's wait
goto retry_zapq; * for that to complete. Since we have no idea whether it was a RAPQ or
} * ZAPQ, then if it completes successfully, let's issue the ZAPQ.
ret = -EBUSY; */
break; ret = apq_reset_check(q);
if (ret)
break;
goto retry_zapq;
case AP_RESPONSE_Q_NOT_AVAIL: case AP_RESPONSE_Q_NOT_AVAIL:
case AP_RESPONSE_DECONFIGURED: case AP_RESPONSE_DECONFIGURED:
case AP_RESPONSE_CHECKSTOPPED: case AP_RESPONSE_CHECKSTOPPED:
...@@ -1699,7 +1701,7 @@ static int vfio_ap_mdev_reset_queues(struct ap_queue_table *qtable) ...@@ -1699,7 +1701,7 @@ static int vfio_ap_mdev_reset_queues(struct ap_queue_table *qtable)
struct vfio_ap_queue *q; struct vfio_ap_queue *q;
hash_for_each(qtable->queues, loop_cursor, q, mdev_qnode) { hash_for_each(qtable->queues, loop_cursor, q, mdev_qnode) {
ret = vfio_ap_mdev_reset_queue(q, 1); ret = vfio_ap_mdev_reset_queue(q);
/* /*
* Regardless whether a queue turns out to be busy, or * Regardless whether a queue turns out to be busy, or
* is not operational, we need to continue resetting * is not operational, we need to continue resetting
...@@ -1950,7 +1952,7 @@ void vfio_ap_mdev_remove_queue(struct ap_device *apdev) ...@@ -1950,7 +1952,7 @@ void vfio_ap_mdev_remove_queue(struct ap_device *apdev)
} }
} }
vfio_ap_mdev_reset_queue(q, 1); vfio_ap_mdev_reset_queue(q);
dev_set_drvdata(&apdev->device, NULL); dev_set_drvdata(&apdev->device, NULL);
kfree(q); kfree(q);
release_update_locks_for_mdev(matrix_mdev); release_update_locks_for_mdev(matrix_mdev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment