Skip to contentSkip to conversation

configure.ac: slightly more standard --disable-tests

PATCH In review Ben Widawsky 2 participants 16 messages Feb 7, 2013 – Feb 8, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/12 configure.ac: slightly more standard --disable-tests

This partially reverts
commit 7c170724003f42cd4ceea9f6c805292bbe2e81b2

Author: Rodrigo Vivi <[email protected]>
Date:   Tue Feb 5 16:17:54 2013 -0200

Build: Add --disable-tests configure flag to avoid tests build

I was still in the middle of arguing this when Daniel merged it.

Cc Rodrigo Vivi <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Julien Cristau <[email protected]>
---
 configure.ac      | 2 +-
 tests/Makefile.am | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
configure.ac +1 -1
index e66876c..d66c9f9 100644
@@ -128,7 +128,6 @@ AC_ARG_ENABLE(tests,
 	      [BUILD_TESTS=$enableval], [BUILD_TESTS="yes"])
 if test "x$BUILD_TESTS" = xyes; then
 	AC_DEFINE(BUILD_TESTS, 1, [Build tests])
-	AC_CONFIG_FILES([tests/Makefile])
 fi
 AM_CONDITIONAL(BUILD_TESTS, [test "x$BUILD_TESTS" = xyes])
 
@@ -139,6 +138,7 @@ AC_CONFIG_FILES([
 		 lib/Makefile
 		 man/Makefile
 		 scripts/Makefile
+		 tests/Makefile
 		 tools/Makefile
 		 debugger/Makefile
 		 debugger/system_routine/Makefile
tests/Makefile.am +2 -0
index 20b7324..ef68a02 100644
@@ -1,3 +1,4 @@
+if BUILD_TESTS
 noinst_PROGRAMS = \
 	gem_stress \
 	$(TESTS_progs) \
@@ -195,3 +196,4 @@ prime_nv_api_CFLAGS = $(AM_CFLAGS) $(DRM_NOUVEAU_CFLAGS)
 prime_nv_api_LDADD = $(LDADD) $(DRM_NOUVEAU_LIBS)
 prime_nv_pcopy_CFLAGS = $(AM_CFLAGS) $(DRM_NOUVEAU_CFLAGS)
 prime_nv_pcopy_LDADD = $(LDADD) $(DRM_NOUVEAU_LIBS)
+endif
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 2/12 configure.ac: Move prime stuff to where it belongs

---
 configure.ac | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
configure.ac +10 -10
index d66c9f9..1381279 100644
@@ -59,16 +59,6 @@ XORG_DEFAULT_OPTIONS
 PKG_CHECK_MODULES(DRM, [libdrm_intel >= 2.4.38 libdrm])
 PKG_CHECK_MODULES(PCIACCESS, [pciaccess >= 0.10])
 
-# for dma-buf tests
-AC_ARG_ENABLE(nouveau, AS_HELP_STRING([--disable-nouveau],
-	      [Enable use of nouveau API for prime tests (default: enabled)]),
-	      [NOUVEAU=$enableval], [NOUVEAU=yes])
-if test "x$NOUVEAU" = xyes; then
-	PKG_CHECK_MODULES(DRM_NOUVEAU, [libdrm_nouveau >= 2.4.33])
-	AC_DEFINE(HAVE_NOUVEAU, 1, [Have nouveau support])
-fi
-AM_CONDITIONAL(HAVE_NOUVEAU, [test "x$NOUVEAU" = xyes])
-
 # for testdisplay
 PKG_CHECK_MODULES(CAIRO, cairo)
 PKG_CHECK_MODULES(LIBUDEV, [libudev], [udev=yes], [udev=no])
@@ -80,6 +70,16 @@ PKG_CHECK_MODULES(GLIB, glib-2.0)
 # -----------------------------------------------------------------------------
 #			Configuration options
 # -----------------------------------------------------------------------------
+# for dma-buf tests
+AC_ARG_ENABLE(nouveau, AS_HELP_STRING([--disable-nouveau],
+	      [Enable use of nouveau API for prime tests (default: enabled)]),
+	      [NOUVEAU=$enableval], [NOUVEAU=yes])
+if test "x$NOUVEAU" = xyes; then
+	PKG_CHECK_MODULES(DRM_NOUVEAU, [libdrm_nouveau >= 2.4.33])
+	AC_DEFINE(HAVE_NOUVEAU, 1, [Have nouveau support])
+fi
+AM_CONDITIONAL(HAVE_NOUVEAU, [test "x$NOUVEAU" = xyes])
+
 # Define a configure option for the shadder debugger
 AC_ARG_ENABLE(shader-debugger, AS_HELP_STRING([--enable-shader-debugger],
 	      [Enable shader debugging support [autodetected]]),
Signature · 1 line
1.8.1.2
#3 lore raw

PATCH 3/12 quick_dump: A dump utility different than reg_dumper

In reply to Ben Widawsky

This is the base tool for quick dump. At it's heart, quick dump is simply a basic text parsing thingie which plugs into intel-gpu-tools to do something similar to intel_reg_dumper.

The format for the register definition files is very open, so it's just something simple for now.

---
 configure.ac                        |   1 +
 tools/Makefile.am                   |   2 +
 tools/quick_dump/Makefile.am        |   3 +
 tools/quick_dump/base_display.txt   | 197 ++++++++++++++++++++++++++++++++++++
 tools/quick_dump/base_interrupt.txt |  20 ++++
 tools/quick_dump/base_other.txt     |   6 ++
 tools/quick_dump/base_power.txt     |  21 ++++
 tools/quick_dump/base_rings.txt     |  27 +++++
 tools/quick_dump/quick_dump.py      |  37 +++++++
 9 files changed, 314 insertions(+)
 create mode 100644 tools/quick_dump/Makefile.am
 create mode 100644 tools/quick_dump/base_display.txt
 create mode 100644 tools/quick_dump/base_interrupt.txt
 create mode 100644 tools/quick_dump/base_other.txt
 create mode 100644 tools/quick_dump/base_power.txt
 create mode 100644 tools/quick_dump/base_rings.txt
 create mode 100755 tools/quick_dump/quick_dump.py
configure.ac +1 -0
index 1381279..15b0f88 100644
@@ -140,6 +140,7 @@ AC_CONFIG_FILES([
 		 scripts/Makefile
 		 tests/Makefile
 		 tools/Makefile
+		 tools/quick_dump/Makefile
 		 debugger/Makefile
 		 debugger/system_routine/Makefile
 		 ])
tools/Makefile.am +2 -0
index 71fb087..016fb89 100644
@@ -1,3 +1,5 @@
+DIST_SUBDIRS = quick_dump
+
 bin_PROGRAMS = 				\
 	intel_disable_clock_gating 	\
 	intel_audio_dump 		\
tools/quick_dump/Makefile.am new file +3 -0
new file mode 100644
index 0000000..34938c8
@@ -0,0 +1,3 @@
+EXTRA_DIST =  \
+	      base_display.txt base_interrupt.txt base_other.txt base_power.txt base_rings.txt \
+	      quick_dump.py
tools/quick_dump/base_display.txt new file +197 -0

197 lines not on this page · raw message

tools/quick_dump/base_interrupt.txt new file +20 -0
new file mode 100644
index 0000000..df4244b
@@ -0,0 +1,20 @@
+('GEN6_PMINTRMSK', '0x0000a168', '')
+('DEISR', '0x00044000', '')
+('DEIMR', '0x00044004', '')
+('DEIIR', '0x00044008', '')
+('DEIER', '0x0004400c', '')
+('GTISR', '0x00044010', '')
+('GTIMR', '0x00044014', '')
+('GTIIR', '0x00044018', '')
+('GTIER', '0x0004401c', '')
+('GEN6_PMISR', '0x00044020', '')
+('GEN6_PMIMR', '0x00044024', '')
+('GEN6_PMIIR', '0x00044028', '')
+('GEN6_PMIER', '0x0004402c', '')
+('SDEISR', '0x000c4000', '')
+('SDEIMR', '0x000c4004', '')
+('SDEIIR', '0x000c4008', '')
+('SDEIER', '0x000c400c', '')
+('RENDER_IMR', '0x000020a8', '')
+('BSD_IMR', '0x000120a8', '')
+('BLT_IMR', '0x000220a8', '')
tools/quick_dump/base_other.txt new file +6 -0
new file mode 100644
index 0000000..24fefdf
@@ -0,0 +1,6 @@
+('PGETBL_CTL', '0x00002020', '')
+('MI_MODE', '0x0000209c', '')
+('ERROR_GEN6', '0x000040a0', '')
+('RENDER_HWSTAM', '0x00002098', '')
+('GEN6_BSD_HWSTAM', '0x00012098', '')
+('GEN6_BLITTER_HWSTAM', '0x00022098', '')
tools/quick_dump/base_power.txt new file +21 -0
new file mode 100644
index 0000000..4a142e5
@@ -0,0 +1,21 @@
+('GEN6_RPNSWREQ', '0x0000a008', '')
+('GEN6_RC_VIDEO_FREQ', '0x0000a00c', '')
+('GEN6_RP_DOWN_TIMEOUT', '0x0000a010', '')
+('GEN6_RP_INTERRUPT_LIMITS', '0x0000a014', '')
+('GEN6_RP_CONTROL', '0x0000a024', '')
+('GEN6_RP_UP_THRESHOLD', '0x0000a02c', '')
+('GEN6_RP_UP_EI', '0x0000a068', '')
+('GEN6_RP_DOWN_EI', '0x0000a06c', '')
+('GEN6_RP_IDLE_HYSTERSIS', '0x0000a070', '')
+('GEN6_RC_CONTROL', '0x0000a090', '')
+('GEN6_RC_STATE', '0x0000a094', '')
+('GEN6_RC1_WAKE_RATE_LIMIT', '0x0000a098', '')
+('GEN6_RC6_WAKE_RATE_LIMIT', '0x0000a09c', '')
+('GEN6_RC_EVALUATION_INTERVAL', '0x0000a0a8', '')
+('GEN6_RC_IDLE_HYSTERSIS', '0x0000a0ac', '')
+('GEN6_RC_SLEEP', '0x0000a0b0', '')
+('GEN6_RC1e_THRESHOLD', '0x0000a0b4', '')
+('GEN6_RC6_THRESHOLD', '0x0000a0b8', '')
+('RC6_RESIDENCY_TIME', '0x00138108', '')
+('RC6p_RESIDENCY_TIME', '0x0013810c', '')
+('RC6pp_RESIDENCY_TIME', '0x00138110', '')
tools/quick_dump/base_rings.txt new file +27 -0
new file mode 100644
index 0000000..d791172
@@ -0,0 +1,27 @@
+('RENDER_INSTPM', '0x20c0', '')
+('BSD_INSTPM', '0x120c0', '')
+('BLT_INSTPM', '0x220c0', '')
+('RENDER_RING_HEAD', '0x2034', '')
+('BSD_RING_HEAD', '0x12034', '')
+('BLT_RING_HEAD', '0x22034', '')
+('RENDER_IPEIR', '0x2064', '')
+('BSD_IPEIR', '0x12064', '')
+('BLT_IPEIR', '0x22064', '')
+('RENDER_IPEHR', '0x2068', '')
+('BSD_IPEHR', '0x12068', '')
+('BLT_IPEHR', '0x22068', '')
+('RENDER_INSTDONE', '0x206c', '')
+('BSD_INSTDONE', '0x1206c', '')
+('BLT_INSTDONE', '0x2206c', '')
+('RENDER_INSTPS', '0x2070', '')
+('BSD_INSTPS', '0x12070', '')
+('BLT_INSTPS', '0x22070', '')
+('RENDER_RING_ACTHD', '0x2074', '')
+('BSD_RING_ACTHD', '0x12074', '')
+('BLT_RING_ACTHD', '0x22074', '')
+('RENDER_FADDR', '0x2078', '')
+('BSD_FADDR', '0x12078', '')
+('BLT_FADDR', '0x22078', '')
+('RENDER_RING_TAIL', '0x2030', '')
+('BSD_RING_TAIL', '0x12030', '')
+('BLT_RING_TAIL', '0x22030', '')
tools/quick_dump/quick_dump.py new file +37 -0
new file mode 100755
index 0000000..3fea7bb
@@ -0,0 +1,37 @@
+#!/usr/bin/env python3
+
+import argparse
+import os
+import sys
+import ast
+import subprocess
+
+def parse_file(file):
+	for line in file:
+		register = ast.literal_eval(line)
+		value = subprocess.check_output(["../intel_reg_read", register[1]])
+		value = value.decode('UTF-8') # convert the byte array to string
+		value = value.rstrip() #dump the newline
+		value = value.split(':') #output is 'addr : offset'
+		print(value[0], "(", register[0], ")", value[1])
+
+
+parser = argparse.ArgumentParser(description='Dumb register dumper.')
+parser.add_argument('-b', '--baseless', action='store_true', default=False, help='baseless mode, ignore files starting with base_')
+parser.add_argument('profile', nargs='?', type=argparse.FileType('r'), default=None)
+args = parser.parse_args()
+
+#parse anything named base_ these are assumed to apply for all gens.
+if args.baseless == False:
+	for root, dirs, files in os.walk('.'):
+		for name in files:
+			if name.startswith(("base_")):
+				file = open(name.rstrip(), 'r')
+				parse_file(file)
+
+if args.profile == None:
+	sys.exit()
+
+for extra in args.profile:
+	extra_file = open(extra.rstrip(), 'r')
+	parse_file(extra_file)
Signature · 1 line
1.8.1.2
#4 lore raw

PATCH 4/12 quick_dump: gen6 support

In reply to Ben Widawsky
---
 tools/quick_dump/Makefile.am    | 1 +
 tools/quick_dump/gen6_other.txt | 1 +
 tools/quick_dump/sandybridge    | 1 +
 3 files changed, 3 insertions(+)
 create mode 100644 tools/quick_dump/gen6_other.txt
 create mode 100644 tools/quick_dump/sandybridge
tools/quick_dump/Makefile.am +1 -0
index 34938c8..fbafdc5 100644
@@ -1,3 +1,4 @@
 EXTRA_DIST =  \
 	      base_display.txt base_interrupt.txt base_other.txt base_power.txt base_rings.txt \
+	      gen6_other.txt sandybridge \
 	      quick_dump.py
tools/quick_dump/gen6_other.txt new file +1 -0
new file mode 100644
index 0000000..9aa6539
@@ -0,0 +1 @@
+('GFX_MODE', '0x00002520', '')
tools/quick_dump/sandybridge new file +1 -0
new file mode 100644
index 0000000..6ece0fd
@@ -0,0 +1 @@
+gen6_other.txt
Signature · 1 line
1.8.1.2
#5 lore raw

PATCH 5/12 quick_dump: gen7 support

In reply to Ben Widawsky
---
 tools/quick_dump/Makefile.am    | 1 +
 tools/quick_dump/gen7_other.txt | 1 +
 tools/quick_dump/ivybridge      | 1 +
 3 files changed, 3 insertions(+)
 create mode 100644 tools/quick_dump/gen7_other.txt
 create mode 100644 tools/quick_dump/ivybridge
tools/quick_dump/Makefile.am +1 -0
index fbafdc5..0ed28fb 100644
@@ -1,4 +1,5 @@
 EXTRA_DIST =  \
 	      base_display.txt base_interrupt.txt base_other.txt base_power.txt base_rings.txt \
 	      gen6_other.txt sandybridge \
+	      gen7_other.txt ivybridge \
 	      quick_dump.py
tools/quick_dump/gen7_other.txt new file +1 -0
new file mode 100644
index 0000000..b6313a4
@@ -0,0 +1 @@
+('GFX_MODE_GEN7', '0x0000229c', '')
tools/quick_dump/ivybridge new file +1 -0
new file mode 100644
index 0000000..4637b42
@@ -0,0 +1 @@
+gen7_other.txt
Signature · 1 line
1.8.1.2
#6 lore raw

PATCH 6/12 quick_dump: vlv support

In reply to Ben Widawsky

This patch includes a patch from Jesse which removed a bunch of VLV registers which were useless in my original RFC.

---
 tools/quick_dump/Makefile.am     |  1 +
 tools/quick_dump/valleyview      |  6 +++
 tools/quick_dump/vlv_display.txt | 84 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 91 insertions(+)
 create mode 100644 tools/quick_dump/valleyview
 create mode 100644 tools/quick_dump/vlv_display.txt
tools/quick_dump/Makefile.am +1 -0
index 0ed28fb..a0c7083 100644
@@ -2,4 +2,5 @@ EXTRA_DIST =  \
 	      base_display.txt base_interrupt.txt base_other.txt base_power.txt base_rings.txt \
 	      gen6_other.txt sandybridge \
 	      gen7_other.txt ivybridge \
+	      vlv_display.txt valleyview \
 	      quick_dump.py
tools/quick_dump/valleyview new file +6 -0
new file mode 100644
index 0000000..2669d92
@@ -0,0 +1,6 @@
+vlv_display.txt
+base_interrupt.txt
+base_other.txt
+base_power.txt
+base_rings.txt
+gen7_other.txt
tools/quick_dump/vlv_display.txt new file +84 -0

84 lines not on this page · raw message

Signature · 1 line
1.8.1.2
#7 lore raw

PATCH 7/12 configure.ac: Add swig dependency

In reply to Ben Widawsky

As far as I can tell (and recommended to me by Matt) taking these m4 extension macros from http://www.gnu.org/software/autoconf-archive/
doesn't require the project distribute GPL. I am a bit confused from reading the license. I'd really hope someone can comment.

The only other solution would be to roll my on m4 macros, or figure out a way to check that this autoconf-archive package is included from the configure.ac.

---
 configure.ac          |   5 +
 m4/ax_pkg_swig.m4     | 135 +++++++++++++++++++++
 m4/ax_python_devel.m4 | 325 ++++++++++++++++++++++++++++++++++++++++++++++++++
 m4/ax_swig_python.m4  |  64 ++++++++++
 4 files changed, 529 insertions(+)
 create mode 100644 m4/ax_pkg_swig.m4
 create mode 100644 m4/ax_python_devel.m4
 create mode 100644 m4/ax_swig_python.m4
configure.ac +5 -0
index 15b0f88..b8e34d3 100644
@@ -50,6 +50,11 @@ AC_CHECK_FUNCS([asprintf])
 AC_DISABLE_STATIC
 AC_PROG_LIBTOOL
 
+# SWIG configuration
+AX_PKG_SWIG(2.0.0, [], [ AC_MSG_ERROR([SWIG 2.0.0 or higher is required to build..]) ])
+AX_PYTHON_DEVEL([>= '3.0'])
+AX_SWIG_PYTHON
+
 # Require X.Org macros 1.16 or later for XORG_TESTSET_CFLAG
 m4_ifndef([XORG_MACROS_VERSION],
 	  [m4_fatal([must install xorg-macros 1.16 or later before running autoconf/autogen])])
m4/ax_pkg_swig.m4 new file +135 -0

135 lines not on this page · raw message

m4/ax_python_devel.m4 new file +325 -0

325 lines not on this page · raw message

m4/ax_swig_python.m4 new file +64 -0

64 lines not on this page · raw message

Signature · 1 line
1.8.1.2
#8 lore raw

PATCH 8/12 quick_dump: SWIG chipset interface

In reply to Ben Widawsky

This isn't strictly necessary it would have been easy enough to simply convert intel_chipset.h but this should be nice prep work for directly doing MMIO. It also serves as a nice review point.

It's demonstrated with an autodetect function in the script. That autodetect has a hardcoded path that shouldn't be there, but it will go away in the next patch when we can properly link in libpciaccess.

Thanks to Matt for helping whip the automake stuff into shape.

v2: Switch to $(top_srcdir)

---
 tools/Makefile.am                |  2 +-
 tools/quick_dump/Makefile.am     | 18 +++++++++++++++++-
 tools/quick_dump/chipset.i       | 12 ++++++++++++
 tools/quick_dump/intel_chipset.c | 16 ++++++++++++++++
 tools/quick_dump/quick_dump.py   | 15 +++++++++++++++
 5 files changed, 61 insertions(+), 2 deletions(-)
 create mode 100644 tools/quick_dump/chipset.i
 create mode 100644 tools/quick_dump/intel_chipset.c
tools/Makefile.am +1 -1
index 016fb89..6088919 100644
@@ -1,4 +1,4 @@
-DIST_SUBDIRS = quick_dump
+SUBDIRS = quick_dump
 
 bin_PROGRAMS = 				\
 	intel_disable_clock_gating 	\
tools/quick_dump/Makefile.am +17 -1
index a0c7083..6c04dd5 100644
@@ -1,6 +1,22 @@
+BUILT_SOURCES = chipset_wrap_python.c
+
+bin_SCRIPTS = quick_dump.py chipset.py
+
+lib_LTLIBRARIES = I915ChipsetPython.la
+I915ChipsetPython_la_CFLAGS = -I$(top_srcdir)/lib $(PYTHON_CPPFLAGS)
+I915ChipsetPython_la_LDFLAGS = -module -avoid-version $(PYTHON_LDFLAGS)
+I915ChipsetPython_la_SOURCES = chipset_wrap_python.c intel_chipset.c
+
+chipset_wrap_python.c: chipset.i
+	$(SWIG) $(AX_SWIG_PYTHON_OPT) -I$(top_srcdir)/lib -o $@ $<
+
+all-local: I915ChipsetPython.la
+	$(LN_S) -f .libs/I915ChipsetPython.so _chipset.so
+
+CLEANFILES = chipset_wrap_python.c chipset.py _chipset.so
 EXTRA_DIST =  \
 	      base_display.txt base_interrupt.txt base_other.txt base_power.txt base_rings.txt \
 	      gen6_other.txt sandybridge \
 	      gen7_other.txt ivybridge \
 	      vlv_display.txt valleyview \
-	      quick_dump.py
+	      chipset.i quick_dump.py chipset.py
tools/quick_dump/chipset.i new file +12 -0
new file mode 100644
index 0000000..16c4932
@@ -0,0 +1,12 @@
+%module chipset 
+%{
+#include "intel_chipset.h"
+extern int is_sandybridge(unsigned short pciid);
+extern int is_ivybridge(unsigned short pciid);
+extern int is_valleyview(unsigned short pciid);
+%}
+
+%include "intel_chipset.h"
+extern int is_sandybridge(unsigned short pciid);
+extern int is_ivybridge(unsigned short pciid);
+extern int is_valleyview(unsigned short pciid);
tools/quick_dump/intel_chipset.c new file +16 -0
new file mode 100644
index 0000000..b242ffc
@@ -0,0 +1,16 @@
+#include "intel_chipset.h"
+
+int is_sandybridge(unsigned short pciid)
+{
+	return IS_GEN6(pciid);
+}
+
+int is_ivybridge(unsigned short pciid)
+{
+	return IS_IVYBRIDGE(pciid);
+}
+
+int is_valleyview(unsigned short pciid)
+{
+	return IS_VALLEYVIEW(pciid);
+}
tools/quick_dump/quick_dump.py +15 -0
index 3fea7bb..59cae1f 100755
@@ -5,6 +5,7 @@ import os
 import sys
 import ast
 import subprocess
+import chipset
 
 def parse_file(file):
 	for line in file:
@@ -18,6 +19,7 @@ def parse_file(file):
 
 parser = argparse.ArgumentParser(description='Dumb register dumper.')
 parser.add_argument('-b', '--baseless', action='store_true', default=False, help='baseless mode, ignore files starting with base_')
+parser.add_argument('-a', '--autodetect', action='store_true', default=False, help='autodetect chipset')
 parser.add_argument('profile', nargs='?', type=argparse.FileType('r'), default=None)
 args = parser.parse_args()
 
@@ -29,6 +31,19 @@ if args.baseless == False:
 				file = open(name.rstrip(), 'r')
 				parse_file(file)
 
+if args.autodetect:
+	sysfs_file = open('/sys/class/drm/card0/device/device', 'r')
+	devid_str = sysfs_file.read()
+	devid = int(devid_str, 16)
+	if chipset.is_sandybridge(devid):
+		args.profile = open('sandybridge', 'r')
+	elif chipset.is_ivybridge(devid):
+		args.profile = open('ivybridge', 'r')
+	elif chipset.is_valleyview(devid):
+		args.profile = open('valleyview', 'r')
+	else:
+		print("Autodetect of %x " + devid + " failed")
+
 if args.profile == None:
 	sys.exit()
 
Signature · 1 line
1.8.1.2
#9 lore raw

PATCH 9/12 quick_dump: Connect libpciaccess and other utils

In reply to Ben Widawsky

Make a register access library with sample to do register reads

---
 tools/quick_dump/Makefile.am     | 14 +++++++++-----
 tools/quick_dump/chipset.i       | 16 ++++++++++++++--
 tools/quick_dump/intel_chipset.c |  7 +++++++
 tools/quick_dump/quick_dump.py   |  5 ++---
 tools/quick_dump/reg_access.py   | 25 +++++++++++++++++++++++++
 5 files changed, 57 insertions(+), 10 deletions(-)
 create mode 100755 tools/quick_dump/reg_access.py
tools/quick_dump/Makefile.am +9 -5
index 6c04dd5..d898f8e 100644
@@ -1,14 +1,18 @@
 BUILT_SOURCES = chipset_wrap_python.c
 
-bin_SCRIPTS = quick_dump.py chipset.py
+bin_SCRIPTS = quick_dump.py chipset.py reg_access.py
 
 lib_LTLIBRARIES = I915ChipsetPython.la
-I915ChipsetPython_la_CFLAGS = -I$(top_srcdir)/lib $(PYTHON_CPPFLAGS)
-I915ChipsetPython_la_LDFLAGS = -module -avoid-version $(PYTHON_LDFLAGS)
-I915ChipsetPython_la_SOURCES = chipset_wrap_python.c intel_chipset.c
+I915ChipsetPython_la_CFLAGS = -I$(top_srcdir)/lib $(PYTHON_CPPFLAGS) $(CFLAGS) -I/usr/include/libdrm/
+I915ChipsetPython_la_LDFLAGS = -module -avoid-version $(PYTHON_LDFLAGS) -lpciaccess
+I915ChipsetPython_la_SOURCES = chipset_wrap_python.c intel_chipset.c \
+			       $(top_srcdir)/lib/intel_drm.c  \
+			       $(top_srcdir)/lib/intel_pci.c  \
+			       $(top_srcdir)/lib/intel_reg_map.c  \
+			       $(top_srcdir)/lib/intel_mmio.c
 
 chipset_wrap_python.c: chipset.i
-	$(SWIG) $(AX_SWIG_PYTHON_OPT) -I$(top_srcdir)/lib -o $@ $<
+	$(SWIG) $(AX_SWIG_PYTHON_OPT) -I/usr/include -I$(top_srcdir)/lib -o $@ $<
 
 all-local: I915ChipsetPython.la
 	$(LN_S) -f .libs/I915ChipsetPython.so _chipset.so
tools/quick_dump/chipset.i +14 -2
index 16c4932..2f4f5ef 100644
@@ -1,12 +1,24 @@
-%module chipset 
+%module chipset
+%include "stdint.i"
 %{
+#include <pciaccess.h>
+#include <stdint.h>
 #include "intel_chipset.h"
 extern int is_sandybridge(unsigned short pciid);
 extern int is_ivybridge(unsigned short pciid);
 extern int is_valleyview(unsigned short pciid);
+extern struct pci_device *intel_get_pci_device();
+extern int intel_register_access_init(struct pci_device *pci_dev, int safe);
+extern uint32_t intel_register_read(uint32_t reg);
+extern void intel_register_access_fini();
+extern unsigned short pcidev_to_devid(struct pci_device *pci_dev);
 %}
 
-%include "intel_chipset.h"
 extern int is_sandybridge(unsigned short pciid);
 extern int is_ivybridge(unsigned short pciid);
 extern int is_valleyview(unsigned short pciid);
+extern struct pci_device *intel_get_pci_device();
+extern int intel_register_access_init(struct pci_device *pci_dev, int safe);
+extern uint32_t intel_register_read(uint32_t reg);
+extern void intel_register_access_fini();
+extern unsigned short pcidev_to_devid(struct pci_device *pci_dev);
tools/quick_dump/intel_chipset.c +7 -0
index b242ffc..d6e7f91 100644
@@ -1,3 +1,4 @@
+#include <pciaccess.h>
 #include "intel_chipset.h"
 
 int is_sandybridge(unsigned short pciid)
@@ -14,3 +15,9 @@ int is_valleyview(unsigned short pciid)
 {
 	return IS_VALLEYVIEW(pciid);
 }
+
+/* Simple helper because I couldn't make this work in the script */
+unsigned short pcidev_to_devid(struct pci_device *pdev)
+{
+	return pdev->device_id;
+}
tools/quick_dump/quick_dump.py +2 -3
index 59cae1f..44aa2ba 100755
@@ -32,9 +32,8 @@ if args.baseless == False:
 				parse_file(file)
 
 if args.autodetect:
-	sysfs_file = open('/sys/class/drm/card0/device/device', 'r')
-	devid_str = sysfs_file.read()
-	devid = int(devid_str, 16)
+	pci_dev = chipset.intel_get_pci_device()
+	devid = chipset.pcidev_to_devid(pci_dev)
 	if chipset.is_sandybridge(devid):
 		args.profile = open('sandybridge', 'r')
 	elif chipset.is_ivybridge(devid):
tools/quick_dump/reg_access.py new file +25 -0
new file mode 100755
index 0000000..0f63424
@@ -0,0 +1,25 @@
+#!/usr/bin/env python3
+import chipset
+
+def read(reg):
+	reg = int(reg, 16)
+	val = chipset.intel_register_read(reg)
+	return val
+
+def init():
+	pci_dev = chipset.intel_get_pci_device()
+	ret = chipset.intel_register_access_init(pci_dev, 0)
+	if ret != 0:
+		print("Register access init failed");
+		return False
+	return True
+
+if __name__ == "__main__":
+	import sys
+
+	if init() == False:
+		sys.exit()
+
+	reg = sys.argv[1]
+	print(hex(read(reg)))
+	chipset.intel_register_access_fini()
Signature · 1 line
1.8.1.2
#10 lore raw

PATCH 10/12 quick_dump: Use the register access library

In reply to Ben Widawsky
---
 tools/quick_dump/quick_dump.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
tools/quick_dump/quick_dump.py +6 -5
index 44aa2ba..5c88ef1 100755
@@ -6,15 +6,13 @@ import sys
 import ast
 import subprocess
 import chipset
+import reg_access as reg
 
 def parse_file(file):
 	for line in file:
 		register = ast.literal_eval(line)
-		value = subprocess.check_output(["../intel_reg_read", register[1]])
-		value = value.decode('UTF-8') # convert the byte array to string
-		value = value.rstrip() #dump the newline
-		value = value.split(':') #output is 'addr : offset'
-		print(value[0], "(", register[0], ")", value[1])
+		val = reg.read(register[1])
+		print(register[1], "(", register[0], ")", hex(val))
 
 
 parser = argparse.ArgumentParser(description='Dumb register dumper.')
@@ -23,6 +21,9 @@ parser.add_argument('-a', '--autodetect', action='store_true', default=False, he
 parser.add_argument('profile', nargs='?', type=argparse.FileType('r'), default=None)
 args = parser.parse_args()
 
+if reg.init() == False:
+	sys.exit()
+
 #parse anything named base_ these are assumed to apply for all gens.
 if args.baseless == False:
 	for root, dirs, files in os.walk('.'):
Signature · 1 line
1.8.1.2
#11 lore raw

PATCH 11/12 quick_dump: Give dumper an AM_CONDITIONAL

In reply to Ben Widawsky

It may sometimes be undesirable to build or install the quick dumper. This was requested by Damien.

Cc Damien Lespiau <[email protected]>
---
 configure.ac      | 19 ++++++++++++++-----
 tools/Makefile.am |  2 ++
 2 files changed, 16 insertions(+), 5 deletions(-)
configure.ac +14 -5
index b8e34d3..5e2dbed 100644
@@ -50,11 +50,6 @@ AC_CHECK_FUNCS([asprintf])
 AC_DISABLE_STATIC
 AC_PROG_LIBTOOL
 
-# SWIG configuration
-AX_PKG_SWIG(2.0.0, [], [ AC_MSG_ERROR([SWIG 2.0.0 or higher is required to build..]) ])
-AX_PYTHON_DEVEL([>= '3.0'])
-AX_SWIG_PYTHON
-
 # Require X.Org macros 1.16 or later for XORG_TESTSET_CFLAG
 m4_ifndef([XORG_MACROS_VERSION],
 	  [m4_fatal([must install xorg-macros 1.16 or later before running autoconf/autogen])])
@@ -85,6 +80,20 @@ if test "x$NOUVEAU" = xyes; then
 fi
 AM_CONDITIONAL(HAVE_NOUVEAU, [test "x$NOUVEAU" = xyes])
 
+#Configure options for the python quick-dumper
+AC_ARG_ENABLE(dumper,
+	      AS_HELP_STRING([--disable-dumper],
+			     [Disable the python based register dumper (default: enabled)]),
+			     DUMPER=$enableval], [DUMPER=yes])
+if test "x$DUMPER" == xyes; then
+	AC_DEFINE(HAVE_DUMPER, 1, [Have dumper support])
+	# SWIG configuration
+	AX_PKG_SWIG(2.0.0, [], [ AC_MSG_ERROR([SWIG 2.0.0 or higher is required to build..]) ])
+	AX_PYTHON_DEVEL([>= '3.0'])
+	AX_SWIG_PYTHON
+fi
+AM_CONDITIONAL(HAVE_DUMPER, [test "x$DUMPER" = xyes])
+
 # Define a configure option for the shadder debugger
 AC_ARG_ENABLE(shader-debugger, AS_HELP_STRING([--enable-shader-debugger],
 	      [Enable shader debugging support [autodetected]]),
tools/Makefile.am +2 -0
index 6088919..bb3328f 100644
@@ -1,4 +1,6 @@
+if HAVE_DUMPER
 SUBDIRS = quick_dump
+endif
 
 bin_PROGRAMS = 				\
 	intel_disable_clock_gating 	\
Signature · 1 line
1.8.1.2
#12 lore raw

PATCH 12/12 README: Add quick_dump info

In reply to Ben Widawsky
---
 README | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
README +15 -0
index 0ec53fb..5ede794 100644
@@ -75,6 +75,21 @@ tools/
 	These tools generally must be run as root, safe for the ones that just
 	decode dumps.
 
+tools/quick_dump
+	Quick dumper is a python tool built with SWIG bindings to
+	important libraries exported by the rest of the tool quite. The tool
+	itself is quite straight forward, and should also be a useful example
+	for others wishing to write python based i915 tools.
+
+	As of writing, the build is sort of broken in Arch because of
+	the way they package Python. You'll need something like:
+	LDFLAGS="-lpython3.3m"
+
+	Note to package maintainers: It is not recommended to package
+	this directory, as the tool is not yet designed for such usage. If the
+	package is installed via "make install" the user will have to
+	set their python library path appropriately.
+
 debugger/
 	This tool is to be used to do shader debugging. It acts like a
 	debug server accepting connections from debug clients such as
Signature · 1 line
1.8.1.2
Reviewed-by on v1 12/12
#13 lore raw

Re: [PATCH 12/12] README: Add quick_dump info

Am Donnerstag, den 07.02.2013, 10:39 -0800 schrieb Ben Widawsky:

Thank you for updating documentation!

Quoted 10 lines
---
 README | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
README +0 -0
index 0ec53fb..5ede794 100644

README tools/ · line 80

Quoted 6 lines
README +3 -0
@@ -75,6 +75,21 @@ tools/
 	These tools generally must be run as root, safe for the ones that just
 	decode dumps.
 
+tools/quick_dump
+	Quick dumper is a python tool built with SWIG bindings to
+	important libraries exported by the rest of the tool quite. The tool

*s*uite

README tools/ · line 84

Quoted 4 lines
README +4 -0
+	itself is quite straight forward, and should also be a useful example
+	for others wishing to write python based i915 tools.
+
+	As of writing, the build is sort of broken in Arch because of

Arch Linux distribution [add URL]

README tools/ · line 89

Quoted 5 lines
README +5 -0
+	the way they package Python. You'll need something like:
+	LDFLAGS="-lpython3.3m"
+
+	Note to package maintainers: It is not recommended to package
+	this directory, as the tool is not yet designed for such usage. If the

*wide* usage?

README tools/ · line 90

Quoted 1 line
README +1 -0
+	package is installed via "make install" the user will have to

s,the user/users/

README tools/ · line 95

Quoted 5 lines
README +2 -0
+	set their python library path appropriately.
+
 debugger/
 	This tool is to be used to do shader debugging. It acts like a
 	debug server accepting connections from debug clients such as

With the above changes (proofread by a native English speaker)

Thanks,

Paul

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#14 lore raw

Re: [PATCH 12/12] README: Add quick_dump info

Quoted 50 lines · Paul Menzel

Am Donnerstag, den 07.02.2013, 10:39 -0800 schrieb Ben Widawsky:

Thank you for updating documentation!

Quoted 10 lines
---
 README | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
README +0 -0
index 0ec53fb..5ede794 100644

README tools/ · line 80

Quoted 6 lines
README +3 -0
@@ -75,6 +75,21 @@ tools/
 	These tools generally must be run as root, safe for the ones that just
 	decode dumps.
 
+tools/quick_dump
+	Quick dumper is a python tool built with SWIG bindings to
+	important libraries exported by the rest of the tool quite. The tool

*s*uite

README tools/ · line 84

Quoted 4 lines
README +4 -0
+	itself is quite straight forward, and should also be a useful example
+	for others wishing to write python based i915 tools.
+
+	As of writing, the build is sort of broken in Arch because of

Arch Linux distribution [add URL]

README tools/ · line 89

Quoted 5 lines
README +5 -0
+	the way they package Python. You'll need something like:
+	LDFLAGS="-lpython3.3m"
+
+	Note to package maintainers: It is not recommended to package
+	this directory, as the tool is not yet designed for such usage. If the

*wide* usage?

README tools/ · line 90

Quoted 1 line
README +1 -0
+	package is installed via "make install" the user will have to

s,the user/users/

README tools/ · line 95

Quoted 5 lines
README +2 -0
+	set their python library path appropriately.
+
 debugger/
 	This tool is to be used to do shader debugging. It acts like a
 	debug server accepting connections from debug clients such as

With the above changes (proofread by a native English speaker)

Quoted 6 lines

Thanks,

Paul

Thank you, Paul. I have absorbed all your requests, and added your r-b.

Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
#15 lore raw
In reply to Ben Widawsky

Dear Ben,

Am Donnerstag, den 07.02.2013, 10:39 -0800 schrieb Ben Widawsky:

Quoted 1 line

This partially reverts

missing empty line for better legibility.

Quoted 7 lines

commit 7c170724003f42cd4ceea9f6c805292bbe2e81b2

Author: Rodrigo Vivi <[email protected]>
Date:   Tue Feb 5 16:17:54 2013 -0200

Build: Add --disable-tests configure flag to avoid tests build

I was still in the middle of arguing this when Daniel merged it.

Could you please explain your change? Why is it »sligthly more standard«?

Quoted 4 lines
Cc Rodrigo Vivi <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Julien Cristau <[email protected]>

Thanks,

Paul

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx