# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxxx
# Date 1167503007 0
# Node ID d275951acf103aed23293ddc9313d5af5c3406b8
# Parent 63fb88610e1eea29feec1fe32fc96ff63811a6f6
[LINUX] Extend the event-channel interfaces to provide helper methods
for creating interdomain event channels bound to IRQ handlers.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c | 28 +--
linux-2.6-xen-sparse/drivers/xen/blkback/common.h | 1
linux-2.6-xen-sparse/drivers/xen/blkback/interface.c | 21 --
linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c | 17 -
linux-2.6-xen-sparse/drivers/xen/blkfront/block.h | 2
linux-2.6-xen-sparse/drivers/xen/blktap/common.h | 1
linux-2.6-xen-sparse/drivers/xen/blktap/interface.c | 21 --
linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c | 2
linux-2.6-xen-sparse/drivers/xen/core/evtchn.c | 145 ++++++++++++++--
linux-2.6-xen-sparse/drivers/xen/fbfront/xenfb.c | 18 -
linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c | 16 -
linux-2.6-xen-sparse/drivers/xen/netback/common.h | 1
linux-2.6-xen-sparse/drivers/xen/netback/interface.c | 17 -
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c | 19 --
linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c | 10 -
linux-2.6-xen-sparse/drivers/xen/tpmback/common.h | 1
linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c | 21 --
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c | 22 --
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c | 2
linux-2.6-xen-sparse/include/xen/evtchn.h | 43 +++-
linux-2.6-xen-sparse/include/xen/xenbus.h | 8
21 files changed, 225 insertions(+), 191 deletions(-)
diff -r 63fb88610e1e -r d275951acf10
linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c
--- a/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c Sat Dec 30 15:45:13
2006 +0000
+++ b/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c Sat Dec 30 18:23:27
2006 +0000
@@ -54,7 +54,6 @@ struct tpm_private {
tpmif_tx_interface_t *tx;
atomic_t refcnt;
- unsigned int evtchn;
unsigned int irq;
u8 is_connected;
u8 is_suspended;
@@ -271,7 +270,7 @@ static void destroy_tpmring(struct tpm_p
if (tp->irq)
unbind_from_irqhandler(tp->irq, tp);
- tp->evtchn = tp->irq = 0;
+ tp->irq = 0;
}
@@ -302,8 +301,8 @@ again:
goto abort_transaction;
}
- err = xenbus_printf(xbt, dev->nodename,
- "event-channel", "%u", tp->evtchn);
+ err = xenbus_printf(xbt, dev->nodename, "event-channel", "%u",
+ irq_to_evtchn_port(tp->irq));
if (err) {
message = "writing event-channel";
goto abort_transaction;
@@ -459,19 +458,15 @@ static int tpmif_connect(struct xenbus_d
tp->backend_id = domid;
- err = xenbus_alloc_evtchn(dev, &tp->evtchn);
- if (err)
+ err = bind_listening_port_to_irqhandler(
+ domid, tpmif_int, SA_SAMPLE_RANDOM, "tpmif", tp);
+ if (err <= 0) {
+ WPRINTK("bind_listening_port_to_irqhandler failed "
+ "(err=%d)\n", err);
return err;
-
- err = bind_evtchn_to_irqhandler(tp->evtchn,
- tpmif_int, SA_SAMPLE_RANDOM, "tpmif",
- tp);
- if (err <= 0) {
- WPRINTK("bind_evtchn_to_irqhandler failed (err=%d)\n", err);
- return err;
- }
-
+ }
tp->irq = err;
+
return 0;
}
@@ -656,9 +651,6 @@ static int tpm_xmit(struct tpm_private *
mb();
- DPRINTK("Notifying backend via event channel %d\n",
- tp->evtchn);
-
notify_remote_via_irq(tp->irq);
spin_unlock_irq(&tp->tx_lock);
diff -r 63fb88610e1e -r d275951acf10
linux-2.6-xen-sparse/drivers/xen/blkback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/common.h Sat Dec 30 15:45:13
2006 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/common.h Sat Dec 30 18:23:27
2006 +0000
@@ -65,7 +65,6 @@ typedef struct blkif_st {
domid_t domid;
unsigned int handle;
/* Physical parameters of the comms window. */
- unsigned int evtchn;
unsigned int irq;
/* Comms information. */
blkif_back_ring_t blk_ring;
diff -r 63fb88610e1e -r d275951acf10
linux-2.6-xen-sparse/drivers/xen/blkback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c Sat Dec 30
15:45:13 2006 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c Sat Dec 30
18:23:27 2006 +0000
@@ -97,7 +97,6 @@ int blkif_map(blkif_t *blkif, unsigned l
{
blkif_sring_t *sring;
int err;
- struct evtchn_bind_interdomain bind_interdomain;
/* Already connected through? */
if (blkif->irq)
@@ -112,24 +111,18 @@ int blkif_map(blkif_t *blkif, unsigned l
return err;
}
- bind_interdomain.remote_dom = blkif->domid;
- bind_interdomain.remote_port = evtchn;
+ sring = (blkif_sring_t *)blkif->blk_ring_area->addr;
+ BACK_RING_INIT(&blkif->blk_ring, sring, PAGE_SIZE);
- err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
- &bind_interdomain);
- if (err) {
+ err = bind_interdomain_evtchn_to_irqhandler(
+ blkif->domid, evtchn, blkif_be_int, 0, "blkif-backend", blkif);
+ if (err < 0)
+ {
unmap_frontend_page(blkif);
free_vm_area(blkif->blk_ring_area);
return err;
}
-
- blkif->evtchn = bind_interdomain.local_port;
-
- sring = (blkif_sring_t *)blkif->blk_ring_area->addr;
- BACK_RING_INIT(&blkif->blk_ring, sring, PAGE_SIZE);
-
- blkif->irq = bind_evtchn_to_irqhandler(
- blkif->evtchn, blkif_be_int, 0, "blkif-backend", blkif);
+ blkif->irq = err;
return 0;
}
diff -r 63fb88610e1e -r d275951acf10
linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c Sat Dec 30
15:45:13 2006 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c Sat Dec 30
18:23:27 2006 +0000
@@ -174,8 +174,8 @@ again:
message = "writing ring-ref";
goto abort_transaction;
}
- err = xenbus_printf(xbt, dev->nodename,
- "event-channel", "%u", info->evtchn);
+ err = xenbus_printf(xbt, dev->nodename, "event-channel", "%u",
+ irq_to_evtchn_port(info->irq));
if (err) {
message = "writing event-channel";
goto abort_transaction;
@@ -228,15 +228,11 @@ static int setup_blkring(struct xenbus_d
}
info->ring_ref = err;
- err = xenbus_alloc_evtchn(dev, &info->evtchn);
- if (err)
- goto fail;
-
- err = bind_evtchn_to_irqhandler(
- info->evtchn, blkif_int, SA_SAMPLE_RANDOM, "blkif", info);
+ err = bind_listening_port_to_irqhandler(
+ dev->otherend_id, blkif_int, SA_SAMPLE_RANDOM, "blkif", info);
if (err <= 0) {
xenbus_dev_fatal(dev, err,
- "bind_evtchn_to_irqhandler failed");
+ "bind_listening_port_to_irqhandler");
goto fail;
}
info->irq = err;
@@ -775,8 +771,7 @@ static void blkif_free(struct blkfront_i
}
if (info->irq)
unbind_from_irqhandler(info->irq, info);
- info->evtchn = info->irq = 0;
-
+ info->irq = 0;
}
static void blkif_completion(struct blk_shadow *s)
diff -r 63fb88610e1e -r d275951acf10
linux-2.6-xen-sparse/drivers/xen/blkfront/block.h
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/block.h Sat Dec 30 15:45:13
2006 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/block.h Sat Dec 30 18:23:27
2006 +0000
@@ -119,7 +119,7 @@ struct blkfront_info
int connected;
int ring_ref;
blkif_front_ring_t ring;
- unsigned int evtchn, irq;
+ unsigned int irq;
struct xlbd_major_info *mi;
request_queue_t *rq;
struct work_struct work;
diff -r 63fb88610e1e -r d275951acf10
linux-2.6-xen-sparse/drivers/xen/blktap/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/common.h Sat Dec 30 15:45:13
2006 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/common.h Sat Dec 30 18:23:27
2006 +0000
@@ -56,7 +56,6 @@ typedef struct blkif_st {
domid_t domid;
unsigned int handle;
/* Physical parameters of the comms window. */
- unsigned int evtchn;
unsigned int irq;
/* Comms information. */
blkif_back_ring_t blk_ring;
diff -r 63fb88610e1e -r d275951acf10
linux-2.6-xen-sparse/drivers/xen/blktap/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c Sat Dec 30
15:45:13 2006 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c Sat Dec 30
18:23:27 2006 +0000
@@ -98,7 +98,6 @@ int tap_blkif_map(blkif_t *blkif, unsign
{
blkif_sring_t *sring;
int err;
- struct evtchn_bind_interdomain bind_interdomain;
/* Already connected through? */
if (blkif->irq)
@@ -113,24 +112,18 @@ int tap_blkif_map(blkif_t *blkif, unsign
return err;
}
- bind_interdomain.remote_dom = blkif->domid;
- bind_interdomain.remote_port = evtchn;
+ sring = (blkif_sring_t *)blkif->blk_ring_area->addr;
+ BACK_RING_INIT(&blkif->blk_ring, sring, PAGE_SIZE);
- err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
- &bind_interdomain);
- if (err) {
+ err = bind_interdomain_evtchn_to_irqhandler(
+ blkif->domid, evtchn, tap_blkif_be_int,
+ 0, "blkif-backend", blkif);
+ if (err < 0) {
unmap_frontend_page(blkif);
free_vm_area(blkif->blk_ring_area);
return err;
}
-
- blkif->evtchn = bind_interdomain.local_port;
-
- sring = (blkif_sring_t *)blkif->blk_ring_area->addr;
- BACK_RING_INIT(&blkif->blk_ring, sring, PAGE_SIZE);
-
- blkif->irq = bind_evtchn_to_irqhandler(
- blkif->evtchn, tap_blkif_be_int, 0, "blkif-backend", blkif);
+ blkif->irq = err;
return 0;
}
diff -r 63fb88610e1e -r d275951acf10
linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c
--- a/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c Sat Dec 30
15:45:13 2006 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c Sat Dec 30
18:23:27 2006 +0000
@@ -121,7 +121,7 @@ int xencons_ring_init(void)
!xen_start_info->console.domU.evtchn)
return -ENODEV;
- irq = bind_evtchn_to_irqhandler(
+ irq = bind_caller_port_to_irqhandler(
xen_start_info->console.domU.evtchn,
handle_input, 0, "xencons", NULL);
if (irq < 0) {
diff -r 63fb88610e1e -r d275951acf10
linux-2.6-xen-sparse/drivers/xen/core/evtchn.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/evtchn.c Sat Dec 30 15:45:13
2006 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/core/evtchn.c Sat Dec 30 18:23:27
2006 +0000
@@ -61,7 +61,14 @@ static u32 irq_info[NR_IRQS];
static u32 irq_info[NR_IRQS];
/* Binding types. */
-enum { IRQT_UNBOUND, IRQT_PIRQ, IRQT_VIRQ, IRQT_IPI, IRQT_EVTCHN };
+enum {
+ IRQT_UNBOUND,
+ IRQT_PIRQ,
+ IRQT_VIRQ,
+ IRQT_IPI,
+ IRQT_LOCAL_PORT,
+ IRQT_CALLER_PORT
+};
/* Constructor for packed IRQ information. */
static inline u32 mk_irq_info(u32 type, u32 index, u32 evtchn)
@@ -275,18 +282,18 @@ static int find_unbound_irq(void)
return -ENOSPC;
}
-static int bind_evtchn_to_irq(unsigned int evtchn)
+static int bind_caller_port_to_irq(unsigned int caller_port)
{
int irq;
spin_lock(&irq_mapping_update_lock);
- if ((irq = evtchn_to_irq[evtchn]) == -1) {
+ if ((irq = evtchn_to_irq[caller_port]) == -1) {
if ((irq = find_unbound_irq()) < 0)
goto out;
- evtchn_to_irq[evtchn] = irq;
- irq_info[irq] = mk_irq_info(IRQT_EVTCHN, 0, evtchn);
+ evtchn_to_irq[caller_port] = irq;
+ irq_info[irq] = mk_irq_info(IRQT_CALLER_PORT, 0, caller_port);
}
irq_bindcount[irq]++;
@@ -294,6 +301,59 @@ static int bind_evtchn_to_irq(unsigned i
out:
spin_unlock(&irq_mapping_update_lock);
return irq;
+}
+
+static int bind_local_port_to_irq(unsigned int local_port)
+{
+ int irq;
+
+ spin_lock(&irq_mapping_update_lock);
+
+ BUG_ON(evtchn_to_irq[local_port] != -1);
+
+ if ((irq = find_unbound_irq()) < 0) {
+ struct evtchn_close close = { .port = local_port };
+ if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close))
+ BUG();
+ goto out;
+ }
+
+ evtchn_to_irq[local_port] = irq;
+ irq_info[irq] = mk_irq_info(IRQT_LOCAL_PORT, 0, local_port);
+ irq_bindcount[irq]++;
+
+ out:
+ spin_unlock(&irq_mapping_update_lock);
+ return irq;
+}
+
+static int bind_listening_port_to_irq(unsigned int remote_domain)
+{
+ struct evtchn_alloc_unbound alloc_unbound;
+ int err;
+
+ alloc_unbound.dom = DOMID_SELF;
+ alloc_unbound.remote_dom = remote_domain;
+
+ err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound,
+ &alloc_unbound);
+
+ return err ? : bind_local_port_to_irq(alloc_unbound.port);
+}
+
+static int bind_interdomain_evtchn_to_irq(unsigned int remote_domain,
+ unsigned int remote_port)
+{
+ struct evtchn_bind_interdomain bind_interdomain;
+ int err;
+
+ bind_interdomain.remote_dom = remote_domain;
+ bind_interdomain.remote_port = remote_port;
+
+ err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
+ &bind_interdomain);
+
+ return err ? : bind_local_port_to_irq(bind_interdomain.local_port);
}
static int bind_virq_to_irq(unsigned int virq, unsigned int cpu)
@@ -370,7 +430,8 @@ static void unbind_from_irq(unsigned int
if ((--irq_bindcount[irq] == 0) && VALID_EVTCHN(evtchn)) {
close.port = evtchn;
- if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close) != 0)
+ if ((type_from_irq(irq) != IRQT_CALLER_PORT) &&
+ HYPERVISOR_event_channel_op(EVTCHNOP_close, &close))
BUG();
switch (type_from_irq(irq)) {
@@ -396,17 +457,16 @@ static void unbind_from_irq(unsigned int
spin_unlock(&irq_mapping_update_lock);
}
-int bind_evtchn_to_irqhandler(
- unsigned int evtchn,
+int bind_caller_port_to_irqhandler(
+ unsigned int caller_port,
irqreturn_t (*handler)(int, void *, struct pt_regs *),
unsigned long irqflags,
const char *devname,
void *dev_id)
{
- unsigned int irq;
- int retval;
-
- irq = bind_evtchn_to_irq(evtchn);
+ int irq, retval;
+
+ irq = bind_caller_port_to_irq(caller_port);
if (irq < 0)
return irq;
@@ -418,7 +478,54 @@ int bind_evtchn_to_irqhandler(
return irq;
}
-EXPORT_SYMBOL_GPL(bind_evtchn_to_irqhandler);
+EXPORT_SYMBOL_GPL(bind_caller_port_to_irqhandler);
+
+int bind_listening_port_to_irqhandler(
+ unsigned int remote_domain,
+ irqreturn_t (*handler)(int, void *, struct pt_regs *),
+ unsigned long irqflags,
+ const char *devname,
+ void *dev_id)
+{
+ int irq, retval;
+
+ irq = bind_listening_port_to_irq(remote_domain);
+ if (irq < 0)
+ return irq;
+
+ retval = request_irq(irq, handler, irqflags, devname, dev_id);
+ if (retval != 0) {
+ unbind_from_irq(irq);
+ return retval;
+ }
+
+ return irq;
+}
+EXPORT_SYMBOL_GPL(bind_listening_port_to_irqhandler);
+
+int bind_interdomain_evtchn_to_irqhandler(
+ unsigned int remote_domain,
+ unsigned int remote_port,
+ irqreturn_t (*handler)(int, void *, struct pt_regs *),
+ unsigned long irqflags,
+ const char *devname,
+ void *dev_id)
+{
+ int irq, retval;
+
+ irq = bind_interdomain_evtchn_to_irq(remote_domain, remote_port);
+ if (irq < 0)
+ return irq;
+
+ retval = request_irq(irq, handler, irqflags, devname, dev_id);
+ if (retval != 0) {
+ unbind_from_irq(irq);
+ return retval;
+ }
+
+ return irq;
+}
+EXPORT_SYMBOL_GPL(bind_interdomain_evtchn_to_irqhandler);
int bind_virq_to_irqhandler(
unsigned int virq,
@@ -428,8 +535,7 @@ int bind_virq_to_irqhandler(
const char *devname,
void *dev_id)
{
- unsigned int irq;
- int retval;
+ int irq, retval;
irq = bind_virq_to_irq(virq, cpu);
if (irq < 0)
@@ -453,8 +559,7 @@ int bind_ipi_to_irqhandler(
const char *devname,
void *dev_id)
{
- unsigned int irq;
- int retval;
+ int irq, retval;
irq = bind_ipi_to_irq(ipi, cpu);
if (irq < 0)
@@ -729,6 +834,12 @@ void notify_remote_via_irq(int irq)
}
EXPORT_SYMBOL_GPL(notify_remote_via_irq);
+int irq_to_evtchn_port(int irq)
+{
+ return evtchn_from_irq(irq);
+}
+EXPORT_SYMBOL_GPL(irq_to_evtchn_port);
+
void mask_evtchn(int port)
{
shared_info_t *s = HYPERVISOR_shared_info;
diff -r 63fb88610e1e -r d275951acf10
linux-2.6-xen-sparse/drivers/xen/fbfront/xenfb.c
--- a/linux-2.6-xen-sparse/drivers/xen/fbfront/xenfb.c Sat Dec 30 15:45:13
2006 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/fbfront/xenfb.c Sat Dec 30 18:23:27
2006 +0000
@@ -56,7 +56,6 @@ struct xenfb_info
struct page **pages;
struct list_head mappings; /* protected by mm_lock */
- unsigned evtchn;
int irq;
struct xenfb_page *page;
unsigned long *mfns;
@@ -156,7 +155,7 @@ static void xenfb_do_update(struct xenfb
wmb(); /* ensure ring contents visible */
info->page->out_prod = prod + 1;
- notify_remote_via_evtchn(info->evtchn);
+ notify_remote_via_irq(info->irq);
}
static int xenfb_queue_full(struct xenfb_info *info)
@@ -429,7 +428,7 @@ static irqreturn_t xenfb_event_handler(i
if (page->in_cons != page->in_prod) {
info->page->in_cons = info->page->in_prod;
- notify_remote_via_evtchn(info->evtchn);
+ notify_remote_via_irq(info->irq);
}
return IRQ_HANDLED;
}
@@ -618,14 +617,11 @@ static int xenfb_connect_backend(struct
int ret;
struct xenbus_transaction xbt;
- ret = xenbus_alloc_evtchn(dev, &info->evtchn);
- if (ret)
- return ret;
- ret = bind_evtchn_to_irqhandler(info->evtchn, xenfb_event_handler,
- 0, "xenfb", info);
+ ret = bind_listening_port_to_irqhandler(
+ dev->otherend_id, xenfb_event_handler, 0, "xenfb", info);
if (ret < 0) {
- xenbus_free_evtchn(dev, info->evtchn);
- xenbus_dev_fatal(dev, ret, "bind_evtchn_to_irqhandler");
+ xenbus_dev_fatal(dev, ret,
+ "bind_listening_port_to_irqhandler");
return ret;
}
info->irq = ret;
@@ -641,7 +637,7 @@ static int xenfb_connect_backend(struct
if (ret)
goto error_xenbus;
ret = xenbus_printf(xbt, dev->nodename, "event-channel", "%u",
- info->evtchn);
+ irq_to_evtchn_port(info->irq));
if (ret)
goto error_xenbus;
ret = xenbus_printf(xbt, dev->nodename, "feature-update", "1");
diff -r 63fb88610e1e -r d275951acf10
linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c
--- a/linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c Sat Dec 30 15:45:13
2006 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c Sat Dec 30 18:23:27
2006 +0000
@@ -31,7 +31,6 @@ struct xenkbd_info
{
struct input_dev *dev;
struct xenkbd_page *page;
- unsigned evtchn;
int irq;
struct xenbus_device *xbdev;
};
@@ -76,7 +75,7 @@ static irqreturn_t input_handler(int rq,
input_sync(info->dev);
mb(); /* ensure we got ring contents */
page->in_cons = cons;
- notify_remote_via_evtchn(info->evtchn);
+ notify_remote_via_irq(info->irq);
return IRQ_HANDLED;
}
@@ -168,14 +167,11 @@ static int xenkbd_connect_backend(struct
int ret;
struct xenbus_transaction xbt;
- ret = xenbus_alloc_evtchn(dev, &info->evtchn);
- if (ret)
- return ret;
- ret = bind_evtchn_to_irqhandler(info->evtchn, input_handler, 0,
- "xenkbd", info);
+ ret = bind_listening_port_to_irqhandler(
+ dev->otherend_id, input_handler, 0, "xenkbd", info);
if (ret < 0) {
- xenbus_free_evtchn(dev, info->evtchn);
- xenbus_dev_fatal(dev, ret, "bind_evtchn_to_irqhandler");
+ xenbus_dev_fatal(dev, ret,
+ "bind_listening_port_to_irqhandler");
return ret;
}
info->irq = ret;
@@ -191,7 +187,7 @@ static int xenkbd_connect_backend(struct
if (ret)
goto error_xenbus;
ret = xenbus_printf(xbt, dev->nodename, "event-channel", "%u",
- info->evtchn);
+ irq_to_evtchn_port(info->irq));
if (ret)
goto error_xenbus;
ret = xenbus_transaction_end(xbt, 0);
diff -r 63fb88610e1e -r d275951acf10
linux-2.6-xen-sparse/drivers/xen/netback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/netback/common.h Sat Dec 30 15:45:13
2006 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/common.h Sat Dec 30 18:23:27
2006 +0000
@@ -67,7 +67,6 @@ typedef struct netif_st {
grant_ref_t tx_shmem_ref;
grant_handle_t rx_shmem_handle;
grant_ref_t rx_shmem_ref;
- unsigned int evtchn;
unsigned int irq;
/* The shared rings and indexes. */
diff -r 63fb88610e1e -r d275951acf10
linux-2.6-xen-sparse/drivers/xen/netback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c Sat Dec 30
15:45:13 2006 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c Sat Dec 30
18:23:27 2006 +0000
@@ -259,7 +259,6 @@ int netif_map(netif_t *netif, unsigned l
int err = -ENOMEM;
netif_tx_sring_t *txs;
netif_rx_sring_t *rxs;
- struct evtchn_bind_interdomain bind_interdomain;
/* Already connected through? */
if (netif->irq)
@@ -276,18 +275,12 @@ int netif_map(netif_t *netif, unsigned l
if (err)
goto err_map;
- bind_interdomain.remote_dom = netif->domid;
- bind_interdomain.remote_port = evtchn;
-
- err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
- &bind_interdomain);
- if (err)
+ err = bind_interdomain_evtchn_to_irqhandler(
+ netif->domid, evtchn, netif_be_int, 0,
+ netif->dev->name, netif);
+ if (err < 0)
goto err_hypervisor;
-
- netif->evtchn = bind_interdomain.local_port;
-
- netif->irq = bind_evtchn_to_irqhandler(
- netif->evtchn, netif_be_int, 0, netif->dev->name, netif);
+ netif->irq = err;
disable_irq(netif->irq);
txs = (netif_tx_sring_t *)netif->tx_comms_area->addr;
diff -r 63fb88610e1e -r d275951acf10
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Sat Dec 30
15:45:13 2006 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Sat Dec 30
18:23:27 2006 +0000
@@ -153,7 +153,7 @@ struct netfront_info {
spinlock_t tx_lock;
spinlock_t rx_lock;
- unsigned int evtchn, irq;
+ unsigned int irq;
unsigned int copying_receiver;
/* Receive-ring batched refills. */
@@ -408,7 +408,8 @@ again:
goto abort_transaction;
}
err = xenbus_printf(xbt, dev->nodename,
- "event-channel", "%u", info->evtchn);
+ "event-channel", "%u",
+ irq_to_evtchn_port(info->irq));
if (err) {
message = "writing event-channel";
goto abort_transaction;
@@ -513,17 +514,15 @@ static int setup_device(struct xenbus_de
}
info->rx_ring_ref = err;
- err = xenbus_alloc_evtchn(dev, &info->evtchn);
- if (err)
- goto fail;
-
memcpy(netdev->dev_addr, info->mac, ETH_ALEN);
- err = bind_evtchn_to_irqhandler(info->evtchn, netif_int,
- SA_SAMPLE_RANDOM, netdev->name,
- netdev);
+
+ err = bind_listening_port_to_irqhandler(
+ dev->otherend_id, netif_int, SA_SAMPLE_RANDOM, netdev->name,
+ netdev);
if (err < 0)
goto fail;
info->irq = err;
+
return 0;
fail:
@@ -2029,7 +2028,7 @@ static void netif_disconnect_backend(str
if (info->irq)
unbind_from_irqhandler(info->irq, info->netdev);
- info->evtchn = info->irq = 0;
+ info->irq = 0;
end_access(info->tx_ring_ref, info->tx.sring);
end_access(info->rx_ring_ref, info->rx.sring);
diff -r 63fb88610e1e -r d275951acf10
linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c Sat Dec 30 15:45:13
2006 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c Sat Dec 30 18:23:27
2006 +0000
@@ -71,7 +71,6 @@ static int pciback_do_attach(struct pcib
int remote_evtchn)
{
int err = 0;
- int evtchn;
struct vm_struct *area;
dev_dbg(&pdev->xdev->dev,
@@ -86,12 +85,9 @@ static int pciback_do_attach(struct pcib
pdev->sh_area = area;
pdev->sh_info = area->addr;
- err = xenbus_bind_evtchn(pdev->xdev, remote_evtchn, &evtchn);
- if (err)
- goto out;
-
- err = bind_evtchn_to_irqhandler(evtchn, pciback_handle_event,
- SA_SAMPLE_RANDOM, "pciback", pdev);
+ err = bind_interdomain_evtchn_to_irqhandler(
+ pdev->xdev->otherend_id, remote_evtchn, pciback_handle_event,
+ SA_SAMPLE_RANDOM, "pciback", pdev);
if (err < 0) {
xenbus_dev_fatal(pdev->xdev, err,
"Error binding event channel to IRQ");
diff -r 63fb88610e1e -r d275951acf10
linux-2.6-xen-sparse/drivers/xen/tpmback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/common.h Sat Dec 30 15:45:13
2006 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/common.h Sat Dec 30 18:23:27
2006 +0000
@@ -30,7 +30,6 @@ typedef struct tpmif_st {
unsigned int handle;
/* Physical parameters of the comms window. */
- unsigned int evtchn;
unsigned int irq;
/* The shared rings and indexes. */
diff -r 63fb88610e1e -r d275951acf10
linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c Sat Dec 30
15:45:13 2006 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c Sat Dec 30
18:23:27 2006 +0000
@@ -118,11 +118,9 @@ int tpmif_map(tpmif_t *tpmif, unsigned l
int tpmif_map(tpmif_t *tpmif, unsigned long shared_page, unsigned int evtchn)
{
int err;
- struct evtchn_bind_interdomain bind_interdomain;
- if (tpmif->irq) {
+ if (tpmif->irq)
return 0;
- }
if ((tpmif->tx_area = alloc_vm_area(PAGE_SIZE)) == NULL)
return -ENOMEM;
@@ -133,24 +131,17 @@ int tpmif_map(tpmif_t *tpmif, unsigned l
return err;
}
+ tpmif->tx = (tpmif_tx_interface_t *)tpmif->tx_area->addr;
- bind_interdomain.remote_dom = tpmif->domid;
- bind_interdomain.remote_port = evtchn;
-
- err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
- &bind_interdomain);
- if (err) {
+ err = bind_interdomain_evtchn_to_irqhandler(
+ tpmif->domid, evtchn, tpmif_be_int, 0, tpmif->devname, tpmif);
+ if (err < 0) {
unmap_frontend_page(tpmif);
free_vm_area(tpmif->tx_area);
return err;
}
+ tpmif->irq = err;
- tpmif->evtchn = bind_interdomain.local_port;
-
- tpmif->tx = (tpmif_tx_interface_t *)tpmif->tx_area->addr;
-
- tpmif->irq = bind_evtchn_to_irqhandler(
- tpmif->evtchn, tpmif_be_int, 0, tpmif->devname, tpmif);
tpmif->shmem_ref = shared_page;
tpmif->active = 1;
diff -r 63fb88610e1e -r d275951acf10
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c Sat Dec 30
15:45:13 2006 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c Sat Dec 30
18:23:27 2006 +0000
@@ -254,28 +254,6 @@ EXPORT_SYMBOL_GPL(xenbus_alloc_evtchn);
EXPORT_SYMBOL_GPL(xenbus_alloc_evtchn);
-int xenbus_bind_evtchn(struct xenbus_device *dev, int remote_port, int *port)
-{
- struct evtchn_bind_interdomain bind_interdomain;
- int err;
-
- bind_interdomain.remote_dom = dev->otherend_id;
- bind_interdomain.remote_port = remote_port,
-
- err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
- &bind_interdomain);
- if (err)
- xenbus_dev_fatal(dev, err,
- "binding to event channel %d from domain %d",
- remote_port, dev->otherend_id);
- else
- *port = bind_interdomain.local_port;
-
- return err;
-}
-EXPORT_SYMBOL_GPL(xenbus_bind_evtchn);
-
-
int xenbus_free_evtchn(struct xenbus_device *dev, int port)
{
struct evtchn_close close;
diff -r 63fb88610e1e -r d275951acf10
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c Sat Dec 30
15:45:13 2006 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c Sat Dec 30
18:23:27 2006 +0000
@@ -196,7 +196,7 @@ int xb_init_comms(void)
if (xenbus_irq)
unbind_from_irqhandler(xenbus_irq, &xb_waitq);
- err = bind_evtchn_to_irqhandler(
+ err = bind_caller_port_to_irqhandler(
xen_store_evtchn, wake_waiting,
0, "xenbus", &xb_waitq);
if (err <= 0) {
diff -r 63fb88610e1e -r d275951acf10 linux-2.6-xen-sparse/include/xen/evtchn.h
--- a/linux-2.6-xen-sparse/include/xen/evtchn.h Sat Dec 30 15:45:13 2006 +0000
+++ b/linux-2.6-xen-sparse/include/xen/evtchn.h Sat Dec 30 18:23:27 2006 +0000
@@ -52,22 +52,34 @@
* The IRQ argument passed to the callback handler is the same as returned
* from the bind call. It may not correspond to a Linux IRQ number.
* Returns IRQ or negative errno.
- * UNBIND: Takes IRQ to unbind from; automatically closes the event channel.
*/
-extern int bind_evtchn_to_irqhandler(
- unsigned int evtchn,
+int bind_caller_port_to_irqhandler(
+ unsigned int caller_port,
irqreturn_t (*handler)(int, void *, struct pt_regs *),
unsigned long irqflags,
const char *devname,
void *dev_id);
-extern int bind_virq_to_irqhandler(
+int bind_listening_port_to_irqhandler(
+ unsigned int remote_domain,
+ irqreturn_t (*handler)(int, void *, struct pt_regs *),
+ unsigned long irqflags,
+ const char *devname,
+ void *dev_id);
+int bind_interdomain_evtchn_to_irqhandler(
+ unsigned int remote_domain,
+ unsigned int remote_port,
+ irqreturn_t (*handler)(int, void *, struct pt_regs *),
+ unsigned long irqflags,
+ const char *devname,
+ void *dev_id);
+int bind_virq_to_irqhandler(
unsigned int virq,
unsigned int cpu,
irqreturn_t (*handler)(int, void *, struct pt_regs *),
unsigned long irqflags,
const char *devname,
void *dev_id);
-extern int bind_ipi_to_irqhandler(
+int bind_ipi_to_irqhandler(
unsigned int ipi,
unsigned int cpu,
irqreturn_t (*handler)(int, void *, struct pt_regs *),
@@ -77,21 +89,21 @@ extern int bind_ipi_to_irqhandler(
/*
* Common unbind function for all event sources. Takes IRQ to unbind from.
- * Automatically closes the underlying event channel (even for bindings
- * made with bind_evtchn_to_irqhandler()).
+ * Automatically closes the underlying event channel (except for bindings
+ * made with bind_caller_port_to_irqhandler()).
*/
-extern void unbind_from_irqhandler(unsigned int irq, void *dev_id);
+void unbind_from_irqhandler(unsigned int irq, void *dev_id);
-extern void irq_resume(void);
+void irq_resume(void);
/* Entry point for notifications into Linux subsystems. */
asmlinkage void evtchn_do_upcall(struct pt_regs *regs);
/* Entry point for notifications into the userland character device. */
-extern void evtchn_device_upcall(int port);
+void evtchn_device_upcall(int port);
-extern void mask_evtchn(int port);
-extern void unmask_evtchn(int port);
+void mask_evtchn(int port);
+void unmask_evtchn(int port);
static inline void clear_evtchn(int port)
{
@@ -106,9 +118,10 @@ static inline void notify_remote_via_evt
}
/*
- * Unlike notify_remote_via_evtchn(), this is safe to use across
- * save/restore. Notifications on a broken connection are silently dropped.
+ * Use these to access the event channel underlying the IRQ handle returned
+ * by bind_*_to_irqhandler().
*/
-extern void notify_remote_via_irq(int irq);
+void notify_remote_via_irq(int irq);
+int irq_to_evtchn_port(int irq);
#endif /* __ASM_EVTCHN_H__ */
diff -r 63fb88610e1e -r d275951acf10 linux-2.6-xen-sparse/include/xen/xenbus.h
--- a/linux-2.6-xen-sparse/include/xen/xenbus.h Sat Dec 30 15:45:13 2006 +0000
+++ b/linux-2.6-xen-sparse/include/xen/xenbus.h Sat Dec 30 18:23:27 2006 +0000
@@ -262,14 +262,6 @@ int xenbus_alloc_evtchn(struct xenbus_de
/**
- * Bind to an existing interdomain event channel in another domain. Returns 0
- * on success and stores the local port in *port. On error, returns -errno,
- * switches the device to XenbusStateClosing, and saves the error in XenStore.
- */
-int xenbus_bind_evtchn(struct xenbus_device *dev, int remote_port, int *port);
-
-
-/**
* Free an existing event channel. Returns 0 on success or -errno on error.
*/
int xenbus_free_evtchn(struct xenbus_device *dev, int port);
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|