Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows: do not exclude DN_NEED_RESTART drivers if LevelZeroStagedDriverPath is set #204

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading