[Intel-gfx] [PATCH] Make GTT dumper work on other 9XX chips

Zhenyu Wang zhenyu.z.wang at intel.com
Wed Oct 15 10:28:21 CEST 2008


On 2008.10.15 00:03:09 -0700, Eric Anholt wrote:
> 
> Nice, but could you replace the INGTT() macro with something referencing
> the appropriate BAR instead of spamming pI830->mmio with something that
> isn't the mmio BAR?
> 

ok, how about this one?

From 0585b5e066cab5cec875f4afc2acbecd4b0eae4c Mon Sep 17 00:00:00 2001
From: Zhenyu Wang <zhenyu.z.wang at intel.com>
Date: Wed, 15 Oct 2008 16:42:55 +0800
Subject: [PATCH] Make GTT dumper work on other 9XX chips

---
 src/reg_dumper/gtt.c |   30 +++++++++++++++++++++++++-----
 1 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/src/reg_dumper/gtt.c b/src/reg_dumper/gtt.c
index cf9e37a..eca4bc6 100644
--- a/src/reg_dumper/gtt.c
+++ b/src/reg_dumper/gtt.c
@@ -36,22 +36,42 @@
 #include "reg_dumper.h"
 #include "../i810_reg.h"
 
-#define INGTT(offset) INREG(gtt_base + (offset) / (KB(4) / 4))
+#define INGTT(offset) (*(volatile uint32_t *)(gtt + (offset) / (KB(4) / 4)))
 
 int main(int argc, char **argv)
 {
 	I830Rec i830;
 	I830Ptr pI830 = &i830;
-	int gtt_base, start, aper_size;
+	int start, aper_size;
+	unsigned char *gtt;
+
 	intel_i830rec_init(pI830);
 
+	if (!IS_I9XX(pI830)) {
+		printf("Unsupported chipset for gtt dumper\n");
+		exit(1);
+	}
+
 	if (IS_G4X(pI830) || IS_GM45(pI830))
-		gtt_base = MB(2);
+		gtt = (unsigned char *)(pI830->mmio + MB(2));
+	else if (IS_I965G(pI830))
+		gtt = (unsigned char *)(pI830->mmio + KB(512));
 	else {
-		printf("Unsupported chipset for gtt dumper\n");
+		/* 915/945 chips has GTT range in bar 3*/
+		int err = 0;
+		err = pci_device_map_range (pI830->pci_dev,
+				pI830->pci_dev->regions[3].base_addr,
+				pI830->pci_dev->regions[3].size,
+				PCI_DEV_MAP_FLAG_WRITABLE,
+				(void **)&gtt);
+		if (err != 0) {
+			fprintf(stderr, "mapping GTT bar failed\n");
+			exit(1);
+		}
 	}
 
-	aper_size = MB(256);
+	aper_size = pI830->pci_dev->regions[2].size;
+
 	for (start = 0; start < aper_size; start += KB(4)) {
 		uint32_t start_pte = INGTT(start);
 		uint32_t end;
-- 
1.5.6.5


-- 
Open Source Technology Center, Intel ltd.

$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.freedesktop.org/archives/intel-gfx/attachments/20081015/c1108e16/attachment.sig>


More information about the Intel-gfx mailing list