diff --git a/shared/source/os_interface/linux/drm_neo.cpp b/shared/source/os_interface/linux/drm_neo.cpp index a73509faee..06f95df368 100644 --- a/shared/source/os_interface/linux/drm_neo.cpp +++ b/shared/source/os_interface/linux/drm_neo.cpp @@ -465,6 +465,38 @@ uint32_t Drm::getVirtualMemoryAddressSpace(uint32_t vmId) { return 0; } +bool Drm::translateTopologyInfo(const drm_i915_query_topology_info *queryTopologyInfo, int &sliceCount, int &subSliceCount, int &euCount) { + sliceCount = 0; + subSliceCount = 0; + euCount = 0; + + for (int x = 0; x < queryTopologyInfo->max_slices; x++) { + bool isSliceEnable = (queryTopologyInfo->data[x / 8] >> (x % 8)) & 1; + if (!isSliceEnable) { + continue; + } + sliceCount++; + for (int y = 0; y < queryTopologyInfo->max_subslices; y++) { + size_t yOffset = (queryTopologyInfo->subslice_offset + x * queryTopologyInfo->subslice_stride + y / 8); + bool isSubSliceEnabled = (queryTopologyInfo->data[yOffset] >> (y % 8)) & 1; + if (!isSubSliceEnabled) { + continue; + } + subSliceCount++; + for (int z = 0; z < queryTopologyInfo->max_eus_per_subslice; z++) { + size_t zOffset = (queryTopologyInfo->eu_offset + (x * queryTopologyInfo->max_subslices + y) * queryTopologyInfo->eu_stride + z / 8); + bool isEUEnabled = (queryTopologyInfo->data[zOffset] >> (z % 8)) & 1; + if (!isEUEnabled) { + continue; + } + euCount++; + } + } + } + + return (sliceCount && subSliceCount && euCount); +} + Drm::~Drm() { destroyVirtualMemoryAddressSpace(); } diff --git a/shared/source/os_interface/linux/drm_neo.h b/shared/source/os_interface/linux/drm_neo.h index ed885643ab..13fb9a5de1 100644 --- a/shared/source/os_interface/linux/drm_neo.h +++ b/shared/source/os_interface/linux/drm_neo.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2020 Intel Corporation + * Copyright (C) 2017-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -161,6 +161,7 @@ class Drm { protected: int getQueueSliceCount(drm_i915_gem_context_param_sseu *sseu); + bool translateTopologyInfo(const drm_i915_query_topology_info *queryTopologyInfo, int &sliceCount, int &subSliceCount, int &euCount); std::string generateUUID(); std::string generateElfUUID(const void *data); bool sliceCountChangeSupported = false; diff --git a/shared/source/os_interface/linux/drm_query_extended.cpp b/shared/source/os_interface/linux/drm_query_extended.cpp index 638f9f40a0..c88de1d2f8 100644 --- a/shared/source/os_interface/linux/drm_query_extended.cpp +++ b/shared/source/os_interface/linux/drm_query_extended.cpp @@ -20,33 +20,7 @@ bool Drm::queryTopology(int &sliceCount, int &subSliceCount, int &euCount) { return false; } - sliceCount = 0; - subSliceCount = 0; - euCount = 0; - - for (int x = 0; x < data->max_slices; x++) { - bool isSliceEnable = (data->data[x / 8] >> (x % 8)) & 1; - if (!isSliceEnable) { - continue; - } - sliceCount++; - for (int y = 0; y < data->max_subslices; y++) { - bool isSubSliceEnabled = (data->data[data->subslice_offset + x * data->subslice_stride + y / 8] >> (y % 8)) & 1; - if (!isSubSliceEnabled) { - continue; - } - subSliceCount++; - for (int z = 0; z < data->max_eus_per_subslice; z++) { - bool isEUEnabled = (data->data[data->eu_offset + (x * data->max_subslices + y) * data->eu_stride + z / 8] >> (z % 8)) & 1; - if (!isEUEnabled) { - continue; - } - euCount++; - } - } - } - - return (sliceCount && subSliceCount && euCount); + return translateTopologyInfo(data, sliceCount, subSliceCount, euCount); } } // namespace NEO