intel/device: make internal functions private
authorMark Janes <mark.a.janes@intel.com>
Tue, 30 Jul 2019 00:38:42 +0000 (17:38 -0700)
committerMark Janes <mark.a.janes@intel.com>
Thu, 1 Aug 2019 23:40:03 +0000 (16:40 -0700)
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 <kenneth@whitecape.org>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/intel/dev/gen_device_info.c
src/intel/dev/gen_device_info.h

index 462a906d08d2b5a34c5a4bc9372817d6d2a147d6..cbe55007993f3d17c71e87f8df37d5c1bcf47c28 100644 (file)
@@ -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);
 
@@ -1183,6 +1121,66 @@ gen_device_info_update_from_topology(struct gen_device_info *devinfo,
    devinfo->num_eu_per_subslice = DIV_ROUND_UP(n_eus, n_subslices);
 }
 
+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)
 {
@@ -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;
index bf5347432a507840d006fa90fc8d9f8af51d023b..57f1495a1e6ef3e55e5a2331108802561cc2dcc9 100644 (file)
@@ -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)