2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2025-01-28 12:37:29 +00:00
|
|
|
* Copyright (C) 2020-2025 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2023-11-27 13:47:52 +00:00
|
|
|
#include "shared/source/debug_settings/debug_settings_manager.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/execution_environment/root_device_environment.h"
|
2025-09-18 15:37:03 +00:00
|
|
|
#include "shared/source/helpers/aligned_memory.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/os_interface/linux/drm_memory_operations_handler.h"
|
|
|
|
|
#include "shared/source/os_interface/linux/drm_neo.h"
|
2021-12-13 18:47:36 +00:00
|
|
|
#include "shared/source/os_interface/linux/hw_device_id.h"
|
2023-03-10 12:28:11 +00:00
|
|
|
#include "shared/source/os_interface/product_helper.h"
|
2021-03-29 13:43:50 +02:00
|
|
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
#include <system_error>
|
|
|
|
|
#include <unistd.h>
|
2020-02-11 17:48:40 +01:00
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
bool OSInterface::osEnabled64kbPages = false;
|
2020-09-22 16:29:34 +02:00
|
|
|
bool OSInterface::newResourceImplicitFlush = true;
|
|
|
|
|
bool OSInterface::gpuIdleImplicitFlush = true;
|
2021-05-19 20:12:09 +00:00
|
|
|
bool OSInterface::requiresSupportForWddmTrimNotification = false;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2021-05-21 01:17:57 +02:00
|
|
|
bool OSInterface::isDebugAttachAvailable() const {
|
2023-12-13 16:09:52 +00:00
|
|
|
if (driverModel && driverModel->getDriverModelType() == DriverModelType::drm) {
|
2021-05-21 01:17:57 +02:00
|
|
|
return driverModel->as<Drm>()->isDebugAttachAvailable();
|
2021-02-23 17:57:27 +00:00
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-14 11:27:22 +00:00
|
|
|
bool OSInterface::isLockablePointer(bool isLockable) const {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-27 19:44:47 +02:00
|
|
|
bool initDrmOsInterface(std::unique_ptr<HwDeviceId> &&hwDeviceId, uint32_t rootDeviceIndex,
|
2021-12-13 18:47:36 +00:00
|
|
|
RootDeviceEnvironment *rootDeviceEnv) {
|
2021-05-27 19:44:47 +02:00
|
|
|
auto hwDeviceIdDrm = std::unique_ptr<HwDeviceIdDrm>(reinterpret_cast<HwDeviceIdDrm *>(hwDeviceId.release()));
|
|
|
|
|
|
|
|
|
|
Drm *drm = Drm::create(std::move(hwDeviceIdDrm), *rootDeviceEnv);
|
2020-02-13 13:26:40 +01:00
|
|
|
if (!drm) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-13 18:47:36 +00:00
|
|
|
auto &dstOsInterface = rootDeviceEnv->osInterface;
|
2021-05-27 19:44:47 +02:00
|
|
|
dstOsInterface.reset(new OSInterface());
|
|
|
|
|
dstOsInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
|
|
|
|
|
auto hardwareInfo = rootDeviceEnv->getMutableHardwareInfo();
|
2022-11-14 14:52:40 +00:00
|
|
|
auto &productHelper = rootDeviceEnv->getHelper<ProductHelper>();
|
|
|
|
|
if (productHelper.configureHwInfoDrm(hardwareInfo, hardwareInfo, *rootDeviceEnv)) {
|
2020-02-13 13:26:40 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
2023-11-27 13:47:52 +00:00
|
|
|
|
2024-04-09 12:43:12 +00:00
|
|
|
const bool isCsrHwWithAub = obtainCsrTypeFromIntegerValue(debugManager.flags.SetCommandStreamReceiver.get(), CommandStreamReceiverType::hardware) == CommandStreamReceiverType::hardwareWithAub;
|
2023-11-27 13:47:52 +00:00
|
|
|
rootDeviceEnv->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, rootDeviceIndex, isCsrHwWithAub);
|
2021-07-21 08:47:43 +00:00
|
|
|
|
2020-02-13 13:26:40 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
2021-03-29 13:43:50 +02:00
|
|
|
|
2025-09-18 15:37:03 +00:00
|
|
|
bool OSInterface::isSizeWithinThresholdForStaging(const void *ptr, size_t size) const {
|
|
|
|
|
if (isAligned<MemoryConstants::pageSize2M>(ptr)) {
|
|
|
|
|
return size < 64 * MemoryConstants::megaByte;
|
|
|
|
|
}
|
|
|
|
|
return size < 512 * MemoryConstants::megaByte;
|
2025-02-04 10:24:31 +00:00
|
|
|
}
|
|
|
|
|
|
2025-01-31 15:26:12 +00:00
|
|
|
uint32_t OSInterface::getAggregatedProcessCount() const {
|
|
|
|
|
if (driverModel && driverModel->getDriverModelType() == DriverModelType::drm) {
|
|
|
|
|
return driverModel->as<Drm>()->getAggregatedProcessCount();
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-17 07:14:36 +00:00
|
|
|
void OSInterface::registerTrimCallback() {}
|
|
|
|
|
void OSInterface::unregisterTrimCallback() {}
|
|
|
|
|
|
2019-08-21 10:53:07 +02:00
|
|
|
} // namespace NEO
|