All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: linux-um@lists.infradead.org
Cc: Johannes Berg <johannes.berg@intel.com>
Subject: [PATCH 2/7] um: virtio: use dynamic IRQ allocation
Date: Mon, 23 Nov 2020 20:56:16 +0100	[thread overview]
Message-ID: <20201123205445.ca0bcc4d6429.Id7bf6cf5659579ac53cce88552126e4d98a74e3d@changeid> (raw)
In-Reply-To: <20201123195621.275470-1-johannes@sipsolutions.net>

From: Johannes Berg <johannes.berg@intel.com>

This separates the devices, which is better for debug and for
later suspend/resume and wakeup support, since there we'll
have to separate which IRQs can wake up the system and which
cannot.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 arch/um/drivers/virtio_uml.c | 22 ++++++++++++++--------
 arch/um/include/asm/irq.h    |  5 ++---
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/arch/um/drivers/virtio_uml.c b/arch/um/drivers/virtio_uml.c
index f76b8da28d20..94b112749d5b 100644
--- a/arch/um/drivers/virtio_uml.c
+++ b/arch/um/drivers/virtio_uml.c
@@ -55,7 +55,7 @@ struct virtio_uml_device {
 	struct platform_device *pdev;
 
 	spinlock_t sock_lock;
-	int sock, req_fd;
+	int sock, req_fd, irq;
 	u64 features;
 	u64 protocol_features;
 	u8 status;
@@ -409,12 +409,14 @@ static int vhost_user_init_slave_req(struct virtio_uml_device *vu_dev)
 		return rc;
 	vu_dev->req_fd = req_fds[0];
 
-	rc = um_request_irq(VIRTIO_IRQ, vu_dev->req_fd, IRQ_READ,
+	rc = um_request_irq(UM_IRQ_ALLOC, vu_dev->req_fd, IRQ_READ,
 			    vu_req_interrupt, IRQF_SHARED,
 			    vu_dev->pdev->name, vu_dev);
 	if (rc < 0)
 		goto err_close;
 
+	vu_dev->irq = rc;
+
 	rc = vhost_user_send_no_payload_fd(vu_dev, VHOST_USER_SET_SLAVE_REQ_FD,
 					   req_fds[1]);
 	if (rc)
@@ -423,7 +425,7 @@ static int vhost_user_init_slave_req(struct virtio_uml_device *vu_dev)
 	goto out;
 
 err_free_irq:
-	um_free_irq(VIRTIO_IRQ, vu_dev);
+	um_free_irq(vu_dev->irq, vu_dev);
 err_close:
 	os_close_file(req_fds[0]);
 out:
@@ -802,7 +804,11 @@ static void vu_del_vq(struct virtqueue *vq)
 	struct virtio_uml_vq_info *info = vq->priv;
 
 	if (info->call_fd >= 0) {
-		um_free_irq(VIRTIO_IRQ, vq);
+		struct virtio_uml_device *vu_dev;
+
+		vu_dev = to_virtio_uml_device(vq->vdev);
+
+		um_free_irq(vu_dev->irq, vq);
 		os_close_file(info->call_fd);
 	}
 
@@ -852,7 +858,7 @@ 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(VIRTIO_IRQ, info->call_fd, IRQ_READ,
+	rc = um_request_irq(vu_dev->irq, info->call_fd, IRQ_READ,
 			    vu_interrupt, IRQF_SHARED, info->name, vq);
 	if (rc < 0)
 		goto close_both;
@@ -864,7 +870,7 @@ static int vu_setup_vq_call_fd(struct virtio_uml_device *vu_dev,
 	goto out;
 
 release_irq:
-	um_free_irq(VIRTIO_IRQ, vq);
+	um_free_irq(vu_dev->irq, vq);
 close_both:
 	os_close_file(call_fds[0]);
 out:
@@ -969,7 +975,7 @@ static struct virtqueue *vu_setup_vq(struct virtio_device *vdev,
 
 error_setup:
 	if (info->call_fd >= 0) {
-		um_free_irq(VIRTIO_IRQ, vq);
+		um_free_irq(vu_dev->irq, vq);
 		os_close_file(info->call_fd);
 	}
 error_call:
@@ -1078,7 +1084,7 @@ static void virtio_uml_release_dev(struct device *d)
 
 	/* might not have been opened due to not negotiating the feature */
 	if (vu_dev->req_fd >= 0) {
-		um_free_irq(VIRTIO_IRQ, vu_dev);
+		um_free_irq(vu_dev->irq, vu_dev);
 		os_close_file(vu_dev->req_fd);
 	}
 
diff --git a/arch/um/include/asm/irq.h b/arch/um/include/asm/irq.h
index b6fa6301c75b..547bff7b3a89 100644
--- a/arch/um/include/asm/irq.h
+++ b/arch/um/include/asm/irq.h
@@ -17,18 +17,17 @@
 #define TELNETD_IRQ 		12
 #define XTERM_IRQ 		13
 #define RANDOM_IRQ 		14
-#define VIRTIO_IRQ		15
 
 #ifdef CONFIG_UML_NET_VECTOR
 
-#define VECTOR_BASE_IRQ		(VIRTIO_IRQ + 1)
+#define VECTOR_BASE_IRQ		(RANDOM_IRQ + 1)
 #define VECTOR_IRQ_SPACE	8
 
 #define UM_FIRST_DYN_IRQ (VECTOR_IRQ_SPACE + VECTOR_BASE_IRQ)
 
 #else
 
-#define UM_FIRST_DYN_IRQ (VIRTIO_IRQ + 1)
+#define UM_FIRST_DYN_IRQ (RANDOM_IRQ + 1)
 
 #endif
 
-- 
2.26.2


_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um


  parent reply	other threads:[~2020-11-23 19:56 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-23 19:56 [PATCH 0/7 um: IRQ handling cleanups Johannes Berg
2020-11-23 19:56 ` [PATCH 1/7] um: support dynamic IRQ allocation Johannes Berg
2020-11-30 11:26   ` Anton Ivanov
2020-11-23 19:56 ` Johannes Berg [this message]
2020-11-30 13:45   ` [PATCH 2/7] um: virtio: use " Anton Ivanov
2020-11-23 19:56 ` [PATCH 3/7] um: clean up alarm IRQ chip name Johannes Berg
2020-11-30 13:54   ` Anton Ivanov
2020-11-23 19:56 ` [PATCH 4/7] um: irq: clean up and rename struct irq_fd Johannes Berg
2020-11-30 14:01   ` Anton Ivanov
2020-11-23 19:56 ` [PATCH 5/7] um: irq: reduce irq_reg allocation Johannes Berg
2020-11-23 19:56 ` [PATCH 6/7] um: remove IRQ_NONE type Johannes Berg
2020-11-30 14:31   ` Anton Ivanov
2020-11-23 19:56 ` [PATCH 7/7] um: simplify IRQ handling code Johannes Berg
2020-11-24 21:50   ` Anton Ivanov
2020-11-24 21:58     ` Johannes Berg
2020-11-24 22:36       ` Anton Ivanov
2020-11-30 12:00         ` Johannes Berg
2020-11-30 13:40           ` Anton Ivanov
2020-11-30 16:30   ` Anton Ivanov
2020-12-01 20:15     ` Johannes Berg
2020-12-02  9:03       ` Anton Ivanov
2020-12-02 11:29         ` Johannes Berg
2020-12-02 11:31           ` Anton Ivanov
2020-12-02 11:32             ` Johannes Berg
2020-12-02 11:56               ` Anton Ivanov
2020-12-02 11:58                 ` Johannes Berg
2020-12-02 11:43           ` Johannes Berg
2020-12-02 11:49     ` Johannes Berg
2020-12-02 11:54   ` Johannes Berg
2020-12-02 11:58     ` Anton Ivanov
2020-11-24  8:14 ` [PATCH 0/7 um: IRQ handling cleanups Anton Ivanov
2020-11-24  8:55   ` Johannes Berg
2020-11-24  8:58     ` Johannes Berg
2020-11-24  9:06       ` Anton Ivanov
2020-11-24 16:34         ` Anton Ivanov
2020-11-24 16:39           ` Johannes Berg
2020-11-24 16:42             ` Anton Ivanov
2020-11-24 16:45             ` Anton Ivanov
2020-11-24 16:46               ` Johannes Berg
2020-11-24 17:07                 ` Anton Ivanov
2020-11-24 18:32                   ` Johannes Berg
2020-11-24 21:11 ` Johannes Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201123205445.ca0bcc4d6429.Id7bf6cf5659579ac53cce88552126e4d98a74e3d@changeid \
    --to=johannes@sipsolutions.net \
    --cc=johannes.berg@intel.com \
    --cc=linux-um@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.