fix: query drm info to aligned storages

xe topology info to byte aligned storage
xe engine info to 2 byte aligned storage
system info to 4 byte aligned storage

all other info to 8 byte aligned storage

Related-To: NEO-9038
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2023-10-02 14:26:33 +00:00
committed by Compute-Runtime-Automation
parent fd7c750cf7
commit 85eafc9e61
21 changed files with 105 additions and 76 deletions

View File

@@ -44,8 +44,8 @@ namespace NEO {
int IoctlHelperXe::xeGetQuery(Query *data) {
if (data->numItems == 1) {
QueryItem *queryItem = (QueryItem *)data->itemsPtr;
std::vector<uint8_t> *queryData = nullptr;
QueryItem *queryItem = reinterpret_cast<QueryItem *>(data->itemsPtr);
std::vector<uint64_t> *queryData = nullptr;
switch (queryItem->queryId) {
case static_cast<int>(DrmParam::QueryHwconfigTable):
queryData = &hwconfigFakei915;
@@ -54,19 +54,15 @@ int IoctlHelperXe::xeGetQuery(Query *data) {
xeLog("error: bad query 0x%x\n", queryItem->queryId);
return -1;
}
if (queryData != nullptr) {
if (queryItem->length == 0) {
queryItem->length = static_cast<int32_t>(queryData->size());
return 0;
}
if (queryItem->length != static_cast<int32_t>(queryData->size())) {
xeLog("error: incorrect length 0x%x 0x%lx\n", queryItem->length, queryData->size());
return -1;
}
memcpy_s(reinterpret_cast<void *>(queryItem->dataPtr),
queryItem->length, queryData->data(), queryItem->length);
auto queryDataSize = static_cast<int32_t>(queryData->size() * sizeof(uint64_t));
if (queryItem->length == 0) {
queryItem->length = queryDataSize;
return 0;
}
UNRECOVERABLE_IF(queryItem->length != queryDataSize);
memcpy_s(reinterpret_cast<void *>(queryItem->dataPtr),
queryItem->length, queryData->data(), queryItem->length);
return 0;
}
return -1;
}
@@ -136,7 +132,7 @@ bool IoctlHelperXe::initialize() {
if (retVal != 0 || queryConfig.size == 0) {
return false;
}
auto data = std::vector<uint8_t>(sizeof(drm_xe_query_config) + sizeof(uint64_t) * queryConfig.size, 0);
auto data = std::vector<uint64_t>(Math::divideAndRoundUp(sizeof(drm_xe_query_config) + sizeof(uint64_t) * queryConfig.size, sizeof(uint64_t)), 0);
struct drm_xe_query_config *config = reinterpret_cast<struct drm_xe_query_config *>(data.data());
queryConfig.data = castToUint64(config);
IoctlHelper::ioctl(DrmIoctl::Query, &queryConfig);
@@ -195,13 +191,14 @@ bool IoctlHelperXe::isVmBindAvailable() {
return true;
}
std::vector<uint8_t> IoctlHelperXe::queryData(uint32_t queryId) {
template <typename DataType>
std::vector<DataType> IoctlHelperXe::queryData(uint32_t queryId) {
struct drm_xe_device_query deviceQuery = {};
deviceQuery.query = queryId;
IoctlHelper::ioctl(DrmIoctl::Query, &deviceQuery);
std::vector<uint8_t> retVal(deviceQuery.size);
std::vector<DataType> retVal(Math::divideAndRoundUp(deviceQuery.size, sizeof(DataType)));
deviceQuery.data = castToUint64(retVal.data());
IoctlHelper::ioctl(DrmIoctl::Query, &deviceQuery);
@@ -210,9 +207,9 @@ std::vector<uint8_t> IoctlHelperXe::queryData(uint32_t queryId) {
}
std::unique_ptr<EngineInfo> IoctlHelperXe::createEngineInfo(bool isSysmanEnabled) {
auto enginesData = queryData(DRM_XE_DEVICE_QUERY_ENGINES);
auto enginesData = queryData<uint16_t>(DRM_XE_DEVICE_QUERY_ENGINES);
auto numberHwEngines = enginesData.size() /
auto numberHwEngines = enginesData.size() * sizeof(uint16_t) /
sizeof(struct drm_xe_engine_class_instance);
xeLog("numberHwEngines=%d\n", numberHwEngines);
@@ -268,8 +265,8 @@ inline MemoryRegion createMemoryRegionFromXeMemRegion(const drm_xe_query_mem_reg
}
std::unique_ptr<MemoryInfo> IoctlHelperXe::createMemoryInfo() {
auto memUsageData = queryData(DRM_XE_DEVICE_QUERY_MEM_USAGE);
auto gtsData = queryData(DRM_XE_DEVICE_QUERY_GTS);
auto memUsageData = queryData<uint64_t>(DRM_XE_DEVICE_QUERY_MEM_USAGE);
auto gtsData = queryData<uint64_t>(DRM_XE_DEVICE_QUERY_GTS);
if (memUsageData.empty() || gtsData.empty()) {
return {};
@@ -366,7 +363,7 @@ void IoctlHelperXe::getTopologyMap(uint32_t nTiles, std::vector<std::bitset<8>>
bool IoctlHelperXe::getTopologyDataAndMap(const HardwareInfo &hwInfo, DrmQueryTopologyData &topologyData, TopologyMap &topologyMap) {
auto queryGtTopology = queryData(DRM_XE_DEVICE_QUERY_GT_TOPOLOGY);
auto queryGtTopology = queryData<uint8_t>(DRM_XE_DEVICE_QUERY_GT_TOPOLOGY);
auto fillMask = [](std::vector<std::bitset<8>> &vec, drm_xe_query_topology_mask *topo) {
for (uint32_t j = 0; j < topo->num_bytes; j++) {
@@ -378,7 +375,7 @@ bool IoctlHelperXe::getTopologyDataAndMap(const HardwareInfo &hwInfo, DrmQueryTo
std::vector<std::bitset<8>> computeDss[2];
std::vector<std::bitset<8>> euDss[2];
auto topologySize = queryGtTopology.size();
uint8_t *dataPtr = reinterpret_cast<uint8_t *>(queryGtTopology.data());
auto dataPtr = queryGtTopology.data();
auto nTiles = 1u;
@@ -406,7 +403,7 @@ bool IoctlHelperXe::getTopologyDataAndMap(const HardwareInfo &hwInfo, DrmQueryTo
uint32_t itemSize = sizeof(drm_xe_query_topology_mask) + topo->num_bytes;
topologySize -= itemSize;
dataPtr += itemSize;
dataPtr = ptrOffset(dataPtr, itemSize);
}
bool isComputeDssEmpty = false;

View File

@@ -120,7 +120,8 @@ class IoctlHelperXe : public IoctlHelper {
const char *xeGetClassName(int className);
const char *xeGetBindOpName(int bindOp);
const char *xeGetengineClassName(uint32_t engineClass);
std::vector<uint8_t> queryData(uint32_t queryId);
template <typename DataType>
std::vector<DataType> queryData(uint32_t queryId);
int xeWaitUserFence(uint64_t mask, uint16_t op, uint64_t addr, uint64_t value, int64_t timeout);
int xeVmBind(const VmBindParams &vmBindParams, bool bindOp);
void xeShowBindTable();
@@ -145,7 +146,7 @@ class IoctlHelperXe : public IoctlHelper {
std::vector<BindInfo> bindInfo;
int instance = 0;
uint32_t xeTimestampFrequency = 0;
std::vector<uint8_t> hwconfigFakei915;
std::vector<uint64_t> hwconfigFakei915;
std::vector<drm_xe_engine_class_instance> contextParamEngine;
std::vector<drm_xe_engine_class_instance> allEngines;
};