mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Create wrappers for gem context destroy, gem vm control, gem wait, reset stats
Related-To: NEO-6852 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
51d1752a68
commit
7d3fc9ab74
@@ -94,8 +94,8 @@ int DrmMock::ioctl(unsigned long request, void *arg) {
|
||||
|
||||
if ((request == DRM_IOCTL_I915_GEM_CONTEXT_DESTROY) && (arg != nullptr)) {
|
||||
ioctlCount.contextDestroy++;
|
||||
auto destroy = static_cast<drm_i915_gem_context_destroy *>(arg);
|
||||
this->receivedDestroyContextId = destroy->ctx_id;
|
||||
auto destroy = static_cast<GemContextDestroy *>(arg);
|
||||
this->receivedDestroyContextId = destroy->contextId;
|
||||
return this->storedRetVal;
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ int DrmMock::ioctl(unsigned long request, void *arg) {
|
||||
}
|
||||
if (request == DRM_IOCTL_I915_GEM_WAIT) {
|
||||
ioctlCount.gemWait++;
|
||||
receivedGemWait = *static_cast<drm_i915_gem_wait *>(arg);
|
||||
receivedGemWait = *static_cast<GemWait *>(arg);
|
||||
return 0;
|
||||
}
|
||||
if (request == DRM_IOCTL_GEM_CLOSE) {
|
||||
@@ -225,9 +225,9 @@ int DrmMock::ioctl(unsigned long request, void *arg) {
|
||||
}
|
||||
if (request == DRM_IOCTL_I915_GET_RESET_STATS && arg != nullptr) {
|
||||
ioctlCount.gemResetStats++;
|
||||
auto outResetStats = static_cast<drm_i915_reset_stats *>(arg);
|
||||
auto outResetStats = static_cast<ResetStats *>(arg);
|
||||
for (const auto &resetStats : resetStatsToReturn) {
|
||||
if (resetStats.ctx_id == outResetStats->ctx_id) {
|
||||
if (resetStats.contextId == outResetStats->contextId) {
|
||||
*outResetStats = resetStats;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ class DrmMock : public Drm {
|
||||
bool capturedCooperativeContextRequest = false;
|
||||
|
||||
uint32_t passedContextDebugId = std::numeric_limits<uint32_t>::max();
|
||||
std::vector<drm_i915_reset_stats> resetStatsToReturn{};
|
||||
std::vector<ResetStats> resetStatsToReturn{};
|
||||
|
||||
GemContextCreateExtSetParam receivedContextCreateSetParam = {};
|
||||
uint32_t receivedContextCreateFlags = 0;
|
||||
@@ -213,27 +213,27 @@ class DrmMock : public Drm {
|
||||
std::vector<MockExecBuffer> execBuffers{};
|
||||
std::vector<MockExecObject> receivedBos{};
|
||||
//DRM_IOCTL_I915_GEM_CREATE
|
||||
__u64 createParamsSize = 0;
|
||||
__u32 createParamsHandle = 0;
|
||||
uint64_t createParamsSize = 0;
|
||||
uint32_t createParamsHandle = 0;
|
||||
//DRM_IOCTL_I915_GEM_SET_TILING
|
||||
__u32 setTilingMode = 0;
|
||||
__u32 setTilingHandle = 0;
|
||||
__u32 setTilingStride = 0;
|
||||
uint32_t setTilingMode = 0;
|
||||
uint32_t setTilingHandle = 0;
|
||||
uint32_t setTilingStride = 0;
|
||||
//DRM_IOCTL_PRIME_FD_TO_HANDLE
|
||||
__u32 outputHandle = 0;
|
||||
__s32 inputFd = 0;
|
||||
uint32_t outputHandle = 0;
|
||||
int32_t inputFd = 0;
|
||||
int fdToHandleRetVal = 0;
|
||||
//DRM_IOCTL_HANDLE_TO_FD
|
||||
__s32 outputFd = 0;
|
||||
int32_t outputFd = 0;
|
||||
//DRM_IOCTL_I915_GEM_USERPTR
|
||||
__u32 returnHandle = 0;
|
||||
__u64 gpuMemSize = 3u * MemoryConstants::gigaByte;
|
||||
uint32_t returnHandle = 0;
|
||||
uint64_t gpuMemSize = 3u * MemoryConstants::gigaByte;
|
||||
//DRM_IOCTL_I915_GEM_MMAP
|
||||
uint64_t lockedPtr[4];
|
||||
//DRM_IOCTL_I915_QUERY
|
||||
QueryItem storedQueryItem = {};
|
||||
//DRM_IOCTL_I915_GEM_WAIT
|
||||
drm_i915_gem_wait receivedGemWait = {};
|
||||
GemWait receivedGemWait = {};
|
||||
//DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT
|
||||
uint32_t storedDrmContextId{};
|
||||
//DRM_IOCTL_GEM_CLOSE
|
||||
|
||||
@@ -140,8 +140,8 @@ int DrmMockCustom::ioctl(unsigned long request, void *arg) {
|
||||
} break;
|
||||
|
||||
case DRM_IOCTL_I915_GEM_WAIT: {
|
||||
auto gemWaitParams = (drm_i915_gem_wait *)arg;
|
||||
gemWaitTimeout = gemWaitParams->timeout_ns;
|
||||
auto gemWaitParams = static_cast<NEO::GemWait *>(arg);
|
||||
gemWaitTimeout = gemWaitParams->timeoutNs;
|
||||
ioctl_cnt.gemWait++;
|
||||
} break;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/string.h"
|
||||
#include "shared/source/os_interface/linux/drm_wrappers.h"
|
||||
#include "shared/source/os_interface/linux/sys_calls.h"
|
||||
|
||||
#include "drm/i915_drm.h"
|
||||
@@ -97,17 +98,17 @@ int ioctl(int fileDescriptor, unsigned long int request, void *arg) {
|
||||
}
|
||||
if (request == DRM_IOCTL_I915_GEM_VM_CREATE) {
|
||||
ioctlVmCreateCalled++;
|
||||
auto control = static_cast<drm_i915_gem_vm_control *>(arg);
|
||||
auto control = static_cast<GemVmControl *>(arg);
|
||||
ioctlVmCreateExtensionArg = control->extensions;
|
||||
control->vm_id = ++vmId;
|
||||
control->vmId = ++vmId;
|
||||
vmFlags |= control->flags;
|
||||
return ioctlVmCreateReturned;
|
||||
}
|
||||
if (request == DRM_IOCTL_I915_GEM_VM_DESTROY) {
|
||||
auto control = static_cast<drm_i915_gem_vm_control *>(arg);
|
||||
auto control = static_cast<GemVmControl *>(arg);
|
||||
vmId--;
|
||||
vmFlags = 0;
|
||||
return (control->vm_id > 0) ? 0 : -1;
|
||||
return (control->vmId > 0) ? 0 : -1;
|
||||
}
|
||||
if (request == invalidIoctl) {
|
||||
errno = 0;
|
||||
|
||||
@@ -1105,11 +1105,11 @@ TEST(DrmTest, GivenZeroBatchActiveAndZeroBatchPendingResetStatsWhenIsGpuHangIsCa
|
||||
mockOsContextLinux.drmContextIds.push_back(0);
|
||||
mockOsContextLinux.drmContextIds.push_back(3);
|
||||
|
||||
drm_i915_reset_stats resetStats{};
|
||||
resetStats.ctx_id = 0;
|
||||
ResetStats resetStats{};
|
||||
resetStats.contextId = 0;
|
||||
drm.resetStatsToReturn.push_back(resetStats);
|
||||
|
||||
resetStats.ctx_id = 3;
|
||||
resetStats.contextId = 3;
|
||||
drm.resetStatsToReturn.push_back(resetStats);
|
||||
|
||||
bool isGpuHangDetected{};
|
||||
@@ -1129,12 +1129,12 @@ TEST(DrmTest, GivenBatchActiveGreaterThanZeroResetStatsWhenIsGpuHangIsCalledThen
|
||||
mockOsContextLinux.drmContextIds.push_back(0);
|
||||
mockOsContextLinux.drmContextIds.push_back(3);
|
||||
|
||||
drm_i915_reset_stats resetStats{};
|
||||
resetStats.ctx_id = 0;
|
||||
ResetStats resetStats{};
|
||||
resetStats.contextId = 0;
|
||||
drm.resetStatsToReturn.push_back(resetStats);
|
||||
|
||||
resetStats.ctx_id = 3;
|
||||
resetStats.batch_active = 2;
|
||||
resetStats.contextId = 3;
|
||||
resetStats.batchActive = 2;
|
||||
drm.resetStatsToReturn.push_back(resetStats);
|
||||
|
||||
bool isGpuHangDetected{};
|
||||
@@ -1153,9 +1153,9 @@ TEST(DrmTest, GivenBatchPendingGreaterThanZeroResetStatsWhenIsGpuHangIsCalledThe
|
||||
MockOsContextLinux mockOsContextLinux{drm, contextId, engineDescriptor};
|
||||
mockOsContextLinux.drmContextIds.push_back(8);
|
||||
|
||||
drm_i915_reset_stats resetStats{};
|
||||
resetStats.ctx_id = 8;
|
||||
resetStats.batch_pending = 7;
|
||||
ResetStats resetStats{};
|
||||
resetStats.contextId = 8;
|
||||
resetStats.batchPending = 7;
|
||||
drm.resetStatsToReturn.push_back(resetStats);
|
||||
|
||||
bool isGpuHangDetected{};
|
||||
|
||||
Reference in New Issue
Block a user