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-ia64-devel

[Xen-ia64-devel] [PATCH] sparse tree machine vector support

To: xen-ia64-devel <xen-ia64-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-ia64-devel] [PATCH] sparse tree machine vector support
From: Alex Williamson <alex.williamson@xxxxxx>
Date: Sun, 06 May 2007 22:57:12 -0600
Delivery-date: Sun, 06 May 2007 21:55:40 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-ia64-devel-request@lists.xensource.com?subject=help>
List-id: Discussion of the ia64 port of Xen <xen-ia64-devel.lists.xensource.com>
List-post: <mailto:xen-ia64-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: HP OSLO R&D
Sender: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
   I think this is ready to be committed to the tree, so I'm sending it
out one more time for review first.  This patch includes the iommu
paravirtualization and the Xen machine vector support that I sent out
previously.  Before applying this patch, several files need to be added
to the sparse tree:

linux-2.6-xen-sparse/arch/ia64/xen/swiotlb.c (from lib/swiotlb.c)
linux-2.6-xen-sparse/arch/ia64/hp/common/sba_iommu.c
linux-2.6-xen-sparse/arch/ia64/kernel/acpi.c
linux-2.6-xen-sparse/include/asm-ia64/machvec.h

I've had to disable the mark_clean() functionality in swiotlb and
sba_iommu for the running on Xen case.  I'm not sure if it's feasible to
enable these, but for now it's a performance optimization that can be
easily skipped.  This also corrects a bug in PCI driver domains when
enabling CONFIG_NUMA.  We simply need to set the node value in the pci
controller structure.  As Isaku mentioned before, machvec_dig.h can be
removed from the sparse tree once this goes in.  Please let me know if
you have any comments or test results.  Thanks,

        Alex

Signed-off-by: Alex Williamson <alex.williamson@xxxxxx>
---

diff -r 642a9bcaf19c buildconfigs/linux-defconfig_xen0_ia64
--- a/buildconfigs/linux-defconfig_xen0_ia64    Sun May 06 20:34:15 2007 -0600
+++ b/buildconfigs/linux-defconfig_xen0_ia64    Sun May 06 22:06:42 2007 -0600
@@ -1,8 +1,9 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.18-xen0
-# Mon Jan 29 10:16:18 2007
-#
+# Linux kernel version: 2.6.18-xen0
+# Sun May  6 20:45:43 2007
+#
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
 #
 # Code maturity level options
@@ -99,12 +100,13 @@ CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
 CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
 CONFIG_DMA_IS_DMA32=y
 CONFIG_AUDIT_ARCH=y
-# CONFIG_IA64_GENERIC is not set
-CONFIG_IA64_DIG=y
+CONFIG_IA64_GENERIC=y
+# CONFIG_IA64_DIG is not set
 # CONFIG_IA64_HP_ZX1 is not set
 # CONFIG_IA64_HP_ZX1_SWIOTLB is not set
 # CONFIG_IA64_SGI_SN2 is not set
 # CONFIG_IA64_HP_SIM is not set
+# CONFIG_IA64_XEN is not set
 # CONFIG_ITANIUM is not set
 CONFIG_MCKINLEY=y
 # CONFIG_IA64_PAGE_SIZE_4KB is not set
@@ -120,6 +122,7 @@ CONFIG_IA64_L1_CACHE_SHIFT=7
 CONFIG_IA64_L1_CACHE_SHIFT=7
 CONFIG_IA64_CYCLONE=y
 CONFIG_IOSAPIC=y
+# CONFIG_IA64_SGI_SN_XP is not set
 CONFIG_FORCE_MAX_ZONEORDER=11
 CONFIG_SMP=y
 CONFIG_NR_CPUS=16
@@ -129,23 +132,37 @@ CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
 # CONFIG_PERMIT_BSP_REMOVE is not set
 # CONFIG_PREEMPT is not set
 CONFIG_SELECT_MEMORY_MODEL=y
-CONFIG_FLATMEM_MANUAL=y
-# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_FLATMEM_MANUAL is not set
+CONFIG_DISCONTIGMEM_MANUAL=y
 # CONFIG_SPARSEMEM_MANUAL is not set
-CONFIG_FLATMEM=y
+CONFIG_DISCONTIGMEM=y
 CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_NEED_MULTIPLE_NODES=y
 # CONFIG_SPARSEMEM_STATIC is not set
 CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_MIGRATION is not set
 CONFIG_RESOURCES_64BIT=y
 CONFIG_ARCH_SELECT_MEMORY_MODEL=y
 CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
 CONFIG_ARCH_FLATMEM_ENABLE=y
 CONFIG_ARCH_SPARSEMEM_ENABLE=y
-# CONFIG_VIRTUAL_MEM_MAP is not set
+CONFIG_ARCH_DISCONTIGMEM_DEFAULT=y
+CONFIG_NUMA=y
+CONFIG_NODES_SHIFT=10
+CONFIG_VIRTUAL_MEM_MAP=y
+CONFIG_HOLES_IN_ZONE=y
+CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y
+CONFIG_HAVE_ARCH_NODEDATA_EXTENSION=y
 # CONFIG_IA32_SUPPORT is not set
-CONFIG_IA64_MCA_RECOVERY=y
+# CONFIG_IA64_MCA_RECOVERY is not set
 CONFIG_PERFMON=y
 CONFIG_IA64_PALINFO=y
+CONFIG_SGI_SN=y
+
+#
+# SN Devices
+#
+# CONFIG_SGI_IOC3 is not set
 
 #
 # Firmware Drivers
@@ -172,6 +189,7 @@ CONFIG_ACPI_PROCESSOR=y
 CONFIG_ACPI_PROCESSOR=y
 CONFIG_ACPI_HOTPLUG_CPU=y
 CONFIG_ACPI_THERMAL=y
+CONFIG_ACPI_NUMA=y
 CONFIG_ACPI_BLACKLIST_YEAR=0
 # CONFIG_ACPI_DEBUG is not set
 CONFIG_ACPI_EC=y
@@ -203,6 +221,7 @@ CONFIG_HOTPLUG_PCI_ACPI=y
 # CONFIG_HOTPLUG_PCI_ACPI_IBM is not set
 # CONFIG_HOTPLUG_PCI_CPCI is not set
 # CONFIG_HOTPLUG_PCI_SHPC is not set
+# CONFIG_HOTPLUG_PCI_SGI is not set
 
 #
 # PCCARD (PCMCIA/CardBus) support
@@ -747,6 +766,8 @@ CONFIG_SERIAL_NONSTANDARD=y
 # CONFIG_SX is not set
 # CONFIG_RIO is not set
 # CONFIG_STALDRV is not set
+# CONFIG_SGI_SNSC is not set
+# CONFIG_SGI_TIOCX is not set
 
 #
 # Serial drivers
@@ -755,6 +776,7 @@ CONFIG_SERIAL_NONSTANDARD=y
 #
 # Non-8250 serial port support
 #
+# CONFIG_SERIAL_SGI_L1_CONSOLE is not set
 # CONFIG_SERIAL_JSM is not set
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
@@ -782,6 +804,8 @@ CONFIG_AGP=y
 # CONFIG_AGP_SIS is not set
 # CONFIG_AGP_VIA is not set
 CONFIG_AGP_I460=y
+# CONFIG_AGP_HP_ZX1 is not set
+# CONFIG_AGP_SGI_TIOCA is not set
 CONFIG_DRM=y
 # CONFIG_DRM_TDFX is not set
 # CONFIG_DRM_R128 is not set
@@ -793,6 +817,7 @@ CONFIG_DRM=y
 # CONFIG_RAW_DRIVER is not set
 # CONFIG_HPET is not set
 # CONFIG_HANGCHECK_TIMER is not set
+# CONFIG_MMTIMER is not set
 
 #
 # TPM devices
@@ -1541,6 +1566,13 @@ CONFIG_IRQ_PER_CPU=y
 CONFIG_IRQ_PER_CPU=y
 
 #
+# HP Simulator drivers
+#
+# CONFIG_HP_SIMETH is not set
+# CONFIG_HP_SIMSERIAL is not set
+# CONFIG_HP_SIMSCSI is not set
+
+#
 # Instrumentation Support
 #
 # CONFIG_PROFILING is not set
@@ -1615,9 +1647,6 @@ CONFIG_CRYPTO_DES=y
 #
 # Hardware crypto devices
 #
-# CONFIG_XEN_UTIL is not set
-CONFIG_XEN_BALLOON=y
-CONFIG_XEN_REBOOT=y
 # CONFIG_XEN_SMPBOOT is not set
 CONFIG_XEN_INTERFACE_VERSION=0x00030205
 
@@ -1642,15 +1671,14 @@ CONFIG_XEN_TPMDEV_BACKEND=m
 CONFIG_XEN_TPMDEV_BACKEND=m
 CONFIG_XEN_BLKDEV_FRONTEND=y
 CONFIG_XEN_NETDEV_FRONTEND=y
-# CONFIG_XEN_FRAMEBUFFER is not set
+CONFIG_XEN_FRAMEBUFFER=y
+CONFIG_XEN_KEYBOARD=y
 # CONFIG_XEN_SCRUB_PAGES is not set
 CONFIG_XEN_DISABLE_SERIAL=y
 CONFIG_XEN_SYSFS=y
 CONFIG_XEN_COMPAT_030002_AND_LATER=y
 # CONFIG_XEN_COMPAT_030004_AND_LATER is not set
 # CONFIG_XEN_COMPAT_LATEST_ONLY is not set
-CONFIG_XEN_COMPAT_030002=y
-CONFIG_XEN_COMPAT_030004=y
+CONFIG_XEN_COMPAT=0x030002
 CONFIG_HAVE_IRQ_IGNORE_UNHANDLED=y
 CONFIG_NO_IDLE_HZ=y
-CONFIG_XEN_DEVMEM=y
diff -r 642a9bcaf19c buildconfigs/linux-defconfig_xenU_ia64
--- a/buildconfigs/linux-defconfig_xenU_ia64    Sun May 06 20:34:15 2007 -0600
+++ b/buildconfigs/linux-defconfig_xenU_ia64    Sun May 06 22:28:21 2007 -0600
@@ -1,8 +1,9 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.18-xenU
-# Mon Jan 29 10:26:51 2007
-#
+# Linux kernel version: 2.6.18-xenU
+# Sun May  6 22:07:34 2007
+#
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
 #
 # Code maturity level options
@@ -56,6 +57,7 @@ CONFIG_MODULES=y
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
 # CONFIG_KMOD is not set
+CONFIG_STOP_MACHINE=y
 
 #
 # Block layer
@@ -97,11 +99,12 @@ CONFIG_DMA_IS_DMA32=y
 CONFIG_DMA_IS_DMA32=y
 CONFIG_AUDIT_ARCH=y
 # CONFIG_IA64_GENERIC is not set
-CONFIG_IA64_DIG=y
+# CONFIG_IA64_DIG is not set
 # CONFIG_IA64_HP_ZX1 is not set
 # CONFIG_IA64_HP_ZX1_SWIOTLB is not set
 # CONFIG_IA64_SGI_SN2 is not set
 # CONFIG_IA64_HP_SIM is not set
+CONFIG_IA64_XEN=y
 # CONFIG_ITANIUM is not set
 CONFIG_MCKINLEY=y
 # CONFIG_IA64_PAGE_SIZE_4KB is not set
@@ -175,7 +178,7 @@ CONFIG_ACPI_EC=y
 CONFIG_ACPI_EC=y
 CONFIG_ACPI_POWER=y
 CONFIG_ACPI_SYSTEM=y
-# CONFIG_ACPI_CONTAINER is not set
+CONFIG_ACPI_CONTAINER=y
 
 #
 # CPU Frequency scaling
@@ -673,7 +676,6 @@ CONFIG_AGP=y
 CONFIG_AGP=y
 # CONFIG_AGP_SIS is not set
 # CONFIG_AGP_VIA is not set
-# CONFIG_AGP_I460 is not set
 CONFIG_DRM=y
 # CONFIG_DRM_TDFX is not set
 # CONFIG_DRM_R128 is not set
@@ -1467,9 +1469,6 @@ CONFIG_CRYPTO_DES=y
 #
 # Hardware crypto devices
 #
-# CONFIG_XEN_UTIL is not set
-CONFIG_XEN_BALLOON=y
-CONFIG_XEN_REBOOT=y
 # CONFIG_XEN_SMPBOOT is not set
 CONFIG_XEN_INTERFACE_VERSION=0x00030205
 
@@ -1491,8 +1490,6 @@ CONFIG_XEN_COMPAT_030002_AND_LATER=y
 CONFIG_XEN_COMPAT_030002_AND_LATER=y
 # CONFIG_XEN_COMPAT_030004_AND_LATER is not set
 # CONFIG_XEN_COMPAT_LATEST_ONLY is not set
-CONFIG_XEN_COMPAT_030002=y
-CONFIG_XEN_COMPAT_030004=y
+CONFIG_XEN_COMPAT=0x030002
 CONFIG_HAVE_IRQ_IGNORE_UNHANDLED=y
 CONFIG_NO_IDLE_HZ=y
-CONFIG_XEN_DEVMEM=y
diff -r 642a9bcaf19c buildconfigs/linux-defconfig_xen_ia64
--- a/buildconfigs/linux-defconfig_xen_ia64     Sun May 06 20:34:15 2007 -0600
+++ b/buildconfigs/linux-defconfig_xen_ia64     Sun May 06 22:02:58 2007 -0600
@@ -1,8 +1,9 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.18-xen
-# Mon Jan 29 10:01:13 2007
-#
+# Linux kernel version: 2.6.18-xen
+# Sun May  6 20:45:43 2007
+#
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
 #
 # Code maturity level options
@@ -99,12 +100,13 @@ CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
 CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
 CONFIG_DMA_IS_DMA32=y
 CONFIG_AUDIT_ARCH=y
-# CONFIG_IA64_GENERIC is not set
-CONFIG_IA64_DIG=y
+CONFIG_IA64_GENERIC=y
+# CONFIG_IA64_DIG is not set
 # CONFIG_IA64_HP_ZX1 is not set
 # CONFIG_IA64_HP_ZX1_SWIOTLB is not set
 # CONFIG_IA64_SGI_SN2 is not set
 # CONFIG_IA64_HP_SIM is not set
+# CONFIG_IA64_XEN is not set
 # CONFIG_ITANIUM is not set
 CONFIG_MCKINLEY=y
 # CONFIG_IA64_PAGE_SIZE_4KB is not set
@@ -120,6 +122,7 @@ CONFIG_IA64_L1_CACHE_SHIFT=7
 CONFIG_IA64_L1_CACHE_SHIFT=7
 CONFIG_IA64_CYCLONE=y
 CONFIG_IOSAPIC=y
+# CONFIG_IA64_SGI_SN_XP is not set
 CONFIG_FORCE_MAX_ZONEORDER=11
 CONFIG_SMP=y
 CONFIG_NR_CPUS=16
@@ -129,23 +132,37 @@ CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
 # CONFIG_PERMIT_BSP_REMOVE is not set
 # CONFIG_PREEMPT is not set
 CONFIG_SELECT_MEMORY_MODEL=y
-CONFIG_FLATMEM_MANUAL=y
-# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_FLATMEM_MANUAL is not set
+CONFIG_DISCONTIGMEM_MANUAL=y
 # CONFIG_SPARSEMEM_MANUAL is not set
-CONFIG_FLATMEM=y
+CONFIG_DISCONTIGMEM=y
 CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_NEED_MULTIPLE_NODES=y
 # CONFIG_SPARSEMEM_STATIC is not set
 CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_MIGRATION is not set
 CONFIG_RESOURCES_64BIT=y
 CONFIG_ARCH_SELECT_MEMORY_MODEL=y
 CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
 CONFIG_ARCH_FLATMEM_ENABLE=y
 CONFIG_ARCH_SPARSEMEM_ENABLE=y
-# CONFIG_VIRTUAL_MEM_MAP is not set
+CONFIG_ARCH_DISCONTIGMEM_DEFAULT=y
+CONFIG_NUMA=y
+CONFIG_NODES_SHIFT=10
+CONFIG_VIRTUAL_MEM_MAP=y
+CONFIG_HOLES_IN_ZONE=y
+CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y
+CONFIG_HAVE_ARCH_NODEDATA_EXTENSION=y
 # CONFIG_IA32_SUPPORT is not set
-CONFIG_IA64_MCA_RECOVERY=y
+# CONFIG_IA64_MCA_RECOVERY is not set
 CONFIG_PERFMON=y
 CONFIG_IA64_PALINFO=y
+CONFIG_SGI_SN=y
+
+#
+# SN Devices
+#
+# CONFIG_SGI_IOC3 is not set
 
 #
 # Firmware Drivers
@@ -172,6 +189,7 @@ CONFIG_ACPI_PROCESSOR=y
 CONFIG_ACPI_PROCESSOR=y
 CONFIG_ACPI_HOTPLUG_CPU=y
 CONFIG_ACPI_THERMAL=y
+CONFIG_ACPI_NUMA=y
 CONFIG_ACPI_BLACKLIST_YEAR=0
 # CONFIG_ACPI_DEBUG is not set
 CONFIG_ACPI_EC=y
@@ -203,6 +221,7 @@ CONFIG_HOTPLUG_PCI_ACPI=y
 # CONFIG_HOTPLUG_PCI_ACPI_IBM is not set
 # CONFIG_HOTPLUG_PCI_CPCI is not set
 # CONFIG_HOTPLUG_PCI_SHPC is not set
+# CONFIG_HOTPLUG_PCI_SGI is not set
 
 #
 # PCCARD (PCMCIA/CardBus) support
@@ -747,6 +766,8 @@ CONFIG_SERIAL_NONSTANDARD=y
 # CONFIG_SX is not set
 # CONFIG_RIO is not set
 # CONFIG_STALDRV is not set
+# CONFIG_SGI_SNSC is not set
+# CONFIG_SGI_TIOCX is not set
 
 #
 # Serial drivers
@@ -755,6 +776,7 @@ CONFIG_SERIAL_NONSTANDARD=y
 #
 # Non-8250 serial port support
 #
+# CONFIG_SERIAL_SGI_L1_CONSOLE is not set
 # CONFIG_SERIAL_JSM is not set
 CONFIG_UNIX98_PTYS=y
 CONFIG_LEGACY_PTYS=y
@@ -782,6 +804,8 @@ CONFIG_AGP=y
 # CONFIG_AGP_SIS is not set
 # CONFIG_AGP_VIA is not set
 CONFIG_AGP_I460=y
+# CONFIG_AGP_HP_ZX1 is not set
+# CONFIG_AGP_SGI_TIOCA is not set
 CONFIG_DRM=y
 # CONFIG_DRM_TDFX is not set
 # CONFIG_DRM_R128 is not set
@@ -793,6 +817,7 @@ CONFIG_DRM=y
 # CONFIG_RAW_DRIVER is not set
 # CONFIG_HPET is not set
 # CONFIG_HANGCHECK_TIMER is not set
+# CONFIG_MMTIMER is not set
 
 #
 # TPM devices
@@ -1541,6 +1566,13 @@ CONFIG_IRQ_PER_CPU=y
 CONFIG_IRQ_PER_CPU=y
 
 #
+# HP Simulator drivers
+#
+# CONFIG_HP_SIMETH is not set
+# CONFIG_HP_SIMSERIAL is not set
+# CONFIG_HP_SIMSCSI is not set
+
+#
 # Instrumentation Support
 #
 # CONFIG_PROFILING is not set
@@ -1615,9 +1647,6 @@ CONFIG_CRYPTO_DES=y
 #
 # Hardware crypto devices
 #
-# CONFIG_XEN_UTIL is not set
-CONFIG_XEN_BALLOON=y
-CONFIG_XEN_REBOOT=y
 # CONFIG_XEN_SMPBOOT is not set
 CONFIG_XEN_INTERFACE_VERSION=0x00030205
 
@@ -1650,8 +1679,6 @@ CONFIG_XEN_COMPAT_030002_AND_LATER=y
 CONFIG_XEN_COMPAT_030002_AND_LATER=y
 # CONFIG_XEN_COMPAT_030004_AND_LATER is not set
 # CONFIG_XEN_COMPAT_LATEST_ONLY is not set
-CONFIG_XEN_COMPAT_030002=y
-CONFIG_XEN_COMPAT_030004=y
+CONFIG_XEN_COMPAT=0x030002
 CONFIG_HAVE_IRQ_IGNORE_UNHANDLED=y
 CONFIG_NO_IDLE_HZ=y
-CONFIG_XEN_DEVMEM=y
diff -r 642a9bcaf19c linux-2.6-xen-sparse/arch/ia64/Kconfig
--- a/linux-2.6-xen-sparse/arch/ia64/Kconfig    Sun May 06 20:34:15 2007 -0600
+++ b/linux-2.6-xen-sparse/arch/ia64/Kconfig    Sun May 06 20:36:09 2007 -0600
@@ -160,6 +160,10 @@ config IA64_SGI_SN2
 
 config IA64_HP_SIM
        bool "Ski-simulator"
+
+config IA64_XEN
+       bool "Xen guest"
+       depends on XEN
 
 endchoice
 
diff -r 642a9bcaf19c linux-2.6-xen-sparse/arch/ia64/Makefile
--- a/linux-2.6-xen-sparse/arch/ia64/Makefile   Sun May 06 20:34:15 2007 -0600
+++ b/linux-2.6-xen-sparse/arch/ia64/Makefile   Sun May 06 22:27:43 2007 -0600
@@ -60,6 +60,7 @@ core-$(CONFIG_IA64_GENERIC)   += arch/ia6
 core-$(CONFIG_IA64_GENERIC)    += arch/ia64/dig/
 core-$(CONFIG_IA64_HP_ZX1)     += arch/ia64/dig/
 core-$(CONFIG_IA64_HP_ZX1_SWIOTLB) += arch/ia64/dig/
+core-$(CONFIG_IA64_XEN)                += arch/ia64/dig/
 core-$(CONFIG_IA64_SGI_SN2)    += arch/ia64/sn/
 core-$(CONFIG_XEN)             += arch/ia64/xen/
 
diff -r 642a9bcaf19c linux-2.6-xen-sparse/arch/ia64/hp/common/sba_iommu.c
--- a/linux-2.6-xen-sparse/arch/ia64/hp/common/sba_iommu.c      Sun May 06 
20:34:15 2007 -0600
+++ b/linux-2.6-xen-sparse/arch/ia64/hp/common/sba_iommu.c      Sun May 06 
20:36:16 2007 -0600
@@ -763,13 +763,14 @@ sba_free_range(struct ioc *ioc, dma_addr
  */
 
 #if 1
-#define sba_io_pdir_entry(pdir_ptr, vba) *pdir_ptr = ((vba & 
~0xE000000000000FFFULL)   \
-                                                     | 0x8000000000000000ULL)
+#define sba_io_pdir_entry(pdir_ptr, vba) *pdir_ptr =   \
+       ((virt_to_bus((void *)vba) & ~0xFFFULL) | 0x8000000000000000ULL)
 #else
 void SBA_INLINE
 sba_io_pdir_entry(u64 *pdir_ptr, unsigned long vba)
 {
-       *pdir_ptr = ((vba & ~0xE000000000000FFFULL) | 0x80000000000000FFULL);
+       *pdir_ptr = ((virt_to_bus((void *)vba) & ~0xFFFULL) |
+                   0x80000000000000FFULL);
 }
 #endif
 
@@ -783,6 +784,12 @@ mark_clean (void *addr, size_t size)
 mark_clean (void *addr, size_t size)
 {
        unsigned long pg_addr, end;
+
+#ifdef CONFIG_XEN
+       /* XXX: Bad things happen starting domUs when this is enabled. */
+       if (is_running_on_xen())
+               return;
+#endif
 
        pg_addr = PAGE_ALIGN((unsigned long) addr);
        end = (unsigned long) addr + size;
@@ -894,15 +901,14 @@ sba_map_single(struct device *dev, void 
        unsigned long flags;
 #endif
 #ifdef ALLOW_IOV_BYPASS
-       unsigned long pci_addr = virt_to_phys(addr);
-#endif
-
-#ifdef ALLOW_IOV_BYPASS
+       unsigned long pci_addr = virt_to_bus(addr);
+
        ASSERT(to_pci_dev(dev)->dma_mask);
        /*
        ** Check if the PCI device can DMA to ptr... if so, just return ptr
        */
-       if (likely((pci_addr & ~to_pci_dev(dev)->dma_mask) == 0)) {
+       if (likely(pci_addr & ~to_pci_dev(dev)->dma_mask) == 0 &&
+                  !range_straddles_page_boundary(addr, size)) {
                /*
                ** Device is bit capable of DMA'ing to the buffer...
                ** just return the PCI address of ptr
@@ -973,13 +979,13 @@ sba_mark_clean(struct ioc *ioc, dma_addr
        void    *addr;
 
        if (size <= iovp_size) {
-               addr = phys_to_virt(ioc->pdir_base[off] &
-                                   ~0xE000000000000FFFULL);
+               addr = bus_to_virt(ioc->pdir_base[off] &
+                                  ~0xE000000000000FFFULL);
                mark_clean(addr, size);
        } else {
                do {
-                       addr = phys_to_virt(ioc->pdir_base[off] &
-                                           ~0xE000000000000FFFULL);
+                       addr = bus_to_virt(ioc->pdir_base[off] &
+                                          ~0xE000000000000FFFULL);
                        mark_clean(addr, min(size, iovp_size));
                        off++;
                        size -= iovp_size;
@@ -1018,7 +1024,7 @@ void sba_unmap_single(struct device *dev
 
 #ifdef ENABLE_MARK_CLEAN
                if (dir == DMA_FROM_DEVICE) {
-                       mark_clean(phys_to_virt(iova), size);
+                       mark_clean(bus_to_virt(iova), size);
                }
 #endif
                return;
@@ -1102,9 +1108,14 @@ sba_alloc_coherent (struct device *dev, 
                return NULL;
 
        memset(addr, 0, size);
-       *dma_handle = virt_to_phys(addr);
 
 #ifdef ALLOW_IOV_BYPASS
+#ifdef CONFIG_XEN
+       if (xen_create_contiguous_region((unsigned long)addr, get_order(size),
+                                        fls64(dev->coherent_dma_mask)))
+               goto iommu_map;
+#endif
+       *dma_handle = virt_to_bus(addr);
        ASSERT(dev->coherent_dma_mask);
        /*
        ** Check if the PCI device can DMA to ptr... if so, just return ptr
@@ -1115,6 +1126,9 @@ sba_alloc_coherent (struct device *dev, 
 
                return addr;
        }
+#ifdef CONFIG_XEN
+iommu_map:
+#endif
 #endif
 
        /*
@@ -1138,6 +1152,13 @@ sba_alloc_coherent (struct device *dev, 
  */
 void sba_free_coherent (struct device *dev, size_t size, void *vaddr, 
dma_addr_t dma_handle)
 {
+#if defined(ALLOW_IOV_BYPASS) && defined(CONFIG_XEN)
+       struct ioc *ioc = GET_IOC(dev);
+
+       if (likely((dma_handle & ioc->imask) != ioc->ibase))
+               xen_destroy_contiguous_region((unsigned long)vaddr,
+                                             get_order(size));
+#endif
        sba_unmap_single(dev, dma_handle, size, 0);
        free_pages((unsigned long) vaddr, get_order(size));
 }
@@ -1406,7 +1427,7 @@ int sba_map_sg(struct device *dev, struc
        if (likely((ioc->dma_mask & ~to_pci_dev(dev)->dma_mask) == 0)) {
                for (sg = sglist ; filled < nents ; filled++, sg++){
                        sg->dma_length = sg->length;
-                       sg->dma_address = virt_to_phys(sba_sg_address(sg));
+                       sg->dma_address = virt_to_bus(sba_sg_address(sg));
                }
                return filled;
        }
@@ -1560,13 +1581,19 @@ ioc_iova_init(struct ioc *ioc)
        if (!ioc->pdir_base)
                panic(PFX "Couldn't allocate I/O Page Table\n");
 
+#ifdef CONFIG_XEN
+       /* The page table needs to be pinned in Xen memory */
+       if (xen_create_contiguous_region((unsigned long)ioc->pdir_base,
+                                        get_order(ioc->pdir_size), 0))
+               panic(PFX "Couldn't contiguously map I/O Page Table\n");
+#endif
        memset(ioc->pdir_base, 0, ioc->pdir_size);
 
        DBG_INIT("%s() IOV page size %ldK pdir %p size %x\n", __FUNCTION__,
                iovp_size >> 10, ioc->pdir_base, ioc->pdir_size);
 
        ASSERT(ALIGN((unsigned long) ioc->pdir_base, 4*1024) == (unsigned long) 
ioc->pdir_base);
-       WRITE_REG(virt_to_phys(ioc->pdir_base), ioc->ioc_hpa + IOC_PDIR_BASE);
+       WRITE_REG(virt_to_bus(ioc->pdir_base), ioc->ioc_hpa + IOC_PDIR_BASE);
 
        /*
        ** If an AGP device is present, only use half of the IOV space
@@ -1603,7 +1630,7 @@ ioc_iova_init(struct ioc *ioc)
                for ( ; (u64) poison_addr < addr + iovp_size; poison_addr += 
poison_size)
                        memcpy(poison_addr, spill_poison, poison_size);
 
-               prefetch_spill_page = virt_to_phys(addr);
+               prefetch_spill_page = virt_to_bus(addr);
 
                DBG_INIT("%s() prefetch spill addr: 0x%lx\n", __FUNCTION__, 
prefetch_spill_page);
        }
diff -r 642a9bcaf19c linux-2.6-xen-sparse/arch/ia64/kernel/acpi.c
--- a/linux-2.6-xen-sparse/arch/ia64/kernel/acpi.c      Sun May 06 20:34:15 
2007 -0600
+++ b/linux-2.6-xen-sparse/arch/ia64/kernel/acpi.c      Sun May 06 22:30:57 
2007 -0600
@@ -109,6 +109,10 @@ const char *acpi_get_sysname(void)
                return "hpzx1";
        } else if (!strcmp(hdr->oem_id, "SGI")) {
                return "sn2";
+#ifdef CONFIG_XEN
+       } else if (is_running_on_xen() && !strcmp(hdr->oem_id, "XEN")) {
+               return "xen";
+#endif
        }
 
        return "dig";
@@ -123,6 +127,8 @@ const char *acpi_get_sysname(void)
        return "sn2";
 # elif defined (CONFIG_IA64_DIG)
        return "dig";
+# elif defined (CONFIG_IA64_XEN)
+       return "xen";
 # else
 #      error Unknown platform.  Fix acpi.c.
 # endif
diff -r 642a9bcaf19c linux-2.6-xen-sparse/arch/ia64/xen/Makefile
--- a/linux-2.6-xen-sparse/arch/ia64/xen/Makefile       Sun May 06 20:34:15 
2007 -0600
+++ b/linux-2.6-xen-sparse/arch/ia64/xen/Makefile       Sun May 06 20:36:09 
2007 -0600
@@ -3,7 +3,7 @@
 #
 
 obj-y := hypercall.o xenivt.o xenentry.o xensetup.o xenpal.o xenhpski.o \
-        hypervisor.o pci-dma-xen.o util.o xencomm.o xcom_hcall.o \
-        xcom_mini.o xcom_privcmd.o mem.o
+        hypervisor.o util.o xencomm.o xcom_hcall.o xcom_mini.o \
+        xcom_privcmd.o mem.o xen_dma.o
 
-pci-dma-xen-y := ../../i386/kernel/pci-dma-xen.o
+obj-$(CONFIG_IA64_GENERIC) += machvec.o
diff -r 642a9bcaf19c linux-2.6-xen-sparse/arch/ia64/xen/machvec.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/linux-2.6-xen-sparse/arch/ia64/xen/machvec.c      Sun May 06 20:36:16 
2007 -0600
@@ -0,0 +1,4 @@
+#define MACHVEC_PLATFORM_NAME           xen
+#define MACHVEC_PLATFORM_HEADER         <asm/machvec_xen.h>
+#include <asm/machvec_init.h>
+
diff -r 642a9bcaf19c linux-2.6-xen-sparse/arch/ia64/xen/swiotlb.c
--- a/linux-2.6-xen-sparse/arch/ia64/xen/swiotlb.c      Sun May 06 20:34:15 
2007 -0600
+++ b/linux-2.6-xen-sparse/arch/ia64/xen/swiotlb.c      Sun May 06 20:36:16 
2007 -0600
@@ -32,11 +32,22 @@
 #include <linux/init.h>
 #include <linux/bootmem.h>
 
+#ifdef CONFIG_XEN
+/*
+ * What DMA mask should Xen use to remap the bounce buffer pool?  Most
+ * reports seem to indicate 30 bits is sufficient, except maybe for old
+ * sound cards that we probably don't care about anyway.  If we need to,
+ * we could put in some smarts to try to lower, but hopefully it's not
+ * necessary.
+ */
+#define DMA_BITS       (30)
+#endif
+
 #define OFFSET(val,align) ((unsigned long)     \
                           ( (val) & ( (align) - 1)))
 
 #define SG_ENT_VIRT_ADDRESS(sg)        (page_address((sg)->page) + 
(sg)->offset)
-#define SG_ENT_PHYS_ADDRESS(SG)        virt_to_phys(SG_ENT_VIRT_ADDRESS(SG))
+#define SG_ENT_PHYS_ADDRESS(SG)        virt_to_bus(SG_ENT_VIRT_ADDRESS(SG))
 
 /*
  * Maximum allowable number of contiguous slabs to map,
@@ -139,6 +150,10 @@ swiotlb_init_with_default_size (size_t d
                io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
        }
 
+#ifdef CONFIG_XEN
+       if (is_running_on_xen())
+               io_tlb_nslabs = roundup_pow_of_two(io_tlb_nslabs);
+#endif
        /*
         * Get IO TLB memory from the low pages
         */
@@ -146,6 +161,17 @@ swiotlb_init_with_default_size (size_t d
        if (!io_tlb_start)
                panic("Cannot allocate SWIOTLB buffer");
        io_tlb_end = io_tlb_start + io_tlb_nslabs * (1 << IO_TLB_SHIFT);
+
+#ifdef CONFIG_XEN
+       for (i = 0 ; i < io_tlb_nslabs ; i += IO_TLB_SEGSIZE) {
+               if (xen_create_contiguous_region(
+                               (unsigned long)io_tlb_start +
+                               (i << IO_TLB_SHIFT),
+                               get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT),
+                               DMA_BITS))
+                       panic("Failed to setup Xen contiguous region");
+       }
+#endif
 
        /*
         * Allocate and initialize the free list array.  This array is used
@@ -162,6 +188,11 @@ swiotlb_init_with_default_size (size_t d
         * Get the overflow emergency buffer
         */
        io_tlb_overflow_buffer = alloc_bootmem_low(io_tlb_overflow);
+#ifdef CONFIG_XEN
+       if (xen_create_contiguous_region((unsigned long)io_tlb_overflow_buffer,
+                                        get_order(io_tlb_overflow), DMA_BITS))
+               panic("Failed to setup Xen contiguous region for overflow");
+#endif
        printk(KERN_INFO "Placing software IO TLB between 0x%lx - 0x%lx\n",
               virt_to_phys(io_tlb_start), virt_to_phys(io_tlb_end));
 }
@@ -188,6 +219,10 @@ swiotlb_late_init_with_default_size (siz
                io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
        }
 
+#ifdef CONFIG_XEN
+       if (is_running_on_xen())
+               io_tlb_nslabs = roundup_pow_of_two(io_tlb_nslabs);
+#endif
        /*
         * Get IO TLB memory from the low pages
         */
@@ -213,6 +248,16 @@ swiotlb_late_init_with_default_size (siz
        io_tlb_end = io_tlb_start + io_tlb_nslabs * (1 << IO_TLB_SHIFT);
        memset(io_tlb_start, 0, io_tlb_nslabs * (1 << IO_TLB_SHIFT));
 
+#ifdef CONFIG_XEN
+       for (i = 0 ; i < io_tlb_nslabs ; i += IO_TLB_SEGSIZE) {
+               if (xen_create_contiguous_region(
+                               (unsigned long)io_tlb_start +
+                               (i << IO_TLB_SHIFT),
+                               get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT),
+                               DMA_BITS))
+                       panic("Failed to setup Xen contiguous region");
+       }
+#endif
        /*
         * Allocate and initialize the free list array.  This array is used
         * to find contiguous free memory regions of size up to IO_TLB_SEGSIZE
@@ -242,6 +287,11 @@ swiotlb_late_init_with_default_size (siz
        if (!io_tlb_overflow_buffer)
                goto cleanup4;
 
+#ifdef CONFIG_XEN
+       if (xen_create_contiguous_region((unsigned long)io_tlb_overflow_buffer,
+                                        get_order(io_tlb_overflow), DMA_BITS))
+               panic("Failed to setup Xen contiguous region for overflow");
+#endif
        printk(KERN_INFO "Placing %ldMB software IO TLB between 0x%lx - "
               "0x%lx\n", (io_tlb_nslabs * (1 << IO_TLB_SHIFT)) >> 20,
               virt_to_phys(io_tlb_start), virt_to_phys(io_tlb_end));
@@ -445,7 +495,25 @@ swiotlb_alloc_coherent(struct device *hw
        flags |= GFP_DMA;
 
        ret = (void *)__get_free_pages(flags, order);
-       if (ret && address_needs_mapping(hwdev, virt_to_phys(ret))) {
+#ifdef CONFIG_XEN
+       if (ret && is_running_on_xen()) {
+               if (xen_create_contiguous_region((unsigned long)ret, order,
+                                       fls64(hwdev->coherent_dma_mask))) {
+                       free_pages((unsigned long)ret, order);
+                       ret = NULL;
+               } else {
+                       /*
+                        * Short circuit the rest, xen_create_contiguous_region
+                        * should fail if it didn't give us an address within
+                        * the mask requested.  
+                        */
+                       memset(ret, 0, size);
+                       *dma_handle = virt_to_bus(ret);
+                       return ret;
+               }
+       }
+#endif
+       if (ret && address_needs_mapping(hwdev, virt_to_bus(ret))) {
                /*
                 * The allocated memory isn't reachable by the device.
                 * Fall back on swiotlb_map_single().
@@ -465,11 +533,11 @@ swiotlb_alloc_coherent(struct device *hw
                if (swiotlb_dma_mapping_error(handle))
                        return NULL;
 
-               ret = phys_to_virt(handle);
+               ret = bus_to_virt(handle);
        }
 
        memset(ret, 0, size);
-       dev_addr = virt_to_phys(ret);
+       dev_addr = virt_to_bus(ret);
 
        /* Confirm address can be DMA'd by device */
        if (address_needs_mapping(hwdev, dev_addr)) {
@@ -487,9 +555,13 @@ swiotlb_free_coherent(struct device *hwd
                      dma_addr_t dma_handle)
 {
        if (!(vaddr >= (void *)io_tlb_start
-                    && vaddr < (void *)io_tlb_end))
+                    && vaddr < (void *)io_tlb_end)) {
+#ifdef CONFIG_XEN
+               xen_destroy_contiguous_region((unsigned long)vaddr,
+                                             get_order(size));
+#endif
                free_pages((unsigned long) vaddr, get_order(size));
-       else
+       } else
                /* DMA_TO_DEVICE to avoid memcpy in unmap_single */
                swiotlb_unmap_single (hwdev, dma_handle, size, DMA_TO_DEVICE);
 }
@@ -525,7 +597,7 @@ dma_addr_t
 dma_addr_t
 swiotlb_map_single(struct device *hwdev, void *ptr, size_t size, int dir)
 {
-       unsigned long dev_addr = virt_to_phys(ptr);
+       unsigned long dev_addr = virt_to_bus(ptr);
        void *map;
 
        BUG_ON(dir == DMA_NONE);
@@ -534,7 +606,8 @@ swiotlb_map_single(struct device *hwdev,
         * we can safely return the device addr and not worry about bounce
         * buffering it.
         */
-       if (!address_needs_mapping(hwdev, dev_addr) && !swiotlb_force)
+       if (!range_straddles_page_boundary(ptr, size) &&
+           !address_needs_mapping(hwdev, dev_addr) && !swiotlb_force)
                return dev_addr;
 
        /*
@@ -546,7 +619,7 @@ swiotlb_map_single(struct device *hwdev,
                map = io_tlb_overflow_buffer;
        }
 
-       dev_addr = virt_to_phys(map);
+       dev_addr = virt_to_bus(map);
 
        /*
         * Ensure that the address returned is DMA'ble
@@ -566,6 +639,12 @@ mark_clean(void *addr, size_t size)
 mark_clean(void *addr, size_t size)
 {
        unsigned long pg_addr, end;
+
+#ifdef CONFIG_XEN
+       /* XXX: Bad things happen when starting domUs if this is enabled. */
+       if (is_running_on_xen())
+               return;
+#endif
 
        pg_addr = PAGE_ALIGN((unsigned long) addr);
        end = (unsigned long) addr + size;
@@ -588,7 +667,7 @@ swiotlb_unmap_single(struct device *hwde
 swiotlb_unmap_single(struct device *hwdev, dma_addr_t dev_addr, size_t size,
                     int dir)
 {
-       char *dma_addr = phys_to_virt(dev_addr);
+       char *dma_addr = bus_to_virt(dev_addr);
 
        BUG_ON(dir == DMA_NONE);
        if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end)
@@ -611,7 +690,7 @@ swiotlb_sync_single(struct device *hwdev
 swiotlb_sync_single(struct device *hwdev, dma_addr_t dev_addr,
                    size_t size, int dir, int target)
 {
-       char *dma_addr = phys_to_virt(dev_addr);
+       char *dma_addr = bus_to_virt(dev_addr);
 
        BUG_ON(dir == DMA_NONE);
        if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end)
@@ -642,7 +721,7 @@ swiotlb_sync_single_range(struct device 
                          unsigned long offset, size_t size,
                          int dir, int target)
 {
-       char *dma_addr = phys_to_virt(dev_addr) + offset;
+       char *dma_addr = bus_to_virt(dev_addr) + offset;
 
        BUG_ON(dir == DMA_NONE);
        if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end)
@@ -695,7 +774,7 @@ swiotlb_map_sg(struct device *hwdev, str
 
        for (i = 0; i < nelems; i++, sg++) {
                addr = SG_ENT_VIRT_ADDRESS(sg);
-               dev_addr = virt_to_phys(addr);
+               dev_addr = virt_to_bus(addr);
                if (swiotlb_force || address_needs_mapping(hwdev, dev_addr)) {
                        void *map = map_single(hwdev, addr, sg->length, dir);
                        sg->dma_address = virt_to_bus(map);
@@ -728,7 +807,7 @@ swiotlb_unmap_sg(struct device *hwdev, s
 
        for (i = 0; i < nelems; i++, sg++)
                if (sg->dma_address != SG_ENT_PHYS_ADDRESS(sg))
-                       unmap_single(hwdev, (void *) 
phys_to_virt(sg->dma_address), sg->dma_length, dir);
+                       unmap_single(hwdev, (void *) 
bus_to_virt(sg->dma_address), sg->dma_length, dir);
                else if (dir == DMA_FROM_DEVICE)
                        mark_clean(SG_ENT_VIRT_ADDRESS(sg), sg->dma_length);
 }
@@ -771,7 +850,7 @@ int
 int
 swiotlb_dma_mapping_error(dma_addr_t dma_addr)
 {
-       return (dma_addr == virt_to_phys(io_tlb_overflow_buffer));
+       return (dma_addr == virt_to_bus(io_tlb_overflow_buffer));
 }
 
 /*
@@ -783,7 +862,7 @@ int
 int
 swiotlb_dma_supported (struct device *hwdev, u64 mask)
 {
-       return (virt_to_phys (io_tlb_end) - 1) <= mask;
+       return (virt_to_bus(io_tlb_end) - 1) <= mask;
 }
 
 EXPORT_SYMBOL(swiotlb_init);
diff -r 642a9bcaf19c linux-2.6-xen-sparse/arch/ia64/xen/xen_dma.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/linux-2.6-xen-sparse/arch/ia64/xen/xen_dma.c      Sun May 06 22:11:49 
2007 -0600
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2007 Hewlett-Packard Development Company, L.P.
+ *     Alex Williamson <alex.williamson@xxxxxx>
+ *
+ * Basic DMA mapping services for Xen guests.
+ * Based on arch/i386/kernel/pci-dma-xen.c.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#include <linux/dma-mapping.h>
+#include <linux/mm.h>
+#include <asm/scatterlist.h>
+
+#define IOMMU_BUG_ON(test)                                     \
+do {                                                           \
+       if (unlikely(test)) {                                   \
+               printk(KERN_ALERT "Fatal DMA error!\n");        \
+               BUG();                                          \
+       }                                                       \
+} while (0)
+
+
+/*
+ * This should be broken out of swiotlb and put in a common place
+ * when merged with upstream Linux.
+ */
+static inline int
+address_needs_mapping(struct device *hwdev, dma_addr_t addr)
+{
+       dma_addr_t mask = 0xffffffff;
+
+       /* If the device has a mask, use it, otherwise default to 32 bits */
+       if (hwdev && hwdev->dma_mask)
+               mask = *hwdev->dma_mask;
+       return (addr & ~mask) != 0;
+}
+
+int
+xen_map_sg(struct device *hwdev, struct scatterlist *sg, int nents,
+          int direction)
+{
+       int i;
+
+       for (i = 0 ; i < nents ; i++) {
+               sg[i].dma_address = page_to_bus(sg[i].page) + sg[i].offset;
+               sg[i].dma_length  = sg[i].length;
+
+               IOMMU_BUG_ON(address_needs_mapping(hwdev, sg[i].dma_address));
+       }
+
+       return nents;
+}
+EXPORT_SYMBOL(xen_map_sg);
+
+void
+xen_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents,
+            int direction)
+{
+}
+EXPORT_SYMBOL(xen_unmap_sg);
+
+int
+xen_dma_mapping_error(dma_addr_t dma_addr)
+{
+       return 0;
+}
+EXPORT_SYMBOL(xen_dma_mapping_error);
+
+int
+xen_dma_supported(struct device *dev, u64 mask)
+{
+       return 1;
+}
+EXPORT_SYMBOL(xen_dma_supported);
+
+void *
+xen_alloc_coherent(struct device *dev, size_t size,
+                  dma_addr_t *dma_handle, gfp_t gfp)
+{
+       unsigned long vaddr;
+       unsigned int order = get_order(size);
+
+       vaddr = __get_free_pages(gfp, order);
+
+       if (!vaddr)
+               return NULL;
+
+       if (xen_create_contiguous_region(vaddr, order,
+                                        dev->coherent_dma_mask)) {
+               free_pages(vaddr, order);
+               return NULL;
+       }
+
+       memset((void *)vaddr, 0, size);
+       *dma_handle = virt_to_bus((void *)vaddr);
+
+       return (void *)vaddr;
+}
+EXPORT_SYMBOL(xen_alloc_coherent);
+
+void
+xen_free_coherent(struct device *dev, size_t size,
+                     void *vaddr, dma_addr_t dma_handle)
+{
+       unsigned int order =  get_order(size);
+
+       xen_destroy_contiguous_region((unsigned long)vaddr, order);
+       free_pages((unsigned long)vaddr, order);
+}
+EXPORT_SYMBOL(xen_free_coherent);
+
+dma_addr_t
+xen_map_single(struct device *dev, void *ptr, size_t size,
+              int direction)
+{
+       dma_addr_t dma_addr = virt_to_bus(ptr);
+
+       IOMMU_BUG_ON(range_straddles_page_boundary(ptr, size));
+       IOMMU_BUG_ON(address_needs_mapping(dev, dma_addr));
+
+       return dma_addr;
+}
+EXPORT_SYMBOL(xen_map_single);
+
+void
+xen_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
+                int direction)
+{
+}
+EXPORT_SYMBOL(xen_unmap_single);
diff -r 642a9bcaf19c linux-2.6-xen-sparse/include/asm-ia64/dma-mapping.h
--- a/linux-2.6-xen-sparse/include/asm-ia64/dma-mapping.h       Sun May 06 
20:34:15 2007 -0600
+++ b/linux-2.6-xen-sparse/include/asm-ia64/dma-mapping.h       Sun May 06 
20:36:09 2007 -0600
@@ -13,7 +13,6 @@
 #include <asm/swiotlb.h>
 #endif
 
-#ifndef CONFIG_XEN
 #define dma_alloc_coherent     platform_dma_alloc_coherent
 #define dma_alloc_noncoherent  platform_dma_alloc_coherent     /* coherent 
mem. is cheap */
 #define dma_free_coherent      platform_dma_free_coherent
@@ -27,47 +26,6 @@
 #define dma_sync_single_for_device platform_dma_sync_single_for_device
 #define dma_sync_sg_for_device platform_dma_sync_sg_for_device
 #define dma_mapping_error      platform_dma_mapping_error
-#else
-int dma_map_sg(struct device *hwdev, struct scatterlist *sg, int nents,
-               enum dma_data_direction direction);
-void dma_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents,
-                  enum dma_data_direction direction);
-int dma_supported(struct device *dev, u64 mask);
-void *dma_alloc_coherent(struct device *dev, size_t size,
-                         dma_addr_t *dma_handle, gfp_t gfp);
-void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
-                       dma_addr_t dma_handle);
-dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
-                          enum dma_data_direction direction);
-void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
-                      enum dma_data_direction direction);
-void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,
-                             size_t size, enum dma_data_direction direction);
-void dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle,
-                                size_t size,
-                                enum dma_data_direction direction);
-int dma_mapping_error(dma_addr_t dma_addr);
-
-#define flush_write_buffers()  do { } while (0)
-static inline void
-dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
-                    enum dma_data_direction direction)
-{
-       if (swiotlb)
-               swiotlb_sync_sg_for_cpu(dev,sg,nelems,direction);
-       flush_write_buffers();
-}
-
-static inline void
-dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
-                       enum dma_data_direction direction)
-{
-       if (swiotlb)
-               swiotlb_sync_sg_for_device(dev,sg,nelems,direction);
-       flush_write_buffers();
-}
-#endif
-
 #define dma_map_page(dev, pg, off, size, dir)                          \
        dma_map_single(dev, page_address(pg) + (off), (size), (dir))
 #define dma_unmap_page(dev, dma_addr, size, dir)                       \
@@ -83,9 +41,7 @@ dma_sync_sg_for_device(struct device *de
 #define dma_sync_single_range_for_device(dev, dma_handle, offset, size, dir)   
\
        dma_sync_single_for_device(dev, dma_handle, size, dir)
 
-#ifndef CONFIG_XEN
 #define dma_supported          platform_dma_supported
-#endif
 
 static inline int
 dma_set_mask (struct device *dev, u64 mask)
@@ -111,26 +67,19 @@ dma_cache_sync (void *vaddr, size_t size
 #define dma_is_consistent(dma_handle)  (1)     /* all we do is coherent 
memory... */
 
 #ifdef CONFIG_XEN
-/* arch/i386/kernel/swiotlb.o requires */
-void contiguous_bitmap_init(unsigned long end_pfn);
-
-static inline int
-address_needs_mapping(struct device *hwdev, dma_addr_t addr)
-{
-       dma_addr_t mask = DMA_64BIT_MASK;
-       /* If the device has a mask, use it, otherwise default to 64 bits */
-       if (hwdev && hwdev->dma_mask)
-               mask = *hwdev->dma_mask;
-       return (addr & ~mask) != 0;
-}
-
 static inline int
 range_straddles_page_boundary(void *p, size_t size)
 {
        extern unsigned long *contiguous_bitmap;
+
+       if (!is_running_on_xen())
+               return 0;
+
        return (((((unsigned long)p & ~PAGE_MASK) + size) > PAGE_SIZE) &&
                !test_bit(__pa(p) >> PAGE_SHIFT, contiguous_bitmap));
 }
+#else
+#define range_straddles_page_boundary(addr, size)      (0)
 #endif
 
 #endif /* _ASM_IA64_DMA_MAPPING_H */
diff -r 642a9bcaf19c linux-2.6-xen-sparse/include/asm-ia64/machvec.h
--- a/linux-2.6-xen-sparse/include/asm-ia64/machvec.h   Sun May 06 20:34:15 
2007 -0600
+++ b/linux-2.6-xen-sparse/include/asm-ia64/machvec.h   Sun May 06 20:36:16 
2007 -0600
@@ -108,6 +108,8 @@ extern void machvec_tlb_migrate_finish (
 #  include <asm/machvec_hpzx1_swiotlb.h>
 # elif defined (CONFIG_IA64_SGI_SN2)
 #  include <asm/machvec_sn2.h>
+# elif defined (CONFIG_IA64_XEN)
+#  include <asm/machvec_xen.h>
 # elif defined (CONFIG_IA64_GENERIC)
 
 # ifdef MACHVEC_PLATFORM_HEADER
diff -r 642a9bcaf19c linux-2.6-xen-sparse/include/asm-ia64/machvec_dig.h
--- a/linux-2.6-xen-sparse/include/asm-ia64/machvec_dig.h       Sun May 06 
20:34:15 2007 -0600
+++ b/linux-2.6-xen-sparse/include/asm-ia64/machvec_dig.h       Sun May 06 
20:36:09 2007 -0600
@@ -13,19 +13,4 @@ extern ia64_mv_setup_t dig_setup;
 #define platform_name          "dig"
 #define platform_setup         dig_setup
 
-#ifdef CONFIG_XEN
-# define platform_dma_map_sg           dma_map_sg
-# define platform_dma_unmap_sg         dma_unmap_sg
-# define platform_dma_mapping_error    dma_mapping_error
-# define platform_dma_supported                dma_supported
-# define platform_dma_alloc_coherent   dma_alloc_coherent
-# define platform_dma_free_coherent    dma_free_coherent
-# define platform_dma_map_single       dma_map_single
-# define platform_dma_unmap_single     dma_unmap_single
-# define platform_dma_sync_single_for_cpu \
-                                       dma_sync_single_for_cpu
-# define platform_dma_sync_single_for_device \
-                                       dma_sync_single_for_device
-#endif
-
 #endif /* _ASM_IA64_MACHVEC_DIG_h */
diff -r 642a9bcaf19c linux-2.6-xen-sparse/include/asm-ia64/machvec_xen.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/linux-2.6-xen-sparse/include/asm-ia64/machvec_xen.h       Sun May 06 
20:36:16 2007 -0600
@@ -0,0 +1,37 @@
+#ifndef _ASM_IA64_MACHVEC_XEN_h
+#define _ASM_IA64_MACHVEC_XEN_h
+
+extern ia64_mv_setup_t                 dig_setup;
+extern ia64_mv_dma_alloc_coherent      xen_alloc_coherent;
+extern ia64_mv_dma_free_coherent       xen_free_coherent;
+extern ia64_mv_dma_map_single          xen_map_single;
+extern ia64_mv_dma_unmap_single                xen_unmap_single;
+extern ia64_mv_dma_map_sg              xen_map_sg;
+extern ia64_mv_dma_unmap_sg            xen_unmap_sg;
+extern ia64_mv_dma_supported           xen_dma_supported;
+extern ia64_mv_dma_mapping_error       xen_dma_mapping_error;
+
+/*
+ * This stuff has dual use!
+ *
+ * For a generic kernel, the macros are used to initialize the
+ * platform's machvec structure.  When compiling a non-generic kernel,
+ * the macros are used directly.
+ */
+#define platform_name                          "xen"
+#define platform_setup                         dig_setup
+#define platform_dma_init                      machvec_noop
+#define platform_dma_alloc_coherent            xen_alloc_coherent
+#define platform_dma_free_coherent             xen_free_coherent
+#define platform_dma_map_single                        xen_map_single
+#define platform_dma_unmap_single              xen_unmap_single
+#define platform_dma_map_sg                    xen_map_sg
+#define platform_dma_unmap_sg                  xen_unmap_sg
+#define platform_dma_sync_single_for_cpu       machvec_dma_sync_single
+#define platform_dma_sync_sg_for_cpu           machvec_dma_sync_sg
+#define platform_dma_sync_single_for_device    machvec_dma_sync_single
+#define platform_dma_sync_sg_for_device                machvec_dma_sync_sg
+#define platform_dma_supported                 xen_dma_supported
+#define platform_dma_mapping_error             xen_dma_mapping_error
+
+#endif /* _ASM_IA64_MACHVEC_XEN_h */
diff -r 642a9bcaf19c linux-2.6-xen-sparse/include/xen/pcifront.h
--- a/linux-2.6-xen-sparse/include/xen/pcifront.h       Sun May 06 20:34:15 
2007 -0600
+++ b/linux-2.6-xen-sparse/include/xen/pcifront.h       Sun May 06 21:30:53 
2007 -0600
@@ -62,6 +62,7 @@ static inline void pcifront_init_sd(stru
        sd->segment = domain;
        sd->acpi_handle = NULL;
        sd->iommu = NULL;
+       sd->node = -1;
        sd->windows = 0;
        sd->window = NULL;
        sd->platform_data = pdev;
diff -r 642a9bcaf19c linux-2.6-xen-sparse/lib/Makefile
--- a/linux-2.6-xen-sparse/lib/Makefile Sun May 06 20:34:15 2007 -0600
+++ b/linux-2.6-xen-sparse/lib/Makefile Sun May 06 20:36:09 2007 -0600
@@ -52,7 +52,12 @@ obj-$(CONFIG_AUDIT_GENERIC) += audit.o
 obj-$(CONFIG_AUDIT_GENERIC) += audit.o
 
 obj-$(CONFIG_SWIOTLB) += swiotlb.o
+ifeq ($(CONFIG_X86),y)
 swiotlb-$(CONFIG_XEN) := ../arch/i386/kernel/swiotlb.o
+endif
+ifeq ($(CONFIG_IA64),y)
+swiotlb-$(CONFIG_XEN) := ../arch/ia64/xen/swiotlb.o
+endif
 
 hostprogs-y    := gen_crc32table
 clean-files    := crc32table.h



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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-ia64-devel] [PATCH] sparse tree machine vector support, Alex Williamson <=