<div dir="ltr"><div>Very sketchily</div><div><br></div><div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Jul 18, 2018 at 10:21 AM Lionel Landwerlin <<a href="mailto:lionel.g.landwerlin@intel.com">lionel.g.landwerlin@intel.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">In commit 86cb05a6d35a52 ("intel: aubinator: remove standard input<br>
processing option") we removed the ability to process aub as an input<br>
stream because we're now rely on mmapping the aub file to back the<br>
buffers aubinator is parsing.<br>
<br>
intel_aubdump was the provider of the standard input data and since<br>
we've copied/reworked intel_aubdump into intel_dump_gpu within Mesa,<br>
we don't need that code anymore.<br>
<br>
Signed-off-by: Lionel Landwerlin <<a href="mailto:lionel.g.landwerlin@intel.com" target="_blank">lionel.g.landwerlin@intel.com</a>><br>
---<br>
 src/intel/tools/intel_dump_gpu.c  | 121 +++++++-----------------------<br>
 src/intel/tools/<a href="http://intel_dump_gpu.in" rel="noreferrer" target="_blank">intel_dump_gpu.in</a> |  27 +------<br>
 2 files changed, 29 insertions(+), 119 deletions(-)<br>
<br>
diff --git a/src/intel/tools/intel_dump_gpu.c b/src/intel/tools/intel_dump_gpu.c<br>
index 6d2c4b7f983..5fd2c8ea723 100644<br>
--- a/src/intel/tools/intel_dump_gpu.c<br>
+++ b/src/intel/tools/intel_dump_gpu.c<br>
@@ -53,8 +53,8 @@ static int (*libc_close)(int fd) = close_init_helper;<br>
 static int (*libc_ioctl)(int fd, unsigned long request, ...) = ioctl_init_helper;<br>
<br>
 static int drm_fd = -1;<br>
-static char *filename = NULL;<br>
-static FILE *files[2] = { NULL, NULL };<br>
+static char *output_filename = NULL;<br>
+static FILE *output_file = NULL;<br>
 static int verbose = 0;<br>
 static bool device_override;<br>
<br>
@@ -111,7 +111,7 @@ align_u32(uint32_t v, uint32_t a)<br>
<br>
 static struct gen_device_info devinfo = {0};<br>
 static uint32_t device;<br>
-static struct aub_file aubs[2];<br>
+static struct aub_file aub_file;<br>
<br>
 static void *<br>
 relocate_bo(struct bo *bo, const struct drm_i915_gem_execbuffer2 *execbuffer2,<br>
@@ -205,28 +205,21 @@ dump_execbuffer2(int fd, struct drm_i915_gem_execbuffer2 *execbuffer2)<br>
       fail_if(!gen_get_device_info(device, &devinfo),<br>
               "failed to identify chipset=0x%x\n", device);<br>
<br>
-      for (int i = 0; i < ARRAY_SIZE(files); i++) {<br>
-         if (files[i] != NULL) {<br>
-            aub_file_init(&aubs[i], files[i], device);<br>
-            if (verbose == 2)<br>
-               aubs[i].verbose_log_file = stdout;<br>
-            aub_write_header(&aubs[i], program_invocation_short_name);<br>
-         }<br>
-      }<br>
+      aub_file_init(&aub_file, output_file, device);<br>
+      if (verbose == 2)<br>
+         aub_file.verbose_log_file = stdout;<br>
+      aub_write_header(&aub_file, program_invocation_short_name);<br>
<br>
       if (verbose)<br>
          printf("[intel_aubdump: running, "<br>
                 "output file %s, chipset id 0x%04x, gen %d]\n",<br>
-                filename, device, devinfo.gen);<br>
+                output_filename, device, devinfo.gen);<br>
    }<br>
<br>
-   /* Any aub */<br>
-   struct aub_file *any_aub = files[0] ? &aubs[0] : &aubs[1];;<br>
-<br>
-   if (aub_use_execlists(any_aub))<br>
+   if (aub_use_execlists(&aub_file))<br>
       offset = 0x1000;<br>
    else<br>
-      offset = aub_gtt_size(any_aub);<br>
+      offset = aub_gtt_size(&aub_file);<br>
<br>
    if (verbose)<br>
       printf("Dumping execbuffer2:\n");<br>
@@ -263,13 +256,8 @@ dump_execbuffer2(int fd, struct drm_i915_gem_execbuffer2 *execbuffer2)<br>
          bo->map = gem_mmap(fd, obj->handle, 0, bo->size);<br>
       fail_if(bo->map == MAP_FAILED, "intel_aubdump: bo mmap failed\n");<br>
<br>
-      for (int i = 0; i < ARRAY_SIZE(files); i++) {<br>
-         if (files[i] == NULL)<br>
-            continue;<br>
-<br>
-         if (aub_use_execlists(&aubs[i]))<br>
-            aub_map_ppgtt(&aubs[i], bo->offset, bo->size);<br>
-      }<br>
+      if (aub_use_execlists(&aub_file))<br>
+         aub_map_ppgtt(&aub_file, bo->offset, bo->size);<br>
    }<br>
<br>
    batch_index = (execbuffer2->flags & I915_EXEC_BATCH_FIRST) ? 0 :<br>
@@ -284,30 +272,21 @@ dump_execbuffer2(int fd, struct drm_i915_gem_execbuffer2 *execbuffer2)<br>
       else<br>
          data = bo->map;<br>
<br>
-      for (int i = 0; i < ARRAY_SIZE(files); i++) {<br>
-         if (files[i] == NULL)<br>
-            continue;<br>
-<br>
-         if (bo == batch_bo) {<br>
-            aub_write_trace_block(&aubs[i], AUB_TRACE_TYPE_BATCH,<br>
-                                  GET_PTR(data), bo->size, bo->offset);<br>
-         } else {<br>
-            aub_write_trace_block(&aubs[i], AUB_TRACE_TYPE_NOTYPE,<br>
-                                  GET_PTR(data), bo->size, bo->offset);<br>
-         }<br>
+      if (bo == batch_bo) {<br>
+         aub_write_trace_block(&aub_file, AUB_TRACE_TYPE_BATCH,<br>
+                               GET_PTR(data), bo->size, bo->offset);<br>
+      } else {<br>
+         aub_write_trace_block(&aub_file, AUB_TRACE_TYPE_NOTYPE,<br>
+                               GET_PTR(data), bo->size, bo->offset);<br>
       }<br>
+<br>
       if (data != bo->map)<br>
          free(data);<br>
    }<br>
<br>
-   for (int i = 0; i < ARRAY_SIZE(files); i++) {<br>
-      if (files[i] != NULL)<br>
-         continue;<br>
-<br>
-      aub_write_exec(&aubs[i],<br>
-                     batch_bo->offset + execbuffer2->batch_start_offset,<br>
-                     offset, ring_flag);<br>
-   }<br>
+   aub_write_exec(&aub_file,<br>
+                  batch_bo->offset + execbuffer2->batch_start_offset,<br>
+                  offset, ring_flag);<br>
<br>
    if (device_override &&<br>
        (execbuffer2->flags & I915_EXEC_FENCE_ARRAY) != 0) {<br>
@@ -358,40 +337,6 @@ close(int fd)<br>
    return libc_close(fd);<br>
 }<br>
<br>
-static FILE *<br>
-launch_command(char *command)<br>
-{<br>
-   int i = 0, fds[2];<br>
-   char **args = calloc(strlen(command), sizeof(char *));<br>
-   char *iter = command;<br>
-<br>
-   args[i++] = iter = command;<br>
-<br>
-   while ((iter = strstr(iter, ",")) != NULL) {<br>
-      *iter = '\0';<br>
-      iter += 1;<br>
-      args[i++] = iter;<br>
-   }<br>
-<br>
-   if (pipe(fds) == -1)<br>
-      return NULL;<br>
-<br>
-   switch (fork()) {<br>
-   case 0:<br>
-      dup2(fds[0], 0);<br>
-      fail_if(execvp(args[0], args) == -1,<br>
-              "intel_aubdump: failed to launch child command\n");<br>
-      return NULL;<br>
-<br>
-   default:<br>
-      free(args);<br>
-      return fdopen(fds[1], "w");<br>
-<br>
-   case -1:<br>
-      return NULL;<br>
-   }<br>
-}<br>
-<br>
 static void<br>
 maybe_init(void)<br>
 {<br>
@@ -418,16 +363,11 @@ maybe_init(void)<br>
                  value);<br>
          device_override = true;<br>
       } else if (!strcmp(key, "file")) {<br>
-         filename = strdup(value);<br>
-         files[0] = fopen(filename, "w+");<br>
-         fail_if(files[0] == NULL,<br>
+         output_filename = strdup(value);<br>
+         output_file = fopen(output_filename, "w+");<br>
+         fail_if(output_file == NULL,<br>
                  "intel_aubdump: failed to open file '%s'\n",<br>
-                 filename);<br>
-      } else if (!strcmp(key,  "command")) {<br>
-         files[1] = launch_command(value);<br>
-         fail_if(files[1] == NULL,<br>
-                 "intel_aubdump: failed to launch command '%s'\n",<br>
-                 value);<br>
+                 output_filename);<br>
       } else {<br>
          fprintf(stderr, "intel_aubdump: unknown option '%s'\n", key);<br>
       }<br>
@@ -598,12 +538,7 @@ ioctl_init_helper(int fd, unsigned long request, ...)<br>
 static void __attribute__ ((destructor))<br>
 fini(void)<br>
 {<br>
-   free(filename);<br>
-   for (int i = 0; i < ARRAY_SIZE(files); i++) {<br>
-      if (aubs[i].file)<br>
-         aub_file_finish(&aubs[i]);<br>
-      else if (files[i])<br>
-         fclose(files[i]);<br>
-   }<br>
+   free(output_filename);<br>
+   aub_file_finish(&aub_file);<br>
    free(bos);<br>
 }<br>
diff --git a/src/intel/tools/<a href="http://intel_dump_gpu.in" rel="noreferrer" target="_blank">intel_dump_gpu.in</a> b/src/intel/tools/<a href="http://intel_dump_gpu.in" rel="noreferrer" target="_blank">intel_dump_gpu.in</a><br>
index b9887f0ed2e..9eea37189db 100755<br>
--- a/src/intel/tools/<a href="http://intel_dump_gpu.in" rel="noreferrer" target="_blank">intel_dump_gpu.in</a><br>
+++ b/src/intel/tools/<a href="http://intel_dump_gpu.in" rel="noreferrer" target="_blank">intel_dump_gpu.in</a><br>
@@ -10,9 +10,6 @@ contents and execution of the GEM application.<br>
<br>
   -o, --output=FILE  Name of AUB file. Defaults to COMMAND.aub<br>
<br>
-  -c, --command=CMD  Execute CMD and write the AUB file's content to its<br>
-                     standard input<br>
-<br>
       --device=ID    Override PCI ID of the reported device<br>
<br>
   -v                 Enable verbose output<br>
@@ -27,7 +24,6 @@ EOF<br>
 }<br>
<br>
 args=""<br>
-command=""<br>
 file=""<br>
<br>
 function add_arg() {<br>
@@ -35,17 +31,6 @@ function add_arg() {<br>
     args="$args$arg\n"<br>
 }<br>
<br>
-function build_command () {<br>
-    command=""<br>
-    for i in $1; do<br>
-        if [ -z $command ]; then<br>
-            command=$i<br>
-        else<br>
-            command="$command,$i"<br>
-        fi;<br>
-    done<br>
-}<br>
-<br>
 while true; do<br>
     case "$1" in<br>
         -o)<br>
@@ -71,16 +56,6 @@ while true; do<br>
             add_arg "file=${file:-$(basename ${file}).aub}"<br>
             shift<br>
             ;;<br>
-        -c)<br>
-            build_command "$2"<br>
-            add_arg "command=$command"<br>
-            shift 2<br>
-            ;;<br>
-        --command=*)<br>
-            build_command "${1##--command=}"<br>
-            add_arg "command=$command"<br>
-            shift<br>
-            ;;<br>
         --device=*)<br>
             add_arg "device=${1##--device=}"<br>
             shift<br>
@@ -105,7 +80,7 @@ done<br>
<br>
 [ -z $1 ] && show_help<br>
<br>
-[ -z $file ] && [ -z $command ] && add_arg "file=intel.aub"<br>
+[ -z $file ] && add_arg "file=intel.aub"<br>
<br>
 LD_PRELOAD="@install_libexecdir@/libintel_dump_gpu.so${LD_PPRELOAD:+:$LD_PRELOAD}" \<br>
           exec -- "$@" 3<<EOF<br>
-- <br>
2.18.0<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div>