← Back to Pull requests

nvpassthrough: keep a card's other functions bound across driver switches #130

Open
unknown opened this pull request with 379 lines diff across 4 files
View on GitHub
unknown unknown commented on Oct 21, 2026 05:47 UTC
Author

Follow-up to kubernetes-sigs/dra-driver-nvidia-gpu#1567, where the maintainers asked for the fix to go here.

Problem

Unbind unbinds the device and every other PCI function of the same card (HDMI audio, and since #115 also the VirtualLink USB functions), and clears their driver_override. BindToDriver then binds only the device itself. So a caller that switches a GPU with Unbind + BindToDriver, as the DRA driver does, leaves the other functions without a driver after every switch, in both directions:

  • To vfio: the GPU lands on vfio-pci, but its audio function is left unbound instead of moving to vfio with it.

  • Back to the host driver: the audio function is unbound again, and nothing binds it anywhere. A host that keeps it on vfio-pci for passthrough (for example via vfio_pci ids=, so that KubeVirt can pass it to a VM as a PCI host device) loses that binding on every VM start and stop.
  • Fix

  • BindToDriver binds the other functions of the card as well when the target is a vfio driver (vfio-pci or a variant), reusing the loop from BindToVFIODriver (now bindAuxDevices).

  • Unbind only unbinds the device it is given. The bind side already moves the other functions to vfio, and no API binds them back to a host driver, so unbinding them only left them driverless.
  • With this, Unbind + BindToDriver(vfio) moves the whole card to vfio, and Unbind + BindToDriver(nvidia) returns only the GPU and leaves the other functions where they are. The DRA driver needs no code change, only the dependency bump.

    The Unbind change is a behaviour change for callers that expect it to free the whole card. The only importer I could find is the DRA driver (k8s-driver-manager carries its own copy in internal/nvpassthrough). If you would rather keep Unbind as it is, an alternative is a separate method that unbinds only the given function, which the DRA driver would then call.

    Tests

  • TestIsVFIODriver covers the vfio driver check, including variant drivers and both _ and - spellings.

  • make assert-fmt vet check-vendor, go test ./pkg/nvpassthrough/ and golangci-lint run ./pkg/nvpassthrough/... pass.

  • dra-driver-nvidia-gpu main builds and its gpu-kubelet-plugin tests pass with this branch via a replace directive and no other change.

  • Hardware: Talos v1.14.0, Kubernetes v1.36.1, NVIDIA 595.91.07, RTX 3090 Ti (audio function on vfio-pci via vfio_pci ids=), KubeVirt v1.9.0, running the DRA driver built against this branch with no DRA driver code change. Stopping the VM returned the GPU to nvidia and left the audio function on vfio-pci; starting it again moved the GPU to vfio-pci, and the VM came up with the GPU and the audio function (as a KubeVirt PCI host device). With v0.12.0 and v0.13.0 the audio function is left without a driver after each switch. The vfio direction of BindToDriver did not have to move the audio function in that run, since it was already on vfio-pci; that path is the same loop BindToVFIODriver uses.
  • Diff: 379 lines (+284 / -95) across 4 files Reviewer: cdesiniotis Review duration: 18235m
    All Vouch review confidence checks passed
    Residual risk 0.24 = Change Risk (0.43) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 379 lines diff across 4 files
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.355
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #130"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.9% (MEDIUM) · Higher = larger blast radius
    42.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 24.5% · Safe to merge
    24.5%