s390/vfio-ap: Ignore duplicate link requests in vfio_ap_mdev_link_queue
authorJason J. Herne <jjherne@linux.ibm.com>
Mon, 15 Apr 2024 15:25:53 +0000 (11:25 -0400)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Mon, 22 Apr 2024 10:49:17 +0000 (12:49 +0200)
vfio_ap_mdev_link_queue is changed to detect if a matrix_mdev has
already linked the given queue. If so, it bails out.

Signed-off-by: "Jason J. Herne" <jjherne@linux.ibm.com>
Reviewed-by: Tony Krowiak <akrowiak@linux.ibm.com>
Link: https://lore.kernel.org/r/20240415152555.13152-4-jjherne@linux.ibm.com
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
drivers/s390/crypto/vfio_ap_ops.c

index e01f53a3c5b77668c58c0e641f406480d11c712b..1499c218112271146f0d79ee4544a9b004416c04 100644 (file)
@@ -794,10 +794,11 @@ err_put_vdev:
 static void vfio_ap_mdev_link_queue(struct ap_matrix_mdev *matrix_mdev,
                                    struct vfio_ap_queue *q)
 {
-       if (q) {
-               q->matrix_mdev = matrix_mdev;
-               hash_add(matrix_mdev->qtable.queues, &q->mdev_qnode, q->apqn);
-       }
+       if (!q || vfio_ap_mdev_get_queue(matrix_mdev, q->apqn))
+               return;
+
+       q->matrix_mdev = matrix_mdev;
+       hash_add(matrix_mdev->qtable.queues, &q->mdev_qnode, q->apqn);
 }
 
 static void vfio_ap_mdev_link_apqn(struct ap_matrix_mdev *matrix_mdev, int apqn)