intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/10] [RFC v2] quick dump
@ 2013-02-03  0:07 Ben Widawsky
  2013-02-03  0:07 ` [PATCH 01/10] configure.ac: Fix spacing Ben Widawsky
                   ` (10 more replies)
  0 siblings, 11 replies; 20+ messages in thread
From: Ben Widawsky @ 2013-02-03  0:07 UTC (permalink / raw)
  To: intel-gfx; +Cc: Ben Widawsky, vincent.beng.keat.cheah, alan.previn.teres.alexis

This is my second attempt at winning approval for the series. First one
was: https://patchwork.kernel.org/patch/1493131/

In spending the time to rework this tool, I've begun to lose my belief
in some of the original motivations I had.  Even if you don't want to
review, but just like (or dislike) what you see, I'd appreciate such
comments.

One very important note: I don't know or understand the legal implications of
patch 6. I'd really appreciate anyone who's dealt with the m4 extensions on
non-GPL projects to comment.

What's new
==========
The primary differences this time around is I've tried to add the proper
autofoo things, as well as using SWIG to get python bindings. I've left
the original incantation for the script in the first few patches so
people can observe the progression. (Potentially we can also drop the
real patches with the SWIG interface).

What it is
==========
The goal is simply to make a tool can get register state, and one that
is easy to maintain and update across many generations. I've also long
theorized that having python bindings to our gpu tools could really
benefit certain types of debugging. reg_access.py is an example of a
simple binding which could really be helpful.

Like intel_reg_dumper, supporting new generations isn't free. In order
to make the tool nearly as useful as intel_reg_dumper I created the
base_ files. These files were created directly from intel_reg_dumper.
The idea of base_ files as well as the hackish implementation in
quick_dump will likely need to change over time, for I feel that's not
where the power of the tool lies.

How to use it
=============
reg_access.py provides register reading capabilities out of the box.
You can either run it as an app:
sudo ./reg_access.py 0x20c0
0x8080

or directly from python interpreter:
>>> import reg_access as reg
>>> reg.init()
True
>>> hex(reg.read("0x20c0"))
'0x8080'

I'll leave all the options up to readers of the code, but here are some
useful examples,
to dump all base registers, and your current platform registers:
sudo ./quick_dump.py -a

to just dump platform specific registers
sudo ./quick_dump.py -ab

profiles can be used for specific lists of reigsters. Profiles are
simply text files containing a list of other text files with interesting
registers. See sandybridge|ivybridge|valleyview as examples.
sudo ./quick_dump.py -b valleyview

What is left
============
The valleyview profile isn't complete. Hopefully someone with such a
platform can fix it up.

Jesse had given me a patch for dpio support on Valleyview. I haven't bothered
to port that to the new SWIG stuff. Since his patch implied it wasn't complete
anyway, I have decided not to bother putting it in this series.

I probably need to slap some copyright stuff on things.

There is talk that the future holds some magical XML register files, passed
down to us by the omniscient designers. If that ever happens, the tool
would simply change to XML parsing.

-- 
Ben Widawsky (10):
  configure.ac: Fix spacing
  configure.ac: Add vim magic modeline
  quick_dump: A dump utility different than reg_dumper
  quick_dump: gen6 support
  quick_dump: gen7 support
  quick_dump: vlv support
  configure.ac: Add swig dependency
  quick_dump: SWIG chipset interface
  quick_dump: Connect libpciaccess and other utils
  quick_dump: Use the register access library

 configure.ac                        | 102 +++++------
 m4/ax_pkg_swig.m4                   | 135 +++++++++++++++
 m4/ax_python_devel.m4               | 325 ++++++++++++++++++++++++++++++++++++
 m4/ax_swig_python.m4                |  64 +++++++
 tools/Makefile.am                   |   2 +
 tools/quick_dump/Makefile.am        |  26 +++
 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/chipset.i          |  24 +++
 tools/quick_dump/gen6_other.txt     |   1 +
 tools/quick_dump/gen7_other.txt     |   1 +
 tools/quick_dump/intel_chipset.c    |  23 +++
 tools/quick_dump/ivybridge          |   1 +
 tools/quick_dump/quick_dump.py      |  52 ++++++
 tools/quick_dump/reg_access.py      |  25 +++
 tools/quick_dump/sandybridge        |   1 +
 tools/quick_dump/valleyview         |   6 +
 tools/quick_dump/vlv_display.txt    |  84 ++++++++++
 21 files changed, 1095 insertions(+), 48 deletions(-)
 create mode 100644 m4/ax_pkg_swig.m4
 create mode 100644 m4/ax_python_devel.m4
 create mode 100644 m4/ax_swig_python.m4
 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 100644 tools/quick_dump/chipset.i
 create mode 100644 tools/quick_dump/gen6_other.txt
 create mode 100644 tools/quick_dump/gen7_other.txt
 create mode 100644 tools/quick_dump/intel_chipset.c
 create mode 100644 tools/quick_dump/ivybridge
 create mode 100755 tools/quick_dump/quick_dump.py
 create mode 100755 tools/quick_dump/reg_access.py
 create mode 100644 tools/quick_dump/sandybridge
 create mode 100644 tools/quick_dump/valleyview
 create mode 100644 tools/quick_dump/vlv_display.txt

-- 
1.8.1.2

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 01/10] configure.ac: Fix spacing
  2013-02-03  0:07 [PATCH 00/10] [RFC v2] quick dump Ben Widawsky
@ 2013-02-03  0:07 ` Ben Widawsky
  2013-02-03  0:07 ` [PATCH 02/10] configure.ac: Add vim magic modeline Ben Widawsky
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 20+ messages in thread
From: Ben Widawsky @ 2013-02-03  0:07 UTC (permalink / raw)
  To: intel-gfx; +Cc: Ben Widawsky, vincent.beng.keat.cheah, alan.previn.teres.alexis

Almost all based on vim's config file type. It got it wrong in a few
places which were fixed by hand.

Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
 configure.ac | 94 +++++++++++++++++++++++++++++-------------------------------
 1 file changed, 46 insertions(+), 48 deletions(-)

diff --git a/configure.ac b/configure.ac
index 0ba7ce7..b75a9d4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,9 +22,9 @@
 
 AC_PREREQ([2.60])
 AC_INIT([intel-gpu-tools],
-        [1.3],
-        [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
-        [intel-gpu-tools])
+	[1.3],
+	[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
+	[intel-gpu-tools])
 
 AC_CONFIG_SRCDIR([Makefile.am])
 AC_CONFIG_HEADERS([config.h])
@@ -41,8 +41,8 @@ AM_MAINTAINER_MODE
 # Checks for functions, headers, structures, etc.
 AC_CHECK_HEADERS([termios.h])
 AC_CHECK_MEMBERS([struct sysinfo.totalram],[],[],[AC_INCLUDES_DEFAULT
-#include <sys/sysinfo.h>
-])
+		  #include <sys/sysinfo.h>
+		  ])
 AC_CHECK_FUNCS([swapctl])
 AC_CHECK_FUNCS([asprintf])
 
@@ -60,17 +60,15 @@ 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])
+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])
+	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])
@@ -84,37 +82,37 @@ PKG_CHECK_MODULES(GLIB, glib-2.0)
 # -----------------------------------------------------------------------------
 # Define a configure option for the shadder debugger
 AC_ARG_ENABLE(shader-debugger, AS_HELP_STRING([--enable-shader-debugger],
-    [Enable shader debugging support [autodetected]]),
-    [BUILD_SHADER_DEBUGGER="$enableval"], [BUILD_SHADER_DEBUGGER=auto])
+	      [Enable shader debugging support [autodetected]]),
+	      [BUILD_SHADER_DEBUGGER="$enableval"], [BUILD_SHADER_DEBUGGER=auto])
 
 # Shadder debugger depends on python3, intel-genasm and objcopy
 if test "x$BUILD_SHADER_DEBUGGER" != xno; then
-    # Check Python 3 is installed
-    if test "$PYTHON" = ":" ; then
-	if test "x$BUILD_SHADER_DEBUGGER" = xyes; then
-	    AC_MSG_ERROR([Shader debugger requested, python version 3 not found.])
-	else
-	    BUILD_SHADER_DEBUGGER=no
+	# Check Python 3 is installed
+	if test "$PYTHON" = ":" ; then
+		if test "x$BUILD_SHADER_DEBUGGER" = xyes; then
+			AC_MSG_ERROR([Shader debugger requested, python version 3 not found.])
+		else
+			BUILD_SHADER_DEBUGGER=no
+		fi
 	fi
-    fi
-    # Check for the Intel Chipset assembler compiler
-    AC_PATH_PROGS([GEN4ASM], intel-gen4asm)
-    if test -z "$GEN4ASM" ; then
-	if test "x$BUILD_SHADER_DEBUGGER" = xyes; then
-	    AC_MSG_ERROR([Shader debugger requested, but intel-gen4asm not found.])
-	else
-	    BUILD_SHADER_DEBUGGER=no
+	# Check for the Intel Chipset assembler compiler
+	AC_PATH_PROGS([GEN4ASM], intel-gen4asm)
+	if test -z "$GEN4ASM" ; then
+		if test "x$BUILD_SHADER_DEBUGGER" = xyes; then
+			AC_MSG_ERROR([Shader debugger requested, but intel-gen4asm not found.])
+		else
+			BUILD_SHADER_DEBUGGER=no
+		fi
 	fi
-    fi
-    # Check for the objcopy GNU binary utiliy command
-    AC_PATH_PROGS([OBJCOPY], objcopy)
-    if test -z "$OBJCOPY" ; then
-	if test "x$BUILD_SHADER_DEBUGGER" = xyes; then
-	    AC_MSG_ERROR([Shader debugger requested, but objcopy command not found.])
-	else
-	    BUILD_SHADER_DEBUGGER=no
+	# Check for the objcopy GNU binary utiliy command
+	AC_PATH_PROGS([OBJCOPY], objcopy)
+	if test -z "$OBJCOPY" ; then
+		if test "x$BUILD_SHADER_DEBUGGER" = xyes; then
+			AC_MSG_ERROR([Shader debugger requested, but objcopy command not found.])
+		else
+			BUILD_SHADER_DEBUGGER=no
+		fi
 	fi
-    fi
 fi
 
 AM_CONDITIONAL(BUILD_SHADER_DEBUGGER, [test "x$BUILD_SHADER_DEBUGGER" != xno])
@@ -125,15 +123,15 @@ XORG_TESTSET_CFLAG([THREAD_CFLAGS], [-pthread], [-mt])
 AC_SUBST([THREAD_CFLAGS])
 
 AC_CONFIG_FILES([
-	Makefile
-	benchmarks/Makefile
-	demos/Makefile
-	lib/Makefile
-	man/Makefile
-	scripts/Makefile
-	tests/Makefile
-	tools/Makefile
-	debugger/Makefile
-	debugger/system_routine/Makefile
-])
+		 Makefile
+		 benchmarks/Makefile
+		 demos/Makefile
+		 lib/Makefile
+		 man/Makefile
+		 scripts/Makefile
+		 tests/Makefile
+		 tools/Makefile
+		 debugger/Makefile
+		 debugger/system_routine/Makefile
+		 ])
 AC_OUTPUT
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 02/10] configure.ac: Add vim magic modeline
  2013-02-03  0:07 [PATCH 00/10] [RFC v2] quick dump Ben Widawsky
  2013-02-03  0:07 ` [PATCH 01/10] configure.ac: Fix spacing Ben Widawsky
@ 2013-02-03  0:07 ` Ben Widawsky
  2013-02-03  0:07 ` [PATCH 03/10] quick_dump: A dump utility different than reg_dumper Ben Widawsky
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 20+ messages in thread
From: Ben Widawsky @ 2013-02-03  0:07 UTC (permalink / raw)
  To: intel-gfx; +Cc: Ben Widawsky, vincent.beng.keat.cheah, alan.previn.teres.alexis

Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
 configure.ac | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configure.ac b/configure.ac
index b75a9d4..1c56fa4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -135,3 +135,5 @@ AC_CONFIG_FILES([
 		 debugger/system_routine/Makefile
 		 ])
 AC_OUTPUT
+
+# vim: set ft=config ts=8 sw=8 tw=0 noet :
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 03/10] quick_dump: A dump utility different than reg_dumper
  2013-02-03  0:07 [PATCH 00/10] [RFC v2] quick dump Ben Widawsky
  2013-02-03  0:07 ` [PATCH 01/10] configure.ac: Fix spacing Ben Widawsky
  2013-02-03  0:07 ` [PATCH 02/10] configure.ac: Add vim magic modeline Ben Widawsky
@ 2013-02-03  0:07 ` Ben Widawsky
  2013-02-03  0:07 ` [PATCH 04/10] quick_dump: gen6 support Ben Widawsky
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 20+ messages in thread
From: Ben Widawsky @ 2013-02-03  0:07 UTC (permalink / raw)
  To: intel-gfx; +Cc: Ben Widawsky, vincent.beng.keat.cheah, alan.previn.teres.alexis

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.

Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
 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

diff --git a/configure.ac b/configure.ac
index 1c56fa4..7f89ee6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -131,6 +131,7 @@ AC_CONFIG_FILES([
 		 scripts/Makefile
 		 tests/Makefile
 		 tools/Makefile
+		 tools/quick_dump/Makefile
 		 debugger/Makefile
 		 debugger/system_routine/Makefile
 		 ])
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 71fb087..016fb89 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -1,3 +1,5 @@
+DIST_SUBDIRS = quick_dump
+
 bin_PROGRAMS = 				\
 	intel_disable_clock_gating 	\
 	intel_audio_dump 		\
diff --git a/tools/quick_dump/Makefile.am b/tools/quick_dump/Makefile.am
new file mode 100644
index 0000000..34938c8
--- /dev/null
+++ b/tools/quick_dump/Makefile.am
@@ -0,0 +1,3 @@
+EXTRA_DIST =  \
+	      base_display.txt base_interrupt.txt base_other.txt base_power.txt base_rings.txt \
+	      quick_dump.py
diff --git a/tools/quick_dump/base_display.txt b/tools/quick_dump/base_display.txt
new file mode 100644
index 0000000..8bead7f
--- /dev/null
+++ b/tools/quick_dump/base_display.txt
@@ -0,0 +1,197 @@
+('CPU_VGACNTRL', '0x00041000', '')
+('PORT_DBG', '0x00042308', '')
+('DIGITAL_PORT_HOTPLUG_CNTRL', '0x00044030', '')
+('FDI_PLL_BIOS_0', '0x00046000', '')
+('FDI_PLL_BIOS_1', '0x00046004', '')
+('FDI_PLL_BIOS_2', '0x00046008', '')
+('DISPLAY_PORT_PLL_BIOS_0', '0x0004600c', '')
+('DISPLAY_PORT_PLL_BIOS_1', '0x00046010', '')
+('DISPLAY_PORT_PLL_BIOS_2', '0x00046014', '')
+('FDI_PLL_FREQ_CTL', '0x00046030', '')
+('BLC_PWM_CPU_CTL2', '0x00048250', '')
+('BLC_PWM_CPU_CTL', '0x00048254', '')
+('HTOTAL_A', '0x00060000', '')
+('HBLANK_A', '0x00060004', '')
+('HSYNC_A', '0x00060008', '')
+('VTOTAL_A', '0x0006000c', '')
+('VBLANK_A', '0x00060010', '')
+('VSYNC_A', '0x00060014', '')
+('PIPEASRC', '0x0006001c', '')
+('VSYNCSHIFT_A', '0x00060028', '')
+('PIPEA_DATA_M1', '0x00060030', '')
+('PIPEA_DATA_N1', '0x00060034', '')
+('PIPEA_DATA_M2', '0x00060038', '')
+('PIPEA_DATA_N2', '0x0006003c', '')
+('PIPEA_LINK_M1', '0x00060040', '')
+('PIPEA_LINK_N1', '0x00060044', '')
+('PIPEA_LINK_M2', '0x00060048', '')
+('PIPEA_LINK_N2', '0x0006004c', '')
+('FDI_TXA_CTL', '0x00060100', '')
+('HTOTAL_B', '0x00061000', '')
+('HBLANK_B', '0x00061004', '')
+('HSYNC_B', '0x00061008', '')
+('VTOTAL_B', '0x0006100c', '')
+('VBLANK_B', '0x00061010', '')
+('VSYNC_B', '0x00061014', '')
+('PIPEBSRC', '0x0006101c', '')
+('VSYNCSHIFT_B', '0x00061028', '')
+('PIPEB_DATA_M1', '0x00061030', '')
+('PIPEB_DATA_N1', '0x00061034', '')
+('PIPEB_DATA_M2', '0x00061038', '')
+('PIPEB_DATA_N2', '0x0006103c', '')
+('PIPEB_LINK_M1', '0x00061040', '')
+('PIPEB_LINK_N1', '0x00061044', '')
+('PIPEB_LINK_M2', '0x00061048', '')
+('PIPEB_LINK_N2', '0x0006104c', '')
+('FDI_TXB_CTL', '0x00061100', '')
+('HTOTAL_C', '0x00062000', '')
+('HBLANK_C', '0x00062004', '')
+('HSYNC_C', '0x00062008', '')
+('VTOTAL_C', '0x0006200c', '')
+('VBLANK_C', '0x00062010', '')
+('VSYNC_C', '0x00062014', '')
+('PIPECSRC', '0x0006201c', '')
+('VSYNCSHIFT_C', '0x00062028', '')
+('PIPEC_DATA_M1', '0x00062030', '')
+('PIPEC_DATA_N1', '0x00062034', '')
+('PIPEC_DATA_M2', '0x00062038', '')
+('PIPEC_DATA_N2', '0x0006203c', '')
+('PIPEC_LINK_M1', '0x00062040', '')
+('PIPEC_LINK_N1', '0x00062044', '')
+('PIPEC_LINK_M2', '0x00062048', '')
+('PIPEC_LINK_N2', '0x0006204c', '')
+('FDI_TXC_CTL', '0x00062100', '')
+('CPU_eDP_A', '0x00064000', '')
+('PFA_WIN_POS', '0x00068070', '')
+('PFA_WIN_SIZE', '0x00068074', '')
+('PFA_CTL_1', '0x00068080', '')
+('PFA_CTL_2', '0x00068084', '')
+('PFA_CTL_3', '0x00068088', '')
+('PFA_CTL_4', '0x00068090', '')
+('PFB_WIN_POS', '0x00068870', '')
+('PFB_WIN_SIZE', '0x00068874', '')
+('PFB_CTL_1', '0x00068880', '')
+('PFB_CTL_2', '0x00068884', '')
+('PFB_CTL_3', '0x00068888', '')
+('PFB_CTL_4', '0x00068890', '')
+('PFC_WIN_POS', '0x00069070', '')
+('PFC_WIN_SIZE', '0x00069074', '')
+('PFC_CTL_1', '0x00069080', '')
+('PFC_CTL_2', '0x00069084', '')
+('PFC_CTL_3', '0x00069088', '')
+('PFC_CTL_4', '0x00069090', '')
+('PIPEACONF', '0x00070008', '')
+('DSPACNTR', '0x00070180', '')
+('DSPABASE', '0x00070184', '')
+('DSPASTRIDE', '0x00070188', '')
+('DSPASURF', '0x0007019c', '')
+('DSPATILEOFF', '0x000701a4', '')
+('PIPEBCONF', '0x00071008', '')
+('DSPBCNTR', '0x00071180', '')
+('DSPBBASE', '0x00071184', '')
+('DSPBSTRIDE', '0x00071188', '')
+('DSPBSURF', '0x0007119c', '')
+('DSPBTILEOFF', '0x000711a4', '')
+('PIPECCONF', '0x00072008', '')
+('DSPCCNTR', '0x00072180', '')
+('DSPCBASE', '0x00072184', '')
+('DSPCSTRIDE', '0x00072188', '')
+('DSPCSURF', '0x0007219c', '')
+('DSPCTILEOFF', '0x000721a4', '')
+('PCH_DPLL_A', '0x000c6014', '')
+('PCH_DPLL_B', '0x000c6018', '')
+('PCH_FPA0', '0x000c6040', '')
+('PCH_FPA1', '0x000c6044', '')
+('PCH_FPB0', '0x000c6048', '')
+('PCH_FPB1', '0x000c604c', '')
+('PCH_DREF_CONTROL', '0x000c6200', '')
+('PCH_RAWCLK_FREQ', '0x000c6204', '')
+('PCH_DPLL_TMR_CFG', '0x000c6208', '')
+('PCH_SSC4_PARMS', '0x000c6210', '')
+('PCH_SSC4_AUX_PARMS', '0x000c6214', '')
+('PCH_DPLL_ANALOG_CTL', '0x000c6300', '')
+('PCH_DPLL_SEL', '0x000c7000', '')
+('PCH_PP_STATUS', '0x000c7200', '')
+('PCH_PP_CONTROL', '0x000c7204', '')
+('PCH_PP_ON_DELAYS', '0x000c7208', '')
+('PCH_PP_OFF_DELAYS', '0x000c720c', '')
+('PCH_PP_DIVISOR', '0x000c7210', '')
+('BLC_PWM_PCH_CTL1', '0x000c8250', '')
+('BLC_PWM_PCH_CTL2', '0x000c8254', '')
+('TRANS_HTOTAL_A', '0x000e0000', '')
+('TRANS_HBLANK_A', '0x000e0004', '')
+('TRANS_HSYNC_A', '0x000e0008', '')
+('TRANS_VTOTAL_A', '0x000e000c', '')
+('TRANS_VBLANK_A', '0x000e0010', '')
+('TRANS_VSYNC_A', '0x000e0014', '')
+('TRANS_VSYNCSHIFT_A', '0x000e0028', '')
+('TRANSA_DATA_M1', '0x000e0030', '')
+('TRANSA_DATA_N1', '0x000e0034', '')
+('TRANSA_DATA_M2', '0x000e0038', '')
+('TRANSA_DATA_N2', '0x000e003c', '')
+('TRANSA_DP_LINK_M1', '0x000e0040', '')
+('TRANSA_DP_LINK_N1', '0x000e0044', '')
+('TRANSA_DP_LINK_M2', '0x000e0048', '')
+('TRANSA_DP_LINK_N2', '0x000e004c', '')
+('TRANS_DP_CTL_A', '0x000e0300', '')
+('TRANS_HTOTAL_B', '0x000e1000', '')
+('TRANS_HBLANK_B', '0x000e1004', '')
+('TRANS_HSYNC_B', '0x000e1008', '')
+('TRANS_VTOTAL_B', '0x000e100c', '')
+('TRANS_VBLANK_B', '0x000e1010', '')
+('TRANS_VSYNC_B', '0x000e1014', '')
+('TRANS_VSYNCSHIFT_B', '0x000e1028', '')
+('TRANSB_DATA_M1', '0x000e1030', '')
+('TRANSB_DATA_N1', '0x000e1034', '')
+('TRANSB_DATA_M2', '0x000e1038', '')
+('TRANSB_DATA_N2', '0x000e103c', '')
+('TRANSB_DP_LINK_M1', '0x000e1040', '')
+('TRANSB_DP_LINK_N1', '0x000e1044', '')
+('TRANSB_DP_LINK_M2', '0x000e1048', '')
+('TRANSB_DP_LINK_N2', '0x000e104c', '')
+('PCH_ADPA', '0x000e1100', '')
+('HDMIB', '0x000e1140', '')
+('HDMIC', '0x000e1150', '')
+('HDMID', '0x000e1160', '')
+('PCH_LVDS', '0x000e1180', '')
+('TRANS_DP_CTL_B', '0x000e1300', '')
+('TRANS_HTOTAL_C', '0x000e2000', '')
+('TRANS_HBLANK_C', '0x000e2004', '')
+('TRANS_HSYNC_C', '0x000e2008', '')
+('TRANS_VTOTAL_C', '0x000e200c', '')
+('TRANS_VBLANK_C', '0x000e2010', '')
+('TRANS_VSYNC_C', '0x000e2014', '')
+('TRANS_VSYNCSHIFT_C', '0x000e2028', '')
+('TRANSC_DATA_M1', '0x000e2030', '')
+('TRANSC_DATA_N1', '0x000e2034', '')
+('TRANSC_DATA_M2', '0x000e2038', '')
+('TRANSC_DATA_N2', '0x000e203c', '')
+('TRANSC_DP_LINK_M1', '0x000e2040', '')
+('TRANSC_DP_LINK_N1', '0x000e2044', '')
+('TRANSC_DP_LINK_M2', '0x000e2048', '')
+('TRANSC_DP_LINK_N2', '0x000e204c', '')
+('TRANS_DP_CTL_C', '0x000e2300', '')
+('PCH_DP_B', '0x000e4100', '')
+('PCH_DP_C', '0x000e4200', '')
+('PCH_DP_D', '0x000e4300', '')
+('TRANSACONF', '0x000f0008', '')
+('FDI_RXA_CTL', '0x000f000c', '')
+('FDI_RXA_MISC', '0x000f0010', '')
+('FDI_RXA_IIR', '0x000f0014', '')
+('FDI_RXA_IMR', '0x000f0018', '')
+('FDI_RXA_TUSIZE1', '0x000f0030', '')
+('FDI_RXA_TUSIZE2', '0x000f0038', '')
+('TRANSBCONF', '0x000f1008', '')
+('FDI_RXB_CTL', '0x000f100c', '')
+('FDI_RXB_MISC', '0x000f1010', '')
+('FDI_RXB_IIR', '0x000f1014', '')
+('FDI_RXB_IMR', '0x000f1018', '')
+('FDI_RXB_TUSIZE1', '0x000f1030', '')
+('FDI_RXB_TUSIZE2', '0x000f1038', '')
+('TRANSCCONF', '0x000f2008', '')
+('FDI_RXC_CTL', '0x000f200c', '')
+('FDI_RXC_MISC', '0x000f2010', '')
+('FDI_RXC_TUSIZE1', '0x000f2030', '')
+('FDI_RXC_TUSIZE2', '0x000f2038', '')
+('FDI_PLL_CTL_1', '0x000fe000', '')
+('FDI_PLL_CTL_2', '0x000fe004', '')
diff --git a/tools/quick_dump/base_interrupt.txt b/tools/quick_dump/base_interrupt.txt
new file mode 100644
index 0000000..df4244b
--- /dev/null
+++ b/tools/quick_dump/base_interrupt.txt
@@ -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', '')
diff --git a/tools/quick_dump/base_other.txt b/tools/quick_dump/base_other.txt
new file mode 100644
index 0000000..24fefdf
--- /dev/null
+++ b/tools/quick_dump/base_other.txt
@@ -0,0 +1,6 @@
+('PGETBL_CTL', '0x00002020', '')
+('MI_MODE', '0x0000209c', '')
+('ERROR_GEN6', '0x000040a0', '')
+('RENDER_HWSTAM', '0x00002098', '')
+('GEN6_BSD_HWSTAM', '0x00012098', '')
+('GEN6_BLITTER_HWSTAM', '0x00022098', '')
diff --git a/tools/quick_dump/base_power.txt b/tools/quick_dump/base_power.txt
new file mode 100644
index 0000000..4a142e5
--- /dev/null
+++ b/tools/quick_dump/base_power.txt
@@ -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', '')
diff --git a/tools/quick_dump/base_rings.txt b/tools/quick_dump/base_rings.txt
new file mode 100644
index 0000000..d791172
--- /dev/null
+++ b/tools/quick_dump/base_rings.txt
@@ -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', '')
diff --git a/tools/quick_dump/quick_dump.py b/tools/quick_dump/quick_dump.py
new file mode 100755
index 0000000..3fea7bb
--- /dev/null
+++ b/tools/quick_dump/quick_dump.py
@@ -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)
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 04/10] quick_dump: gen6 support
  2013-02-03  0:07 [PATCH 00/10] [RFC v2] quick dump Ben Widawsky
                   ` (2 preceding siblings ...)
  2013-02-03  0:07 ` [PATCH 03/10] quick_dump: A dump utility different than reg_dumper Ben Widawsky
@ 2013-02-03  0:07 ` Ben Widawsky
  2013-02-03  0:07 ` [PATCH 05/10] quick_dump: gen7 support Ben Widawsky
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 20+ messages in thread
From: Ben Widawsky @ 2013-02-03  0:07 UTC (permalink / raw)
  To: intel-gfx; +Cc: Ben Widawsky, vincent.beng.keat.cheah, alan.previn.teres.alexis

Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
 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

diff --git a/tools/quick_dump/Makefile.am b/tools/quick_dump/Makefile.am
index 34938c8..fbafdc5 100644
--- a/tools/quick_dump/Makefile.am
+++ b/tools/quick_dump/Makefile.am
@@ -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
diff --git a/tools/quick_dump/gen6_other.txt b/tools/quick_dump/gen6_other.txt
new file mode 100644
index 0000000..9aa6539
--- /dev/null
+++ b/tools/quick_dump/gen6_other.txt
@@ -0,0 +1 @@
+('GFX_MODE', '0x00002520', '')
diff --git a/tools/quick_dump/sandybridge b/tools/quick_dump/sandybridge
new file mode 100644
index 0000000..6ece0fd
--- /dev/null
+++ b/tools/quick_dump/sandybridge
@@ -0,0 +1 @@
+gen6_other.txt
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 05/10] quick_dump: gen7 support
  2013-02-03  0:07 [PATCH 00/10] [RFC v2] quick dump Ben Widawsky
                   ` (3 preceding siblings ...)
  2013-02-03  0:07 ` [PATCH 04/10] quick_dump: gen6 support Ben Widawsky
@ 2013-02-03  0:07 ` Ben Widawsky
  2013-02-03  0:07 ` [PATCH 06/10] quick_dump: vlv support Ben Widawsky
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 20+ messages in thread
From: Ben Widawsky @ 2013-02-03  0:07 UTC (permalink / raw)
  To: intel-gfx; +Cc: Ben Widawsky, vincent.beng.keat.cheah, alan.previn.teres.alexis

Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
 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

diff --git a/tools/quick_dump/Makefile.am b/tools/quick_dump/Makefile.am
index fbafdc5..0ed28fb 100644
--- a/tools/quick_dump/Makefile.am
+++ b/tools/quick_dump/Makefile.am
@@ -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
diff --git a/tools/quick_dump/gen7_other.txt b/tools/quick_dump/gen7_other.txt
new file mode 100644
index 0000000..b6313a4
--- /dev/null
+++ b/tools/quick_dump/gen7_other.txt
@@ -0,0 +1 @@
+('GFX_MODE_GEN7', '0x0000229c', '')
diff --git a/tools/quick_dump/ivybridge b/tools/quick_dump/ivybridge
new file mode 100644
index 0000000..4637b42
--- /dev/null
+++ b/tools/quick_dump/ivybridge
@@ -0,0 +1 @@
+gen7_other.txt
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 06/10] quick_dump: vlv support
  2013-02-03  0:07 [PATCH 00/10] [RFC v2] quick dump Ben Widawsky
                   ` (4 preceding siblings ...)
  2013-02-03  0:07 ` [PATCH 05/10] quick_dump: gen7 support Ben Widawsky
@ 2013-02-03  0:07 ` Ben Widawsky
  2013-02-03  0:07 ` [PATCH 07/10] configure.ac: Add swig dependency Ben Widawsky
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 20+ messages in thread
From: Ben Widawsky @ 2013-02-03  0:07 UTC (permalink / raw)
  To: intel-gfx; +Cc: Ben Widawsky, vincent.beng.keat.cheah, alan.previn.teres.alexis

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

Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
 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

diff --git a/tools/quick_dump/Makefile.am b/tools/quick_dump/Makefile.am
index 0ed28fb..a0c7083 100644
--- a/tools/quick_dump/Makefile.am
+++ b/tools/quick_dump/Makefile.am
@@ -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
diff --git a/tools/quick_dump/valleyview b/tools/quick_dump/valleyview
new file mode 100644
index 0000000..2669d92
--- /dev/null
+++ b/tools/quick_dump/valleyview
@@ -0,0 +1,6 @@
+vlv_display.txt
+base_interrupt.txt
+base_other.txt
+base_power.txt
+base_rings.txt
+gen7_other.txt
diff --git a/tools/quick_dump/vlv_display.txt b/tools/quick_dump/vlv_display.txt
new file mode 100644
index 0000000..c785670
--- /dev/null
+++ b/tools/quick_dump/vlv_display.txt
@@ -0,0 +1,84 @@
+('DPLLA_CRTL', '0x186014', '')
+('DPLBA_CRTL', '0x186018', '')
+('DPLLAMD_CRTL', '0x18601c', '')
+('DPLBAMD_CRTL', '0x186020', '')
+('RAWCLK_FREQ', '0x186024', '')
+('D_STAT', '0x186104', '')
+('DISPCLK_GATE_D', '0x186200', '')
+('DPPSR_CGDIS', '0x186204', '')
+('RAMCLK_GATE_D', '0x186210', '')
+('CPU_VGACNTRL', '0x001c1000', '')
+('HTOTAL_A', '0x001e0000', '')
+('HBLANK_A', '0x001e0004', '')
+('HSYNC_A', '0x001e0008', '')
+('VTOTAL_A', '0x001e000c', '')
+('VBLANK_A', '0x001e0010', '')
+('VSYNC_A', '0x001e0014', '')
+('PIPEASRC', '0x001e001c', '')
+('VSYNCSHIFT_A', '0x001e0028', '')
+('PIPEA_DATA_M1', '0x001e0030', '')
+('PIPEA_DATA_N1', '0x001e0034', '')
+('PIPEA_DATA_M2', '0x001e0038', '')
+('PIPEA_DATA_N2', '0x001e003c', '')
+('PIPEA_LINK_M1', '0x001e0040', '')
+('PIPEA_LINK_N1', '0x001e0044', '')
+('PIPEA_LINK_M2', '0x001e0048', '')
+('PIPEA_LINK_N2', '0x001e004c', '')
+('HTOTAL_B', '0x001e1000', '')
+('HBLANK_B', '0x001e1004', '')
+('HSYNC_B', '0x001e1008', '')
+('VTOTAL_B', '0x001e100c', '')
+('VBLANK_B', '0x001e1010', '')
+('VSYNC_B', '0x001e1014', '')
+('PIPEBSRC', '0x001e101c', '')
+('VSYNCSHIFT_B', '0x001e1028', '')
+('PIPEB_DATA_M1', '0x001e1030', '')
+('PIPEB_DATA_N1', '0x001e1034', '')
+('PIPEB_DATA_M2', '0x001e1038', '')
+('PIPEB_DATA_N2', '0x001e103c', '')
+('PIPEB_LINK_M1', '0x001e1040', '')
+('PIPEB_LINK_N1', '0x001e1044', '')
+('PIPEB_LINK_M2', '0x001e1048', '')
+('PIPEB_LINK_N2', '0x001e104c', '')
+('ADPA', '0x1e1100', '')
+('PORT_HOTPLUG_EN', '0x1e1110', '')
+('PORT_HOTPLUG_STAT', '0x1e1114', '')
+('SDVO_HDMIB', '0x1e1140', '')
+('SDVO_DP2', '0x1e1154', '')
+('HDMIC', '0x1e1160', '')
+('PORT_HOTPLUG_CTRL', '0x1e1164', '')
+('DP_B', '0x1e4100', '')
+('PIPEACONF', '0x001f0008', '')
+('PIPEASTAT', '0x001f0024', '')
+('DPINVGTT', '0x001f002c', '')
+('DSPARB', '0x001f0030', '')
+('FW1', '0x001f0034', '')
+('FW2', '0x001f0038', '')
+('FW3', '0x001f003c', '')
+('FW4', '0x001f0070', '')
+('FW5', '0x001f0074', '')
+('FW6', '0x001f0078', '')
+('FW7', '0x001f007c', '')
+('DDL1', '0x001f0050', '')
+('DDL2', '0x001f0052', '')
+('DSPARB2', '0x001f0060', '')
+('DSPHOWM', '0x001f0064', '')
+('DSPHOWM1', '0x001f0068', '')
+('DSPACNTR', '0x001f0180', '')
+('DSPABASE', '0x001f0184', '')
+('DSPASTRIDE', '0x001f0188', '')
+('DSPASURF', '0x001f019c', '')
+('DSPATILEOFF', '0x001f01a4', '')
+('PIPEBCONF', '0x001f1008', '')
+('PIPEBSTAT', '0x001f1024', '')
+('DSPBCNTR', '0x001f1180', '')
+('DSPBBASE', '0x001f1184', '')
+('DSPBSTRIDE', '0x001f1188', '')
+('DSPBSURF', '0x001f119c', '')
+('DSPBTILEOFF', '0x001f11a4', '')
+('PIPECCONF', '0x001f2008', '')
+('DSPCCNTR', '0x001f2180', '')
+('DSPCBASE', '0x001f2184', '')
+('DSPCSTRIDE', '0x001f2188', '')
+('DSPCSURF', '0x001f219c', '')
+('DSPCTILEOFF', '0x001f21a4', '')
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 07/10] configure.ac: Add swig dependency
  2013-02-03  0:07 [PATCH 00/10] [RFC v2] quick dump Ben Widawsky
                   ` (5 preceding siblings ...)
  2013-02-03  0:07 ` [PATCH 06/10] quick_dump: vlv support Ben Widawsky
@ 2013-02-03  0:07 ` Ben Widawsky
  2013-02-03  0:08 ` [PATCH 08/10] quick_dump: SWIG chipset interface Ben Widawsky
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 20+ messages in thread
From: Ben Widawsky @ 2013-02-03  0:07 UTC (permalink / raw)
  To: intel-gfx
  Cc: Ben Widawsky, vincent.beng.keat.cheah, Matt Turner,
	alan.previn.teres.alexis

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.

Cc: Matt Turner <mattst88@gmail.com>
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
 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

diff --git a/configure.ac b/configure.ac
index 7f89ee6..f2d76d3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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])])
diff --git a/m4/ax_pkg_swig.m4 b/m4/ax_pkg_swig.m4
new file mode 100644
index 0000000..d836eec
--- /dev/null
+++ b/m4/ax_pkg_swig.m4
@@ -0,0 +1,135 @@
+# ===========================================================================
+#        http://www.gnu.org/software/autoconf-archive/ax_pkg_swig.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_PKG_SWIG([major.minor.micro], [action-if-found], [action-if-not-found])
+#
+# DESCRIPTION
+#
+#   This macro searches for a SWIG installation on your system. If found,
+#   then SWIG is AC_SUBST'd; if not found, then $SWIG is empty.  If SWIG is
+#   found, then SWIG_LIB is set to the SWIG library path, and AC_SUBST'd.
+#
+#   You can use the optional first argument to check if the version of the
+#   available SWIG is greater than or equal to the value of the argument. It
+#   should have the format: N[.N[.N]] (N is a number between 0 and 999. Only
+#   the first N is mandatory.) If the version argument is given (e.g.
+#   1.3.17), AX_PKG_SWIG checks that the swig package is this version number
+#   or higher.
+#
+#   As usual, action-if-found is executed if SWIG is found, otherwise
+#   action-if-not-found is executed.
+#
+#   In configure.in, use as:
+#
+#     AX_PKG_SWIG(1.3.17, [], [ AC_MSG_ERROR([SWIG is required to build..]) ])
+#     AX_SWIG_ENABLE_CXX
+#     AX_SWIG_MULTI_MODULE_SUPPORT
+#     AX_SWIG_PYTHON
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Sebastian Huber <sebastian-huber@web.de>
+#   Copyright (c) 2008 Alan W. Irwin
+#   Copyright (c) 2008 Rafael Laboissiere <rafael@laboissiere.net>
+#   Copyright (c) 2008 Andrew Collier
+#   Copyright (c) 2011 Murray Cumming <murrayc@openismus.com>
+#
+#   This program is free software; you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation; either version 2 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+
+#serial 11
+
+AC_DEFUN([AX_PKG_SWIG],[
+        # Ubuntu has swig 2.0 as /usr/bin/swig2.0
+        AC_PATH_PROGS([SWIG],[swig swig2.0])
+        if test -z "$SWIG" ; then
+                m4_ifval([$3],[$3],[:])
+        elif test -n "$1" ; then
+                AC_MSG_CHECKING([SWIG version])
+                [swig_version=`$SWIG -version 2>&1 | grep 'SWIG Version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`]
+                AC_MSG_RESULT([$swig_version])
+                if test -n "$swig_version" ; then
+                        # Calculate the required version number components
+                        [required=$1]
+                        [required_major=`echo $required | sed 's/[^0-9].*//'`]
+                        if test -z "$required_major" ; then
+                                [required_major=0]
+                        fi
+                        [required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
+                        [required_minor=`echo $required | sed 's/[^0-9].*//'`]
+                        if test -z "$required_minor" ; then
+                                [required_minor=0]
+                        fi
+                        [required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
+                        [required_patch=`echo $required | sed 's/[^0-9].*//'`]
+                        if test -z "$required_patch" ; then
+                                [required_patch=0]
+                        fi
+                        # Calculate the available version number components
+                        [available=$swig_version]
+                        [available_major=`echo $available | sed 's/[^0-9].*//'`]
+                        if test -z "$available_major" ; then
+                                [available_major=0]
+                        fi
+                        [available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
+                        [available_minor=`echo $available | sed 's/[^0-9].*//'`]
+                        if test -z "$available_minor" ; then
+                                [available_minor=0]
+                        fi
+                        [available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
+                        [available_patch=`echo $available | sed 's/[^0-9].*//'`]
+                        if test -z "$available_patch" ; then
+                                [available_patch=0]
+                        fi
+                        # Convert the version tuple into a single number for easier comparison.
+                        # Using base 100 should be safe since SWIG internally uses BCD values
+                        # to encode its version number.
+                        required_swig_vernum=`expr $required_major \* 10000 \
+                            \+ $required_minor \* 100 \+ $required_patch`
+                        available_swig_vernum=`expr $available_major \* 10000 \
+                            \+ $available_minor \* 100 \+ $available_patch`
+
+                        if test $available_swig_vernum -lt $required_swig_vernum; then
+                                AC_MSG_WARN([SWIG version >= $1 is required.  You have $swig_version.])
+                                SWIG=''
+                                m4_ifval([$3],[$3],[])
+                        else
+                                AC_MSG_CHECKING([for SWIG library])
+                                SWIG_LIB=`$SWIG -swiglib`
+                                AC_MSG_RESULT([$SWIG_LIB])
+                                m4_ifval([$2],[$2],[])
+                        fi
+                else
+                        AC_MSG_WARN([cannot determine SWIG version])
+                        SWIG=''
+                        m4_ifval([$3],[$3],[])
+                fi
+        fi
+        AC_SUBST([SWIG_LIB])
+])
diff --git a/m4/ax_python_devel.m4 b/m4/ax_python_devel.m4
new file mode 100644
index 0000000..def4b4a
--- /dev/null
+++ b/m4/ax_python_devel.m4
@@ -0,0 +1,325 @@
+# ===========================================================================
+#      http://www.gnu.org/software/autoconf-archive/ax_python_devel.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_PYTHON_DEVEL([version])
+#
+# DESCRIPTION
+#
+#   Note: Defines as a precious variable "PYTHON_VERSION". Don't override it
+#   in your configure.ac.
+#
+#   This macro checks for Python and tries to get the include path to
+#   'Python.h'. It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LDFLAGS)
+#   output variables. It also exports $(PYTHON_EXTRA_LIBS) and
+#   $(PYTHON_EXTRA_LDFLAGS) for embedding Python in your code.
+#
+#   You can search for some particular version of Python by passing a
+#   parameter to this macro, for example ">= '2.3.1'", or "== '2.4'". Please
+#   note that you *have* to pass also an operator along with the version to
+#   match, and pay special attention to the single quotes surrounding the
+#   version number. Don't use "PYTHON_VERSION" for this: that environment
+#   variable is declared as precious and thus reserved for the end-user.
+#
+#   This macro should work for all versions of Python >= 2.1.0. As an end
+#   user, you can disable the check for the python version by setting the
+#   PYTHON_NOVERSIONCHECK environment variable to something else than the
+#   empty string.
+#
+#   If you need to use this macro for an older Python version, please
+#   contact the authors. We're always open for feedback.
+#
+# LICENSE
+#
+#   Copyright (c) 2009 Sebastian Huber <sebastian-huber@web.de>
+#   Copyright (c) 2009 Alan W. Irwin
+#   Copyright (c) 2009 Rafael Laboissiere <rafael@laboissiere.net>
+#   Copyright (c) 2009 Andrew Collier
+#   Copyright (c) 2009 Matteo Settenvini <matteo@member.fsf.org>
+#   Copyright (c) 2009 Horst Knorr <hk_classes@knoda.org>
+#
+#   This program is free software: you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation, either version 3 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+
+#serial 11
+
+AU_ALIAS([AC_PYTHON_DEVEL], [AX_PYTHON_DEVEL])
+AC_DEFUN([AX_PYTHON_DEVEL],[
+	#
+	# Allow the use of a (user set) custom python version
+	#
+	AC_ARG_VAR([PYTHON_VERSION],[The installed Python
+		version to use, for example '2.3'. This string
+		will be appended to the Python interpreter
+		canonical name.])
+
+	AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]])
+	if test -z "$PYTHON"; then
+	   AC_MSG_ERROR([Cannot find python$PYTHON_VERSION in your system path])
+	   PYTHON_VERSION=""
+	fi
+
+	#
+	# Check for a version of Python >= 2.1.0
+	#
+	AC_MSG_CHECKING([for a version of Python >= '2.1.0'])
+	ac_supports_python_ver=`$PYTHON -c "import sys; \
+		ver = sys.version.split ()[[0]]; \
+		print (ver >= '2.1.0')"`
+	if test "$ac_supports_python_ver" != "True"; then
+		if test -z "$PYTHON_NOVERSIONCHECK"; then
+			AC_MSG_RESULT([no])
+			AC_MSG_FAILURE([
+This version of the AC@&t@_PYTHON_DEVEL macro
+doesn't work properly with versions of Python before
+2.1.0. You may need to re-run configure, setting the
+variables PYTHON_CPPFLAGS, PYTHON_LDFLAGS, PYTHON_SITE_PKG,
+PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand.
+Moreover, to disable this check, set PYTHON_NOVERSIONCHECK
+to something else than an empty string.
+])
+		else
+			AC_MSG_RESULT([skip at user request])
+		fi
+	else
+		AC_MSG_RESULT([yes])
+	fi
+
+	#
+	# if the macro parameter ``version'' is set, honour it
+	#
+	if test -n "$1"; then
+		AC_MSG_CHECKING([for a version of Python $1])
+		ac_supports_python_ver=`$PYTHON -c "import sys; \
+			ver = sys.version.split ()[[0]]; \
+			print (ver $1)"`
+		if test "$ac_supports_python_ver" = "True"; then
+		   AC_MSG_RESULT([yes])
+		else
+			AC_MSG_RESULT([no])
+			AC_MSG_ERROR([this package requires Python $1.
+If you have it installed, but it isn't the default Python
+interpreter in your system path, please pass the PYTHON_VERSION
+variable to configure. See ``configure --help'' for reference.
+])
+			PYTHON_VERSION=""
+		fi
+	fi
+
+	#
+	# Check if you have distutils, else fail
+	#
+	AC_MSG_CHECKING([for the distutils Python package])
+	ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`
+	if test -z "$ac_distutils_result"; then
+		AC_MSG_RESULT([yes])
+	else
+		AC_MSG_RESULT([no])
+		AC_MSG_ERROR([cannot import Python module "distutils".
+Please check your Python installation. The error was:
+$ac_distutils_result])
+		PYTHON_VERSION=""
+	fi
+
+	#
+	# Check for Python include path
+	#
+	AC_MSG_CHECKING([for Python include path])
+	if test -z "$PYTHON_CPPFLAGS"; then
+		python_path=`$PYTHON -c "import distutils.sysconfig; \
+			print (distutils.sysconfig.get_python_inc ());"`
+		if test -n "${python_path}"; then
+			python_path="-I$python_path"
+		fi
+		PYTHON_CPPFLAGS=$python_path
+	fi
+	AC_MSG_RESULT([$PYTHON_CPPFLAGS])
+	AC_SUBST([PYTHON_CPPFLAGS])
+
+	#
+	# Check for Python library path
+	#
+	AC_MSG_CHECKING([for Python library path])
+	if test -z "$PYTHON_LDFLAGS"; then
+		# (makes two attempts to ensure we've got a version number
+		# from the interpreter)
+		ac_python_version=`cat<<EOD | $PYTHON -
+
+# join all versioning strings, on some systems
+# major/minor numbers could be in different list elements
+from distutils.sysconfig import *
+ret = ''
+for e in get_config_vars ('VERSION'):
+	if (e != None):
+		ret += e
+print (ret)
+EOD`
+
+		if test -z "$ac_python_version"; then
+			if test -n "$PYTHON_VERSION"; then
+				ac_python_version=$PYTHON_VERSION
+			else
+				ac_python_version=`$PYTHON -c "import sys; \
+					print (sys.version[[:3]])"`
+			fi
+		fi
+
+		# Make the versioning information available to the compiler
+		AC_DEFINE_UNQUOTED([HAVE_PYTHON], ["$ac_python_version"],
+                                   [If available, contains the Python version number currently in use.])
+
+		# First, the library directory:
+		ac_python_libdir=`cat<<EOD | $PYTHON -
+
+# There should be only one
+import distutils.sysconfig
+for e in distutils.sysconfig.get_config_vars ('LIBDIR'):
+	if e != None:
+		print (e)
+		break
+EOD`
+
+		# Before checking for libpythonX.Y, we need to know
+		# the extension the OS we're on uses for libraries
+		# (we take the first one, if there's more than one fix me!):
+		ac_python_soext=`$PYTHON -c \
+		  "import distutils.sysconfig; \
+		  print (distutils.sysconfig.get_config_vars('SO')[[0]])"`
+
+		# Now, for the library:
+		ac_python_soname=`$PYTHON -c \
+		  "import distutils.sysconfig; \
+		  print (distutils.sysconfig.get_config_vars('LDLIBRARY')[[0]])"`
+
+		# Strip away extension from the end to canonicalize its name:
+		ac_python_library=`echo "$ac_python_soname" | sed "s/${ac_python_soext}$//"`
+
+		# This small piece shamelessly adapted from PostgreSQL python macro;
+		# credits goes to momjian, I think. I'd like to put the right name
+		# in the credits, if someone can point me in the right direction... ?
+		#
+		if test -n "$ac_python_libdir" -a -n "$ac_python_library" \
+			-a x"$ac_python_library" != x"$ac_python_soname"
+		then
+			# use the official shared library
+			ac_python_library=`echo "$ac_python_library" | sed "s/^lib//"`
+			PYTHON_LDFLAGS="-L$ac_python_libdir -l$ac_python_library"
+		else
+			# old way: use libpython from python_configdir
+			ac_python_libdir=`$PYTHON -c \
+			  "from distutils.sysconfig import get_python_lib as f; \
+			  import os; \
+			  print (os.path.join(f(plat_specific=1, standard_lib=1), 'config'));"`
+			PYTHON_LDFLAGS="-L$ac_python_libdir -lpython$ac_python_version"
+		fi
+
+		if test -z "PYTHON_LDFLAGS"; then
+			AC_MSG_ERROR([
+  Cannot determine location of your Python DSO. Please check it was installed with
+  dynamic libraries enabled, or try setting PYTHON_LDFLAGS by hand.
+			])
+		fi
+	fi
+	AC_MSG_RESULT([$PYTHON_LDFLAGS])
+	AC_SUBST([PYTHON_LDFLAGS])
+
+	#
+	# Check for site packages
+	#
+	AC_MSG_CHECKING([for Python site-packages path])
+	if test -z "$PYTHON_SITE_PKG"; then
+		PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \
+			print (distutils.sysconfig.get_python_lib(0,0));"`
+	fi
+	AC_MSG_RESULT([$PYTHON_SITE_PKG])
+	AC_SUBST([PYTHON_SITE_PKG])
+
+	#
+	# libraries which must be linked in when embedding
+	#
+	AC_MSG_CHECKING(python extra libraries)
+	if test -z "$PYTHON_EXTRA_LIBS"; then
+	   PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
+                conf = distutils.sysconfig.get_config_var; \
+                print (conf('LOCALMODLIBS') + ' ' + conf('LIBS'))"`
+	fi
+	AC_MSG_RESULT([$PYTHON_EXTRA_LIBS])
+	AC_SUBST(PYTHON_EXTRA_LIBS)
+
+	#
+	# linking flags needed when embedding
+	#
+	AC_MSG_CHECKING(python extra linking flags)
+	if test -z "$PYTHON_EXTRA_LDFLAGS"; then
+		PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \
+			conf = distutils.sysconfig.get_config_var; \
+			print (conf('LINKFORSHARED'))"`
+	fi
+	AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS])
+	AC_SUBST(PYTHON_EXTRA_LDFLAGS)
+
+	#
+	# final check to see if everything compiles alright
+	#
+	AC_MSG_CHECKING([consistency of all components of python development environment])
+	# save current global flags
+	ac_save_LIBS="$LIBS"
+	ac_save_CPPFLAGS="$CPPFLAGS"
+	LIBS="$ac_save_LIBS $PYTHON_LDFLAGS $PYTHON_EXTRA_LDFLAGS $PYTHON_EXTRA_LIBS"
+	CPPFLAGS="$ac_save_CPPFLAGS $PYTHON_CPPFLAGS"
+	AC_LANG_PUSH([C])
+	AC_LINK_IFELSE([
+		AC_LANG_PROGRAM([[#include <Python.h>]],
+				[[Py_Initialize();]])
+		],[pythonexists=yes],[pythonexists=no])
+	AC_LANG_POP([C])
+	# turn back to default flags
+	CPPFLAGS="$ac_save_CPPFLAGS"
+	LIBS="$ac_save_LIBS"
+
+	AC_MSG_RESULT([$pythonexists])
+
+        if test ! "x$pythonexists" = "xyes"; then
+	   AC_MSG_FAILURE([
+  Could not link test program to Python. Maybe the main Python library has been
+  installed in some non-standard library path. If so, pass it to configure,
+  via the LDFLAGS environment variable.
+  Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib"
+  ============================================================================
+   ERROR!
+   You probably have to install the development version of the Python package
+   for your distribution.  The exact name of this package varies among them.
+  ============================================================================
+	   ])
+	  PYTHON_VERSION=""
+	fi
+
+	#
+	# all done!
+	#
+])
diff --git a/m4/ax_swig_python.m4 b/m4/ax_swig_python.m4
new file mode 100644
index 0000000..bf22558
--- /dev/null
+++ b/m4/ax_swig_python.m4
@@ -0,0 +1,64 @@
+# ===========================================================================
+#      http://www.gnu.org/software/autoconf-archive/ax_swig_python.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_SWIG_PYTHON([use-shadow-classes = {no, yes}])
+#
+# DESCRIPTION
+#
+#   Checks for Python and provides the $(AX_SWIG_PYTHON_CPPFLAGS), and
+#   $(AX_SWIG_PYTHON_OPT) output variables.
+#
+#   $(AX_SWIG_PYTHON_OPT) contains all necessary SWIG options to generate
+#   code for Python. Shadow classes are enabled unless the value of the
+#   optional first argument is exactly 'no'. If you need multi module
+#   support (provided by the AX_SWIG_MULTI_MODULE_SUPPORT macro) use
+#   $(AX_SWIG_PYTHON_LIBS) to link against the appropriate library. It
+#   contains the SWIG Python runtime library that is needed by the type
+#   check system for example.
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Sebastian Huber <sebastian-huber@web.de>
+#   Copyright (c) 2008 Alan W. Irwin
+#   Copyright (c) 2008 Rafael Laboissiere <rafael@laboissiere.net>
+#   Copyright (c) 2008 Andrew Collier
+#
+#   This program is free software; you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation; either version 2 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+
+#serial 10
+
+AU_ALIAS([SWIG_PYTHON], [AX_SWIG_PYTHON])
+AC_DEFUN([AX_SWIG_PYTHON],[
+        AC_REQUIRE([AX_PKG_SWIG])
+        AC_REQUIRE([AX_PYTHON_DEVEL])
+        test "x$1" != "xno" || swig_shadow=" -noproxy"
+        AC_SUBST([AX_SWIG_PYTHON_OPT],[-python$swig_shadow])
+        AC_SUBST([AX_SWIG_PYTHON_CPPFLAGS],[$PYTHON_CPPFLAGS])
+])
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 08/10] quick_dump: SWIG chipset interface
  2013-02-03  0:07 [PATCH 00/10] [RFC v2] quick dump Ben Widawsky
                   ` (6 preceding siblings ...)
  2013-02-03  0:07 ` [PATCH 07/10] configure.ac: Add swig dependency Ben Widawsky
@ 2013-02-03  0:08 ` Ben Widawsky
  2013-02-04 18:21   ` Matt Turner
  2013-02-03  0:08 ` [PATCH 09/10] quick_dump: Connect libpciaccess and other utils Ben Widawsky
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 20+ messages in thread
From: Ben Widawsky @ 2013-02-03  0:08 UTC (permalink / raw)
  To: intel-gfx
  Cc: Ben Widawsky, vincent.beng.keat.cheah, Matt Turner,
	alan.previn.teres.alexis

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.

Cc: Matt Turner <mattst88@gmail.com>
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
 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

diff --git a/tools/Makefile.am b/tools/Makefile.am
index 016fb89..6088919 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -1,4 +1,4 @@
-DIST_SUBDIRS = quick_dump
+SUBDIRS = quick_dump
 
 bin_PROGRAMS = 				\
 	intel_disable_clock_gating 	\
diff --git a/tools/quick_dump/Makefile.am b/tools/quick_dump/Makefile.am
index a0c7083..6c04dd5 100644
--- a/tools/quick_dump/Makefile.am
+++ b/tools/quick_dump/Makefile.am
@@ -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
diff --git a/tools/quick_dump/chipset.i b/tools/quick_dump/chipset.i
new file mode 100644
index 0000000..16c4932
--- /dev/null
+++ b/tools/quick_dump/chipset.i
@@ -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);
diff --git a/tools/quick_dump/intel_chipset.c b/tools/quick_dump/intel_chipset.c
new file mode 100644
index 0000000..b242ffc
--- /dev/null
+++ b/tools/quick_dump/intel_chipset.c
@@ -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);
+}
diff --git a/tools/quick_dump/quick_dump.py b/tools/quick_dump/quick_dump.py
index 3fea7bb..59cae1f 100755
--- a/tools/quick_dump/quick_dump.py
+++ b/tools/quick_dump/quick_dump.py
@@ -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()
 
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 09/10] quick_dump: Connect libpciaccess and other utils
  2013-02-03  0:07 [PATCH 00/10] [RFC v2] quick dump Ben Widawsky
                   ` (7 preceding siblings ...)
  2013-02-03  0:08 ` [PATCH 08/10] quick_dump: SWIG chipset interface Ben Widawsky
@ 2013-02-03  0:08 ` Ben Widawsky
  2013-02-03 18:15   ` Ben Widawsky
  2013-02-03  0:08 ` [PATCH 10/10] quick_dump: Use the register access library Ben Widawsky
  2013-02-03  9:29 ` [PATCH 00/10] [RFC v2] quick dump Jesse Barnes
  10 siblings, 1 reply; 20+ messages in thread
From: Ben Widawsky @ 2013-02-03  0:08 UTC (permalink / raw)
  To: intel-gfx; +Cc: Ben Widawsky, vincent.beng.keat.cheah, alan.previn.teres.alexis

Make a register access library with sample to do register reads

Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
 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

diff --git a/tools/quick_dump/Makefile.am b/tools/quick_dump/Makefile.am
index 6c04dd5..4711830 100644
--- a/tools/quick_dump/Makefile.am
+++ b/tools/quick_dump/Makefile.am
@@ -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 \
+			       ../../lib/intel_drm.c  \
+			       ../../lib/intel_pci.c  \
+			       ../../lib/intel_reg_map.c  \
+			       ../../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
diff --git a/tools/quick_dump/chipset.i b/tools/quick_dump/chipset.i
index 16c4932..2f4f5ef 100644
--- a/tools/quick_dump/chipset.i
+++ b/tools/quick_dump/chipset.i
@@ -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);
diff --git a/tools/quick_dump/intel_chipset.c b/tools/quick_dump/intel_chipset.c
index b242ffc..d6e7f91 100644
--- a/tools/quick_dump/intel_chipset.c
+++ b/tools/quick_dump/intel_chipset.c
@@ -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;
+}
diff --git a/tools/quick_dump/quick_dump.py b/tools/quick_dump/quick_dump.py
index 59cae1f..44aa2ba 100755
--- a/tools/quick_dump/quick_dump.py
+++ b/tools/quick_dump/quick_dump.py
@@ -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):
diff --git a/tools/quick_dump/reg_access.py b/tools/quick_dump/reg_access.py
new file mode 100755
index 0000000..0f63424
--- /dev/null
+++ b/tools/quick_dump/reg_access.py
@@ -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()
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 10/10] quick_dump: Use the register access library
  2013-02-03  0:07 [PATCH 00/10] [RFC v2] quick dump Ben Widawsky
                   ` (8 preceding siblings ...)
  2013-02-03  0:08 ` [PATCH 09/10] quick_dump: Connect libpciaccess and other utils Ben Widawsky
@ 2013-02-03  0:08 ` Ben Widawsky
  2013-02-03  9:29 ` [PATCH 00/10] [RFC v2] quick dump Jesse Barnes
  10 siblings, 0 replies; 20+ messages in thread
From: Ben Widawsky @ 2013-02-03  0:08 UTC (permalink / raw)
  To: intel-gfx; +Cc: Ben Widawsky, vincent.beng.keat.cheah, alan.previn.teres.alexis

Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
 tools/quick_dump/quick_dump.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/tools/quick_dump/quick_dump.py b/tools/quick_dump/quick_dump.py
index 44aa2ba..5c88ef1 100755
--- a/tools/quick_dump/quick_dump.py
+++ b/tools/quick_dump/quick_dump.py
@@ -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('.'):
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH 00/10] [RFC v2] quick dump
  2013-02-03  0:07 [PATCH 00/10] [RFC v2] quick dump Ben Widawsky
                   ` (9 preceding siblings ...)
  2013-02-03  0:08 ` [PATCH 10/10] quick_dump: Use the register access library Ben Widawsky
@ 2013-02-03  9:29 ` Jesse Barnes
  2013-02-03 12:22   ` Chris Wilson
  10 siblings, 1 reply; 20+ messages in thread
From: Jesse Barnes @ 2013-02-03  9:29 UTC (permalink / raw)
  To: Ben Widawsky; +Cc: intel-gfx, vincent.beng.keat.cheah, alan.previn.teres.alexis

On Sat,  2 Feb 2013 16:07:52 -0800
Ben Widawsky <ben@bwidawsk.net> wrote:

> This is my second attempt at winning approval for the series. First one
> was: https://patchwork.kernel.org/patch/1493131/
> 
> In spending the time to rework this tool, I've begun to lose my belief
> in some of the original motivations I had.  Even if you don't want to
> review, but just like (or dislike) what you see, I'd appreciate such
> comments.

I'd like to see it land in i-g-t.  Having the regs defined in a text or
xml file is an improvement over what we have today, and is easier to
extend.  At first the advantage of reg_dumper was that it parsed out
the bitfields of the various regs.  But we didn't keep up with that,
and also haven't kept up with the regs on new platforms as well as we
could.  Text files would make that easier, and xml files might bring
back the bit field parsing, which would be extra nice.

Acked-by: Jesse Barnes <jbarnes@virtuousgeek.org>

Jesse

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 00/10] [RFC v2] quick dump
  2013-02-03  9:29 ` [PATCH 00/10] [RFC v2] quick dump Jesse Barnes
@ 2013-02-03 12:22   ` Chris Wilson
  2013-02-03 18:13     ` Ben Widawsky
  0 siblings, 1 reply; 20+ messages in thread
From: Chris Wilson @ 2013-02-03 12:22 UTC (permalink / raw)
  To: Jesse Barnes
  Cc: Ben Widawsky, vincent.beng.keat.cheah, intel-gfx,
	alan.previn.teres.alexis

On Sun, Feb 03, 2013 at 10:29:15AM +0100, Jesse Barnes wrote:
> On Sat,  2 Feb 2013 16:07:52 -0800
> Ben Widawsky <ben@bwidawsk.net> wrote:
> 
> > This is my second attempt at winning approval for the series. First one
> > was: https://patchwork.kernel.org/patch/1493131/
> > 
> > In spending the time to rework this tool, I've begun to lose my belief
> > in some of the original motivations I had.  Even if you don't want to
> > review, but just like (or dislike) what you see, I'd appreciate such
> > comments.
> 
> I'd like to see it land in i-g-t.  Having the regs defined in a text or
> xml file is an improvement over what we have today, and is easier to
> extend.  At first the advantage of reg_dumper was that it parsed out
> the bitfields of the various regs.  But we didn't keep up with that,
> and also haven't kept up with the regs on new platforms as well as we
> could.  Text files would make that easier, and xml files might bring
> back the bit field parsing, which would be extra nice.

Completely agree. For me the big improvement would be being able to use
the bspec register names or our internal approximation thereof rather
than having to loop up the actual addresses every time. 

Having the name database available in python should make building
integrated little snippets to parse traces which are also python
accessible.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 00/10] [RFC v2] quick dump
  2013-02-03 12:22   ` Chris Wilson
@ 2013-02-03 18:13     ` Ben Widawsky
  2013-02-04 15:10       ` Daniel Vetter
  2013-02-05 11:59       ` Damien Lespiau
  0 siblings, 2 replies; 20+ messages in thread
From: Ben Widawsky @ 2013-02-03 18:13 UTC (permalink / raw)
  To: Chris Wilson, Jesse Barnes, intel-gfx, vincent.beng.keat.cheah,
	alan.previn.teres.alexis

On Sun, Feb 03, 2013 at 12:22:25PM +0000, Chris Wilson wrote:
> On Sun, Feb 03, 2013 at 10:29:15AM +0100, Jesse Barnes wrote:
> > On Sat,  2 Feb 2013 16:07:52 -0800
> > Ben Widawsky <ben@bwidawsk.net> wrote:
> > 
> > > This is my second attempt at winning approval for the series. First one
> > > was: https://patchwork.kernel.org/patch/1493131/
> > > 
> > > In spending the time to rework this tool, I've begun to lose my belief
> > > in some of the original motivations I had.  Even if you don't want to
> > > review, but just like (or dislike) what you see, I'd appreciate such
> > > comments.
> > 
> > I'd like to see it land in i-g-t.  Having the regs defined in a text or
> > xml file is an improvement over what we have today, and is easier to
> > extend.  At first the advantage of reg_dumper was that it parsed out
> > the bitfields of the various regs.  But we didn't keep up with that,
> > and also haven't kept up with the regs on new platforms as well as we
> > could.  Text files would make that easier, and xml files might bring
> > back the bit field parsing, which would be extra nice.
> 
> Completely agree. For me the big improvement would be being able to use
> the bspec register names or our internal approximation thereof rather
> than having to loop up the actual addresses every time. 
> 
> Having the name database available in python should make building
> integrated little snippets to parse traces which are also python
> accessible.
> -Chris

It's really nice to get support from you. A mix of fever and staring at
the same code too long can really make someone go crazy. Still, a few
concerns left from me, one of which I accidentally left out of the
description.

- Someone needs to give me a yes or no on the m4 extension macros. This
  will block any pushing.
- The build kind of sucks on Arch because of Arch's choices regarding
  python libraries. To build this on Arch, you must run something like:
  ./autogen.sh PYTHON_LDFLAGS="-L/usr/lib/python3.3 -lpython3.3m"
  I really don't like autogen not working out of the box. Perhaps I need
  to add an AC_ flag to default this tool to off? What do others think?
  Does it work properly on other distros? How to handle this?
- Ideally, I'd like someone to send me some fixes for valleyview
  definitions if they're needed. I am not sure.

Jesse, if you can send me a list of DPIO offsets to read, I'll add the
appropriate patch. (It can wait until you get back).

-- 
Ben Widawsky, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 09/10] quick_dump: Connect libpciaccess and other utils
  2013-02-03  0:08 ` [PATCH 09/10] quick_dump: Connect libpciaccess and other utils Ben Widawsky
@ 2013-02-03 18:15   ` Ben Widawsky
  0 siblings, 0 replies; 20+ messages in thread
From: Ben Widawsky @ 2013-02-03 18:15 UTC (permalink / raw)
  To: intel-gfx; +Cc: vincent.beng.keat.cheah, alan.previn.teres.alexis

On Sat, Feb 02, 2013 at 04:08:01PM -0800, Ben Widawsky wrote:
> Make a register access library with sample to do register reads
> 
> Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
> ---
>  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
> 
> diff --git a/tools/quick_dump/Makefile.am b/tools/quick_dump/Makefile.am
> index 6c04dd5..4711830 100644
> --- a/tools/quick_dump/Makefile.am
> +++ b/tools/quick_dump/Makefile.am
> @@ -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 \
> +			       ../../lib/intel_drm.c  \
> +			       ../../lib/intel_pci.c  \
> +			       ../../lib/intel_reg_map.c  \
> +			       ../../lib/intel_mmio.c

I should probably $(top_srcdir)/lib these sources. Fixed locally.

>  
>  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
> diff --git a/tools/quick_dump/chipset.i b/tools/quick_dump/chipset.i
> index 16c4932..2f4f5ef 100644
> --- a/tools/quick_dump/chipset.i
> +++ b/tools/quick_dump/chipset.i
> @@ -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);
> diff --git a/tools/quick_dump/intel_chipset.c b/tools/quick_dump/intel_chipset.c
> index b242ffc..d6e7f91 100644
> --- a/tools/quick_dump/intel_chipset.c
> +++ b/tools/quick_dump/intel_chipset.c
> @@ -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;
> +}
> diff --git a/tools/quick_dump/quick_dump.py b/tools/quick_dump/quick_dump.py
> index 59cae1f..44aa2ba 100755
> --- a/tools/quick_dump/quick_dump.py
> +++ b/tools/quick_dump/quick_dump.py
> @@ -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):
> diff --git a/tools/quick_dump/reg_access.py b/tools/quick_dump/reg_access.py
> new file mode 100755
> index 0000000..0f63424
> --- /dev/null
> +++ b/tools/quick_dump/reg_access.py
> @@ -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()
> -- 
> 1.8.1.2
> 

-- 
Ben Widawsky, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 00/10] [RFC v2] quick dump
  2013-02-03 18:13     ` Ben Widawsky
@ 2013-02-04 15:10       ` Daniel Vetter
  2013-02-04 18:19         ` Ben Widawsky
  2013-02-05 11:59       ` Damien Lespiau
  1 sibling, 1 reply; 20+ messages in thread
From: Daniel Vetter @ 2013-02-04 15:10 UTC (permalink / raw)
  To: Ben Widawsky; +Cc: intel-gfx, vincent.beng.keat.cheah, alan.previn.teres.alexis

On Sun, Feb 03, 2013 at 10:13:10AM -0800, Ben Widawsky wrote:
> On Sun, Feb 03, 2013 at 12:22:25PM +0000, Chris Wilson wrote:
> > On Sun, Feb 03, 2013 at 10:29:15AM +0100, Jesse Barnes wrote:
> > > On Sat,  2 Feb 2013 16:07:52 -0800
> > > Ben Widawsky <ben@bwidawsk.net> wrote:
> > > 
> > > > This is my second attempt at winning approval for the series. First one
> > > > was: https://patchwork.kernel.org/patch/1493131/
> > > > 
> > > > In spending the time to rework this tool, I've begun to lose my belief
> > > > in some of the original motivations I had.  Even if you don't want to
> > > > review, but just like (or dislike) what you see, I'd appreciate such
> > > > comments.
> > > 
> > > I'd like to see it land in i-g-t.  Having the regs defined in a text or
> > > xml file is an improvement over what we have today, and is easier to
> > > extend.  At first the advantage of reg_dumper was that it parsed out
> > > the bitfields of the various regs.  But we didn't keep up with that,
> > > and also haven't kept up with the regs on new platforms as well as we
> > > could.  Text files would make that easier, and xml files might bring
> > > back the bit field parsing, which would be extra nice.
> > 
> > Completely agree. For me the big improvement would be being able to use
> > the bspec register names or our internal approximation thereof rather
> > than having to loop up the actual addresses every time. 
> > 
> > Having the name database available in python should make building
> > integrated little snippets to parse traces which are also python
> > accessible.
> > -Chris
> 
> It's really nice to get support from you. A mix of fever and staring at
> the same code too long can really make someone go crazy. Still, a few
> concerns left from me, one of which I accidentally left out of the
> description.
> 
> - Someone needs to give me a yes or no on the m4 extension macros. This
>   will block any pushing.
> - The build kind of sucks on Arch because of Arch's choices regarding
>   python libraries. To build this on Arch, you must run something like:
>   ./autogen.sh PYTHON_LDFLAGS="-L/usr/lib/python3.3 -lpython3.3m"
>   I really don't like autogen not working out of the box. Perhaps I need
>   to add an AC_ flag to default this tool to off? What do others think?
>   Does it work properly on other distros? How to handle this?
> - Ideally, I'd like someone to send me some fixes for valleyview
>   definitions if they're needed. I am not sure.
> 
> Jesse, if you can send me a list of DPIO offsets to read, I'll add the
> appropriate patch. (It can wait until you get back).

Yeah, I like. Can't help you with the autfoo though :( And no opinion on
the m4 macro stuff, I guess you need to poke our legal guys quickly for
this.

The only thing to ponder imo is whether we should add intel_ prefixes to
the tools and add all the new files to the install target (probably need
tos shove the data files somewhere in var then). Without that we need to
ask bug reporters to install latest git and run the dumper tools from
there.

Otoh we do ask them to grab latest i-g-t git almost every time, anyway ...
-Daniel
> 
> -- 
> Ben Widawsky, Intel Open Source Technology Center
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 00/10] [RFC v2] quick dump
  2013-02-04 15:10       ` Daniel Vetter
@ 2013-02-04 18:19         ` Ben Widawsky
  0 siblings, 0 replies; 20+ messages in thread
From: Ben Widawsky @ 2013-02-04 18:19 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: intel-gfx, vincent.beng.keat.cheah, alan.previn.teres.alexis

On Mon, Feb 04, 2013 at 04:10:55PM +0100, Daniel Vetter wrote:
> On Sun, Feb 03, 2013 at 10:13:10AM -0800, Ben Widawsky wrote:
> > On Sun, Feb 03, 2013 at 12:22:25PM +0000, Chris Wilson wrote:
> > > On Sun, Feb 03, 2013 at 10:29:15AM +0100, Jesse Barnes wrote:
> > > > On Sat,  2 Feb 2013 16:07:52 -0800
> > > > Ben Widawsky <ben@bwidawsk.net> wrote:
> > > > 
> > > > > This is my second attempt at winning approval for the series. First one
> > > > > was: https://patchwork.kernel.org/patch/1493131/
> > > > > 
> > > > > In spending the time to rework this tool, I've begun to lose my belief
> > > > > in some of the original motivations I had.  Even if you don't want to
> > > > > review, but just like (or dislike) what you see, I'd appreciate such
> > > > > comments.
> > > > 
> > > > I'd like to see it land in i-g-t.  Having the regs defined in a text or
> > > > xml file is an improvement over what we have today, and is easier to
> > > > extend.  At first the advantage of reg_dumper was that it parsed out
> > > > the bitfields of the various regs.  But we didn't keep up with that,
> > > > and also haven't kept up with the regs on new platforms as well as we
> > > > could.  Text files would make that easier, and xml files might bring
> > > > back the bit field parsing, which would be extra nice.
> > > 
> > > Completely agree. For me the big improvement would be being able to use
> > > the bspec register names or our internal approximation thereof rather
> > > than having to loop up the actual addresses every time. 
> > > 
> > > Having the name database available in python should make building
> > > integrated little snippets to parse traces which are also python
> > > accessible.
> > > -Chris
> > 
> > It's really nice to get support from you. A mix of fever and staring at
> > the same code too long can really make someone go crazy. Still, a few
> > concerns left from me, one of which I accidentally left out of the
> > description.
> > 
> > - Someone needs to give me a yes or no on the m4 extension macros. This
> >   will block any pushing.
> > - The build kind of sucks on Arch because of Arch's choices regarding
> >   python libraries. To build this on Arch, you must run something like:
> >   ./autogen.sh PYTHON_LDFLAGS="-L/usr/lib/python3.3 -lpython3.3m"
> >   I really don't like autogen not working out of the box. Perhaps I need
> >   to add an AC_ flag to default this tool to off? What do others think?
> >   Does it work properly on other distros? How to handle this?
> > - Ideally, I'd like someone to send me some fixes for valleyview
> >   definitions if they're needed. I am not sure.
> > 
> > Jesse, if you can send me a list of DPIO offsets to read, I'll add the
> > appropriate patch. (It can wait until you get back).
> 
> Yeah, I like. Can't help you with the autfoo though :( And no opinion on
> the m4 macro stuff, I guess you need to poke our legal guys quickly for
> this.

Okay, I think I've satisfied myself, from the project page:
http://savannah.gnu.org/projects/autoconf-archive/

"Every single one of those macros can be re-used without imposing any
restrictions whatsoever on the licensing of the generated configure
script. In particular, it is possible to use all those macros in
configure scripts that are meant for non-free software"

> 
> The only thing to ponder imo is whether we should add intel_ prefixes to
> the tools and add all the new files to the install target (probably need
> tos shove the data files somewhere in var then). Without that we need to
> ask bug reporters to install latest git and run the dumper tools from
> there.
> 
> Otoh we do ask them to grab latest i-g-t git almost every time, anyway ...
> -Daniel

I've gone back and forth as to whether or not I want to robustly support
this from "make install." I'm not really too certain of the correct way
to install python scripts, so I've mostly punted on this. My feeling for
now is, let's make it work in tree, and when it becomes more useful,
make sure it works with make install.

> > 
> > -- 
> > Ben Widawsky, Intel Open Source Technology Center
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/intel-gfx
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> +41 (0) 79 365 57 48 - http://blog.ffwll.ch

-- 
Ben Widawsky, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 08/10] quick_dump: SWIG chipset interface
  2013-02-03  0:08 ` [PATCH 08/10] quick_dump: SWIG chipset interface Ben Widawsky
@ 2013-02-04 18:21   ` Matt Turner
  0 siblings, 0 replies; 20+ messages in thread
From: Matt Turner @ 2013-02-04 18:21 UTC (permalink / raw)
  To: Ben Widawsky; +Cc: intel-gfx, vincent.beng.keat.cheah, alan.previn.teres.alexis

On Sat, Feb 2, 2013 at 4:08 PM, Ben Widawsky <ben@bwidawsk.net> wrote:
> 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.
>
> Cc: Matt Turner <mattst88@gmail.com>
> Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
> ---

Patches 7 & 8 are Reviewed-by: Matt Turner <mattst88@gmail.com>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 00/10] [RFC v2] quick dump
  2013-02-03 18:13     ` Ben Widawsky
  2013-02-04 15:10       ` Daniel Vetter
@ 2013-02-05 11:59       ` Damien Lespiau
  2013-02-05 16:48         ` Ben Widawsky
  1 sibling, 1 reply; 20+ messages in thread
From: Damien Lespiau @ 2013-02-05 11:59 UTC (permalink / raw)
  To: Ben Widawsky; +Cc: intel-gfx, vincent.beng.keat.cheah, alan.previn.teres.alexis

On Sun, Feb 03, 2013 at 10:13:10AM -0800, Ben Widawsky wrote:
> - The build kind of sucks on Arch because of Arch's choices regarding
>   python libraries. To build this on Arch, you must run something like:
>   ./autogen.sh PYTHON_LDFLAGS="-L/usr/lib/python3.3 -lpython3.3m"

Don't you have a python3.pc that would allow you to pull the right
flags?

An other detail it that we can't add those hard dependencies to i-g-t,
distributions will hate us (even more). So you'd need to make its
compilation optional.

-- 
Damien

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 00/10] [RFC v2] quick dump
  2013-02-05 11:59       ` Damien Lespiau
@ 2013-02-05 16:48         ` Ben Widawsky
  0 siblings, 0 replies; 20+ messages in thread
From: Ben Widawsky @ 2013-02-05 16:48 UTC (permalink / raw)
  To: Damien Lespiau
  Cc: intel-gfx, vincent.beng.keat.cheah, alan.previn.teres.alexis

On Tue, Feb 05, 2013 at 11:59:19AM +0000, Damien Lespiau wrote:
> On Sun, Feb 03, 2013 at 10:13:10AM -0800, Ben Widawsky wrote:
> > - The build kind of sucks on Arch because of Arch's choices regarding
> >   python libraries. To build this on Arch, you must run something like:
> >   ./autogen.sh PYTHON_LDFLAGS="-L/usr/lib/python3.3 -lpython3.3m"
> 
> Don't you have a python3.pc that would allow you to pull the right
> flags?

It's the python devel stuff which seems broken. I don't know too much
about this stuff. I'm guessing it just works on other distros.

> 
> An other detail it that we can't add those hard dependencies to i-g-t,
> distributions will hate us (even more). So you'd need to make its
> compilation optional.
> 
> -- 
> Damien

I have no problem doing that. Remember though that SWIG is a build time
dependency, not a run time one. That shouldn't be an issue for any
distro. So it's really just python which concerns you?

-- 
Ben Widawsky, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2013-02-05 16:47 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-03  0:07 [PATCH 00/10] [RFC v2] quick dump Ben Widawsky
2013-02-03  0:07 ` [PATCH 01/10] configure.ac: Fix spacing Ben Widawsky
2013-02-03  0:07 ` [PATCH 02/10] configure.ac: Add vim magic modeline Ben Widawsky
2013-02-03  0:07 ` [PATCH 03/10] quick_dump: A dump utility different than reg_dumper Ben Widawsky
2013-02-03  0:07 ` [PATCH 04/10] quick_dump: gen6 support Ben Widawsky
2013-02-03  0:07 ` [PATCH 05/10] quick_dump: gen7 support Ben Widawsky
2013-02-03  0:07 ` [PATCH 06/10] quick_dump: vlv support Ben Widawsky
2013-02-03  0:07 ` [PATCH 07/10] configure.ac: Add swig dependency Ben Widawsky
2013-02-03  0:08 ` [PATCH 08/10] quick_dump: SWIG chipset interface Ben Widawsky
2013-02-04 18:21   ` Matt Turner
2013-02-03  0:08 ` [PATCH 09/10] quick_dump: Connect libpciaccess and other utils Ben Widawsky
2013-02-03 18:15   ` Ben Widawsky
2013-02-03  0:08 ` [PATCH 10/10] quick_dump: Use the register access library Ben Widawsky
2013-02-03  9:29 ` [PATCH 00/10] [RFC v2] quick dump Jesse Barnes
2013-02-03 12:22   ` Chris Wilson
2013-02-03 18:13     ` Ben Widawsky
2013-02-04 15:10       ` Daniel Vetter
2013-02-04 18:19         ` Ben Widawsky
2013-02-05 11:59       ` Damien Lespiau
2013-02-05 16:48         ` Ben Widawsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).