mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
Extract HwDeviceId from Drm
Related-To: NEO-4208 Change-Id: I1678ad92cab2a369769b93da69dc46a1d515f261 Signed-off-by: Jablonski, Mateusz <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
8560b2b262
commit
018e585eb1
@@ -23,6 +23,8 @@ set(NEO_CORE_OS_INTERFACE_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_device_id.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_device_id_linux.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/linux_inc.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/drm_query.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/engine_info.h
|
||||
@@ -43,6 +45,7 @@ set(NEO_CORE_OS_INTERFACE_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_time_linux.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/page_table_manager_functions.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/print.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sys_calls.h
|
||||
)
|
||||
|
||||
set_property(GLOBAL PROPERTY NEO_CORE_OS_INTERFACE_LINUX ${NEO_CORE_OS_INTERFACE_LINUX})
|
||||
|
||||
@@ -56,7 +56,7 @@ int Drm::ioctl(unsigned long request, void *arg) {
|
||||
int ret;
|
||||
SYSTEM_ENTER();
|
||||
do {
|
||||
ret = ::ioctl(fd, request, arg);
|
||||
ret = ::ioctl(getFileDescriptor(), request, arg);
|
||||
} while (ret == -1 && (errno == EINTR || errno == EAGAIN));
|
||||
SYSTEM_LEAVE(request);
|
||||
return ret;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#pragma once
|
||||
#include "core/helpers/basic_math.h"
|
||||
#include "core/os_interface/linux/engine_info.h"
|
||||
#include "core/os_interface/linux/hw_device_id.h"
|
||||
#include "core/os_interface/linux/memory_info.h"
|
||||
#include "core/utilities/api_intercept.h"
|
||||
|
||||
@@ -65,7 +66,7 @@ class Drm {
|
||||
bool isPreemptionSupported() const { return preemptionSupported; }
|
||||
|
||||
MOCKABLE_VIRTUAL void checkPreemptionSupport();
|
||||
int getFileDescriptor() const { return fd; }
|
||||
inline int getFileDescriptor() const { return hwDeviceId->getFileDescriptor(); }
|
||||
uint32_t createDrmContext();
|
||||
void destroyDrmContext(uint32_t drmContextId);
|
||||
void setLowPriorityContextParam(uint32_t drmContextId);
|
||||
@@ -99,12 +100,12 @@ class Drm {
|
||||
drm_i915_gem_context_param_sseu sseu{};
|
||||
bool preemptionSupported = false;
|
||||
bool nonPersistentContextsSupported = false;
|
||||
int fd;
|
||||
std::unique_ptr<HwDeviceId> hwDeviceId;
|
||||
int deviceId = 0;
|
||||
int revisionId = 0;
|
||||
GTTYPE eGtType = GTTYPE_UNDEFINED;
|
||||
RootDeviceEnvironment &rootDeviceEnvironment;
|
||||
Drm(int fd, RootDeviceEnvironment &rootDeviceEnvironment) : fd(fd), rootDeviceEnvironment(rootDeviceEnvironment) {}
|
||||
Drm(std::unique_ptr<HwDeviceId> hwDeviceIdIn, RootDeviceEnvironment &rootDeviceEnvironment) : hwDeviceId(std::move(hwDeviceIdIn)), rootDeviceEnvironment(rootDeviceEnvironment) {}
|
||||
std::unique_ptr<EngineInfo> engineInfo;
|
||||
std::unique_ptr<MemoryInfo> memoryInfo;
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ class DrmNullDevice : public Drm {
|
||||
}
|
||||
}
|
||||
|
||||
DrmNullDevice(int fd, RootDeviceEnvironment &rootDeviceEnvironment) : Drm(fd, rootDeviceEnvironment), gpuTimestamp(0){};
|
||||
DrmNullDevice(std::unique_ptr<HwDeviceId> hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::move(hwDeviceId), rootDeviceEnvironment), gpuTimestamp(0){};
|
||||
|
||||
protected:
|
||||
uint64_t gpuTimestamp;
|
||||
|
||||
22
core/os_interface/linux/hw_device_id.h
Normal file
22
core/os_interface/linux/hw_device_id.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "core/helpers/non_copyable_or_moveable.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class HwDeviceId : NonCopyableClass {
|
||||
public:
|
||||
HwDeviceId(int fileDescriptorIn) : fileDescriptor(fileDescriptorIn) {}
|
||||
~HwDeviceId();
|
||||
constexpr int getFileDescriptor() const { return fileDescriptor; }
|
||||
|
||||
protected:
|
||||
const int fileDescriptor;
|
||||
};
|
||||
} // namespace NEO
|
||||
17
core/os_interface/linux/hw_device_id_linux.cpp
Normal file
17
core/os_interface/linux/hw_device_id_linux.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/os_interface/linux/hw_device_id.h"
|
||||
#include "core/os_interface/linux/sys_calls.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
HwDeviceId::~HwDeviceId() {
|
||||
SysCalls::close(fileDescriptor);
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
14
core/os_interface/linux/sys_calls.h
Normal file
14
core/os_interface/linux/sys_calls.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace NEO {
|
||||
namespace SysCalls {
|
||||
int close(int fileDescriptor);
|
||||
}
|
||||
} // namespace NEO
|
||||
18
core/os_interface/linux/sys_calls_linux.cpp
Normal file
18
core/os_interface/linux/sys_calls_linux.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/os_interface/linux/sys_calls.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
namespace NEO {
|
||||
namespace SysCalls {
|
||||
int close(int fileDescriptor) {
|
||||
return ::close(fileDescriptor);
|
||||
}
|
||||
} // namespace SysCalls
|
||||
} // namespace NEO
|
||||
Reference in New Issue
Block a user