# Nvidia 378.13 kernel 4.10 patch

## fhede

Hello.

Kernel 4.10 patch found here. 

https://devtalk.nvidia.com/default/topic/994087/linux/387-13-patch-for-4-10-0-rc8-linus-master-/

----------

## Juippisi

It worked. Thanks!

----------

## musv

Patch for nvidia-drivers-340.102

Took the patch from above and dropped everything, which isn't available in 340 branch. It compiled and seems to work so far (tested with Sauerbraten).

```
diff -ur work.orig/kernel/nv-linux.h work/kernel/nv-linux.h

--- work.orig/kernel/nv-linux.h   2017-03-02 20:07:06.155149811 +0100

+++ work/kernel/nv-linux.h   2017-03-02 20:09:39.871830734 +0100

@@ -270,7 +270,8 @@

 

 extern int nv_pat_mode;

 

-#if !defined(NV_VMWARE) && defined(CONFIG_HOTPLUG_CPU)

+//#if !defined(NV_VMWARE) && defined(CONFIG_HOTPLUG_CPU)

+#if 0

 #define NV_ENABLE_HOTPLUG_CPU

 #include <linux/cpu.h>              /* CPU hotplug support              */

 #include <linux/notifier.h>         /* struct notifier_block, etc       */

diff -ur work.orig/kernel/nv-p2p.c work/kernel/nv-p2p.c

--- work.orig/kernel/nv-p2p.c   2017-03-02 20:07:06.155149811 +0100

+++ work/kernel/nv-p2p.c   2017-03-02 20:11:52.313197256 +0100

@@ -112,7 +112,7 @@

 int nvidia_p2p_get_pages(

     uint64_t p2p_token,

     uint32_t va_space,

-    uint64_t virtual_address,

+    uint64_t address,

     uint64_t length,

     struct nvidia_p2p_page_table **page_table,

     void (*free_callback)(void * data),

@@ -136,7 +136,7 @@

         return -ENOMEM;

 

     status = rm_p2p_get_pages(sp, p2p_token, va_space,

-            virtual_address, length, &physical_addresses, &wreqmb_h,

+            address, length, &physical_addresses, &wreqmb_h,

             &rreqmb_h, &entries, *page_table,

             free_callback, data);

     if (status != RM_OK)

@@ -195,7 +195,7 @@

                 nvidia_p2p_page_t_cache);

     }

 

-    rm_p2p_put_pages(sp, p2p_token, va_space, virtual_address,

+    rm_p2p_put_pages(sp, p2p_token, va_space, address,

             *page_table);

 

     os_free_mem((*page_table)->pages);

@@ -232,7 +232,7 @@

 int nvidia_p2p_put_pages(

     uint64_t p2p_token,

     uint32_t va_space,

-    uint64_t virtual_address,

+    uint64_t address,

     struct nvidia_p2p_page_table *page_table

 )

 {

@@ -243,7 +243,7 @@

     if (sp == NULL)

         return -ENOMEM;

 

-    status = rm_p2p_put_pages(sp, p2p_token, va_space, virtual_address,

+    status = rm_p2p_put_pages(sp, p2p_token, va_space, address,

             page_table);

     if (status == RM_OK)

         nvidia_p2p_free_page_table(page_table);
```

----------

## mbar

Newest version: https://gist.github.com/tpruzina/c4d9c0ca6bdbb6e78ab2126a7cdf8f1c

----------

## brutico

Could you explain step by step how the patch is applied

----------

## donmartio

Normally you would create a directory in /etc/portage/patches matching the name of the package the patch is for.

For example:

mkdir -p /etc/portage/patches/x11-drivers/nvidia-drivers-340.102

Now you place the patches you want to apply in this folder.

cd /etc/portage/patches/x11-drivers/nvidia-drivers-340.102

vim NVIDIA-378.13-KERNEL-4.10.patch

:set paste

<PASTE THE PATCH>

:wq

finally remerge the package:

emerge =x11-drivers/nvidia-drivers-340.102

----------

## hurricane

Can anyone adapt the newest version of the patch for nvidia-drivers-340.102 too?

----------

## musv

I created a bug-report to integrate into portage:

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

----------

