mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-29 00:58:39 +08:00
Fallback into legacy IOCTLs in case of incorrect topology data
Change-Id: Ibf0a3885729ab6cf5888534677ff73b875d142c1 Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
2762ad7121
commit
240b97706f
@@ -7,6 +7,9 @@
|
||||
|
||||
#include "opencl/test/unit_test/os_interface/linux/drm_mock.h"
|
||||
|
||||
#include "shared/source/execution_environment/root_device_environment.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
const int DrmMock::mockFd;
|
||||
@@ -164,9 +167,13 @@ int DrmMock::ioctl(unsigned long request, void *arg) {
|
||||
if (request == DRM_IOCTL_I915_QUERY && arg != nullptr) {
|
||||
auto queryArg = static_cast<drm_i915_query *>(arg);
|
||||
auto queryItemArg = reinterpret_cast<drm_i915_query_item *>(queryArg->items_ptr);
|
||||
|
||||
auto realEuCount = rootDeviceEnvironment.getHardwareInfo()->gtSystemInfo.EUCount;
|
||||
auto dataSize = std::ceil(realEuCount / 8.0);
|
||||
|
||||
if (queryItemArg->length == 0) {
|
||||
if (queryItemArg->query_id == DRM_I915_QUERY_TOPOLOGY_INFO) {
|
||||
queryItemArg->length = sizeof(drm_i915_query_topology_info) + std::ceil(this->StoredEUVal / 8.0);
|
||||
queryItemArg->length = sizeof(drm_i915_query_topology_info) + dataSize;
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
@@ -176,13 +183,15 @@ int DrmMock::ioctl(unsigned long request, void *arg) {
|
||||
return -1;
|
||||
}
|
||||
topologyArg->max_slices = this->StoredSVal;
|
||||
topologyArg->max_subslices = this->StoredSSVal / this->StoredSVal;
|
||||
topologyArg->max_eus_per_subslice = this->StoredEUVal / this->StoredSSVal;
|
||||
topologyArg->max_subslices = this->StoredSVal ? (this->StoredSSVal / this->StoredSVal) : 0;
|
||||
topologyArg->max_eus_per_subslice = this->StoredSSVal ? (this->StoredEUVal / this->StoredSSVal) : 0;
|
||||
|
||||
if (this->disableSomeTopology) {
|
||||
memset(topologyArg->data, 0xCA, std::ceil(this->StoredEUVal / 8.0));
|
||||
memset(topologyArg->data, 0xCA, dataSize);
|
||||
} else {
|
||||
memset(topologyArg->data, 0xFF, std::ceil(this->StoredEUVal / 8.0));
|
||||
memset(topologyArg->data, 0xFF, dataSize);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,6 +258,42 @@ TEST_F(HwInfoConfigTestLinuxDummy, whenFailGettingTopologyThenFallbackToEuCountI
|
||||
EXPECT_NE(-1, ret);
|
||||
}
|
||||
|
||||
TEST_F(HwInfoConfigTestLinuxDummy, givenInvalidTopologyDataWhenConfiguringThenReturnError) {
|
||||
auto storedSVal = drm->StoredSVal;
|
||||
auto storedSSVal = drm->StoredSSVal;
|
||||
auto storedEUVal = drm->StoredEUVal;
|
||||
|
||||
{
|
||||
// 0 euCount
|
||||
drm->StoredSVal = storedSVal;
|
||||
drm->StoredSSVal = storedSSVal;
|
||||
drm->StoredEUVal = 0;
|
||||
|
||||
int sliceCount, subSliceCount, euCount;
|
||||
EXPECT_FALSE(drm->queryTopology(sliceCount, subSliceCount, euCount));
|
||||
}
|
||||
|
||||
{
|
||||
// 0 subSliceCount
|
||||
drm->StoredSVal = storedSVal;
|
||||
drm->StoredSSVal = 0;
|
||||
drm->StoredEUVal = storedEUVal;
|
||||
|
||||
int sliceCount, subSliceCount, euCount;
|
||||
EXPECT_FALSE(drm->queryTopology(sliceCount, subSliceCount, euCount));
|
||||
}
|
||||
|
||||
{
|
||||
// 0 sliceCount
|
||||
drm->StoredSVal = 0;
|
||||
drm->StoredSSVal = storedSSVal;
|
||||
drm->StoredEUVal = storedEUVal;
|
||||
|
||||
int sliceCount, subSliceCount, euCount;
|
||||
EXPECT_FALSE(drm->queryTopology(sliceCount, subSliceCount, euCount));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(HwInfoConfigTestLinuxDummy, dummyNegativeFailingConfigureCustom) {
|
||||
drm->StoredDeviceID = 10;
|
||||
|
||||
|
||||
@@ -402,7 +402,7 @@ bool Drm::queryTopology(int &sliceCount, int &subSliceCount, int &euCount) {
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return (sliceCount && subSliceCount && euCount);
|
||||
}
|
||||
|
||||
Drm::~Drm() = default;
|
||||
|
||||
Reference in New Issue
Block a user