Skip to content

Commit

Permalink
Prevent driver removal if initDrivers support exists
Browse files Browse the repository at this point in the history
Signed-off-by: Neil R. Spruit <neil.r.spruit@intel.com>
  • Loading branch information
nrspruit committed Sep 13, 2024
1 parent 95bd433 commit 418ce29
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
7 changes: 7 additions & 0 deletions scripts/templates/ldrddi.cpp.mako
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,13 @@ ${tbl['export']['name']}(
atLeastOneDriverValid = true;
else
drv.initStatus = getTableResult;
%if namespace != "zes":
%if tbl['name'] == "Global":
if (drv.dditable.ze.Global.pfnInitDrivers) {
loader::context->initDriversSupport = true;
}
%endif
%endif
%else:
result = getTable( version, &drv.dditable.${n}.${tbl['name']});
%endif
Expand Down
3 changes: 3 additions & 0 deletions source/loader/ze_ldrddi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6352,6 +6352,9 @@ zeGetGlobalProcAddrTable(
atLeastOneDriverValid = true;
else
drv.initStatus = getTableResult;
if (drv.dditable.ze.Global.pfnInitDrivers) {
loader::context->initDriversSupport = true;
}
}

if(!atLeastOneDriverValid)
Expand Down
11 changes: 6 additions & 5 deletions source/loader/ze_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,13 @@ namespace loader
std::string freeLibraryErrorValue;
ze_result_t result = init_driver(*it, flags, desc, globalInitStored, sysmanGlobalInitStored, sysmanOnly);
if(result != ZE_RESULT_SUCCESS) {
if (debugTraceEnabled) {
std::string errorMessage = "Check Drivers Failed on " + it->name + " , driver will be removed. " + initName + " failed with ";
debug_trace_message(errorMessage, loader::to_string(result));
}
// If the driver has already been init and handles are to be read, then this driver cannot be removed from the list.
if (!it->driverInuse) {
// Also, if any driver supports zeInitDrivers, then no driver can be removed to allow for different sets of drivers.
if (!it->driverInuse && !loader::context->initDriversSupport) {
if (debugTraceEnabled) {
std::string errorMessage = "Check Drivers Failed on " + it->name + " , driver will be removed. " + initName + " failed with ";
debug_trace_message(errorMessage, loader::to_string(result));
}
it = drivers->erase(it);
// If the number of drivers is now ==1, then we need to reinit the ddi tables to pass through.
// If ZE_ENABLE_LOADER_INTERCEPT is set to 1, then even if drivers were removed, don't reinit the ddi tables.
Expand Down
1 change: 1 addition & 0 deletions source/loader/ze_loader_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ namespace loader
bool driverEnvironmentQueried = false;

bool forceIntercept = false;
bool initDriversSupport = false;
std::vector<zel_component_version_t> compVersions;
const char *LOADER_COMP_NAME = "loader";

Expand Down

0 comments on commit 418ce29

Please sign in to comment.