WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [linux-2.6.18-xen] xen/backends: use xenbus_be.ko interf

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [linux-2.6.18-xen] xen/backends: use xenbus_be.ko interfaces instead of open-coding them
From: Xen patchbot-linux-2.6.18-xen <patchbot@xxxxxxx>
Date: Tue, 05 Apr 2011 12:50:05 +0100
Delivery-date: Tue, 05 Apr 2011 04:51:05 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Jan Beulich <jbeulich@xxxxxxxxxx>
# Date 1302003500 -3600
# Node ID 13937900bbd01cd62592d3535ea4943c22ba2b92
# Parent  0bee20f8e418d32ab5828eb57c7542ca27ce425d
xen/backends: use xenbus_be.ko interfaces instead of open-coding them

Also remove unused xenbus_{,un}map_ring(), adjust types, and clean up
header inclusion.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
---


diff -r 0bee20f8e418 -r 13937900bbd0 drivers/xen/blkback/blkback.c
--- a/drivers/xen/blkback/blkback.c     Sat Apr 02 15:54:29 2011 +0100
+++ b/drivers/xen/blkback/blkback.c     Tue Apr 05 12:38:20 2011 +0100
@@ -40,6 +40,8 @@
 #include <linux/list.h>
 #include <linux/delay.h>
 #include <xen/balloon.h>
+#include <xen/evtchn.h>
+#include <xen/gnttab.h>
 #include <asm/hypervisor.h>
 #include "common.h"
 
diff -r 0bee20f8e418 -r 13937900bbd0 drivers/xen/blkback/common.h
--- a/drivers/xen/blkback/common.h      Sat Apr 02 15:54:29 2011 +0100
+++ b/drivers/xen/blkback/common.h      Tue Apr 05 12:38:20 2011 +0100
@@ -32,17 +32,12 @@
 #include <linux/interrupt.h>
 #include <linux/slab.h>
 #include <linux/blkdev.h>
-#include <linux/vmalloc.h>
 #include <linux/wait.h>
-#include <asm/io.h>
-#include <asm/setup.h>
-#include <asm/pgalloc.h>
-#include <xen/evtchn.h>
 #include <asm/hypervisor.h>
 #include <xen/blkif.h>
-#include <xen/gnttab.h>
 #include <xen/driver_util.h>
 #include <xen/xenbus.h>
+#include <xen/interface/event_channel.h>
 #include "blkback-pagemap.h"
 
 
@@ -94,9 +89,6 @@
        int                 st_wr_sect;
 
        wait_queue_head_t waiting_to_free;
-
-       grant_handle_t shmem_handle;
-       grant_ref_t    shmem_ref;
 } blkif_t;
 
 struct backend_info
@@ -112,7 +104,7 @@
 blkif_t *blkif_alloc(domid_t domid);
 void blkif_disconnect(blkif_t *blkif);
 void blkif_free(blkif_t *blkif);
-int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int evtchn);
+int blkif_map(blkif_t *blkif, grant_ref_t, evtchn_port_t);
 void vbd_resize(blkif_t *blkif);
 
 #define blkif_get(_b) (atomic_inc(&(_b)->refcnt))
diff -r 0bee20f8e418 -r 13937900bbd0 drivers/xen/blkback/interface.c
--- a/drivers/xen/blkback/interface.c   Sat Apr 02 15:54:29 2011 +0100
+++ b/drivers/xen/blkback/interface.c   Tue Apr 05 12:38:20 2011 +0100
@@ -33,7 +33,7 @@
 #include "common.h"
 #include <xen/evtchn.h>
 #include <linux/kthread.h>
-#include <linux/delay.h>
+#include <linux/vmalloc.h>
 
 static kmem_cache_t *blkif_cachep;
 
@@ -56,75 +56,39 @@
        return blkif;
 }
 
-static int map_frontend_page(blkif_t *blkif, unsigned long shared_page)
+int blkif_map(blkif_t *blkif, grant_ref_t ring_ref, evtchn_port_t evtchn)
 {
-       struct gnttab_map_grant_ref op;
-       int ret;
-
-       gnttab_set_map_op(&op, (unsigned long)blkif->blk_ring_area->addr,
-                         GNTMAP_host_map, shared_page, blkif->domid);
-
-       gnttab_check_GNTST_eagain_do_while(GNTTABOP_map_grant_ref, &op);
-
-       if (op.status == GNTST_okay) {
-               blkif->shmem_ref = shared_page;
-               blkif->shmem_handle = op.handle;
-               ret = 0;
-       } else {
-               DPRINTK(" Grant table operation failure %d!\n", (int)op.status);
-               ret = -EINVAL;
-       }
-
-       return ret;
-}
-
-static void unmap_frontend_page(blkif_t *blkif)
-{
-       struct gnttab_unmap_grant_ref op;
-
-       gnttab_set_unmap_op(&op, (unsigned long)blkif->blk_ring_area->addr,
-                           GNTMAP_host_map, blkif->shmem_handle);
-
-       if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
-               BUG();
-}
-
-int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int evtchn)
-{
+       struct vm_struct *area;
        int err;
 
        /* Already connected through? */
        if (blkif->irq)
                return 0;
 
-       if ( (blkif->blk_ring_area = alloc_vm_area(PAGE_SIZE)) == NULL )
-               return -ENOMEM;
-
-       err = map_frontend_page(blkif, shared_page);
-       if (err) {
-               free_vm_area(blkif->blk_ring_area);
-               return err;
-       }
+       area = xenbus_map_ring_valloc(blkif->be->dev, ring_ref);
+       if (IS_ERR(area))
+               return PTR_ERR(area);
+       blkif->blk_ring_area = area;
 
        switch (blkif->blk_protocol) {
        case BLKIF_PROTOCOL_NATIVE:
        {
                blkif_sring_t *sring;
-               sring = (blkif_sring_t *)blkif->blk_ring_area->addr;
+               sring = (blkif_sring_t *)area->addr;
                BACK_RING_INIT(&blkif->blk_rings.native, sring, PAGE_SIZE);
                break;
        }
        case BLKIF_PROTOCOL_X86_32:
        {
                blkif_x86_32_sring_t *sring_x86_32;
-               sring_x86_32 = (blkif_x86_32_sring_t 
*)blkif->blk_ring_area->addr;
+               sring_x86_32 = (blkif_x86_32_sring_t *)area->addr;
                BACK_RING_INIT(&blkif->blk_rings.x86_32, sring_x86_32, 
PAGE_SIZE);
                break;
        }
        case BLKIF_PROTOCOL_X86_64:
        {
                blkif_x86_64_sring_t *sring_x86_64;
-               sring_x86_64 = (blkif_x86_64_sring_t 
*)blkif->blk_ring_area->addr;
+               sring_x86_64 = (blkif_x86_64_sring_t *)area->addr;
                BACK_RING_INIT(&blkif->blk_rings.x86_64, sring_x86_64, 
PAGE_SIZE);
                break;
        }
@@ -136,8 +100,7 @@
                blkif->domid, evtchn, blkif_be_int, 0, "blkif-backend", blkif);
        if (err < 0)
        {
-               unmap_frontend_page(blkif);
-               free_vm_area(blkif->blk_ring_area);
+               xenbus_unmap_ring_vfree(blkif->be->dev, area);
                blkif->blk_rings.common.sring = NULL;
                return err;
        }
@@ -163,8 +126,7 @@
        }
 
        if (blkif->blk_rings.common.sring) {
-               unmap_frontend_page(blkif);
-               free_vm_area(blkif->blk_ring_area);
+               xenbus_unmap_ring_vfree(blkif->be->dev, blkif->blk_ring_area);
                blkif->blk_rings.common.sring = NULL;
        }
 }
diff -r 0bee20f8e418 -r 13937900bbd0 drivers/xen/blktap/blktap.c
--- a/drivers/xen/blktap/blktap.c       Sat Apr 02 15:54:29 2011 +0100
+++ b/drivers/xen/blktap/blktap.c       Tue Apr 05 12:38:20 2011 +0100
@@ -45,6 +45,8 @@
 #include "common.h"
 #include <xen/balloon.h>
 #include <xen/driver_util.h>
+#include <xen/evtchn.h>
+#include <xen/gnttab.h>
 #include <linux/kernel.h>
 #include <linux/fs.h>
 #include <linux/mm.h>
diff -r 0bee20f8e418 -r 13937900bbd0 drivers/xen/blktap/common.h
--- a/drivers/xen/blktap/common.h       Sat Apr 02 15:54:29 2011 +0100
+++ b/drivers/xen/blktap/common.h       Tue Apr 05 12:38:20 2011 +0100
@@ -32,15 +32,11 @@
 #include <linux/interrupt.h>
 #include <linux/slab.h>
 #include <linux/blkdev.h>
-#include <linux/vmalloc.h>
-#include <asm/io.h>
-#include <asm/setup.h>
-#include <asm/pgalloc.h>
-#include <xen/evtchn.h>
 #include <asm/hypervisor.h>
 #include <xen/blkif.h>
-#include <xen/gnttab.h>
 #include <xen/driver_util.h>
+#include <xen/xenbus.h>
+#include <xen/interface/event_channel.h>
 
 #define DPRINTK(_f, _a...) pr_debug("(file=%s, line=%d) " _f, \
                                     __FILE__ , __LINE__ , ## _a )
@@ -80,19 +76,15 @@
 
        wait_queue_head_t waiting_to_free;
 
-       grant_handle_t shmem_handle;
-       grant_ref_t    shmem_ref;
-       
        int             dev_num;
        uint64_t        sectors;
 } blkif_t;
 
 blkif_t *tap_alloc_blkif(domid_t domid);
-void tap_blkif_free(blkif_t *blkif);
+void tap_blkif_free(blkif_t *, struct xenbus_device *);
 void tap_blkif_kmem_cache_free(blkif_t *blkif);
-int tap_blkif_map(blkif_t *blkif, unsigned long shared_page, 
-                 unsigned int evtchn);
-void tap_blkif_unmap(blkif_t *blkif);
+int tap_blkif_map(blkif_t *, struct xenbus_device *, grant_ref_t,
+                 evtchn_port_t);
 
 #define blkif_get(_b) (atomic_inc(&(_b)->refcnt))
 #define blkif_put(_b)                                  \
diff -r 0bee20f8e418 -r 13937900bbd0 drivers/xen/blktap/interface.c
--- a/drivers/xen/blktap/interface.c    Sat Apr 02 15:54:29 2011 +0100
+++ b/drivers/xen/blktap/interface.c    Tue Apr 05 12:38:20 2011 +0100
@@ -33,7 +33,7 @@
 
 #include "common.h"
 #include <xen/evtchn.h>
-#include <linux/delay.h>
+#include <linux/vmalloc.h>
 
 static kmem_cache_t *blkif_cachep;
 
@@ -56,76 +56,40 @@
        return blkif;
 }
 
-static int map_frontend_page(blkif_t *blkif, unsigned long shared_page)
+int tap_blkif_map(blkif_t *blkif, struct xenbus_device *dev,
+                 grant_ref_t ring_ref, evtchn_port_t evtchn)
 {
-       struct gnttab_map_grant_ref op;
-       int ret;
-
-       gnttab_set_map_op(&op, (unsigned long)blkif->blk_ring_area->addr,
-                         GNTMAP_host_map, shared_page, blkif->domid);
-
-       gnttab_check_GNTST_eagain_do_while(GNTTABOP_map_grant_ref, &op);
-
-       if (op.status == GNTST_okay) {
-               blkif->shmem_ref = shared_page;
-               blkif->shmem_handle = op.handle;
-               ret = 0;
-       } else {
-               DPRINTK("Grant table operation failure %d!\n", (int)op.status);
-               ret = -EINVAL;
-       }
-
-       return ret;
-}
-
-static void unmap_frontend_page(blkif_t *blkif)
-{
-       struct gnttab_unmap_grant_ref op;
-
-       gnttab_set_unmap_op(&op, (unsigned long)blkif->blk_ring_area->addr,
-                           GNTMAP_host_map, blkif->shmem_handle);
-
-       if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
-               BUG();
-}
-
-int tap_blkif_map(blkif_t *blkif, unsigned long shared_page, 
-                 unsigned int evtchn)
-{
+       struct vm_struct *area;
        int err;
 
        /* Already connected through? */
        if (blkif->irq)
                return 0;
 
-       if ( (blkif->blk_ring_area = alloc_vm_area(PAGE_SIZE)) == NULL )
-               return -ENOMEM;
-
-       err = map_frontend_page(blkif, shared_page);
-       if (err) {
-               free_vm_area(blkif->blk_ring_area);
-               return err;
-       }
+       area = xenbus_map_ring_valloc(dev, ring_ref);
+       if (IS_ERR(area))
+               return PTR_ERR(area);
+       blkif->blk_ring_area = area;
 
        switch (blkif->blk_protocol) {
        case BLKIF_PROTOCOL_NATIVE:
        {
                blkif_sring_t *sring;
-               sring = (blkif_sring_t *)blkif->blk_ring_area->addr;
+               sring = (blkif_sring_t *)area->addr;
                BACK_RING_INIT(&blkif->blk_rings.native, sring, PAGE_SIZE);
                break;
        }
        case BLKIF_PROTOCOL_X86_32:
        {
                blkif_x86_32_sring_t *sring_x86_32;
-               sring_x86_32 = (blkif_x86_32_sring_t 
*)blkif->blk_ring_area->addr;
+               sring_x86_32 = (blkif_x86_32_sring_t *)area->addr;
                BACK_RING_INIT(&blkif->blk_rings.x86_32, sring_x86_32, 
PAGE_SIZE);
                break;
        }
        case BLKIF_PROTOCOL_X86_64:
        {
                blkif_x86_64_sring_t *sring_x86_64;
-               sring_x86_64 = (blkif_x86_64_sring_t 
*)blkif->blk_ring_area->addr;
+               sring_x86_64 = (blkif_x86_64_sring_t *)area->addr;
                BACK_RING_INIT(&blkif->blk_rings.x86_64, sring_x86_64, 
PAGE_SIZE);
                break;
        }
@@ -137,8 +101,7 @@
                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);
+               xenbus_unmap_ring_vfree(dev, area);
                blkif->blk_rings.common.sring = NULL;
                return err;
        }
@@ -147,26 +110,21 @@
        return 0;
 }
 
-void tap_blkif_unmap(blkif_t *blkif)
-{
-       if (blkif->irq) {
-               unbind_from_irqhandler(blkif->irq, blkif);
-               blkif->irq = 0;
-       }
-       if (blkif->blk_rings.common.sring) {
-               unmap_frontend_page(blkif);
-               free_vm_area(blkif->blk_ring_area);
-               blkif->blk_rings.common.sring = NULL;
-       }
-}
-
-void tap_blkif_free(blkif_t *blkif)
+void tap_blkif_free(blkif_t *blkif, struct xenbus_device *dev)
 {
        atomic_dec(&blkif->refcnt);
        wait_event(blkif->waiting_to_free, atomic_read(&blkif->refcnt) == 0);
        atomic_inc(&blkif->refcnt);
 
-       tap_blkif_unmap(blkif);
+       if (blkif->irq) {
+               unbind_from_irqhandler(blkif->irq, blkif);
+               blkif->irq = 0;
+       }
+
+       if (blkif->blk_rings.common.sring) {
+               xenbus_unmap_ring_vfree(dev, blkif->blk_ring_area);
+               blkif->blk_rings.common.sring = NULL;
+       }
 }
 
 void tap_blkif_kmem_cache_free(blkif_t *blkif)
diff -r 0bee20f8e418 -r 13937900bbd0 drivers/xen/blktap/xenbus.c
--- a/drivers/xen/blktap/xenbus.c       Sat Apr 02 15:54:29 2011 +0100
+++ b/drivers/xen/blktap/xenbus.c       Tue Apr 05 12:38:20 2011 +0100
@@ -192,7 +192,7 @@
                if (be->blkif->xenblkd)
                        kthread_stop(be->blkif->xenblkd);
                signal_tapdisk(be->blkif->dev_num);
-               tap_blkif_free(be->blkif);
+               tap_blkif_free(be->blkif, dev);
                tap_blkif_kmem_cache_free(be->blkif);
                be->blkif = NULL;
        }
@@ -348,7 +348,7 @@
        }
 
        /* idempotent */
-       tap_blkif_free(blkif);
+       tap_blkif_free(blkif, blkif->be->dev);
 }
 
 /**
@@ -472,7 +472,7 @@
               ring_ref, evtchn, be->blkif->blk_protocol, protocol);
 
        /* Map the shared frame, irq etc. */
-       err = tap_blkif_map(be->blkif, ring_ref, evtchn);
+       err = tap_blkif_map(be->blkif, dev, ring_ref, evtchn);
        if (err) {
                xenbus_dev_fatal(dev, err, "mapping ring-ref %lu port %u",
                                 ring_ref, evtchn);
diff -r 0bee20f8e418 -r 13937900bbd0 drivers/xen/netback/common.h
--- a/drivers/xen/netback/common.h      Sat Apr 02 15:54:29 2011 +0100
+++ b/drivers/xen/netback/common.h      Tue Apr 05 12:38:20 2011 +0100
@@ -38,14 +38,10 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/wait.h>
-#include <xen/evtchn.h>
 #include <xen/interface/io/netif.h>
-#include <asm/io.h>
-#include <asm/pgalloc.h>
-#include <xen/interface/grant_table.h>
-#include <xen/gnttab.h>
 #include <xen/driver_util.h>
 #include <xen/xenbus.h>
+#include <xen/interface/event_channel.h>
 
 #define DPRINTK(_f, _a...)                     \
        pr_debug("(file=%s, line=%d) " _f,      \
@@ -62,11 +58,6 @@
 
        u8               fe_dev_addr[6];
 
-       /* Physical parameters of the comms window. */
-       grant_handle_t   tx_shmem_handle;
-       grant_ref_t      tx_shmem_ref;
-       grant_handle_t   rx_shmem_handle;
-       grant_ref_t      rx_shmem_ref;
        unsigned int     irq;
 
        /* The shared rings and indexes. */
@@ -185,12 +176,12 @@
 #define NET_TX_RING_SIZE __CONST_RING_SIZE(netif_tx, PAGE_SIZE)
 #define NET_RX_RING_SIZE __CONST_RING_SIZE(netif_rx, PAGE_SIZE)
 
-void netif_disconnect(netif_t *netif);
+void netif_disconnect(struct backend_info *be);
 
 void netif_set_features(netif_t *netif);
 netif_t *netif_alloc(struct device *parent, domid_t domid, unsigned int 
handle);
-int netif_map(netif_t *netif, unsigned long tx_ring_ref,
-             unsigned long rx_ring_ref, unsigned int evtchn);
+int netif_map(struct backend_info *be, grant_ref_t tx_ring_ref,
+             grant_ref_t rx_ring_ref, evtchn_port_t evtchn);
 
 #define netif_get(_b) (atomic_inc(&(_b)->refcnt))
 #define netif_put(_b)                                          \
diff -r 0bee20f8e418 -r 13937900bbd0 drivers/xen/netback/interface.c
--- a/drivers/xen/netback/interface.c   Sat Apr 02 15:54:29 2011 +0100
+++ b/drivers/xen/netback/interface.c   Tue Apr 05 12:38:20 2011 +0100
@@ -34,6 +34,8 @@
 #include <linux/ethtool.h>
 #include <linux/rtnetlink.h>
 #include <linux/delay.h>
+#include <linux/vmalloc.h>
+#include <xen/evtchn.h>
 
 /*
  * Module parameter 'queue_length':
@@ -288,65 +290,11 @@
        return netif;
 }
 
-static int map_frontend_pages(
-       netif_t *netif, grant_ref_t tx_ring_ref, grant_ref_t rx_ring_ref)
+int netif_map(struct backend_info *be, grant_ref_t tx_ring_ref,
+             grant_ref_t rx_ring_ref, evtchn_port_t evtchn)
 {
-       struct gnttab_map_grant_ref op;
-
-       gnttab_set_map_op(&op, (unsigned long)netif->tx_comms_area->addr,
-                         GNTMAP_host_map, tx_ring_ref, netif->domid);
-       gnttab_check_GNTST_eagain_do_while(GNTTABOP_map_grant_ref, &op);
-
-       if (op.status != GNTST_okay) {
-               DPRINTK(" Gnttab failure mapping tx_ring_ref %d!\n", 
(int)op.status);
-               return -EINVAL;
-       }
-
-       netif->tx_shmem_ref    = tx_ring_ref;
-       netif->tx_shmem_handle = op.handle;
-
-       gnttab_set_map_op(&op, (unsigned long)netif->rx_comms_area->addr,
-                         GNTMAP_host_map, rx_ring_ref, netif->domid);
-       gnttab_check_GNTST_eagain_do_while(GNTTABOP_map_grant_ref, &op);
-
-       if (op.status != GNTST_okay) {
-               struct gnttab_unmap_grant_ref unop;
-
-               gnttab_set_unmap_op(&unop,
-                                   (unsigned long)netif->tx_comms_area->addr,
-                                   GNTMAP_host_map, netif->tx_shmem_handle);
-               VOID(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref,
-                                              &unop, 1));
-               DPRINTK(" Gnttab failure mapping rx_ring_ref %d!\n", 
(int)op.status);
-               return -EINVAL;
-       }
-
-       netif->rx_shmem_ref    = rx_ring_ref;
-       netif->rx_shmem_handle = op.handle;
-
-       return 0;
-}
-
-static void unmap_frontend_pages(netif_t *netif)
-{
-       struct gnttab_unmap_grant_ref op;
-
-       gnttab_set_unmap_op(&op, (unsigned long)netif->tx_comms_area->addr,
-                           GNTMAP_host_map, netif->tx_shmem_handle);
-
-       if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
-               BUG();
-
-       gnttab_set_unmap_op(&op, (unsigned long)netif->rx_comms_area->addr,
-                           GNTMAP_host_map, netif->rx_shmem_handle);
-
-       if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
-               BUG();
-}
-
-int netif_map(netif_t *netif, unsigned long tx_ring_ref,
-             unsigned long rx_ring_ref, unsigned int evtchn)
-{
+       netif_t *netif = be->netif;
+       struct vm_struct *area;
        int err = -ENOMEM;
        netif_tx_sring_t *txs;
        netif_rx_sring_t *rxs;
@@ -355,16 +303,16 @@
        if (netif->irq)
                return 0;
 
-       netif->tx_comms_area = alloc_vm_area(PAGE_SIZE);
-       if (netif->tx_comms_area == NULL)
-               return -ENOMEM;
-       netif->rx_comms_area = alloc_vm_area(PAGE_SIZE);
-       if (netif->rx_comms_area == NULL)
+       area = xenbus_map_ring_valloc(be->dev, tx_ring_ref);
+       if (IS_ERR(area))
+               return PTR_ERR(area);
+       netif->tx_comms_area = area;
+       area = xenbus_map_ring_valloc(be->dev, rx_ring_ref);
+       if (IS_ERR(area)) {
+               err = PTR_ERR(area);
                goto err_rx;
-
-       err = map_frontend_pages(netif, tx_ring_ref, rx_ring_ref);
-       if (err)
-               goto err_map;
+       }
+       netif->rx_comms_area = area;
 
        err = bind_interdomain_evtchn_to_irqhandler(
                netif->domid, evtchn, netif_be_int, 0,
@@ -393,16 +341,16 @@
 
        return 0;
 err_hypervisor:
-       unmap_frontend_pages(netif);
-err_map:
-       free_vm_area(netif->rx_comms_area);
+       xenbus_unmap_ring_vfree(be->dev, netif->rx_comms_area);
 err_rx:
-       free_vm_area(netif->tx_comms_area);
+       xenbus_unmap_ring_vfree(be->dev, netif->tx_comms_area);
        return err;
 }
 
-void netif_disconnect(netif_t *netif)
+void netif_disconnect(struct backend_info *be)
 {
+       netif_t *netif = be->netif;
+
        if (netback_carrier_ok(netif)) {
                rtnl_lock();
                netback_carrier_off(netif);
@@ -425,9 +373,8 @@
        unregister_netdev(netif->dev);
 
        if (netif->tx.sring) {
-               unmap_frontend_pages(netif);
-               free_vm_area(netif->tx_comms_area);
-               free_vm_area(netif->rx_comms_area);
+               xenbus_unmap_ring_vfree(be->dev, netif->tx_comms_area);
+               xenbus_unmap_ring_vfree(be->dev, netif->rx_comms_area);
        }
 
        free_netdev(netif->dev);
diff -r 0bee20f8e418 -r 13937900bbd0 drivers/xen/netback/netback.c
--- a/drivers/xen/netback/netback.c     Sat Apr 02 15:54:29 2011 +0100
+++ b/drivers/xen/netback/netback.c     Tue Apr 05 12:38:20 2011 +0100
@@ -38,6 +38,8 @@
 #include <linux/if_vlan.h>
 #include <linux/tcp.h>
 #include <xen/balloon.h>
+#include <xen/evtchn.h>
+#include <xen/gnttab.h>
 #include <xen/interface/memory.h>
 
 /*define NETBE_DEBUG_INTERRUPT*/
diff -r 0bee20f8e418 -r 13937900bbd0 drivers/xen/netback/xenbus.c
--- a/drivers/xen/netback/xenbus.c      Sat Apr 02 15:54:29 2011 +0100
+++ b/drivers/xen/netback/xenbus.c      Tue Apr 05 12:38:20 2011 +0100
@@ -52,7 +52,7 @@
 
        if (be->netif) {
                kobject_uevent(&xbdev_dev->kobj, KOBJ_OFFLINE);
-               netif_disconnect(be->netif);
+               netif_disconnect(be);
                be->netif = NULL;
        }
 }
@@ -418,7 +418,7 @@
        netif_set_features(netif);
 
        /* Map the shared frame, irq etc. */
-       err = netif_map(netif, tx_ring_ref, rx_ring_ref, evtchn);
+       err = netif_map(be, tx_ring_ref, rx_ring_ref, evtchn);
        if (err) {
                xenbus_dev_fatal(dev, err,
                                 "mapping shared-frames %lu/%lu port %u",
diff -r 0bee20f8e418 -r 13937900bbd0 drivers/xen/scsiback/common.h
--- a/drivers/xen/scsiback/common.h     Sat Apr 02 15:54:29 2011 +0100
+++ b/drivers/xen/scsiback/common.h     Tue Apr 05 12:38:20 2011 +0100
@@ -48,17 +48,10 @@
 #include <scsi/scsi_device.h>
 #include <scsi/scsi_dbg.h>
 #include <scsi/scsi_eh.h>
-#include <asm/io.h>
-#include <asm/setup.h>
-#include <asm/pgalloc.h>
-#include <asm/delay.h>
-#include <xen/evtchn.h>
 #include <asm/hypervisor.h>
-#include <xen/gnttab.h>
 #include <xen/driver_util.h>
 #include <xen/xenbus.h>
 #include <xen/interface/io/ring.h>
-#include <xen/interface/grant_table.h>
 #include <xen/interface/io/vscsiif.h>
 
 
@@ -90,8 +83,6 @@
 
        struct vscsiif_back_ring  ring;
        struct vm_struct *ring_area;
-       grant_handle_t shmem_handle;
-       grant_ref_t shmem_ref;
 
        spinlock_t ring_lock;
        atomic_t nr_unreplied_reqs;
@@ -148,14 +139,13 @@
 #define VSCSI_TYPE_HOST                1
 
 irqreturn_t scsiback_intr(int, void *, struct pt_regs *);
-int scsiback_init_sring(struct vscsibk_info *info,
-               unsigned long ring_ref, unsigned int evtchn);
+int scsiback_init_sring(struct vscsibk_info *, grant_ref_t, evtchn_port_t);
 int scsiback_schedule(void *data);
 
 
 struct vscsibk_info *vscsibk_info_alloc(domid_t domid);
 void scsiback_free(struct vscsibk_info *info);
-void scsiback_disconnect(struct vscsibk_info *info);
+void scsiback_disconnect(struct vscsibk_info *);
 int __init scsiback_interface_init(void);
 void scsiback_interface_exit(void);
 int scsiback_xenbus_init(void);
diff -r 0bee20f8e418 -r 13937900bbd0 drivers/xen/scsiback/interface.c
--- a/drivers/xen/scsiback/interface.c  Sat Apr 02 15:54:29 2011 +0100
+++ b/drivers/xen/scsiback/interface.c  Tue Apr 05 12:38:20 2011 +0100
@@ -38,6 +38,7 @@
 #include <xen/evtchn.h>
 #include <linux/kthread.h>
 #include <linux/delay.h>
+#include <linux/vmalloc.h>
 
 
 static kmem_cache_t *scsiback_cachep;
@@ -60,45 +61,10 @@
        return info;
 }
 
-static int map_frontend_page( struct vscsibk_info *info,
-                               unsigned long ring_ref)
+int scsiback_init_sring(struct vscsibk_info *info, grant_ref_t ring_ref,
+                       evtchn_port_t evtchn)
 {
-       struct gnttab_map_grant_ref op;
-       int ret;
-
-       gnttab_set_map_op(&op, (unsigned long)info->ring_area->addr,
-                               GNTMAP_host_map, ring_ref,
-                               info->domid);
-       gnttab_check_GNTST_eagain_do_while(GNTTABOP_map_grant_ref, &op);
-
-       if (op.status != GNTST_okay) {
-               printk(KERN_ERR "scsiback: Grant table operation failure 
%d!\n", (int)op.status);
-               ret = -EINVAL;
-       } else {
-               info->shmem_ref    = ring_ref;
-               info->shmem_handle = op.handle;
-               ret = 0;
-       }
-
-       return ret;
-}
-
-static void unmap_frontend_page(struct vscsibk_info *info)
-{
-       struct gnttab_unmap_grant_ref op;
-       int err;
-
-       gnttab_set_unmap_op(&op, (unsigned long)info->ring_area->addr,
-                               GNTMAP_host_map, info->shmem_handle);
-
-       err = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
-       BUG_ON(err);
-
-}
-
-int scsiback_init_sring(struct vscsibk_info *info,
-               unsigned long ring_ref, unsigned int evtchn)
-{
+       struct vm_struct *area;
        struct vscsiif_sring *sring;
        int err;
 
@@ -107,15 +73,12 @@
                return -1;
        }
 
-       info->ring_area = alloc_vm_area(PAGE_SIZE);
-       if (!info)
-               return -ENOMEM;
+       area = xenbus_map_ring_valloc(info->dev, ring_ref);
+       if (IS_ERR(area))
+               return PTR_ERR(area);
+       info->ring_area = area;
 
-       err = map_frontend_page(info, ring_ref);
-       if (err)
-               goto free_vm;
-
-       sring = (struct vscsiif_sring *) info->ring_area->addr;
+       sring = (struct vscsiif_sring *)area->addr;
        BACK_RING_INIT(&info->ring, sring, PAGE_SIZE);
 
        err = bind_interdomain_evtchn_to_irqhandler(
@@ -130,9 +93,7 @@
        return 0;
 
 unmap_page:
-       unmap_frontend_page(info);
-free_vm:
-       free_vm_area(info->ring_area);
+       xenbus_unmap_ring_vfree(info->dev, area);
 
        return err;
 }
@@ -153,8 +114,7 @@
        }
 
        if (info->ring.sring) {
-               unmap_frontend_page(info);
-               free_vm_area(info->ring_area);
+               xenbus_unmap_ring_vfree(info->dev, info->ring_area);
                info->ring.sring = NULL;
        }
 }
diff -r 0bee20f8e418 -r 13937900bbd0 drivers/xen/scsiback/scsiback.c
--- a/drivers/xen/scsiback/scsiback.c   Sat Apr 02 15:54:29 2011 +0100
+++ b/drivers/xen/scsiback/scsiback.c   Tue Apr 05 12:38:20 2011 +0100
@@ -35,6 +35,8 @@
 #include <linux/list.h>
 #include <linux/delay.h>
 #include <xen/balloon.h>
+#include <xen/evtchn.h>
+#include <xen/gnttab.h>
 #include <asm/hypervisor.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
diff -r 0bee20f8e418 -r 13937900bbd0 drivers/xen/tpmback/common.h
--- a/drivers/xen/tpmback/common.h      Sat Apr 02 15:54:29 2011 +0100
+++ b/drivers/xen/tpmback/common.h      Tue Apr 05 12:38:20 2011 +0100
@@ -8,19 +8,31 @@
 #include <linux/version.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
+#include <linux/mm.h>
 #include <linux/slab.h>
-#include <xen/evtchn.h>
 #include <xen/driver_util.h>
-#include <xen/interface/grant_table.h>
+#include <xen/xenbus.h>
+#include <xen/interface/event_channel.h>
 #include <xen/interface/io/tpmif.h>
-#include <asm/io.h>
-#include <asm/pgalloc.h>
 
 #define DPRINTK(_f, _a...)                     \
        pr_debug("(file=%s, line=%d) " _f,      \
                 __FILE__ , __LINE__ , ## _a )
 
-struct backend_info;
+struct backend_info
+{
+       struct xenbus_device *dev;
+
+       /* our communications channel */
+       struct tpmif_st *tpmif;
+
+       long int frontend_id;
+       long int instance; // instance of TPM
+       u8 is_instance_set;// whether instance number has been set
+
+       /* watch front end for changes */
+       struct xenbus_watch backend_watch;
+};
 
 typedef struct tpmif_st {
        struct list_head tpmif_list;
@@ -45,8 +57,6 @@
 
        struct backend_info *bi;
 
-       grant_handle_t shmem_handle;
-       grant_ref_t shmem_ref;
        struct page **mmap_pages;
 
        char devname[20];
@@ -60,7 +70,7 @@
 void tpmif_deschedule_work(tpmif_t * tpmif);
 void tpmif_xenbus_init(void);
 void tpmif_xenbus_exit(void);
-int tpmif_map(tpmif_t *tpmif, unsigned long shared_page, unsigned int evtchn);
+int tpmif_map(tpmif_t *, grant_ref_t, evtchn_port_t);
 irqreturn_t tpmif_be_int(int irq, void *dev_id, struct pt_regs *regs);
 
 long int tpmback_get_instance(struct backend_info *bi);
diff -r 0bee20f8e418 -r 13937900bbd0 drivers/xen/tpmback/interface.c
--- a/drivers/xen/tpmback/interface.c   Sat Apr 02 15:54:29 2011 +0100
+++ b/drivers/xen/tpmback/interface.c   Tue Apr 05 12:38:20 2011 +0100
@@ -13,7 +13,9 @@
 
 #include "common.h"
 #include <linux/delay.h>
+#include <linux/vmalloc.h>
 #include <xen/balloon.h>
+#include <xen/evtchn.h>
 #include <xen/gnttab.h>
 
 static kmem_cache_t *tpmif_cachep;
@@ -78,68 +80,30 @@
        return alloc_tpmif(domid, bi);
 }
 
-static int map_frontend_page(tpmif_t *tpmif, unsigned long shared_page)
+int tpmif_map(tpmif_t *tpmif, grant_ref_t ring_ref, evtchn_port_t evtchn)
 {
-       struct gnttab_map_grant_ref op;
-       int ret;
-
-       gnttab_set_map_op(&op, (unsigned long)tpmif->tx_area->addr,
-                         GNTMAP_host_map, shared_page, tpmif->domid);
-
-       gnttab_check_GNTST_eagain_do_while(GNTTABOP_map_grant_ref, &op);
-
-       if (op.status != GNTST_okay) {
-               DPRINTK(" Grant table operation failure %d!\n", (int)op.status);
-               ret = -EINVAL;
-       } else {
-               tpmif->shmem_ref = shared_page;
-               tpmif->shmem_handle = op.handle;
-               ret = 0;
-       }
-
-       return ret;
-}
-
-static void unmap_frontend_page(tpmif_t *tpmif)
-{
-       struct gnttab_unmap_grant_ref op;
-
-       gnttab_set_unmap_op(&op, (unsigned long)tpmif->tx_area->addr,
-                           GNTMAP_host_map, tpmif->shmem_handle);
-
-       if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
-               BUG();
-}
-
-int tpmif_map(tpmif_t *tpmif, unsigned long shared_page, unsigned int evtchn)
-{
+       struct vm_struct *area;
        int err;
 
        if (tpmif->irq)
                return 0;
 
-       if ((tpmif->tx_area = alloc_vm_area(PAGE_SIZE)) == NULL)
-               return -ENOMEM;
+       area = xenbus_map_ring_valloc(tpmif->bi->dev, ring_ref);
+       if (IS_ERR(area))
+               return PTR_ERR(area);
+       tpmif->tx_area = area;
 
-       err = map_frontend_page(tpmif, shared_page);
-       if (err) {
-               free_vm_area(tpmif->tx_area);
-               return err;
-       }
-
-       tpmif->tx = (tpmif_tx_interface_t *)tpmif->tx_area->addr;
+       tpmif->tx = (tpmif_tx_interface_t *)area->addr;
        memset(tpmif->tx, 0, PAGE_SIZE);
 
        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);
+               xenbus_unmap_ring_vfree(tpmif->bi->dev, area);
                return err;
        }
        tpmif->irq = err;
 
-       tpmif->shmem_ref = shared_page;
        tpmif->active = 1;
 
        return 0;
@@ -150,10 +114,8 @@
        if (tpmif->irq)
                unbind_from_irqhandler(tpmif->irq, tpmif);
 
-       if (tpmif->tx) {
-               unmap_frontend_page(tpmif);
-               free_vm_area(tpmif->tx_area);
-       }
+       if (tpmif->tx)
+               xenbus_unmap_ring_vfree(tpmif->bi->dev, tpmif->tx_area);
 
        free_tpmif(tpmif);
 }
diff -r 0bee20f8e418 -r 13937900bbd0 drivers/xen/tpmback/xenbus.c
--- a/drivers/xen/tpmback/xenbus.c      Sat Apr 02 15:54:29 2011 +0100
+++ b/drivers/xen/tpmback/xenbus.c      Tue Apr 05 12:38:20 2011 +0100
@@ -21,21 +21,6 @@
 #include <xen/xenbus.h>
 #include "common.h"
 
-struct backend_info
-{
-       struct xenbus_device *dev;
-
-       /* our communications channel */
-       tpmif_t *tpmif;
-
-       long int frontend_id;
-       long int instance; // instance of TPM
-       u8 is_instance_set;// whether instance number has been set
-
-       /* watch front end for changes */
-       struct xenbus_watch backend_watch;
-};
-
 static void maybe_connect(struct backend_info *be);
 static void connect(struct backend_info *be);
 static int connect_ring(struct backend_info *be);
diff -r 0bee20f8e418 -r 13937900bbd0 drivers/xen/usbback/interface.c
--- a/drivers/xen/usbback/interface.c   Sat Apr 02 15:54:29 2011 +0100
+++ b/drivers/xen/usbback/interface.c   Tue Apr 05 12:38:20 2011 +0100
@@ -43,8 +43,9 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#include <linux/delay.h>
+#include <linux/vmalloc.h>
 #include "usbback.h"
+#include <xen/evtchn.h>
 
 static LIST_HEAD(usbif_list);
 static DEFINE_SPINLOCK(usbif_list_lock);
@@ -101,83 +102,27 @@
        return usbif;
 }
 
-static int map_frontend_pages(usbif_t *usbif,
-                               grant_ref_t urb_ring_ref,
-                               grant_ref_t conn_ring_ref)
-{
-       struct gnttab_map_grant_ref op;
-
-       gnttab_set_map_op(&op, (unsigned long)usbif->urb_ring_area->addr,
-                         GNTMAP_host_map, urb_ring_ref, usbif->domid);
-
-       gnttab_check_GNTST_eagain_do_while(GNTTABOP_map_grant_ref, &op);
-
-       if (op.status != GNTST_okay) {
-               printk(KERN_ERR "grant table failure mapping urb_ring_ref 
%d\n", (int)op.status);
-               return -EINVAL;
-       }
-
-       usbif->urb_shmem_ref = urb_ring_ref;
-       usbif->urb_shmem_handle = op.handle;
-
-       gnttab_set_map_op(&op, (unsigned long)usbif->conn_ring_area->addr,
-                         GNTMAP_host_map, conn_ring_ref, usbif->domid);
-
-       gnttab_check_GNTST_eagain_do_while(GNTTABOP_map_grant_ref, &op);
-
-       if (op.status != GNTST_okay) {
-               struct gnttab_unmap_grant_ref unop;
-               gnttab_set_unmap_op(&unop,
-                               (unsigned long) usbif->urb_ring_area->addr,
-                               GNTMAP_host_map, usbif->urb_shmem_handle);
-               VOID(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &unop,
-                               1));
-               printk(KERN_ERR "grant table failure mapping conn_ring_ref 
%d\n", (int)op.status);
-               return -EINVAL;
-       }
-
-       usbif->conn_shmem_ref = conn_ring_ref;
-       usbif->conn_shmem_handle = op.handle;
-
-       return 0;
-}
-
-static void unmap_frontend_pages(usbif_t *usbif)
-{
-       struct gnttab_unmap_grant_ref op;
-
-       gnttab_set_unmap_op(&op, (unsigned long)usbif->urb_ring_area->addr,
-                           GNTMAP_host_map, usbif->urb_shmem_handle);
-
-       if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
-               BUG();
-
-       gnttab_set_unmap_op(&op, (unsigned long)usbif->conn_ring_area->addr,
-                           GNTMAP_host_map, usbif->conn_shmem_handle);
-
-       if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
-               BUG();
-}
-
-int usbif_map(usbif_t *usbif, unsigned long urb_ring_ref,
-               unsigned long conn_ring_ref, unsigned int evtchn)
+int usbif_map(usbif_t *usbif, grant_ref_t urb_ring_ref,
+             grant_ref_t conn_ring_ref, evtchn_port_t evtchn)
 {
        int err = -ENOMEM;
-
+       struct vm_struct *area;
        usbif_urb_sring_t *urb_sring;
        usbif_conn_sring_t *conn_sring;
 
        if (usbif->irq)
                return 0;
 
-       if ((usbif->urb_ring_area = alloc_vm_area(PAGE_SIZE)) == NULL)
-               return err;
-       if ((usbif->conn_ring_area = alloc_vm_area(PAGE_SIZE)) == NULL)
+       area = xenbus_map_ring_valloc(usbif->xbdev, urb_ring_ref);
+       if (IS_ERR(area))
+               return PTR_ERR(area);
+       usbif->urb_ring_area = area;
+       area = xenbus_map_ring_valloc(usbif->xbdev, conn_ring_ref);
+       if (IS_ERR(area)) {
+               err = PTR_ERR(area);
                goto fail_alloc;
-
-       err = map_frontend_pages(usbif, urb_ring_ref, conn_ring_ref);
-       if (err)
-               goto fail_map;
+       }
+       usbif->conn_ring_area = area;
 
        err = bind_interdomain_evtchn_to_irqhandler(
                        usbif->domid, evtchn, usbbk_be_int, 0,
@@ -195,11 +140,9 @@
        return 0;
 
 fail_evtchn:
-       unmap_frontend_pages(usbif);
-fail_map:
-       free_vm_area(usbif->conn_ring_area);
+       xenbus_unmap_ring_vfree(usbif->xbdev, usbif->conn_ring_area);
 fail_alloc:
-       free_vm_area(usbif->urb_ring_area);
+       xenbus_unmap_ring_vfree(usbif->xbdev, usbif->urb_ring_area);
 
        return err;
 }
@@ -229,9 +172,8 @@
        }
 
        if (usbif->urb_ring.sring) {
-               unmap_frontend_pages(usbif);
-               free_vm_area(usbif->urb_ring_area);
-               free_vm_area(usbif->conn_ring_area);
+               xenbus_unmap_ring_vfree(usbif->xbdev, usbif->urb_ring_area);
+               xenbus_unmap_ring_vfree(usbif->xbdev, usbif->conn_ring_area);
                usbif->urb_ring.sring = NULL;
                usbif->conn_ring.sring = NULL;
        }
diff -r 0bee20f8e418 -r 13937900bbd0 drivers/xen/usbback/usbback.c
--- a/drivers/xen/usbback/usbback.c     Sat Apr 02 15:54:29 2011 +0100
+++ b/drivers/xen/usbback/usbback.c     Tue Apr 05 12:38:20 2011 +0100
@@ -45,6 +45,8 @@
 
 #include <linux/mm.h>
 #include <xen/balloon.h>
+#include <xen/evtchn.h>
+#include <xen/gnttab.h>
 #include "usbback.h"
 
 #if 0
diff -r 0bee20f8e418 -r 13937900bbd0 drivers/xen/usbback/usbback.h
--- a/drivers/xen/usbback/usbback.h     Sat Apr 02 15:54:29 2011 +0100
+++ b/drivers/xen/usbback/usbback.h     Tue Apr 05 12:38:20 2011 +0100
@@ -55,11 +55,9 @@
 #include <linux/wait.h>
 #include <linux/list.h>
 #include <linux/kref.h>
-#include <xen/evtchn.h>
-#include <xen/gnttab.h>
 #include <xen/driver_util.h>
-#include <xen/interface/xen.h>
 #include <xen/xenbus.h>
+#include <xen/interface/event_channel.h>
 #include <xen/interface/io/usbif.h>
 
 struct usbstub;
@@ -86,11 +84,6 @@
        spinlock_t conn_ring_lock;
        atomic_t refcnt;
 
-       grant_handle_t urb_shmem_handle;
-       grant_ref_t urb_shmem_ref;
-       grant_handle_t conn_shmem_handle;
-       grant_ref_t conn_shmem_ref;
-
        struct xenbus_watch backend_watch;
 
        /* device address lookup table */
@@ -134,8 +127,8 @@
 usbif_t *usbif_alloc(domid_t domid, unsigned int handle);
 void usbif_disconnect(usbif_t *usbif);
 void usbif_free(usbif_t *usbif);
-int usbif_map(usbif_t *usbif, unsigned long urb_ring_ref,
-               unsigned long conn_ring_ref, unsigned int evtchn);
+int usbif_map(usbif_t *usbif, grant_ref_t urb_ring_ref,
+             grant_ref_t conn_ring_ref, evtchn_port_t);
 
 #define usbif_get(_b) (atomic_inc(&(_b)->refcnt))
 #define usbif_put(_b) \
diff -r 0bee20f8e418 -r 13937900bbd0 drivers/xen/xenbus/xenbus_backend_client.c
--- a/drivers/xen/xenbus/xenbus_backend_client.c        Sat Apr 02 15:54:29 
2011 +0100
+++ b/drivers/xen/xenbus/xenbus_backend_client.c        Tue Apr 05 12:38:20 
2011 +0100
@@ -37,7 +37,7 @@
 #include <xen/driver_util.h>
 
 /* Based on Rusty Russell's skeleton driver's map_page */
-struct vm_struct *xenbus_map_ring_valloc(struct xenbus_device *dev, int 
gnt_ref)
+struct vm_struct *xenbus_map_ring_valloc(struct xenbus_device *dev, 
grant_ref_t gnt_ref)
 {
        struct gnttab_map_grant_ref op;
        struct vm_struct *area;
@@ -68,32 +68,6 @@
 EXPORT_SYMBOL_GPL(xenbus_map_ring_valloc);
 
 
-int xenbus_map_ring(struct xenbus_device *dev, int gnt_ref,
-                  grant_handle_t *handle, void *vaddr)
-{
-       struct gnttab_map_grant_ref op;
-       int ret;
-       
-       gnttab_set_map_op(&op, (unsigned long)vaddr, GNTMAP_host_map,
-                         gnt_ref, dev->otherend_id);
-
-       gnttab_check_GNTST_eagain_do_while(GNTTABOP_map_grant_ref, &op);
-
-       if (op.status != GNTST_okay) {
-               xenbus_dev_fatal(dev, op.status,
-                                "mapping in shared page %d from domain %d",
-                                gnt_ref, dev->otherend_id);
-               ret = -EINVAL;
-       } else {
-               *handle = op.handle;
-               ret = 0;
-       }
-
-       return ret;
-}
-EXPORT_SYMBOL_GPL(xenbus_map_ring);
-
-
 /* Based on Rusty Russell's skeleton driver's unmap_page */
 int xenbus_unmap_ring_vfree(struct xenbus_device *dev, struct vm_struct *area)
 {
@@ -117,25 +91,6 @@
 EXPORT_SYMBOL_GPL(xenbus_unmap_ring_vfree);
 
 
-int xenbus_unmap_ring(struct xenbus_device *dev,
-                    grant_handle_t handle, void *vaddr)
-{
-       struct gnttab_unmap_grant_ref op;
-
-       gnttab_set_unmap_op(&op, (unsigned long)vaddr, GNTMAP_host_map,
-                           handle);
-       if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
-               BUG();
-
-       if (op.status != GNTST_okay)
-               xenbus_dev_error(dev, op.status,
-                                "unmapping page at handle %d error %d",
-                                handle, op.status);
-
-       return op.status == GNTST_okay ? 0 : -EINVAL;
-}
-EXPORT_SYMBOL_GPL(xenbus_unmap_ring);
-
 int xenbus_dev_is_online(struct xenbus_device *dev)
 {
        int rc, val;
diff -r 0bee20f8e418 -r 13937900bbd0 include/xen/xenbus.h
--- a/include/xen/xenbus.h      Sat Apr 02 15:54:29 2011 +0100
+++ b/include/xen/xenbus.h      Tue Apr 05 12:38:20 2011 +0100
@@ -233,28 +233,20 @@
  * Map a page of memory into this domain from another domain's grant table.
  * xenbus_map_ring_valloc allocates a page of virtual address space, maps the
  * page to that address, and sets *vaddr to that address.
- * xenbus_map_ring does not allocate the virtual address space (you must do
- * this yourself!). It only maps in the page to the specified address.
  * Returns 0 on success, and GNTST_* (see xen/include/interface/grant_table.h)
  * or -ENOMEM on error. If an error is returned, device will switch to
  * XenbusStateClosing and the error message will be saved in XenStore.
  */
 struct vm_struct *xenbus_map_ring_valloc(struct xenbus_device *dev,
-                                        int gnt_ref);
-int xenbus_map_ring(struct xenbus_device *dev, int gnt_ref,
-                          grant_handle_t *handle, void *vaddr);
-
+                                        grant_ref_t ref);
 
 /**
- * Unmap a page of memory in this domain that was imported from another domain.
- * Use xenbus_unmap_ring_vfree if you mapped in your memory with
- * xenbus_map_ring_valloc (it will free the virtual address space).
+ * Unmap a page of memory in this domain that was imported from another domain
+ * and free the virtual address space.
  * Returns 0 on success and returns GNTST_* on error
  * (see xen/include/interface/grant_table.h).
  */
 int xenbus_unmap_ring_vfree(struct xenbus_device *dev, struct vm_struct *);
-int xenbus_unmap_ring(struct xenbus_device *dev,
-                     grant_handle_t handle, void *vaddr);
 
 
 /**

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [linux-2.6.18-xen] xen/backends: use xenbus_be.ko interfaces instead of open-coding them, Xen patchbot-linux-2 . 6 . 18-xen <=