Repository navigation
nvidia: Open the PCI sysfs config file through init's root on Linux 7.3 - #1512
someonewithpc wants to merge 1 commit into
Conversation
|
Confirming this fixes the problem reported in #1507 (Dell Precision 5480, RTX 2000 Ada Laptop GPU Independent runtime evidence from my machine, with a minimal test module that performs both opens from a kthread on 7.3.0: 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. |
|
Tested on Linux 7.3.4 (Arch) with an AMD root port and an RTX 5070 Laptop GPU (GB206M). The PR now conflicts with @@ -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
369378d to
c66b7b8
Compare
|
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 After the GPU was detected and bound to the patched NVIDIA driver, I observed: Thanks for the patch! |
agustux
left a comment
There was a problem hiding this comment.
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!
|
Confirmed working on 7.3.5-arch1-1 with Intel iGPU + RTX 3050 Ti Mobile and PRIME render offload. If anyone wants to build this themselves on arch, I forked the official arch package: Note: This is the dkms version, so you'll need |
…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
|
Tested this patch on my laptop (ASUS ProArt P16 H7606, RTX 5070 Laptop Applied cleanly (with minor offset fuzz on to: Can confirm it is working properly, D3cold is back and power consumption is a lot more reasonable! |
|
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 From reading the diff: the open build would be covered in either case, because the scoped open is inside |
|
Patch works for me as well, switches to D3cold as supposed to. |
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
kthreadin an emptynullfs(torvalds/linux@32750c77e811d, "fs: start all kthreads in nullfs"), so path lookups from akthreadfail.nv_get_pci_sysfs_config()runs in one during module init: the PCI async probe worker in the open build, and thenv-probe-<bdf>kthreadin both builds. Itsfilp_open()of/sys/bus/pci/devices/<bdf>/configfails,sysfs_config_filestaysNULLandnv_dynamic_power_available()returnsfalseThis opens the file inside
scoped_with_init_fs()when the kernel exportsuserspace_init_fsto the module, which covers the open build. The proprietary build can't use it, becauseuserspace_init_fsisEXPORT_SYMBOL_GPL, but it has no async probe either, so there thekthreadonly serializes the same work and the probe now runs inline whenNV_PCI_ASYNC_PROBE_SUPPORTEDis 0. Two conftests innvidia.Kbuilddetect the symbol and whether it's GPL-onlyA 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>/powergoes from "Runtime D3 status: Not supported" to "Enabled (fine-grained)", and the GPU now reachesruntime_statussuspendedwhen nothing holds it and wakes when a process opens it. The open module builds with the change