mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
Moving getPciPath out of os interface
Signed-off-by: Jaroslaw Chodor <jaroslaw.chodor@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
2b3b47b495
commit
8ca347f836
@@ -57,6 +57,8 @@ set(NEO_CORE_OS_INTERFACE_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_thread_linux.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_time_linux.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_time_linux.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/pci_path.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/pci_path.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/page_table_manager_functions.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/print.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/settings_reader_create.cpp
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "shared/source/os_interface/linux/hw_device_id.h"
|
||||
#include "shared/source/os_interface/linux/os_inc.h"
|
||||
#include "shared/source/os_interface/linux/os_interface.h"
|
||||
#include "shared/source/os_interface/linux/pci_path.h"
|
||||
#include "shared/source/os_interface/linux/sys_calls.h"
|
||||
#include "shared/source/os_interface/linux/system_info.h"
|
||||
#include "shared/source/os_interface/os_environment.h"
|
||||
@@ -399,7 +400,7 @@ std::vector<std::unique_ptr<HwDeviceId>> OSInterface::discoverDevices(ExecutionE
|
||||
std::string path = std::string(pathPrefix) + std::to_string(i + startNum);
|
||||
int fileDescriptor = SysCalls::open(path.c_str(), O_RDWR);
|
||||
|
||||
auto pciPath = OSInterface::OSInterfaceImpl::getPciPath(fileDescriptor);
|
||||
auto pciPath = NEO::getPciPath(fileDescriptor);
|
||||
|
||||
appendHwDeviceId(hwDeviceIds, fileDescriptor, pciPath.value_or("00:02.0").c_str());
|
||||
if (!hwDeviceIds.empty() && hwDeviceIds.size() == numRootDevices) {
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
#include "shared/source/os_interface/linux/drm_neo.h"
|
||||
#include "shared/source/os_interface/linux/sys_calls.h"
|
||||
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
#include <sys/stat.h>
|
||||
#include <system_error>
|
||||
#include <unistd.h>
|
||||
@@ -78,29 +76,4 @@ bool RootDeviceEnvironment::initOsInterface(std::unique_ptr<HwDeviceId> &&hwDevi
|
||||
return true;
|
||||
}
|
||||
|
||||
std::optional<std::string> OSInterface::OSInterfaceImpl::getPciPath(int deviceFd) {
|
||||
char path[256] = {0};
|
||||
size_t pathlen = 256;
|
||||
|
||||
if (SysCalls::getDevicePath(deviceFd, path, pathlen)) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (SysCalls::access(path, F_OK)) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
int readLinkSize = 0;
|
||||
char devicePath[256] = {0};
|
||||
readLinkSize = SysCalls::readlink(path, devicePath, pathlen);
|
||||
|
||||
if (readLinkSize == -1) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::string_view devicePathView(devicePath, static_cast<size_t>(readLinkSize));
|
||||
devicePathView = devicePathView.substr(devicePathView.find("/drm/render") - 7u, 7u);
|
||||
|
||||
return std::string(devicePathView);
|
||||
}
|
||||
} // namespace NEO
|
||||
|
||||
@@ -27,8 +27,6 @@ class OSInterface::OSInterfaceImpl {
|
||||
|
||||
bool isDebugAttachAvailable() const;
|
||||
|
||||
static std::optional<std::string> getPciPath(int deviceFd);
|
||||
|
||||
protected:
|
||||
std::unique_ptr<Drm> drm;
|
||||
};
|
||||
|
||||
41
shared/source/os_interface/linux/pci_path.cpp
Normal file
41
shared/source/os_interface/linux/pci_path.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/os_interface/linux/pci_path.h"
|
||||
|
||||
#include "shared/source/os_interface/linux/sys_calls.h"
|
||||
|
||||
#include <string_view>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace NEO {
|
||||
std::optional<std::string> getPciPath(int deviceFd) {
|
||||
char path[256] = {0};
|
||||
size_t pathlen = 256;
|
||||
|
||||
if (SysCalls::getDevicePath(deviceFd, path, pathlen)) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (SysCalls::access(path, F_OK)) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
int readLinkSize = 0;
|
||||
char devicePath[256] = {0};
|
||||
readLinkSize = SysCalls::readlink(path, devicePath, pathlen);
|
||||
|
||||
if (readLinkSize == -1) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::string_view devicePathView(devicePath, static_cast<size_t>(readLinkSize));
|
||||
devicePathView = devicePathView.substr(devicePathView.find("/drm/render") - 7u, 7u);
|
||||
|
||||
return std::string(devicePathView);
|
||||
}
|
||||
} // namespace NEO
|
||||
17
shared/source/os_interface/linux/pci_path.h
Normal file
17
shared/source/os_interface/linux/pci_path.h
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
std::optional<std::string> getPciPath(int deviceFd);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user