bk://linux-dj.bkbits.net/agpgart
davej@redhat.com|ChangeSet|20040406224441|00286 davej

# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2004/04/06 23:44:41+01:00 davej@redhat.com 
#   [AGPGART] Whitespace cleanup in sis-agp
#   use spaces instead of (borked) tabs.
# 
# drivers/char/agp/sis-agp.c
#   2004/04/06 23:44:35+01:00 davej@redhat.com +7 -7
#   [AGPGART] Whitespace cleanup in sis-agp
#   use spaces instead of (borked) tabs.
# 
# ChangeSet
#   2004/04/06 22:12:22+01:00 davej@redhat.com 
#   [AGPGART] Fix SiS 746 again.
#   Turns out that this chipset won't work in AGPv3 mode with the generic AGPv3 routines.
#   *somehow*, it works in AGPv3 mode with AGPv2 aperture sizing etc. Very, very strange.
#   Still, until we get some docs from SiS, some support is better than none.
# 
# drivers/char/agp/sis-agp.c
#   2004/04/06 22:12:16+01:00 davej@redhat.com +11 -5
#   [AGPGART] Fix SiS 746 again.
#   Turns out that this chipset won't work in AGPv3 mode with the generic AGPv3 routines.
#   *somehow*, it works in AGPv3 mode with AGPv2 aperture sizing etc. Very, very strange.
#   Still, until we get some docs from SiS, some support is better than none.
# 
# ChangeSet
#   2004/04/05 20:08:47+01:00 davej@redhat.com 
#   [AGPGART] Previous AGPv3 SiS fixes broke AGPv2 users. Oops.
# 
# drivers/char/agp/sis-agp.c
#   2004/04/05 20:08:38+01:00 davej@redhat.com +3 -3
#   [AGPGART] Previous AGPv3 SiS fixes broke AGPv2 users. Oops.
# 
# ChangeSet
#   2004/04/02 10:44:51+01:00 davej@redhat.com 
#   [AGPGART] EM64T driver should only run when we have a supported CPU.
#   Otherwise we see strange things at boottime if we compile in all drivers, like this..
#   
#   agpgart: Unsupported Intel chipset (device id: 1a30)
#   agpgart: Detected an Intel i845 Chipset.
# 
# drivers/char/agp/intel-mch-agp.c
#   2004/04/02 10:44:45+01:00 davej@redhat.com +4 -1
#   [AGPGART] EM64T driver should only run when we have a supported CPU.
#   Otherwise we see strange things at boottime if we compile in all drivers, like this..
#   
#   agpgart: Unsupported Intel chipset (device id: 1a30)
#   agpgart: Detected an Intel i845 Chipset.
# 
# ChangeSet
#   2004/04/02 01:42:56+01:00 davej@redhat.com 
#   [AGPGART] Actually Call the SiS workaround on SiS 746 too.
# 
# drivers/char/agp/sis-agp.c
#   2004/04/02 01:42:51+01:00 davej@redhat.com +3 -2
#   [AGPGART] Actually Call the SiS workaround on SiS 746 too.
# 
# ChangeSet
#   2004/04/01 19:27:38+01:00 davej@redhat.com 
#   [AGPGART] Fix SiS workaround printk. This happens on multiple chipsets.
# 
# drivers/char/agp/sis-agp.c
#   2004/04/01 19:27:32+01:00 davej@redhat.com +1 -1
#   [AGPGART] Fix SiS workaround printk. This happens on multiple chipsets.
# 
# ChangeSet
#   2004/04/01 19:12:53+01:00 davej@redhat.com 
#   [AGPGART] SiS 746 chipset also needs extra recovery time when changing mode.
# 
# drivers/char/agp/sis-agp.c
#   2004/04/01 19:12:47+01:00 davej@redhat.com +7 -3
#   [AGPGART] SiS 746 chipset also needs extra recovery time when changing mode.
# 
# ChangeSet
#   2004/04/01 17:49:08+01:00 davej@redhat.com 
#   [AGPGART] Efficeon GART driver can use generic masking routine.
# 
# drivers/char/agp/efficeon-agp.c
#   2004/04/01 17:49:02+01:00 davej@redhat.com +1 -8
#   [AGPGART] Efficeon GART driver can use generic masking routine.
# 
# ChangeSet
#   2004/04/01 17:34:57+01:00 davej@redhat.com 
#   [AGPGART] VIA GART driver can use the new generic AGPv3 masks.
# 
# drivers/char/agp/via-agp.c
#   2004/04/01 17:34:50+01:00 davej@redhat.com +1 -15
#   [AGPGART] VIA GART driver can use the new generic AGPv3 masks.
# 
diff -Nru a/drivers/char/agp/efficeon-agp.c b/drivers/char/agp/efficeon-agp.c
--- a/drivers/char/agp/efficeon-agp.c	Thu Apr  8 14:51:30 2004
+++ b/drivers/char/agp/efficeon-agp.c	Thu Apr  8 14:51:30 2004
@@ -302,13 +302,6 @@
 	return 0;
 }
 
-/* GATT entry: (physical address | 1) */
-static unsigned long efficeon_mask_memory(unsigned long addr, int type)
-{
-	/* Memory type is ignored */
-
-	return addr | agp_bridge->driver->masks[0].mask;
-}
 
 struct agp_bridge_driver efficeon_driver = {
 	.owner			= THIS_MODULE,
@@ -319,7 +312,7 @@
 	.fetch_size		= efficeon_fetch_size,
 	.cleanup		= efficeon_cleanup,
 	.tlb_flush		= efficeon_tlbflush,
-	.mask_memory		= efficeon_mask_memory,
+	.mask_memory		= agp_generic_mask_memory,
 	.masks			= efficeon_generic_masks,
 	.agp_enable		= agp_generic_enable,
 	.cache_flush		= global_cache_flush,
diff -Nru a/drivers/char/agp/intel-mch-agp.c b/drivers/char/agp/intel-mch-agp.c
--- a/drivers/char/agp/intel-mch-agp.c	Thu Apr  8 14:51:30 2004
+++ b/drivers/char/agp/intel-mch-agp.c	Thu Apr  8 14:51:30 2004
@@ -487,9 +487,12 @@
 				     const struct pci_device_id *ent)
 {
 	struct agp_bridge_data *bridge;
+	struct resource *r;
 	char *name = "(unknown)";
 	u8 cap_ptr = 0;
-	struct resource *r;
+
+	if (!boot_cpu_has(X86_FEATURE_LM))
+		return -ENODEV;
 
 	cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP);
 
diff -Nru a/drivers/char/agp/sis-agp.c b/drivers/char/agp/sis-agp.c
--- a/drivers/char/agp/sis-agp.c	Thu Apr  8 14:51:30 2004
+++ b/drivers/char/agp/sis-agp.c	Thu Apr  8 14:51:30 2004
@@ -93,10 +93,14 @@
 
 		pci_write_config_dword(device, agp + PCI_AGP_COMMAND, command);
 
-		if(device->device == PCI_DEVICE_ID_SI_648) {
-			// weird: on 648 and 648fx chipsets any rate change in the target command register
-			// triggers a 5ms screwup during which the master cannot be configured
-			printk(KERN_INFO PFX "sis 648 agp fix - giving bridge time to recover\n");
+		/*
+		 * Weird: on 648(fx) and 746(fx) chipsets any rate change in the target
+		 * command register triggers a 5ms screwup during which the master
+		 * cannot be configured		 
+		 */
+		if (device->device == PCI_DEVICE_ID_SI_648 ||
+		    device->device == PCI_DEVICE_ID_SI_746) {
+			printk(KERN_INFO PFX "SiS chipset with AGP problems detected. Giving bridge time to recover.\n");
 			set_current_state(TASK_UNINTERRUPTIBLE);
 			schedule_timeout (1+(HZ*10)/1000);
 		}
@@ -221,19 +225,26 @@
 
 static void __devinit sis_get_driver(struct agp_bridge_data *bridge)
 {
-	if (bridge->dev->device == PCI_DEVICE_ID_SI_648) {
-		if (agp_bridge->major_version == 3 && agp_bridge->minor_version < 5) {
-			sis_driver.agp_enable=sis_648_enable;
-		} else {
-			sis_driver.agp_enable			= sis_648_enable;
-			sis_driver.aperture_sizes		= agp3_generic_sizes;
-			sis_driver.size_type			= U16_APER_SIZE;
-			sis_driver.num_aperture_sizes	= AGP_GENERIC_SIZES_ENTRIES;
-			sis_driver.configure			= agp3_generic_configure;
-			sis_driver.fetch_size			= agp3_generic_fetch_size;
-			sis_driver.cleanup				= agp3_generic_cleanup;
-			sis_driver.tlb_flush			= agp3_generic_tlbflush;
+	if (bridge->dev->device == PCI_DEVICE_ID_SI_648) { 
+		sis_driver.agp_enable=sis_648_enable;
+		if (agp_bridge->major_version == 3) {
+			sis_driver.aperture_sizes = agp3_generic_sizes;
+			sis_driver.size_type = U16_APER_SIZE;
+			sis_driver.num_aperture_sizes = AGP_GENERIC_SIZES_ENTRIES;
+			sis_driver.configure = agp3_generic_configure;
+			sis_driver.fetch_size = agp3_generic_fetch_size;
+			sis_driver.cleanup = agp3_generic_cleanup;
+			sis_driver.tlb_flush = agp3_generic_tlbflush;
 		}
+	}
+
+	if (bridge->dev->device == PCI_DEVICE_ID_SI_746) {
+		/*
+		 * We don't know enough about the 746 to enable it properly.
+		 * Though we do know that it needs the 'delay' hack to settle
+		 * after changing modes.
+		 */
+		sis_driver.agp_enable=sis_648_enable;
 	}
 }
 
diff -Nru a/drivers/char/agp/via-agp.c b/drivers/char/agp/via-agp.c
--- a/drivers/char/agp/via-agp.c	Thu Apr  8 14:51:30 2004
+++ b/drivers/char/agp/via-agp.c	Thu Apr  8 14:51:30 2004
@@ -160,23 +160,9 @@
 }
 
 
-static struct aper_size_info_16 via_generic_agp3_sizes[11] =
-{
-	{ 4,     1024,  0, 1<<11|1<<10|1<<9|1<<8|1<<5|1<<4|1<<3|1<<2|1<<1|1<<0 },
-	{ 8,     2048,  1, 1<<11|1<<10|1<<9|1<<8|1<<5|1<<4|1<<3|1<<2|1<<1},
-	{ 16,    4096,  2, 1<<11|1<<10|1<<9|1<<8|1<<5|1<<4|1<<3|1<<2},
-	{ 32,    8192,  3, 1<<11|1<<10|1<<9|1<<8|1<<5|1<<4|1<<3},
-	{ 64,   16384,  4, 1<<11|1<<10|1<<9|1<<8|1<<5|1<<4},
-	{ 128,  32768,  5, 1<<11|1<<10|1<<9|1<<8|1<<5},
-	{ 256,  65536,  6, 1<<11|1<<10|1<<9|1<<8},
-	{ 512,  131072, 7, 1<<11|1<<10|1<<9},
-	{ 1024, 262144, 8, 1<<11|1<<10},
-	{ 2048, 524288, 9, 1<<11}	/* 2GB <- Max supported */
-};
-
 struct agp_bridge_driver via_agp3_driver = {
 	.owner			= THIS_MODULE,
-	.aperture_sizes		= via_generic_agp3_sizes,
+	.aperture_sizes		= agp3_generic_sizes,
 	.size_type		= U8_APER_SIZE,
 	.num_aperture_sizes	= 10,
 	.configure		= via_configure_agp3,