[PATCH v6 01/15] s390/vfio-ap: Provide function to get the number of queues assigned to mdev

From: Anthony Krowiak

Date: Mon Jul 27 2026 - 13:38:14 EST


Provides a function that returns the number of queues that are or will be
passed through to a guest when the mdev is attached to a guest.

Signed-off-by: Anthony Krowiak <akrowiak@xxxxxxxxxxxxx>
---
drivers/s390/crypto/vfio_ap_ops.c | 8 ++++++++
drivers/s390/crypto/vfio_ap_private.h | 2 ++
2 files changed, 10 insertions(+)

diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
index 44b3a1dcc1b3..36786d70a88f 100644
--- a/drivers/s390/crypto/vfio_ap_ops.c
+++ b/drivers/s390/crypto/vfio_ap_ops.c
@@ -2098,6 +2098,14 @@ static void vfio_ap_mdev_request(struct vfio_device *vdev, unsigned int count)
release_update_locks_for_mdev(matrix_mdev);
}

+int vfio_ap_mdev_get_num_queues(struct ap_matrix *ap_matrix)
+{
+ lockdep_assert_held(&matrix_dev->mdevs_lock);
+
+ return bitmap_weight(ap_matrix->apm, AP_DEVICES) *
+ bitmap_weight(ap_matrix->aqm, AP_DOMAINS);
+}
+
static int vfio_ap_mdev_get_device_info(unsigned long arg)
{
unsigned long minsz;
diff --git a/drivers/s390/crypto/vfio_ap_private.h b/drivers/s390/crypto/vfio_ap_private.h
index 9bff666b0b35..9677e49554d7 100644
--- a/drivers/s390/crypto/vfio_ap_private.h
+++ b/drivers/s390/crypto/vfio_ap_private.h
@@ -152,6 +152,8 @@ struct vfio_ap_queue {
struct work_struct reset_work;
};

+int vfio_ap_mdev_get_num_queues(struct ap_matrix *ap_matrix);
+
int vfio_ap_mdev_register(void);
void vfio_ap_mdev_unregister(void);

--
2.53.0