# Kernel 4.12 and nvidia-drivers-340.120-r1

## musv

Did some investigation to get my old graphics device running. Maybe someone finds it useful too.

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

----------

## NTU

A dude here was on about the same thing: https://forums.gentoo.org/viewtopic-t-1067720.html

----------

## musv

NTU: As you can see in my bug-report I took the patch from the nvidia devtalk, corrected some line numbers and created a patch, which works with the Gentoo-Ebuild. 

So it's no problem, it's a solution.

----------

## NTU

I wasn't criticizing or bashing you, there's just like 8 threads scattered about, about nvidia blobs now on kernel 4.12. At least this thread is a "read this if you can't google" rather than "help me, I can't google, gimmie answer plox."

----------

## tomtom69

Is there also any patch for (legacy) nvidia-drivers 304.135 and kernel 4.12 on amd64?

Up to now I was always able to find patches or generate ones by myself, but this time I'm stuck.

Compiling nvidia-drivers-304.135 works without patch with kernel 4.9.34 but aborts with the following message with 4.12.5:

```

/var/tmp/portage/x11-drivers/nvidia-drivers-304.135/work/kernel/nv-pat.c: In function ‘nv_kern_cpu_callback’:

/var/tmp/portage/x11-drivers/nvidia-drivers-304.135/work/kernel/nv-pat.c:213:14: error: ‘CPU_DOWN_FAILED’ undeclared (first use in this function)

         case CPU_DOWN_FAILED:

              ^

/var/tmp/portage/x11-drivers/nvidia-drivers-304.135/work/kernel/nv-pat.c:213:14: note: each undeclared identifier is reported only once for each function it appears in

/var/tmp/portage/x11-drivers/nvidia-drivers-304.135/work/kernel/nv-pat.c:220:14: error: ‘CPU_DOWN_PREPARE’ undeclared (first use in this function)

         case CPU_DOWN_PREPARE:

              ^

In file included from /var/tmp/portage/x11-drivers/nvidia-drivers-304.135/work/kernel/nv-pat.c:15:0:

/var/tmp/portage/x11-drivers/nvidia-drivers-304.135/work/kernel/nv-pat.c: In function ‘nv_init_pat_support’:

/var/tmp/portage/x11-drivers/nvidia-drivers-304.135/work/kernel/nv-linux.h:398:34: error: implicit declaration of function ‘register_cpu_notifier’ [-Werror=implicit-function-declaration]

 #define register_hotcpu_notifier register_cpu_notifier

                                  ^

/var/tmp/portage/x11-drivers/nvidia-drivers-304.135/work/kernel/nv-pat.c:258:17: note: in expansion of macro ‘register_hotcpu_notifier’

             if (register_hotcpu_notifier(&nv_hotcpu_nfb) != 0)

                 ^

/var/tmp/portage/x11-drivers/nvidia-drivers-304.135/work/kernel/nv-pat.c: In function ‘nv_teardown_pat_support’:

/var/tmp/portage/x11-drivers/nvidia-drivers-304.135/work/kernel/nv-linux.h:395:36: error: implicit declaration of function ‘unregister_cpu_notifier’ [-Werror=implicit-function-declaration]

 #define unregister_hotcpu_notifier unregister_cpu_notifier

                                    ^

/var/tmp/portage/x11-drivers/nvidia-drivers-304.135/work/kernel/nv-pat.c:283:9: note: in expansion of macro ‘unregister_hotcpu_notifier’

         unregister_hotcpu_notifier(&nv_hotcpu_nfb);

         ^

```

----------

## fedeliallalinea

Try patch from open suse

----------

## tomtom69

I tried this patch but unfortunately I get the same error messages.

CPU_DOWN_PREPARE and the other symbols can be found in the kernel sources so I think some include file might be missing, but I could not find which one...

----------

## tomtom69

I finally was able to create a patch that seems to work:

https://pastebin.com/581qEsEQ

To simply undefine NV_ENABLE_HOTPLUG_CPU is somewhat brute force, but afaik this can only break suspend modes (which do not work correctly anyway since kernel 4.x on my machine because of nvidia driver problems). Maybe someone has a better solution than mine.

@fedeliallalinea: Thanks for the hint - the patch mentioned was also necessary to compile.

----------

