Skip to contentSkip to conversation

AGP 4/7: add generic print of AGP version & mode

PATCH In review Bjorn Helgaas 2 participants 2 messages Jan 7, 2003 – Jan 8, 2003 Agpgart driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 AGP 4/7: add generic print of AGP version & mode

# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas:
# ChangeSet 1.974 -> 1.975
# drivers/char/agp/generic.c 1.11 -> 1.12
# drivers/char/agp/sworks-agp.c 1.14 -> 1.15
# drivers/char/agp/amd-k8-agp.c 1.17 -> 1.18
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/01/07 [email protected] 1.975
# Print AGP version & mode when programming devices.
# --------------------------------------------
#

drivers/char/agp/amd-k8-agp.c +3 -10
diff -Nru a/drivers/char/agp/amd-k8-agp.c b/drivers/char/agp/amd-k8-agp.c
@@ -382,9 +382,6 @@
 			 * Ok, here we have a AGP device. Disable impossible 
 			 * settings, and adjust the readqueue to the minimum.
 			 */
-
-			printk (KERN_INFO "AGP: Setting up AGPv3 capable device at %d:%d:%d\n",
-					device->bus->number, PCI_FUNC(device->devfn), PCI_SLOT(device->devfn));
 			pci_read_config_dword(device, cap_ptr + 4, &scratch);
 
 			/* adjust RQ depth */
@@ -402,15 +399,11 @@
 			if (!((command & 0x10) && (scratch & 0x10) && (mode & 0x10)))
 				command &= ~0x10;
 
-			if (!((command & 2) && (scratch & 2) && (mode & 2))) {
+			if (!((command & 2) && (scratch & 2) && (mode & 2)))
 				command &= ~2;		/* 8x */
-				printk (KERN_INFO "AGP: Putting device into 8x mode\n");
-			}
 
-			if (!((command & 1) && (scratch & 1) && (mode & 1))) {
+			if (!((command & 1) && (scratch & 1) && (mode & 1)))
 				command &= ~1;		/* 4x */
-				printk (KERN_INFO "AGP: Putting device into 4x mode\n");
-			}
 		}
 	}
 	/*
@@ -433,7 +426,7 @@
 	 *        command registers.
 	 */
 
-	agp_device_command(command);
+	agp_device_command(command, 1);
 }
 
 
drivers/char/agp/generic.c +9 -2
diff -Nru a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
@@ -314,15 +314,22 @@
 
 /* Generic Agp routines - Start */
 
-void agp_device_command(u32 command)
+void agp_device_command(u32 command, int agp_v3)
 {
 	struct pci_dev *device;
+	int mode;
+
+	mode = command & 0x7;
+	if (agp_v3)
+		mode *= 4;
 
 	pci_for_each_dev(device) {
 		u8 agp = pci_find_capability(device, PCI_CAP_ID_AGP);
 		if (!agp)
 			continue;
 
+		printk(KERN_INFO PFX "Putting AGP V%d device at %s into %dx mode\n",
+				agp_v3 ? 3 : 2, device->slot_name, mode);
 		pci_write_config_dword(device, agp + 8, command);
 	}
 }
@@ -409,7 +416,7 @@
 	 *        command registers.
 	 */
 
-	agp_device_command(command);
+	agp_device_command(command, 0);
 }
 
 int agp_generic_create_gatt_table(void)
drivers/char/agp/sworks-agp.c +1 -1
diff -Nru a/drivers/char/agp/sworks-agp.c b/drivers/char/agp/sworks-agp.c
@@ -496,7 +496,7 @@
 	 *        command registers.
 	 */
 
-	agp_device_command(command);
+	agp_device_command(command, 0);
 }
 
 static int __init serverworks_setup (struct pci_dev *pdev)
#1 lore raw

Hi Bjorn,
hi lkml,

drivers/char/agp/generic.c line 317

Quoted 9 lines · Bjorn Helgaas

diff -Nru a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c

drivers/char/agp/generic.c +1 -1
@@ -314,15 +314,22 @@
 
 /* Generic Agp routines - Start */
 
-void agp_device_command(u32 command)
+void agp_device_command(u32 command, int agp_v3)

Why not agp_version?

Quoted 5 lines
drivers/char/agp/generic.c +3 -0
 {
 	struct pci_dev *device;
+	int mode;
+
+	mode = command & 0x7;

drivers/char/agp/generic.c line 332

Quoted 10 lines
drivers/char/agp/generic.c +4 -0
+	if (agp_v3)
+		mode *= 4;
 
 	pci_for_each_dev(device) {
 		u8 agp = pci_find_capability(device, PCI_CAP_ID_AGP);
 		if (!agp)
 			continue;
 
+		printk(KERN_INFO PFX "Putting AGP V%d device at %s into %dx mode\n",
+				agp_v3 ? 3 : 2, device->slot_name, mode);

Why not use agp_version directly here?

drivers/char/agp/generic.c line 335

Quoted 3 lines
drivers/char/agp/generic.c +0 -0
 		pci_write_config_dword(device, agp + 8, command);
 	}
 }

And always supply AGP_VERSION_1, AGP_VERSION_2, AGP_VERSION_3 and so or simply numbers to that command?

This offers a lot of possibilities:

- Version checking (drivers can deny commands not suitable for this interface, if this checking is enabled)

- Support for AGP_VERSION_4 can be implemented without obfuscating the interface for older (non-compliant) drivers.

- One check less ;-)

- Cleaner Code

Regards

Ingo Oeser

Signature · 1 line
Science is what we can tell a computer. Art is everything else. --- D.E.Knuth