mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 07:14:10 +08:00
feature(sysman): Added sysfs filenames for the memory module
- The sysfs filenames have been added in the sysfsNameToFileMap of the SysmanKmdInterface classes. - The functions returning the sysfs filenames have been removed from the shared directory. - The ULTs have been added to return the sysfs filenames. Related-To: LOCI-4699 Signed-off-by: Bari, Pratik <pratik.bari@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
e6b0930657
commit
3f083360a2
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "level_zero/sysman/source/firmware_util/sysman_firmware_util.h"
|
||||
#include "level_zero/sysman/source/linux/zes_os_sysman_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_kmd_interface.h"
|
||||
#include "level_zero/sysman/source/sysman_const.h"
|
||||
|
||||
#include "drm/intel_hwconfig_types.h"
|
||||
@@ -33,6 +34,7 @@ LinuxMemoryImp::LinuxMemoryImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint3
|
||||
pDevice = pLinuxSysmanImp->getSysmanDeviceImp();
|
||||
pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
|
||||
pPmt = pLinuxSysmanImp->getPlatformMonitoringTechAccess(subdeviceId);
|
||||
pSysmanKmdInterface = pLinuxSysmanImp->getSysmanKmdInterface();
|
||||
}
|
||||
|
||||
bool LinuxMemoryImp::isMemoryModuleSupported() {
|
||||
@@ -78,7 +80,7 @@ ze_result_t LinuxMemoryImp::getProperties(zes_mem_properties_t *pProperties) {
|
||||
pProperties->physicalSize = 0;
|
||||
if (isSubdevice) {
|
||||
std::string memval;
|
||||
physicalSizeFile = pDrm->getIoctlHelper()->getFileForMemoryAddrRange(subdeviceId);
|
||||
physicalSizeFile = pSysmanKmdInterface->getSysfsFilePathForPhysicalMemorySize(subdeviceId);
|
||||
ze_result_t result = pSysfsAccess->read(physicalSizeFile, memval);
|
||||
uint64_t intval = strtoull(memval.c_str(), nullptr, 16);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
@@ -157,7 +159,7 @@ void LinuxMemoryImp::getHbmFrequency(PRODUCT_FAMILY productFamily, unsigned shor
|
||||
hbmFrequency = 0;
|
||||
if (productFamily == IGFX_PVC) {
|
||||
if (stepping >= REVISION_B) {
|
||||
const std::string hbmRP0FreqFile = pDrm->getIoctlHelper()->getFileForMaxMemoryFrequencyOfSubDevice(subdeviceId);
|
||||
const std::string hbmRP0FreqFile = pSysmanKmdInterface->getSysfsFilePath(SysfsName::sysfsNameMaxMemoryFrequency, subdeviceId, true);
|
||||
uint64_t hbmFreqValue = 0;
|
||||
ze_result_t result = pSysfsAccess->read(hbmRP0FreqFile, hbmFreqValue);
|
||||
if (ZE_RESULT_SUCCESS == result) {
|
||||
|
||||
@@ -23,6 +23,8 @@ class SysfsAccess;
|
||||
struct Device;
|
||||
class PlatformMonitoringTech;
|
||||
class LinuxSysmanImp;
|
||||
class SysmanKmdInterface;
|
||||
|
||||
class LinuxMemoryImp : public OsMemory, NEO::NonCopyableOrMovableClass {
|
||||
public:
|
||||
ze_result_t getProperties(zes_mem_properties_t *pProperties) override;
|
||||
@@ -39,6 +41,7 @@ class LinuxMemoryImp : public OsMemory, NEO::NonCopyableOrMovableClass {
|
||||
NEO::Drm *pDrm = nullptr;
|
||||
SysmanDeviceImp *pDevice = nullptr;
|
||||
PlatformMonitoringTech *pPmt = nullptr;
|
||||
SysmanKmdInterface *pSysmanKmdInterface = nullptr;
|
||||
void getHbmFrequency(PRODUCT_FAMILY productFamily, unsigned short stepping, uint64_t &hbmFrequency);
|
||||
|
||||
private:
|
||||
|
||||
@@ -63,6 +63,9 @@ void SysmanKmdInterfaceI915::initSysfsNameToFileMap(const PRODUCT_FAMILY product
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameDefaultPowerLimit] = std::make_pair("", "power1_rated_max");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameCriticalPowerLimit] = std::make_pair("", (productFamily == IGFX_PVC) ? "curr1_crit" : "power1_crit");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameStandbyModeControl] = std::make_pair("rc6_enable", "power/rc6_enable");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameMemoryAddressRange] = std::make_pair("addr_range", "");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameMaxMemoryFrequency] = std::make_pair("mem_RP0_freq_mhz", "");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameMinMemoryFrequency] = std::make_pair("mem_RPn_freq_mhz", "");
|
||||
}
|
||||
|
||||
void SysmanKmdInterfaceXe::initSysfsNameToFileMap(const PRODUCT_FAMILY productFamily) {
|
||||
@@ -87,6 +90,9 @@ void SysmanKmdInterfaceXe::initSysfsNameToFileMap(const PRODUCT_FAMILY productFa
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameEnergyCounterNode] = std::make_pair("", "energy1_input");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameDefaultPowerLimit] = std::make_pair("", "power1_rated_max");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameCriticalPowerLimit] = std::make_pair("", (productFamily == IGFX_PVC) ? "curr1_crit" : "power1_crit");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameMemoryAddressRange] = std::make_pair("physical_vram_size_bytes", "");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameMaxMemoryFrequency] = std::make_pair("freq_vram_rp0", "");
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameMinMemoryFrequency] = std::make_pair("freq_vram_rpn", "");
|
||||
}
|
||||
|
||||
std::string SysmanKmdInterfaceI915::getSysfsFilePath(SysfsName sysfsName, uint32_t subDeviceId, bool baseDirectoryExists) {
|
||||
@@ -99,6 +105,18 @@ std::string SysmanKmdInterfaceXe::getSysfsFilePath(SysfsName sysfsName, uint32_t
|
||||
return filePath;
|
||||
}
|
||||
|
||||
std::string SysmanKmdInterfaceI915::getSysfsFilePathForPhysicalMemorySize(uint32_t subDeviceId) {
|
||||
std::string filePathPhysicalMemorySize = getBasePath(subDeviceId) +
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameMemoryAddressRange].first;
|
||||
return filePathPhysicalMemorySize;
|
||||
}
|
||||
|
||||
std::string SysmanKmdInterfaceXe::getSysfsFilePathForPhysicalMemorySize(uint32_t subDeviceId) {
|
||||
std::string filePathPhysicalMemorySize = "device/tile" + std::to_string(subDeviceId) + "/" +
|
||||
sysfsNameToFileMap[SysfsName::sysfsNameMemoryAddressRange].first;
|
||||
return filePathPhysicalMemorySize;
|
||||
}
|
||||
|
||||
int64_t SysmanKmdInterfaceI915::getEngineActivityFd(zes_engine_group_t engineGroup, uint32_t engineInstance, uint32_t subDeviceId, PmuInterface *const &pPmuInterface) {
|
||||
uint64_t config = UINT64_MAX;
|
||||
switch (engineGroup) {
|
||||
|
||||
@@ -72,6 +72,9 @@ enum class SysfsName {
|
||||
sysfsNameDefaultPowerLimit,
|
||||
sysfsNameCriticalPowerLimit,
|
||||
sysfsNameStandbyModeControl,
|
||||
sysfsNameMemoryAddressRange,
|
||||
sysfsNameMaxMemoryFrequency,
|
||||
sysfsNameMinMemoryFrequency,
|
||||
};
|
||||
|
||||
class SysmanKmdInterface {
|
||||
@@ -81,6 +84,7 @@ class SysmanKmdInterface {
|
||||
|
||||
virtual std::string getBasePath(uint32_t subDeviceId) const = 0;
|
||||
virtual std::string getSysfsFilePath(SysfsName sysfsName, uint32_t subDeviceId, bool baseDirectoryExists) = 0;
|
||||
virtual std::string getSysfsFilePathForPhysicalMemorySize(uint32_t subDeviceId) = 0;
|
||||
virtual int64_t getEngineActivityFd(zes_engine_group_t engineGroup, uint32_t engineInstance, uint32_t subDeviceId, PmuInterface *const &pmuInterface) = 0;
|
||||
virtual std::string getHwmonName(uint32_t subDeviceId, bool isSubdevice) const = 0;
|
||||
virtual bool isStandbyModeControlAvailable() const = 0;
|
||||
@@ -93,6 +97,7 @@ class SysmanKmdInterfaceI915 : public SysmanKmdInterface {
|
||||
|
||||
std::string getBasePath(uint32_t subDeviceId) const override;
|
||||
std::string getSysfsFilePath(SysfsName sysfsName, uint32_t subDeviceId, bool baseDirectoryExists) override;
|
||||
std::string getSysfsFilePathForPhysicalMemorySize(uint32_t subDeviceId) override;
|
||||
int64_t getEngineActivityFd(zes_engine_group_t engineGroup, uint32_t engineInstance, uint32_t subDeviceId, PmuInterface *const &pmuInterface) override;
|
||||
std::string getHwmonName(uint32_t subDeviceId, bool isSubdevice) const override;
|
||||
bool isStandbyModeControlAvailable() const override { return true; }
|
||||
@@ -109,6 +114,7 @@ class SysmanKmdInterfaceXe : public SysmanKmdInterface {
|
||||
|
||||
std::string getBasePath(uint32_t subDeviceId) const override;
|
||||
std::string getSysfsFilePath(SysfsName sysfsName, uint32_t subDeviceId, bool baseDirectoryExists) override;
|
||||
std::string getSysfsFilePathForPhysicalMemorySize(uint32_t subDeviceId) override;
|
||||
int64_t getEngineActivityFd(zes_engine_group_t engineGroup, uint32_t engineInstance, uint32_t subDeviceId, PmuInterface *const &pmuInterface) override;
|
||||
std::string getHwmonName(uint32_t subDeviceId, bool isSubdevice) const override;
|
||||
bool isStandbyModeControlAvailable() const override { return false; }
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "level_zero/sysman/source/linux/pmt/sysman_pmt_xml_offsets.h"
|
||||
#include "level_zero/sysman/source/memory/linux/sysman_os_memory_imp_prelim.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_kmd_interface.h"
|
||||
#include "level_zero/sysman/source/sysman_const.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_fixture.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/memory/linux/mock_memory_prelim.h"
|
||||
@@ -97,6 +98,20 @@ class SysmanDeviceMemoryFixture : public SysmanDeviceFixture {
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(SysmanDeviceMemoryFixture, GivenKmdInterfaceWhenGettingSysfsFileNamesForI915VersionThenProperPathsAreReturned) {
|
||||
auto pSysmanKmdInterface = std::make_unique<SysmanKmdInterfaceI915>(productFamily);
|
||||
EXPECT_STREQ("gt/gt0/addr_range", pSysmanKmdInterface->getSysfsFilePathForPhysicalMemorySize(0).c_str());
|
||||
EXPECT_STREQ("gt/gt0/mem_RP0_freq_mhz", pSysmanKmdInterface->getSysfsFilePath(SysfsName::sysfsNameMaxMemoryFrequency, 0, true).c_str());
|
||||
EXPECT_STREQ("gt/gt0/mem_RPn_freq_mhz", pSysmanKmdInterface->getSysfsFilePath(SysfsName::sysfsNameMinMemoryFrequency, 0, true).c_str());
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceMemoryFixture, GivenKmdInterfaceWhenGettingSysfsFileNamesForXeVersionThenProperPathsAreReturned) {
|
||||
auto pSysmanKmdInterface = std::make_unique<SysmanKmdInterfaceXe>(productFamily);
|
||||
EXPECT_STREQ("device/tile0/physical_vram_size_bytes", pSysmanKmdInterface->getSysfsFilePathForPhysicalMemorySize(0).c_str());
|
||||
EXPECT_STREQ("device/tile0/gt0/freq_vram_rp0", pSysmanKmdInterface->getSysfsFilePath(SysfsName::sysfsNameMaxMemoryFrequency, 0, true).c_str());
|
||||
EXPECT_STREQ("device/tile0/gt0/freq_vram_rpn", pSysmanKmdInterface->getSysfsFilePath(SysfsName::sysfsNameMinMemoryFrequency, 0, true).c_str());
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceMemoryFixture, GivenComponentCountZeroWhenEnumeratingMemoryModulesWithLocalMemorySupportThenValidCountIsReturned) {
|
||||
setLocalSupportedAndReinit(true);
|
||||
|
||||
|
||||
@@ -34,12 +34,20 @@ void memoryGetTimeStamp(uint64_t ×tamp) {
|
||||
timestamp = std::chrono::duration_cast<std::chrono::microseconds>(ts.time_since_epoch()).count();
|
||||
}
|
||||
|
||||
void LinuxMemoryImp::init() {
|
||||
if (isSubdevice) {
|
||||
const std::string baseDir = "gt/gt" + std::to_string(subdeviceId) + "/";
|
||||
physicalSizeFile = baseDir + "addr_range";
|
||||
}
|
||||
}
|
||||
|
||||
LinuxMemoryImp::LinuxMemoryImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) : isSubdevice(onSubdevice), subdeviceId(subdeviceId) {
|
||||
pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
|
||||
pDrm = &pLinuxSysmanImp->getDrm();
|
||||
pDevice = pLinuxSysmanImp->getDeviceHandle();
|
||||
pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
|
||||
pPmt = pLinuxSysmanImp->getPlatformMonitoringTechAccess(subdeviceId);
|
||||
init();
|
||||
}
|
||||
|
||||
bool LinuxMemoryImp::isMemoryModuleSupported() {
|
||||
@@ -79,7 +87,6 @@ ze_result_t LinuxMemoryImp::getProperties(zes_mem_properties_t *pProperties) {
|
||||
pProperties->physicalSize = 0;
|
||||
if (isSubdevice) {
|
||||
std::string memval;
|
||||
physicalSizeFile = pDrm->getIoctlHelper()->getFileForMemoryAddrRange(subdeviceId);
|
||||
ze_result_t result = pSysfsAccess->read(physicalSizeFile, memval);
|
||||
uint64_t intval = strtoull(memval.c_str(), nullptr, 16);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
@@ -158,7 +165,9 @@ void LinuxMemoryImp::getHbmFrequency(PRODUCT_FAMILY productFamily, unsigned shor
|
||||
hbmFrequency = 0;
|
||||
if (productFamily == IGFX_PVC) {
|
||||
if (stepping >= REVISION_B) {
|
||||
const std::string hbmRP0FreqFile = pDrm->getIoctlHelper()->getFileForMaxMemoryFrequencyOfSubDevice(subdeviceId);
|
||||
const std::string baseDir = "gt/gt" + std::to_string(subdeviceId) + "/";
|
||||
// Calculating bandwidth based on HBM max frequency
|
||||
const std::string hbmRP0FreqFile = baseDir + "mem_RP0_freq_mhz";
|
||||
uint64_t hbmFreqValue = 0;
|
||||
ze_result_t result = pSysfsAccess->read(hbmRP0FreqFile, hbmFreqValue);
|
||||
if (ZE_RESULT_SUCCESS == result) {
|
||||
|
||||
@@ -45,6 +45,7 @@ class LinuxMemoryImp : public OsMemory, NEO::NonCopyableOrMovableClass {
|
||||
ze_result_t getHbmBandwidth(uint32_t numHbmModules, zes_mem_bandwidth_t *pBandwidth);
|
||||
ze_result_t getHbmBandwidthPVC(uint32_t numHbmModules, zes_mem_bandwidth_t *pBandwidth);
|
||||
ze_result_t getHbmBandwidthEx(uint32_t numHbmModules, uint32_t counterMaxValue, uint64_t *pReadCounters, uint64_t *pWriteCounters, uint64_t *pMaxBandwidth, uint64_t timeout);
|
||||
void init();
|
||||
static const std::string deviceMemoryHealth;
|
||||
bool isSubdevice = false;
|
||||
uint32_t subdeviceId = 0;
|
||||
|
||||
@@ -138,6 +138,12 @@ class SysmanDeviceMemoryFixture : public SysmanDeviceFixture {
|
||||
MemoryManager *pMemoryManagerOld;
|
||||
};
|
||||
|
||||
TEST_F(SysmanDeviceMemoryFixture, GivenWhenGettingMemoryPropertiesThenSuccessIsReturned) {
|
||||
zes_mem_properties_t properties = {};
|
||||
auto pLinuxMemoryImp = std::make_unique<LinuxMemoryImp>(pOsSysman, true, 0);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxMemoryImp->getProperties(&properties));
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceMemoryFixture, GivenComponentCountZeroWhenEnumeratingMemoryModulesWithLocalMemorySupportThenValidCountIsReturned) {
|
||||
setLocalSupportedAndReinit(true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user