intel/tools: Add basic aub_context code and helpers.

v2:
 - Only dump context if there were no erros (Lionel).
 - Store counter for context handles in aub_file (Lionel).
v3:
 - Add a comment about aub_context -> GEM context (Lionel).

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
This commit is contained in:
Rafael Antognolli
2019-09-13 15:13:31 -07:00
parent 472de61187
commit 12feafc28e
3 changed files with 115 additions and 0 deletions
+32
View File
@@ -336,6 +336,23 @@ remove_bo(int fd, int handle)
bo->map = NULL;
}
static uint32_t
dump_create_context(int fd, uint32_t *ctx_id)
{
if (!aub_file.file) {
aub_file_init(&aub_file, output_file,
verbose == 2 ? stdout : NULL,
device, program_invocation_short_name);
aub_write_default_setup(&aub_file);
if (verbose)
printf("[running, output file %s, chipset id 0x%04x, gen %d]\n",
output_filename, device, devinfo.gen);
}
return aub_write_context_create(&aub_file, ctx_id);
}
__attribute__ ((visibility ("default"))) int
close(int fd)
{
@@ -458,6 +475,21 @@ ioctl(int fd, unsigned long request, ...)
return libc_ioctl(fd, request, argp);
}
case DRM_IOCTL_I915_GEM_CONTEXT_CREATE: {
uint32_t *ctx_id = NULL;
struct drm_i915_gem_context_create *create = argp;
ret = 0;
if (!device_override) {
ret = libc_ioctl(fd, request, argp);
ctx_id = &create->ctx_id;
}
if (ret == 0)
create->ctx_id = dump_create_context(fd, ctx_id);
return ret;
}
case DRM_IOCTL_I915_GEM_CREATE: {
struct drm_i915_gem_create *create = argp;