Module: Mesa Branch: main Commit: 6ae6921216c0465c10e6df3e5e46f6d03633b1ca URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6ae6921216c0465c10e6df3e5e46f6d03633b1ca
Author: José Roberto de Souza <[email protected]> Date: Wed Oct 5 08:49:26 2022 -0700 intel: Add and use intel_gem_destroy_context() Again sharing the same function across all Intel drivers. Signed-off-by: José Roberto de Souza <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18974> --- src/gallium/drivers/crocus/crocus_bufmgr.c | 4 +--- src/gallium/drivers/iris/iris_bufmgr.c | 4 +--- src/intel/common/intel_gem.c | 9 +++++++++ src/intel/common/intel_gem.h | 1 + src/intel/vulkan/anv_device.c | 6 +++--- src/intel/vulkan/anv_gem.c | 10 ---------- src/intel/vulkan/anv_gem_stubs.c | 6 ------ src/intel/vulkan/anv_private.h | 1 - src/intel/vulkan_hasvk/anv_device.c | 6 +++--- src/intel/vulkan_hasvk/anv_gem.c | 10 ---------- src/intel/vulkan_hasvk/anv_gem_stubs.c | 6 ------ src/intel/vulkan_hasvk/anv_private.h | 1 - 12 files changed, 18 insertions(+), 46 deletions(-) diff --git a/src/gallium/drivers/crocus/crocus_bufmgr.c b/src/gallium/drivers/crocus/crocus_bufmgr.c index 4e8b5a9baba..d618083ee84 100644 --- a/src/gallium/drivers/crocus/crocus_bufmgr.c +++ b/src/gallium/drivers/crocus/crocus_bufmgr.c @@ -1594,10 +1594,8 @@ crocus_clone_hw_context(struct crocus_bufmgr *bufmgr, uint32_t ctx_id) void crocus_destroy_hw_context(struct crocus_bufmgr *bufmgr, uint32_t ctx_id) { - struct drm_i915_gem_context_destroy d = { .ctx_id = ctx_id }; - if (ctx_id != 0 && - intel_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_CONTEXT_DESTROY, &d) != 0) { + !intel_gem_destroy_context(bufmgr->fd, ctx_id)) { fprintf(stderr, "DRM_IOCTL_I915_GEM_CONTEXT_DESTROY failed: %s\n", strerror(errno)); } diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c index de38bce035f..c4af964f954 100644 --- a/src/gallium/drivers/iris/iris_bufmgr.c +++ b/src/gallium/drivers/iris/iris_bufmgr.c @@ -2294,10 +2294,8 @@ iris_clone_hw_context(struct iris_bufmgr *bufmgr, uint32_t ctx_id) void iris_destroy_kernel_context(struct iris_bufmgr *bufmgr, uint32_t ctx_id) { - struct drm_i915_gem_context_destroy d = { .ctx_id = ctx_id }; - if (ctx_id != 0 && - intel_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_CONTEXT_DESTROY, &d) != 0) { + !intel_gem_destroy_context(bufmgr->fd, ctx_id)) { fprintf(stderr, "DRM_IOCTL_I915_GEM_CONTEXT_DESTROY failed: %s\n", strerror(errno)); } diff --git a/src/intel/common/intel_gem.c b/src/intel/common/intel_gem.c index 69dde109b49..7819be0aae0 100644 --- a/src/intel/common/intel_gem.c +++ b/src/intel/common/intel_gem.c @@ -68,6 +68,15 @@ intel_gem_create_context(int fd, uint32_t *context_id) return true; } +bool +intel_gem_destroy_context(int fd, uint32_t context_id) +{ + struct drm_i915_gem_context_destroy destroy = { + .ctx_id = context_id, + }; + return intel_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_DESTROY, &destroy) == 0; +} + bool intel_gem_create_context_engines(int fd, const struct intel_query_engine_info *info, diff --git a/src/intel/common/intel_gem.h b/src/intel/common/intel_gem.h index b13ef367d6d..9f9ce9ed919 100644 --- a/src/intel/common/intel_gem.h +++ b/src/intel/common/intel_gem.h @@ -160,6 +160,7 @@ intel_i915_query_alloc(int fd, uint64_t query_id, int32_t *query_length) bool intel_gem_supports_syncobj_wait(int fd); bool intel_gem_create_context(int fd, uint32_t *context_id); +bool intel_gem_destroy_context(int fd, uint32_t context_id); bool intel_gem_create_context_engines(int fd, const struct intel_query_engine_info *info, diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index e19ebfefaeb..055d233dc22 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -3206,7 +3206,7 @@ anv_device_setup_context(struct anv_device *device, return result; fail_context: - anv_gem_destroy_context(device, device->context_id); + intel_gem_destroy_context(device->fd, device->context_id); return result; } @@ -3663,7 +3663,7 @@ VkResult anv_CreateDevice( anv_queue_finish(&device->queues[i]); vk_free(&device->vk.alloc, device->queues); fail_context_id: - anv_gem_destroy_context(device, device->context_id); + intel_gem_destroy_context(device->fd, device->context_id); fail_fd: close(device->fd); fail_device: @@ -3748,7 +3748,7 @@ void anv_DestroyDevice( anv_queue_finish(&device->queues[i]); vk_free(&device->vk.alloc, device->queues); - anv_gem_destroy_context(device, device->context_id); + intel_gem_destroy_context(device->fd, device->context_id); if (INTEL_DEBUG(DEBUG_BATCH)) intel_batch_decode_ctx_finish(&device->decoder_ctx); diff --git a/src/intel/vulkan/anv_gem.c b/src/intel/vulkan/anv_gem.c index b87c99d43e2..c0c60d75bf1 100644 --- a/src/intel/vulkan/anv_gem.c +++ b/src/intel/vulkan/anv_gem.c @@ -302,16 +302,6 @@ anv_gem_has_context_priority(int fd, VkQueueGlobalPriorityKHR priority) priority); } -int -anv_gem_destroy_context(struct anv_device *device, int context) -{ - struct drm_i915_gem_context_destroy destroy = { - .ctx_id = context, - }; - - return intel_ioctl(device->fd, DRM_IOCTL_I915_GEM_CONTEXT_DESTROY, &destroy); -} - static int vk_priority_to_i915(VkQueueGlobalPriorityKHR priority) { diff --git a/src/intel/vulkan/anv_gem_stubs.c b/src/intel/vulkan/anv_gem_stubs.c index ce01fa40d39..ea17982ad0e 100644 --- a/src/intel/vulkan/anv_gem_stubs.c +++ b/src/intel/vulkan/anv_gem_stubs.c @@ -124,12 +124,6 @@ anv_gem_get_param(int fd, uint32_t param) unreachable("Unused"); } -int -anv_gem_destroy_context(struct anv_device *device, int context) -{ - unreachable("Unused"); -} - int anv_gem_set_context_param(int fd, int context, uint32_t param, uint64_t value) { diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 49f62cfc73c..f7f919cb581 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1347,7 +1347,6 @@ int anv_gem_execbuffer(struct anv_device *device, int anv_gem_set_tiling(struct anv_device *device, uint32_t gem_handle, uint32_t stride, uint32_t tiling); bool anv_gem_has_context_priority(int fd, VkQueueGlobalPriorityKHR priority); -int anv_gem_destroy_context(struct anv_device *device, int context); int anv_gem_set_context_param(int fd, int context, uint32_t param, uint64_t value); int anv_gem_get_param(int fd, uint32_t param); diff --git a/src/intel/vulkan_hasvk/anv_device.c b/src/intel/vulkan_hasvk/anv_device.c index 047c0d98ed2..59a24034df8 100644 --- a/src/intel/vulkan_hasvk/anv_device.c +++ b/src/intel/vulkan_hasvk/anv_device.c @@ -2855,7 +2855,7 @@ anv_device_setup_context(struct anv_device *device, return result; fail_context: - anv_gem_destroy_context(device, device->context_id); + intel_gem_destroy_context(device->fd, device->context_id); return result; } @@ -3263,7 +3263,7 @@ VkResult anv_CreateDevice( anv_queue_finish(&device->queues[i]); vk_free(&device->vk.alloc, device->queues); fail_context_id: - anv_gem_destroy_context(device, device->context_id); + intel_gem_destroy_context(device->fd, device->context_id); fail_fd: close(device->fd); fail_device: @@ -3335,7 +3335,7 @@ void anv_DestroyDevice( anv_queue_finish(&device->queues[i]); vk_free(&device->vk.alloc, device->queues); - anv_gem_destroy_context(device, device->context_id); + intel_gem_destroy_context(device->fd, device->context_id); if (INTEL_DEBUG(DEBUG_BATCH)) intel_batch_decode_ctx_finish(&device->decoder_ctx); diff --git a/src/intel/vulkan_hasvk/anv_gem.c b/src/intel/vulkan_hasvk/anv_gem.c index 903650452c0..a383f8e17f6 100644 --- a/src/intel/vulkan_hasvk/anv_gem.c +++ b/src/intel/vulkan_hasvk/anv_gem.c @@ -273,16 +273,6 @@ anv_gem_has_context_priority(int fd, int priority) priority); } -int -anv_gem_destroy_context(struct anv_device *device, int context) -{ - struct drm_i915_gem_context_destroy destroy = { - .ctx_id = context, - }; - - return intel_ioctl(device->fd, DRM_IOCTL_I915_GEM_CONTEXT_DESTROY, &destroy); -} - int anv_gem_set_context_param(int fd, int context, uint32_t param, uint64_t value) { diff --git a/src/intel/vulkan_hasvk/anv_gem_stubs.c b/src/intel/vulkan_hasvk/anv_gem_stubs.c index e86ae41a57e..751e206de2c 100644 --- a/src/intel/vulkan_hasvk/anv_gem_stubs.c +++ b/src/intel/vulkan_hasvk/anv_gem_stubs.c @@ -116,12 +116,6 @@ anv_gem_get_param(int fd, uint32_t param) unreachable("Unused"); } -int -anv_gem_destroy_context(struct anv_device *device, int context) -{ - unreachable("Unused"); -} - int anv_gem_set_context_param(int fd, int context, uint32_t param, uint64_t value) { diff --git a/src/intel/vulkan_hasvk/anv_private.h b/src/intel/vulkan_hasvk/anv_private.h index 600489d76a5..b1143fbb984 100644 --- a/src/intel/vulkan_hasvk/anv_private.h +++ b/src/intel/vulkan_hasvk/anv_private.h @@ -1382,7 +1382,6 @@ int anv_gem_execbuffer(struct anv_device *device, int anv_gem_set_tiling(struct anv_device *device, uint32_t gem_handle, uint32_t stride, uint32_t tiling); bool anv_gem_has_context_priority(int fd, int priority); -int anv_gem_destroy_context(struct anv_device *device, int context); int anv_gem_set_context_param(int fd, int context, uint32_t param, uint64_t value); int anv_gem_get_param(int fd, uint32_t param);
