mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bjorn Helgaas <bjorn_helgaas@hp.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: linux-kernel@vger.kernel.org, dri-devel@lists.sourceforge.net,
	Bjorn Helgaas <bjorn_helgaas@hp.com>
Subject: [PATCH] 2.4.18-pre6 AGP enable fixes
Date: Wed, 23 Jan 2002 13:46:02 -0700	[thread overview]
Message-ID: <20020123204523.04A764556@ldl.fc.hp.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2132 bytes --]

In 2.4.17-pre5, agp_generic_agp_enable() and serverworks_agp_enable()
were changed to look for AGP devices as coprocessors on non-VGA
devices as well as VGA devices.

But those functions contain TWO loops that scan for AGP devices (one
to collect the settings they support, and a second to update the
command registers), and 2.4.17-pre5 only changed the first loop in
each case.  Shouldn't both loops be changed, as in the "agp_dev" patch
attached?

While looking at this code, I noticed a possible further improvement.
Currently it looks like this:

        pci_for_each_dev(device)
        {
                if((((device->class >> 16) & 0xFF) != PCI_BASE_CLASS_DISPLAY) &&
                        (device->class != (PCI_CLASS_PROCESSOR_CO << 8)))
                        continue;

                pci_read_config_dword(device, 0x04, &scratch);
 
                if (!(scratch & 0x00100000))
                        continue;
 
                pci_read_config_byte(device, 0x34, &cap_ptr);
 
                if (cap_ptr != 0x00) {
                        do {
                                pci_read_config_dword(device,
                                                      cap_ptr, &cap_id);
 
                                if ((cap_id & 0xff) != 0x02)
                                        cap_ptr = (cap_id >> 8) & 0xff;
                        }
                        while (((cap_id & 0xff) != 0x02) && (cap_ptr != 0x00));
                }
                if (cap_ptr != 0x00) {
		        ...

The bulk of the above is just a reimplementation of pci_find_capability(),
so what about changing the whole shooting match to the following:

        pci_for_each_dev(device) {
                cap_ptr = pci_find_capability(device, PCI_CAP_ID_AGP);
                if (cap_ptr != 0x00) {
		        ...

Is there anything gained by checking the device class before looking
for the AGP capability?  The "agp_find_cap" patch attached implements
this idea.  I've compiled and booted kernels with both patches, but
they're otherwise untested.

-- 
Bjorn Helgaas - bjorn_helgaas@hp.com
Linux Systems Operation R&D
Hewlett-Packard

[-- Attachment #2: agp_dev-2.4.18-pre6.patch --]
[-- Type: text/plain, Size: 1356 bytes --]

diff -u -X /home/helgaas/exclude -r linux-2.4.18-pre6/drivers/char/agp/agpgart_be.c build/linux-2.4.18-pre6/drivers/char/agp/agpgart_be.c
--- linux-2.4.18-pre6/drivers/char/agp/agpgart_be.c	Wed Jan 23 10:16:39 2002
+++ build/linux-2.4.18-pre6/drivers/char/agp/agpgart_be.c	Wed Jan 23 10:23:23 2002
@@ -506,8 +506,17 @@
 	 *        command registers.
 	 */
 
-	while ((device = pci_find_class(PCI_CLASS_DISPLAY_VGA << 8,
-					device)) != NULL) {
+	pci_for_each_dev(device)
+	{
+		/*
+		 *	Enable AGP devices. Most will be VGA display but
+		 *	some may be coprocessors on non VGA devices too
+		 */
+		 
+		if((((device->class >> 16) & 0xFF) != PCI_BASE_CLASS_DISPLAY) &&
+			(device->class != (PCI_CLASS_PROCESSOR_CO << 8)))
+			continue;
+
 		pci_read_config_dword(device, 0x04, &scratch);
 
 		if (!(scratch & 0x00100000))
@@ -3421,8 +3430,17 @@
 	 *        command registers.
 	 */
 
-	while ((device = pci_find_class(PCI_CLASS_DISPLAY_VGA << 8,
-					device)) != NULL) {
+	pci_for_each_dev(device)
+	{
+		/*
+		 *	Enable AGP devices. Most will be VGA display but
+		 *	some may be coprocessors on non VGA devices too
+		 */
+		 
+		if((((device->class >> 16) & 0xFF) != PCI_BASE_CLASS_DISPLAY) &&
+			(device->class != (PCI_CLASS_PROCESSOR_CO << 8)))
+			continue;
+
 		pci_read_config_dword(device, 0x04, &scratch);
 
 		if (!(scratch & 0x00100000))

[-- Attachment #3: agp_find_cap-2.4.18-pre6.patch --]
[-- Type: text/plain, Size: 3866 bytes --]

diff -u -X /home/helgaas/exclude -r linux-2.4.18-pre6/drivers/char/agp/agpgart_be.c build/linux-2.4.18-pre6-find_cap/drivers/char/agp/agpgart_be.c
--- linux-2.4.18-pre6/drivers/char/agp/agpgart_be.c	Wed Jan 23 10:16:39 2002
+++ build/linux-2.4.18-pre6-find_cap/drivers/char/agp/agpgart_be.c	Wed Jan 23 10:32:12 2002
@@ -410,34 +410,8 @@
 	 */
 
 
-	pci_for_each_dev(device)
-	{
-		/*
-		 *	Enable AGP devices. Most will be VGA display but
-		 *	some may be coprocessors on non VGA devices too
-		 */
-		 
-		if((((device->class >> 16) & 0xFF) != PCI_BASE_CLASS_DISPLAY) &&
-			(device->class != (PCI_CLASS_PROCESSOR_CO << 8)))
-			continue;
-
-		pci_read_config_dword(device, 0x04, &scratch);
-
-		if (!(scratch & 0x00100000))
-			continue;
-
-		pci_read_config_byte(device, 0x34, &cap_ptr);
-
-		if (cap_ptr != 0x00) {
-			do {
-				pci_read_config_dword(device,
-						      cap_ptr, &cap_id);
-
-				if ((cap_id & 0xff) != 0x02)
-					cap_ptr = (cap_id >> 8) & 0xff;
-			}
-			while (((cap_id & 0xff) != 0x02) && (cap_ptr != 0x00));
-		}
+	pci_for_each_dev(device) {
+		cap_ptr = pci_find_capability(device, PCI_CAP_ID_AGP);
 		if (cap_ptr != 0x00) {
 			/*
 			 * Ok, here we have a AGP device. Disable impossible 
@@ -506,25 +480,8 @@
 	 *        command registers.
 	 */
 
-	while ((device = pci_find_class(PCI_CLASS_DISPLAY_VGA << 8,
-					device)) != NULL) {
-		pci_read_config_dword(device, 0x04, &scratch);
-
-		if (!(scratch & 0x00100000))
-			continue;
-
-		pci_read_config_byte(device, 0x34, &cap_ptr);
-
-		if (cap_ptr != 0x00) {
-			do {
-				pci_read_config_dword(device,
-						      cap_ptr, &cap_id);
-
-				if ((cap_id & 0xff) != 0x02)
-					cap_ptr = (cap_id >> 8) & 0xff;
-			}
-			while (((cap_id & 0xff) != 0x02) && (cap_ptr != 0x00));
-		}
+	pci_for_each_dev(device) {
+		cap_ptr = pci_find_capability(device, PCI_CAP_ID_AGP);
 		if (cap_ptr != 0x00)
 			pci_write_config_dword(device, cap_ptr + 8, command);
 	}
@@ -3326,24 +3283,8 @@
 	 */
 
 
-	pci_for_each_dev(device)
-	{
-		/*
-		 *	Enable AGP devices. Most will be VGA display but
-		 *	some may be coprocessors on non VGA devices too
-		 */
-		 
-		if((((device->class >> 16) & 0xFF) != PCI_BASE_CLASS_DISPLAY) &&
-			(device->class != (PCI_CLASS_PROCESSOR_CO << 8)))
-			continue;
-
-		pci_read_config_dword(device, 0x04, &scratch);
-
-		if (!(scratch & 0x00100000))
-			continue;
-
-		pci_read_config_byte(device, 0x34, &cap_ptr);
-
+	pci_for_each_dev(device) {
+		cap_ptr = pci_find_capability(device, PCI_CAP_ID_AGP);
 		if (cap_ptr != 0x00) {
 			do {
 				pci_read_config_dword(device,
@@ -3421,25 +3362,8 @@
 	 *        command registers.
 	 */
 
-	while ((device = pci_find_class(PCI_CLASS_DISPLAY_VGA << 8,
-					device)) != NULL) {
-		pci_read_config_dword(device, 0x04, &scratch);
-
-		if (!(scratch & 0x00100000))
-			continue;
-
-		pci_read_config_byte(device, 0x34, &cap_ptr);
-
-		if (cap_ptr != 0x00) {
-			do {
-				pci_read_config_dword(device,
-						      cap_ptr, &cap_id);
-
-				if ((cap_id & 0xff) != 0x02)
-					cap_ptr = (cap_id >> 8) & 0xff;
-			}
-			while (((cap_id & 0xff) != 0x02) && (cap_ptr != 0x00));
-		}
+	pci_for_each_dev(device) {
+		cap_ptr = pci_find_capability(device, PCI_CAP_ID_AGP);
 		if (cap_ptr != 0x00)
 			pci_write_config_dword(device, cap_ptr + 8, command);
 	}
@@ -4037,20 +3961,7 @@
 #endif	/* CONFIG_AGP_SWORKS */
 
 	/* find capndx */
-	pci_read_config_dword(dev, 0x04, &scratch);
-	if (!(scratch & 0x00100000))
-		return -ENODEV;
-
-	pci_read_config_byte(dev, 0x34, &cap_ptr);
-	if (cap_ptr != 0x00) {
-		do {
-			pci_read_config_dword(dev, cap_ptr, &cap_id);
-
-			if ((cap_id & 0xff) != 0x02)
-				cap_ptr = (cap_id >> 8) & 0xff;
-		}
-		while (((cap_id & 0xff) != 0x02) && (cap_ptr != 0x00));
-	}
+	cap_ptr = pci_find_capability(dev, PCI_CAP_ID_AGP);
 	if (cap_ptr == 0x00)
 		return -ENODEV;
 	agp_bridge.capndx = cap_ptr;

             reply	other threads:[~2002-01-23 20:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-23 20:46 Bjorn Helgaas [this message]
2002-01-27 19:40 ` Alan Cox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020123204523.04A764556@ldl.fc.hp.com \
    --to=bjorn_helgaas@hp.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=dri-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®