[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [HVM] Make grant tables functions work in PV-on-HVM drivers.



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Node ID b2f077bbca89b1ea942ac7566c51ee3e2bf422fe
# Parent  879918dbe77f10f37b697cc3aae4d2c2c25dd13a
[HVM] Make grant tables functions work in PV-on-HVM drivers.
Signed-off-by: Steven Smith <ssmith@xxxxxxxxxxxxx>
---
 linux-2.6-xen-sparse/drivers/xen/core/gnttab.c           |   56 ++++++++++++---
 unmodified_drivers/linux-2.6/mkbuildtree                 |    1 
 unmodified_drivers/linux-2.6/platform-pci/Kbuild         |    2 
 unmodified_drivers/linux-2.6/platform-pci/platform-pci.c |    9 +-
 unmodified_drivers/linux-2.6/platform-pci/platform-pci.h |    2 
 5 files changed, 58 insertions(+), 12 deletions(-)

diff -r 879918dbe77f -r b2f077bbca89 
linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c    Thu Aug 17 16:08:01 
2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c    Thu Aug 17 16:21:08 
2006 +0100
@@ -41,6 +41,8 @@
 #include <asm/pgtable.h>
 #include <asm/uaccess.h>
 #include <asm/synch_bitops.h>
+#include <asm/io.h>
+#include <xen/interface/memory.h>
 
 /* External tools reserve first few grant table entries. */
 #define NR_RESERVED_ENTRIES 8
@@ -350,6 +352,8 @@ void gnttab_cancel_free_callback(struct 
 }
 EXPORT_SYMBOL_GPL(gnttab_cancel_free_callback);
 
+#ifdef CONFIG_XEN
+
 #ifndef __ia64__
 static int map_pte_fn(pte_t *pte, struct page *pmd_page,
                      unsigned long addr, void *data)
@@ -404,23 +408,57 @@ int gnttab_resume(void)
        shared = __va(frames[0] << PAGE_SHIFT);
        printk("grant table at %p\n", shared);
 #endif
-
-       return 0;
 }
 
 int gnttab_suspend(void)
 {
-
 #ifndef __ia64__
        apply_to_page_range(&init_mm, (unsigned long)shared,
                            PAGE_SIZE * NR_GRANT_FRAMES,
                            unmap_pte_fn, NULL);
 #endif
-
-       return 0;
-}
-
-static int __init gnttab_init(void)
+       return 0;
+}
+
+#else /* !CONFIG_XEN */
+
+#include <platform-pci.h>
+
+int gnttab_resume(void)
+{
+       unsigned long frames;
+       struct xen_add_to_physmap xatp;
+       unsigned int i;
+
+       frames = alloc_xen_mmio(PAGE_SIZE * NR_GRANT_FRAMES);
+
+       for (i = 0; i < NR_GRANT_FRAMES; i++) {
+               xatp.domid = DOMID_SELF;
+               xatp.idx = i;
+               xatp.space = XENMAPSPACE_grant_table;
+               xatp.gpfn = (frames >> PAGE_SHIFT) + i;
+               if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp))
+                       BUG();
+       }
+
+       shared = ioremap(frames, PAGE_SIZE * NR_GRANT_FRAMES);
+       if (shared == NULL) {
+               printk("error to ioremap gnttab share frames\n");
+               return -1;
+       }
+
+       return 0;
+}
+
+int gnttab_suspend(void)
+{
+       iounmap(shared);
+       return 0;
+}
+
+#endif /* !CONFIG_XEN */
+
+int __init gnttab_init(void)
 {
        int i;
 
@@ -439,4 +477,6 @@ static int __init gnttab_init(void)
        return 0;
 }
 
+#ifdef CONFIG_XEN
 core_initcall(gnttab_init);
+#endif
diff -r 879918dbe77f -r b2f077bbca89 unmodified_drivers/linux-2.6/mkbuildtree
--- a/unmodified_drivers/linux-2.6/mkbuildtree  Thu Aug 17 16:08:01 2006 +0100
+++ b/unmodified_drivers/linux-2.6/mkbuildtree  Thu Aug 17 16:21:08 2006 +0100
@@ -5,6 +5,7 @@ XEN=$C/../../xen
 XEN=$C/../../xen
 XL=$C/../../linux-2.6-xen-sparse
 
+ln -sf ${XL}/drivers/xen/core/gnttab.c platform-pci
 ln -sf ${XL}/drivers/xen/core/features.c platform-pci
 
 mkdir -p include
diff -r 879918dbe77f -r b2f077bbca89 
unmodified_drivers/linux-2.6/platform-pci/Kbuild
--- a/unmodified_drivers/linux-2.6/platform-pci/Kbuild  Thu Aug 17 16:08:01 
2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/Kbuild  Thu Aug 17 16:21:08 
2006 +0100
@@ -4,4 +4,4 @@ obj-m := xen-platform-pci.o
 
 EXTRA_CFLAGS += -I$(M)/platform-pci
 
-xen-platform-pci-objs := evtchn.o platform-pci.o xen_support.o features.o
+xen-platform-pci-objs := evtchn.o platform-pci.o gnttab.o xen_support.o 
features.o
diff -r 879918dbe77f -r b2f077bbca89 
unmodified_drivers/linux-2.6/platform-pci/platform-pci.c
--- a/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c  Thu Aug 17 
16:08:01 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c  Thu Aug 17 
16:21:08 2006 +0100
@@ -64,14 +64,17 @@ static int __init init_xen_info(void)
        xatp.idx = 0;
        xatp.space = XENMAPSPACE_shared_info;
        xatp.gpfn = shared_info_frame;
-       BUG_ON(HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp));
+       if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp))
+               BUG();
+
        shared_info_area =
                ioremap(shared_info_frame << PAGE_SHIFT, PAGE_SIZE);
-
-       if (!shared_info_area)
+       if (shared_info_area == NULL)
                panic("can't map shared info\n");
 
        phys_to_machine_mapping = NULL;
+
+       gnttab_init();
 
        return 0;
 }
diff -r 879918dbe77f -r b2f077bbca89 
unmodified_drivers/linux-2.6/platform-pci/platform-pci.h
--- a/unmodified_drivers/linux-2.6/platform-pci/platform-pci.h  Thu Aug 17 
16:08:01 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/platform-pci.h  Thu Aug 17 
16:21:08 2006 +0100
@@ -36,6 +36,8 @@ static inline int set_callback_irq(int i
 
 unsigned long alloc_xen_mmio(unsigned long len);
 
+int gnttab_init(void);
+
 void setup_xen_features(void);
 
 irqreturn_t evtchn_interrupt(int irq, void *dev_id, struct pt_regs *regs);

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.