2019-03-19 13:53:55 +01:00
|
|
|
/*
|
2022-01-03 14:16:00 +00:00
|
|
|
* Copyright (C) 2020-2022 Intel Corporation
|
2019-03-19 13:53:55 +01:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2021-10-27 12:43:46 +00:00
|
|
|
#include "shared/source/helpers/string.h"
|
2021-03-16 17:47:26 +00:00
|
|
|
#include "shared/source/os_interface/linux/sys_calls.h"
|
2019-06-17 13:56:03 +02:00
|
|
|
|
2019-03-19 13:53:55 +01:00
|
|
|
#include "drm_neo.h"
|
2020-04-10 13:54:07 +02:00
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2019-03-19 13:53:55 +01:00
|
|
|
|
2021-12-01 11:45:29 +00:00
|
|
|
namespace IoctlToStringHelper {
|
2021-06-28 13:17:49 +00:00
|
|
|
std::string getIoctlStringRemaining(unsigned long request) {
|
2021-09-22 14:31:27 +02:00
|
|
|
return std::to_string(request);
|
2021-06-28 13:17:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string getIoctlParamStringRemaining(int param) {
|
2021-09-22 14:31:27 +02:00
|
|
|
return std::to_string(param);
|
2021-06-28 13:17:49 +00:00
|
|
|
}
|
2021-12-01 11:45:29 +00:00
|
|
|
} // namespace IoctlToStringHelper
|
2021-06-28 13:17:49 +00:00
|
|
|
|
2021-03-16 17:47:26 +00:00
|
|
|
int Drm::createDrmVirtualMemory(uint32_t &drmVmId) {
|
|
|
|
|
drm_i915_gem_vm_control ctl = {};
|
|
|
|
|
auto ret = SysCalls::ioctl(getFileDescriptor(), DRM_IOCTL_I915_GEM_VM_CREATE, &ctl);
|
|
|
|
|
if (ret == 0) {
|
2020-09-20 15:41:43 +00:00
|
|
|
if (ctl.vm_id == 0) {
|
|
|
|
|
// 0 is reserved for invalid/unassigned ppgtt
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2021-03-16 17:47:26 +00:00
|
|
|
drmVmId = ctl.vm_id;
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-27 12:43:46 +00:00
|
|
|
bool Drm::isDebugAttachAvailable() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int Drm::bindBufferObject(OsContext *osContext, uint32_t vmHandleId, BufferObject *bo) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int Drm::unbindBufferObject(OsContext *osContext, uint32_t vmHandleId, BufferObject *bo) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Drm::isVmBindAvailable() {
|
|
|
|
|
return this->bindAvailable;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-14 12:41:38 +00:00
|
|
|
uint32_t Drm::createDrmContextExt(drm_i915_gem_context_create_ext &gcc, uint32_t drmVmId, bool isCooperativeContextRequested) {
|
2021-12-01 18:19:36 +00:00
|
|
|
drm_i915_gem_context_create_ext_setparam extSetparam = {};
|
|
|
|
|
|
|
|
|
|
if (drmVmId > 0) {
|
|
|
|
|
extSetparam.base.name = I915_CONTEXT_CREATE_EXT_SETPARAM;
|
|
|
|
|
extSetparam.param.param = I915_CONTEXT_PARAM_VM;
|
|
|
|
|
extSetparam.param.value = drmVmId;
|
|
|
|
|
gcc.extensions = reinterpret_cast<uint64_t>(&extSetparam);
|
|
|
|
|
gcc.flags |= I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS;
|
|
|
|
|
}
|
2021-10-27 12:43:46 +00:00
|
|
|
return ioctl(DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT, &gcc);
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|