[Mesa-dev] [PATCH] intel: tools: dump: remove command execution feature

Lionel Landwerlin lionel.g.landwerlin at intel.com
Wed Jul 18 14:19:51 UTC 2018


In commit 86cb05a6d35a52 ("intel: aubinator: remove standard input
processing option") we removed the ability to process aub as an input
stream because we're now rely on mmapping the aub file to back the
buffer aubinator is parsing.

intel_aubdump was the provider of the standard input data and since
we've copied/reworked intel_aubdump into intel_dump_gpu within Mesa,
we don't that code anymore.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
---
 src/intel/tools/intel_dump_gpu.c  | 73 ++++---------------------------
 src/intel/tools/intel_dump_gpu.in | 27 +-----------
 2 files changed, 10 insertions(+), 90 deletions(-)

diff --git a/src/intel/tools/intel_dump_gpu.c b/src/intel/tools/intel_dump_gpu.c
index 766ba662d91..6758cab13c4 100644
--- a/src/intel/tools/intel_dump_gpu.c
+++ b/src/intel/tools/intel_dump_gpu.c
@@ -254,7 +254,7 @@ static int (*libc_ioctl)(int fd, unsigned long request, ...) = ioctl_init_helper
 
 static int drm_fd = -1;
 static char *filename = NULL;
-static FILE *files[2] = { NULL, NULL };
+static FILE *aub_file = NULL;
 static struct gen_device_info devinfo = {0};
 static int verbose = 0;
 static bool device_override;
@@ -320,13 +320,8 @@ align_u32(uint32_t v, uint32_t a)
 static void
 dword_out(uint32_t data)
 {
-   for (int i = 0; i < ARRAY_SIZE (files); i++) {
-      if (files[i] == NULL)
-         continue;
-
-      fail_if(fwrite(&data, 1, 4, files[i]) == 0,
-              "Writing to output failed\n");
-   }
+   fail_if(fwrite(&data, 1, 4, aub_file) == 0,
+           "Writing to output failed\n");
 }
 
 static void
@@ -335,13 +330,8 @@ data_out(const void *data, size_t size)
    if (size == 0)
       return;
 
-   for (int i = 0; i < ARRAY_SIZE (files); i++) {
-      if (files[i] == NULL)
-         continue;
-
-      fail_if(fwrite(data, 1, size, files[i]) == 0,
-              "Writing to output failed\n");
-   }
+   fail_if(fwrite(data, 1, size, aub_file) == 0,
+           "Writing to output failed\n");
 }
 
 static uint32_t
@@ -990,10 +980,7 @@ dump_execbuffer2(int fd, struct drm_i915_gem_execbuffer2 *execbuffer2)
                           ring_flag);
    }
 
-   for (int i = 0; i < ARRAY_SIZE(files); i++) {
-      if (files[i] != NULL)
-         fflush(files[i]);
-   }
+   fflush(aub_file);
 
    if (device_override &&
        (execbuffer2->flags & I915_EXEC_FENCE_ARRAY) != 0) {
@@ -1044,40 +1031,6 @@ close(int fd)
    return libc_close(fd);
 }
 
-static FILE *
-launch_command(char *command)
-{
-   int i = 0, fds[2];
-   char **args = calloc(strlen(command), sizeof(char *));
-   char *iter = command;
-
-   args[i++] = iter = command;
-
-   while ((iter = strstr(iter, ",")) != NULL) {
-      *iter = '\0';
-      iter += 1;
-      args[i++] = iter;
-   }
-
-   if (pipe(fds) == -1)
-      return NULL;
-
-   switch (fork()) {
-   case 0:
-      dup2(fds[0], 0);
-      fail_if(execvp(args[0], args) == -1,
-              "intel_aubdump: failed to launch child command\n");
-      return NULL;
-
-   default:
-      free(args);
-      return fdopen(fds[1], "w");
-
-   case -1:
-      return NULL;
-   }
-}
-
 static void
 maybe_init(void)
 {
@@ -1105,15 +1058,10 @@ maybe_init(void)
          device_override = true;
       } else if (!strcmp(key, "file")) {
          filename = strdup(value);
-         files[0] = fopen(filename, "w+");
-         fail_if(files[0] == NULL,
+         aub_file = fopen(filename, "w+");
+         fail_if(aub_file == NULL,
                  "intel_aubdump: failed to open file '%s'\n",
                  filename);
-      } else if (!strcmp(key,  "command")) {
-         files[1] = launch_command(value);
-         fail_if(files[1] == NULL,
-                 "intel_aubdump: failed to launch command '%s'\n",
-                 value);
       } else {
          fprintf(stderr, "intel_aubdump: unknown option '%s'\n", key);
       }
@@ -1285,9 +1233,6 @@ static void __attribute__ ((destructor))
 fini(void)
 {
    free(filename);
-   for (int i = 0; i < ARRAY_SIZE(files); i++) {
-      if (files[i] != NULL)
-         fclose(files[i]);
-   }
+   fclose(aub_file);
    free(bos);
 }
diff --git a/src/intel/tools/intel_dump_gpu.in b/src/intel/tools/intel_dump_gpu.in
index b9887f0ed2e..9eea37189db 100755
--- a/src/intel/tools/intel_dump_gpu.in
+++ b/src/intel/tools/intel_dump_gpu.in
@@ -10,9 +10,6 @@ contents and execution of the GEM application.
 
   -o, --output=FILE  Name of AUB file. Defaults to COMMAND.aub
 
-  -c, --command=CMD  Execute CMD and write the AUB file's content to its
-                     standard input
-
       --device=ID    Override PCI ID of the reported device
 
   -v                 Enable verbose output
@@ -27,7 +24,6 @@ EOF
 }
 
 args=""
-command=""
 file=""
 
 function add_arg() {
@@ -35,17 +31,6 @@ function add_arg() {
     args="$args$arg\n"
 }
 
-function build_command () {
-    command=""
-    for i in $1; do
-        if [ -z $command ]; then
-            command=$i
-        else
-            command="$command,$i"
-        fi;
-    done
-}
-
 while true; do
     case "$1" in
         -o)
@@ -71,16 +56,6 @@ while true; do
             add_arg "file=${file:-$(basename ${file}).aub}"
             shift
             ;;
-        -c)
-            build_command "$2"
-            add_arg "command=$command"
-            shift 2
-            ;;
-        --command=*)
-            build_command "${1##--command=}"
-            add_arg "command=$command"
-            shift
-            ;;
         --device=*)
             add_arg "device=${1##--device=}"
             shift
@@ -105,7 +80,7 @@ done
 
 [ -z $1 ] && show_help
 
-[ -z $file ] && [ -z $command ] && add_arg "file=intel.aub"
+[ -z $file ] && add_arg "file=intel.aub"
 
 LD_PRELOAD="@install_libexecdir@/libintel_dump_gpu.so${LD_PPRELOAD:+:$LD_PRELOAD}" \
           exec -- "$@" 3<<EOF
-- 
2.18.0



More information about the mesa-dev mailing list