Re: [PATCH v7 01/15] s390/vfio-ap: Provide function to get the number of queues assigned to mdev
From: Jason J. Herne
Date: Thu Aug 13 2026 - 07:55:27 EST
On 8/7/26 6:18 PM, Anthony Krowiak wrote:
Provides a function that returns the number of queues that are or will bestatic inline unsigned int bitmap_weight(const unsigned long *src, unsigned int nbits)
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);
+}
+
bitmap_weight returns an unsigned int. I think vfio_ap_mdev_get_num_queues should probably return an unsigned int too, for maximum typw safety?
Other than that:
Reviewed-by: Jason J. Herne <jjherne@xxxxxxxxxxxxx>