[Intel-gfx] [PATCH] scripts: Add a dmesg filter to prettify ioctl traces

Damien Lespiau damien.lespiau at gmail.com
Thu Nov 1 17:42:47 CET 2012


From: Damien Lespiau <damien.lespiau at intel.com>

Signed-off-by: Damien Lespiau <damien.lespiau at intel.com>
---
 scripts/Makefile.am  |   2 +-
 scripts/dmesg_filter | 195 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 196 insertions(+), 1 deletion(-)
 create mode 100755 scripts/dmesg_filter

diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index baf3612..cbaafea 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -1,3 +1,3 @@
 
 dist_noinst_SCRIPTS = who.sh
-noinst_PYTHON = throttle.py
+noinst_PYTHON = throttle.py dmesg_filter
diff --git a/scripts/dmesg_filter b/scripts/dmesg_filter
new file mode 100755
index 0000000..782a942
--- /dev/null
+++ b/scripts/dmesg_filter
@@ -0,0 +1,195 @@
+#!/usr/bin/env python
+import fileinput
+import re
+import sys
+
+DRM_COMMAND_BASE = 0x40
+DRM_COMMAND_END  = 0xA0
+
+drm_ioctls = (
+    ('DRM_IOCTL_VERSION', 0x00),
+    ('DRM_IOCTL_GET_UNIQUE', 0x01),
+    ('DRM_IOCTL_GET_MAGIC', 0x02),
+    ('DRM_IOCTL_IRQ_BUSID', 0x03),
+    ('DRM_IOCTL_GET_MAP', 0x04),
+    ('DRM_IOCTL_GET_CLIENT', 0x05),
+    ('DRM_IOCTL_GET_STATS', 0x06),
+    ('DRM_IOCTL_SET_VERSION', 0x07),
+    ('DRM_IOCTL_MODESET_CTL', 0x08),
+    ('DRM_IOCTL_GEM_CLOSE', 0x09),
+    ('DRM_IOCTL_GEM_FLINK', 0x0a),
+    ('DRM_IOCTL_GEM_OPEN', 0x0b),
+    ('DRM_IOCTL_GET_CAP', 0x0c),
+
+    ('DRM_IOCTL_SET_UNIQUE', 0x10),
+    ('DRM_IOCTL_AUTH_MAGIC', 0x11),
+    ('DRM_IOCTL_BLOCK', 0x12),
+    ('DRM_IOCTL_UNBLOCK', 0x13),
+    ('DRM_IOCTL_CONTROL', 0x14),
+    ('DRM_IOCTL_ADD_MAP', 0x15),
+    ('DRM_IOCTL_ADD_BUFS', 0x16),
+    ('DRM_IOCTL_MARK_BUFS', 0x17),
+    ('DRM_IOCTL_INFO_BUFS', 0x18),
+    ('DRM_IOCTL_MAP_BUFS', 0x19),
+    ('DRM_IOCTL_FREE_BUFS', 0x1a),
+
+    ('DRM_IOCTL_RM_MAP', 0x1b),
+
+    ('DRM_IOCTL_SET_SAREA_CTX', 0x1c),
+    ('DRM_IOCTL_GET_SAREA_CTX', 0x1d),
+
+    ('DRM_IOCTL_SET_MASTER', 0x1e),
+    ('DRM_IOCTL_DROP_MASTER', 0x1f),
+
+    ('DRM_IOCTL_ADD_CTX', 0x20),
+    ('DRM_IOCTL_RM_CTX', 0x21),
+    ('DRM_IOCTL_MOD_CTX', 0x22),
+    ('DRM_IOCTL_GET_CTX', 0x23),
+    ('DRM_IOCTL_SWITCH_CTX', 0x24),
+    ('DRM_IOCTL_NEW_CTX', 0x25),
+    ('DRM_IOCTL_RES_CTX', 0x26),
+    ('DRM_IOCTL_ADD_DRAW', 0x27),
+    ('DRM_IOCTL_RM_DRAW', 0x28),
+    ('DRM_IOCTL_DMA', 0x29),
+    ('DRM_IOCTL_LOCK', 0x2a),
+    ('DRM_IOCTL_UNLOCK', 0x2b),
+    ('DRM_IOCTL_FINISH', 0x2c),
+
+    ('DRM_IOCTL_PRIME_HANDLE_TO_FD', 0x2d),
+    ('DRM_IOCTL_PRIME_FD_TO_HANDLE', 0x2e),
+
+    ('DRM_IOCTL_AGP_ACQUIRE', 0x30),
+    ('DRM_IOCTL_AGP_RELEASE', 0x31),
+    ('DRM_IOCTL_AGP_ENABLE',  0x32),
+    ('DRM_IOCTL_AGP_INFO', 0x33),
+    ('DRM_IOCTL_AGP_ALLOC',0x34),
+    ('DRM_IOCTL_AGP_FREE', 0x35),
+    ('DRM_IOCTL_AGP_BIND', 0x36),
+    ('DRM_IOCTL_AGP_UNBIND', 0x37),
+
+    ('DRM_IOCTL_SG_ALLOC', 0x38),
+    ('DRM_IOCTL_SG_FREE', 0x39),
+
+    ('DRM_IOCTL_WAIT_VBLANK', 0x3a),
+
+    ('DRM_IOCTL_UPDATE_DRAW', 0x3f),
+
+    ('DRM_IOCTL_MODE_GETRESOURCES', 0xA0),
+    ('DRM_IOCTL_MODE_GETCRTC', 0xA1),
+    ('DRM_IOCTL_MODE_SETCRTC', 0xA2),
+    ('DRM_IOCTL_MODE_CURSOR', 0xA3),
+    ('DRM_IOCTL_MODE_GETGAMMA', 0xA4),
+    ('DRM_IOCTL_MODE_SETGAMMA', 0xA5),
+    ('DRM_IOCTL_MODE_GETENCODER', 0xA6),
+    ('DRM_IOCTL_MODE_GETCONNECTOR', 0xA7),
+    ('DRM_IOCTL_MODE_ATTACHMODE', 0xA8),
+    ('DRM_IOCTL_MODE_DETACHMODE', 0xA9),
+
+    ('DRM_IOCTL_MODE_GETPROPERTY', 0xAA),
+    ('DRM_IOCTL_MODE_SETPROPERTY', 0xAB),
+    ('DRM_IOCTL_MODE_GETPROPBLOB', 0xAC),
+    ('DRM_IOCTL_MODE_GETFB', 0xAD),
+    ('DRM_IOCTL_MODE_ADDFB', 0xAE),
+    ('DRM_IOCTL_MODE_RMFB', 0xAF),
+    ('DRM_IOCTL_MODE_PAGE_FLIP', 0xB0),
+    ('DRM_IOCTL_MODE_DIRTYFB', 0xB1),
+
+    ('DRM_IOCTL_MODE_CREATE_DUMB', 0xB2),
+    ('DRM_IOCTL_MODE_MAP_DUMB', 0xB3),
+    ('DRM_IOCTL_MODE_DESTROY_DUMB', 0xB4),
+    ('DRM_IOCTL_MODE_GETPLANERESOURCES', 0xB5),
+    ('DRM_IOCTL_MODE_GETPLANE', 0xB6),
+    ('DRM_IOCTL_MODE_SETPLANE', 0xB7),
+    ('DRM_IOCTL_MODE_ADDFB2', 0xB8),
+    ('DRM_IOCTL_MODE_OBJ_GETPROPERTIES', 0xB9),
+    ('DRM_IOCTL_MODE_OBJ_SETPROPERTY', 0xBA),
+)
+
+intel_ioctls = (
+    ('DRM_I915_INIT', 0x00),
+    ('DRM_I915_FLUSH', 0x01),
+    ('DRM_I915_FLIP', 0x02),
+    ('DRM_I915_BATCHBUFFER', 0x03),
+    ('DRM_I915_IRQ_EMIT', 0x04),
+    ('DRM_I915_IRQ_WAIT', 0x05),
+    ('DRM_I915_GETPARAM', 0x06),
+    ('DRM_I915_SETPARAM', 0x07),
+    ('DRM_I915_ALLOC', 0x08),
+    ('DRM_I915_FREE', 0x09),
+    ('DRM_I915_INIT_HEAP', 0x0a),
+    ('DRM_I915_CMDBUFFER', 0x0b),
+    ('DRM_I915_DESTROY_HEAP', 0x0c),
+    ('DRM_I915_SET_VBLANK_PIPE', 0x0d),
+    ('DRM_I915_GET_VBLANK_PIPE', 0x0e),
+    ('DRM_I915_VBLANK_SWAP', 0x0f),
+    ('DRM_I915_HWS_ADDR', 0x11),
+    ('DRM_I915_GEM_INIT', 0x13),
+    ('DRM_I915_GEM_EXECBUFFER', 0x14),
+    ('DRM_I915_GEM_PIN', 0x15),
+    ('DRM_I915_GEM_UNPIN', 0x16),
+    ('DRM_I915_GEM_BUSY', 0x17),
+    ('DRM_I915_GEM_THROTTLE', 0x18),
+    ('DRM_I915_GEM_ENTERVT', 0x19),
+    ('DRM_I915_GEM_LEAVEVT', 0x1a),
+    ('DRM_I915_GEM_CREATE', 0x1b),
+    ('DRM_I915_GEM_PREAD', 0x1c),
+    ('DRM_I915_GEM_PWRITE', 0x1d),
+    ('DRM_I915_GEM_MMAP', 0x1e),
+    ('DRM_I915_GEM_SET_DOMAIN', 0x1f),
+    ('DRM_I915_GEM_SW_FINISH', 0x20),
+    ('DRM_I915_GEM_SET_TILING', 0x21),
+    ('DRM_I915_GEM_GET_TILING', 0x22),
+    ('DRM_I915_GEM_GET_APERTURE', 0x23),
+    ('DRM_I915_GEM_MMAP_GTT', 0x24),
+    ('DRM_I915_GET_PIPE_FROM_CRTC_ID', 0x25),
+    ('DRM_I915_GEM_MADVISE', 0x26),
+    ('DRM_I915_OVERLAY_PUT_IMAGE', 0x27),
+    ('DRM_I915_OVERLAY_ATTRS', 0x28),
+    ('DRM_I915_GEM_EXECBUFFER2', 0x29),
+    ('DRM_I915_GET_SPRITE_COLORKEY', 0x2a),
+    ('DRM_I915_SET_SPRITE_COLORKEY', 0x2b),
+    ('DRM_I915_GEM_WAIT', 0x2c),
+    ('DRM_I915_GEM_CONTEXT_CREATE', 0x2d),
+    ('DRM_I915_GEM_CONTEXT_DESTROY', 0x2e),
+    ('DRM_I915_GEM_SET_CACHEING', 0x2f),
+    ('DRM_I915_GEM_GET_CACHEING', 0x30),
+    ('DRM_I915_REG_READ', 0x31),
+)
+
+ioctl_hash = {}
+for ioctl in drm_ioctls:
+    ioctl_hash["0x%02x" % ioctl[1]] = ioctl[0]
+for ioctl in intel_ioctls:
+    ioctl_hash["0x%02x" % (DRM_COMMAND_BASE + ioctl[1])] = ioctl[0]
+
+def find_ioctl(nr):
+    if nr in ioctl_hash:
+        return ioctl_hash[nr]
+    else:
+        return "Unknown ioctl 0x%02x" % str(nr)
+
+ioctl_pattern = re.compile(r"""
+    \[(?P<timesamp>[ \d\.]+)\]\ ?
+    \[drm:drm_ioctl\],
+    \ pid=(?P<pid>[\d]+),
+    \ cmd=(?P<cmd>[\dxa-fA-F]+),
+    \ nr=(?P<nr>[\dxa-fA-F]+),
+    \ dev\ (?P<dev>[\dxa-fA-F]+),
+    \ auth=(?P<auth>[\d]+)
+""", re.X)
+
+for line in fileinput.input():
+    m = ioctl_pattern.match(line)
+    if m:
+        ts = m.group('timesamp')
+        nr = m.group('nr')
+	pid = m.group('pid')
+	dev = m.group('dev')
+	if ts:
+            print("[%s] [drm:drm_ioctl], [pid=%s], [dev=%s], %s" %
+              (ts, pid, dev, find_ioctl(nr)))
+        else:
+            print("[drm:drm_ioctl], [pid=%s], [dev=%s], %s" %
+              (pid, dev, find_ioctl(nr)))
+    else:
+        sys.stdout.write(line)
-- 
1.7.11.7




More information about the Intel-gfx mailing list