From: José Roberto de Souza Date: Thu, 6 Oct 2022 17:04:32 +0000 (-0700) Subject: intel: Add has_mmap_offset to intel_device_info X-Git-Tag: upstream/23.3.3~17307 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e9eceb11061db36aea5c83eaa0972f5680c1f0d8;p=platform%2Fupstream%2Fmesa.git intel: Add has_mmap_offset to intel_device_info All 4 drivers were fetching the same information, better do it on one place. Reviewed-by: Tapani Pälli Signed-off-by: José Roberto de Souza Part-of: --- diff --git a/src/gallium/drivers/crocus/crocus_bufmgr.c b/src/gallium/drivers/crocus/crocus_bufmgr.c index 3d62dec..a00543f 100644 --- a/src/gallium/drivers/crocus/crocus_bufmgr.c +++ b/src/gallium/drivers/crocus/crocus_bufmgr.c @@ -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); diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c index b3aebd8..e357625 100644 --- a/src/gallium/drivers/iris/iris_bufmgr.c +++ b/src/gallium/drivers/iris/iris_bufmgr.c @@ -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); diff --git a/src/intel/dev/intel_device_info.c b/src/intel/dev/intel_device_info.c index 1ec84de..26500d3 100644 --- a/src/intel/dev/intel_device_info.c +++ b/src/intel/dev/intel_device_info.c @@ -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, - ×tamp_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; } diff --git a/src/intel/dev/intel_device_info.h b/src/intel/dev/intel_device_info.h index 6bb3868..3b0f5a1 100644 --- a/src/intel/dev/intel_device_info.h +++ b/src/intel/dev/intel_device_info.h @@ -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 diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index b16e884..023ac5a 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -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; diff --git a/src/intel/vulkan/anv_gem.c b/src/intel/vulkan/anv_gem.c index 4b52767..c1dba6a 100644 --- a/src/intel/vulkan/anv_gem.c +++ b/src/intel/vulkan/anv_gem.c @@ -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); diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 7104101..713182a 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -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; diff --git a/src/intel/vulkan_hasvk/anv_device.c b/src/intel/vulkan_hasvk/anv_device.c index 5d3ed88..890781b 100644 --- a/src/intel/vulkan_hasvk/anv_device.c +++ b/src/intel/vulkan_hasvk/anv_device.c @@ -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; diff --git a/src/intel/vulkan_hasvk/anv_gem.c b/src/intel/vulkan_hasvk/anv_gem.c index 56c7162..2d8e26c 100644 --- a/src/intel/vulkan_hasvk/anv_gem.c +++ b/src/intel/vulkan_hasvk/anv_gem.c @@ -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); diff --git a/src/intel/vulkan_hasvk/anv_private.h b/src/intel/vulkan_hasvk/anv_private.h index 7d3c81a..3f00604 100644 --- a/src/intel/vulkan_hasvk/anv_private.h +++ b/src/intel/vulkan_hasvk/anv_private.h @@ -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;