mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +08:00
Pass RootDeviceEnvironment to Drm
Related-To: NEO-4207 Change-Id: Ic59abf9221702333efea69213391b9646ae0864e Signed-off-by: Jablonski, Mateusz <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
780925aab4
commit
adc3a97503
@@ -11,6 +11,7 @@
|
||||
#include "core/helpers/options.h"
|
||||
#include "core/os_interface/linux/drm_neo.h"
|
||||
#include "runtime/os_interface/linux/drm_memory_manager.h"
|
||||
#include "runtime/platform/platform.h"
|
||||
#include "unit_tests/helpers/gtest_helpers.h"
|
||||
|
||||
#include "drm/i915_drm.h"
|
||||
@@ -24,26 +25,29 @@
|
||||
|
||||
#define RENDER_DEVICE_NAME_MATCHER ::testing::StrEq("/dev/dri/renderD128")
|
||||
|
||||
using NEO::constructPlatform;
|
||||
using NEO::Drm;
|
||||
using NEO::RootDeviceEnvironment;
|
||||
|
||||
static const int mockFd = 33;
|
||||
|
||||
class DrmMockImpl : public Drm {
|
||||
public:
|
||||
DrmMockImpl(int fd) : Drm(fd){};
|
||||
DrmMockImpl(int fd) : Drm(fd, *constructPlatform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]){};
|
||||
MOCK_METHOD2(ioctl, int(unsigned long request, void *arg));
|
||||
};
|
||||
|
||||
class DrmMockSuccess : public Drm {
|
||||
public:
|
||||
DrmMockSuccess() : Drm(mockFd) {}
|
||||
DrmMockSuccess() : DrmMockSuccess(*constructPlatform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]) {}
|
||||
DrmMockSuccess(RootDeviceEnvironment &rootDeviceEnvironment) : Drm(mockFd, rootDeviceEnvironment) {}
|
||||
|
||||
int ioctl(unsigned long request, void *arg) override { return 0; };
|
||||
};
|
||||
|
||||
class DrmMockFail : public Drm {
|
||||
public:
|
||||
DrmMockFail() : Drm(mockFd) {}
|
||||
DrmMockFail() : Drm(mockFd, *constructPlatform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]) {}
|
||||
|
||||
int ioctl(unsigned long request, void *arg) override { return -1; };
|
||||
};
|
||||
@@ -323,7 +327,7 @@ class DrmMockCustom : public Drm {
|
||||
ioctl_res_ext = &NONE;
|
||||
}
|
||||
|
||||
DrmMockCustom() : Drm(mockFd) {
|
||||
DrmMockCustom() : Drm(mockFd, *constructPlatform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]) {
|
||||
reset();
|
||||
ioctl_expected.contextCreate = static_cast<int>(NEO::HwHelper::get(NEO::platformDevices[0]->platform.eRenderCoreFamily).getGpgpuEngineInstances().size());
|
||||
ioctl_expected.contextDestroy = ioctl_expected.contextCreate.load();
|
||||
|
||||
@@ -36,7 +36,7 @@ class DrmMockForWorker : public Drm {
|
||||
std::atomic<int> gem_close_cnt;
|
||||
std::atomic<int> gem_close_expected;
|
||||
std::atomic<std::thread::id> ioctl_caller_thread_id;
|
||||
DrmMockForWorker() : Drm(33) {
|
||||
DrmMockForWorker() : Drm(33, *platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]) {
|
||||
}
|
||||
int ioctl(unsigned long request, void *arg) override {
|
||||
if (_IOC_TYPE(request) == DRM_IOCTL_BASE) {
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include "core/memory_manager/memory_constants.h"
|
||||
#include "core/os_interface/linux/drm_neo.h"
|
||||
#include "runtime/execution_environment/execution_environment.h"
|
||||
#include "runtime/platform/platform.h"
|
||||
|
||||
#include "drm/i915_drm.h"
|
||||
|
||||
@@ -30,9 +32,10 @@ class DrmMock : public Drm {
|
||||
using Drm::query;
|
||||
using Drm::sliceCountChangeSupported;
|
||||
|
||||
DrmMock() : Drm(mockFd) {
|
||||
DrmMock(RootDeviceEnvironment &rootDeviceEnvironment) : Drm(mockFd, rootDeviceEnvironment) {
|
||||
sliceCountChangeSupported = true;
|
||||
}
|
||||
DrmMock() : DrmMock(*platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]) {}
|
||||
|
||||
~DrmMock() {
|
||||
if (sysFsDefaultGpuPathToRestore != nullptr) {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/execution_environment/root_device_environment.h"
|
||||
#include "core/helpers/options.h"
|
||||
#include "core/os_interface/linux/drm_neo.h"
|
||||
#include "test.h"
|
||||
@@ -20,7 +21,7 @@ static std::vector<Drm *> drmMockStack;
|
||||
|
||||
class DrmMockDefault : public DrmMock {
|
||||
public:
|
||||
DrmMockDefault() : DrmMock() {
|
||||
DrmMockDefault(RootDeviceEnvironment &rootDeviceEnvironment) : DrmMock(rootDeviceEnvironment) {
|
||||
StoredRetVal = 0;
|
||||
StoredRetValForDeviceID = 0;
|
||||
StoredRetValForEUVal = 0;
|
||||
@@ -32,8 +33,11 @@ class DrmMockDefault : public DrmMock {
|
||||
}
|
||||
};
|
||||
|
||||
struct static_init : public DrmMockDefault {
|
||||
static_init() : DrmMockDefault() { drmMockStack.push_back(this); }
|
||||
struct static_init {
|
||||
static_init() : rootDeviceEnvironment(executionEnvironment), drmMockDefault(rootDeviceEnvironment) { drmMockStack.push_back(&drmMockDefault); }
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
RootDeviceEnvironment rootDeviceEnvironment;
|
||||
DrmMockDefault drmMockDefault;
|
||||
};
|
||||
|
||||
static static_init s;
|
||||
@@ -51,7 +55,7 @@ Drm *Drm::get(int32_t deviceOrdinal) {
|
||||
return drmMockStack[drmMockStack.size() - 1];
|
||||
}
|
||||
|
||||
Drm *Drm::create(int32_t deviceOrdinal) {
|
||||
Drm *Drm::create(int32_t deviceOrdinal, RootDeviceEnvironment &rootDeviceEnvironment) {
|
||||
// We silently skip deviceOrdinal
|
||||
EXPECT_EQ(deviceOrdinal, 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user