From: José Roberto de Souza Date: Fri, 10 Feb 2023 15:50:30 +0000 (-0800) Subject: anv: Implement Xe version of execute_simple_batch() X-Git-Tag: upstream/23.3.3~11219 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3f544150bb346847a46162bc89f542cc66d08e30;p=platform%2Fupstream%2Fmesa.git anv: Implement Xe version of execute_simple_batch() Signed-off-by: José Roberto de Souza Reviewed-by: Lionel Landwerlin Part-of: --- diff --git a/src/intel/vulkan/meson.build b/src/intel/vulkan/meson.build index 99cb110..e133979 100644 --- a/src/intel/vulkan/meson.build +++ b/src/intel/vulkan/meson.build @@ -137,6 +137,8 @@ libanv_files = files( 'i915/anv_kmd_backend.c', 'layers/anv_doom64.c', 'layers/anv_hitman3.c', + 'xe/anv_batch_chain.c', + 'xe/anv_batch_chain.h', 'xe/anv_kmd_backend.c', 'xe/anv_device.c', 'xe/anv_device.h', diff --git a/src/intel/vulkan/xe/anv_batch_chain.c b/src/intel/vulkan/xe/anv_batch_chain.c new file mode 100644 index 0000000..b964ec8 --- /dev/null +++ b/src/intel/vulkan/xe/anv_batch_chain.c @@ -0,0 +1,72 @@ +/* + * Copyright © 2023 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "xe/anv_batch_chain.h" + +#include "anv_private.h" + +#include + +#include "drm-uapi/xe_drm.h" + +VkResult +xe_execute_simple_batch(struct anv_queue *queue, struct anv_bo *batch_bo, + uint32_t batch_bo_size) +{ + struct anv_device *device = queue->device; + VkResult result = VK_SUCCESS; + uint32_t syncobj_handle; + + if (drmSyncobjCreate(device->fd, 0, &syncobj_handle)) + return vk_errorf(device, VK_ERROR_UNKNOWN, "Unable to create sync obj"); + + struct drm_xe_sync sync = { + .flags = DRM_XE_SYNC_SYNCOBJ | DRM_XE_SYNC_SIGNAL, + .handle = syncobj_handle, + }; + struct drm_xe_exec exec = { + .engine_id = queue->engine_id, + .num_batch_buffer = 1, + .address = batch_bo->offset, + .num_syncs = 1, + .syncs = (uintptr_t)&sync, + }; + + if (intel_ioctl(device->fd, DRM_IOCTL_XE_EXEC, &exec)) { + result = vk_device_set_lost(&device->vk, "XE_EXEC failed: %m"); + goto exec_error; + } + + struct drm_syncobj_wait wait = { + .handles = (uintptr_t)&syncobj_handle, + .timeout_nsec = INT64_MAX, + .count_handles = 1, + }; + if (intel_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_WAIT, &wait)) + result = vk_device_set_lost(&device->vk, "DRM_IOCTL_SYNCOBJ_WAIT failed: %m"); + +exec_error: + drmSyncobjDestroy(device->fd, syncobj_handle); + + return result; +} diff --git a/src/intel/vulkan/xe/anv_batch_chain.h b/src/intel/vulkan/xe/anv_batch_chain.h new file mode 100644 index 0000000..8984694 --- /dev/null +++ b/src/intel/vulkan/xe/anv_batch_chain.h @@ -0,0 +1,35 @@ +/* + * Copyright © 2023 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#pragma once + +#include + +#include "vulkan/vulkan_core.h" + +struct anv_queue; +struct anv_bo; + +VkResult +xe_execute_simple_batch(struct anv_queue *queue, struct anv_bo *batch_bo, + uint32_t batch_bo_size); diff --git a/src/intel/vulkan/xe/anv_kmd_backend.c b/src/intel/vulkan/xe/anv_kmd_backend.c index 434215e..80aa931 100644 --- a/src/intel/vulkan/xe/anv_kmd_backend.c +++ b/src/intel/vulkan/xe/anv_kmd_backend.c @@ -26,6 +26,8 @@ #include "anv_private.h" +#include "xe/anv_batch_chain.h" + #include "drm-uapi/xe_drm.h" static uint32_t @@ -137,6 +139,7 @@ anv_xe_kmd_backend_get(void) .gem_mmap = xe_gem_mmap, .gem_vm_bind = xe_gem_vm_bind, .gem_vm_unbind = xe_gem_vm_unbind, + .execute_simple_batch = xe_execute_simple_batch, }; return &xe_backend; }