intel: Add has_mmap_offset to intel_device_info
authorJosé Roberto de Souza <jose.souza@intel.com>
Thu, 6 Oct 2022 17:04:32 +0000 (10:04 -0700)
committerMarge Bot <emma+marge@anholt.net>
Mon, 7 Nov 2022 17:22:14 +0000 (17:22 +0000)
All 4 drivers were fetching the same information, better do it on one
place.

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19425>

src/gallium/drivers/crocus/crocus_bufmgr.c
src/gallium/drivers/iris/iris_bufmgr.c
src/intel/dev/intel_device_info.c
src/intel/dev/intel_device_info.h
src/intel/vulkan/anv_device.c
src/intel/vulkan/anv_gem.c
src/intel/vulkan/anv_private.h
src/intel/vulkan_hasvk/anv_device.c
src/intel/vulkan_hasvk/anv_gem.c
src/intel/vulkan_hasvk/anv_private.h

index 3d62dec..a00543f 100644 (file)
@@ -1622,9 +1622,7 @@ crocus_bufmgr_create(struct intel_device_info *devinfo, int fd, bool bo_reuse)
    bufmgr->has_llc = devinfo->has_llc;
    bufmgr->has_tiling_uapi = devinfo->has_tiling_uapi;
    bufmgr->bo_reuse = bo_reuse;
-   int val;
-   if (intel_gem_get_param(fd, I915_PARAM_MMAP_GTT_VERSION, &val) && val >= 4)
-      bufmgr->has_mmap_offset = true;
+   bufmgr->has_mmap_offset = devinfo->has_mmap_offset;
 
    init_cache_buckets(bufmgr);
 
index b3aebd8..e357625 100644 (file)
@@ -2408,9 +2408,8 @@ iris_bufmgr_create(struct intel_device_info *devinfo, int fd, bool bo_reuse)
    bufmgr->has_local_mem = devinfo->has_local_mem;
    bufmgr->has_tiling_uapi = devinfo->has_tiling_uapi;
    bufmgr->bo_reuse = bo_reuse;
+   bufmgr->has_mmap_offset = devinfo->has_mmap_offset;
    int val;
-   if (intel_gem_get_param(fd, I915_PARAM_MMAP_GTT_VERSION, &val) && val >= 4)
-      bufmgr->has_mmap_offset = true;
    if (intel_gem_get_param(fd, I915_PARAM_HAS_USERPTR_PROBE, &val) && val >= 1)
       bufmgr->has_userptr_probe = true;
    iris_bufmgr_get_meminfo(bufmgr, devinfo);
index 1ec84de..26500d3 100644 (file)
@@ -1955,10 +1955,9 @@ intel_i915_get_device_info_from_fd(int fd, struct intel_device_info *devinfo)
       update_cs_workgroup_threads(devinfo);
    }
 
-   int timestamp_frequency;
-   if (getparam(fd, I915_PARAM_CS_TIMESTAMP_FREQUENCY,
-                &timestamp_frequency))
-      devinfo->timestamp_frequency = timestamp_frequency;
+   int val;
+   if (getparam(fd, I915_PARAM_CS_TIMESTAMP_FREQUENCY, &val))
+      devinfo->timestamp_frequency = val;
    else if (devinfo->ver >= 10) {
       mesa_loge("Kernel 4.15 required to read the CS timestamp frequency.");
       return false;
@@ -2005,6 +2004,9 @@ intel_i915_get_device_info_from_fd(int fd, struct intel_device_info *devinfo)
    get_context_param(fd, 0, I915_CONTEXT_PARAM_GTT_SIZE, &devinfo->gtt_size);
    devinfo->has_tiling_uapi = has_get_tiling(fd);
 
+   if (getparam(fd, I915_PARAM_MMAP_GTT_VERSION, &val))
+      devinfo->has_mmap_offset = val >= 4;
+
    return true;
 }
 
index 6bb3868..3b0f5a1 100644 (file)
@@ -146,6 +146,7 @@ struct intel_device_info
    bool has_local_mem;
    bool has_lsc;
    bool has_mesh_shading;
+   bool has_mmap_offset;
 
    /**
     * \name Intel hardware quirks
index b16e884..023ac5a 100644 (file)
@@ -799,9 +799,6 @@ anv_i915_physical_device_get_parameters(struct anv_physical_device *device)
    if (intel_gem_get_param(fd, I915_PARAM_HAS_EXEC_TIMELINE_FENCES, &val))
       device->has_exec_timeline = val;
 
-   if (intel_gem_get_param(fd, I915_PARAM_MMAP_GTT_VERSION, &val))
-      device->has_mmap_offset = val >= 4;
-
    if (intel_gem_get_param(fd, I915_PARAM_HAS_USERPTR_PROBE, &val))
       device->has_userptr_probe = val;
 
@@ -4311,7 +4308,7 @@ VkResult anv_MapMemory(
 
    /* GEM will fail to map if the offset isn't 4k-aligned.  Round down. */
    uint64_t map_offset;
-   if (!device->physical->has_mmap_offset)
+   if (!device->physical->info.has_mmap_offset)
       map_offset = offset & ~4095ull;
    else
       map_offset = 0;
index 4b52767..c1dba6a 100644 (file)
@@ -146,7 +146,7 @@ anv_gem_mmap(struct anv_device *device, uint32_t gem_handle,
              uint64_t offset, uint64_t size, uint32_t flags)
 {
    void *map;
-   if (device->physical->has_mmap_offset)
+   if (device->physical->info.has_mmap_offset)
       map = anv_gem_mmap_offset(device, gem_handle, offset, size, flags);
    else
       map = anv_gem_mmap_legacy(device, gem_handle, offset, size, flags);
index 7104101..713182a 100644 (file)
@@ -964,7 +964,6 @@ struct anv_physical_device {
     bool                                        has_exec_capture;
     VkQueueGlobalPriorityKHR                    max_context_priority;
     bool                                        has_context_isolation;
-    bool                                        has_mmap_offset;
     bool                                        has_userptr_probe;
     uint64_t                                    gtt_size;
 
index 5d3ed88..890781b 100644 (file)
@@ -882,9 +882,6 @@ anv_physical_device_try_create(struct vk_instance *vk_instance,
    device->always_flush_cache = INTEL_DEBUG(DEBUG_STALL) ||
       driQueryOptionb(&instance->dri_options, "always_flush_cache");
 
-   if (intel_gem_get_param(fd, I915_PARAM_MMAP_GTT_VERSION, &val))
-      device->has_mmap_offset = val >= 4;
-
    if (intel_gem_get_param(fd, I915_PARAM_HAS_USERPTR_PROBE, &val))
       device->has_userptr_probe = val;
 
@@ -3886,7 +3883,7 @@ VkResult anv_MapMemory(
 
    /* GEM will fail to map if the offset isn't 4k-aligned.  Round down. */
    uint64_t map_offset;
-   if (!device->physical->has_mmap_offset)
+   if (!device->physical->info.has_mmap_offset)
       map_offset = offset & ~4095ull;
    else
       map_offset = 0;
index 56c7162..2d8e26c 100644 (file)
@@ -117,7 +117,7 @@ anv_gem_mmap(struct anv_device *device, uint32_t gem_handle,
              uint64_t offset, uint64_t size, uint32_t flags)
 {
    void *map;
-   if (device->physical->has_mmap_offset)
+   if (device->physical->info.has_mmap_offset)
       map = anv_gem_mmap_offset(device, gem_handle, offset, size, flags);
    else
       map = anv_gem_mmap_legacy(device, gem_handle, offset, size, flags);
index 7d3c81a..3f00604 100644 (file)
@@ -963,7 +963,6 @@ struct anv_physical_device {
     bool                                        has_exec_capture;
     int                                         max_context_priority;
     bool                                        has_context_isolation;
-    bool                                        has_mmap_offset;
     bool                                        has_userptr_probe;
     uint64_t                                    gtt_size;