Skip to content

nvidia: Open the PCI sysfs config file through init's root on Linux 7.3 - #1512

Open
someonewithpc wants to merge 1 commit into
NVIDIA:mainfrom
someonewithpc:kthread-nullfs-sysfs-config
Open

someonewithpc wants to merge 1 commit into
NVIDIA:mainfrom
someonewithpc:kthread-nullfs-sysfs-config

Conversation

@someonewithpc

Copy link
Copy Markdown

On Linux 7.3 the GPU never runtime suspends: the driver reports "Runtime D3 status: Not supported" on hardware that supports fine-grained RTD3 and suspended on Linux 7.2.9

Linux 7.3 starts every kthread in an empty nullfs (torvalds/linux@32750c77e811d, "fs: start all kthreads in nullfs"), so path lookups from a kthread fail. nv_get_pci_sysfs_config() runs in one during module init: the PCI async probe worker in the open build, and the nv-probe-<bdf> kthread in both builds. Its filp_open() of /sys/bus/pci/devices/<bdf>/config fails, sysfs_config_file stays NULL and nv_dynamic_power_available() returns false

This opens the file inside scoped_with_init_fs() when the kernel exports userspace_init_fs to the module, which covers the open build. The proprietary build can't use it, because userspace_init_fs is EXPORT_SYMBOL_GPL, but it has no async probe either, so there the kthread only serializes the same work and the probe now runs inline when NV_PCI_ASYNC_PROBE_SUPPORTED is 0. Two conftests in nvidia.Kbuild detect the symbol and whether it's GPL-only

A probe after module init (sysfs bind, hotplug) already ran inline and isn't affected

Tested on an ASUS ROG Flow X13 (GV301QH, GTX 1650 Max-Q) with Linux 7.3 and 615.78.08. With the proprietary module, /proc/driver/nvidia/gpus/<bdf>/power goes from "Runtime D3 status: Not supported" to "Enabled (fine-grained)", and the GPU now reaches runtime_status suspended when nothing holds it and wakes when a process opens it. The open module builds with the change

@CLAassistant

CLAassistant commented Nov 1, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Ogtoad

Ogtoad commented Nov 3, 2026

Copy link
Copy Markdown

Confirming this fixes the problem reported in #1507 (Dell Precision 5480, RTX 2000 Ada Laptop GPU [10de:28b8], Linux 7.3.0, 615.78.08 open modules; a second report in that thread covers a Legion Pro 7 with an RTX 5090 Laptop GPU on Gentoo).

Independent runtime evidence from my machine, with a minimal test module that performs both opens from a kthread on 7.3.0:

kthread filp_open(/sys/bus/pci/devices/0000:01:00.0/config) -> -2
kthread file_open_root(userspace_init_fs, /sys/bus/pci/devices/0000:01:00.0/config) -> 0 (on sysfs)

The same driver build enables RTD3 without any change on 6.18, and an unbind/bind from process context on 7.3 gives "Enabled (fine-grained)" with the GPU reaching D3cold, which matches the analysis in the PR description. Full kprobe trace, debug log and nvidia-bug-report are in #1507.

@Aspecky

Aspecky commented Nov 16, 2026

Copy link
Copy Markdown

Tested on Linux 7.3.4 (Arch) with an AMD root port and an RTX 5070 Laptop GPU (GB206M).
This fixes RTD3 on both 615.78.08 and 620.70.06, and the GPU and root port reach D3cold. Details, with in-driver printks of the plain vs scoped open, are in #1507 (comment).

The PR now conflicts with main (620.70.06). Only hunk 1 is affected: in 620 the #include <linux/kthread.h> line is followed by the NV_SEQ_READ_ITER_PRESENT includes. Hunks 2-3 and the Kbuild hunk apply with offsets only. This is what I use on 620.70.06, and it applies to main with --fuzz=0:

@@ -46,6 +46,10 @@
 #include <linux/iommu.h>
 #include <linux/kthread.h>
 
+#if NV_CHECK_EXPORT_SYMBOL(userspace_init_fs)
+#include <linux/fs_struct.h>
+#endif
+
 #if defined(NV_SEQ_READ_ITER_PRESENT)
 #include <linux/seq_file.h>
 #include <linux/kernfs.h>

Linux 7.3 starts every kthread in an empty nullfs (commit 32750c77e811d,
"fs: start all kthreads in nullfs"), so path lookups from kthreads fail.
nv_get_pci_sysfs_config() runs in one during module init: the PCI async
probe worker in the open build, and the nv-probe-<bdf> kthread in both.
Its filp_open() of /sys/bus/pci/devices/<bdf>/config then fails,
sysfs_config_file stays NULL, nv_dynamic_power_available() returns false
and RM reports "Runtime D3 status: Not supported". The GPU never runtime
suspends

Open the file inside scoped_with_init_fs() where userspace_init_fs is
available to the module. That covers the open build. A non-GPL build
can't use it, since userspace_init_fs is EXPORT_SYMBOL_GPL, but it has no
async probe either, so the kthread only serializes the same work. Probe
inline there when NV_PCI_ASYNC_PROBE_SUPPORTED is 0

A probe after module init (sysfs bind, hotplug) already ran inline and is
not affected
@avih7531

Copy link
Copy Markdown

Confirmed working with PR #1512 applied to NVIDIA 620.73.04 on Arch Linux.

System:

The patch applied cleanly to the 620.73.04 sources, including nv-pci.c and nvidia.Kbuild. The DKMS modules compiled and installed successfully.

After the GPU was detected and bound to the patched NVIDIA driver, I observed:

Runtime D3 status: Enabled (fine-grained)
Video Memory: Off

power/control:        auto
power/runtime_status: suspended
power_state:          D3cold

Thanks for the patch!

@agustux agustux left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed working on Turing too, which I think is the first Turing data point for #1507. Applied to 620.73.04 on Arch.

System:

  • Laptop: Lenovo ThinkPad P53, Intel iGPU drives the panel, dGPU behind root port 00:01.0
  • GPU: Quadro T2000 Mobile / Max-Q (TU117GLM, 10de:1fb8)
  • Kernel: 7.3.5-arch1-1
  • Driver: nvidia-open-dkms 620.73.04, rebuilt with this PR applied
  • Configuration: NVreg_DynamicPowerManagement=0x02, PCI runtime PM set to auto, nvidia modules loaded from the initramfs

The patch applied cleanly to the 620.73.04 sources, and conftest detected userspace_init_fs as both present and GPL.

Runtime D3 status power/runtime_status
7.3.5, stock 620.73.04 Not supported active
7.3.5, patched 620.73.04 Enabled (fine-grained) suspended
6.18.64-1-lts, stock 620.73.04 Enabled (fine-grained) suspended

With the patched driver at idle:

Video Memory: Off
power_state:  D3cold

Thanks!

@yannleretaille

yannleretaille commented Nov 24, 2026 •

Copy link
Copy Markdown

Confirmed working on 7.3.5-arch1-1 with Intel iGPU + RTX 3050 Ti Mobile and PRIME render offload.
Power state goes back to D3cold when not in use and PRIME still works.

If anyone wants to build this themselves on arch, I forked the official arch package:

git clone --depth 1 --single-branch --no-tags --branch fix-rtd3-linux-7.3 https://gitlab.archlinux.org/yannleretaille/nvidia-utils.git
cd nvidia-utils
makepkg -sci

Note: This is the dkms version, so you'll need linux-headers for all current kernels.

OmerFarukOruc added a commit to OmerFarukOruc/nixos-config that referenced this pull request Nov 24, 2026
…4070 sleep on Linux 7.3

The RTX 4070 never runtime-suspended on kernel 7.3: the driver reported
"Runtime D3 status: Not supported", because kernel threads start in an
empty root since 7.3 and the probe cannot open the card's sysfs config
file. No driver release fixes it, 620.73.04 included.

Take the driver from the `stable` release of the kernel flake's nixpkgs
(620.73.04) instead of the 615.78.08 pin, and add three patches to its
open module in graphics.nix: the two NVPCF patches the pin carried and
the patch of NVIDIA pull request 1512 for the sysfs open. The `patches`
check now applies them, so a driver release that breaks one fails the
gate.

`scripts/build.sh` built nvidia-open-620.73.04-7.3.5 and the `patches`
check with the three patches.

Refs: NVIDIA/open-gpu-kernel-modules#1507
Refs: NVIDIA/open-gpu-kernel-modules#1512
Refs: #351
@busybox11

Copy link
Copy Markdown

Tested this patch on my laptop (ASUS ProArt P16 H7606, RTX 5070 Laptop 10de:2d18, kernel 7.3.5, 615.78.08 open kernel modules on NixOS).

Applied cleanly (with minor offset fuzz on nv-pci.c and nvidia.Kbuild) and built without issues. After rebooting, /proc/driver/nvidia/gpus/0000:64:00.0/power switched from:

Runtime D3 status:          Not supported

to:

Runtime D3 status:          Enabled (fine-grained)

Can confirm it is working properly, D3cold is back and power consumption is a lot more reasonable!

@larsschellhas

Copy link
Copy Markdown

One case that may be worth checking for this PR. The description says that a probe after module init (sysfs bind, hotplug) runs inline and isn't affected. A sysfs bind runs in the writing process, but I would expect a hotplug probe to run in the kernel thread that handles the event, which on 7.3 also starts in nullfs.

On a Surface Book 3, where the dGPU sits in the detachable base, with the proprietary 595.99.02 on 7.3.6, RTD3 is enabled after boot and Not supported after a re-attach (details in #1507). In the same boot, unbinding and binding from a process restored it. I have not tested this PR and have not traced the context of the hotplug probe.

From reading the diff: the open build would be covered in either case, because the scoped open is inside nv_get_pci_sysfs_config(). The proprietary build would still fail after a hotplug.

@Anfeket

Anfeket commented Nov 27, 2026

Copy link
Copy Markdown

Patch works for me as well, switches to D3cold as supposed to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants