2022-05-04 22:10:46 +00:00
|
|
|
/*
|
2025-02-18 11:40:06 +00:00
|
|
|
* Copyright (C) 2022-2025 Intel Corporation
|
2022-05-04 22:10:46 +00:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2024-03-15 13:14:45 +00:00
|
|
|
#include "shared/source/debug_settings/debug_settings_manager.h"
|
2022-05-04 22:10:46 +00:00
|
|
|
#include "shared/source/execution_environment/execution_environment.h"
|
2023-07-11 10:55:25 +00:00
|
|
|
#include "shared/source/execution_environment/root_device_environment.h"
|
|
|
|
|
#include "shared/source/os_interface/linux/drm_memory_operations_handler.h"
|
2025-04-08 22:05:33 +00:00
|
|
|
#include "shared/source/os_interface/linux/drm_neo.h"
|
2024-03-15 13:14:45 +00:00
|
|
|
#include "shared/source/os_interface/linux/file_descriptor.h"
|
2025-04-08 22:05:33 +00:00
|
|
|
#include "shared/source/os_interface/linux/ioctl_helper.h"
|
|
|
|
|
#include "shared/source/os_interface/os_interface.h"
|
2024-03-15 13:14:45 +00:00
|
|
|
#include "shared/source/utilities/directory.h"
|
2022-05-04 22:10:46 +00:00
|
|
|
|
2024-03-15 13:14:45 +00:00
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <unistd.h>
|
2022-05-04 22:10:46 +00:00
|
|
|
namespace NEO {
|
|
|
|
|
|
2023-07-11 10:55:25 +00:00
|
|
|
void ExecutionEnvironment::adjustRootDeviceEnvironments() {
|
|
|
|
|
for (auto rootDeviceIndex = 0u; rootDeviceIndex < rootDeviceEnvironments.size(); rootDeviceIndex++) {
|
|
|
|
|
auto drmMemoryOperationsHandler = static_cast<DrmMemoryOperationsHandler *>(rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface.get());
|
|
|
|
|
drmMemoryOperationsHandler->setRootDeviceIndex(rootDeviceIndex);
|
|
|
|
|
}
|
2022-05-04 22:10:46 +00:00
|
|
|
}
|
2024-03-15 13:14:45 +00:00
|
|
|
|
|
|
|
|
void ExecutionEnvironment::configureCcsMode() {
|
|
|
|
|
const auto &ccsString = debugManager.flags.ZEX_NUMBER_OF_CCS.get();
|
|
|
|
|
|
|
|
|
|
if (ccsString.compare("default") == 0 ||
|
|
|
|
|
ccsString.empty()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *endPtr = nullptr;
|
|
|
|
|
uint32_t ccsMode = static_cast<uint32_t>(std::strtoul(ccsString.c_str(), &endPtr, 10));
|
|
|
|
|
if (endPtr == ccsString.c_str()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const std::string drmPath = "/sys/class/drm";
|
2025-02-18 11:40:06 +00:00
|
|
|
const std::string expectedFilePrefix = drmPath + "/card";
|
2024-03-15 13:14:45 +00:00
|
|
|
auto files = Directory::getFiles(drmPath.c_str());
|
2025-04-08 22:05:33 +00:00
|
|
|
for (auto rootDeviceIndex = 0u; rootDeviceIndex < rootDeviceEnvironments.size(); rootDeviceIndex++) {
|
|
|
|
|
auto drm = rootDeviceEnvironments[rootDeviceIndex]->osInterface->getDriverModel()->as<NEO::Drm>();
|
|
|
|
|
auto ioctlHelper = drm->getIoctlHelper();
|
|
|
|
|
auto files = Directory::getFiles(drmPath.c_str());
|
|
|
|
|
ioctlHelper->configureCcsMode(files, expectedFilePrefix, ccsMode, deviceCcsModeVec);
|
2024-03-15 13:14:45 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExecutionEnvironment::restoreCcsMode() {
|
|
|
|
|
for (auto &[ccsFile, ccsMode] : deviceCcsModeVec) {
|
|
|
|
|
auto fd = FileDescriptor(ccsFile.c_str(), O_WRONLY);
|
|
|
|
|
DEBUG_BREAK_IF(fd < 0);
|
|
|
|
|
if (fd > 0) {
|
|
|
|
|
[[maybe_unused]] auto ret = SysCalls::write(fd, &ccsMode, sizeof(uint32_t));
|
|
|
|
|
DEBUG_BREAK_IF(ret < 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
deviceCcsModeVec.clear();
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-04 22:10:46 +00:00
|
|
|
} // namespace NEO
|