]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
um: virtio_uml: fix call_fd IRQ allocation
authorBenjamin Berg <benjamin.berg@intel.com>
Sun, 3 Nov 2024 21:28:53 +0000 (22:28 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 7 Nov 2024 16:57:49 +0000 (17:57 +0100)
If the device does not support slave requests, then the IRQ will not yet
be allocated. So initialize the IRQ to UM_IRQ_ALLOC so that it will be
allocated if none has been assigned yet and store it slightly later when
we know that it will not be immediately unregistered again.

Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Link: https://patch.msgid.link/20241103212854.1436046-4-benjamin@sipsolutions.net
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
arch/um/drivers/virtio_uml.c

index c602892f329f53c6df3c1461a4eec5772610e904..0f9efee4c671a714291cda85e91ec3095a61fa91 100644 (file)
@@ -888,7 +888,7 @@ static int vu_setup_vq_call_fd(struct virtio_uml_device *vu_dev,
 {
        struct virtio_uml_vq_info *info = vq->priv;
        int call_fds[2];
-       int rc;
+       int rc, irq;
 
        /* no call FD needed/desired in this case */
        if (vu_dev->protocol_features &
@@ -905,19 +905,23 @@ static int vu_setup_vq_call_fd(struct virtio_uml_device *vu_dev,
                return rc;
 
        info->call_fd = call_fds[0];
-       rc = um_request_irq(vu_dev->irq, info->call_fd, IRQ_READ,
-                           vu_interrupt, IRQF_SHARED, info->name, vq);
-       if (rc < 0)
+       irq = um_request_irq(vu_dev->irq, info->call_fd, IRQ_READ,
+                            vu_interrupt, IRQF_SHARED, info->name, vq);
+       if (irq < 0) {
+               rc = irq;
                goto close_both;
+       }
 
        rc = vhost_user_set_vring_call(vu_dev, vq->index, call_fds[1]);
        if (rc)
                goto release_irq;
 
+       vu_dev->irq = irq;
+
        goto out;
 
 release_irq:
-       um_free_irq(vu_dev->irq, vq);
+       um_free_irq(irq, vq);
 close_both:
        os_close_file(call_fds[0]);
 out:
@@ -1201,6 +1205,7 @@ static int virtio_uml_probe(struct platform_device *pdev)
        vu_dev->vdev.id.vendor = VIRTIO_DEV_ANY_ID;
        vu_dev->pdev = pdev;
        vu_dev->req_fd = -1;
+       vu_dev->irq = UM_IRQ_ALLOC;
 
        time_travel_propagate_time();