ia64/xen-unstable

changeset 4301:ac7313eb3788

bitkeeper revision 1.1159.258.65 (424331652VL7RiaHBn8P0uqDDLtLBA)

Merge xenbk@gandalf:/var/bk/xen-2.0-testing.bk
into wray-m-3.hpl.hp.com:/home/mjw/repos-bk/xen-2.0-testing.bk
author mjw@wray-m-3.hpl.hp.com
date Thu Mar 24 21:25:36 2005 +0000 (2005-03-24)
parents e769a20ff878 2fa2e30bcbde
children 27081126eb42
files .rootkeys linux-2.6.11-xen-sparse/arch/xen/i386/kernel/time.c linux-2.6.11-xen-sparse/drivers/xen/blkfront/vbd.c linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/agp.h patches/linux-2.6.11/agpgart.patch tools/libxc/xc_private.h xen/arch/x86/domain.c xen/common/domain.c xen/common/page_alloc.c xen/common/schedule.c xen/include/xen/mm.h xen/include/xen/softirq.h
line diff
     1.1 --- a/.rootkeys	Thu Mar 24 21:24:38 2005 +0000
     1.2 +++ b/.rootkeys	Thu Mar 24 21:25:36 2005 +0000
     1.3 @@ -281,6 +281,7 @@ 405853f6nbeazrNyEWNHBuoSg2PiPA linux-2.6
     1.4  4108f5c1ppFXVpQzCOAZ6xXYubsjKA linux-2.6.11-xen-sparse/drivers/xen/privcmd/Makefile
     1.5  3e5a4e65IUfzzMu2kZFlGEB8-rpTaA linux-2.6.11-xen-sparse/drivers/xen/privcmd/privcmd.c
     1.6  412f47e4RKD-R5IS5gEXvcT8L4v8gA linux-2.6.11-xen-sparse/include/asm-generic/pgtable.h
     1.7 +42400318xlBIV46qyxLTaDepPLNyhg linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/agp.h
     1.8  40f56239YAjS52QG2FIAQpHDZAdGHg linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/desc.h
     1.9  4107adf1E5O4ztGHNGMzCCNhcvqNow linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/dma-mapping.h
    1.10  40f5623akIoBsQ3KxSB2kufkbgONXQ linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/fixmap.h
     2.1 --- a/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/time.c	Thu Mar 24 21:24:38 2005 +0000
     2.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/time.c	Thu Mar 24 21:25:36 2005 +0000
     2.3 @@ -673,6 +673,7 @@ int set_timeout_timer(void)
     2.4  {
     2.5  	u64 alarm = 0;
     2.6  	int ret = 0;
     2.7 +	unsigned long j;
     2.8  
     2.9  	/*
    2.10  	 * This is safe against long blocking (since calculations are
    2.11 @@ -681,7 +682,10 @@ int set_timeout_timer(void)
    2.12  	 * would first get locked out. It is safe against normal
    2.13  	 * updates of jiffies since interrupts are off.
    2.14  	 */
    2.15 -	alarm = __jiffies_to_st(next_timer_interrupt());
    2.16 +	j = next_timer_interrupt();
    2.17 +	if (j < (jiffies + 1))
    2.18 +		j = jiffies + 1;
    2.19 +	alarm = __jiffies_to_st(j);
    2.20  
    2.21  	/* Failure is pretty bad, but we'd best soldier on. */
    2.22  	if ( HYPERVISOR_set_timer_op(alarm) != 0 )
     3.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/blkfront/vbd.c	Thu Mar 24 21:24:38 2005 +0000
     3.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/blkfront/vbd.c	Thu Mar 24 21:25:36 2005 +0000
     3.3 @@ -365,7 +365,7 @@ static int xlvbd_init_device(vdisk_t *xd
     3.4   */
     3.5  static int xlvbd_remove_device(int dev16)
     3.6  {
     3.7 -    int i, rc = 0, minor = MINOR(dev16);
     3.8 +    int i, rc = 0;
     3.9      struct gendisk *gd;
    3.10      struct block_device *bd;
    3.11      struct xlbd_disk_info *di;
    3.12 @@ -393,7 +393,6 @@ static int xlvbd_remove_device(int dev16
    3.13          goto out;
    3.14      }
    3.15  
    3.16 -    BUG_ON(minor != gd->first_minor);
    3.17      /* The VBD is mapped to an entire unit. */
    3.18      
    3.19      invalidate_partition(gd, 0);
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/agp.h	Thu Mar 24 21:25:36 2005 +0000
     4.3 @@ -0,0 +1,37 @@
     4.4 +#ifndef AGP_H
     4.5 +#define AGP_H 1
     4.6 +
     4.7 +#include <asm/pgtable.h>
     4.8 +#include <asm/cacheflush.h>
     4.9 +#include <asm/system.h>
    4.10 +
    4.11 +/* 
    4.12 + * Functions to keep the agpgart mappings coherent with the MMU.
    4.13 + * The GART gives the CPU a physical alias of pages in memory. The alias region is
    4.14 + * mapped uncacheable. Make sure there are no conflicting mappings
    4.15 + * with different cachability attributes for the same page. This avoids
    4.16 + * data corruption on some CPUs.
    4.17 + */
    4.18 +
    4.19 +int map_page_into_agp(struct page *page);
    4.20 +int unmap_page_from_agp(struct page *page);
    4.21 +#define flush_agp_mappings() global_flush_tlb()
    4.22 +
    4.23 +/* Could use CLFLUSH here if the cpu supports it. But then it would
    4.24 +   need to be called for each cacheline of the whole page so it may not be 
    4.25 +   worth it. Would need a page for it. */
    4.26 +#define flush_agp_cache() wbinvd()
    4.27 +
    4.28 +/* Convert a physical address to an address suitable for the GART. */
    4.29 +#define phys_to_gart(x) phys_to_machine(x)
    4.30 +#define gart_to_phys(x) machine_to_phys(x)
    4.31 +
    4.32 +/* GATT allocation. Returns/accepts GATT kernel virtual address. */
    4.33 +#define alloc_gatt_pages(order)	({                                          \
    4.34 +	char *_t; dma_addr_t _d;                                            \
    4.35 +	_t = dma_alloc_coherent(NULL,PAGE_SIZE<<(order),&_d,GFP_KERNEL);    \
    4.36 +	_t; })
    4.37 +#define free_gatt_pages(table, order)	\
    4.38 +	dma_free_coherent(NULL,PAGE_SIZE<<(order),(table),virt_to_bus(table))
    4.39 +
    4.40 +#endif
     5.1 --- a/patches/linux-2.6.11/agpgart.patch	Thu Mar 24 21:24:38 2005 +0000
     5.2 +++ b/patches/linux-2.6.11/agpgart.patch	Thu Mar 24 21:25:36 2005 +0000
     5.3 @@ -1,371 +1,437 @@
     5.4 -diff -rup pristine-linux-2.6.11/drivers/char/agp/ali-agp.c linux-2.6.11/drivers/char/agp/ali-agp.c
     5.5 ---- pristine-linux-2.6.11/drivers/char/agp/ali-agp.c	2005-03-02 07:38:13.000000000 +0000
     5.6 -+++ linux-2.6.11/drivers/char/agp/ali-agp.c	2005-03-11 00:35:21.320192760 +0000
     5.7 -@@ -150,7 +150,7 @@ static void *m1541_alloc_page(void)
     5.8 +--- linux-2.6.11/drivers/char/agp/agp.h	2005-03-02 07:38:07 +00:00
     5.9 ++++ linux-2.6.11-agp/drivers/char/agp/agp.h	2005-03-22 11:14:02 +00:00
    5.10 +@@ -272,6 +272,8 @@
    5.11 + #define AGP_GENERIC_SIZES_ENTRIES 11
    5.12 + extern struct aper_size_info_16 agp3_generic_sizes[];
    5.13 + 
    5.14 ++#define virt_to_gart(x) (phys_to_gart(virt_to_phys(x)))
    5.15 ++#define gart_to_virt(x) (phys_to_virt(gart_to_phys(x)))
    5.16 + 
    5.17 + extern int agp_off;
    5.18 + extern int agp_try_unsupported_boot;
    5.19 +--- linux-2.6.11/drivers/char/agp/ali-agp.c	2005-03-02 07:38:13 +00:00
    5.20 ++++ linux-2.6.11-agp/drivers/char/agp/ali-agp.c	2005-03-22 11:14:56 +00:00
    5.21 +@@ -150,7 +150,7 @@
    5.22   	pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp);
    5.23   	pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL,
    5.24   			(((temp & ALI_CACHE_FLUSH_ADDR_MASK) |
    5.25  -			  virt_to_phys(addr)) | ALI_CACHE_FLUSH_EN ));
    5.26 -+			  virt_to_bus(addr)) | ALI_CACHE_FLUSH_EN ));
    5.27 ++			  virt_to_gart(addr)) | ALI_CACHE_FLUSH_EN ));
    5.28   	return addr;
    5.29   }
    5.30   
    5.31 -@@ -174,7 +174,7 @@ static void m1541_destroy_page(void * ad
    5.32 +@@ -174,7 +174,7 @@
    5.33   	pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp);
    5.34   	pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL,
    5.35   			(((temp & ALI_CACHE_FLUSH_ADDR_MASK) |
    5.36  -			  virt_to_phys(addr)) | ALI_CACHE_FLUSH_EN));
    5.37 -+			  virt_to_bus(addr)) | ALI_CACHE_FLUSH_EN));
    5.38 ++			  virt_to_gart(addr)) | ALI_CACHE_FLUSH_EN));
    5.39   	agp_generic_destroy_page(addr);
    5.40   }
    5.41   
    5.42 -diff -rup pristine-linux-2.6.11/drivers/char/agp/amd-k7-agp.c linux-2.6.11/drivers/char/agp/amd-k7-agp.c
    5.43 ---- pristine-linux-2.6.11/drivers/char/agp/amd-k7-agp.c	2005-03-02 07:38:33.000000000 +0000
    5.44 -+++ linux-2.6.11/drivers/char/agp/amd-k7-agp.c	2005-03-11 00:35:21.321192788 +0000
    5.45 -@@ -43,7 +43,7 @@ static int amd_create_page_map(struct am
    5.46 +--- linux-2.6.11/drivers/char/agp/amd-k7-agp.c	2005-03-02 07:38:33 +00:00
    5.47 ++++ linux-2.6.11-agp/drivers/char/agp/amd-k7-agp.c	2005-03-22 11:14:56 +00:00
    5.48 +@@ -43,7 +43,7 @@
    5.49   
    5.50   	SetPageReserved(virt_to_page(page_map->real));
    5.51   	global_cache_flush();
    5.52  -	page_map->remapped = ioremap_nocache(virt_to_phys(page_map->real),
    5.53 -+	page_map->remapped = ioremap_nocache(virt_to_bus(page_map->real),
    5.54 ++	page_map->remapped = ioremap_nocache(virt_to_gart(page_map->real),
    5.55   					    PAGE_SIZE);
    5.56   	if (page_map->remapped == NULL) {
    5.57   		ClearPageReserved(virt_to_page(page_map->real));
    5.58 -@@ -154,7 +154,7 @@ static int amd_create_gatt_table(void)
    5.59 +@@ -154,7 +154,7 @@
    5.60   
    5.61   	agp_bridge->gatt_table_real = (u32 *)page_dir.real;
    5.62   	agp_bridge->gatt_table = (u32 __iomem *)page_dir.remapped;
    5.63  -	agp_bridge->gatt_bus_addr = virt_to_phys(page_dir.real);
    5.64 -+	agp_bridge->gatt_bus_addr = virt_to_bus(page_dir.real);
    5.65 ++	agp_bridge->gatt_bus_addr = virt_to_gart(page_dir.real);
    5.66   
    5.67   	/* Get the address for the gart region.
    5.68   	 * This is a bus address even on the alpha, b/c its
    5.69 -@@ -167,7 +167,7 @@ static int amd_create_gatt_table(void)
    5.70 +@@ -167,7 +167,7 @@
    5.71   
    5.72   	/* Calculate the agp offset */
    5.73   	for (i = 0; i < value->num_entries / 1024; i++, addr += 0x00400000) {
    5.74  -		writel(virt_to_phys(amd_irongate_private.gatt_pages[i]->real) | 1,
    5.75 -+		writel(virt_to_bus(amd_irongate_private.gatt_pages[i]->real) | 1,
    5.76 ++		writel(virt_to_gart(amd_irongate_private.gatt_pages[i]->real) | 1,
    5.77   			page_dir.remapped+GET_PAGE_DIR_OFF(addr));
    5.78   		readl(page_dir.remapped+GET_PAGE_DIR_OFF(addr));	/* PCI Posting. */
    5.79   	}
    5.80 -diff -rup pristine-linux-2.6.11/drivers/char/agp/amd64-agp.c linux-2.6.11/drivers/char/agp/amd64-agp.c
    5.81 ---- pristine-linux-2.6.11/drivers/char/agp/amd64-agp.c	2005-03-02 07:38:13.000000000 +0000
    5.82 -+++ linux-2.6.11/drivers/char/agp/amd64-agp.c	2005-03-11 00:35:21.322192816 +0000
    5.83 -@@ -218,7 +218,7 @@ static struct aper_size_info_32 amd_8151
    5.84 +--- linux-2.6.11/drivers/char/agp/amd64-agp.c	2005-03-02 07:38:13 +00:00
    5.85 ++++ linux-2.6.11-agp/drivers/char/agp/amd64-agp.c	2005-03-22 11:14:56 +00:00
    5.86 +@@ -218,7 +218,7 @@
    5.87   
    5.88   static int amd_8151_configure(void)
    5.89   {
    5.90  -	unsigned long gatt_bus = virt_to_phys(agp_bridge->gatt_table_real);
    5.91 -+	unsigned long gatt_bus = virt_to_bus(agp_bridge->gatt_table_real);
    5.92 ++	unsigned long gatt_bus = virt_to_gart(agp_bridge->gatt_table_real);
    5.93   
    5.94   	/* Configure AGP regs in each x86-64 host bridge. */
    5.95   	for_each_nb() {
    5.96 -@@ -590,7 +590,7 @@ static void __devexit agp_amd64_remove(s
    5.97 +@@ -590,7 +590,7 @@
    5.98   {
    5.99   	struct agp_bridge_data *bridge = pci_get_drvdata(pdev);
   5.100   
   5.101  -	release_mem_region(virt_to_phys(bridge->gatt_table_real),
   5.102 -+	release_mem_region(virt_to_bus(bridge->gatt_table_real),
   5.103 ++	release_mem_region(virt_to_gart(bridge->gatt_table_real),
   5.104   			   amd64_aperture_sizes[bridge->aperture_size_idx].size);
   5.105   	agp_remove_bridge(bridge);
   5.106   	agp_put_bridge(bridge);
   5.107 -diff -rup pristine-linux-2.6.11/drivers/char/agp/ati-agp.c linux-2.6.11/drivers/char/agp/ati-agp.c
   5.108 ---- pristine-linux-2.6.11/drivers/char/agp/ati-agp.c	2005-03-02 07:38:13.000000000 +0000
   5.109 -+++ linux-2.6.11/drivers/char/agp/ati-agp.c	2005-03-11 00:41:25.848450763 +0000
   5.110 -@@ -61,7 +61,7 @@ static int ati_create_page_map(ati_page_
   5.111 +--- linux-2.6.11/drivers/char/agp/ati-agp.c	2005-03-02 07:38:13 +00:00
   5.112 ++++ linux-2.6.11-agp/drivers/char/agp/ati-agp.c	2005-03-22 11:14:56 +00:00
   5.113 +@@ -61,7 +61,7 @@
   5.114   
   5.115   	SetPageReserved(virt_to_page(page_map->real));
   5.116   	err = map_page_into_agp(virt_to_page(page_map->real));
   5.117  -	page_map->remapped = ioremap_nocache(virt_to_phys(page_map->real),
   5.118 -+	page_map->remapped = ioremap_nocache(virt_to_bus(page_map->real),
   5.119 ++	page_map->remapped = ioremap_nocache(virt_to_gart(page_map->real),
   5.120   					    PAGE_SIZE);
   5.121   	if (page_map->remapped == NULL || err) {
   5.122   		ClearPageReserved(virt_to_page(page_map->real));
   5.123 -diff -rup pristine-linux-2.6.11/drivers/char/agp/backend.c linux-2.6.11/drivers/char/agp/backend.c
   5.124 ---- pristine-linux-2.6.11/drivers/char/agp/backend.c	2005-03-02 07:38:13.000000000 +0000
   5.125 -+++ linux-2.6.11/drivers/char/agp/backend.c	2005-03-11 00:35:21.323192844 +0000
   5.126 -@@ -142,7 +142,7 @@ static int agp_backend_initialize(struct
   5.127 +--- linux-2.6.11/drivers/char/agp/backend.c	2005-03-02 07:38:13 +00:00
   5.128 ++++ linux-2.6.11-agp/drivers/char/agp/backend.c	2005-03-22 11:14:56 +00:00
   5.129 +@@ -142,7 +142,7 @@
   5.130   			return -ENOMEM;
   5.131   		}
   5.132   
   5.133  -		bridge->scratch_page_real = virt_to_phys(addr);
   5.134 -+		bridge->scratch_page_real = virt_to_bus(addr);
   5.135 ++		bridge->scratch_page_real = virt_to_gart(addr);
   5.136   		bridge->scratch_page =
   5.137   		    bridge->driver->mask_memory(bridge->scratch_page_real, 0);
   5.138   	}
   5.139 -@@ -186,7 +186,7 @@ static int agp_backend_initialize(struct
   5.140 +@@ -186,7 +186,7 @@
   5.141   err_out:
   5.142   	if (bridge->driver->needs_scratch_page)
   5.143   		bridge->driver->agp_destroy_page(
   5.144  -				phys_to_virt(bridge->scratch_page_real));
   5.145 -+				bus_to_virt(bridge->scratch_page_real));
   5.146 ++				gart_to_virt(bridge->scratch_page_real));
   5.147   	if (got_gatt)
   5.148   		bridge->driver->free_gatt_table();
   5.149   	if (got_keylist) {
   5.150 -@@ -211,7 +211,7 @@ static void agp_backend_cleanup(struct a
   5.151 +@@ -211,7 +211,7 @@
   5.152   	if (bridge->driver->agp_destroy_page &&
   5.153   	    bridge->driver->needs_scratch_page)
   5.154   		bridge->driver->agp_destroy_page(
   5.155  -				phys_to_virt(bridge->scratch_page_real));
   5.156 -+				bus_to_virt(bridge->scratch_page_real));
   5.157 ++				gart_to_virt(bridge->scratch_page_real));
   5.158   }
   5.159   
   5.160   /* XXX Kludge alert: agpgart isn't ready for multiple bridges yet */
   5.161 -diff -rup pristine-linux-2.6.11/drivers/char/agp/efficeon-agp.c linux-2.6.11/drivers/char/agp/efficeon-agp.c
   5.162 ---- pristine-linux-2.6.11/drivers/char/agp/efficeon-agp.c	2005-03-02 07:37:30.000000000 +0000
   5.163 -+++ linux-2.6.11/drivers/char/agp/efficeon-agp.c	2005-03-11 00:35:21.324192872 +0000
   5.164 -@@ -219,7 +219,7 @@ static int efficeon_create_gatt_table(vo
   5.165 +--- linux-2.6.11/drivers/char/agp/efficeon-agp.c	2005-03-02 07:37:30 +00:00
   5.166 ++++ linux-2.6.11-agp/drivers/char/agp/efficeon-agp.c	2005-03-22 11:15:17 +00:00
   5.167 +@@ -219,7 +219,7 @@
   5.168   
   5.169   		efficeon_private.l1_table[index] = page;
   5.170   
   5.171  -		value = __pa(page) | pati | present | index;
   5.172 -+		value = virt_to_bus(page) | pati | present | index;
   5.173 ++		value = virt_to_gart(page) | pati | present | index;
   5.174   
   5.175   		pci_write_config_dword(agp_bridge->dev,
   5.176   			EFFICEON_ATTPAGE, value);
   5.177 -diff -rup pristine-linux-2.6.11/drivers/char/agp/generic.c linux-2.6.11/drivers/char/agp/generic.c
   5.178 ---- pristine-linux-2.6.11/drivers/char/agp/generic.c	2005-03-02 07:37:55.000000000 +0000
   5.179 -+++ linux-2.6.11/drivers/char/agp/generic.c	2005-03-11 00:44:53.858248651 +0000
   5.180 -@@ -151,7 +151,7 @@ void agp_free_memory(struct agp_memory *
   5.181 +--- linux-2.6.11/drivers/char/agp/generic.c	2005-03-02 07:37:55 +00:00
   5.182 ++++ linux-2.6.11-agp/drivers/char/agp/generic.c	2005-03-22 11:17:37 +00:00
   5.183 +@@ -151,7 +151,7 @@
   5.184   	}
   5.185   	if (curr->page_count != 0) {
   5.186   		for (i = 0; i < curr->page_count; i++) {
   5.187  -			agp_bridge->driver->agp_destroy_page(phys_to_virt(curr->memory[i]));
   5.188 -+			agp_bridge->driver->agp_destroy_page(bus_to_virt(curr->memory[i]));
   5.189 ++			agp_bridge->driver->agp_destroy_page(gart_to_virt(curr->memory[i]));
   5.190   		}
   5.191   	}
   5.192   	agp_free_key(curr->key);
   5.193 -@@ -204,7 +204,7 @@ struct agp_memory *agp_allocate_memory(s
   5.194 +@@ -204,7 +204,7 @@
   5.195   			agp_free_memory(new);
   5.196   			return NULL;
   5.197   		}
   5.198  -		new->memory[i] = virt_to_phys(addr);
   5.199 -+		new->memory[i] = virt_to_bus(addr);
   5.200 ++		new->memory[i] = virt_to_gart(addr);
   5.201   		new->page_count++;
   5.202   	}
   5.203   
   5.204 -@@ -659,6 +659,7 @@ int agp_generic_create_gatt_table(void)
   5.205 - 	int i;
   5.206 - 	void *temp;
   5.207 - 	struct page *page;
   5.208 -+	dma_addr_t dma;
   5.209 - 
   5.210 - 	/* The generic routines can't handle 2 level gatt's */
   5.211 - 	if (agp_bridge->driver->size_type == LVL2_APER_SIZE)
   5.212 -@@ -697,8 +698,10 @@ int agp_generic_create_gatt_table(void)
   5.213 +@@ -697,8 +697,7 @@
   5.214   				break;
   5.215   			}
   5.216   
   5.217  -			table = (char *) __get_free_pages(GFP_KERNEL,
   5.218  -							  page_order);
   5.219 -+			table = dma_alloc_coherent(
   5.220 -+					&agp_bridge->dev->dev,
   5.221 -+					PAGE_SIZE << page_order, &dma,
   5.222 -+					GFP_KERNEL);
   5.223 ++			table = alloc_gatt_pages(page_order);
   5.224   
   5.225   			if (table == NULL) {
   5.226   				i++;
   5.227 -@@ -729,7 +732,9 @@ int agp_generic_create_gatt_table(void)
   5.228 +@@ -729,7 +728,7 @@
   5.229   		size = ((struct aper_size_info_fixed *) temp)->size;
   5.230   		page_order = ((struct aper_size_info_fixed *) temp)->page_order;
   5.231   		num_entries = ((struct aper_size_info_fixed *) temp)->num_entries;
   5.232  -		table = (char *) __get_free_pages(GFP_KERNEL, page_order);
   5.233 -+		table = dma_alloc_coherent(
   5.234 -+				&agp_bridge->dev->dev,
   5.235 -+				PAGE_SIZE << page_order, &dma, GFP_KERNEL);
   5.236 ++		table = alloc_gatt_pages(page_order);
   5.237   	}
   5.238   
   5.239   	if (table == NULL)
   5.240 -@@ -744,7 +749,7 @@ int agp_generic_create_gatt_table(void)
   5.241 +@@ -744,7 +743,7 @@
   5.242   	agp_gatt_table = (void *)table;
   5.243   
   5.244   	agp_bridge->driver->cache_flush();
   5.245  -	agp_bridge->gatt_table = ioremap_nocache(virt_to_phys(table),
   5.246 -+	agp_bridge->gatt_table = ioremap_nocache(virt_to_bus(table),
   5.247 ++	agp_bridge->gatt_table = ioremap_nocache(virt_to_gart(table),
   5.248   					(PAGE_SIZE * (1 << page_order)));
   5.249   	agp_bridge->driver->cache_flush();
   5.250   
   5.251 -@@ -752,11 +757,12 @@ int agp_generic_create_gatt_table(void)
   5.252 +@@ -752,11 +751,11 @@
   5.253   		for (page = virt_to_page(table); page <= virt_to_page(table_end); page++)
   5.254   			ClearPageReserved(page);
   5.255   
   5.256  -		free_pages((unsigned long) table, page_order);
   5.257 -+		dma_free_coherent(&agp_bridge->dev->dev, PAGE_SIZE<<page_order,
   5.258 -+					table, dma);
   5.259 ++		free_gatt_pages(table, page_order);
   5.260   
   5.261   		return -ENOMEM;
   5.262   	}
   5.263  -	agp_bridge->gatt_bus_addr = virt_to_phys(agp_bridge->gatt_table_real);
   5.264 -+	agp_bridge->gatt_bus_addr = virt_to_bus(table);
   5.265 ++	agp_bridge->gatt_bus_addr = virt_to_gart(agp_bridge->gatt_table_real);
   5.266   
   5.267   	/* AK: bogus, should encode addresses > 4GB */
   5.268   	for (i = 0; i < num_entries; i++) {
   5.269 -@@ -810,7 +816,8 @@ int agp_generic_free_gatt_table(void)
   5.270 +@@ -810,7 +809,7 @@
   5.271   	for (page = virt_to_page(table); page <= virt_to_page(table_end); page++)
   5.272   		ClearPageReserved(page);
   5.273   
   5.274  -	free_pages((unsigned long) agp_bridge->gatt_table_real, page_order);
   5.275 -+	dma_free_coherent(&agp_bridge->dev->dev, PAGE_SIZE<<page_order,
   5.276 -+		agp_bridge->gatt_table_real, agp_bridge->gatt_bus_addr);
   5.277 ++	free_gatt_pages(agp_bridge->gatt_table_real, page_order);
   5.278   
   5.279   	agp_gatt_table = NULL;
   5.280   	agp_bridge->gatt_table = NULL;
   5.281 -diff -rup pristine-linux-2.6.11/drivers/char/agp/hp-agp.c linux-2.6.11/drivers/char/agp/hp-agp.c
   5.282 ---- pristine-linux-2.6.11/drivers/char/agp/hp-agp.c	2005-03-02 07:38:19.000000000 +0000
   5.283 -+++ linux-2.6.11/drivers/char/agp/hp-agp.c	2005-03-11 00:47:41.424653508 +0000
   5.284 -@@ -110,7 +110,7 @@ static int __init hp_zx1_ioc_shared(void
   5.285 +--- linux-2.6.11/drivers/char/agp/hp-agp.c	2005-03-02 07:38:19 +00:00
   5.286 ++++ linux-2.6.11-agp/drivers/char/agp/hp-agp.c	2005-03-22 11:14:56 +00:00
   5.287 +@@ -110,7 +110,7 @@
   5.288   	hp->gart_size = HP_ZX1_GART_SIZE;
   5.289   	hp->gatt_entries = hp->gart_size / hp->io_page_size;
   5.290   
   5.291  -	hp->io_pdir = phys_to_virt(readq(hp->ioc_regs+HP_ZX1_PDIR_BASE));
   5.292 -+	hp->io_pdir = bus_to_virt(readq(hp->ioc_regs+HP_ZX1_PDIR_BASE));
   5.293 ++	hp->io_pdir = gart_to_virt(readq(hp->ioc_regs+HP_ZX1_PDIR_BASE));
   5.294   	hp->gatt = &hp->io_pdir[HP_ZX1_IOVA_TO_PDIR(hp->gart_base)];
   5.295   
   5.296   	if (hp->gatt[0] != HP_ZX1_SBA_IOMMU_COOKIE) {
   5.297 -@@ -248,7 +248,7 @@ hp_zx1_configure (void)
   5.298 +@@ -248,7 +248,7 @@
   5.299   	agp_bridge->mode = readl(hp->lba_regs+hp->lba_cap_offset+PCI_AGP_STATUS);
   5.300   
   5.301   	if (hp->io_pdir_owner) {
   5.302  -		writel(virt_to_phys(hp->io_pdir), hp->ioc_regs+HP_ZX1_PDIR_BASE);
   5.303 -+		writel(virt_to_bus(hp->io_pdir), hp->ioc_regs+HP_ZX1_PDIR_BASE);
   5.304 ++		writel(virt_to_gart(hp->io_pdir), hp->ioc_regs+HP_ZX1_PDIR_BASE);
   5.305   		readl(hp->ioc_regs+HP_ZX1_PDIR_BASE);
   5.306   		writel(hp->io_tlb_ps, hp->ioc_regs+HP_ZX1_TCNFG);
   5.307   		readl(hp->ioc_regs+HP_ZX1_TCNFG);
   5.308 -diff -rup pristine-linux-2.6.11/drivers/char/agp/i460-agp.c linux-2.6.11/drivers/char/agp/i460-agp.c
   5.309 ---- pristine-linux-2.6.11/drivers/char/agp/i460-agp.c	2005-03-02 07:38:10.000000000 +0000
   5.310 -+++ linux-2.6.11/drivers/char/agp/i460-agp.c	2005-03-11 00:35:21.327192957 +0000
   5.311 -@@ -371,7 +371,7 @@ static int i460_alloc_large_page (struct
   5.312 +--- linux-2.6.11/drivers/char/agp/i460-agp.c	2005-03-02 07:38:10 +00:00
   5.313 ++++ linux-2.6.11-agp/drivers/char/agp/i460-agp.c	2005-03-22 11:14:56 +00:00
   5.314 +@@ -371,7 +371,7 @@
   5.315   	}
   5.316   	memset(lp->alloced_map, 0, map_size);
   5.317   
   5.318  -	lp->paddr = virt_to_phys(lpage);
   5.319 -+	lp->paddr = virt_to_bus(lpage);
   5.320 ++	lp->paddr = virt_to_gart(lpage);
   5.321   	lp->refcount = 0;
   5.322   	atomic_add(I460_KPAGES_PER_IOPAGE, &agp_bridge->current_memory_agp);
   5.323   	return 0;
   5.324 -@@ -382,7 +382,7 @@ static void i460_free_large_page (struct
   5.325 +@@ -382,7 +382,7 @@
   5.326   	kfree(lp->alloced_map);
   5.327   	lp->alloced_map = NULL;
   5.328   
   5.329  -	free_pages((unsigned long) phys_to_virt(lp->paddr), I460_IO_PAGE_SHIFT - PAGE_SHIFT);
   5.330 -+	free_pages((unsigned long) bus_to_virt(lp->paddr), I460_IO_PAGE_SHIFT - PAGE_SHIFT);
   5.331 ++	free_pages((unsigned long) gart_to_virt(lp->paddr), I460_IO_PAGE_SHIFT - PAGE_SHIFT);
   5.332   	atomic_sub(I460_KPAGES_PER_IOPAGE, &agp_bridge->current_memory_agp);
   5.333   }
   5.334   
   5.335 -diff -rup pristine-linux-2.6.11/drivers/char/agp/intel-agp.c linux-2.6.11/drivers/char/agp/intel-agp.c
   5.336 ---- pristine-linux-2.6.11/drivers/char/agp/intel-agp.c	2005-03-02 07:38:09.000000000 +0000
   5.337 -+++ linux-2.6.11/drivers/char/agp/intel-agp.c	2005-03-11 00:35:21.328192985 +0000
   5.338 -@@ -285,7 +285,7 @@ static struct agp_memory *alloc_agpphysm
   5.339 +--- linux-2.6.11/drivers/char/agp/intel-agp.c	2005-03-02 07:38:09 +00:00
   5.340 ++++ linux-2.6.11-agp/drivers/char/agp/intel-agp.c	2005-03-22 11:14:56 +00:00
   5.341 +@@ -285,7 +285,7 @@
   5.342 + 	if (new == NULL)
   5.343 + 		return NULL;
   5.344 + 
   5.345 +-	new->memory[0] = virt_to_phys(addr);
   5.346 ++	new->memory[0] = virt_to_gart(addr);
   5.347 + 	if (pg_count == 4) {
   5.348 + 		/* kludge to get 4 physical pages for ARGB cursor */
   5.349 + 		new->memory[1] = new->memory[0] + PAGE_SIZE;
   5.350 +@@ -328,10 +328,10 @@
   5.351 + 	agp_free_key(curr->key);
   5.352 + 	if(curr->type == AGP_PHYS_MEMORY) {
   5.353 + 		if (curr->page_count == 4)
   5.354 +-			i8xx_destroy_pages(phys_to_virt(curr->memory[0]));
   5.355 ++			i8xx_destroy_pages(gart_to_virt(curr->memory[0]));
   5.356 + 		else
   5.357 + 			agp_bridge->driver->agp_destroy_page(
   5.358 +-				 phys_to_virt(curr->memory[0]));
   5.359 ++				 gart_to_virt(curr->memory[0]));
   5.360 + 		vfree(curr->memory);
   5.361 + 	}
   5.362 + 	kfree(curr);
   5.363 +--- linux-2.6.11/drivers/char/agp/intel-mch-agp.c	2005-03-02 07:37:48 +00:00
   5.364 ++++ linux-2.6.11-agp/drivers/char/agp/intel-mch-agp.c	2005-03-22 11:14:56 +00:00
   5.365 +@@ -51,7 +51,7 @@
   5.366   	if (new == NULL)
   5.367   		return NULL;
   5.368   
   5.369  -	new->memory[0] = virt_to_phys(addr);
   5.370 -+	new->memory[0] = virt_to_bus(addr);
   5.371 - 	if (pg_count == 4) {
   5.372 - 		/* kludge to get 4 physical pages for ARGB cursor */
   5.373 - 		new->memory[1] = new->memory[0] + PAGE_SIZE;
   5.374 -@@ -328,10 +328,10 @@ static void intel_i810_free_by_type(stru
   5.375 - 	agp_free_key(curr->key);
   5.376 - 	if(curr->type == AGP_PHYS_MEMORY) {
   5.377 - 		if (curr->page_count == 4)
   5.378 --			i8xx_destroy_pages(phys_to_virt(curr->memory[0]));
   5.379 -+			i8xx_destroy_pages(bus_to_virt(curr->memory[0]));
   5.380 - 		else
   5.381 - 			agp_bridge->driver->agp_destroy_page(
   5.382 --				 phys_to_virt(curr->memory[0]));
   5.383 -+				 bus_to_virt(curr->memory[0]));
   5.384 - 		vfree(curr->memory);
   5.385 - 	}
   5.386 - 	kfree(curr);
   5.387 -diff -rup pristine-linux-2.6.11/drivers/char/agp/intel-mch-agp.c linux-2.6.11/drivers/char/agp/intel-mch-agp.c
   5.388 ---- pristine-linux-2.6.11/drivers/char/agp/intel-mch-agp.c	2005-03-02 07:37:48.000000000 +0000
   5.389 -+++ linux-2.6.11/drivers/char/agp/intel-mch-agp.c	2005-03-11 00:49:37.713063638 +0000
   5.390 -@@ -51,7 +51,7 @@ static struct agp_memory *alloc_agpphysm
   5.391 - 	if (new == NULL)
   5.392 - 		return NULL;
   5.393 - 
   5.394 --	new->memory[0] = virt_to_phys(addr);
   5.395 -+	new->memory[0] = virt_to_bus(addr);
   5.396 ++	new->memory[0] = virt_to_gart(addr);
   5.397   	new->page_count = 1;
   5.398   	new->num_scratch_pages = 1;
   5.399   	new->type = AGP_PHYS_MEMORY;
   5.400 -@@ -63,7 +63,7 @@ static void intel_i810_free_by_type(stru
   5.401 +@@ -63,7 +63,7 @@
   5.402   {
   5.403   	agp_free_key(curr->key);
   5.404   	if(curr->type == AGP_PHYS_MEMORY) {
   5.405  -		agp_bridge->driver->agp_destroy_page(phys_to_virt(curr->memory[0]));
   5.406 -+		agp_bridge->driver->agp_destroy_page(bus_to_virt(curr->memory[0]));
   5.407 ++		agp_bridge->driver->agp_destroy_page(gart_to_virt(curr->memory[0]));
   5.408   		vfree(curr->memory);
   5.409   	}
   5.410   	kfree(curr);
   5.411 -diff -rup pristine-linux-2.6.11/drivers/char/agp/sworks-agp.c linux-2.6.11/drivers/char/agp/sworks-agp.c
   5.412 ---- pristine-linux-2.6.11/drivers/char/agp/sworks-agp.c	2005-03-02 07:38:37.000000000 +0000
   5.413 -+++ linux-2.6.11/drivers/char/agp/sworks-agp.c	2005-03-11 00:35:21.330193041 +0000
   5.414 -@@ -51,7 +51,7 @@ static int serverworks_create_page_map(s
   5.415 +--- linux-2.6.11/drivers/char/agp/sworks-agp.c	2005-03-02 07:38:37 +00:00
   5.416 ++++ linux-2.6.11-agp/drivers/char/agp/sworks-agp.c	2005-03-22 11:14:56 +00:00
   5.417 +@@ -51,7 +51,7 @@
   5.418   	}
   5.419   	SetPageReserved(virt_to_page(page_map->real));
   5.420   	global_cache_flush();
   5.421  -	page_map->remapped = ioremap_nocache(virt_to_phys(page_map->real), 
   5.422 -+	page_map->remapped = ioremap_nocache(virt_to_bus(page_map->real), 
   5.423 ++	page_map->remapped = ioremap_nocache(virt_to_gart(page_map->real), 
   5.424   					    PAGE_SIZE);
   5.425   	if (page_map->remapped == NULL) {
   5.426   		ClearPageReserved(virt_to_page(page_map->real));
   5.427 -@@ -162,7 +162,7 @@ static int serverworks_create_gatt_table
   5.428 +@@ -162,7 +162,7 @@
   5.429   	/* Create a fake scratch directory */
   5.430   	for(i = 0; i < 1024; i++) {
   5.431   		writel(agp_bridge->scratch_page, serverworks_private.scratch_dir.remapped+i);
   5.432  -		writel(virt_to_phys(serverworks_private.scratch_dir.real) | 1, page_dir.remapped+i);
   5.433 -+		writel(virt_to_bus(serverworks_private.scratch_dir.real) | 1, page_dir.remapped+i);
   5.434 ++		writel(virt_to_gart(serverworks_private.scratch_dir.real) | 1, page_dir.remapped+i);
   5.435   	}
   5.436   
   5.437   	retval = serverworks_create_gatt_pages(value->num_entries / 1024);
   5.438 -@@ -174,7 +174,7 @@ static int serverworks_create_gatt_table
   5.439 +@@ -174,7 +174,7 @@
   5.440   
   5.441   	agp_bridge->gatt_table_real = (u32 *)page_dir.real;
   5.442   	agp_bridge->gatt_table = (u32 __iomem *)page_dir.remapped;
   5.443  -	agp_bridge->gatt_bus_addr = virt_to_phys(page_dir.real);
   5.444 -+	agp_bridge->gatt_bus_addr = virt_to_bus(page_dir.real);
   5.445 ++	agp_bridge->gatt_bus_addr = virt_to_gart(page_dir.real);
   5.446   
   5.447   	/* Get the address for the gart region.
   5.448   	 * This is a bus address even on the alpha, b/c its
   5.449 -@@ -187,7 +187,7 @@ static int serverworks_create_gatt_table
   5.450 +@@ -187,7 +187,7 @@
   5.451   	/* Calculate the agp offset */	
   5.452   
   5.453   	for(i = 0; i < value->num_entries / 1024; i++)
   5.454  -		writel(virt_to_phys(serverworks_private.gatt_pages[i]->real)|1, page_dir.remapped+i);
   5.455 -+		writel(virt_to_bus(serverworks_private.gatt_pages[i]->real)|1, page_dir.remapped+i);
   5.456 ++		writel(virt_to_gart(serverworks_private.gatt_pages[i]->real)|1, page_dir.remapped+i);
   5.457   
   5.458   	return 0;
   5.459   }
   5.460 -diff -rup pristine-linux-2.6.11/drivers/char/agp/uninorth-agp.c linux-2.6.11/drivers/char/agp/uninorth-agp.c
   5.461 ---- pristine-linux-2.6.11/drivers/char/agp/uninorth-agp.c	2005-03-02 07:38:09.000000000 +0000
   5.462 -+++ linux-2.6.11/drivers/char/agp/uninorth-agp.c	2005-03-11 00:35:21.330193041 +0000
   5.463 -@@ -200,7 +200,7 @@ static int uninorth_create_gatt_table(vo
   5.464 +--- linux-2.6.11/drivers/char/agp/uninorth-agp.c	2005-03-02 07:38:09 +00:00
   5.465 ++++ linux-2.6.11-agp/drivers/char/agp/uninorth-agp.c	2005-03-22 11:14:56 +00:00
   5.466 +@@ -200,7 +200,7 @@
   5.467   
   5.468   	agp_bridge->gatt_table_real = (u32 *) table;
   5.469   	agp_bridge->gatt_table = (u32 *)table;
   5.470  -	agp_bridge->gatt_bus_addr = virt_to_phys(table);
   5.471 -+	agp_bridge->gatt_bus_addr = virt_to_bus(table);
   5.472 ++	agp_bridge->gatt_bus_addr = virt_to_gart(table);
   5.473   
   5.474   	for (i = 0; i < num_entries; i++) {
   5.475   		agp_bridge->gatt_table[i] =
   5.476 -diff -rup pristine-linux-2.6.11/include/asm-i386/agp.h linux-2.6.11/include/asm-i386/agp.h
   5.477 ---- pristine-linux-2.6.11/include/asm-i386/agp.h	2005-03-02 07:37:31.000000000 +0000
   5.478 -+++ linux-2.6.11/include/asm-i386/agp.h	2005-03-11 00:35:21.331193069 +0000
   5.479 -@@ -3,6 +3,7 @@
   5.480 +--- linux-2.6.11/include/asm-alpha/agp.h	2005-03-02 07:37:39 +00:00
   5.481 ++++ linux-2.6.11-agp/include/asm-alpha/agp.h	2005-03-22 11:18:34 +00:00
   5.482 +@@ -10,4 +10,14 @@
   5.483 + #define flush_agp_mappings() 
   5.484 + #define flush_agp_cache() mb()
   5.485   
   5.486 - #include <asm/pgtable.h>
   5.487 - #include <asm/cacheflush.h>
   5.488 -+#include <asm/system.h>
   5.489 ++/* Convert a physical address to an address suitable for the GART. */
   5.490 ++#define phys_to_gart(x) (x)
   5.491 ++#define gart_to_phys(x) (x)
   5.492 ++
   5.493 ++/* GATT allocation. Returns/accepts GATT kernel virtual address. */
   5.494 ++#define alloc_gatt_pages(order)		\
   5.495 ++	((char *)__get_free_pages(GFP_KERNEL, (order)))
   5.496 ++#define free_gatt_pages(table, order)	\
   5.497 ++	free_pages((unsigned long)(table), (order))
   5.498 ++
   5.499 + #endif
   5.500 +--- linux-2.6.11/include/asm-i386/agp.h	2005-03-02 07:37:31 +00:00
   5.501 ++++ linux-2.6.11-agp/include/asm-i386/agp.h	2005-03-22 11:18:39 +00:00
   5.502 +@@ -21,4 +21,14 @@
   5.503 +    worth it. Would need a page for it. */
   5.504 + #define flush_agp_cache() asm volatile("wbinvd":::"memory")
   5.505 + 
   5.506 ++/* Convert a physical address to an address suitable for the GART. */
   5.507 ++#define phys_to_gart(x) (x)
   5.508 ++#define gart_to_phys(x) (x)
   5.509 ++
   5.510 ++/* GATT allocation. Returns/accepts GATT kernel virtual address. */
   5.511 ++#define alloc_gatt_pages(order)		\
   5.512 ++	((char *)__get_free_pages(GFP_KERNEL, (order)))
   5.513 ++#define free_gatt_pages(table, order)	\
   5.514 ++	free_pages((unsigned long)(table), (order))
   5.515 ++
   5.516 + #endif
   5.517 +--- linux-2.6.11/include/asm-ia64/agp.h	2005-03-02 07:38:09 +00:00
   5.518 ++++ linux-2.6.11-agp/include/asm-ia64/agp.h	2005-03-22 11:18:45 +00:00
   5.519 +@@ -18,4 +18,14 @@
   5.520 + #define flush_agp_mappings()		/* nothing */
   5.521 + #define flush_agp_cache()		mb()
   5.522   
   5.523 - /* 
   5.524 -  * Functions to keep the agpgart mappings coherent with the MMU.
   5.525 -@@ -19,6 +20,6 @@ int unmap_page_from_agp(struct page *pag
   5.526 - /* Could use CLFLUSH here if the cpu supports it. But then it would
   5.527 -    need to be called for each cacheline of the whole page so it may not be 
   5.528 ++/* Convert a physical address to an address suitable for the GART. */
   5.529 ++#define phys_to_gart(x) (x)
   5.530 ++#define gart_to_phys(x) (x)
   5.531 ++
   5.532 ++/* GATT allocation. Returns/accepts GATT kernel virtual address. */
   5.533 ++#define alloc_gatt_pages(order)		\
   5.534 ++	((char *)__get_free_pages(GFP_KERNEL, (order)))
   5.535 ++#define free_gatt_pages(table, order)	\
   5.536 ++	free_pages((unsigned long)(table), (order))
   5.537 ++
   5.538 + #endif /* _ASM_IA64_AGP_H */
   5.539 +--- linux-2.6.11/include/asm-ppc/agp.h	2005-03-02 07:38:08 +00:00
   5.540 ++++ linux-2.6.11-agp/include/asm-ppc/agp.h	2005-03-22 11:18:52 +00:00
   5.541 +@@ -10,4 +10,14 @@
   5.542 + #define flush_agp_mappings()
   5.543 + #define flush_agp_cache() mb()
   5.544 + 
   5.545 ++/* Convert a physical address to an address suitable for the GART. */
   5.546 ++#define phys_to_gart(x) (x)
   5.547 ++#define gart_to_phys(x) (x)
   5.548 ++
   5.549 ++/* GATT allocation. Returns/accepts GATT kernel virtual address. */
   5.550 ++#define alloc_gatt_pages(order)		\
   5.551 ++	((char *)__get_free_pages(GFP_KERNEL, (order)))
   5.552 ++#define free_gatt_pages(table, order)	\
   5.553 ++	free_pages((unsigned long)(table), (order))
   5.554 ++
   5.555 + #endif
   5.556 +--- linux-2.6.11/include/asm-sparc64/agp.h	2005-03-02 07:37:48 +00:00
   5.557 ++++ linux-2.6.11-agp/include/asm-sparc64/agp.h	2005-03-22 11:18:59 +00:00
   5.558 +@@ -8,4 +8,14 @@
   5.559 + #define flush_agp_mappings() 
   5.560 + #define flush_agp_cache() mb()
   5.561 + 
   5.562 ++/* Convert a physical address to an address suitable for the GART. */
   5.563 ++#define phys_to_gart(x) (x)
   5.564 ++#define gart_to_phys(x) (x)
   5.565 ++
   5.566 ++/* GATT allocation. Returns/accepts GATT kernel virtual address. */
   5.567 ++#define alloc_gatt_pages(order)		\
   5.568 ++	((char *)__get_free_pages(GFP_KERNEL, (order)))
   5.569 ++#define free_gatt_pages(table, order)	\
   5.570 ++	free_pages((unsigned long)(table), (order))
   5.571 ++
   5.572 + #endif
   5.573 +--- linux-2.6.11/include/asm-x86_64/agp.h	2005-03-02 07:37:30 +00:00
   5.574 ++++ linux-2.6.11-agp/include/asm-x86_64/agp.h	2005-03-22 11:18:22 +00:00
   5.575 +@@ -19,4 +19,14 @@
   5.576      worth it. Would need a page for it. */
   5.577 --#define flush_agp_cache() asm volatile("wbinvd":::"memory")
   5.578 -+#define flush_agp_cache() wbinvd()
   5.579 + #define flush_agp_cache() asm volatile("wbinvd":::"memory")
   5.580   
   5.581 ++/* Convert a physical address to an address suitable for the GART. */
   5.582 ++#define phys_to_gart(x) (x)
   5.583 ++#define gart_to_phys(x) (x)
   5.584 ++
   5.585 ++/* GATT allocation. Returns/accepts GATT kernel virtual address. */
   5.586 ++#define alloc_gatt_pages(order)		\
   5.587 ++	((char *)__get_free_pages(GFP_KERNEL, (order)))
   5.588 ++#define free_gatt_pages(table, order)	\
   5.589 ++	free_pages((unsigned long)(table), (order))
   5.590 ++
   5.591   #endif
     6.1 --- a/tools/libxc/xc_private.h	Thu Mar 24 21:24:38 2005 +0000
     6.2 +++ b/tools/libxc/xc_private.h	Thu Mar 24 21:25:36 2005 +0000
     6.3 @@ -72,7 +72,7 @@ static inline int do_xen_hypercall(int x
     6.4  
     6.5  static inline int do_dom0_op(int xc_handle, dom0_op_t *op)
     6.6  {
     6.7 -    int ret = -1;
     6.8 +    int ret = -1, retries = 0;
     6.9      privcmd_hypercall_t hypercall;
    6.10  
    6.11      op->interface_version = DOM0_INTERFACE_VERSION;
    6.12 @@ -86,8 +86,18 @@ static inline int do_dom0_op(int xc_hand
    6.13          goto out1;
    6.14      }
    6.15  
    6.16 + again:
    6.17      if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 )
    6.18      {
    6.19 +        if ( (errno == EAGAIN) && (retries++ < 10) )
    6.20 +        {
    6.21 +            /*
    6.22 +             * This was added for memory allocation, where we can get EAGAIN
    6.23 +             * if memory is unavailable because it is on the scrub list.
    6.24 +             */
    6.25 +            sleep(1);
    6.26 +            goto again;
    6.27 +        }
    6.28          if ( errno == EACCES )
    6.29              fprintf(stderr, "Dom0 operation failed -- need to"
    6.30                      " rebuild the user-space tool set?\n");
     7.1 --- a/xen/arch/x86/domain.c	Thu Mar 24 21:24:38 2005 +0000
     7.2 +++ b/xen/arch/x86/domain.c	Thu Mar 24 21:25:36 2005 +0000
     7.3 @@ -69,7 +69,10 @@ static __attribute_used__ void idle_loop
     7.4      {
     7.5          irq_stat[cpu].idle_timestamp = jiffies;
     7.6          while ( !softirq_pending(cpu) )
     7.7 +        {
     7.8 +            page_scrub_schedule_work();
     7.9              default_idle();
    7.10 +        }
    7.11          do_softirq();
    7.12      }
    7.13  }
     8.1 --- a/xen/common/domain.c	Thu Mar 24 21:24:38 2005 +0000
     8.2 +++ b/xen/common/domain.c	Thu Mar 24 21:25:36 2005 +0000
     8.3 @@ -197,7 +197,7 @@ unsigned int alloc_new_dom_mem(struct do
     8.4          if ( unlikely((page = alloc_domheap_page(d)) == NULL) )
     8.5          {
     8.6              domain_relinquish_memory(d);
     8.7 -            return -ENOMEM;
     8.8 +            return list_empty(&page_scrub_list) ? -ENOMEM : -EAGAIN;
     8.9          }
    8.10  
    8.11          /* Initialise the machine-to-phys mapping for this page. */
     9.1 --- a/xen/common/page_alloc.c	Thu Mar 24 21:24:38 2005 +0000
     9.2 +++ b/xen/common/page_alloc.c	Thu Mar 24 21:25:36 2005 +0000
     9.3 @@ -28,6 +28,7 @@
     9.4  #include <xen/spinlock.h>
     9.5  #include <xen/slab.h>
     9.6  #include <xen/irq.h>
     9.7 +#include <xen/softirq.h>
     9.8  #include <asm/domain_page.h>
     9.9  
    9.10  /*
    9.11 @@ -551,7 +552,6 @@ void free_domheap_pages(struct pfn_info 
    9.12  {
    9.13      int            i, drop_dom_ref;
    9.14      struct domain *d = pg->u.inuse.domain;
    9.15 -    void          *p;
    9.16  
    9.17      ASSERT(!in_irq());
    9.18  
    9.19 @@ -579,18 +579,6 @@ void free_domheap_pages(struct pfn_info 
    9.20              pg[i].tlbflush_timestamp  = tlbflush_current_time();
    9.21              pg[i].u.free.cpu_mask     = 1 << d->processor;
    9.22              list_del(&pg[i].list);
    9.23 -
    9.24 -            /*
    9.25 -             * Normally we expect a domain to clear pages before freeing them,
    9.26 -             * if it cares about the secrecy of their contents. However, after
    9.27 -             * a domain has died we assume responsibility for erasure.
    9.28 -             */
    9.29 -            if ( unlikely(test_bit(DF_DYING, &d->flags)) )
    9.30 -            {
    9.31 -                p = map_domain_mem(page_to_phys(&pg[i]));
    9.32 -                clear_page(p);
    9.33 -                unmap_domain_mem(p);
    9.34 -            }
    9.35          }
    9.36  
    9.37          d->tot_pages -= 1 << order;
    9.38 @@ -598,7 +586,24 @@ void free_domheap_pages(struct pfn_info 
    9.39  
    9.40          spin_unlock_recursive(&d->page_alloc_lock);
    9.41  
    9.42 -        free_heap_pages(MEMZONE_DOM, pg, order);
    9.43 +        if ( likely(!test_bit(DF_DYING, &d->flags)) )
    9.44 +        {
    9.45 +            free_heap_pages(MEMZONE_DOM, pg, order);
    9.46 +        }
    9.47 +        else
    9.48 +        {
    9.49 +            /*
    9.50 +             * Normally we expect a domain to clear pages before freeing them,
    9.51 +             * if it cares about the secrecy of their contents. However, after
    9.52 +             * a domain has died we assume responsibility for erasure.
    9.53 +             */
    9.54 +            for ( i = 0; i < (1 << order); i++ )
    9.55 +            {
    9.56 +                spin_lock(&page_scrub_lock);
    9.57 +                list_add(&pg[i].list, &page_scrub_list);
    9.58 +                spin_unlock(&page_scrub_lock);
    9.59 +            }
    9.60 +        }
    9.61      }
    9.62      else
    9.63      {
    9.64 @@ -616,3 +621,63 @@ unsigned long avail_domheap_pages(void)
    9.65  {
    9.66      return avail[MEMZONE_DOM];
    9.67  }
    9.68 +
    9.69 +
    9.70 +
    9.71 +/*************************
    9.72 + * PAGE SCRUBBING
    9.73 + */
    9.74 +
    9.75 +static spinlock_t page_scrub_lock;
    9.76 +struct list_head page_scrub_list;
    9.77 +
    9.78 +static void page_scrub_softirq(void)
    9.79 +{
    9.80 +    struct list_head *ent;
    9.81 +    struct pfn_info  *pg;
    9.82 +    void             *p;
    9.83 +    int               i;
    9.84 +    s_time_t          start = NOW();
    9.85 +
    9.86 +    /* Aim to do 1ms of work (ten percent of a 10ms jiffy). */
    9.87 +    do {
    9.88 +        spin_lock(&page_scrub_lock);
    9.89 +
    9.90 +        if ( unlikely((ent = page_scrub_list.next) == &page_scrub_list) )
    9.91 +        {
    9.92 +            spin_unlock(&page_scrub_lock);
    9.93 +            return;
    9.94 +        }
    9.95 +        
    9.96 +        /* Peel up to 16 pages from the list. */
    9.97 +        for ( i = 0; i < 16; i++ )
    9.98 +            if ( (ent = ent->next) == &page_scrub_list )
    9.99 +                break;
   9.100 +        
   9.101 +        /* Remove peeled pages from the list. */
   9.102 +        ent->next->prev = &page_scrub_list;
   9.103 +        page_scrub_list.next = ent->next;
   9.104 +        
   9.105 +        spin_unlock(&page_scrub_lock);
   9.106 +        
   9.107 +        /* Working backwards, scrub each page in turn. */
   9.108 +        while ( ent != &page_scrub_list )
   9.109 +        {
   9.110 +            pg = list_entry(ent, struct pfn_info, list);
   9.111 +            ent = ent->prev;
   9.112 +            p = map_domain_mem(page_to_phys(pg));
   9.113 +            clear_page(p);
   9.114 +            unmap_domain_mem(p);
   9.115 +            free_heap_pages(MEMZONE_DOM, pg, 0);
   9.116 +        }
   9.117 +    } while ( (NOW() - start) < MILLISECS(1) );
   9.118 +}
   9.119 +
   9.120 +static __init int page_scrub_init(void)
   9.121 +{
   9.122 +    spin_lock_init(&page_scrub_lock);
   9.123 +    INIT_LIST_HEAD(&page_scrub_list);
   9.124 +    open_softirq(PAGE_SCRUB_SOFTIRQ, page_scrub_softirq);
   9.125 +    return 0;
   9.126 +}
   9.127 +__initcall(page_scrub_init);
    10.1 --- a/xen/common/schedule.c	Thu Mar 24 21:24:38 2005 +0000
    10.2 +++ b/xen/common/schedule.c	Thu Mar 24 21:25:36 2005 +0000
    10.3 @@ -437,6 +437,8 @@ static void t_timer_fn(unsigned long unu
    10.4      if ( !is_idle_task(d) && update_dom_time(d) )
    10.5          send_guest_virq(d, VIRQ_TIMER);
    10.6  
    10.7 +    page_scrub_schedule_work();
    10.8 +
    10.9      t_timer[d->processor].expires = NOW() + MILLISECS(10);
   10.10      add_ac_timer(&t_timer[d->processor]);
   10.11  }
    11.1 --- a/xen/include/xen/mm.h	Thu Mar 24 21:24:38 2005 +0000
    11.2 +++ b/xen/include/xen/mm.h	Thu Mar 24 21:25:36 2005 +0000
    11.3 @@ -2,6 +2,10 @@
    11.4  #ifndef __XEN_MM_H__
    11.5  #define __XEN_MM_H__
    11.6  
    11.7 +#include <xen/config.h>
    11.8 +#include <xen/list.h>
    11.9 +#include <xen/spinlock.h>
   11.10 +
   11.11  struct domain;
   11.12  struct pfn_info;
   11.13  
   11.14 @@ -34,6 +38,15 @@ unsigned long avail_domheap_pages(void);
   11.15  #define alloc_domheap_page(_d) (alloc_domheap_pages(_d,0))
   11.16  #define free_domheap_page(_p) (free_domheap_pages(_p,0))
   11.17  
   11.18 +/* Automatic page scrubbing for dead domains. */
   11.19 +extern spinlock_t page_scrub_lock;
   11.20 +extern struct list_head page_scrub_list;
   11.21 +#define page_scrub_schedule_work()              \
   11.22 +    do {                                        \
   11.23 +        if ( !list_empty(&page_scrub_list) )    \
   11.24 +            raise_softirq(PAGE_SCRUB_SOFTIRQ);  \
   11.25 +    } while ( 0 )
   11.26 +
   11.27  #include <asm/mm.h>
   11.28  
   11.29  #endif /* __XEN_MM_H__ */
    12.1 --- a/xen/include/xen/softirq.h	Thu Mar 24 21:24:38 2005 +0000
    12.2 +++ b/xen/include/xen/softirq.h	Thu Mar 24 21:25:36 2005 +0000
    12.3 @@ -7,7 +7,8 @@
    12.4  #define NEW_TLBFLUSH_CLOCK_PERIOD_SOFTIRQ 2
    12.5  #define KEYPRESS_SOFTIRQ                  3
    12.6  #define NMI_SOFTIRQ                       4
    12.7 -#define NR_SOFTIRQS                       5
    12.8 +#define PAGE_SCRUB_SOFTIRQ                5
    12.9 +#define NR_SOFTIRQS                       6
   12.10  
   12.11  #ifndef __ASSEMBLY__
   12.12