public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Chris Wright <chrisw@sous-sol.org>
To: Avi Kivity <avi@redhat.com>
Cc: kvm@vger.kernel.org, ddutile@redhat.com
Subject: [PATCH] kvm: external module: fix request_irq for < 2.6.19
Date: Tue, 28 Apr 2009 08:56:51 -0700	[thread overview]
Message-ID: <20090428155651.GF3036@sequoia.sous-sol.org> (raw)

The irq handler changes (introduced in 2.6.19, not 2.6.20) dropped
struct pt_regs from the handler prototype, they are found globally now.
This introduces the back compat for older kernels.  The handler is just
a thin layer which calls the real registered handler (all this to work
around a minor little compiler warning ;-)  Needed for device assignment
on older kernels.

Signed-off-by: Chris Wright <chrisw@redhat.com>
---
 kernel/external-module-compat-comm.h |   30 ++++++++++++++++++++++++++----
 kernel/ia64/hack-module.awk          |    2 +-
 kernel/x86/hack-module.awk           |    2 +-
 3 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/kernel/external-module-compat-comm.h b/kernel/external-module-compat-comm.h
index 5649d33..032a0f1 100644
--- a/kernel/external-module-compat-comm.h
+++ b/kernel/external-module-compat-comm.h
@@ -645,19 +645,41 @@ static inline int pci_reset_function(struct pci_dev *dev)
 #endif
 
 #include <linux/interrupt.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
+
+typedef irqreturn_t (*kvm_irq_handler_t)(int, void *);
+static kvm_irq_handler_t kvm_irq_handlers[NR_IRQS];
+
+static irqreturn_t kvm_irq_thunk(int irq, void *dev_id, struct pt_regs *regs)
+{
+	kvm_irq_handler_t handler = kvm_irq_handlers[irq];
+	return handler(irq, dev_id);
+}
 
-typedef irqreturn_t (*kvm_irq_handler_t)(int, void *, struct pt_regs *);
 static inline int kvm_request_irq(unsigned int a, kvm_irq_handler_t handler,
 				  unsigned long c, const char *d, void *e)
 {
-	/* FIXME: allocate thunk, etc. */
-	return -EINVAL;
+	int rc;
+	kvm_irq_handler_t old = kvm_irq_handlers[a];
+	if (old)
+		return -EBUSY;
+	kvm_irq_handlers[a] = handler;
+	rc = request_irq(a, kvm_irq_thunk, c, d, e);
+	if (rc)
+		kvm_irq_handlers[a] = NULL;
+	return rc;
+}
+
+static inline void kvm_free_irq(unsigned int irq, void *dev_id)
+{
+	free_irq(irq, dev_id);
+	kvm_irq_handlers[irq] = NULL;
 }
 
 #else
 
 #define kvm_request_irq request_irq
+#define kvm_free_irq free_irq
 
 #endif
 
diff --git a/kernel/ia64/hack-module.awk b/kernel/ia64/hack-module.awk
index d0ef130..2eb557a 100644
--- a/kernel/ia64/hack-module.awk
+++ b/kernel/ia64/hack-module.awk
@@ -2,7 +2,7 @@ BEGIN { split("INIT_WORK on_each_cpu smp_call_function " \
 	      "hrtimer_add_expires_ns hrtimer_get_expires " \
 	      "hrtimer_get_expires_ns hrtimer_start_expires " \
 	      "hrtimer_expires_remaining " \
-	      "request_irq", compat_apis); }
+	      "request_irq free_irq", compat_apis); }
 
 /MODULE_AUTHOR/ {
     printf("MODULE_INFO(version, \"%s\");\n", version)
diff --git a/kernel/x86/hack-module.awk b/kernel/x86/hack-module.awk
index c04e073..325d399 100644
--- a/kernel/x86/hack-module.awk
+++ b/kernel/x86/hack-module.awk
@@ -2,7 +2,7 @@ BEGIN { split("INIT_WORK tsc_khz desc_struct ldttss_desc64 desc_ptr " \
 	      "hrtimer_add_expires_ns hrtimer_get_expires " \
 	      "hrtimer_get_expires_ns hrtimer_start_expires " \
 	      "hrtimer_expires_remaining " \
-	      "on_each_cpu relay_open request_irq" , compat_apis); }
+	      "on_each_cpu relay_open request_irq free_irq" , compat_apis); }
 
 /^int kvm_init\(/ { anon_inodes = 1 }
 

             reply	other threads:[~2009-04-28 15:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-28 15:56 Chris Wright [this message]
2009-04-30 11:44 ` [PATCH] kvm: external module: fix request_irq for < 2.6.19 Avi Kivity

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=20090428155651.GF3036@sequoia.sous-sol.org \
    --to=chrisw@sous-sol.org \
    --cc=avi@redhat.com \
    --cc=ddutile@redhat.com \
    --cc=kvm@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox