All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matt Chapman <matthewc@hp.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] abstract request_evtchn
Date: Mon, 1 Aug 2005 16:32:10 -0600	[thread overview]
Message-ID: <20050801223210.GA4532@kirby.fc.hp.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 294 bytes --]

This patch provides request_evtchn and free_evtchn, intended
to be used instead of bind_evtchn_to_irq/request_irq and
free_irq/unbind_evtchn_from_irq.  This allows architectures
to implement event channels as they see fit, not necessarily
using Linux IRQs.

Tested to still work on x86.

Matt


[-- Attachment #2: blk2.diff --]
[-- Type: text/plain, Size: 4504 bytes --]

diff -r 12122e34b96f linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c
--- a/linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c	Thu Jul 14 22:33:25 2005
+++ b/linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c	Thu Jul 14 16:51:46 2005
@@ -341,6 +341,20 @@
     spin_unlock(&irq_mapping_update_lock);
 }
 
+int request_evtchn(int evtchn, evtchn_handler handler,
+                   unsigned long irqflags, const char * devname, void *dev_id)
+{
+    int irq = bind_evtchn_to_irq(evtchn);
+    return request_irq(irq, handler, irqflags, devname, dev_id);
+}
+
+void free_evtchn(int evtchn, void *dev_id)
+{
+    int irq = evtchn_to_irq[evtchn];
+    free_irq(irq, dev_id);
+    unbind_evtchn_from_irq(evtchn);
+}
+
 static void do_nothing_function(void *ign)
 {
 }
diff -r 12122e34b96f linux-2.6-xen-sparse/drivers/xen/blkback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/common.h	Thu Jul 14 22:33:25 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/common.h	Thu Jul 14 16:51:46 2005
@@ -42,7 +42,6 @@
     /* Physical parameters of the comms window. */
     unsigned long     shmem_frame;
     unsigned int      evtchn;
-    int               irq;
     /* Comms information. */
     blkif_back_ring_t blk_ring;
     /* VBDs attached to this interface. */
diff -r 12122e34b96f linux-2.6-xen-sparse/drivers/xen/blkback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Thu Jul 14 22:33:25 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Thu Jul 14 16:51:46 2005
@@ -38,7 +38,7 @@
      * may be outstanding requests at the disc whose asynchronous responses
      * must still be notified to the remote driver.
      */
-    unbind_evtchn_from_irq(blkif->evtchn);
+    free_evtchn(blkif->evtchn, blkif);
 
 #ifdef CONFIG_XEN_BLKDEV_GRANT
     {
@@ -247,12 +247,11 @@
     BACK_RING_INIT(&blkif->blk_ring, sring, PAGE_SIZE);
     
     blkif->evtchn        = evtchn;
-    blkif->irq           = bind_evtchn_to_irq(evtchn);
     blkif->shmem_frame   = shmem_frame;
     blkif->status        = CONNECTED;
     blkif_get(blkif);
 
-    request_irq(blkif->irq, blkif_be_int, 0, "blkif-backend", blkif);
+    request_evtchn(blkif->evtchn, blkif_be_int, 0, "blkif-backend", blkif);
 
     connect->status = BLKIF_BE_STATUS_OKAY;
 }
@@ -277,7 +276,6 @@
         blkif->status = DISCONNECTING;
         blkif->disconnect_rspid = rsp_id;
         wmb(); /* Let other CPUs see the status change. */
-        free_irq(blkif->irq, blkif);
         blkif_deschedule(blkif);
         blkif_put(blkif);
         return 0; /* Caller should not send response message. */
diff -r 12122e34b96f linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Thu Jul 14 22:33:25 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Thu Jul 14 16:51:46 2005
@@ -78,7 +78,6 @@
 static int blkif_handle = 0;
 static unsigned int blkif_state = BLKIF_STATE_CLOSED;
 static unsigned int blkif_evtchn = 0;
-static unsigned int blkif_irq = 0;
 
 static int blkif_control_rsp_valid;
 static blkif_response_t blkif_control_rsp;
@@ -1159,10 +1158,7 @@
         free_page((unsigned long)blk_ring.sring);
         blk_ring.sring = NULL;
     }
-    free_irq(blkif_irq, NULL);
-    blkif_irq = 0;
-    
-    unbind_evtchn_from_irq(blkif_evtchn);
+    free_evtchn(blkif_evtchn, NULL);
     blkif_evtchn = 0;
 }
 
@@ -1266,12 +1262,11 @@
     int err = 0;
 
     blkif_evtchn = status->evtchn;
-    blkif_irq    = bind_evtchn_to_irq(blkif_evtchn);
-
-    err = request_irq(blkif_irq, blkif_int, SA_SAMPLE_RANDOM, "blkif", NULL);
+
+    err = request_evtchn(blkif_evtchn, blkif_int, SA_SAMPLE_RANDOM, "blkif", NULL);
     if ( err )
     {
-        WPRINTK("request_irq failed (err=%d)\n", err);
+        WPRINTK("request_evtchn failed (err=%d)\n", err);
         return;
     }
 
diff -r 12122e34b96f linux-2.6-xen-sparse/include/asm-xen/evtchn.h
--- a/linux-2.6-xen-sparse/include/asm-xen/evtchn.h	Thu Jul 14 22:33:25 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/evtchn.h	Thu Jul 14 16:51:46 2005
@@ -41,6 +41,11 @@
 /*
  * LOW-LEVEL DEFINITIONS
  */
+
+/* Binding to event channels */
+typedef int (*evtchn_handler)(int dummy, void *dev_id, struct pt_regs *regs);
+int request_evtchn(int evtchn, evtchn_handler handler, unsigned long irqflags, const char *devname, void *dev_id);
+void free_evtchn(int evtchn, void *dev_id);
 
 /* Entry point for notifications into Linux subsystems. */
 asmlinkage void evtchn_do_upcall(struct pt_regs *regs);

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

             reply	other threads:[~2005-08-01 22:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-01 22:32 Matt Chapman [this message]
2005-08-02 11:43 ` [PATCH] abstract request_evtchn Keir Fraser
2005-08-02 20:26   ` Matt Chapman
     [not found] ` <mailman.1122982780.21880@unix-os.sc.intel.com>
2005-08-02 20:41   ` Arun Sharma
  -- strict thread matches above, loose matches on Subject: below --
2005-08-03 15:09 Ling, Xiaofeng

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=20050801223210.GA4532@kirby.fc.hp.com \
    --to=matthewc@hp.com \
    --cc=xen-devel@lists.xensource.com \
    /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.