Skip to content

Commit

Permalink
windows: do not exclude DN_NEED_RESTART drivers if LevelZeroStagedDri…
Browse files Browse the repository at this point in the history
…verPath is set

Signed-off-by: Lisanna Dettwyler <lisanna.dettwyler@intel.com>
  • Loading branch information
lisanna-dettwyler committed Sep 23, 2024
1 parent 24ad9d6 commit 583b9f7
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion source/loader/windows/driver_discovery_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,35 @@ std::vector<DriverLibraryPath> discoverEnabledDrivers() {
return enabledDrivers;
}

bool isStagedDriverPathSetForDisplayAdapter(DEVINST dnDevNode) {
static constexpr char stagedDriverPathKey[] = "LevelZeroStagedDriverPath";

HKEY hkey = {};
CONFIGRET configErr = CM_Open_DevNode_Key(dnDevNode, KEY_QUERY_VALUE, 0,
RegDisposition_OpenExisting, &hkey,
CM_REGISTRY_SOFTWARE);

if (CR_SUCCESS != configErr) {
assert(false && "CM_Open_DevNode_Key failed");
return false;
}

DWORD regValueType = {};
DWORD pathSize = {};
LSTATUS regOpStatus = RegQueryValueExA(hkey, stagedDriverPathKey, NULL,
&regValueType, NULL, &pathSize);

bool isStagedDriverPathSet = false;
if (ERROR_SUCCESS == regOpStatus) {
isStagedDriverPathSet = true;
}

regOpStatus = RegCloseKey(hkey);
assert((ERROR_SUCCESS == regOpStatus) && "RegCloseKey failed");

return isStagedDriverPathSet;
}

bool isDeviceAvailable(DEVINST devnode) {
ULONG devStatus = {};
ULONG devProblem = {};
Expand All @@ -61,7 +90,9 @@ bool isDeviceAvailable(DEVINST devnode) {

bool isInInvalidState = (devStatus & DN_HAS_PROBLEM)
&& (devProblem == CM_PROB_NEED_RESTART);
isInInvalidState |= (DN_NEED_RESTART == (devStatus & DN_NEED_RESTART));
if (! isStagedDriverPathSetForDisplayAdapter(devnode)) {
isInInvalidState |= (DN_NEED_RESTART == (devStatus & DN_NEED_RESTART));
}
isInInvalidState |= (devStatus & DN_HAS_PROBLEM)
&& (devProblem == CM_PROB_DISABLED);

Expand Down

0 comments on commit 583b9f7

Please sign in to comment.