Skip to content

Commit 95434f4

Browse files
Revert "Retry in loop when exec or bind fails with ENXIO"
This reverts commit ec13b18. Signed-off-by: Compute-Runtime-Validation <compute-runtime-validation@intel.com>
1 parent 8240f65 commit 95434f4

File tree

4 files changed

+36
-233
lines changed

4 files changed

+36
-233
lines changed

shared/source/os_interface/linux/drm_buffer_object.cpp

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -147,26 +147,24 @@ int BufferObject::exec(uint32_t used, size_t startOffset, unsigned int flags, bo
147147
int ret = ioctlHelper->execBuffer(&execbuf, completionGpuAddress, completionValue);
148148

149149
if (ret != 0) {
150-
do {
151-
int err = this->drm->getErrno();
152-
if (err == EOPNOTSUPP) {
153-
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "ioctl(I915_GEM_EXECBUFFER2) failed with %d. errno=%d(%s)\n", ret, err, strerror(err));
154-
return err;
155-
}
150+
int err = this->drm->getErrno();
151+
if (err == EOPNOTSUPP) {
152+
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "ioctl(I915_GEM_EXECBUFFER2) failed with %d. errno=%d(%s)\n", ret, err, strerror(err));
153+
return err;
154+
}
156155

157-
evictUnusedAllocations(false, true);
158-
ret = ioctlHelper->execBuffer(&execbuf, completionGpuAddress, completionValue);
156+
evictUnusedAllocations(false, true);
157+
ret = ioctlHelper->execBuffer(&execbuf, completionGpuAddress, completionValue);
158+
}
159159

160-
if (ret != 0) {
161-
const auto status = evictUnusedAllocations(true, true);
162-
if (status == MemoryOperationsStatus::GPU_HANG_DETECTED_DURING_OPERATION) {
163-
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "Error! GPU hang detected in BufferObject::exec(). Returning %d\n", gpuHangDetected);
164-
return gpuHangDetected;
165-
}
160+
if (ret != 0) {
161+
const auto status = evictUnusedAllocations(true, true);
162+
if (status == MemoryOperationsStatus::GPU_HANG_DETECTED_DURING_OPERATION) {
163+
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "Error! GPU hang detected in BufferObject::exec(). Returning %d\n", gpuHangDetected);
164+
return gpuHangDetected;
165+
}
166166

167-
ret = ioctlHelper->execBuffer(&execbuf, completionGpuAddress, completionValue);
168-
}
169-
} while (ret != 0 && this->drm->getErrno() == ENXIO);
167+
ret = ioctlHelper->execBuffer(&execbuf, completionGpuAddress, completionValue);
170168
}
171169

172170
if (ret == 0) {

shared/source/os_interface/linux/drm_neo.cpp

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,13 +1324,13 @@ uint64_t Drm::getPatIndex(Gmm *gmm, AllocationType allocationType, CacheRegion c
13241324
return patIndex;
13251325
}
13261326

1327-
int Drm::changeBufferObjectBinding(OsContext *osContext, uint32_t vmHandleId, BufferObject *bo, bool bind) {
1328-
auto vmId = this->getVirtualMemoryAddressSpace(vmHandleId);
1329-
auto ioctlHelper = this->getIoctlHelper();
1327+
int changeBufferObjectBinding(Drm *drm, OsContext *osContext, uint32_t vmHandleId, BufferObject *bo, bool bind) {
1328+
auto vmId = drm->getVirtualMemoryAddressSpace(vmHandleId);
1329+
auto ioctlHelper = drm->getIoctlHelper();
13301330

13311331
uint64_t flags = 0u;
13321332

1333-
if (this->isPerContextVMRequired()) {
1333+
if (drm->isPerContextVMRequired()) {
13341334
auto osContextLinux = static_cast<const OsContextLinux *>(osContext);
13351335
UNRECOVERABLE_IF(osContextLinux->getDrmVmIds().size() <= vmHandleId);
13361336
vmId = osContextLinux->getDrmVmIds()[vmHandleId];
@@ -1345,7 +1345,7 @@ int Drm::changeBufferObjectBinding(OsContext *osContext, uint32_t vmHandleId, Bu
13451345
bool bindCapture = bo->isMarkedForCapture();
13461346
bool bindImmediate = bo->isImmediateBindingRequired();
13471347
bool bindMakeResident = false;
1348-
if (this->useVMBindImmediate()) {
1348+
if (drm->useVMBindImmediate()) {
13491349
bindMakeResident = bo->isExplicitResidencyRequired();
13501350
bindImmediate = true;
13511351
}
@@ -1377,7 +1377,7 @@ int Drm::changeBufferObjectBinding(OsContext *osContext, uint32_t vmHandleId, Bu
13771377

13781378
VmBindExtSetPatT vmBindExtSetPat{};
13791379

1380-
if (this->isVmBindPatIndexProgrammingSupported()) {
1380+
if (drm->isVmBindPatIndexProgrammingSupported()) {
13811381
UNRECOVERABLE_IF(bo->peekPatIndex() == CommonConstants::unsupportedPatIndex);
13821382
ioctlHelper->fillVmBindExtSetPat(vmBindExtSetPat, bo->peekPatIndex(), castToUint64(extensions.get()));
13831383
vmBind.extensions = castToUint64(vmBindExtSetPat);
@@ -1390,13 +1390,13 @@ int Drm::changeBufferObjectBinding(OsContext *osContext, uint32_t vmHandleId, Bu
13901390

13911391
VmBindExtUserFenceT vmBindExtUserFence{};
13921392

1393-
if (this->useVMBindImmediate()) {
1394-
lock = this->lockBindFenceMutex();
1393+
if (drm->useVMBindImmediate()) {
1394+
lock = drm->lockBindFenceMutex();
13951395

1396-
if (!this->hasPageFaultSupport() || bo->isExplicitResidencyRequired()) {
1396+
if (!drm->hasPageFaultSupport() || bo->isExplicitResidencyRequired()) {
13971397
auto nextExtension = vmBind.extensions;
1398-
auto address = castToUint64(this->getFenceAddr(vmHandleId));
1399-
auto value = this->getNextFenceVal(vmHandleId);
1398+
auto address = castToUint64(drm->getFenceAddr(vmHandleId));
1399+
auto value = drm->getNextFenceVal(vmHandleId);
14001400

14011401
ioctlHelper->fillVmBindExtUserFence(vmBindExtUserFence, address, value, nextExtension);
14021402
vmBind.extensions = castToUint64(vmBindExtUserFence);
@@ -1409,7 +1409,7 @@ int Drm::changeBufferObjectBinding(OsContext *osContext, uint32_t vmHandleId, Bu
14091409
break;
14101410
}
14111411

1412-
this->setNewResourceBoundToVM(vmHandleId);
1412+
drm->setNewResourceBoundToVM(vmHandleId);
14131413
} else {
14141414
vmBind.handle = 0u;
14151415
ret = ioctlHelper->vmUnbind(vmBind);
@@ -1424,18 +1424,16 @@ int Drm::changeBufferObjectBinding(OsContext *osContext, uint32_t vmHandleId, Bu
14241424
}
14251425

14261426
int Drm::bindBufferObject(OsContext *osContext, uint32_t vmHandleId, BufferObject *bo) {
1427-
auto ret = changeBufferObjectBinding(osContext, vmHandleId, bo, true);
1427+
auto ret = changeBufferObjectBinding(this, osContext, vmHandleId, bo, true);
14281428
if (ret != 0) {
1429-
do {
1430-
static_cast<DrmMemoryOperationsHandlerBind *>(this->rootDeviceEnvironment.memoryOperationsInterface.get())->evictUnusedAllocations(false, false);
1431-
ret = changeBufferObjectBinding(osContext, vmHandleId, bo, true);
1432-
} while (ret != 0 && getErrno() == ENXIO);
1429+
static_cast<DrmMemoryOperationsHandlerBind *>(this->rootDeviceEnvironment.memoryOperationsInterface.get())->evictUnusedAllocations(false, false);
1430+
ret = changeBufferObjectBinding(this, osContext, vmHandleId, bo, true);
14331431
}
14341432
return ret;
14351433
}
14361434

14371435
int Drm::unbindBufferObject(OsContext *osContext, uint32_t vmHandleId, BufferObject *bo) {
1438-
return changeBufferObjectBinding(osContext, vmHandleId, bo, false);
1436+
return changeBufferObjectBinding(this, osContext, vmHandleId, bo, false);
14391437
}
14401438

14411439
int Drm::createDrmVirtualMemory(uint32_t &drmVmId) {

shared/source/os_interface/linux/drm_neo.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ class Drm : public DriverModel {
129129
uint32_t getVirtualMemoryAddressSpace(uint32_t vmId) const;
130130
MOCKABLE_VIRTUAL int bindBufferObject(OsContext *osContext, uint32_t vmHandleId, BufferObject *bo);
131131
MOCKABLE_VIRTUAL int unbindBufferObject(OsContext *osContext, uint32_t vmHandleId, BufferObject *bo);
132-
MOCKABLE_VIRTUAL int changeBufferObjectBinding(OsContext *osContext, uint32_t vmHandleId, BufferObject *bo, bool bind);
133132
int setupHardwareInfo(const DeviceDescriptor *, bool);
134133
void setupSystemInfo(HardwareInfo *hwInfo, SystemInfo *sysInfo);
135134
void setupCacheInfo(const HardwareInfo &hwInfo);

0 commit comments

Comments
 (0)