From ddb59cd20e180240d1f64df37e606775fc96a2aa Mon Sep 17 00:00:00 2001 From: Mark Janes Date: Mon, 29 Jul 2019 17:38:42 -0700 Subject: [PATCH] intel/device: make internal functions private The device info initializer makes several fuctions internal: - handling of device override - updating topology from kernel information The implementation file is slightly reordered due to the renamed functions being static. Reviewed-by: Kenneth Graunke Reviewed-by: Lionel Landwerlin --- src/intel/dev/gen_device_info.c | 142 +++++++++++++++++++--------------------- src/intel/dev/gen_device_info.h | 10 --- 2 files changed, 68 insertions(+), 84 deletions(-) diff --git a/src/intel/dev/gen_device_info.c b/src/intel/dev/gen_device_info.c index 462a906..cbe5500 100644 --- a/src/intel/dev/gen_device_info.c +++ b/src/intel/dev/gen_device_info.c @@ -82,8 +82,8 @@ gen_device_name_to_pci_device_id(const char *name) * * Returns -1 if the override is not set. */ -int -gen_get_pci_device_id_override(void) +static int +get_pci_device_id_override(void) { if (geteuid() == getuid()) { const char *devid_override = getenv("INTEL_DEVID_OVERRIDE"); @@ -1059,68 +1059,6 @@ fill_masks(struct gen_device_info *devinfo) } } -bool -gen_device_info_update_from_masks(struct gen_device_info *devinfo, - uint32_t slice_mask, - uint32_t subslice_mask, - uint32_t n_eus) -{ - struct drm_i915_query_topology_info *topology; - - assert((slice_mask & 0xff) == slice_mask); - - size_t data_length = 100; - - topology = calloc(1, sizeof(*topology) + data_length); - if (!topology) - return false; - - topology->max_slices = util_last_bit(slice_mask); - topology->max_subslices = util_last_bit(subslice_mask); - - topology->subslice_offset = DIV_ROUND_UP(topology->max_slices, 8); - topology->subslice_stride = DIV_ROUND_UP(topology->max_subslices, 8); - - uint32_t n_subslices = __builtin_popcount(slice_mask) * - __builtin_popcount(subslice_mask); - uint32_t num_eu_per_subslice = DIV_ROUND_UP(n_eus, n_subslices); - uint32_t eu_mask = (1U << num_eu_per_subslice) - 1; - - topology->eu_offset = topology->subslice_offset + - DIV_ROUND_UP(topology->max_subslices, 8); - topology->eu_stride = DIV_ROUND_UP(num_eu_per_subslice, 8); - - /* Set slice mask in topology */ - for (int b = 0; b < topology->subslice_offset; b++) - topology->data[b] = (slice_mask >> (b * 8)) & 0xff; - - for (int s = 0; s < topology->max_slices; s++) { - - /* Set subslice mask in topology */ - for (int b = 0; b < topology->subslice_stride; b++) { - int subslice_offset = topology->subslice_offset + - s * topology->subslice_stride + b; - - topology->data[subslice_offset] = (subslice_mask >> (b * 8)) & 0xff; - } - - /* Set eu mask in topology */ - for (int ss = 0; ss < topology->max_subslices; ss++) { - for (int b = 0; b < topology->eu_stride; b++) { - int eu_offset = topology->eu_offset + - (s * topology->max_subslices + ss) * topology->eu_stride + b; - - topology->data[eu_offset] = (eu_mask >> (b * 8)) & 0xff; - } - } - } - - gen_device_info_update_from_topology(devinfo, topology); - free(topology); - - return true; -} - static void reset_masks(struct gen_device_info *devinfo) { @@ -1137,9 +1075,9 @@ reset_masks(struct gen_device_info *devinfo) memset(devinfo->eu_masks, 0, sizeof(devinfo->eu_masks)); } -void -gen_device_info_update_from_topology(struct gen_device_info *devinfo, - const struct drm_i915_query_topology_info *topology) +static void +update_from_topology(struct gen_device_info *devinfo, + const struct drm_i915_query_topology_info *topology) { reset_masks(devinfo); @@ -1184,6 +1122,66 @@ gen_device_info_update_from_topology(struct gen_device_info *devinfo, } static bool +update_from_masks(struct gen_device_info *devinfo, uint32_t slice_mask, + uint32_t subslice_mask, uint32_t n_eus) +{ + struct drm_i915_query_topology_info *topology; + + assert((slice_mask & 0xff) == slice_mask); + + size_t data_length = 100; + + topology = calloc(1, sizeof(*topology) + data_length); + if (!topology) + return false; + + topology->max_slices = util_last_bit(slice_mask); + topology->max_subslices = util_last_bit(subslice_mask); + + topology->subslice_offset = DIV_ROUND_UP(topology->max_slices, 8); + topology->subslice_stride = DIV_ROUND_UP(topology->max_subslices, 8); + + uint32_t n_subslices = __builtin_popcount(slice_mask) * + __builtin_popcount(subslice_mask); + uint32_t num_eu_per_subslice = DIV_ROUND_UP(n_eus, n_subslices); + uint32_t eu_mask = (1U << num_eu_per_subslice) - 1; + + topology->eu_offset = topology->subslice_offset + + DIV_ROUND_UP(topology->max_subslices, 8); + topology->eu_stride = DIV_ROUND_UP(num_eu_per_subslice, 8); + + /* Set slice mask in topology */ + for (int b = 0; b < topology->subslice_offset; b++) + topology->data[b] = (slice_mask >> (b * 8)) & 0xff; + + for (int s = 0; s < topology->max_slices; s++) { + + /* Set subslice mask in topology */ + for (int b = 0; b < topology->subslice_stride; b++) { + int subslice_offset = topology->subslice_offset + + s * topology->subslice_stride + b; + + topology->data[subslice_offset] = (subslice_mask >> (b * 8)) & 0xff; + } + + /* Set eu mask in topology */ + for (int ss = 0; ss < topology->max_subslices; ss++) { + for (int b = 0; b < topology->eu_stride; b++) { + int eu_offset = topology->eu_offset + + (s * topology->max_subslices + ss) * topology->eu_stride + b; + + topology->data[eu_offset] = (eu_mask >> (b * 8)) & 0xff; + } + } + } + + update_from_topology(devinfo, topology); + free(topology); + + return true; +} + +static bool getparam(int fd, uint32_t param, int *value) { int tmp; @@ -1284,10 +1282,7 @@ getparam_topology(struct gen_device_info *devinfo, int fd) if (!getparam(fd, I915_PARAM_SUBSLICE_MASK, &subslice_mask)) return false; - return gen_device_info_update_from_masks(devinfo, - slice_mask, - subslice_mask, - n_eus); + return update_from_masks(devinfo, slice_mask, subslice_mask, n_eus); } /** @@ -1315,8 +1310,7 @@ query_topology(struct gen_device_info *devinfo, int fd) item.length <= 0) return false; - gen_device_info_update_from_topology(devinfo, - topo_info); + update_from_topology(devinfo, topo_info); free(topo_info); @@ -1327,7 +1321,7 @@ query_topology(struct gen_device_info *devinfo, int fd) bool gen_get_device_info_from_fd(int fd, struct gen_device_info *devinfo) { - int devid = gen_get_pci_device_id_override(); + int devid = get_pci_device_id_override(); if (devid > 0) { if (!gen_get_device_info_from_pci_id(devid, devinfo)) return false; diff --git a/src/intel/dev/gen_device_info.h b/src/intel/dev/gen_device_info.h index bf53474..57f1495 100644 --- a/src/intel/dev/gen_device_info.h +++ b/src/intel/dev/gen_device_info.h @@ -271,19 +271,9 @@ gen_device_info_subslice_available(const struct gen_device_info *devinfo, subslice / 8] & (1U << (subslice % 8))) != 0; } -int gen_get_pci_device_id_override(void); int gen_device_name_to_pci_device_id(const char *name); const char *gen_get_device_name(int devid); -/* Used with SLICE_MASK/SUBSLICE_MASK values from DRM_I915_GETPARAM. */ -bool gen_device_info_update_from_masks(struct gen_device_info *devinfo, - uint32_t slice_mask, - uint32_t subslice_mask, - uint32_t n_eus); -/* Used with DRM_IOCTL_I915_QUERY & DRM_I915_QUERY_TOPOLOGY_INFO. */ -void gen_device_info_update_from_topology(struct gen_device_info *devinfo, - const struct drm_i915_query_topology_info *topology); - static inline uint64_t gen_device_info_timebase_scale(const struct gen_device_info *devinfo, uint64_t gpu_timestamp) -- 2.7.4