Unify query ioctls

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2022-05-30 13:00:24 +00:00
committed by Compute-Runtime-Automation
parent 58ec879c46
commit 571199d048
11 changed files with 83 additions and 129 deletions

View File

@@ -142,6 +142,10 @@ std::string getIoctlString(DrmIoctl ioctlRequest) {
return "DRM_IOCTL_I915_GEM_VM_CREATE";
case DrmIoctl::GemVmDestroy:
return "DRM_IOCTL_I915_GEM_VM_DESTROY";
case DrmIoctl::QueryEngineInfo:
return "DRM_I915_QUERY_ENGINE_INFO";
case DrmIoctl::QueryMemoryRegions:
return "DRM_I915_QUERY_MEMORY_REGIONS";
}
UNRECOVERABLE_IF(true);
return "";
@@ -977,7 +981,7 @@ bool Drm::querySystemInfo() {
}
std::vector<uint8_t> Drm::getMemoryRegions() {
return this->query(ioctlHelper->getMemRegionsIoctlVal(), 0);
return this->query(ioctlHelper->getIoctlRequestValue(DrmIoctl::QueryMemoryRegions), 0);
}
bool Drm::queryMemoryInfo() {
@@ -991,7 +995,7 @@ bool Drm::queryMemoryInfo() {
}
bool Drm::queryEngineInfo(bool isSysmanEnabled) {
auto enginesQuery = this->query(ioctlHelper->getEngineInfoIoctlVal(), 0);
auto enginesQuery = this->query(ioctlHelper->getIoctlRequestValue(DrmIoctl::QueryEngineInfo), 0);
if (enginesQuery.empty()) {
return false;
}

View File

@@ -214,6 +214,8 @@ enum class DrmIoctl {
GemContextGetparam,
GemContextSetparam,
Query,
QueryEngineInfo,
QueryMemoryRegions,
GemMmap,
GemMmapOffset,
GemVmCreate,

View File

@@ -82,6 +82,60 @@ void IoctlHelper::logExecBuffer(const ExecBuffer &execBuffer, std::stringstream
<< " }\n";
}
unsigned int IoctlHelper::getIoctlRequestValueBase(DrmIoctl ioctlRequest) const {
switch (ioctlRequest) {
case DrmIoctl::GemExecbuffer2:
return DRM_IOCTL_I915_GEM_EXECBUFFER2;
case DrmIoctl::GemWait:
return DRM_IOCTL_I915_GEM_WAIT;
case DrmIoctl::GemClose:
return DRM_IOCTL_GEM_CLOSE;
case DrmIoctl::GemUserptr:
return DRM_IOCTL_I915_GEM_USERPTR;
case DrmIoctl::GemCreate:
return DRM_IOCTL_I915_GEM_CREATE;
case DrmIoctl::GemSetDomain:
return DRM_IOCTL_I915_GEM_SET_DOMAIN;
case DrmIoctl::GemSetTiling:
return DRM_IOCTL_I915_GEM_SET_TILING;
case DrmIoctl::GemGetTiling:
return DRM_IOCTL_I915_GEM_GET_TILING;
case DrmIoctl::GemContextCreateExt:
return DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT;
case DrmIoctl::GemContextDestroy:
return DRM_IOCTL_I915_GEM_CONTEXT_DESTROY;
case DrmIoctl::RegRead:
return DRM_IOCTL_I915_REG_READ;
case DrmIoctl::GetResetStats:
return DRM_IOCTL_I915_GET_RESET_STATS;
case DrmIoctl::GemContextGetparam:
return DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM;
case DrmIoctl::GemContextSetparam:
return DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM;
case DrmIoctl::Query:
return DRM_IOCTL_I915_QUERY;
case DrmIoctl::GemMmap:
return DRM_IOCTL_I915_GEM_MMAP;
case DrmIoctl::PrimeFdToHandle:
return DRM_IOCTL_PRIME_FD_TO_HANDLE;
case DrmIoctl::PrimeHandleToFd:
return DRM_IOCTL_PRIME_HANDLE_TO_FD;
case DrmIoctl::GemMmapOffset:
return DRM_IOCTL_I915_GEM_MMAP_OFFSET;
case DrmIoctl::GemVmCreate:
return DRM_IOCTL_I915_GEM_VM_CREATE;
case DrmIoctl::GemVmDestroy:
return DRM_IOCTL_I915_GEM_VM_DESTROY;
case DrmIoctl::QueryEngineInfo:
return DRM_I915_QUERY_ENGINE_INFO;
case DrmIoctl::QueryMemoryRegions:
return DRM_I915_QUERY_MEMORY_REGIONS;
default:
UNRECOVERABLE_IF(true);
return 0;
}
}
uint32_t IoctlHelper::createDrmContext(Drm &drm, const OsContext &osContext, uint32_t drmVmId) {
const auto numberOfCCS = drm.getRootDeviceEnvironment().getHardwareInfo()->gtSystemInfo.CCSInfo.NumberOfCCSEnabled;

View File

@@ -84,8 +84,6 @@ class IoctlHelper {
virtual bool setVmBoAdvise(Drm *drm, int32_t handle, uint32_t attribute, void *region) = 0;
virtual bool setVmPrefetch(Drm *drm, uint64_t start, uint64_t length, uint32_t region) = 0;
virtual uint32_t getDirectSubmissionFlag() = 0;
virtual int32_t getMemRegionsIoctlVal() = 0;
virtual int32_t getEngineInfoIoctlVal() = 0;
virtual uint32_t getComputeSlicesIoctlVal() = 0;
virtual std::unique_ptr<uint8_t[]> prepareVmBindExt(const StackVec<uint32_t, 2> &bindExtHandles) = 0;
virtual uint64_t getFlagsForVmBind(bool bindCapture, bool bindImmediate, bool bindMakeResident) = 0;
@@ -115,7 +113,7 @@ class IoctlHelper {
virtual bool isContextDebugSupported(Drm *drm) = 0;
virtual int setContextDebugFlag(Drm *drm, uint32_t drmContextId) = 0;
virtual bool isDebugAttachAvailable() = 0;
virtual unsigned int getIoctlRequestValue(DrmIoctl ioctlRequest) = 0;
virtual unsigned int getIoctlRequestValue(DrmIoctl ioctlRequest) const = 0;
uint32_t createDrmContext(Drm &drm, const OsContext &osContext, uint32_t drmVmId);
@@ -124,6 +122,9 @@ class IoctlHelper {
void fillExecBuffer(ExecBuffer &execBuffer, uintptr_t buffersPtr, uint32_t bufferCount, uint32_t startOffset, uint32_t size, uint64_t flags, uint32_t drmContextId);
void logExecBuffer(const ExecBuffer &execBuffer, std::stringstream &logger);
protected:
unsigned int getIoctlRequestValueBase(DrmIoctl ioctlRequest) const;
};
class IoctlHelperUpstream : public IoctlHelper {
@@ -144,8 +145,6 @@ class IoctlHelperUpstream : public IoctlHelper {
bool setVmBoAdvise(Drm *drm, int32_t handle, uint32_t attribute, void *region) override;
bool setVmPrefetch(Drm *drm, uint64_t start, uint64_t length, uint32_t region) override;
uint32_t getDirectSubmissionFlag() override;
int32_t getMemRegionsIoctlVal() override;
int32_t getEngineInfoIoctlVal() override;
uint32_t getComputeSlicesIoctlVal() override;
std::unique_ptr<uint8_t[]> prepareVmBindExt(const StackVec<uint32_t, 2> &bindExtHandles) override;
uint64_t getFlagsForVmBind(bool bindCapture, bool bindImmediate, bool bindMakeResident) override;
@@ -175,7 +174,7 @@ class IoctlHelperUpstream : public IoctlHelper {
bool isContextDebugSupported(Drm *drm) override;
int setContextDebugFlag(Drm *drm, uint32_t drmContextId) override;
bool isDebugAttachAvailable() override;
unsigned int getIoctlRequestValue(DrmIoctl ioctlRequest) override;
unsigned int getIoctlRequestValue(DrmIoctl ioctlRequest) const override;
};
template <PRODUCT_FAMILY gfxProduct>
@@ -189,7 +188,7 @@ class IoctlHelperImpl : public IoctlHelperUpstream {
uint32_t createGemExt(Drm *drm, const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint32_t vmId) override;
std::vector<MemoryRegion> translateToMemoryRegions(const std::vector<uint8_t> &regionInfo) override;
unsigned int getIoctlRequestValue(DrmIoctl ioctlRequest) override;
unsigned int getIoctlRequestValue(DrmIoctl ioctlRequest) const override;
};
class IoctlHelperPrelim20 : public IoctlHelper {
@@ -210,8 +209,6 @@ class IoctlHelperPrelim20 : public IoctlHelper {
bool setVmBoAdvise(Drm *drm, int32_t handle, uint32_t attribute, void *region) override;
bool setVmPrefetch(Drm *drm, uint64_t start, uint64_t length, uint32_t region) override;
uint32_t getDirectSubmissionFlag() override;
int32_t getMemRegionsIoctlVal() override;
int32_t getEngineInfoIoctlVal() override;
uint32_t getComputeSlicesIoctlVal() override;
std::unique_ptr<uint8_t[]> prepareVmBindExt(const StackVec<uint32_t, 2> &bindExtHandles) override;
uint64_t getFlagsForVmBind(bool bindCapture, bool bindImmediate, bool bindMakeResident) override;
@@ -241,7 +238,7 @@ class IoctlHelperPrelim20 : public IoctlHelper {
bool isContextDebugSupported(Drm *drm) override;
int setContextDebugFlag(Drm *drm, uint32_t drmContextId) override;
bool isDebugAttachAvailable() override;
unsigned int getIoctlRequestValue(DrmIoctl ioctlRequest) override;
unsigned int getIoctlRequestValue(DrmIoctl ioctlRequest) const override;
};
} // namespace NEO

View File

@@ -227,14 +227,6 @@ uint32_t IoctlHelperPrelim20::getDirectSubmissionFlag() {
return PRELIM_I915_CONTEXT_CREATE_FLAGS_LONG_RUNNING;
}
int32_t IoctlHelperPrelim20::getMemRegionsIoctlVal() {
return PRELIM_DRM_I915_QUERY_MEMORY_REGIONS;
}
int32_t IoctlHelperPrelim20::getEngineInfoIoctlVal() {
return PRELIM_DRM_I915_QUERY_ENGINE_INFO;
}
uint32_t IoctlHelperPrelim20::getComputeSlicesIoctlVal() {
return PRELIM_DRM_I915_QUERY_COMPUTE_SLICES;
}
@@ -562,44 +554,8 @@ bool IoctlHelperPrelim20::isDebugAttachAvailable() {
return true;
}
unsigned int IoctlHelperPrelim20::getIoctlRequestValue(DrmIoctl ioctlRequest) {
unsigned int IoctlHelperPrelim20::getIoctlRequestValue(DrmIoctl ioctlRequest) const {
switch (ioctlRequest) {
case DrmIoctl::GemExecbuffer2:
return DRM_IOCTL_I915_GEM_EXECBUFFER2;
case DrmIoctl::GemWait:
return DRM_IOCTL_I915_GEM_WAIT;
case DrmIoctl::GemClose:
return DRM_IOCTL_GEM_CLOSE;
case DrmIoctl::GemUserptr:
return DRM_IOCTL_I915_GEM_USERPTR;
case DrmIoctl::GemCreate:
return DRM_IOCTL_I915_GEM_CREATE;
case DrmIoctl::GemSetDomain:
return DRM_IOCTL_I915_GEM_SET_DOMAIN;
case DrmIoctl::GemSetTiling:
return DRM_IOCTL_I915_GEM_SET_TILING;
case DrmIoctl::GemGetTiling:
return DRM_IOCTL_I915_GEM_GET_TILING;
case DrmIoctl::GemContextCreateExt:
return DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT;
case DrmIoctl::GemContextDestroy:
return DRM_IOCTL_I915_GEM_CONTEXT_DESTROY;
case DrmIoctl::RegRead:
return DRM_IOCTL_I915_REG_READ;
case DrmIoctl::GetResetStats:
return DRM_IOCTL_I915_GET_RESET_STATS;
case DrmIoctl::GemContextGetparam:
return DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM;
case DrmIoctl::GemContextSetparam:
return DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM;
case DrmIoctl::Query:
return DRM_IOCTL_I915_QUERY;
case DrmIoctl::GemMmap:
return DRM_IOCTL_I915_GEM_MMAP;
case DrmIoctl::PrimeFdToHandle:
return DRM_IOCTL_PRIME_FD_TO_HANDLE;
case DrmIoctl::PrimeHandleToFd:
return DRM_IOCTL_PRIME_HANDLE_TO_FD;
case DrmIoctl::GemVmBind:
return PRELIM_DRM_IOCTL_I915_GEM_VM_BIND;
case DrmIoctl::GemVmUnbind:
@@ -624,15 +580,8 @@ unsigned int IoctlHelperPrelim20::getIoctlRequestValue(DrmIoctl ioctlRequest) {
return PRELIM_DRM_IOCTL_I915_GEM_CLOS_FREE;
case DrmIoctl::GemCacheReserve:
return PRELIM_DRM_IOCTL_I915_GEM_CACHE_RESERVE;
case DrmIoctl::GemMmapOffset:
return DRM_IOCTL_I915_GEM_MMAP_OFFSET;
case DrmIoctl::GemVmCreate:
return DRM_IOCTL_I915_GEM_VM_CREATE;
case DrmIoctl::GemVmDestroy:
return DRM_IOCTL_I915_GEM_VM_DESTROY;
default:
UNRECOVERABLE_IF(true);
return 0u;
return getIoctlRequestValueBase(ioctlRequest);
}
}

View File

@@ -111,14 +111,6 @@ uint32_t IoctlHelperUpstream::getDirectSubmissionFlag() {
return 0u;
}
int32_t IoctlHelperUpstream::getMemRegionsIoctlVal() {
return DRM_I915_QUERY_MEMORY_REGIONS;
}
int32_t IoctlHelperUpstream::getEngineInfoIoctlVal() {
return DRM_I915_QUERY_ENGINE_INFO;
}
uint32_t IoctlHelperUpstream::getComputeSlicesIoctlVal() {
return 0;
}
@@ -244,55 +236,11 @@ bool IoctlHelperUpstream::isDebugAttachAvailable() {
return false;
}
unsigned int IoctlHelperUpstream::getIoctlRequestValue(DrmIoctl ioctlRequest) {
switch (ioctlRequest) {
case DrmIoctl::GemExecbuffer2:
return DRM_IOCTL_I915_GEM_EXECBUFFER2;
case DrmIoctl::GemWait:
return DRM_IOCTL_I915_GEM_WAIT;
case DrmIoctl::GemClose:
return DRM_IOCTL_GEM_CLOSE;
case DrmIoctl::GemUserptr:
return DRM_IOCTL_I915_GEM_USERPTR;
case DrmIoctl::GemCreate:
return DRM_IOCTL_I915_GEM_CREATE;
case DrmIoctl::GemCreateExt:
unsigned int IoctlHelperUpstream::getIoctlRequestValue(DrmIoctl ioctlRequest) const {
if (ioctlRequest == DrmIoctl::GemCreateExt) {
return DRM_IOCTL_I915_GEM_CREATE_EXT;
case DrmIoctl::GemSetDomain:
return DRM_IOCTL_I915_GEM_SET_DOMAIN;
case DrmIoctl::GemSetTiling:
return DRM_IOCTL_I915_GEM_SET_TILING;
case DrmIoctl::GemGetTiling:
return DRM_IOCTL_I915_GEM_GET_TILING;
case DrmIoctl::GemContextCreateExt:
return DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT;
case DrmIoctl::GemContextDestroy:
return DRM_IOCTL_I915_GEM_CONTEXT_DESTROY;
case DrmIoctl::RegRead:
return DRM_IOCTL_I915_REG_READ;
case DrmIoctl::GetResetStats:
return DRM_IOCTL_I915_GET_RESET_STATS;
case DrmIoctl::GemContextGetparam:
return DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM;
case DrmIoctl::GemContextSetparam:
return DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM;
case DrmIoctl::Query:
return DRM_IOCTL_I915_QUERY;
case DrmIoctl::GemMmap:
return DRM_IOCTL_I915_GEM_MMAP;
case DrmIoctl::PrimeFdToHandle:
return DRM_IOCTL_PRIME_FD_TO_HANDLE;
case DrmIoctl::PrimeHandleToFd:
return DRM_IOCTL_PRIME_HANDLE_TO_FD;
case DrmIoctl::GemMmapOffset:
return DRM_IOCTL_I915_GEM_MMAP_OFFSET;
case DrmIoctl::GemVmCreate:
return DRM_IOCTL_I915_GEM_VM_CREATE;
case DrmIoctl::GemVmDestroy:
return DRM_IOCTL_I915_GEM_VM_DESTROY;
default:
UNRECOVERABLE_IF(true);
return 0u;
}
return getIoctlRequestValueBase(ioctlRequest);
}
} // namespace NEO

View File

@@ -67,7 +67,7 @@ std::vector<MemoryRegion> IoctlHelperImpl<gfxProduct>::translateToMemoryRegions(
}
template <>
unsigned int IoctlHelperImpl<gfxProduct>::getIoctlRequestValue(DrmIoctl ioctlRequest) {
unsigned int IoctlHelperImpl<gfxProduct>::getIoctlRequestValue(DrmIoctl ioctlRequest) const {
switch (ioctlRequest) {
case DrmIoctl::DG1GemCreateExt:
return DRM_IOCTL_I915_GEM_CREATE_EXT;