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

[Xen-devel] Support for AGP aperture as IOMMU in AMD64 mode [2/2]

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] Support for AGP aperture as IOMMU in AMD64 mode [2/2]
From: "Langsdorf, Mark" <mark.langsdorf@xxxxxxx>
Date: Mon, 16 Jan 2006 17:50:30 -0600
Delivery-date: Mon, 16 Jan 2006 23:58:05 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcYa96JKHFLu6OCsSVOFgPFHmm8hGg==
Thread-topic: Support for AGP aperture as IOMMU in AMD64 mode [2/2]
These are the diffs against the pristine versions of
arch/x86_64/kernel/[aperture.c,pci-gart.c] to better
show the changes necessary to adapt those files to
Xen.

They were included with the patch and should not be
applied again.

-Mark Langsdorf
AMD, Inc.

--- pristine-linux-2.6.12/arch/x86_64/kernel/aperture.c 2005-06-17
12:48:29.000000000 -0700
+++ linux-2.6-xen-sparse/arch/xen/x86_64/kernel/aperture.c
2006-01-12 10:53:17.000000000 -0800
@@ -83,7 +83,7 @@
                printk("Aperture from %s beyond 4GB. Ignoring.\n",name);
                return 0; 
        }
-       if (e820_mapped(aper_base, aper_base + aper_size, E820_RAM)) {  
+       if (0 && e820_mapped(aper_base, aper_base + aper_size,
E820_RAM)) {  
                printk("Aperture from %s pointing to e820 RAM.
Ignoring.\n",name);
                return 0; 
        } 
--- pristine-linux-2.6.12/arch/x86_64/kernel/pci-gart.c 2005-06-17
12:48:29.000000000 -0700
+++ linux-2.6-xen-sparse/arch/xen/x86_64/kernel/pci-gart.c
2006-01-16 14:32:15.000000000 -0800
@@ -30,6 +30,7 @@
 #include <asm/proto.h>
 #include <asm/cacheflush.h>
 #include <asm/kdebug.h>
+#include <asm-xen/xen-public/memory.h>
 
 dma_addr_t bad_dma_address;
 
@@ -39,6 +40,11 @@
 
 u32 *iommu_gatt_base;          /* Remapping table */
 
+/* gart remapping */
+#define virt_to_gart(x) (phys_to_gart(virt_to_phys(x)))
+#define gart_to_virt(x) (phys_to_virt(gart_to_phys(x)))
+#include <asm-xen/asm-i386/agp.h>
+
 int no_iommu; 
 static int no_agp; 
 #ifdef CONFIG_IOMMU_DEBUG
@@ -416,7 +422,7 @@
        if (!dev)
                dev = &fallback_dev;
 
-       phys_mem = virt_to_phys(addr); 
+       phys_mem = virt_to_bus(addr);
        if (!need_iommu(dev, phys_mem, size))
                return phys_mem; 
 
@@ -721,6 +727,7 @@
        unsigned aper_size, gatt_size, new_aper_size;
        
        printk(KERN_INFO "PCI-DMA: Disabling AGP.\n");
+
        aper_size = aper_base = info->aper_size = 0;
        for_all_nb(dev) { 
                new_aper_base = read_aperture(dev, &new_aper_size); 
@@ -740,17 +747,20 @@
        info->aper_size = aper_size>>20; 
 
        gatt_size = (aper_size >> PAGE_SHIFT) * sizeof(u32); 
-       gatt = (void *)__get_free_pages(GFP_KERNEL,
get_order(gatt_size)); 
+       gatt = (void *) alloc_gatt_pages(get_order(gatt_size));
        if (!gatt) 
                panic("Cannot allocate GATT table"); 
        memset(gatt, 0, gatt_size); 
-       agp_gatt_table = gatt;
+       if (!agp_gatt_table)
+               agp_gatt_table = gatt;
+       else
+               goto nommu;
        
        for_all_nb(dev) { 
                u32 ctl; 
                u32 gatt_reg; 
 
-               gatt_reg = __pa(gatt) >> 12; 
+               gatt_reg = (0xffffffff & virt_to_gart(gatt)) >> 12;
                gatt_reg <<= 4; 
                pci_write_config_dword(dev, 0x98, gatt_reg);
                pci_read_config_dword(dev, 0x90, &ctl); 
@@ -782,6 +792,7 @@
        struct pci_dev *dev;
        unsigned long scratch;
        long i;
+       long ram_end = HYPERVISOR_memory_op(XENMEM_maximum_ram_page,
NULL);
 
 #ifndef CONFIG_AGP_AMD64
        no_agp = 1; 
@@ -800,7 +811,7 @@
        } 
        
        if (no_iommu ||
-           (!force_iommu && end_pfn < 0xffffffff>>PAGE_SHIFT) ||
+           (!force_iommu && ram_end < 0xfffff) ||
            !iommu_aperture ||
            (no_agp && init_k8_gatt(&info) < 0)) {
                printk(KERN_INFO "PCI-DMA: Disabling IOMMU.\n"); 
@@ -976,5 +987,7 @@
            if (*p == ',')
                    ++p;
     }
+    if (force_iommu || fallback_aper_force)
+       swiotlb = -1;
     return 1;
 } 


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