From 604f2c625e6aa8693cec89eedcd4aea3912dd598 Mon Sep 17 00:00:00 2001 From: Bellekallu Rajkiran Date: Fri, 11 Mar 2022 06:20:23 +0000 Subject: [PATCH] Sysman: Utilize Ioctl helpers for memory module Memory module translates memory regions without any runtime query on underlying hardware/kernel. Use ioctl helpers for memory region translation. Related-To: LOCI-3006 Signed-off-by: Bellekallu Rajkiran --- .../sysman/memory/linux/os_memory_imp_prelim.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/level_zero/tools/source/sysman/memory/linux/os_memory_imp_prelim.cpp b/level_zero/tools/source/sysman/memory/linux/os_memory_imp_prelim.cpp index 8e171d9cf3..c41cf76e37 100644 --- a/level_zero/tools/source/sysman/memory/linux/os_memory_imp_prelim.cpp +++ b/level_zero/tools/source/sysman/memory/linux/os_memory_imp_prelim.cpp @@ -222,23 +222,22 @@ ze_result_t LinuxMemoryImp::getState(zes_mem_state_t *pState) { } } + std::vector deviceRegions; auto memRegions = pDrm->getMemoryRegions(); if (memRegions.empty()) { return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; } - prelim_drm_i915_query_memory_regions *data = reinterpret_cast(memRegions.data()); - - std::vector deviceRegions; - for (uint32_t regionIndex = 0; regionIndex < data->num_regions; regionIndex++) { - if (data->regions[regionIndex].region.memory_class == PRELIM_I915_MEMORY_CLASS_DEVICE) { - deviceRegions.push_back(data->regions[regionIndex]); + auto regions = pDrm->getIoctlHelper()->translateToMemoryRegions(memRegions); + for (auto region : regions) { + if (region.region.memoryClass == I915_MEMORY_CLASS_DEVICE) { + deviceRegions.push_back(region); } } UNRECOVERABLE_IF(deviceRegions.size() <= subdeviceId); - pState->free = deviceRegions[subdeviceId].unallocated_size; - pState->size = deviceRegions[subdeviceId].probed_size; + pState->free = deviceRegions[subdeviceId].unallocatedSize; + pState->size = deviceRegions[subdeviceId].probedSize; return ZE_RESULT_SUCCESS; }