nvidia: fix GPU removal with active clients - #1292
Open
alexey-lukashov wants to merge 1 commit into
Open
Conversation
PCI removal removes a GPU from nv_linux_devices before waiting for its usage count to reach zero. Existing kernel clients release references through nvidia_dev_put() or nvidia_dev_put_uuid(), which locate the GPU through that same list. Once removal has unlinked the GPU, those release paths can no longer find it and the removal wait can block indefinitely. Move GPUs being removed to a private list. Keep acquisition lookups limited to active GPUs, while release paths search both active and removing GPUs. Drop the GPU from the private list after its references have drained. This preserves the early unlinking introduced by the removal lifecycle refactor, prevents new clients from acquiring the GPU during removal, and allows existing clients to release their references.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1119
Problem
PCI removal removes a GPU from
nv_linux_devicesbefore waiting for itsusage count to reach zero. Existing kernel clients release their references
through
nvidia_dev_put()ornvidia_dev_put_uuid(), which locate the GPUthrough that same list.
Once removal has unlinked the GPU, those release paths can no longer find it.
The usage count therefore does not reach zero and PCI unbind can remain
blocked indefinitely.
Fix
Move GPUs being removed to a private list. New acquisitions continue to
search only the active-device list, while release paths search both active
and removing devices. Remove the GPU from the private list after its
references have drained.
This preserves the early unlinking introduced by the removal lifecycle
refactor, prevents new clients from acquiring the GPU during removal, and
allows existing clients to release their references.
Testing
Tested with the 610.57.04 open kernel modules on Linux 6.8.0-137-generic and
an NVIDIA GeForce RTX 5080 Laptop GPU.
nvidia-smiand a new GLX client could use the GPU again.