Gentoo, latest nvidia patches 331.1, 331.38 (kernel 3.11, 3.13)Подписка на Комментарии к "Gentoo, latest nvidia patches 331.1, 331.38 (kernel 3.11, 3.13)"

Аватар zenon

Для тех, кто понимает, что делает:

# mkdir -p /etc/portage/patches/x11-drivers/nvidia-drivers-331.13/

# cat /etc/portage/patches/x11-drivers/nvidia-drivers-331.13/kernel.patch
From 8a8647ad942c8ac5161e1335f7f3e9dbb34dbf9e Mon Sep 17 00:00:00 2001
From: Lukas Elsner <open@mindrunner.de>
Date: Wed, 17 Jul 2013 01:16:04 +0200
Subject: [PATCH] replace num_physpages with totalram_pages

---
 kernel/nv-linux.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/nv-linux.h b/kernel/nv-linux.h
index 4e5ed89..46c51ec 100644
--- a/kernel/nv-linux.h
+++ b/kernel/nv-linux.h
@@ -957,7 +957,7 @@ static inline int nv_execute_on_all_cpus(void (*func)(void *info), void *info)
 #endif
 
 #if !defined(NV_VMWARE)
-#define NV_NUM_PHYSPAGES                num_physpages
+#define NV_NUM_PHYSPAGES                totalram_pages
 #define NV_GET_CURRENT_PROCESS()        current->tgid
 #define NV_IN_ATOMIC()                  in_atomic()
 #define NV_LOCAL_BH_DISABLE()           local_bh_disable()
--
1.8.3.2
# emerge -pv gentoo-sources nvidia-drivers

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R    ] sys-kernel/gentoo-sources-3.11.4:3.11.4  USE="-build -deblob -experimental -symlink" 0 kB
[ebuild   R    ] x11-drivers/nvidia-drivers-331.13  USE="X acpi (multilib) tools -pax_kernel" 0 kB

Total: 2 packages (2 reinstalls), Size of downloads: 0 kB


----
upd. 30.02.2014.
Ядро 3.13, версия драйвера 331.38
Избавляет от ошибки:

nvidia: Unknown symbol acpi_os_wait_events_complete (err 0)

# mkdir -p /etc/portage/patches/x11-drivers/nvidia-drivers-331.13/

# cat /etc/portage/patches/x11-drivers/nvidia-drivers-331.38/kernel.patch
--- a/kernel/nv-acpi.c
+++ b/kernel/nv-acpi.c
@@ -303,7 +307,10 @@ static int nv_acpi_remove(struct acpi_de
 
     if (pNvAcpiObject->notify_handler_installed)
     {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0)
+ /* beginning with 3.13, acpi_remove_notify_handler() waits for events to finish */
         NV_ACPI_OS_WAIT_EVENTS_COMPLETE();
+#endif
 
         // remove event notifier
         status = acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, nv_acpi_event);
--- a/kernel/uvm/nvidia_uvm_linux.h
+++ b/kernel/uvm/nvidia_uvm_linux.h
@@ -405,11 +405,17 @@ typedef void irqreturn_t;
 // not require the RCU's read lock on current->cred.
 //
 //
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
+#define NV_KUID_TO_UID(value) (__kuid_val(value))
+#else
+#define NV_KUID_TO_UID(value) (value)
+#endif
+
 #if defined(NV_TASK_STRUCT_HAS_CRED)
 #define NV_CURRENT_EUID() \
-    (((typeof(*current->cred) __force __kernel *)current->cred)->euid)
+        NV_KUID_TO_UID(((typeof(*current->cred) __force __kernel *)current->cred)->euid)
 #else
-#define NV_CURRENT_EUID() (current->euid)
+#define NV_CURRENT_EUID() NV_KUID_TO_UID(current->euid)
 #endif
 
 #define NV_ATOMIC_SET(data,val)         atomic_set(&(data), (val))

# emerge -pv gentoo-sources nvidia-drivers

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R    ] sys-kernel/gentoo-sources-3.13.1:3.13.1  USE="-build -deblob -experimental -symlink" 0 kB
[ebuild   R    ] x11-drivers/nvidia-drivers-331.38  USE="X acpi (multilib) tools -pax_kernel" 0 kB

Total: 2 packages (2 reinstalls), Size of downloads: 0 kB

---
Источник - тема на devtalk.nvidia.com
Ссылка на патчи.
---
upd. 01.02.2014, патч для ноутбуков с NVidia Optimus, EFI w/o Compatibility Support Module, при загрузке модуля ошибка:
NVRM: failed to copy vbios to system memory.
NVRM: RmInitAdapter failed! (0x30:0xffffffff:720)
NVRM: rm_init_adapter failed for device bearing minor number 0
NVRM: nvidia_frontend_open: minor 0, module->open() failed, error -5

diff -rupN NVIDIA-Linux-x86_64-331.38.orig/kernel/nv-acpi.c NVIDIA-Linux-x86_64-331.38/kernel/nv-acpi.c
--- NVIDIA-Linux-x86_64-331.38.orig/kernel/nv-acpi.c    2014-01-25 09:39:47.126966926 +0100
+++ NVIDIA-Linux-x86_64-331.38/kernel/nv-acpi.c 2014-01-26 09:59:45.853427603 +0100
@@ -303,7 +303,10 @@ static int nv_acpi_remove(struct acpi_de
 
     if (pNvAcpiObject->notify_handler_installed)
     {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0)
+ /* beginning with 3.13, acpi_remove_notify_handler() waits for events to finish */
         NV_ACPI_OS_WAIT_EVENTS_COMPLETE();
+#endif
 
         // remove event notifier
         status = acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, nv_acpi_event);
@@ -1076,10 +1079,17 @@ RM_STATUS NV_API_CALL nv_acpi_dsm_method
     NvU8 argument3[4]; /* For all DSM sub functions, input size is 4 */
     NvU32 data_size;
     acpi_handle dev_handle  = NULL;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0)
 #ifdef DEVICE_ACPI_HANDLE
     nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv);
     dev_handle = DEVICE_ACPI_HANDLE(&nvl->dev->dev);
 #endif
+#else
+#ifdef ACPI_HANDLE
+    nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv);
+    dev_handle = ACPI_HANDLE(&nvl->dev->dev);
+#endif
+#endif
 
     if (!dev_handle)
         return RM_ERR_NOT_SUPPORTED;
@@ -1179,12 +1189,21 @@ RM_STATUS NV_API_CALL nv_acpi_ddc_method
     NvU32 i;
     acpi_handle dev_handle  = NULL;
     acpi_handle lcd_dev_handle  = NULL;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0)
 #ifdef DEVICE_ACPI_HANDLE
     nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv);
     dev_handle = DEVICE_ACPI_HANDLE(&nvl->dev->dev);
 #else
         return RM_ERR_NOT_SUPPORTED;
 #endif
+#else
+#ifdef ACPI_HANDLE
+    nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv);
+    dev_handle = ACPI_HANDLE(&nvl->dev->dev);
+#else
+        return RM_ERR_NOT_SUPPORTED;
+#endif
+#endif
     if (!dev_handle)
         return RM_ERR_INVALID_ARGUMENT;
 
@@ -1294,12 +1313,21 @@ RM_STATUS NV_API_CALL nv_acpi_rom_method
     struct acpi_object_list input = { 2, rom_arg };
     acpi_handle dev_handle  = NULL;
     uint32_t offset, length;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0)
 #ifdef DEVICE_ACPI_HANDLE
     nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv);
-    dev_handle = DEVICE_ACPI_HANDLE(&nvl->dev->dev);
+    dev_handle = ACPI_DEVICE_HANDLE(&nvl->dev->dev);
 #else
     return RM_ERR_NOT_SUPPORTED;
 #endif
+#else
+#ifdef ACPI_HANDLE
+    nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv);
+    dev_handle = ACPI_HANDLE(&nvl->dev->dev);
+#else
+    return RM_ERR_NOT_SUPPORTED;
+#endif
+#endif
 
     if (!dev_handle)
         return RM_ERR_INVALID_ARGUMENT;
@@ -1364,12 +1392,21 @@ RM_STATUS NV_API_CALL nv_acpi_dod_method
     union acpi_object *dod;
     acpi_handle dev_handle = NULL;
     NvU32 i, count = (*pSize / sizeof(NvU32));
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0)
 #ifdef DEVICE_ACPI_HANDLE
     nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv);
     dev_handle = DEVICE_ACPI_HANDLE(&nvl->dev->dev);
 #else
     return RM_ERR_NOT_SUPPORTED;
 #endif
+#else
+#ifdef ACPI_HANDLE
+    nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv);
+    dev_handle = ACPI_HANDLE(&nvl->dev->dev);
+#else
+    return RM_ERR_NOT_SUPPORTED;
+#endif
+#endif
 
     if (!dev_handle)
         return RM_ERR_INVALID_ARGUMENT;
diff -rupN NVIDIA-Linux-x86_64-331.38.orig/kernel/uvm/nvidia_uvm_linux.h NVIDIA-Linux-x86_64-331.38/kernel/uvm/nvidia_uvm_linux.h
--- NVIDIA-Linux-x86_64-331.38.orig/kernel/uvm/nvidia_uvm_linux.h       2014-01-25 09:39:47.172966925 +0100
+++ NVIDIA-Linux-x86_64-331.38/kernel/uvm/nvidia_uvm_linux.h    2014-01-25 09:46:40.572999245 +0100
@@ -405,11 +405,17 @@ typedef void irqreturn_t;
 // not require the RCU's read lock on current->cred.
 //
 //
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
+#define NV_KUID_TO_UID(value) (__kuid_val(value))
+#else
+#define NV_KUID_TO_UID(value) (value)
+#endif
+
 #if defined(NV_TASK_STRUCT_HAS_CRED)
 #define NV_CURRENT_EUID() \
-    (((typeof(*current->cred) __force __kernel *)current->cred)->euid)
+        NV_KUID_TO_UID(((typeof(*current->cred) __force __kernel *)current->cred)->euid)
 #else
-#define NV_CURRENT_EUID() (current->euid)
+#define NV_CURRENT_EUID() NV_KUID_TO_UID(current->euid)
 #endif
 
 #define NV_ATOMIC_SET(data,val)         atomic_set(&(data), (val))

Подсмотрено тут по совету Tanuki.

Аватар Sema1011

Спасибо! А то патч для 325 есть, а для 331 нет.

Аватар zenon

Добавил патч - ядро 3.13, версия драйвера 331.38.

Аватар Tanuki

Для 331.38 лучше подойдёт этот патч.

Аватар zenon

Tanuki, так то только для Optimus лучше, добавлю и тот сюда, спс.

Добавить комментарий