NVIDIA Linux x86_64 340.98 Driver not building with Kernel 4.9.0-rc2+ [RESOLVED]

A patch is required for the NVIDIA Linux 340.98 driver, as there have been many changes in the Kernel file /include/linux/mm.h from October 8 - 25, 2016. Kernel version is: 4.9.0-rc2 (git-ed99d36).

Link to Linux Kernel history for file mm.h:


Relevant NVIDIA log output:

/usr/src/linux-4.9.0-rc2-git-ed99d36/arch/x86/include/asm/uaccess.h: In function ‘copy_from_user’:
/usr/src/linux-4.9.0-rc2-git-ed99d36/arch/x86/include/asm/uaccess.h:691:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (likely(sz < 0 || sz >= n)) {
/usr/src/linux-4.9.0-rc2-git-ed99d36/include/linux/compiler.h:167:40: note: in definition of macro ‘likely’
# define likely(x) __builtin_expect(!!(x), 1)
/usr/src/linux-4.9.0-rc2-git-ed99d36/arch/x86/include/asm/uaccess.h: In function ‘copy_to_user’:
/usr/src/linux-4.9.0-rc2-git-ed99d36/arch/x86/include/asm/uaccess.h:711:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (likely(sz < 0 || sz >= n)) {
/usr/src/linux-4.9.0-rc2-git-ed99d36/include/linux/compiler.h:167:40: note: in definition of macro ‘likely’
# define likely(x) __builtin_expect(!!(x), 1)
/home/ejm/unpack2/NVIDIA-Linux-x86_64-340.98/kernel/os-mlock.c: In function ‘os_lock_user_pages’:
/home/ejm/unpack2/NVIDIA-Linux-x86_64-340.98/kernel/os-mlock.c:49:48: warning: passing argument 4 of ‘get_user_pages’ makes pointer from integer without a cast [-Wint-conversion]
page_count, write, force, user_pages, NULL);
In file included from /home/ejm/unpack2/NVIDIA-Linux-x86_64-340.98/kernel/nv-linux.h:68:0,
from /home/ejm/unpack2/NVIDIA-Linux-x86_64-340.98/kernel/os-mlock.c:15:
/usr/src/linux-4.9.0-rc2-git-ed99d36/include/linux/mm.h:1278:6: note: expected ‘struct page **’ but argument is of type ‘NvBool {aka unsigned char}’
long get_user_pages(unsigned long start, unsigned long nr_pages,
/home/ejm/unpack2/NVIDIA-Linux-x86_64-340.98/kernel/os-mlock.c:49:55: error: passing argument 5 of ‘get_user_pages’ from incompatible pointer type [-Werror=incompatible-pointer-types]
page_count, write, force, user_pages, NULL);
In file included from /home/ejm/unpack2/NVIDIA-Linux-x86_64-340.98/kernel/nv-linux.h:68:0,
from /home/ejm/unpack2/NVIDIA-Linux-x86_64-340.98/kernel/os-mlock.c:15:
/usr/src/linux-4.9.0-rc2-git-ed99d36/include/linux/mm.h:1278:6: note: expected ‘struct vm_area_struct **’ but argument is of type ‘struct page **’
long get_user_pages(unsigned long start, unsigned long nr_pages,
In file included from /home/ejm/unpack2/NVIDIA-Linux-x86_64-340.98/kernel/os-mlock.c:15:0:
/home/ejm/unpack2/NVIDIA-Linux-x86_64-340.98/kernel/nv-linux.h:2065:41: error: too many arguments to function ‘get_user_pages’
#define NV_GET_USER_PAGES get_user_pages
/home/ejm/unpack2/NVIDIA-Linux-x86_64-340.98/kernel/os-mlock.c:48:11: note: in expansion of macro ‘NV_GET_USER_PAGES’
ret = NV_GET_USER_PAGES((unsigned long)address,
In file included from /home/ejm/unpack2/NVIDIA-Linux-x86_64-340.98/kernel/nv-linux.h:68:0,
from /home/ejm/unpack2/NVIDIA-Linux-x86_64-340.98/kernel/os-mlock.c:15:
/usr/src/linux-4.9.0-rc2-git-ed99d36/include/linux/mm.h:1278:6: note: declared here
long get_user_pages(unsigned long start, unsigned long nr_pages,
cc1: some warnings being treated as errors
make[3]: *** [/usr/src/linux-4.9.0-rc2-git-ed99d36/scripts/Makefile.build:291: /home/ejm/unpack2/NVIDIA-Linux-x86_64-340.98/kernel/os-mlock.o] Error 1
make[2]: *** [/usr/src/linux-4.9.0-rc2-git-ed99d36/Makefile:1482: module/home/ejm/unpack2/NVIDIA-Linux-x86_64-340.98/kernel] Error 2
make[2]: Leaving directory ‘/usr/src/linux-4.9.0-rc2-git-ed99d36’
make[1]: *** [Makefile:150: sub-make] Error 2
make[1]: Leaving directory ‘/usr/src/linux-4.9.0-rc2-git-ed99d36’
nvidia.ko failed to build!
make: *** [Makefile:185: nvidia.ko] Error 1
→ Error.
ERROR: Unable to build the NVIDIA kernel module.
ERROR: Installation has failed. Please see the file ‘/var/log/nvidia-installer.log’ for details. You may find suggestions on fixing installation problems in the README available on the Linux driver download page at www.nvidia.com.

My Linux OS: openSUSE x86-64
Linux Kernel: 4.9.0-rc2 (git-ed99d36)

Hi there, please apply following patch to get it working: https://raw.githubusercontent.com/manjaro/packages-extra/master/linux49-extramodules/nvidia-340xx/linux-4.9-rc2.patch



I applied your patch and the NVIDIA 340.98 driver (nvidia.ko) for Linux Kernel 4.9.0-rc2 (git-ed99d36) did compile successfully. So the build process worked.

The issue now is, when I attempt to load this driver using this kernel, it crashes and does not load.

Here is the relevant dmesg output:

[ 13.111192] gpio_ich: GPIO from 462 to 511 on gpio_ich
[ 13.878032] nvidia: loading out-of-tree module taints kernel.
[ 13.878089] nvidia: module license ‘NVIDIA’ taints kernel.
[ 13.878132] Disabling lock debugging due to kernel taint
[ 13.902362] vgaarb: device changed decodes: PCI:0000:01:00.0,olddecodes=io+mem,decodes=none:owns=io+mem
[ 13.902831] Error: Driver ‘nvidia’ is already registered, aborting…
[ 13.902888] NVRM: DRM init failed
[ 13.903150] NVRM: NVIDIA init module failed!
[ 14.137011] snd_hda_intel 0000:01:00.1: Disabling MSI
[ 14.137076] snd_hda_intel 0000:01:00.1: Handle vga_switcheroo audio client
[ 14.514428] snd_hda_codec_realtek hdaudioC0D2: autoconfig for ALC883: line_outs=1 (0x14/0x0/0x0/0x0/0x0) type:line
[ 14.514493] snd_hda_codec_realtek hdaudioC0D2: speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
[ 14.514548] snd_hda_codec_realtek hdaudioC0D2: hp_outs=1 (0x1b/0x0/0x0/0x0/0x0)
[ 14.514602] snd_hda_codec_realtek hdaudioC0D2: mono: mono_out=0x0
[ 14.514646] snd_hda_codec_realtek hdaudioC0D2: dig-out=0x1e/0x0
[ 14.514690] snd_hda_codec_realtek hdaudioC0D2: inputs:
[ 14.514734] snd_hda_codec_realtek hdaudioC0D2: Rear Mic=0x18
[ 14.514779] snd_hda_codec_realtek hdaudioC0D2: Front Mic=0x19
[ 14.514823] snd_hda_codec_realtek hdaudioC0D2: Line=0x1a
[ 14.514866] snd_hda_codec_realtek hdaudioC0D2: CD=0x1c
[ 14.526830] input: HDA Digital PCBeep as /devices/pci0000:00/0000:00:1b.0/sound/card0/input7
[ 14.527975] input: HDA Intel Rear Mic as /devices/pci0000:00/0000:00:1b.0/sound/card0/input8
[ 14.528271] input: HDA Intel Front Mic as /devices/pci0000:00/0000:00:1b.0/sound/card0/input9
[ 14.528499] input: HDA Intel Line as /devices/pci0000:00/0000:00:1b.0/sound/card0/input10
[ 14.528719] input: HDA Intel Line Out as /devices/pci0000:00/0000:00:1b.0/sound/card0/input11
[ 14.772665] media: Linux media interface: v0.10
[ 14.943448] Linux video capture interface: v2.00
[ 15.280386] usbcore: registered new interface driver snd-usb-audio
[ 15.298275] uvcvideo: Found UVC 1.00 device Webcam C110 (046d:0829)
[ 15.315505] uvcvideo 1-5:1.0: Entity type for entity Processing 2 was not initialized!
[ 15.315572] uvcvideo 1-5:1.0: Entity type for entity Extension 6 was not initialized!
[ 15.315629] uvcvideo 1-5:1.0: Entity type for entity Camera 1 was not initialized!
[ 15.315861] input: Webcam C110 as /devices/pci0000:00/0000:00:1d.7/usb1/1-5/1-5:1.0/input/input12
[ 15.316846] usbcore: registered new interface driver uvcvideo
[ 15.316899] USB Video Class driver (1.1.1)
[ 15.567569] Adding 4223996k swap on /dev/sda7. Priority:-1 extents:1 across:4223996k FS
[ 15.745184] input: HDA NVidia HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input13
[ 15.747916] input: HDA NVidia HDMI/DP,pcm=7 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input14
[ 15.748320] input: HDA NVidia HDMI/DP,pcm=8 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input15
[ 15.748567] input: HDA NVidia HDMI/DP,pcm=9 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input16
[ 17.160271] EXT4-fs (sda6): mounted filesystem with ordered data mode. Opts: acl,user_xattr
[ 17.328274] EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: acl,user_xattr
[ 20.651113] No iBFT detected.
[ 20.741170] 8139too 0000:04:01.0 enp4s1: link up, 100Mbps, full-duplex, lpa 0x41E1
[ 45.410728] ------------[ cut here ]------------
[ 45.410744] WARNING: CPU: 0 PID: 1301 at fs/proc/generic.c:345 proc_register+0xe1/0x104
[ 45.410747] proc_dir_entry ‘driver/nvidia’ already registered
[ 45.410748] Modules linked in: nvidia(PO+) nf_log_ipv6 xt_pkttype nf_log_ipv4 nf_log_common xt_LOG xt_limit iscsi_ibft iscsi_boot_sysfs msr uvcvideo videobuf2_vmalloc videobuf2_memops videobuf2_v4l2 snd_hda_codec_hdmi snd_usb_audio videobuf2_core snd_usbmidi_lib videodev media snd_rawmidi snd_seq_device snd_hda_codec_realtek snd_hda_codec_generic snd_hda_intel snd_hda_codec ip6t_REJECT snd_hda_core nf_reject_ipv6 snd_hwdep xt_tcpudp nf_conntrack_ipv6 nf_defrag_ipv6 snd_pcm snd_timer ip6table_raw snd gpio_ich ipt_REJECT nf_reject_ipv4 iTCO_wdt iTCO_vendor_support lpc_ich ppdev 8139too r8169 acpi_cpufreq parport_pc i2c_i801 tpm_tis iptable_raw soundcore coretemp tpm_tis_core mac_hid drm parport i2c_smbus mii xt_CT shpchp pcspkr iptable_filter button ip6table_mangle nf_conntrack_netbios_ns nf_conntrack_broadcast
[ 45.410811] nf_conntrack_ipv4 nf_defrag_ipv4 ip_tables xt_conntrack nf_conntrack ip6table_filter ip6_tables x_tables usbkbd hid_generic hid_a4tech usbmouse usbhid hid serio_raw dm_multipath scsi_dh_rdac scsi_dh_emc scsi_dh_alua autofs4
[ 45.410831] CPU: 0 PID: 1301 Comm: modprobe Tainted: P O 4.9.0-rc2-git-ed99d36-Pogorze-Karpackie-CUSTOM-KERNEL #1
[ 45.410833] Hardware name: Gigabyte Technology Co., Ltd. G31M-ES2C/G31M-S2C, BIOS F6 02/05/2009
[ 45.410836] ffffc90000afbb40 ffffffff81297b9a ffffc90000afbb90 0000000000000000
[ 45.410841] ffffc90000afbb80 ffffffff81054561 0000015900afbbf8 ffff88014908fcc0
[ 45.410845] ffff8801498521c0 ffff88014aada300 0000000000000000 ffff88014aada338
[ 45.410850] Call Trace:
[ 45.410857] [] dump_stack+0x4d/0x63
[ 45.410861] [] __warn+0xc2/0xdd
[ 45.410864] [] warn_slowpath_fmt+0x4b/0x53
[ 45.410870] [] ? ida_get_new_above+0x173/0x188
[ 45.410873] [] proc_register+0xe1/0x104
[ 45.410877] [] proc_mkdir_data+0x62/0x80
[ 45.410880] [] proc_mkdir_mode+0x13/0x15
[ 45.411163] [] nv_register_procfs+0x3d/0x1a0 [nvidia]
[ 45.411399] [] nvidia_init_module+0x245/0x701 [nvidia]
[ 45.411645] [] ? nv_drm_init+0x15/0x15 [nvidia]
[ 45.411885] [] nvidia_frontend_init_module+0x83/0x8ea [nvidia]
[ 45.412007] [] ? nv_drm_init+0x15/0x15 [nvidia]
[ 45.412007] [] do_one_initcall+0x90/0x113
[ 45.412007] [] ? __vunmap+0x98/0x9e
[ 45.412007] [] ? slab_pre_alloc_hook+0x19/0x1f
[ 45.412007] [] ? kmem_cache_alloc_trace+0xbe/0xcd
[ 45.412007] [] do_init_module+0x5f/0x1ef
[ 45.412007] [] load_module+0x1a9c/0x2003
[ 45.412007] [] ? fsnotify_access+0x5a/0x61
[ 45.412007] [] ? strstarts+0x28/0x28
[ 45.412007] [] SYSC_finit_module+0x83/0x90
[ 45.412007] [] ? SYSC_finit_module+0x83/0x90
[ 45.412007] [] SyS_finit_module+0xe/0x10
[ 45.412007] [] entry_SYSCALL_64_fastpath+0x17/0x98
[ 45.412191] —[ end trace 98e404a289fe02a3 ]—
[ 45.412199] NVRM: failed to register procfs!
[ 45.412284] NVRM: request_mem_region failed for 16M @ 0xe0000000. This can
NVRM: occur when a driver such as rivatv is loaded and claims
NVRM: ownership of the device’s registers.
[ 45.412295] nvidia: probe of 0000:01:00.0 failed with error -1
[ 45.412344] Error: Driver ‘nvidia’ is already registered, aborting…
[ 45.412347] NVRM: DRM init failed
[ 45.412541] NVRM: NVIDIA init module failed!

Both the kernel and the Nvidia driver were compiled with the same GCC version, so that’s not the problem, and there are no “nouveau” or “riva” drivers loaded at all.

This Nvidia driver works well for the 4.8.1-git-a7fac75 Linux Kernel, but not for 4.9.0-rc2 (git-ed99d36). Subsequent to applying your patch, it only compiles but does NOT load properly for the 4.9-rc2 kernel.

nvidia-installer.log (858 KB)

Subsequent to initially showing Nvidia driver 340.98 no longer builds and loads for Linux Kernel 4.9-rc2+, there is still no fully working patch available to fix this issue.

A patch solution posted by philmmanjaro offered only a partial solution which enabled the driver to build (compile) but not load properly.

I would greatly appreciate a complete working patch so that the 4.9+ Linux kernel using my Nvidia graphics card may be properly tested.

Any progress from the Nvidia Linux developers? A response at least would also be appreciated, to let users know where this stands and the current status.

Patiently awaiting a solution.

I’m currently running Fedora Core 24 with 4.7.4, but the “dnf update” has installed kernels
for 4.8.4-200.fc24.x86_64 and 4.8.6-201.fc24.x86_64 which do not boot to the login screen
due to:

Nov 15 18:16:11 jkl /usr/libexec/gdm-x-session[6213]: modprobe: FATAL: Module nvidia not found in directory /lib/modules/4.8.6-201.fc24.x86_64
Nov 15 18:16:11 jkl /usr/libexec/gdm-x-session[6213]: (EE) NVIDIA: Failed to initialize the NVIDIA kernel module. Please see the
Nov 15 18:16:11 jkl /usr/libexec/gdm-x-session[6213]: (EE) NVIDIA: system’s kernel log for additional error messages and
Nov 15 18:16:11 jkl /usr/libexec/gdm-x-session[6213]: (EE) NVIDIA: consult the NVIDIA README for details.
Nov 15 18:16:11 jkl /usr/libexec/gdm-x-session[6213]: (EE) No devices detected.

and in fact the only Nvidia files that I have in /lib/modules are:


I have driver 340.98 installed (for 4.7.4) and have done the “dnf update” command, but
have nothing for the two most recent kernels.

I have nvidia-bug-report.log and /var/log/nvidia-installer.log, and would attach them if I
had a clue how to do that, if it is believed that this would help. This is for a desktop PC
running 64-bit Fedora Core 24, displaying on two monitors using a GeForce 8400 GS.

crazylyle, thank you for adding your issue here!

To attach a file, please hover your mouse pointer to the top-right of the text box and several images will appear, one of them being a paper-clip (attachment). Click on the paper-clip and then proceed to attach your log.

Let’s hope a patch is issued for this driver by Nvidia, or by another external developer soon!

PATCH included at the following post [url]https://devtalk.nvidia.com/default/topic/981852/linux/resolution-patch-attached-for-nvidia-linux-driver-340-98-x86_64-using-linux-kernel-4-9/[/url] RESOLVES all compilation/building & functioning issues.

340.101 builds fine without patching.