From 390061ccc2d8335bb5a369448b27f5b51bb3d80c Mon Sep 17 00:00:00 2001
From: Dave Jones <davej@codemonkey.org.uk>
Date: Thu, 15 May 2003 21:27:47 +0100
Subject: [PATCH] [AGPGART] nForce driver needs its own insert/remove routines.
 These can't use the generic routines due to alignment issues.

---
 drivers/char/agp/nvidia-agp.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/char/agp/nvidia-agp.c b/drivers/char/agp/nvidia-agp.c
index d7250010301f..87a029b329ef 100644
--- a/drivers/char/agp/nvidia-agp.c
+++ b/drivers/char/agp/nvidia-agp.c
@@ -140,7 +140,12 @@ static void nvidia_cleanup(void)
 }
 
 
-#if 0
+/*
+ * Note we can't use the generic routines, even though they are 99% the same.
+ * Aperture sizes <64M still requires a full 64k GART directory, but
+ * only use the portion of the TLB entries that correspond to the apertures
+ * alignment inside the surrounding 64M block.
+ */
 extern int agp_memory_reserved;
 
 static int nvidia_insert_memory(agp_memory * mem, off_t pg_start, int type)
@@ -166,10 +171,11 @@ static int nvidia_insert_memory(agp_memory * mem, off_t pg_start, int type)
 	for (i = 0, j = pg_start; i < mem->page_count; i++, j++)
 		agp_bridge->gatt_table[nvidia_private.pg_offset + j] = mem->memory[i];
 
-	agp_bridge->tlb_flush(mem);
+	agp_bridge->driver->tlb_flush(mem);
 	return 0;
 }
 
+
 static int nvidia_remove_memory(agp_memory * mem, off_t pg_start, int type)
 {
 	int i;
@@ -182,10 +188,9 @@ static int nvidia_remove_memory(agp_memory * mem, off_t pg_start, int type)
 		    (unsigned long) agp_bridge->scratch_page;
 	}
 
-	agp_bridge->tlb_flush(mem);
+	agp_bridge->driver->tlb_flush(mem);
 	return 0;
 }
-#endif
 
 
 static void nvidia_tlbflush(agp_memory * mem)
@@ -251,8 +256,8 @@ struct agp_bridge_driver nvidia_driver = {
 	.cache_flush		= global_cache_flush,
 	.create_gatt_table	= agp_generic_create_gatt_table,
 	.free_gatt_table	= agp_generic_free_gatt_table,
-	.insert_memory		= agp_generic_insert_memory,
-	.remove_memory		= agp_generic_remove_memory,
+	.insert_memory		= nvidia_insert_memory,
+	.remove_memory		= nvidia_remove_memory,
 	.alloc_by_type		= agp_generic_alloc_by_type,
 	.free_by_type		= agp_generic_free_by_type,
 	.agp_alloc_page		= agp_generic_alloc_page,
-- 
2.30.9