Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 610776 - x11-drivers/nvidia-drivers-340.102 with USE=uvm fails to compile against kernel 4.10.0
Summary: x11-drivers/nvidia-drivers-340.102 with USE=uvm fails to compile against kern...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Linux bug wranglers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-24 07:14 UTC by daniel
Modified: 2017-03-17 19:34 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log (build.log,816.61 KB, text/x-log)
2017-02-24 07:14 UTC, daniel
Details
nvidia-uvm-kernel-4.10.patch (nvidia-uvm-kernel-4.10.patch,456 bytes, patch)
2017-03-01 21:11 UTC, Karol Grudziński
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description daniel 2017-02-24 07:14:22 UTC
Created attachment 464952 [details]
build.log

Legacy nvidia-drivers-340.102 have the same problem with kernel 4.10.0 as described and solved here:

https://bugs.gentoo.org/show_bug.cgi?id=602844

Additionally they have a problem which is solved with the patch here:

https://github.com/MilhouseVH/LibreELEC.tv/blob/linux4100/packages/x11/driver/xf86-video-nvidia-legacy/patches/xf86-video-nvidia-legacy-kernel-4.10.patch

With these two patches applied, the drivers compile fine, but only if nvidia-drivers has the uvm USE flag disabled. As soon as I enable the uvm USE flag, it fails to compile at the uvm part (for details see attached build.log):



/var/tmp/portage/x11-drivers/nvidia-drivers-340.102/work/kernel/uvm/nvidia_uvm_lite.c: In function '_fault':
/var/tmp/portage/x11-drivers/nvidia-drivers-340.102/work/kernel/uvm/nvidia_uvm_lite.c:823:45: error: 'struct vm_fault' has no member named 'virtual_address'
     unsigned long vaddr = (unsigned long)vmf->virtual_address;
                                             ^
make[3]: *** [/usr/src/linux-4.10.0-gentoo/scripts/Makefile.build:295: /var/tmp/portage/x11-drivers/nvidia-drivers-340.102/work/kernel/uvm/nvidia_uvm_lite.o] Error 1
make[2]: *** [/usr/src/linux-4.10.0-gentoo/Makefile:1490: _module_/var/tmp/portage/x11-drivers/nvidia-drivers-340.102/work/kernel/uvm] Error 2
make[2]: Leaving directory '/usr/src/linux-4.10.0-gentoo'
make[1]: *** [Makefile:150: sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-4.10.0-gentoo'
NVIDIA: left KBUILD.
 nvidia-uvm.ko failed to build!
make: *** [Makefile:215: nvidia-uvm.ko] Error 1




I enabled this USE flag some time ago because of this bug:

https://bugs.gentoo.org/show_bug.cgi?id=572496
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2017-02-24 08:27:22 UTC

*** This bug has been marked as a duplicate of bug 610058 ***
Comment 2 daniel 2017-02-24 08:43:25 UTC
Sorry, but 

https://bugs.gentoo.org/show_bug.cgi?id=610058

is for version x11-drivers/nvidia-drivers-375.39 and the mentioned patch
fails to apply to my version x11-drivers/nvidia-drivers-340.102
So for me it's not solved yet.
Comment 3 Karol Grudziński 2017-03-01 21:10:11 UTC
@daniel: This error needs very simple fix as suggested in error message. In file kernel/uvm/nvidia_uvm_lite.c change vmf->virtual_address to vmf->address in line 823.
Comment 4 Karol Grudziński 2017-03-01 21:11:32 UTC
Created attachment 465664 [details, diff]
nvidia-uvm-kernel-4.10.patch
Comment 5 daniel 2017-03-02 07:24:22 UTC
Thanks, this patch works.
Comment 6 Loux 2017-03-17 19:34:17 UTC
to support loading legacy driver with kernel >= 4.9, we need to add this patch too :
--- kernel/nv-drm.c	2016-12-15 12:41:26.000000000 +0100
+++ kernel/nv-drm.c	2016-12-15 12:58:48.000000000 +0100
@@ -115,7 +115,11 @@
 };
 
 static struct drm_driver nv_drm_driver = {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)
+    .driver_features = DRIVER_GEM | DRIVER_PRIME | DRIVER_LEGACY,
+#else
     .driver_features = DRIVER_GEM | DRIVER_PRIME,
+#endif
     .load = nv_drm_load,
     .unload = nv_drm_unload,
     .fops = &nv_drm_fops,


Got it from : 
https://devtalk.nvidia.com/default/topic/982052/linux/-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-/1