diff options
author | Alex Goins <agoins@nvidia.com> | 2018-02-23 17:10:31 -0800 |
---|---|---|
committer | Aaron Plattner <aplattner@nvidia.com> | 2018-04-11 14:17:31 -0700 |
commit | 0af9d32f1c968125517be97620043c9ae3b09436 (patch) | |
tree | b4f3ab7950e6ca07a2e80a9aeb112a3bee6356e4 | |
parent | 907b2e2ec8cd0b16590075c97270f32150bb0f50 (diff) |
nvidia-settings: Ignore GPUs that can't be queried from NV-CONTROL
When AllowExternalGpus is not set to TRUE, the X server will ignore
surprise-removable GPUs.
Despite these GPUs being invisible to X and thus invisible to NV-CONTROL, they
are visible via NVML. nvidia-settings can use NVML to query for available GPUs,
and then query additional information from NV-CONTROL. Today, it assumes that a
GPU that is visible via NVML will also be visible via NV-CONTROL, but thanks to
Option "AllowExternalGpus", that is no longer true, resulting in breakage.
The same bug also occurs when using Option "ProbeAllGpus" "False". The effect is
the same as Option "AllowExternalGpus" "False", resulting in only a subset of
GPUs being visible via NV-CONTROL, compared to NVML.
As a short term solution, this change makes nvidia-settings do a mundane
NV-CONTROL query (NV_CTRL_DEPTH_30_ALLOWED) on any GPU target that it allocates,
silently ignoring GPUs that fail. This has the effect of making blacklisted
eGPUs (or other GPUs ignored due to Option "ProbeAllGpus" "False") invisible to
nvidia-settings, preventing further breakages.
NV_CTRL_DEPTH_30_ALLOWED was chosen because it has existed since 2007,
preventing breakage with currently supported drivers, and is unlikely to be
implemented in NVML. If it were to be implemented in NVML, the query could
succeed where we would expect it to fail, preventing the GPU from being properly
ignored.
-rw-r--r-- | src/libXNVCtrlAttributes/NvCtrlAttributesUtils.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributesUtils.c b/src/libXNVCtrlAttributes/NvCtrlAttributesUtils.c index f20108d..b18c199 100644 --- a/src/libXNVCtrlAttributes/NvCtrlAttributesUtils.c +++ b/src/libXNVCtrlAttributes/NvCtrlAttributesUtils.c @@ -685,6 +685,23 @@ static CtrlTarget *nv_alloc_ctrl_target(CtrlSystem *system, t->targetTypeInfo = targetTypeInfo; /* + * detect if the given GPU is visible to the X server and silently fail if + * it is not; if there is a discrepency between NVML and NV-CONTROL, such as + * an eGPU that is invisible to X due to Option "AllowExternalGpus" "true" + * not being specified in xorg.conf, it can cause errors down the line. + */ + + if (target_type == GPU_TARGET) { + /* NV_CTRL_DEPTH_30_ALLOWED expected to succeed for any valid device */ + status = NvCtrlGetAttribute(t, NV_CTRL_DEPTH_30_ALLOWED, &d); + if (status != NvCtrlSuccess) { + nvfree(t); + NvCtrlAttributeClose(handle); + return NULL; + } + } + + /* * get a name for this target; in the case of * X_SCREEN_TARGET targets, just use the string returned * from NvCtrlGetDisplayName(); for other target types, |