diff mbox series

[2/4] um: virtio_uml: use smaller virtqueue sizes for VIRTIO_ID_SOUND

Message ID 20241103212854.1436046-3-benjamin@sipsolutions.net
State Changes Requested
Headers show
Series Enable virtio-fs and virtio-snd in UML | expand

Commit Message

Benjamin Berg Nov. 3, 2024, 9:28 p.m. UTC
From: Benjamin Berg <benjamin.berg@intel.com>

It appears that the different vhost device implementations use different
sizes of the virtual queues. Add device specific limitations (for now,
only for sound), to ensure that we do not get disconnected unexpectedly.

Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
---
 arch/um/drivers/virtio_uml.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Comments

Johannes Berg Nov. 7, 2024, 5:01 p.m. UTC | #1
On Sun, 2024-11-03 at 22:28 +0100, Benjamin Berg wrote:
> From: Benjamin Berg <benjamin.berg@intel.com>
> 
> It appears that the different vhost device implementations use different
> sizes of the virtual queues. Add device specific limitations (for now,
> only for sound), to ensure that we do not get disconnected unexpectedly.

I'm not convinced this makes sense. If anything, it's a workaround for
some specific userspace, but ... do we care enough and not let them fix
it?

The protocol [1] basically says we decide on the size (see
VHOST_USER_SET_VRING_NUM) and the device doesn't even need to allocate
the memory, that's on us?

[1] https://qemu-project.gitlab.io/qemu/interop/vhost-user.html

So maybe let's see what they were thinking? I'm not sure it's important
enough right now to have this working to apply such a workaround without
some further discussion?

On PCI it seems that you can and should query the desired queue size
(see e.g. vp_modern_get_queue_size), but with vhost-user that doesn't
seem to be supported at all, so there isn't really a good thing we could
do in that sense.

johannes
diff mbox series

Patch

diff --git a/arch/um/drivers/virtio_uml.c b/arch/um/drivers/virtio_uml.c
index c602892f329f..2e4b4eadd553 100644
--- a/arch/um/drivers/virtio_uml.c
+++ b/arch/um/drivers/virtio_uml.c
@@ -25,6 +25,7 @@ 
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/virtio.h>
+#include <linux/virtio_ids.h>
 #include <linux/virtio_config.h>
 #include <linux/virtio_ring.h>
 #include <linux/time-internal.h>
@@ -935,9 +936,19 @@  static struct virtqueue *vu_setup_vq(struct virtio_device *vdev,
 	struct platform_device *pdev = vu_dev->pdev;
 	struct virtio_uml_vq_info *info;
 	struct virtqueue *vq;
-	int num = MAX_SUPPORTED_QUEUE_SIZE;
+	int num;
 	int rc;
 
+	/* Seems like we need to hard-code the queue size */
+	switch (vu_dev->vdev.id.device) {
+	case VIRTIO_ID_SOUND:
+		num = 64;
+		break;
+	default:
+		num = MAX_SUPPORTED_QUEUE_SIZE;
+		break;
+	}
+
 	info = kzalloc(sizeof(*info), GFP_KERNEL);
 	if (!info) {
 		rc = -ENOMEM;