Validate host ptr on VM it will be used

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk
2021-08-04 11:56:36 +00:00
committed by Compute-Runtime-Automation
parent 700aecb384
commit 49cf6f79f5
4 changed files with 12 additions and 7 deletions

View File

@@ -221,16 +221,13 @@ void BufferObject::printExecutionBuffer(drm_i915_gem_execbuffer2 &execbuf, const
printf("%s\n", logger.str().c_str());
}
int bindBOsWithinContext(BufferObject *const boToPin[], size_t numberOfBos, OsContext *osContext, uint32_t vmHandleId, bool allContexts) {
int bindBOsWithinContext(BufferObject *const boToPin[], size_t numberOfBos, OsContext *osContext, uint32_t vmHandleId) {
auto retVal = 0;
for (auto drmIterator = 0u; drmIterator < osContext->getDeviceBitfield().size(); drmIterator++) {
if (osContext->getDeviceBitfield().test(drmIterator)) {
for (size_t i = 0; i < numberOfBos; i++) {
retVal |= boToPin[i]->bind(osContext, drmIterator);
if (!allContexts) {
return retVal;
}
}
}
}
@@ -242,7 +239,7 @@ int BufferObject::pin(BufferObject *const boToPin[], size_t numberOfBos, OsConte
auto retVal = 0;
if (this->drm->isVmBindAvailable()) {
retVal = bindBOsWithinContext(boToPin, numberOfBos, osContext, vmHandleId, true);
retVal = bindBOsWithinContext(boToPin, numberOfBos, osContext, vmHandleId);
} else {
StackVec<drm_i915_gem_exec_object2, maxFragmentsCount + 1> execObject(numberOfBos + 1);
retVal = this->exec(4u, 0u, 0u, false, osContext, vmHandleId, drmContextId, boToPin, numberOfBos, &execObject[0]);
@@ -255,7 +252,12 @@ int BufferObject::validateHostPtr(BufferObject *const boToPin[], size_t numberOf
auto retVal = 0;
if (this->drm->isVmBindAvailable()) {
retVal = bindBOsWithinContext(boToPin, numberOfBos, osContext, vmHandleId, false);
for (size_t i = 0; i < numberOfBos; i++) {
retVal = boToPin[i]->bind(osContext, vmHandleId);
if (retVal) {
break;
}
}
} else {
StackVec<drm_i915_gem_exec_object2, maxFragmentsCount + 1> execObject(numberOfBos + 1);
retVal = this->exec(4u, 0u, 0u, false, osContext, vmHandleId, drmContextId, boToPin, numberOfBos, &execObject[0]);