2021-05-21 01:49:44 +08:00
|
|
|
/*
|
2024-05-24 19:50:30 +08:00
|
|
|
* Copyright (C) 2018-2024 Intel Corporation
|
2021-05-21 01:49:44 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "shared/source/os_interface/linux/device_time_drm.h"
|
|
|
|
|
2024-05-28 19:12:18 +08:00
|
|
|
#include "shared/source/debug_settings/debug_settings_manager.h"
|
2022-02-01 22:49:57 +08:00
|
|
|
#include "shared/source/helpers/register_offsets.h"
|
2021-05-21 01:49:44 +08:00
|
|
|
#include "shared/source/os_interface/linux/drm_neo.h"
|
2022-05-18 01:16:13 +08:00
|
|
|
#include "shared/source/os_interface/linux/drm_wrappers.h"
|
2023-01-23 22:55:52 +08:00
|
|
|
#include "shared/source/os_interface/linux/ioctl_helper.h"
|
2021-05-21 07:17:57 +08:00
|
|
|
#include "shared/source/os_interface/os_interface.h"
|
2021-05-21 01:49:44 +08:00
|
|
|
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
|
2023-10-18 16:00:43 +08:00
|
|
|
DeviceTimeDrm::DeviceTimeDrm(OSInterface &osInterface) {
|
|
|
|
pDrm = osInterface.getDriverModel()->as<Drm>();
|
2021-05-21 01:49:44 +08:00
|
|
|
}
|
|
|
|
|
2023-10-18 16:00:43 +08:00
|
|
|
bool DeviceTimeDrm::getGpuCpuTimeImpl(TimeStampData *pGpuCpuTime, OSTime *osTime) {
|
2023-09-18 18:49:16 +08:00
|
|
|
return pDrm->getIoctlHelper()->setGpuCpuTimes(pGpuCpuTime, osTime);
|
2021-05-21 01:49:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
double DeviceTimeDrm::getDynamicDeviceTimerResolution(HardwareInfo const &hwInfo) const {
|
|
|
|
if (pDrm) {
|
|
|
|
int frequency = 0;
|
|
|
|
|
2021-06-25 20:28:28 +08:00
|
|
|
auto error = pDrm->getTimestampFrequency(frequency);
|
2021-05-21 01:49:44 +08:00
|
|
|
if (!error) {
|
2023-09-18 18:49:16 +08:00
|
|
|
return nanosecondsPerSecond / frequency;
|
2021-05-21 01:49:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return OSTime::getDeviceTimerResolution(hwInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t DeviceTimeDrm::getDynamicDeviceTimerClock(HardwareInfo const &hwInfo) const {
|
2023-09-18 18:49:16 +08:00
|
|
|
|
2021-05-21 01:49:44 +08:00
|
|
|
if (pDrm) {
|
|
|
|
int frequency = 0;
|
|
|
|
|
2021-06-25 20:28:28 +08:00
|
|
|
auto error = pDrm->getTimestampFrequency(frequency);
|
2021-05-21 01:49:44 +08:00
|
|
|
if (!error) {
|
|
|
|
return static_cast<uint64_t>(frequency);
|
|
|
|
}
|
|
|
|
}
|
2023-09-18 18:49:16 +08:00
|
|
|
return static_cast<uint64_t>(nanosecondsPerSecond / OSTime::getDeviceTimerResolution(hwInfo));
|
2021-05-21 01:49:44 +08:00
|
|
|
}
|
|
|
|
|
2024-05-28 19:12:18 +08:00
|
|
|
bool DeviceTimeDrm::isTimestampsRefreshEnabled() const {
|
|
|
|
bool timestampsRefreshEnabled = false;
|
|
|
|
if (debugManager.flags.EnableReusingGpuTimestamps.get() != -1) {
|
|
|
|
timestampsRefreshEnabled = debugManager.flags.EnableReusingGpuTimestamps.get();
|
|
|
|
}
|
|
|
|
return timestampsRefreshEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace NEO
|