intel/dev: Use intel_i915_query_alloc in query_topology
authorJason Ekstrand <jason@jlekstrand.net>
Wed, 7 Jul 2021 19:41:20 +0000 (14:41 -0500)
committerMarge Bot <eric+marge@anholt.net>
Fri, 16 Jul 2021 14:19:20 +0000 (14:19 +0000)
Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11770>

src/intel/dev/intel_device_info.c

index 156519d..6962c93 100644 (file)
@@ -1360,26 +1360,9 @@ getparam_topology(struct intel_device_info *devinfo, int fd)
 static bool
 query_topology(struct intel_device_info *devinfo, int fd)
 {
-   struct drm_i915_query_item item = {
-      .query_id = DRM_I915_QUERY_TOPOLOGY_INFO,
-   };
-   struct drm_i915_query query = {
-      .num_items = 1,
-      .items_ptr = (uintptr_t) &item,
-   };
-
-   if (intel_ioctl(fd, DRM_IOCTL_I915_QUERY, &query))
-      return false;
-
-   if (item.length < 0)
-      return false;
-
    struct drm_i915_query_topology_info *topo_info =
-      (struct drm_i915_query_topology_info *) calloc(1, item.length);
-   item.data_ptr = (uintptr_t) topo_info;
-
-   if (intel_ioctl(fd, DRM_IOCTL_I915_QUERY, &query) ||
-       item.length <= 0)
+      intel_i915_query_alloc(fd, DRM_I915_QUERY_TOPOLOGY_INFO);
+   if (topo_info == NULL)
       return false;
 
    update_from_topology(devinfo, topo_info);