iris: Implement the Xe version of iris_bufmgr_init_global_vm()

As Xe KMD requires VM, iris_bufmgr_init_global_vm() now is returing
a boolean telling if bufmgr creationg should continue or not.

Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21937>
This commit is contained in:
José Roberto de Souza 2023-02-14 09:00:22 -08:00 committed by Marge Bot
parent 7f65b94451
commit 60f4bd61b6
4 changed files with 85 additions and 3 deletions

View file

@ -67,6 +67,7 @@
#include "string.h"
#include "iris_kmd_backend.h"
#include "i915/iris_bufmgr.h"
#include "xe/iris_bufmgr.h"
#include "drm-uapi/i915_drm.h"
@ -2209,15 +2210,21 @@ iris_bufmgr_get_meminfo(struct iris_bufmgr *bufmgr,
return true;
}
static void
static bool
iris_bufmgr_init_global_vm(struct iris_bufmgr *bufmgr)
{
switch (bufmgr->devinfo.kmd_type) {
case INTEL_KMD_TYPE_I915:
bufmgr->use_global_vm = iris_i915_init_global_vm(bufmgr, &bufmgr->global_vm_id);
break;
/* i915 don't require VM, so returning true even if use_global_vm is false */
return true;
case INTEL_KMD_TYPE_XE:
bufmgr->use_global_vm = iris_xe_init_global_vm(bufmgr, &bufmgr->global_vm_id);
/* Xe requires VM */
return bufmgr->use_global_vm;
default:
unreachable("missing");
return false;
}
}
@ -2271,7 +2278,8 @@ iris_bufmgr_create(struct intel_device_info *devinfo, int fd, bool bo_reuse)
INTEL_ENGINE_CLASS_COMPUTE);
free(engine_info);
iris_bufmgr_init_global_vm(bufmgr);
if (!iris_bufmgr_init_global_vm(bufmgr))
goto error_init_vm;
STATIC_ASSERT(IRIS_MEMZONE_SHADER_START == 0ull);
const uint64_t _4GB = 1ull << 32;
@ -2364,6 +2372,7 @@ error_slabs_init:
pb_slabs_deinit(&bufmgr->bo_slabs[i]);
}
error_init_vm:
error_engine_info:
close(bufmgr->fd);
error_dup:

View file

@ -22,6 +22,8 @@ files_libiris = files(
'i915/iris_bufmgr.c',
'i915/iris_bufmgr.h',
'i915/iris_kmd_backend.c',
'xe/iris_bufmgr.c',
'xe/iris_bufmgr.h',
'driinfo_iris.h',
'iris_batch.c',
'iris_batch.h',

View file

@ -0,0 +1,41 @@
/*
* 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/iris_bufmgr.h"
#include "common/intel_gem.h"
#include "iris/iris_bufmgr.h"
#include "drm-uapi/xe_drm.h"
bool
iris_xe_init_global_vm(struct iris_bufmgr *bufmgr, uint32_t *vm_id)
{
struct drm_xe_vm_create create = {
.flags = DRM_XE_VM_CREATE_SCRATCH_PAGE,
};
if (intel_ioctl(iris_bufmgr_get_fd(bufmgr), DRM_IOCTL_XE_VM_CREATE, &create))
return false;
*vm_id = create.vm_id;
return true;
}

View file

@ -0,0 +1,30 @@
/*
* 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 <stdint.h>
#include <stdbool.h>
struct iris_bufmgr;
bool iris_xe_init_global_vm(struct iris_bufmgr *bufmgr, uint32_t *vm_id);