From 96e1c945f2bc4047a603753ae10fc4f27754361c Mon Sep 17 00:00:00 2001 From: Mark Janes Date: Wed, 24 Jul 2019 13:48:03 -0700 Subject: i965: Move device info initialization to common code With perf queries, initializing the device info is much more complex than just getting a PCI ID and calling gen_get_device_info. This commit adds a new gen_get_device_info_from_fd helper in common code which does all of the requisite kernel queries to get device info including all of the topology information. Reviewed-by: Kenneth Graunke Reviewed-by: Lionel Landwerlin --- src/mesa/drivers/dri/i965/brw_performance_query.c | 84 +---------------------- src/mesa/drivers/dri/i965/intel_screen.c | 36 ++-------- 2 files changed, 6 insertions(+), 114 deletions(-) (limited to 'src/mesa/drivers') diff --git a/src/mesa/drivers/dri/i965/brw_performance_query.c b/src/mesa/drivers/dri/i965/brw_performance_query.c index a04bf65e1ca..bb8c2bf0fea 100644 --- a/src/mesa/drivers/dri/i965/brw_performance_query.c +++ b/src/mesa/drivers/dri/i965/brw_performance_query.c @@ -1682,67 +1682,6 @@ init_pipeline_statistic_query_registers(struct brw_context *brw) query->data_size = sizeof(uint64_t) * query->n_counters; } -static bool -query_topology(struct brw_context *brw) -{ - __DRIscreen *screen = brw->screen->driScrnPriv; - 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 (drmIoctl(screen->fd, DRM_IOCTL_I915_QUERY, &query)) - 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 (drmIoctl(screen->fd, DRM_IOCTL_I915_QUERY, &query) || - item.length <= 0) - return false; - - gen_device_info_update_from_topology(&brw->screen->devinfo, - topo_info); - - free(topo_info); - - return true; -} - -static bool -getparam_topology(struct brw_context *brw) -{ - __DRIscreen *screen = brw->screen->driScrnPriv; - drm_i915_getparam_t gp; - int ret; - - int slice_mask = 0; - gp.param = I915_PARAM_SLICE_MASK; - gp.value = &slice_mask; - ret = drmIoctl(screen->fd, DRM_IOCTL_I915_GETPARAM, &gp); - if (ret) - return false; - - int subslice_mask = 0; - gp.param = I915_PARAM_SUBSLICE_MASK; - gp.value = &subslice_mask; - ret = drmIoctl(screen->fd, DRM_IOCTL_I915_GETPARAM, &gp); - if (ret) - return false; - - if (!gen_device_info_update_from_masks(&brw->screen->devinfo, - slice_mask, - subslice_mask, - brw->screen->eu_total)) - return false; - - return true; -} - /* gen_device_info will have incorrect default topology values for unsupported kernels. * verify kernel support to ensure OA metrics are accurate. */ @@ -1797,28 +1736,9 @@ brw_init_perf_query_info(struct gl_context *ctx) brw->perfquery.perf = gen_perf_new(brw, drmIoctl); init_pipeline_statistic_query_registers(brw); - brw_perf_query_register_mdapi_statistic_query(brw); - - if (!oa_metrics_kernel_support(screen->fd, devinfo)) - return false; - - if (!query_topology(brw)) { - /* We need the i915 query uAPI on CNL+ (kernel 4.17+). */ - if (devinfo->gen >= 10) - return false; - - if (!getparam_topology(brw)) { - /* We need the SLICE_MASK/SUBSLICE_MASK on gen8+ (kernel 4.13+). */ - if (devinfo->gen >= 8) - return false; - - /* On Haswell, the values are already computed for us in - * gen_device_info. - */ - } - } - if (gen_perf_load_oa_metrics(brw->perfquery.perf, screen->fd, devinfo)) + if ((oa_metrics_kernel_support(screen->fd, devinfo)) && + (gen_perf_load_oa_metrics(brw->perfquery.perf, screen->fd, devinfo))) brw_perf_query_register_mdapi_oa_query(brw); brw->perfquery.unaccumulated = diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index 2bc2e41178d..6c4d7c5be27 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -2413,28 +2413,6 @@ set_max_gl_versions(struct intel_screen *screen) } } -/** - * Return the revision (generally the revid field of the PCI header) of the - * graphics device. - */ -static int -intel_device_get_revision(int fd) -{ - struct drm_i915_getparam gp; - int revision; - int ret; - - memset(&gp, 0, sizeof(gp)); - gp.param = I915_PARAM_REVISION; - gp.value = &revision; - - ret = drmCommandWriteRead(fd, DRM_I915_GETPARAM, &gp, sizeof(gp)); - if (ret) - revision = -1; - - return revision; -} - static void shader_debug_log_mesa(void *data, const char *fmt, ...) { @@ -2513,22 +2491,16 @@ __DRIconfig **intelInitScreen2(__DRIscreen *dri_screen) screen->driScrnPriv = dri_screen; dri_screen->driverPrivate = (void *) screen; - screen->deviceID = gen_get_pci_device_id_override(); - if (screen->deviceID < 0) - screen->deviceID = intel_get_integer(screen, I915_PARAM_CHIPSET_ID); - else - screen->no_hw = true; - - if (!gen_get_device_info(screen->deviceID, &screen->devinfo)) + if (!gen_get_device_info_from_fd(dri_screen->fd, &screen->devinfo)) return NULL; - screen->devinfo.revision = intel_device_get_revision(dri_screen->fd); + const struct gen_device_info *devinfo = &screen->devinfo; + screen->deviceID = devinfo->chipset_id; + screen->no_hw = devinfo->no_hw; if (!intel_init_bufmgr(screen)) return NULL; - const struct gen_device_info *devinfo = &screen->devinfo; - brw_process_intel_debug_variable(); if ((INTEL_DEBUG & DEBUG_SHADER_TIME) && devinfo->gen < 7) { -- cgit v1.2.3