I hit this today after upgrading to the 4.9.x series using the nvidia-340 (legacy) drivers. Basically after modprobing the nvidia driver, there is a kernel panic and in one case a completely unresponsive system. https://devtalk.nvidia.com/default/topic/981852/linux/resolution-patch-attached-for-nvidia-linux-driver-340-98-x86_64-using-linux-kernel-4-9/ And the patch in the aforementioned post fixes the issue. Perhaps it could be added to the tree for others benefit. Reproducible: Always
Pardon me, it was this post https://devtalk.nvidia.com/default/topic/982052/linux/latest-nvidia-driver-340-101-builds-compiles-properly-but-fails-to-load-has-errors-with-linux-kernel-4-9-resolved-with-patch-/ With a slightly different patch. I'll explicitly attach the working patch for clarity. It applies to both the 340.101 and 340.102 drivers.
Created attachment 469912 [details, diff] Patch to fix kernel panic on 4.9.x series kernels Patch from forum post in Comment #2
To confirm, adding this
To confirm, adding this patch to /etc/portage/patches/x11-drivers/nvidia-drivers-340.102/ is necessary to have a working amd64 stable system with the offending period graphics hardware. None of the in-tree nvidia-drivers work with the current amd64 stable gentoo-sources kernels after gentoo-sources-4.4.39 without this patch. Despite originally being a 340.98 patch, it is required (not included) up to 340.102 (tested .101, .101-r1 and .102). According to lspci, hardware in this system is 02:00.0 VGA compatible controller: NVIDIA Corporation G96 [GeForce 9400 GT] (rev a1) Another symptom of missing this patch is an endless spew of kernel log errors including "driver nvidia is already registered" (hopefully this will help other people find this bug).
So is this about a kernel panic or a modprobe error or is it the usual "let's bunch up ten different agonies into one angry little ball" kind of bug report?
On the surface it manifests as a modprobe error with the "driver nvidia already registered" message. However, I just wanted to state that it is more serious than that since it also can result in immediate kernel panics after the modprobe, and an unusable system; not just an annoyance that I cannot load my graphics stack. No angry little ball, just trying to keep Gentoo great :)
Created attachment 485568 [details, diff] kernel-4.9.x.patch I confirm the problem in the first post. My config: gentoo-sources-4.9.37 x11-drivers/nvidia-drivers-340.102-r1 modprobe failed, X did not start. The patch I attached is the same, but fixed to work when I put it in /etc/portage/patches/x11-drivers/nvidia-drivers-340.102-r1/kernel-4.9.patch With this patch modprobe nvidia works, but I had to reboot after applying the patch. X is working fine now. My VGA is in an old ASUS laptop: (lspci output): 01:00.0 VGA compatible controller: NVIDIA Corporation G98M [GeForce 9300M GS] (rev a1) I hope it helps someone. I agree with David this (or some similar) patch should be included in the tree for other Gentoo users comfort! Thank you!
I upgraded Gentoo on another machine, it is amd64 keywords this time, and the same problem came again. The attached patch fixed it, it works fine. [ebuild R ] sys-kernel/gentoo-sources-4.9.34:4.9.34::gentoo USE="-build -experimental -symlink" 0 KiB [ebuild R ~] x11-drivers/nvidia-drivers-340.102-r1:0/340::gentoo USE="X acpi multilib tools -pax_kernel -static-libs -uvm" ABI_X86="(64) -32 (-x32)" 0 KiB 03:00.0 VGA compatible controller: NVIDIA Corporation G94GL [Quadro FX 1800] (rev a1) (prog-if 00 [VGA controller]) Subsystem: NVIDIA Corporation G94GL [Quadro FX 1800] I suppose this problem affects many Gentoo users installing stable kernel and legacy nvidia-drivers for older Nvidia cards. I can't say for sure this patch works for everyone, but the stable gentoo-sources and the unpatched nvidia-drivers-340.110 causes very ugly kernel panics and stability issues too (!).
A suggest applying the patch in the tree OR masking nvidia-drivers-340.102 from installing on kernel-4.9 (or above)
(In reply to László Szalma from comment #9) > A suggest applying the patch in the tree OR masking nvidia-drivers-340.102 > from installing on kernel-4.9 (or above) I suggest you complain to Nvidia. This bug report doesn't even state an actual issue in the Summary yet. Or even a link to an upstream complaint.
Dear Jeroen, I have my problem solved by googling and using forums.gentoo.org and this issue. My "complaint" is only for other users and the Gentoo community. I hope I helped to bring this issue closer to the solution. I found this thread: https://devtalk.nvidia.com/default/topic/982052/-latest-nvidia-driver-340-101-builds-compiles-properly-but-fails-to-load-has-errors-with-linux-kernels-4-9-0-4-9-7-resolved-with-patch-/ I hope this will be good for "upstream complaint". I suggest to change the issue title accordingly, as I can't edit it, for example: "x11-drivers/nvidia-drivers-340.102 - builds but fails to load (and work) with linux-4.9" Thanks for your reply, please be patient we are on the same side :)
This patch is used in Ubuntu/Debian https://github.com/tseliot/nvidia-graphics-drivers/blob/340/debian/dkms_nvidia/patches/buildfix_kernel_4.9.patch This is the same as the attached. There might be some other useful stuff there.
patch for kernel 4.12 https://devtalk.nvidia.com/default/topic/1008771/linux/nvidia-340-xx-compile-error-with-kernel-4-12-rc1/post/5179612/#5179612 Full ebuild with patches: https://github.com/thankjura/overlay/tree/master/x11-drivers/nvidia-drivers
This upstream bug is for me solved with the new nvidia-drivers-304.137 release (and probably 340.104 too?! :)) Thanks!
Presumed fixed.