From: Jason Ekstrand Date: Thu, 19 Mar 2020 21:44:56 +0000 (-0500) Subject: intel/dump_gpu: Add an ensure_device_info helper X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7fd4184378268f50ff737851a88c0e836367199d;p=mesa.git intel/dump_gpu: Add an ensure_device_info helper Reviewed-by: Lionel Landwerlin Part-of: --- diff --git a/src/intel/tools/intel_dump_gpu.c b/src/intel/tools/intel_dump_gpu.c index 551477db23b..fabbf4f73d8 100644 --- a/src/intel/tools/intel_dump_gpu.c +++ b/src/intel/tools/intel_dump_gpu.c @@ -116,6 +116,20 @@ static struct gen_device_info devinfo = {0}; static int device = 0; static struct aub_file aub_file; +static void +ensure_device_info(int fd) +{ + /* We can't do this at open time as we're not yet authenticated. */ + if (device == 0) { + fail_if(!gen_get_device_info_from_fd(fd, &devinfo), + "failed to identify chipset.\n"); + device = devinfo.chipset_id; + } else if (devinfo.gen == 0) { + fail_if(!gen_get_device_info_from_pci_id(device, &devinfo), + "failed to identify chipset.\n"); + } +} + static void * relocate_bo(int fd, struct bo *bo, const struct drm_i915_gem_execbuffer2 *execbuffer2, const struct drm_i915_gem_exec_object2 *obj) @@ -202,15 +216,7 @@ dump_execbuffer2(int fd, struct drm_i915_gem_execbuffer2 *execbuffer2) int batch_index; void *data; - /* We can't do this at open time as we're not yet authenticated. */ - if (device == 0) { - fail_if(!gen_get_device_info_from_fd(fd, &devinfo), - "failed to identify chipset.\n"); - device = devinfo.chipset_id; - } else if (devinfo.gen == 0) { - fail_if(!gen_get_device_info_from_pci_id(device, &devinfo), - "failed to identify chipset.\n"); - } + ensure_device_info(fd); if (!aub_file.file) { aub_file_init(&aub_file, output_file, @@ -470,6 +476,8 @@ ioctl(int fd, unsigned long request, ...) case DRM_IOCTL_I915_GETPARAM: { struct drm_i915_getparam *getparam = argp; + ensure_device_info(fd); + if (getparam->param == I915_PARAM_CHIPSET_ID) return get_pci_id(fd, getparam->value);