From 324d22d684253551cf574658ee071717d2b451f5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Roberto=20de=20Souza?= Date: Thu, 9 Feb 2023 08:50:57 -0800 Subject: [PATCH] anv: Implement gem close and mmap for Xe backend MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: José Roberto de Souza Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/vulkan/xe/anv_kmd_backend.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/intel/vulkan/xe/anv_kmd_backend.c b/src/intel/vulkan/xe/anv_kmd_backend.c index 44661cf..8342d1c 100644 --- a/src/intel/vulkan/xe/anv_kmd_backend.c +++ b/src/intel/vulkan/xe/anv_kmd_backend.c @@ -21,6 +21,8 @@ * IN THE SOFTWARE. */ +#include + #include "anv_private.h" #include "drm-uapi/xe_drm.h" @@ -44,11 +46,36 @@ xe_gem_create(struct anv_device *device, return gem_create.handle; } +static void +xe_gem_close(struct anv_device *device, uint32_t handle) +{ + struct drm_gem_close close = { + .handle = handle, + }; + intel_ioctl(device->fd, DRM_IOCTL_GEM_CLOSE, &close); +} + +static void * +xe_gem_mmap(struct anv_device *device, struct anv_bo *bo, uint64_t offset, + uint64_t size, VkMemoryPropertyFlags property_flags) +{ + struct drm_xe_gem_mmap_offset args = { + .handle = bo->gem_handle, + }; + if (intel_ioctl(device->fd, DRM_IOCTL_XE_GEM_MMAP_OFFSET, &args)) + return MAP_FAILED; + + return mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, + device->fd, args.offset); +} + const struct anv_kmd_backend * anv_xe_kmd_backend_get(void) { static const struct anv_kmd_backend xe_backend = { .gem_create = xe_gem_create, + .gem_close = xe_gem_close, + .gem_mmap = xe_gem_mmap, }; return &xe_backend; } -- 2.7.4