mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 01:04:57 +08:00
fix: query drm info to 8 byte aligned storage
Related-To: NEO-9038 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
7531ced0e3
commit
d0e615820c
@@ -16,6 +16,7 @@
|
||||
#include "shared/source/gmm_helper/gmm.h"
|
||||
#include "shared/source/gmm_helper/resource_info.h"
|
||||
#include "shared/source/helpers/aligned_memory.h"
|
||||
#include "shared/source/helpers/basic_math.h"
|
||||
#include "shared/source/helpers/constants.h"
|
||||
#include "shared/source/helpers/debug_helpers.h"
|
||||
#include "shared/source/helpers/gfx_core_helper.h"
|
||||
@@ -601,7 +602,7 @@ std::string Drm::getDrmVersion(int fileDescriptor) {
|
||||
return std::string(name);
|
||||
}
|
||||
|
||||
std::vector<uint8_t> Drm::query(uint32_t queryId, uint32_t queryItemFlags) {
|
||||
std::vector<uint64_t> Drm::query(uint32_t queryId, uint32_t queryItemFlags) {
|
||||
Query query{};
|
||||
QueryItem queryItem{};
|
||||
queryItem.queryId = queryId;
|
||||
@@ -615,7 +616,7 @@ std::vector<uint8_t> Drm::query(uint32_t queryId, uint32_t queryItemFlags) {
|
||||
return {};
|
||||
}
|
||||
|
||||
auto data = std::vector<uint8_t>(queryItem.length, 0);
|
||||
auto data = std::vector<uint64_t>(Math::divideAndRoundUp(queryItem.length, sizeof(uint64_t)), 0);
|
||||
queryItem.dataPtr = castToUint64(data.data());
|
||||
|
||||
ret = ioctlHelper->ioctl(DrmIoctl::Query, &query);
|
||||
@@ -941,7 +942,7 @@ bool Drm::querySystemInfo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> Drm::getMemoryRegions() {
|
||||
std::vector<uint64_t> Drm::getMemoryRegions() {
|
||||
auto request = ioctlHelper->getDrmParamValue(DrmParam::QueryMemoryRegions);
|
||||
return this->query(request, 0);
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ class Drm : public DriverModel {
|
||||
pciDomain = domain;
|
||||
}
|
||||
|
||||
MOCKABLE_VIRTUAL std::vector<uint8_t> getMemoryRegions();
|
||||
MOCKABLE_VIRTUAL std::vector<uint64_t> getMemoryRegions();
|
||||
|
||||
MOCKABLE_VIRTUAL bool completionFenceSupport();
|
||||
|
||||
@@ -253,7 +253,7 @@ class Drm : public DriverModel {
|
||||
bool readSysFsAsString(const std::string &relativeFilePath, std::string &readString);
|
||||
MOCKABLE_VIRTUAL std::string getSysFsPciPath();
|
||||
std::unique_ptr<HwDeviceIdDrm> &getHwDeviceId() { return hwDeviceId; }
|
||||
std::vector<uint8_t> query(uint32_t queryId, uint32_t queryItemFlags);
|
||||
std::vector<uint64_t> query(uint32_t queryId, uint32_t queryItemFlags);
|
||||
static std::string getDrmVersion(int fileDescriptor);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -121,7 +121,7 @@ int IoctlHelper::createDrmContext(Drm &drm, OsContextLinux &osContext, uint32_t
|
||||
return drmContextId;
|
||||
}
|
||||
|
||||
std::vector<EngineCapabilities> IoctlHelper::translateToEngineCaps(const std::vector<uint8_t> &data) {
|
||||
std::vector<EngineCapabilities> IoctlHelper::translateToEngineCaps(const std::vector<uint64_t> &data) {
|
||||
auto engineInfo = reinterpret_cast<const drm_i915_query_engine_info *>(data.data());
|
||||
std::vector<EngineCapabilities> engines;
|
||||
engines.reserve(engineInfo->num_engines);
|
||||
@@ -135,7 +135,7 @@ std::vector<EngineCapabilities> IoctlHelper::translateToEngineCaps(const std::ve
|
||||
return engines;
|
||||
}
|
||||
|
||||
std::vector<MemoryRegion> IoctlHelper::translateToMemoryRegions(const std::vector<uint8_t> ®ionInfo) {
|
||||
std::vector<MemoryRegion> IoctlHelper::translateToMemoryRegions(const std::vector<uint64_t> ®ionInfo) {
|
||||
auto *data = reinterpret_cast<const drm_i915_query_memory_regions *>(regionInfo.data());
|
||||
auto memRegions = std::vector<MemoryRegion>(data->num_regions);
|
||||
for (uint32_t i = 0; i < data->num_regions; i++) {
|
||||
|
||||
@@ -131,10 +131,10 @@ class IoctlHelper {
|
||||
virtual std::string getIoctlString(DrmIoctl ioctlRequest) const = 0;
|
||||
|
||||
virtual bool checkIfIoctlReinvokeRequired(int error, DrmIoctl ioctlRequest) const;
|
||||
virtual std::vector<MemoryRegion> translateToMemoryRegions(const std::vector<uint8_t> ®ionInfo);
|
||||
virtual std::vector<MemoryRegion> translateToMemoryRegions(const std::vector<uint64_t> ®ionInfo);
|
||||
|
||||
virtual int createDrmContext(Drm &drm, OsContextLinux &osContext, uint32_t drmVmId, uint32_t deviceIndex);
|
||||
std::vector<EngineCapabilities> translateToEngineCaps(const std::vector<uint8_t> &data);
|
||||
std::vector<EngineCapabilities> translateToEngineCaps(const std::vector<uint64_t> &data);
|
||||
|
||||
void fillExecObject(ExecObject &execObject, uint32_t handle, uint64_t gpuAddress, uint32_t drmContextId, bool bindInfo, bool isMarkedForCapture);
|
||||
void logExecObject(const ExecObject &execObject, std::stringstream &logger, size_t size);
|
||||
@@ -237,7 +237,7 @@ class IoctlHelperImpl : public IoctlHelperUpstream {
|
||||
}
|
||||
|
||||
int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) override;
|
||||
std::vector<MemoryRegion> translateToMemoryRegions(const std::vector<uint8_t> ®ionInfo) override;
|
||||
std::vector<MemoryRegion> translateToMemoryRegions(const std::vector<uint64_t> ®ionInfo) override;
|
||||
unsigned int getIoctlRequestValue(DrmIoctl ioctlRequest) const override;
|
||||
std::string getIoctlString(DrmIoctl ioctlRequest) const override;
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
* Copyright (C) 2021-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
bool isQueryDrmTip(const std::vector<uint8_t> &queryInfo) {
|
||||
bool isQueryDrmTip(const std::vector<uint64_t> &queryInfo) {
|
||||
auto dataOnDrmTip = reinterpret_cast<const drm_i915_query_memory_regions *>(queryInfo.data());
|
||||
auto lengthOnDrmTip = static_cast<uint32_t>(sizeof(drm_i915_query_memory_regions) + dataOnDrmTip->num_regions * sizeof(drm_i915_memory_region_info));
|
||||
return static_cast<uint32_t>(queryInfo.size()) == lengthOnDrmTip;
|
||||
|
||||
@@ -18,7 +18,7 @@ using namespace Dg1I915;
|
||||
|
||||
constexpr static auto gfxProduct = IGFX_DG1;
|
||||
|
||||
extern bool isQueryDrmTip(const std::vector<uint8_t> &queryInfo);
|
||||
extern bool isQueryDrmTip(const std::vector<uint64_t> &queryInfo);
|
||||
|
||||
template <>
|
||||
int IoctlHelperImpl<gfxProduct>::createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) {
|
||||
@@ -55,7 +55,7 @@ int IoctlHelperImpl<gfxProduct>::createGemExt(const MemRegionsVec &memClassInsta
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::vector<MemoryRegion> translateDg1RegionInfoToMemoryRegions(const std::vector<uint8_t> ®ionInfo) {
|
||||
std::vector<MemoryRegion> translateDg1RegionInfoToMemoryRegions(const std::vector<uint64_t> ®ionInfo) {
|
||||
auto *data = reinterpret_cast<const drm_i915_query_memory_regions *>(regionInfo.data());
|
||||
auto memRegions = std::vector<MemoryRegion>(data->num_regions);
|
||||
for (uint32_t i = 0; i < data->num_regions; i++) {
|
||||
@@ -68,7 +68,7 @@ std::vector<MemoryRegion> translateDg1RegionInfoToMemoryRegions(const std::vecto
|
||||
}
|
||||
|
||||
template <>
|
||||
std::vector<MemoryRegion> IoctlHelperImpl<gfxProduct>::translateToMemoryRegions(const std::vector<uint8_t> ®ionInfo) {
|
||||
std::vector<MemoryRegion> IoctlHelperImpl<gfxProduct>::translateToMemoryRegions(const std::vector<uint64_t> ®ionInfo) {
|
||||
if (!isQueryDrmTip(regionInfo)) {
|
||||
return translateDg1RegionInfoToMemoryRegions(regionInfo);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
* Copyright (C) 2021-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -15,13 +15,13 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
SystemInfo::SystemInfo(const std::vector<uint8_t> &inputData) {
|
||||
SystemInfo::SystemInfo(const std::vector<uint64_t> &inputData) {
|
||||
this->parseDeviceBlob(inputData);
|
||||
}
|
||||
|
||||
void SystemInfo::parseDeviceBlob(const std::vector<uint8_t> &inputData) {
|
||||
void SystemInfo::parseDeviceBlob(const std::vector<uint64_t> &inputData) {
|
||||
auto data = reinterpret_cast<const uint32_t *>(inputData.data());
|
||||
auto dataSize = inputData.size() / sizeof(uint32_t);
|
||||
auto dataSize = inputData.size() * 2;
|
||||
uint32_t i = 0;
|
||||
while (i + 2 < dataSize) {
|
||||
DEBUG_BREAK_IF(data[i + 1] < 1);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -14,7 +14,7 @@ struct HardwareInfo;
|
||||
|
||||
struct SystemInfo {
|
||||
|
||||
SystemInfo(const std::vector<uint8_t> &inputData);
|
||||
SystemInfo(const std::vector<uint64_t> &inputData);
|
||||
|
||||
~SystemInfo() = default;
|
||||
|
||||
@@ -36,7 +36,7 @@ struct SystemInfo {
|
||||
void checkSysInfoMismatch(HardwareInfo *hwInfo);
|
||||
|
||||
protected:
|
||||
void parseDeviceBlob(const std::vector<uint8_t> &inputData);
|
||||
void parseDeviceBlob(const std::vector<uint64_t> &inputData);
|
||||
|
||||
uint32_t maxSlicesSupported = 0;
|
||||
uint32_t maxDualSubSlicesSupported = 0;
|
||||
|
||||
@@ -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;
|
||||
@@ -55,14 +55,12 @@ int IoctlHelperXe::xeGetQuery(Query *data) {
|
||||
return -1;
|
||||
}
|
||||
if (queryData != nullptr) {
|
||||
auto queryDataSize = static_cast<int32_t>(queryData->size() / sizeof(uint64_t));
|
||||
if (queryItem->length == 0) {
|
||||
queryItem->length = static_cast<int32_t>(queryData->size());
|
||||
queryItem->length = queryDataSize;
|
||||
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;
|
||||
}
|
||||
UNRECOVERABLE_IF(queryItem->length != queryDataSize);
|
||||
memcpy_s(reinterpret_cast<void *>(queryItem->dataPtr),
|
||||
queryItem->length, queryData->data(), queryItem->length);
|
||||
return 0;
|
||||
@@ -136,7 +134,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 +193,13 @@ bool IoctlHelperXe::isVmBindAvailable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> IoctlHelperXe::queryData(uint32_t queryId) {
|
||||
std::vector<uint64_t> 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<uint64_t> retVal(Math::divideAndRoundUp(deviceQuery.size, sizeof(uint64_t)));
|
||||
|
||||
deviceQuery.data = castToUint64(retVal.data());
|
||||
IoctlHelper::ioctl(DrmIoctl::Query, &deviceQuery);
|
||||
@@ -212,7 +210,7 @@ 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 numberHwEngines = enginesData.size() /
|
||||
auto numberHwEngines = enginesData.size() * sizeof(uint64_t) /
|
||||
sizeof(struct drm_xe_engine_class_instance);
|
||||
|
||||
xeLog("numberHwEngines=%d\n", numberHwEngines);
|
||||
@@ -377,8 +375,8 @@ bool IoctlHelperXe::getTopologyDataAndMap(const HardwareInfo &hwInfo, DrmQueryTo
|
||||
std::vector<std::bitset<8>> geomDss[2];
|
||||
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 topologySize = queryGtTopology.size() * sizeof(uint64_t);
|
||||
uint64_t *dataPtr = reinterpret_cast<uint64_t *>(queryGtTopology.data());
|
||||
|
||||
auto nTiles = 1u;
|
||||
|
||||
@@ -406,7 +404,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;
|
||||
|
||||
@@ -120,7 +120,7 @@ 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);
|
||||
std::vector<uint64_t> 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 +145,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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user