Move set domain cpu logic to ioctl helper

Related-To: NEO-6999
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2022-07-25 14:47:08 +00:00
committed by Compute-Runtime-Automation
parent b49e2237c5
commit 3d1c990e37
3 changed files with 10 additions and 7 deletions

View File

@@ -1043,15 +1043,9 @@ bool DrmMemoryManager::setDomainCpu(GraphicsAllocation &graphicsAllocation, bool
if (bo == nullptr)
return false;
// move a buffer object to the CPU read, and possibly write domain, including waiting on flushes to occur
GemSetDomain setDomain = {};
setDomain.handle = bo->peekHandle();
setDomain.readDomains = I915_GEM_DOMAIN_CPU;
setDomain.writeDomain = writeEnable ? I915_GEM_DOMAIN_CPU : 0;
auto &drm = this->getDrm(graphicsAllocation.getRootDeviceIndex());
auto ioctlHelper = drm.getIoctlHelper();
return ioctlHelper->ioctl(DrmIoctl::GemSetDomain, &setDomain) == 0;
return ioctlHelper->setDomainCpu(bo->peekHandle(), writeEnable);
}
void *DrmMemoryManager::lockResourceImpl(GraphicsAllocation &graphicsAllocation) {

View File

@@ -133,6 +133,14 @@ std::vector<MemoryRegion> IoctlHelper::translateToMemoryRegions(const std::vecto
return memRegions;
}
bool IoctlHelper::setDomainCpu(uint32_t handle, bool writeEnable) {
drm_i915_gem_set_domain setDomain{};
setDomain.handle = handle;
setDomain.read_domains = I915_GEM_DOMAIN_CPU;
setDomain.write_domain = writeEnable ? I915_GEM_DOMAIN_CPU : 0;
return this->ioctl(DrmIoctl::GemSetDomain, &setDomain) == 0u;
}
unsigned int IoctlHelper::getIoctlRequestValueBase(DrmIoctl ioctlRequest) const {
switch (ioctlRequest) {
case DrmIoctl::Getparam:

View File

@@ -124,6 +124,7 @@ class IoctlHelper {
void logExecBuffer(const ExecBuffer &execBuffer, std::stringstream &logger);
int getDrmParamValueBase(DrmParam drmParam) const;
unsigned int getIoctlRequestValueBase(DrmIoctl ioctlRequest) const;
bool setDomainCpu(uint32_t handle, bool writeEnable);
std::string getDrmParamStringBase(DrmParam param) const;
std::string getIoctlStringBase(DrmIoctl ioctlRequest) const;