ia64/xen-unstable

changeset 11186:b2f077bbca89

[HVM] Make grant tables functions work in PV-on-HVM drivers.
Signed-off-by: Steven Smith <ssmith@xensource.com>
author kfraser@localhost.localdomain
date Thu Aug 17 16:21:08 2006 +0100 (2006-08-17)
parents 879918dbe77f
children 45f3c127069d
files linux-2.6-xen-sparse/drivers/xen/core/gnttab.c unmodified_drivers/linux-2.6/mkbuildtree unmodified_drivers/linux-2.6/platform-pci/Kbuild unmodified_drivers/linux-2.6/platform-pci/platform-pci.c unmodified_drivers/linux-2.6/platform-pci/platform-pci.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Thu Aug 17 16:08:01 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Thu Aug 17 16:21:08 2006 +0100
     1.3 @@ -41,6 +41,8 @@
     1.4  #include <asm/pgtable.h>
     1.5  #include <asm/uaccess.h>
     1.6  #include <asm/synch_bitops.h>
     1.7 +#include <asm/io.h>
     1.8 +#include <xen/interface/memory.h>
     1.9  
    1.10  /* External tools reserve first few grant table entries. */
    1.11  #define NR_RESERVED_ENTRIES 8
    1.12 @@ -350,6 +352,8 @@ void gnttab_cancel_free_callback(struct 
    1.13  }
    1.14  EXPORT_SYMBOL_GPL(gnttab_cancel_free_callback);
    1.15  
    1.16 +#ifdef CONFIG_XEN
    1.17 +
    1.18  #ifndef __ia64__
    1.19  static int map_pte_fn(pte_t *pte, struct page *pmd_page,
    1.20  		      unsigned long addr, void *data)
    1.21 @@ -404,23 +408,57 @@ int gnttab_resume(void)
    1.22  	shared = __va(frames[0] << PAGE_SHIFT);
    1.23  	printk("grant table at %p\n", shared);
    1.24  #endif
    1.25 +}
    1.26 +
    1.27 +int gnttab_suspend(void)
    1.28 +{
    1.29 +#ifndef __ia64__
    1.30 +	apply_to_page_range(&init_mm, (unsigned long)shared,
    1.31 +			    PAGE_SIZE * NR_GRANT_FRAMES,
    1.32 +			    unmap_pte_fn, NULL);
    1.33 +#endif
    1.34 +	return 0;
    1.35 +}
    1.36 +
    1.37 +#else /* !CONFIG_XEN */
    1.38 +
    1.39 +#include <platform-pci.h>
    1.40 +
    1.41 +int gnttab_resume(void)
    1.42 +{
    1.43 +	unsigned long frames;
    1.44 +	struct xen_add_to_physmap xatp;
    1.45 +	unsigned int i;
    1.46 +
    1.47 +	frames = alloc_xen_mmio(PAGE_SIZE * NR_GRANT_FRAMES);
    1.48 +
    1.49 +	for (i = 0; i < NR_GRANT_FRAMES; i++) {
    1.50 +		xatp.domid = DOMID_SELF;
    1.51 +		xatp.idx = i;
    1.52 +		xatp.space = XENMAPSPACE_grant_table;
    1.53 +		xatp.gpfn = (frames >> PAGE_SHIFT) + i;
    1.54 +		if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp))
    1.55 +			BUG();
    1.56 +	}
    1.57 +
    1.58 +	shared = ioremap(frames, PAGE_SIZE * NR_GRANT_FRAMES);
    1.59 +	if (shared == NULL) {
    1.60 +		printk("error to ioremap gnttab share frames\n");
    1.61 +		return -1;
    1.62 +	}
    1.63  
    1.64  	return 0;
    1.65  }
    1.66  
    1.67  int gnttab_suspend(void)
    1.68  {
    1.69 -
    1.70 -#ifndef __ia64__
    1.71 -	apply_to_page_range(&init_mm, (unsigned long)shared,
    1.72 -			    PAGE_SIZE * NR_GRANT_FRAMES,
    1.73 -			    unmap_pte_fn, NULL);
    1.74 -#endif
    1.75 -
    1.76 +	iounmap(shared);
    1.77  	return 0;
    1.78  }
    1.79  
    1.80 -static int __init gnttab_init(void)
    1.81 +#endif /* !CONFIG_XEN */
    1.82 +
    1.83 +int __init gnttab_init(void)
    1.84  {
    1.85  	int i;
    1.86  
    1.87 @@ -439,4 +477,6 @@ static int __init gnttab_init(void)
    1.88  	return 0;
    1.89  }
    1.90  
    1.91 +#ifdef CONFIG_XEN
    1.92  core_initcall(gnttab_init);
    1.93 +#endif
     2.1 --- a/unmodified_drivers/linux-2.6/mkbuildtree	Thu Aug 17 16:08:01 2006 +0100
     2.2 +++ b/unmodified_drivers/linux-2.6/mkbuildtree	Thu Aug 17 16:21:08 2006 +0100
     2.3 @@ -5,6 +5,7 @@ C=$PWD
     2.4  XEN=$C/../../xen
     2.5  XL=$C/../../linux-2.6-xen-sparse
     2.6  
     2.7 +ln -sf ${XL}/drivers/xen/core/gnttab.c platform-pci
     2.8  ln -sf ${XL}/drivers/xen/core/features.c platform-pci
     2.9  
    2.10  mkdir -p include
     3.1 --- a/unmodified_drivers/linux-2.6/platform-pci/Kbuild	Thu Aug 17 16:08:01 2006 +0100
     3.2 +++ b/unmodified_drivers/linux-2.6/platform-pci/Kbuild	Thu Aug 17 16:21:08 2006 +0100
     3.3 @@ -4,4 +4,4 @@ obj-m := xen-platform-pci.o
     3.4  
     3.5  EXTRA_CFLAGS += -I$(M)/platform-pci
     3.6  
     3.7 -xen-platform-pci-objs := evtchn.o platform-pci.o xen_support.o features.o
     3.8 +xen-platform-pci-objs := evtchn.o platform-pci.o gnttab.o xen_support.o features.o
     4.1 --- a/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c	Thu Aug 17 16:08:01 2006 +0100
     4.2 +++ b/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c	Thu Aug 17 16:21:08 2006 +0100
     4.3 @@ -64,15 +64,18 @@ static int __init init_xen_info(void)
     4.4  	xatp.idx = 0;
     4.5  	xatp.space = XENMAPSPACE_shared_info;
     4.6  	xatp.gpfn = shared_info_frame;
     4.7 -	BUG_ON(HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp));
     4.8 +	if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp))
     4.9 +		BUG();
    4.10 +
    4.11  	shared_info_area =
    4.12  		ioremap(shared_info_frame << PAGE_SHIFT, PAGE_SIZE);
    4.13 -
    4.14 -	if (!shared_info_area)
    4.15 +	if (shared_info_area == NULL)
    4.16  		panic("can't map shared info\n");
    4.17  
    4.18  	phys_to_machine_mapping = NULL;
    4.19  
    4.20 +	gnttab_init();
    4.21 +
    4.22  	return 0;
    4.23  }
    4.24  
     5.1 --- a/unmodified_drivers/linux-2.6/platform-pci/platform-pci.h	Thu Aug 17 16:08:01 2006 +0100
     5.2 +++ b/unmodified_drivers/linux-2.6/platform-pci/platform-pci.h	Thu Aug 17 16:21:08 2006 +0100
     5.3 @@ -36,6 +36,8 @@ static inline int set_callback_irq(int i
     5.4  
     5.5  unsigned long alloc_xen_mmio(unsigned long len);
     5.6  
     5.7 +int gnttab_init(void);
     5.8 +
     5.9  void setup_xen_features(void);
    5.10  
    5.11  irqreturn_t evtchn_interrupt(int irq, void *dev_id, struct pt_regs *regs);