mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-09 22:43:00 +08:00
Metrics: Fix potential divide by zero
- return error when frequency is zero Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
5f5a1a6f81
commit
bcbe3278a9
@@ -55,7 +55,7 @@ ze_result_t MetricIpSamplingLinuxImp::getNearestSupportedSamplingUnit(uint32_t &
|
||||
const auto drm = device.getOsInterface().getDriverModel()->as<NEO::Drm>();
|
||||
int32_t gpuTimeStampfrequency = 0;
|
||||
int32_t ret = drm->getTimestampFrequency(gpuTimeStampfrequency);
|
||||
if (ret < 0) {
|
||||
if (ret < 0 || gpuTimeStampfrequency == 0) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
@@ -155,6 +155,15 @@ HWTEST2_F(MetricIpSamplingLinuxTestPrelim, givenGetTimestampFrequencyFailsWhenSt
|
||||
EXPECT_EQ(metricIpSamplingOsInterface->startMeasurement(notifyEveryNReports, samplingPeriodNs), ZE_RESULT_ERROR_UNKNOWN);
|
||||
}
|
||||
|
||||
HWTEST2_F(MetricIpSamplingLinuxTestPrelim, givenGetTimestampFrequencyReturnsFrequencyEqualZeroWhenStartMeasurementIsCalledThenReturnFailure, IsPVC) {
|
||||
|
||||
auto drm = static_cast<DrmPrelimMock *>(device->getOsInterface().getDriverModel()->as<NEO::Drm>());
|
||||
VariableBackup<int> backupCsTimeStampFrequency(&drm->storedCsTimestampFrequency, 0);
|
||||
|
||||
uint32_t notifyEveryNReports = 0, samplingPeriodNs = 10000;
|
||||
EXPECT_EQ(metricIpSamplingOsInterface->startMeasurement(notifyEveryNReports, samplingPeriodNs), ZE_RESULT_ERROR_UNKNOWN);
|
||||
}
|
||||
|
||||
HWTEST2_F(MetricIpSamplingLinuxTestPrelim, givenIoctlI915PerfOpenFailsWhenStartMeasurementIsCalledThenReturnFailure, IsPVC) {
|
||||
|
||||
uint32_t notifyEveryNReports = 0, samplingPeriodNs = 10000;
|
||||
|
||||
Reference in New Issue
Block a user