summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>2015-08-04 15:00:50 -0700
committerKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>2015-08-04 15:00:50 -0700
commit220c7d1f91e590be74866710d786833938c18c40 (patch)
tree1926a8fb14f89ac4f4b3b930e848e889e0684913
parentf47bdba8b0504661b5d291a8639f156cda993379 (diff)
tools/aubdump: Add --device option for overriding device ID
This lets us capture AUB traces for platforms different from the one we're running on. Signed-off-by: Kristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
-rw-r--r--man/intel_aubdump.man7
-rw-r--r--tools/aubdump.c31
-rw-r--r--tools/intel_aubdump.in9
3 files changed, 40 insertions, 7 deletions
diff --git a/man/intel_aubdump.man b/man/intel_aubdump.man
index ea1c852e..a77947e7 100644
--- a/man/intel_aubdump.man
+++ b/man/intel_aubdump.man
@@ -25,7 +25,12 @@ Write the trace output to the file
.IR FILE .
Default is
.IR COMMAND .aub.
-
+.TP
+.BI \-\^\-device= ID
+Override the PCI ID of the drm device. This is useful for getting an
+aub dump for a different generation of GPU. In this mode intel_aubdump
+will intercept but not forward the execbuffer2 ioctl, as that would
+typically cause a GPU hang.
.SH EXAMPLES
.TP
intel_aubdump -v --output=stuff.aub -- glxgears -geometry 500x500
diff --git a/tools/aubdump.c b/tools/aubdump.c
index d84e2b5e..d835045d 100644
--- a/tools/aubdump.c
+++ b/tools/aubdump.c
@@ -52,6 +52,8 @@ static FILE *file;
static int gen = 0;
static int verbose = 0;
static const uint32_t gtt_size = 0x10000;
+static bool device_override;
+static uint32_t device;
#define MAX_BO_COUNT 64 * 1024
@@ -315,15 +317,17 @@ dump_execbuffer2(int fd, struct drm_i915_gem_execbuffer2 *execbuffer2)
void *data;
/* We can't do this at open time as we're not yet authenticated. */
+ if (device == 0) {
+ device = gem_get_param(fd, I915_PARAM_CHIPSET_ID);
+ fail_if(device == 0 || gen == -1, "failed to identify chipset\n");
+ }
if (gen == 0) {
- uint32_t chipset_id = gem_get_param(fd, I915_PARAM_CHIPSET_ID);
- gen = intel_gen(chipset_id);
+ gen = intel_gen(device);
- fail_if(chipset_id == 0 || gen == -1, "failed to identify chipset\n");
if (verbose)
printf("[intel_aubdump active: "
"output file %s, chipset id 0x%04x, gen %d]\n",
- filename, chipset_id, gen);
+ filename, device, gen);
}
for (uint32_t i = 0; i < execbuffer2->buffer_count; i++) {
@@ -430,6 +434,16 @@ ioctl(int fd, unsigned long request, ...)
if (fd == drm_fd) {
switch (request) {
+ case DRM_IOCTL_I915_GETPARAM: {
+ struct drm_i915_getparam *getparam = argp;
+
+ if (device_override && getparam->param == I915_PARAM_CHIPSET_ID) {
+ *getparam->value = device;
+ return 0;
+ }
+ return libc_ioctl(fd, request, argp);
+ }
+
case DRM_IOCTL_I915_GEM_EXECBUFFER: {
static bool once;
if (!once) {
@@ -442,6 +456,9 @@ ioctl(int fd, unsigned long request, ...)
case DRM_IOCTL_I915_GEM_EXECBUFFER2: {
dump_execbuffer2(fd, argp);
+ if (device_override)
+ return 0;
+
return libc_ioctl(fd, request, argp);
}
@@ -517,10 +534,14 @@ init(void)
fail_if(libc_open == NULL || libc_close == NULL || libc_ioctl == NULL,
"intel_aubdump: failed to get libc open or ioctl\n");
- if (sscanf(args, "verbose=%d;file=%m[^;]", &verbose, &filename) != 2)
+ if (sscanf(args, "verbose=%d;file=%m[^;];device=%i",
+ &verbose, &filename, &device) != 3)
filename = strdup("intel.aub");
fail_if(filename == NULL, "intel_aubdump: out of memory\n");
+ if (device)
+ device_override = true;
+
bos = malloc(MAX_BO_COUNT * sizeof(bos[0]));
fail_if(bos == NULL, "intel_aubdump: out of memory\n");
diff --git a/tools/intel_aubdump.in b/tools/intel_aubdump.in
index 7b5a0a1c..feee23a4 100644
--- a/tools/intel_aubdump.in
+++ b/tools/intel_aubdump.in
@@ -10,6 +10,8 @@ contents and execution of the GEM application.
-o, --output=FILE Name of AUB file. Defaults to COMMAND.aub
+ --device=ID Override PCI ID of the reported device
+
-v Enable verbose output
--help Display this help message and exit
@@ -20,6 +22,7 @@ EOF
}
verbose=0
+device=0
while true; do
case "$1" in
@@ -39,6 +42,10 @@ while true; do
file=${1##--output=}
shift
;;
+ --device=*)
+ device=${1##--device=}
+ shift
+ ;;
--help)
show_help
;;
@@ -66,5 +73,5 @@ exec_prefix=@exec_prefix@
libdir=@libdir@
LD_PRELOAD=${libdir}/intel_aubdump.so${LD_PPRELOAD:+:${LD_PRELOAD}} \
- INTEL_AUBDUMP_ARGS="verbose=$verbose;file=$file" \
+ INTEL_AUBDUMP_ARGS="verbose=$verbose;file=$file;device=$device" \
exec -- "$@"