You are not logged in.

#26 2021-01-04 21:19:42

TheFurryWeeb
Member
Registered: 2020-08-06
Posts: 57

Re: [ERROR] [SOLVED] Custom Linux Kernel Compilation Part 2

loqs wrote:

The patch applies to the source of nvidia 460.27.04 not the kernel source.

So I've just overcomplicated everything. PKGBUILD change to the driver, then compile the driver... Install the compiled driver, then manually compile the kernel and the kernel drivers.

That's it, right?


A computer and Linux nerd, an avid 2D platformer and RPG gamer and a furry combined into one person.

I hope I can help you out with your Arch issues and get myself helped out, as well.

Offline

#27 2021-01-04 21:27:07

seth
Member
Registered: 2012-09-03
Posts: 18,979

Re: [ERROR] [SOLVED] Custom Linux Kernel Compilation Part 2

Afaiu you already have the kernel, installing the pathed nvidia-dkms should suffice.
Otherwise explicitly trigger a dkms update, https://wiki.archlinux.org/index.php/Dy … le_Support

Online

#28 2021-01-04 21:29:00

TheFurryWeeb
Member
Registered: 2020-08-06
Posts: 57

Re: [ERROR] [SOLVED] Custom Linux Kernel Compilation Part 2

ewaller wrote:

TheFurryWeeb Reported

So I have to use this patch on the driver, then I have to just manually compile the kernel? Or does the kernel also need the make command that patches it?

Methinks you meant to hit 'reply', not 'report'

Yep, honest mistake.


A computer and Linux nerd, an avid 2D platformer and RPG gamer and a furry combined into one person.

I hope I can help you out with your Arch issues and get myself helped out, as well.

Offline

#29 2021-01-04 22:03:30

loqs
Member
Registered: 2014-03-06
Posts: 13,005

Re: [ERROR] [SOLVED] Custom Linux Kernel Compilation Part 2

Would it not be easier to use a PKGBUILD for both the kernel and nvidia?

Offline

#30 2021-01-07 23:10:42

TheFurryWeeb
Member
Registered: 2020-08-06
Posts: 57

Re: [ERROR] [SOLVED] Custom Linux Kernel Compilation Part 2

Now that the stable 460 Nvidia driver is available, I tried to use kernel version 5.11.0-rc2 with the 460 driver, but  now, DKMS shows an entirely different error message:

In function 'nv_cap_close fd': /var/lib/dkms/nvidia/460.32.03/build/nvidia/nv-caps.c:592:5: error: implicit declaration of function 'sys_close' (-Werror-mplicit-function-declaration) 592 | sys_close(fd); cci: some warnings being treated as errors make[2]: ** [scripts/Makefile.butld:279: /var/lib/dkms/nvidia/460.32.03/build/nvidia/nv-caps.o] Error 1 make[2]: *** Walting for unfinished jobs.... make[1]: ** [Makefile:1885: /var/lib/dkms/nvidla/460.32.03/build] Error 2 make[1]: Leaving directory '/home/ironicfur/kernelbuild/Linux-5.11-rc2 make: ** [Makefile:88: modules] Error 2

Last edited by TheFurryWeeb (2021-01-07 23:14:00)


A computer and Linux nerd, an avid 2D platformer and RPG gamer and a furry combined into one person.

I hope I can help you out with your Arch issues and get myself helped out, as well.

Offline

#31 2021-01-07 23:22:38

loqs
Member
Registered: 2014-03-06
Posts: 13,005

Re: [ERROR] [SOLVED] Custom Linux Kernel Compilation Part 2

The 460.32.03 driver still needs patching for 5.11,  try:

diff --git a/kernel/conftest.sh b/kernel/conftest.sh
index 87dac2a..2705218 100755
--- a/kernel/conftest.sh
+++ b/kernel/conftest.sh
@@ -1285,12 +1285,12 @@ compile_test() {
                 struct drm_driver drv;
 
                 /* 2013-01-15 89177644a7b6306e6084a89eab7e290f4bfef397 */
-                drv.gem_prime_pin = 0;
+/*                drv.gem_prime_pin = 0;
                 drv.gem_prime_get_sg_table = 0;
                 drv.gem_prime_vmap = 0;
                 drv.gem_prime_vunmap = 0;
                 (void)drm_gem_prime_import;
-                (void)drm_gem_prime_export;
+                (void)drm_gem_prime_export;*/
 
                 /* 2013-10-02 1bb72532ac260a2d3982b40bdd4c936d779d0d16 */
                 (void)drm_dev_alloc;
@@ -2086,6 +2086,42 @@ compile_test() {
             compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_LEGACY_DEV_LIST" "" "types"
         ;;
 
+        drm_driver_has_device_list)
+            # 57bb1ee6034046be70aed33fd6d447bb2b7261fa
+            CODE="
+            #if defined(NV_DRM_DRMP_H_PRESENT)
+            #include <drm/drmP.h>
+            #endif
+
+            #if defined(NV_DRM_DRM_DRV_H_PRESENT)
+            #include <drm/drm_drv.h>
+            #endif
+
+            int conftest_drm_driver_has_device_list(void) {
+                return offsetof(struct drm_driver, device_list);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_DEVICE_LIST" "" "types"
+        ;;
+
+        drm_driver_has_gem_vm_ops)
+            # d693def4fd1c23f1ca5aed1afb9993b3a2069ad2
+            CODE="
+            #if defined(NV_DRM_DRMP_H_PRESENT)
+            #include <drm/drmP.h>
+            #endif
+
+            #if defined(NV_DRM_DRM_DRV_H_PRESENT)
+            #include <drm/drm_drv.h>
+            #endif
+
+            int conftest_drm_driver_has_gem_vm_ops(void) {
+                return offsetof(struct drm_driver, gem_vm_ops);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_VM_OPS" "" "types"
+        ;;
+
         jiffies_to_timespec)
             #
             # Determine if jiffies_to_timespec() is present
@@ -2286,6 +2322,62 @@ compile_test() {
             compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ" "" "types"
         ;;
 
+        drm_driver_has_gem_prime_get_sg_table)
+            # Removed by commit d693def4fd1c23f1ca5aed1afb9993b3a2069ad2
+            CODE="
+            #if defined(NV_DRM_DRMP_H_PRESENT)
+            #include <drm/drmP.h>
+            #endif
+
+            int conftest_drm_driver_has_gem_prime_get_sg_table(void) {
+                return offsetof(struct drm_driver, gem_prime_get_sg_table);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_PRIME_GET_SG_TABLE" "" "types"
+        ;;
+
+        drm_driver_has_gem_prime_export)
+            # Removed by commit d693def4fd1c23f1ca5aed1afb9993b3a2069ad2
+            CODE="
+            #if defined(NV_DRM_DRMP_H_PRESENT)
+            #include <drm/drmP.h>
+            #endif
+
+            int conftest_drm_driver_has_gem_prime_export(void) {
+                return offsetof(struct drm_driver, gem_prime_export);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_PRIME_EXPORT" "" "types"
+        ;;
+
+        drm_driver_has_gem_prime_vmap)
+            # Removed by commit d693def4fd1c23f1ca5aed1afb9993b3a2069ad2
+            CODE="
+            #if defined(NV_DRM_DRMP_H_PRESENT)
+            #include <drm/drmP.h>
+            #endif
+
+            int conftest_drm_driver_has_gem_prime_vmap(void) {
+                return offsetof(struct drm_driver, gem_prime_vmap);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_PRIME_VMAP" "" "types"
+        ;;
+
+        drm_driver_has_gem_prime_vunmap)
+            # Removed by commit d693def4fd1c23f1ca5aed1afb9993b3a2069ad2
+            CODE="
+            #if defined(NV_DRM_DRMP_H_PRESENT)
+            #include <drm/drmP.h>
+            #endif
+
+            int conftest_drm_driver_has_gem_prime_vunmap(void) {
+                return offsetof(struct drm_driver, gem_prime_vunmap);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_PRIME_VUNMAP" "" "types"
+        ;;
+
         drm_crtc_state_has_connectors_changed)
             #
             # Determine if the crtc_state has a 'connectors_changed' field.
@@ -4346,6 +4438,34 @@ compile_test() {
             compile_check_conftest "$CODE" "NV_ITERATE_FD_PRESENT" "" "functions"
         ;;
 
+        drm_atomic_check_atomic_state)
+            # 29b77ad7b9ca8c87152a1a9e8188970fb2a93df4
+            CODE="
+            #include <drm/drm_modeset_helper_vtables.h>
+
+            void drm_atomic_check_atomic_state(struct drm_crtc_helper_funcs * funcs,
+                                               struct drm_crtc *crtc,
+                                               struct drm_atomic_state *state) {
+                funcs->atomic_check(crtc, state);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_ATOMIC_CHECK_ATOMIC_STATE" "" "types"
+        ;;
+
+        drm_atomic_enable_atomic_state)
+            # 351f950db4ab28c321a1bd4b92e4bb03e34c4703
+            CODE="
+            #include <drm/drm_modeset_helper_vtables.h>
+
+            void drm_atomic_enable_atomic_state(struct drm_crtc_helper_funcs * funcs,
+                                                struct drm_crtc *crtc,
+                                                struct drm_atomic_state *state) {
+                funcs->atomic_enable(crtc, state);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_ATOMIC_ENABLE_ATOMIC_STATE" "" "types"
+        ;;
+
         # When adding a new conftest entry, please use the correct format for
         # specifying the relevant upstream Linux kernel commit.
         #
diff --git a/kernel/nvidia-drm/nvidia-drm-crtc.c b/kernel/nvidia-drm/nvidia-drm-crtc.c
index b966bb2..6769004 100644
--- a/kernel/nvidia-drm/nvidia-drm-crtc.c
+++ b/kernel/nvidia-drm/nvidia-drm-crtc.c
@@ -460,8 +460,14 @@ static int head_modeset_config_attach_connector(
  * will be discarded if ->atomic_check() fails.
  */
 static int nv_drm_crtc_atomic_check(struct drm_crtc *crtc,
+#ifndef NV_DRM_ATOMIC_CHECK_ATOMIC_STATE
                                     struct drm_crtc_state *crtc_state)
 {
+#else
+                                    struct drm_atomic_state *state)
+{
+    struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,crtc);
+#endif
     struct nv_drm_crtc_state *nv_crtc_state = to_nv_crtc_state(crtc_state);
     struct NvKmsKapiHeadRequestedConfig *req_config =
         &nv_crtc_state->req_config;
@@ -532,7 +538,11 @@ static void nv_drm_crtc_disable(struct drm_crtc *crtc)
 
 #ifdef NV_DRM_CRTC_HELPER_FUNCS_HAS_ATOMIC_ENABLE
 static void nv_drm_crtc_atomic_enable(struct drm_crtc *crtc,
+#ifndef NV_DRM_ATOMIC_ENABLE_ATOMIC_STATE
                                       struct drm_crtc_state *old_crtc_state)
+#else
+                                      struct drm_atomic_state *state)
+#endif
 {
 
 }
diff --git a/kernel/nvidia-drm/nvidia-drm-drv.c b/kernel/nvidia-drm/nvidia-drm-drv.c
index ebfb5cd..5db6f6f 100644
--- a/kernel/nvidia-drm/nvidia-drm-drv.c
+++ b/kernel/nvidia-drm/nvidia-drm-drv.c
@@ -755,12 +755,20 @@ static struct drm_driver nv_drm_driver = {
 
     .prime_handle_to_fd     = drm_gem_prime_handle_to_fd,
     .prime_fd_to_handle     = drm_gem_prime_fd_to_handle,
+#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_EXPORT)
     .gem_prime_export       = drm_gem_prime_export,
+#endif
     .gem_prime_import       = nv_drm_gem_prime_import,
+#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_GET_SG_TABLE)
     .gem_prime_get_sg_table = nv_drm_gem_prime_get_sg_table,
+#endif
     .gem_prime_import_sg_table = nv_drm_gem_prime_import_sg_table,
+#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_VMAP)
     .gem_prime_vmap         = nv_drm_gem_prime_vmap,
+#endif
+#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_VUNMAP)
     .gem_prime_vunmap       = nv_drm_gem_prime_vunmap,
+#endif
 
 #if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ)
     .gem_prime_res_obj      = nv_drm_gem_prime_res_obj,
@@ -786,10 +794,12 @@ static struct drm_driver nv_drm_driver = {
 
 #if defined(NV_DRM_DRIVER_HAS_LEGACY_DEV_LIST)
     .legacy_dev_list        = LIST_HEAD_INIT(nv_drm_driver.legacy_dev_list),
-#else
+#elif defined(NV_DRM_DRIVER_HAS_DEVICE_LIST)
     .device_list            = LIST_HEAD_INIT(nv_drm_driver.device_list),
 #endif
+#if defined(NV_DRM_DRIVER_HAS_GEM_VM_OPS)
     .gem_vm_ops             = &nv_drm_gem_vma_ops,
+#endif
 };
 
 
diff --git a/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c b/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c
index e554adc..4aa082b 100644
--- a/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c
+++ b/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c
@@ -20,6 +20,7 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
+#include <linux/version.h>
 #include "nvidia-drm-conftest.h"
 
 #if defined(NV_DRM_AVAILABLE)
@@ -58,6 +59,7 @@ static struct sg_table *__nv_drm_gem_user_memory_prime_get_sg_table(
                                     nv_user_memory->pages_count);
 }
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0))
 static void *__nv_drm_gem_user_memory_prime_vmap(
     struct nv_drm_gem_object *nv_gem)
 {
@@ -73,6 +75,28 @@ static void __nv_drm_gem_user_memory_prime_vunmap(
 {
     nv_drm_vunmap(address);
 }
+#else
+// Updated vmap/vunmap operations to use struct dma_buf_map instead of raw pointers
+// See torvalds/linux commits ccc22d41bd9acec58cdc7c3b012e1887aba40af4, 6619ccf1bb1d0ebb071f758111efa83918b216fc
+static int __nv_drm_gem_user_memory_prime_vmap(
+    struct nv_drm_gem_object *nv_gem,
+    struct dma_buf_map *map)
+{
+    struct nv_drm_gem_user_memory *nv_user_memory = to_nv_user_memory(nv_gem);
+
+    map->vaddr = nv_drm_vmap(nv_user_memory->pages,
+                           nv_user_memory->pages_count);
+    map->is_iomem = false;
+    return 0;
+}
+
+static void __nv_drm_gem_user_memory_prime_vunmap(
+    struct nv_drm_gem_object *gem,
+    struct dma_buf_map *map)
+{
+    nv_drm_vunmap(map->vaddr);
+}
+#endif
 
 static int __nv_drm_gem_user_memory_mmap(struct nv_drm_gem_object *nv_gem,
                                          struct vm_area_struct *vma)
diff --git a/kernel/nvidia-drm/nvidia-drm-gem.c b/kernel/nvidia-drm/nvidia-drm-gem.c
index a6b54f0..ca45362 100644
--- a/kernel/nvidia-drm/nvidia-drm-gem.c
+++ b/kernel/nvidia-drm/nvidia-drm-gem.c
@@ -20,6 +20,7 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
+#include <linux/version.h>
 #include "nvidia-drm-conftest.h"
 
 #if defined(NV_DRM_AVAILABLE)
@@ -67,6 +68,13 @@ void nv_drm_gem_free(struct drm_gem_object *gem)
 static struct drm_gem_object_funcs nv_drm_gem_funcs = {
     .free = nv_drm_gem_free,
     .get_sg_table = nv_drm_gem_prime_get_sg_table,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0))
+    // New functions moved from drm_driver because of torvalds/linux commit d693def4fd1c23f1ca5aed1afb9993b3a2069ad2
+    .export       = drm_gem_prime_export,
+    .vmap         = nv_drm_gem_prime_vmap,
+    .vunmap       = nv_drm_gem_prime_vunmap,
+    .vm_ops       = &nv_drm_gem_vma_ops,
+#endif
 };
 #endif
 
@@ -141,6 +149,7 @@ struct sg_table *nv_drm_gem_prime_get_sg_table(struct drm_gem_object *gem)
     return ERR_PTR(-ENOTSUPP);
 }
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0))
 void *nv_drm_gem_prime_vmap(struct drm_gem_object *gem)
 {
     struct nv_drm_gem_object *nv_gem = to_nv_gem_object(gem);
@@ -160,6 +169,29 @@ void nv_drm_gem_prime_vunmap(struct drm_gem_object *gem, void *address)
         nv_gem->ops->prime_vunmap(nv_gem, address);
     }
 }
+#else
+// Updated vmap/vunmap operations to use struct dma_buf_map instead of raw pointers
+// See torvalds/linux commits ccc22d41bd9acec58cdc7c3b012e1887aba40af4, 6619ccf1bb1d0ebb071f758111efa83918b216fc
+int nv_drm_gem_prime_vmap(struct drm_gem_object *gem, struct dma_buf_map *map)
+{
+    struct nv_drm_gem_object *nv_gem = to_nv_gem_object(gem);
+
+    if (nv_gem->ops->prime_vmap != NULL) {
+        return nv_gem->ops->prime_vmap(nv_gem, map);
+    }
+
+    return -ENOTSUPP;
+}
+
+void nv_drm_gem_prime_vunmap(struct drm_gem_object *gem, struct dma_buf_map *map)
+{
+    struct nv_drm_gem_object *nv_gem = to_nv_gem_object(gem);
+
+    if (nv_gem->ops->prime_vunmap != NULL) {
+        nv_gem->ops->prime_vunmap(nv_gem, map);
+    }
+}
+#endif
 
 #if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ)
 nv_dma_resv_t* nv_drm_gem_prime_res_obj(struct drm_gem_object *obj)
diff --git a/kernel/nvidia-drm/nvidia-drm-gem.h b/kernel/nvidia-drm/nvidia-drm-gem.h
index 5c9f33d..24576e2 100644
--- a/kernel/nvidia-drm/nvidia-drm-gem.h
+++ b/kernel/nvidia-drm/nvidia-drm-gem.h
@@ -23,6 +23,7 @@
 #ifndef __NVIDIA_DRM_GEM_H__
 #define __NVIDIA_DRM_GEM_H__
 
+#include <linux/version.h>
 #include "nvidia-drm-conftest.h"
 
 #if defined(NV_DRM_AVAILABLE)
@@ -50,8 +51,15 @@ struct nv_drm_gem_object;
 struct nv_drm_gem_object_funcs {
     void (*free)(struct nv_drm_gem_object *nv_gem);
     struct sg_table *(*prime_get_sg_table)(struct nv_drm_gem_object *nv_gem);
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0))
     void *(*prime_vmap)(struct nv_drm_gem_object *nv_gem);
     void (*prime_vunmap)(struct nv_drm_gem_object *nv_gem, void *address);
+#else
+    // Updated vmap/vunmap operations to use struct dma_buf_map instead of raw pointers
+    // See torvalds/linux commits ccc22d41bd9acec58cdc7c3b012e1887aba40af4, 6619ccf1bb1d0ebb071f758111efa83918b216fc
+    int (*prime_vmap)(struct nv_drm_gem_object *nv_gem, struct dma_buf_map *map);
+    void (*prime_vunmap)(struct nv_drm_gem_object *nv_gem, struct dma_buf_map *map);
+#endif
     struct drm_gem_object *(*prime_dup)(struct drm_device *dev,
                                         const struct nv_drm_gem_object *nv_gem_src);
     int (*mmap)(struct nv_drm_gem_object *nv_gem, struct vm_area_struct *vma);
@@ -188,9 +196,17 @@ struct drm_gem_object *nv_drm_gem_prime_import(struct drm_device *dev,
 
 struct sg_table *nv_drm_gem_prime_get_sg_table(struct drm_gem_object *gem);
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0))
 void *nv_drm_gem_prime_vmap(struct drm_gem_object *gem);
 
 void nv_drm_gem_prime_vunmap(struct drm_gem_object *gem, void *address);
+#else
+// Updated vmap/vunmap operations to use struct dma_buf_map instead of raw pointers
+// See torvalds/linux commits ccc22d41bd9acec58cdc7c3b012e1887aba40af4, 6619ccf1bb1d0ebb071f758111efa83918b216fc
+int nv_drm_gem_prime_vmap(struct drm_gem_object *gem, struct dma_buf_map *map);
+
+void nv_drm_gem_prime_vunmap(struct drm_gem_object *gem, struct dma_buf_map *map);
+#endif
 
 #if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ)
 nv_dma_resv_t* nv_drm_gem_prime_res_obj(struct drm_gem_object *obj);
diff --git a/kernel/nvidia-drm/nvidia-drm.Kbuild b/kernel/nvidia-drm/nvidia-drm.Kbuild
index 23ca4ed..8aefa11 100644
--- a/kernel/nvidia-drm/nvidia-drm.Kbuild
+++ b/kernel/nvidia-drm/nvidia-drm.Kbuild
@@ -106,3 +106,11 @@ NV_CONFTEST_TYPE_COMPILE_TESTS += drm_display_mode_has_vrefresh
 NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_master_set_has_int_return_type
 NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_free_object
 NV_CONFTEST_TYPE_COMPILE_TESTS += drm_prime_pages_to_sg_has_drm_device_arg
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_prime_get_sg_table
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_prime_export
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_prime_vmap
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_prime_vunmap
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_atomic_check_atomic_state
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_atomic_enable_atomic_state
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_device_list
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_vm_ops
diff --git a/kernel/nvidia/nv-caps.c b/kernel/nvidia/nv-caps.c
index 90e866f..5cde194 100644
--- a/kernel/nvidia/nv-caps.c
+++ b/kernel/nvidia/nv-caps.c
@@ -37,8 +37,12 @@ MODULE_PARM_DESC(nv_cap_enable_devfs, "Enable (1) or disable (0) nv-caps " \
 
 extern int NVreg_ModifyDeviceFiles;
 
+#if NV_IS_EXPORT_SYMBOL_PRESENT_close_fd
+#include <linux/fdtable.h>
+#else
 /* sys_close() or __close_fd() */
 #include <linux/syscalls.h>
+#endif
 
 #define NV_CAP_DRV_MINOR_COUNT 8192
 
@@ -586,7 +590,9 @@ void NV_API_CALL nv_cap_close_fd(int fd)
  * 2018-04-02 2ca2a09d6215 ("fs: add ksys_close() wrapper; remove in-kernel
  *  calls to sys_close()")
  */
-#if NV_IS_EXPORT_SYMBOL_PRESENT___close_fd
+#if NV_IS_EXPORT_SYMBOL_PRESENT_close_fd
+    close_fd(fd);
+#elif NV_IS_EXPORT_SYMBOL_PRESENT___close_fd
     __close_fd(current->files, fd);
 #else
     sys_close(fd);
diff --git a/kernel/nvidia/nvidia.Kbuild b/kernel/nvidia/nvidia.Kbuild
index 8fc929e..48a98d3 100644
--- a/kernel/nvidia/nvidia.Kbuild
+++ b/kernel/nvidia/nvidia.Kbuild
@@ -173,6 +173,7 @@ NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_tegra_dce_client_ip
 NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_dram_clk_to_mc_clk
 NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_get_dram_num_channels
 NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_tegra_dram_types
+NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_close_fd
 
 NV_CONFTEST_TYPE_COMPILE_TESTS += acpi_op_remove
 NV_CONFTEST_TYPE_COMPILE_TESTS += outer_flush_all

Last edited by loqs (2021-01-07 23:24:50)

Offline

#32 2021-01-07 23:28:24

TheFurryWeeb
Member
Registered: 2020-08-06
Posts: 57

Re: [ERROR] [SOLVED] Custom Linux Kernel Compilation Part 2

loqs wrote:

The 460.32.03 driver still needs patching for 5.11,  try:

diff --git a/kernel/conftest.sh b/kernel/conftest.sh
index 87dac2a..2705218 100755
--- a/kernel/conftest.sh
+++ b/kernel/conftest.sh
@@ -1285,12 +1285,12 @@ compile_test() {
                 struct drm_driver drv;
 
                 /* 2013-01-15 89177644a7b6306e6084a89eab7e290f4bfef397 */
-                drv.gem_prime_pin = 0;
+/*                drv.gem_prime_pin = 0;
                 drv.gem_prime_get_sg_table = 0;
                 drv.gem_prime_vmap = 0;
                 drv.gem_prime_vunmap = 0;
                 (void)drm_gem_prime_import;
-                (void)drm_gem_prime_export;
+                (void)drm_gem_prime_export;*/
 
                 /* 2013-10-02 1bb72532ac260a2d3982b40bdd4c936d779d0d16 */
                 (void)drm_dev_alloc;
@@ -2086,6 +2086,42 @@ compile_test() {
             compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_LEGACY_DEV_LIST" "" "types"
         ;;
 
+        drm_driver_has_device_list)
+            # 57bb1ee6034046be70aed33fd6d447bb2b7261fa
+            CODE="
+            #if defined(NV_DRM_DRMP_H_PRESENT)
+            #include <drm/drmP.h>
+            #endif
+
+            #if defined(NV_DRM_DRM_DRV_H_PRESENT)
+            #include <drm/drm_drv.h>
+            #endif
+
+            int conftest_drm_driver_has_device_list(void) {
+                return offsetof(struct drm_driver, device_list);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_DEVICE_LIST" "" "types"
+        ;;
+
+        drm_driver_has_gem_vm_ops)
+            # d693def4fd1c23f1ca5aed1afb9993b3a2069ad2
+            CODE="
+            #if defined(NV_DRM_DRMP_H_PRESENT)
+            #include <drm/drmP.h>
+            #endif
+
+            #if defined(NV_DRM_DRM_DRV_H_PRESENT)
+            #include <drm/drm_drv.h>
+            #endif
+
+            int conftest_drm_driver_has_gem_vm_ops(void) {
+                return offsetof(struct drm_driver, gem_vm_ops);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_VM_OPS" "" "types"
+        ;;
+
         jiffies_to_timespec)
             #
             # Determine if jiffies_to_timespec() is present
@@ -2286,6 +2322,62 @@ compile_test() {
             compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ" "" "types"
         ;;
 
+        drm_driver_has_gem_prime_get_sg_table)
+            # Removed by commit d693def4fd1c23f1ca5aed1afb9993b3a2069ad2
+            CODE="
+            #if defined(NV_DRM_DRMP_H_PRESENT)
+            #include <drm/drmP.h>
+            #endif
+
+            int conftest_drm_driver_has_gem_prime_get_sg_table(void) {
+                return offsetof(struct drm_driver, gem_prime_get_sg_table);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_PRIME_GET_SG_TABLE" "" "types"
+        ;;
+
+        drm_driver_has_gem_prime_export)
+            # Removed by commit d693def4fd1c23f1ca5aed1afb9993b3a2069ad2
+            CODE="
+            #if defined(NV_DRM_DRMP_H_PRESENT)
+            #include <drm/drmP.h>
+            #endif
+
+            int conftest_drm_driver_has_gem_prime_export(void) {
+                return offsetof(struct drm_driver, gem_prime_export);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_PRIME_EXPORT" "" "types"
+        ;;
+
+        drm_driver_has_gem_prime_vmap)
+            # Removed by commit d693def4fd1c23f1ca5aed1afb9993b3a2069ad2
+            CODE="
+            #if defined(NV_DRM_DRMP_H_PRESENT)
+            #include <drm/drmP.h>
+            #endif
+
+            int conftest_drm_driver_has_gem_prime_vmap(void) {
+                return offsetof(struct drm_driver, gem_prime_vmap);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_PRIME_VMAP" "" "types"
+        ;;
+
+        drm_driver_has_gem_prime_vunmap)
+            # Removed by commit d693def4fd1c23f1ca5aed1afb9993b3a2069ad2
+            CODE="
+            #if defined(NV_DRM_DRMP_H_PRESENT)
+            #include <drm/drmP.h>
+            #endif
+
+            int conftest_drm_driver_has_gem_prime_vunmap(void) {
+                return offsetof(struct drm_driver, gem_prime_vunmap);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_PRIME_VUNMAP" "" "types"
+        ;;
+
         drm_crtc_state_has_connectors_changed)
             #
             # Determine if the crtc_state has a 'connectors_changed' field.
@@ -4346,6 +4438,34 @@ compile_test() {
             compile_check_conftest "$CODE" "NV_ITERATE_FD_PRESENT" "" "functions"
         ;;
 
+        drm_atomic_check_atomic_state)
+            # 29b77ad7b9ca8c87152a1a9e8188970fb2a93df4
+            CODE="
+            #include <drm/drm_modeset_helper_vtables.h>
+
+            void drm_atomic_check_atomic_state(struct drm_crtc_helper_funcs * funcs,
+                                               struct drm_crtc *crtc,
+                                               struct drm_atomic_state *state) {
+                funcs->atomic_check(crtc, state);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_ATOMIC_CHECK_ATOMIC_STATE" "" "types"
+        ;;
+
+        drm_atomic_enable_atomic_state)
+            # 351f950db4ab28c321a1bd4b92e4bb03e34c4703
+            CODE="
+            #include <drm/drm_modeset_helper_vtables.h>
+
+            void drm_atomic_enable_atomic_state(struct drm_crtc_helper_funcs * funcs,
+                                                struct drm_crtc *crtc,
+                                                struct drm_atomic_state *state) {
+                funcs->atomic_enable(crtc, state);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_ATOMIC_ENABLE_ATOMIC_STATE" "" "types"
+        ;;
+
         # When adding a new conftest entry, please use the correct format for
         # specifying the relevant upstream Linux kernel commit.
         #
diff --git a/kernel/nvidia-drm/nvidia-drm-crtc.c b/kernel/nvidia-drm/nvidia-drm-crtc.c
index b966bb2..6769004 100644
--- a/kernel/nvidia-drm/nvidia-drm-crtc.c
+++ b/kernel/nvidia-drm/nvidia-drm-crtc.c
@@ -460,8 +460,14 @@ static int head_modeset_config_attach_connector(
  * will be discarded if ->atomic_check() fails.
  */
 static int nv_drm_crtc_atomic_check(struct drm_crtc *crtc,
+#ifndef NV_DRM_ATOMIC_CHECK_ATOMIC_STATE
                                     struct drm_crtc_state *crtc_state)
 {
+#else
+                                    struct drm_atomic_state *state)
+{
+    struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,crtc);
+#endif
     struct nv_drm_crtc_state *nv_crtc_state = to_nv_crtc_state(crtc_state);
     struct NvKmsKapiHeadRequestedConfig *req_config =
         &nv_crtc_state->req_config;
@@ -532,7 +538,11 @@ static void nv_drm_crtc_disable(struct drm_crtc *crtc)
 
 #ifdef NV_DRM_CRTC_HELPER_FUNCS_HAS_ATOMIC_ENABLE
 static void nv_drm_crtc_atomic_enable(struct drm_crtc *crtc,
+#ifndef NV_DRM_ATOMIC_ENABLE_ATOMIC_STATE
                                       struct drm_crtc_state *old_crtc_state)
+#else
+                                      struct drm_atomic_state *state)
+#endif
 {
 
 }
diff --git a/kernel/nvidia-drm/nvidia-drm-drv.c b/kernel/nvidia-drm/nvidia-drm-drv.c
index ebfb5cd..5db6f6f 100644
--- a/kernel/nvidia-drm/nvidia-drm-drv.c
+++ b/kernel/nvidia-drm/nvidia-drm-drv.c
@@ -755,12 +755,20 @@ static struct drm_driver nv_drm_driver = {
 
     .prime_handle_to_fd     = drm_gem_prime_handle_to_fd,
     .prime_fd_to_handle     = drm_gem_prime_fd_to_handle,
+#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_EXPORT)
     .gem_prime_export       = drm_gem_prime_export,
+#endif
     .gem_prime_import       = nv_drm_gem_prime_import,
+#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_GET_SG_TABLE)
     .gem_prime_get_sg_table = nv_drm_gem_prime_get_sg_table,
+#endif
     .gem_prime_import_sg_table = nv_drm_gem_prime_import_sg_table,
+#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_VMAP)
     .gem_prime_vmap         = nv_drm_gem_prime_vmap,
+#endif
+#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_VUNMAP)
     .gem_prime_vunmap       = nv_drm_gem_prime_vunmap,
+#endif
 
 #if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ)
     .gem_prime_res_obj      = nv_drm_gem_prime_res_obj,
@@ -786,10 +794,12 @@ static struct drm_driver nv_drm_driver = {
 
 #if defined(NV_DRM_DRIVER_HAS_LEGACY_DEV_LIST)
     .legacy_dev_list        = LIST_HEAD_INIT(nv_drm_driver.legacy_dev_list),
-#else
+#elif defined(NV_DRM_DRIVER_HAS_DEVICE_LIST)
     .device_list            = LIST_HEAD_INIT(nv_drm_driver.device_list),
 #endif
+#if defined(NV_DRM_DRIVER_HAS_GEM_VM_OPS)
     .gem_vm_ops             = &nv_drm_gem_vma_ops,
+#endif
 };
 
 
diff --git a/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c b/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c
index e554adc..4aa082b 100644
--- a/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c
+++ b/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c
@@ -20,6 +20,7 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
+#include <linux/version.h>
 #include "nvidia-drm-conftest.h"
 
 #if defined(NV_DRM_AVAILABLE)
@@ -58,6 +59,7 @@ static struct sg_table *__nv_drm_gem_user_memory_prime_get_sg_table(
                                     nv_user_memory->pages_count);
 }
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0))
 static void *__nv_drm_gem_user_memory_prime_vmap(
     struct nv_drm_gem_object *nv_gem)
 {
@@ -73,6 +75,28 @@ static void __nv_drm_gem_user_memory_prime_vunmap(
 {
     nv_drm_vunmap(address);
 }
+#else
+// Updated vmap/vunmap operations to use struct dma_buf_map instead of raw pointers
+// See torvalds/linux commits ccc22d41bd9acec58cdc7c3b012e1887aba40af4, 6619ccf1bb1d0ebb071f758111efa83918b216fc
+static int __nv_drm_gem_user_memory_prime_vmap(
+    struct nv_drm_gem_object *nv_gem,
+    struct dma_buf_map *map)
+{
+    struct nv_drm_gem_user_memory *nv_user_memory = to_nv_user_memory(nv_gem);
+
+    map->vaddr = nv_drm_vmap(nv_user_memory->pages,
+                           nv_user_memory->pages_count);
+    map->is_iomem = false;
+    return 0;
+}
+
+static void __nv_drm_gem_user_memory_prime_vunmap(
+    struct nv_drm_gem_object *gem,
+    struct dma_buf_map *map)
+{
+    nv_drm_vunmap(map->vaddr);
+}
+#endif
 
 static int __nv_drm_gem_user_memory_mmap(struct nv_drm_gem_object *nv_gem,
                                          struct vm_area_struct *vma)
diff --git a/kernel/nvidia-drm/nvidia-drm-gem.c b/kernel/nvidia-drm/nvidia-drm-gem.c
index a6b54f0..ca45362 100644
--- a/kernel/nvidia-drm/nvidia-drm-gem.c
+++ b/kernel/nvidia-drm/nvidia-drm-gem.c
@@ -20,6 +20,7 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
+#include <linux/version.h>
 #include "nvidia-drm-conftest.h"
 
 #if defined(NV_DRM_AVAILABLE)
@@ -67,6 +68,13 @@ void nv_drm_gem_free(struct drm_gem_object *gem)
 static struct drm_gem_object_funcs nv_drm_gem_funcs = {
     .free = nv_drm_gem_free,
     .get_sg_table = nv_drm_gem_prime_get_sg_table,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0))
+    // New functions moved from drm_driver because of torvalds/linux commit d693def4fd1c23f1ca5aed1afb9993b3a2069ad2
+    .export       = drm_gem_prime_export,
+    .vmap         = nv_drm_gem_prime_vmap,
+    .vunmap       = nv_drm_gem_prime_vunmap,
+    .vm_ops       = &nv_drm_gem_vma_ops,
+#endif
 };
 #endif
 
@@ -141,6 +149,7 @@ struct sg_table *nv_drm_gem_prime_get_sg_table(struct drm_gem_object *gem)
     return ERR_PTR(-ENOTSUPP);
 }
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0))
 void *nv_drm_gem_prime_vmap(struct drm_gem_object *gem)
 {
     struct nv_drm_gem_object *nv_gem = to_nv_gem_object(gem);
@@ -160,6 +169,29 @@ void nv_drm_gem_prime_vunmap(struct drm_gem_object *gem, void *address)
         nv_gem->ops->prime_vunmap(nv_gem, address);
     }
 }
+#else
+// Updated vmap/vunmap operations to use struct dma_buf_map instead of raw pointers
+// See torvalds/linux commits ccc22d41bd9acec58cdc7c3b012e1887aba40af4, 6619ccf1bb1d0ebb071f758111efa83918b216fc
+int nv_drm_gem_prime_vmap(struct drm_gem_object *gem, struct dma_buf_map *map)
+{
+    struct nv_drm_gem_object *nv_gem = to_nv_gem_object(gem);
+
+    if (nv_gem->ops->prime_vmap != NULL) {
+        return nv_gem->ops->prime_vmap(nv_gem, map);
+    }
+
+    return -ENOTSUPP;
+}
+
+void nv_drm_gem_prime_vunmap(struct drm_gem_object *gem, struct dma_buf_map *map)
+{
+    struct nv_drm_gem_object *nv_gem = to_nv_gem_object(gem);
+
+    if (nv_gem->ops->prime_vunmap != NULL) {
+        nv_gem->ops->prime_vunmap(nv_gem, map);
+    }
+}
+#endif
 
 #if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ)
 nv_dma_resv_t* nv_drm_gem_prime_res_obj(struct drm_gem_object *obj)
diff --git a/kernel/nvidia-drm/nvidia-drm-gem.h b/kernel/nvidia-drm/nvidia-drm-gem.h
index 5c9f33d..24576e2 100644
--- a/kernel/nvidia-drm/nvidia-drm-gem.h
+++ b/kernel/nvidia-drm/nvidia-drm-gem.h
@@ -23,6 +23,7 @@
 #ifndef __NVIDIA_DRM_GEM_H__
 #define __NVIDIA_DRM_GEM_H__
 
+#include <linux/version.h>
 #include "nvidia-drm-conftest.h"
 
 #if defined(NV_DRM_AVAILABLE)
@@ -50,8 +51,15 @@ struct nv_drm_gem_object;
 struct nv_drm_gem_object_funcs {
     void (*free)(struct nv_drm_gem_object *nv_gem);
     struct sg_table *(*prime_get_sg_table)(struct nv_drm_gem_object *nv_gem);
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0))
     void *(*prime_vmap)(struct nv_drm_gem_object *nv_gem);
     void (*prime_vunmap)(struct nv_drm_gem_object *nv_gem, void *address);
+#else
+    // Updated vmap/vunmap operations to use struct dma_buf_map instead of raw pointers
+    // See torvalds/linux commits ccc22d41bd9acec58cdc7c3b012e1887aba40af4, 6619ccf1bb1d0ebb071f758111efa83918b216fc
+    int (*prime_vmap)(struct nv_drm_gem_object *nv_gem, struct dma_buf_map *map);
+    void (*prime_vunmap)(struct nv_drm_gem_object *nv_gem, struct dma_buf_map *map);
+#endif
     struct drm_gem_object *(*prime_dup)(struct drm_device *dev,
                                         const struct nv_drm_gem_object *nv_gem_src);
     int (*mmap)(struct nv_drm_gem_object *nv_gem, struct vm_area_struct *vma);
@@ -188,9 +196,17 @@ struct drm_gem_object *nv_drm_gem_prime_import(struct drm_device *dev,
 
 struct sg_table *nv_drm_gem_prime_get_sg_table(struct drm_gem_object *gem);
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0))
 void *nv_drm_gem_prime_vmap(struct drm_gem_object *gem);
 
 void nv_drm_gem_prime_vunmap(struct drm_gem_object *gem, void *address);
+#else
+// Updated vmap/vunmap operations to use struct dma_buf_map instead of raw pointers
+// See torvalds/linux commits ccc22d41bd9acec58cdc7c3b012e1887aba40af4, 6619ccf1bb1d0ebb071f758111efa83918b216fc
+int nv_drm_gem_prime_vmap(struct drm_gem_object *gem, struct dma_buf_map *map);
+
+void nv_drm_gem_prime_vunmap(struct drm_gem_object *gem, struct dma_buf_map *map);
+#endif
 
 #if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ)
 nv_dma_resv_t* nv_drm_gem_prime_res_obj(struct drm_gem_object *obj);
diff --git a/kernel/nvidia-drm/nvidia-drm.Kbuild b/kernel/nvidia-drm/nvidia-drm.Kbuild
index 23ca4ed..8aefa11 100644
--- a/kernel/nvidia-drm/nvidia-drm.Kbuild
+++ b/kernel/nvidia-drm/nvidia-drm.Kbuild
@@ -106,3 +106,11 @@ NV_CONFTEST_TYPE_COMPILE_TESTS += drm_display_mode_has_vrefresh
 NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_master_set_has_int_return_type
 NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_free_object
 NV_CONFTEST_TYPE_COMPILE_TESTS += drm_prime_pages_to_sg_has_drm_device_arg
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_prime_get_sg_table
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_prime_export
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_prime_vmap
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_prime_vunmap
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_atomic_check_atomic_state
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_atomic_enable_atomic_state
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_device_list
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_vm_ops
diff --git a/kernel/nvidia/nv-caps.c b/kernel/nvidia/nv-caps.c
index 90e866f..5cde194 100644
--- a/kernel/nvidia/nv-caps.c
+++ b/kernel/nvidia/nv-caps.c
@@ -37,8 +37,12 @@ MODULE_PARM_DESC(nv_cap_enable_devfs, "Enable (1) or disable (0) nv-caps " \
 
 extern int NVreg_ModifyDeviceFiles;
 
+#if NV_IS_EXPORT_SYMBOL_PRESENT_close_fd
+#include <linux/fdtable.h>
+#else
 /* sys_close() or __close_fd() */
 #include <linux/syscalls.h>
+#endif
 
 #define NV_CAP_DRV_MINOR_COUNT 8192
 
@@ -586,7 +590,9 @@ void NV_API_CALL nv_cap_close_fd(int fd)
  * 2018-04-02 2ca2a09d6215 ("fs: add ksys_close() wrapper; remove in-kernel
  *  calls to sys_close()")
  */
-#if NV_IS_EXPORT_SYMBOL_PRESENT___close_fd
+#if NV_IS_EXPORT_SYMBOL_PRESENT_close_fd
+    close_fd(fd);
+#elif NV_IS_EXPORT_SYMBOL_PRESENT___close_fd
     __close_fd(current->files, fd);
 #else
     sys_close(fd);
diff --git a/kernel/nvidia/nvidia.Kbuild b/kernel/nvidia/nvidia.Kbuild
index 8fc929e..48a98d3 100644
--- a/kernel/nvidia/nvidia.Kbuild
+++ b/kernel/nvidia/nvidia.Kbuild
@@ -173,6 +173,7 @@ NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_tegra_dce_client_ip
 NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_dram_clk_to_mc_clk
 NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_get_dram_num_channels
 NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_tegra_dram_types
+NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_close_fd
 
 NV_CONFTEST_TYPE_COMPILE_TESTS += acpi_op_remove
 NV_CONFTEST_TYPE_COMPILE_TESTS += outer_flush_all

Then how can I download the 455.45.01 driver?

Plus, building the beta 460 driver from source gives me extracting errors in prepare().


A computer and Linux nerd, an avid 2D platformer and RPG gamer and a furry combined into one person.

I hope I can help you out with your Arch issues and get myself helped out, as well.

Offline

#33 2021-01-07 23:41:39

loqs
Member
Registered: 2014-03-06
Posts: 13,005

Re: [ERROR] [SOLVED] Custom Linux Kernel Compilation Part 2

Obtain it from the nvidia website if you mean the .run self extracting archive.  From the ALA if you mean the older version of the nvidia / nvidia-dkms package.
455.45.01 will not work with 5.11 either without a patch.

Offline

#34 2021-01-13 22:04:51

TheFurryWeeb
Member
Registered: 2020-08-06
Posts: 57

Re: [ERROR] [SOLVED] Custom Linux Kernel Compilation Part 2

It seems that the AUR now hosts 5.11-rc3, which is currently the latest kernel, but if I try to install it with yay, now it spits out a different error message in the DKMS make.log file:

 CC [M]  /var/lib/dkms/nvidia/460.32.03/build/nvidia/nvlink_caps.o
/var/lib/dkms/nvidia/460.32.03/build/nvidia/nv-caps.c: In function ‘nv_cap_close_fd’:
/var/lib/dkms/nvidia/460.32.03/build/nvidia/nv-caps.c:592:5: error: implicit declaration of function ‘sys_close’ [-Werror=implicit-function-declaration]
  592 |     sys_close(fd);
      |     ^~~~~~~~~
  CC [M]  /var/lib/dkms/nvidia/460.32.03/build/nvidia/linux_nvswitch.o
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:279: /var/lib/dkms/nvidia/460.32.03/build/nvidia/nv-caps.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [Makefile:1805: /var/lib/dkms/nvidia/460.32.03/build] Error 2
make[1]: Leaving directory '/usr/lib/modules/5.11.0-rc3-1-mainline/build'
make: *** [Makefile:80: modules] Error 2

Is it easier to fix than the issue referring to a non-existent keymap_asm.h file in the previous testing versions of 5.11?


A computer and Linux nerd, an avid 2D platformer and RPG gamer and a furry combined into one person.

I hope I can help you out with your Arch issues and get myself helped out, as well.

Offline

#35 2021-01-13 23:36:24

loqs
Member
Registered: 2014-03-06
Posts: 13,005

Re: [ERROR] [SOLVED] Custom Linux Kernel Compilation Part 2

To me it looks to be identical to the issue you reported in post #30.
About as difficult to fix.

kmap_types patch for 460.27.04

--- a/kernel/common/inc/nv-linux.h
+++ b/kernel/common/inc/nv-linux.h
@@ -117,7 +117,9 @@
 
 #include <linux/moduleparam.h>      /* module_param()                   */
 #include <asm/tlbflush.h>           /* flush_tlb(), flush_tlb_all()     */
+#if defined(NV_ASM_KMAP_TYPES_H_PRESENT)
 #include <asm/kmap_types.h>         /* page table entry lookup          */
+#endif
 
 #include <linux/pci.h>              /* pci_find_class, etc              */
 #include <linux/interrupt.h>        /* tasklets, interrupt helpers      */
diff --git a/kernel/conftest.sh b/kernel/conftest.sh
index 282a911..c2d0fc3 100755
--- a/kernel/conftest.sh
+++ b/kernel/conftest.sh
@@ -159,6 +159,7 @@ test_headers() {
     FILES="$FILES asm/pgtable_types.h"
     FILES="$FILES linux/stringhash.h"
     FILES="$FILES linux/dma-map-ops.h"
+    FILES="$FILES asm/kmap_types.h"
 
     translate_and_preprocess_header_files $FILES
 }

In 460.32.03 the include is not present so no patch is needed,

sys_close -> close_fd again patch for 460.27.04

--- a/kernel/nvidia/nv-caps.c
+++ b/kernel/nvidia/nv-caps.c
@@ -37,8 +37,12 @@ MODULE_PARM_DESC(nv_cap_enable_devfs, "Enable (1) or disable (0) nv-caps " \
 
 extern int NVreg_ModifyDeviceFiles;
 
+#if NV_IS_EXPORT_SYMBOL_PRESENT_close_fd
+#include <linux/fdtable.h>
+#else
 /* sys_close() or __close_fd() */
 #include <linux/syscalls.h>
+#endif
 
 #define NV_CAP_DRV_MINOR_COUNT 8192
 
@@ -586,7 +590,9 @@ void NV_API_CALL nv_cap_close_fd(int fd)
  * 2018-04-02 2ca2a09d6215 ("fs: add ksys_close() wrapper; remove in-kernel
  *  calls to sys_close()")
  */
-#if NV_IS_EXPORT_SYMBOL_PRESENT___close_fd
+#if NV_IS_EXPORT_SYMBOL_PRESENT_close_fd
+    close_fd(fd);
+#elif NV_IS_EXPORT_SYMBOL_PRESENT___close_fd
     __close_fd(current->files, fd);
 #else
     sys_close(fd);
diff --git a/kernel/nvidia/nvidia.Kbuild b/kernel/nvidia/nvidia.Kbuild
index 90579de..c6f3614 100644
--- a/kernel/nvidia/nvidia.Kbuild
+++ b/kernel/nvidia/nvidia.Kbuild
@@ -172,6 +172,7 @@ NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_tegra_dce_client_ip
 NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_dram_clk_to_mc_clk
 NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_get_dram_num_channels
 NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_tegra_dram_types
+NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_close_fd
 
 NV_CONFTEST_TYPE_COMPILE_TESTS += acpi_op_remove
 NV_CONFTEST_TYPE_COMPILE_TESTS += outer_flush_all

Edit:
Full patch for 460.32.03

diff --git a/kernel/conftest.sh b/kernel/conftest.sh
index 87dac2a..2705218 100755
--- a/kernel/conftest.sh
+++ b/kernel/conftest.sh
@@ -1285,12 +1285,12 @@ compile_test() {
                 struct drm_driver drv;
 
                 /* 2013-01-15 89177644a7b6306e6084a89eab7e290f4bfef397 */
-                drv.gem_prime_pin = 0;
+/*                drv.gem_prime_pin = 0;
                 drv.gem_prime_get_sg_table = 0;
                 drv.gem_prime_vmap = 0;
                 drv.gem_prime_vunmap = 0;
                 (void)drm_gem_prime_import;
-                (void)drm_gem_prime_export;
+                (void)drm_gem_prime_export;*/
 
                 /* 2013-10-02 1bb72532ac260a2d3982b40bdd4c936d779d0d16 */
                 (void)drm_dev_alloc;
@@ -2086,6 +2086,42 @@ compile_test() {
             compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_LEGACY_DEV_LIST" "" "types"
         ;;
 
+        drm_driver_has_device_list)
+            # 57bb1ee6034046be70aed33fd6d447bb2b7261fa
+            CODE="
+            #if defined(NV_DRM_DRMP_H_PRESENT)
+            #include <drm/drmP.h>
+            #endif
+
+            #if defined(NV_DRM_DRM_DRV_H_PRESENT)
+            #include <drm/drm_drv.h>
+            #endif
+
+            int conftest_drm_driver_has_device_list(void) {
+                return offsetof(struct drm_driver, device_list);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_DEVICE_LIST" "" "types"
+        ;;
+
+        drm_driver_has_gem_vm_ops)
+            # d693def4fd1c23f1ca5aed1afb9993b3a2069ad2
+            CODE="
+            #if defined(NV_DRM_DRMP_H_PRESENT)
+            #include <drm/drmP.h>
+            #endif
+
+            #if defined(NV_DRM_DRM_DRV_H_PRESENT)
+            #include <drm/drm_drv.h>
+            #endif
+
+            int conftest_drm_driver_has_gem_vm_ops(void) {
+                return offsetof(struct drm_driver, gem_vm_ops);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_VM_OPS" "" "types"
+        ;;
+
         jiffies_to_timespec)
             #
             # Determine if jiffies_to_timespec() is present
@@ -2286,6 +2322,62 @@ compile_test() {
             compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ" "" "types"
         ;;
 
+        drm_driver_has_gem_prime_get_sg_table)
+            # Removed by commit d693def4fd1c23f1ca5aed1afb9993b3a2069ad2
+            CODE="
+            #if defined(NV_DRM_DRMP_H_PRESENT)
+            #include <drm/drmP.h>
+            #endif
+
+            int conftest_drm_driver_has_gem_prime_get_sg_table(void) {
+                return offsetof(struct drm_driver, gem_prime_get_sg_table);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_PRIME_GET_SG_TABLE" "" "types"
+        ;;
+
+        drm_driver_has_gem_prime_export)
+            # Removed by commit d693def4fd1c23f1ca5aed1afb9993b3a2069ad2
+            CODE="
+            #if defined(NV_DRM_DRMP_H_PRESENT)
+            #include <drm/drmP.h>
+            #endif
+
+            int conftest_drm_driver_has_gem_prime_export(void) {
+                return offsetof(struct drm_driver, gem_prime_export);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_PRIME_EXPORT" "" "types"
+        ;;
+
+        drm_driver_has_gem_prime_vmap)
+            # Removed by commit d693def4fd1c23f1ca5aed1afb9993b3a2069ad2
+            CODE="
+            #if defined(NV_DRM_DRMP_H_PRESENT)
+            #include <drm/drmP.h>
+            #endif
+
+            int conftest_drm_driver_has_gem_prime_vmap(void) {
+                return offsetof(struct drm_driver, gem_prime_vmap);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_PRIME_VMAP" "" "types"
+        ;;
+
+        drm_driver_has_gem_prime_vunmap)
+            # Removed by commit d693def4fd1c23f1ca5aed1afb9993b3a2069ad2
+            CODE="
+            #if defined(NV_DRM_DRMP_H_PRESENT)
+            #include <drm/drmP.h>
+            #endif
+
+            int conftest_drm_driver_has_gem_prime_vunmap(void) {
+                return offsetof(struct drm_driver, gem_prime_vunmap);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_PRIME_VUNMAP" "" "types"
+        ;;
+
         drm_crtc_state_has_connectors_changed)
             #
             # Determine if the crtc_state has a 'connectors_changed' field.
@@ -4346,6 +4438,34 @@ compile_test() {
             compile_check_conftest "$CODE" "NV_ITERATE_FD_PRESENT" "" "functions"
         ;;
 
+        drm_atomic_check_atomic_state)
+            # 29b77ad7b9ca8c87152a1a9e8188970fb2a93df4
+            CODE="
+            #include <drm/drm_modeset_helper_vtables.h>
+
+            void drm_atomic_check_atomic_state(struct drm_crtc_helper_funcs * funcs,
+                                               struct drm_crtc *crtc,
+                                               struct drm_atomic_state *state) {
+                funcs->atomic_check(crtc, state);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_ATOMIC_CHECK_ATOMIC_STATE" "" "types"
+        ;;
+
+        drm_atomic_enable_atomic_state)
+            # 351f950db4ab28c321a1bd4b92e4bb03e34c4703
+            CODE="
+            #include <drm/drm_modeset_helper_vtables.h>
+
+            void drm_atomic_enable_atomic_state(struct drm_crtc_helper_funcs * funcs,
+                                                struct drm_crtc *crtc,
+                                                struct drm_atomic_state *state) {
+                funcs->atomic_enable(crtc, state);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_ATOMIC_ENABLE_ATOMIC_STATE" "" "types"
+        ;;
+
         # When adding a new conftest entry, please use the correct format for
         # specifying the relevant upstream Linux kernel commit.
         #
diff --git a/kernel/nvidia-drm/nvidia-drm-crtc.c b/kernel/nvidia-drm/nvidia-drm-crtc.c
index b966bb2..6769004 100644
--- a/kernel/nvidia-drm/nvidia-drm-crtc.c
+++ b/kernel/nvidia-drm/nvidia-drm-crtc.c
@@ -460,8 +460,14 @@ static int head_modeset_config_attach_connector(
  * will be discarded if ->atomic_check() fails.
  */
 static int nv_drm_crtc_atomic_check(struct drm_crtc *crtc,
+#ifndef NV_DRM_ATOMIC_CHECK_ATOMIC_STATE
                                     struct drm_crtc_state *crtc_state)
 {
+#else
+                                    struct drm_atomic_state *state)
+{
+    struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,crtc);
+#endif
     struct nv_drm_crtc_state *nv_crtc_state = to_nv_crtc_state(crtc_state);
     struct NvKmsKapiHeadRequestedConfig *req_config =
         &nv_crtc_state->req_config;
@@ -532,7 +538,11 @@ static void nv_drm_crtc_disable(struct drm_crtc *crtc)
 
 #ifdef NV_DRM_CRTC_HELPER_FUNCS_HAS_ATOMIC_ENABLE
 static void nv_drm_crtc_atomic_enable(struct drm_crtc *crtc,
+#ifndef NV_DRM_ATOMIC_ENABLE_ATOMIC_STATE
                                       struct drm_crtc_state *old_crtc_state)
+#else
+                                      struct drm_atomic_state *state)
+#endif
 {
 
 }
diff --git a/kernel/nvidia-drm/nvidia-drm-drv.c b/kernel/nvidia-drm/nvidia-drm-drv.c
index ebfb5cd..5db6f6f 100644
--- a/kernel/nvidia-drm/nvidia-drm-drv.c
+++ b/kernel/nvidia-drm/nvidia-drm-drv.c
@@ -755,12 +755,20 @@ static struct drm_driver nv_drm_driver = {
 
     .prime_handle_to_fd     = drm_gem_prime_handle_to_fd,
     .prime_fd_to_handle     = drm_gem_prime_fd_to_handle,
+#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_EXPORT)
     .gem_prime_export       = drm_gem_prime_export,
+#endif
     .gem_prime_import       = nv_drm_gem_prime_import,
+#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_GET_SG_TABLE)
     .gem_prime_get_sg_table = nv_drm_gem_prime_get_sg_table,
+#endif
     .gem_prime_import_sg_table = nv_drm_gem_prime_import_sg_table,
+#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_VMAP)
     .gem_prime_vmap         = nv_drm_gem_prime_vmap,
+#endif
+#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_VUNMAP)
     .gem_prime_vunmap       = nv_drm_gem_prime_vunmap,
+#endif
 
 #if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ)
     .gem_prime_res_obj      = nv_drm_gem_prime_res_obj,
@@ -786,10 +794,12 @@ static struct drm_driver nv_drm_driver = {
 
 #if defined(NV_DRM_DRIVER_HAS_LEGACY_DEV_LIST)
     .legacy_dev_list        = LIST_HEAD_INIT(nv_drm_driver.legacy_dev_list),
-#else
+#elif defined(NV_DRM_DRIVER_HAS_DEVICE_LIST)
     .device_list            = LIST_HEAD_INIT(nv_drm_driver.device_list),
 #endif
+#if defined(NV_DRM_DRIVER_HAS_GEM_VM_OPS)
     .gem_vm_ops             = &nv_drm_gem_vma_ops,
+#endif
 };
 
 
diff --git a/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c b/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c
index e554adc..4aa082b 100644
--- a/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c
+++ b/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c
@@ -20,6 +20,7 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
+#include <linux/version.h>
 #include "nvidia-drm-conftest.h"
 
 #if defined(NV_DRM_AVAILABLE)
@@ -58,6 +59,7 @@ static struct sg_table *__nv_drm_gem_user_memory_prime_get_sg_table(
                                     nv_user_memory->pages_count);
 }
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0))
 static void *__nv_drm_gem_user_memory_prime_vmap(
     struct nv_drm_gem_object *nv_gem)
 {
@@ -73,6 +75,28 @@ static void __nv_drm_gem_user_memory_prime_vunmap(
 {
     nv_drm_vunmap(address);
 }
+#else
+// Updated vmap/vunmap operations to use struct dma_buf_map instead of raw pointers
+// See torvalds/linux commits ccc22d41bd9acec58cdc7c3b012e1887aba40af4, 6619ccf1bb1d0ebb071f758111efa83918b216fc
+static int __nv_drm_gem_user_memory_prime_vmap(
+    struct nv_drm_gem_object *nv_gem,
+    struct dma_buf_map *map)
+{
+    struct nv_drm_gem_user_memory *nv_user_memory = to_nv_user_memory(nv_gem);
+
+    map->vaddr = nv_drm_vmap(nv_user_memory->pages,
+                           nv_user_memory->pages_count);
+    map->is_iomem = false;
+    return 0;
+}
+
+static void __nv_drm_gem_user_memory_prime_vunmap(
+    struct nv_drm_gem_object *gem,
+    struct dma_buf_map *map)
+{
+    nv_drm_vunmap(map->vaddr);
+}
+#endif
 
 static int __nv_drm_gem_user_memory_mmap(struct nv_drm_gem_object *nv_gem,
                                          struct vm_area_struct *vma)
diff --git a/kernel/nvidia-drm/nvidia-drm-gem.c b/kernel/nvidia-drm/nvidia-drm-gem.c
index a6b54f0..ca45362 100644
--- a/kernel/nvidia-drm/nvidia-drm-gem.c
+++ b/kernel/nvidia-drm/nvidia-drm-gem.c
@@ -20,6 +20,7 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
+#include <linux/version.h>
 #include "nvidia-drm-conftest.h"
 
 #if defined(NV_DRM_AVAILABLE)
@@ -67,6 +68,13 @@ void nv_drm_gem_free(struct drm_gem_object *gem)
 static struct drm_gem_object_funcs nv_drm_gem_funcs = {
     .free = nv_drm_gem_free,
     .get_sg_table = nv_drm_gem_prime_get_sg_table,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0))
+    // New functions moved from drm_driver because of torvalds/linux commit d693def4fd1c23f1ca5aed1afb9993b3a2069ad2
+    .export       = drm_gem_prime_export,
+    .vmap         = nv_drm_gem_prime_vmap,
+    .vunmap       = nv_drm_gem_prime_vunmap,
+    .vm_ops       = &nv_drm_gem_vma_ops,
+#endif
 };
 #endif
 
@@ -141,6 +149,7 @@ struct sg_table *nv_drm_gem_prime_get_sg_table(struct drm_gem_object *gem)
     return ERR_PTR(-ENOTSUPP);
 }
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0))
 void *nv_drm_gem_prime_vmap(struct drm_gem_object *gem)
 {
     struct nv_drm_gem_object *nv_gem = to_nv_gem_object(gem);
@@ -160,6 +169,29 @@ void nv_drm_gem_prime_vunmap(struct drm_gem_object *gem, void *address)
         nv_gem->ops->prime_vunmap(nv_gem, address);
     }
 }
+#else
+// Updated vmap/vunmap operations to use struct dma_buf_map instead of raw pointers
+// See torvalds/linux commits ccc22d41bd9acec58cdc7c3b012e1887aba40af4, 6619ccf1bb1d0ebb071f758111efa83918b216fc
+int nv_drm_gem_prime_vmap(struct drm_gem_object *gem, struct dma_buf_map *map)
+{
+    struct nv_drm_gem_object *nv_gem = to_nv_gem_object(gem);
+
+    if (nv_gem->ops->prime_vmap != NULL) {
+        return nv_gem->ops->prime_vmap(nv_gem, map);
+    }
+
+    return -ENOTSUPP;
+}
+
+void nv_drm_gem_prime_vunmap(struct drm_gem_object *gem, struct dma_buf_map *map)
+{
+    struct nv_drm_gem_object *nv_gem = to_nv_gem_object(gem);
+
+    if (nv_gem->ops->prime_vunmap != NULL) {
+        nv_gem->ops->prime_vunmap(nv_gem, map);
+    }
+}
+#endif
 
 #if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ)
 nv_dma_resv_t* nv_drm_gem_prime_res_obj(struct drm_gem_object *obj)
diff --git a/kernel/nvidia-drm/nvidia-drm-gem.h b/kernel/nvidia-drm/nvidia-drm-gem.h
index 5c9f33d..24576e2 100644
--- a/kernel/nvidia-drm/nvidia-drm-gem.h
+++ b/kernel/nvidia-drm/nvidia-drm-gem.h
@@ -23,6 +23,7 @@
 #ifndef __NVIDIA_DRM_GEM_H__
 #define __NVIDIA_DRM_GEM_H__
 
+#include <linux/version.h>
 #include "nvidia-drm-conftest.h"
 
 #if defined(NV_DRM_AVAILABLE)
@@ -50,8 +51,15 @@ struct nv_drm_gem_object;
 struct nv_drm_gem_object_funcs {
     void (*free)(struct nv_drm_gem_object *nv_gem);
     struct sg_table *(*prime_get_sg_table)(struct nv_drm_gem_object *nv_gem);
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0))
     void *(*prime_vmap)(struct nv_drm_gem_object *nv_gem);
     void (*prime_vunmap)(struct nv_drm_gem_object *nv_gem, void *address);
+#else
+    // Updated vmap/vunmap operations to use struct dma_buf_map instead of raw pointers
+    // See torvalds/linux commits ccc22d41bd9acec58cdc7c3b012e1887aba40af4, 6619ccf1bb1d0ebb071f758111efa83918b216fc
+    int (*prime_vmap)(struct nv_drm_gem_object *nv_gem, struct dma_buf_map *map);
+    void (*prime_vunmap)(struct nv_drm_gem_object *nv_gem, struct dma_buf_map *map);
+#endif
     struct drm_gem_object *(*prime_dup)(struct drm_device *dev,
                                         const struct nv_drm_gem_object *nv_gem_src);
     int (*mmap)(struct nv_drm_gem_object *nv_gem, struct vm_area_struct *vma);
@@ -188,9 +196,17 @@ struct drm_gem_object *nv_drm_gem_prime_import(struct drm_device *dev,
 
 struct sg_table *nv_drm_gem_prime_get_sg_table(struct drm_gem_object *gem);
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0))
 void *nv_drm_gem_prime_vmap(struct drm_gem_object *gem);
 
 void nv_drm_gem_prime_vunmap(struct drm_gem_object *gem, void *address);
+#else
+// Updated vmap/vunmap operations to use struct dma_buf_map instead of raw pointers
+// See torvalds/linux commits ccc22d41bd9acec58cdc7c3b012e1887aba40af4, 6619ccf1bb1d0ebb071f758111efa83918b216fc
+int nv_drm_gem_prime_vmap(struct drm_gem_object *gem, struct dma_buf_map *map);
+
+void nv_drm_gem_prime_vunmap(struct drm_gem_object *gem, struct dma_buf_map *map);
+#endif
 
 #if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ)
 nv_dma_resv_t* nv_drm_gem_prime_res_obj(struct drm_gem_object *obj);
diff --git a/kernel/nvidia-drm/nvidia-drm.Kbuild b/kernel/nvidia-drm/nvidia-drm.Kbuild
index 23ca4ed..8aefa11 100644
--- a/kernel/nvidia-drm/nvidia-drm.Kbuild
+++ b/kernel/nvidia-drm/nvidia-drm.Kbuild
@@ -106,3 +106,11 @@ NV_CONFTEST_TYPE_COMPILE_TESTS += drm_display_mode_has_vrefresh
 NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_master_set_has_int_return_type
 NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_free_object
 NV_CONFTEST_TYPE_COMPILE_TESTS += drm_prime_pages_to_sg_has_drm_device_arg
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_prime_get_sg_table
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_prime_export
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_prime_vmap
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_prime_vunmap
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_atomic_check_atomic_state
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_atomic_enable_atomic_state
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_device_list
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_vm_ops
diff --git a/kernel/nvidia/nv-caps.c b/kernel/nvidia/nv-caps.c
index 90e866f..5cde194 100644
--- a/kernel/nvidia/nv-caps.c
+++ b/kernel/nvidia/nv-caps.c
@@ -37,8 +37,12 @@ MODULE_PARM_DESC(nv_cap_enable_devfs, "Enable (1) or disable (0) nv-caps " \
 
 extern int NVreg_ModifyDeviceFiles;
 
+#if NV_IS_EXPORT_SYMBOL_PRESENT_close_fd
+#include <linux/fdtable.h>
+#else
 /* sys_close() or __close_fd() */
 #include <linux/syscalls.h>
+#endif
 
 #define NV_CAP_DRV_MINOR_COUNT 8192
 
@@ -586,7 +590,9 @@ void NV_API_CALL nv_cap_close_fd(int fd)
  * 2018-04-02 2ca2a09d6215 ("fs: add ksys_close() wrapper; remove in-kernel
  *  calls to sys_close()")
  */
-#if NV_IS_EXPORT_SYMBOL_PRESENT___close_fd
+#if NV_IS_EXPORT_SYMBOL_PRESENT_close_fd
+    close_fd(fd);
+#elif NV_IS_EXPORT_SYMBOL_PRESENT___close_fd
     __close_fd(current->files, fd);
 #else
     sys_close(fd);
diff --git a/kernel/nvidia/nvidia.Kbuild b/kernel/nvidia/nvidia.Kbuild
index 8fc929e..48a98d3 100644
--- a/kernel/nvidia/nvidia.Kbuild
+++ b/kernel/nvidia/nvidia.Kbuild
@@ -173,6 +173,7 @@ NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_tegra_dce_client_ip
 NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_dram_clk_to_mc_clk
 NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_get_dram_num_channels
 NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_tegra_dram_types
+NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_close_fd
 
 NV_CONFTEST_TYPE_COMPILE_TESTS += acpi_op_remove
 NV_CONFTEST_TYPE_COMPILE_TESTS += outer_flush_all

Last edited by loqs (2021-01-13 23:39:27)

Offline

#36 2021-01-14 06:13:13

TheFurryWeeb
Member
Registered: 2020-08-06
Posts: 57

Re: [ERROR] [SOLVED] Custom Linux Kernel Compilation Part 2

loqs wrote:

To me it looks to be identical to the issue you reported in post #30.
About as difficult to fix.

kmap_types patch for 460.27.04

--- a/kernel/common/inc/nv-linux.h
+++ b/kernel/common/inc/nv-linux.h
@@ -117,7 +117,9 @@
 
 #include <linux/moduleparam.h>      /* module_param()                   */
 #include <asm/tlbflush.h>           /* flush_tlb(), flush_tlb_all()     */
+#if defined(NV_ASM_KMAP_TYPES_H_PRESENT)
 #include <asm/kmap_types.h>         /* page table entry lookup          */
+#endif
 
 #include <linux/pci.h>              /* pci_find_class, etc              */
 #include <linux/interrupt.h>        /* tasklets, interrupt helpers      */
diff --git a/kernel/conftest.sh b/kernel/conftest.sh
index 282a911..c2d0fc3 100755
--- a/kernel/conftest.sh
+++ b/kernel/conftest.sh
@@ -159,6 +159,7 @@ test_headers() {
     FILES="$FILES asm/pgtable_types.h"
     FILES="$FILES linux/stringhash.h"
     FILES="$FILES linux/dma-map-ops.h"
+    FILES="$FILES asm/kmap_types.h"
 
     translate_and_preprocess_header_files $FILES
 }

In 460.32.03 the include is not present so no patch is needed,

sys_close -> close_fd again patch for 460.27.04

--- a/kernel/nvidia/nv-caps.c
+++ b/kernel/nvidia/nv-caps.c
@@ -37,8 +37,12 @@ MODULE_PARM_DESC(nv_cap_enable_devfs, "Enable (1) or disable (0) nv-caps " \
 
 extern int NVreg_ModifyDeviceFiles;
 
+#if NV_IS_EXPORT_SYMBOL_PRESENT_close_fd
+#include <linux/fdtable.h>
+#else
 /* sys_close() or __close_fd() */
 #include <linux/syscalls.h>
+#endif
 
 #define NV_CAP_DRV_MINOR_COUNT 8192
 
@@ -586,7 +590,9 @@ void NV_API_CALL nv_cap_close_fd(int fd)
  * 2018-04-02 2ca2a09d6215 ("fs: add ksys_close() wrapper; remove in-kernel
  *  calls to sys_close()")
  */
-#if NV_IS_EXPORT_SYMBOL_PRESENT___close_fd
+#if NV_IS_EXPORT_SYMBOL_PRESENT_close_fd
+    close_fd(fd);
+#elif NV_IS_EXPORT_SYMBOL_PRESENT___close_fd
     __close_fd(current->files, fd);
 #else
     sys_close(fd);
diff --git a/kernel/nvidia/nvidia.Kbuild b/kernel/nvidia/nvidia.Kbuild
index 90579de..c6f3614 100644
--- a/kernel/nvidia/nvidia.Kbuild
+++ b/kernel/nvidia/nvidia.Kbuild
@@ -172,6 +172,7 @@ NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_tegra_dce_client_ip
 NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_dram_clk_to_mc_clk
 NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_get_dram_num_channels
 NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_tegra_dram_types
+NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_close_fd
 
 NV_CONFTEST_TYPE_COMPILE_TESTS += acpi_op_remove
 NV_CONFTEST_TYPE_COMPILE_TESTS += outer_flush_all

Edit:
Full patch for 460.32.03

diff --git a/kernel/conftest.sh b/kernel/conftest.sh
index 87dac2a..2705218 100755
--- a/kernel/conftest.sh
+++ b/kernel/conftest.sh
@@ -1285,12 +1285,12 @@ compile_test() {
                 struct drm_driver drv;
 
                 /* 2013-01-15 89177644a7b6306e6084a89eab7e290f4bfef397 */
-                drv.gem_prime_pin = 0;
+/*                drv.gem_prime_pin = 0;
                 drv.gem_prime_get_sg_table = 0;
                 drv.gem_prime_vmap = 0;
                 drv.gem_prime_vunmap = 0;
                 (void)drm_gem_prime_import;
-                (void)drm_gem_prime_export;
+                (void)drm_gem_prime_export;*/
 
                 /* 2013-10-02 1bb72532ac260a2d3982b40bdd4c936d779d0d16 */
                 (void)drm_dev_alloc;
@@ -2086,6 +2086,42 @@ compile_test() {
             compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_LEGACY_DEV_LIST" "" "types"
         ;;
 
+        drm_driver_has_device_list)
+            # 57bb1ee6034046be70aed33fd6d447bb2b7261fa
+            CODE="
+            #if defined(NV_DRM_DRMP_H_PRESENT)
+            #include <drm/drmP.h>
+            #endif
+
+            #if defined(NV_DRM_DRM_DRV_H_PRESENT)
+            #include <drm/drm_drv.h>
+            #endif
+
+            int conftest_drm_driver_has_device_list(void) {
+                return offsetof(struct drm_driver, device_list);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_DEVICE_LIST" "" "types"
+        ;;
+
+        drm_driver_has_gem_vm_ops)
+            # d693def4fd1c23f1ca5aed1afb9993b3a2069ad2
+            CODE="
+            #if defined(NV_DRM_DRMP_H_PRESENT)
+            #include <drm/drmP.h>
+            #endif
+
+            #if defined(NV_DRM_DRM_DRV_H_PRESENT)
+            #include <drm/drm_drv.h>
+            #endif
+
+            int conftest_drm_driver_has_gem_vm_ops(void) {
+                return offsetof(struct drm_driver, gem_vm_ops);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_VM_OPS" "" "types"
+        ;;
+
         jiffies_to_timespec)
             #
             # Determine if jiffies_to_timespec() is present
@@ -2286,6 +2322,62 @@ compile_test() {
             compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ" "" "types"
         ;;
 
+        drm_driver_has_gem_prime_get_sg_table)
+            # Removed by commit d693def4fd1c23f1ca5aed1afb9993b3a2069ad2
+            CODE="
+            #if defined(NV_DRM_DRMP_H_PRESENT)
+            #include <drm/drmP.h>
+            #endif
+
+            int conftest_drm_driver_has_gem_prime_get_sg_table(void) {
+                return offsetof(struct drm_driver, gem_prime_get_sg_table);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_PRIME_GET_SG_TABLE" "" "types"
+        ;;
+
+        drm_driver_has_gem_prime_export)
+            # Removed by commit d693def4fd1c23f1ca5aed1afb9993b3a2069ad2
+            CODE="
+            #if defined(NV_DRM_DRMP_H_PRESENT)
+            #include <drm/drmP.h>
+            #endif
+
+            int conftest_drm_driver_has_gem_prime_export(void) {
+                return offsetof(struct drm_driver, gem_prime_export);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_PRIME_EXPORT" "" "types"
+        ;;
+
+        drm_driver_has_gem_prime_vmap)
+            # Removed by commit d693def4fd1c23f1ca5aed1afb9993b3a2069ad2
+            CODE="
+            #if defined(NV_DRM_DRMP_H_PRESENT)
+            #include <drm/drmP.h>
+            #endif
+
+            int conftest_drm_driver_has_gem_prime_vmap(void) {
+                return offsetof(struct drm_driver, gem_prime_vmap);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_PRIME_VMAP" "" "types"
+        ;;
+
+        drm_driver_has_gem_prime_vunmap)
+            # Removed by commit d693def4fd1c23f1ca5aed1afb9993b3a2069ad2
+            CODE="
+            #if defined(NV_DRM_DRMP_H_PRESENT)
+            #include <drm/drmP.h>
+            #endif
+
+            int conftest_drm_driver_has_gem_prime_vunmap(void) {
+                return offsetof(struct drm_driver, gem_prime_vunmap);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_PRIME_VUNMAP" "" "types"
+        ;;
+
         drm_crtc_state_has_connectors_changed)
             #
             # Determine if the crtc_state has a 'connectors_changed' field.
@@ -4346,6 +4438,34 @@ compile_test() {
             compile_check_conftest "$CODE" "NV_ITERATE_FD_PRESENT" "" "functions"
         ;;
 
+        drm_atomic_check_atomic_state)
+            # 29b77ad7b9ca8c87152a1a9e8188970fb2a93df4
+            CODE="
+            #include <drm/drm_modeset_helper_vtables.h>
+
+            void drm_atomic_check_atomic_state(struct drm_crtc_helper_funcs * funcs,
+                                               struct drm_crtc *crtc,
+                                               struct drm_atomic_state *state) {
+                funcs->atomic_check(crtc, state);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_ATOMIC_CHECK_ATOMIC_STATE" "" "types"
+        ;;
+
+        drm_atomic_enable_atomic_state)
+            # 351f950db4ab28c321a1bd4b92e4bb03e34c4703
+            CODE="
+            #include <drm/drm_modeset_helper_vtables.h>
+
+            void drm_atomic_enable_atomic_state(struct drm_crtc_helper_funcs * funcs,
+                                                struct drm_crtc *crtc,
+                                                struct drm_atomic_state *state) {
+                funcs->atomic_enable(crtc, state);
+            }"
+
+            compile_check_conftest "$CODE" "NV_DRM_ATOMIC_ENABLE_ATOMIC_STATE" "" "types"
+        ;;
+
         # When adding a new conftest entry, please use the correct format for
         # specifying the relevant upstream Linux kernel commit.
         #
diff --git a/kernel/nvidia-drm/nvidia-drm-crtc.c b/kernel/nvidia-drm/nvidia-drm-crtc.c
index b966bb2..6769004 100644
--- a/kernel/nvidia-drm/nvidia-drm-crtc.c
+++ b/kernel/nvidia-drm/nvidia-drm-crtc.c
@@ -460,8 +460,14 @@ static int head_modeset_config_attach_connector(
  * will be discarded if ->atomic_check() fails.
  */
 static int nv_drm_crtc_atomic_check(struct drm_crtc *crtc,
+#ifndef NV_DRM_ATOMIC_CHECK_ATOMIC_STATE
                                     struct drm_crtc_state *crtc_state)
 {
+#else
+                                    struct drm_atomic_state *state)
+{
+    struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,crtc);
+#endif
     struct nv_drm_crtc_state *nv_crtc_state = to_nv_crtc_state(crtc_state);
     struct NvKmsKapiHeadRequestedConfig *req_config =
         &nv_crtc_state->req_config;
@@ -532,7 +538,11 @@ static void nv_drm_crtc_disable(struct drm_crtc *crtc)
 
 #ifdef NV_DRM_CRTC_HELPER_FUNCS_HAS_ATOMIC_ENABLE
 static void nv_drm_crtc_atomic_enable(struct drm_crtc *crtc,
+#ifndef NV_DRM_ATOMIC_ENABLE_ATOMIC_STATE
                                       struct drm_crtc_state *old_crtc_state)
+#else
+                                      struct drm_atomic_state *state)
+#endif
 {
 
 }
diff --git a/kernel/nvidia-drm/nvidia-drm-drv.c b/kernel/nvidia-drm/nvidia-drm-drv.c
index ebfb5cd..5db6f6f 100644
--- a/kernel/nvidia-drm/nvidia-drm-drv.c
+++ b/kernel/nvidia-drm/nvidia-drm-drv.c
@@ -755,12 +755,20 @@ static struct drm_driver nv_drm_driver = {
 
     .prime_handle_to_fd     = drm_gem_prime_handle_to_fd,
     .prime_fd_to_handle     = drm_gem_prime_fd_to_handle,
+#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_EXPORT)
     .gem_prime_export       = drm_gem_prime_export,
+#endif
     .gem_prime_import       = nv_drm_gem_prime_import,
+#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_GET_SG_TABLE)
     .gem_prime_get_sg_table = nv_drm_gem_prime_get_sg_table,
+#endif
     .gem_prime_import_sg_table = nv_drm_gem_prime_import_sg_table,
+#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_VMAP)
     .gem_prime_vmap         = nv_drm_gem_prime_vmap,
+#endif
+#if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_VUNMAP)
     .gem_prime_vunmap       = nv_drm_gem_prime_vunmap,
+#endif
 
 #if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ)
     .gem_prime_res_obj      = nv_drm_gem_prime_res_obj,
@@ -786,10 +794,12 @@ static struct drm_driver nv_drm_driver = {
 
 #if defined(NV_DRM_DRIVER_HAS_LEGACY_DEV_LIST)
     .legacy_dev_list        = LIST_HEAD_INIT(nv_drm_driver.legacy_dev_list),
-#else
+#elif defined(NV_DRM_DRIVER_HAS_DEVICE_LIST)
     .device_list            = LIST_HEAD_INIT(nv_drm_driver.device_list),
 #endif
+#if defined(NV_DRM_DRIVER_HAS_GEM_VM_OPS)
     .gem_vm_ops             = &nv_drm_gem_vma_ops,
+#endif
 };
 
 
diff --git a/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c b/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c
index e554adc..4aa082b 100644
--- a/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c
+++ b/kernel/nvidia-drm/nvidia-drm-gem-user-memory.c
@@ -20,6 +20,7 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
+#include <linux/version.h>
 #include "nvidia-drm-conftest.h"
 
 #if defined(NV_DRM_AVAILABLE)
@@ -58,6 +59,7 @@ static struct sg_table *__nv_drm_gem_user_memory_prime_get_sg_table(
                                     nv_user_memory->pages_count);
 }
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0))
 static void *__nv_drm_gem_user_memory_prime_vmap(
     struct nv_drm_gem_object *nv_gem)
 {
@@ -73,6 +75,28 @@ static void __nv_drm_gem_user_memory_prime_vunmap(
 {
     nv_drm_vunmap(address);
 }
+#else
+// Updated vmap/vunmap operations to use struct dma_buf_map instead of raw pointers
+// See torvalds/linux commits ccc22d41bd9acec58cdc7c3b012e1887aba40af4, 6619ccf1bb1d0ebb071f758111efa83918b216fc
+static int __nv_drm_gem_user_memory_prime_vmap(
+    struct nv_drm_gem_object *nv_gem,
+    struct dma_buf_map *map)
+{
+    struct nv_drm_gem_user_memory *nv_user_memory = to_nv_user_memory(nv_gem);
+
+    map->vaddr = nv_drm_vmap(nv_user_memory->pages,
+                           nv_user_memory->pages_count);
+    map->is_iomem = false;
+    return 0;
+}
+
+static void __nv_drm_gem_user_memory_prime_vunmap(
+    struct nv_drm_gem_object *gem,
+    struct dma_buf_map *map)
+{
+    nv_drm_vunmap(map->vaddr);
+}
+#endif
 
 static int __nv_drm_gem_user_memory_mmap(struct nv_drm_gem_object *nv_gem,
                                          struct vm_area_struct *vma)
diff --git a/kernel/nvidia-drm/nvidia-drm-gem.c b/kernel/nvidia-drm/nvidia-drm-gem.c
index a6b54f0..ca45362 100644
--- a/kernel/nvidia-drm/nvidia-drm-gem.c
+++ b/kernel/nvidia-drm/nvidia-drm-gem.c
@@ -20,6 +20,7 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
+#include <linux/version.h>
 #include "nvidia-drm-conftest.h"
 
 #if defined(NV_DRM_AVAILABLE)
@@ -67,6 +68,13 @@ void nv_drm_gem_free(struct drm_gem_object *gem)
 static struct drm_gem_object_funcs nv_drm_gem_funcs = {
     .free = nv_drm_gem_free,
     .get_sg_table = nv_drm_gem_prime_get_sg_table,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0))
+    // New functions moved from drm_driver because of torvalds/linux commit d693def4fd1c23f1ca5aed1afb9993b3a2069ad2
+    .export       = drm_gem_prime_export,
+    .vmap         = nv_drm_gem_prime_vmap,
+    .vunmap       = nv_drm_gem_prime_vunmap,
+    .vm_ops       = &nv_drm_gem_vma_ops,
+#endif
 };
 #endif
 
@@ -141,6 +149,7 @@ struct sg_table *nv_drm_gem_prime_get_sg_table(struct drm_gem_object *gem)
     return ERR_PTR(-ENOTSUPP);
 }
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0))
 void *nv_drm_gem_prime_vmap(struct drm_gem_object *gem)
 {
     struct nv_drm_gem_object *nv_gem = to_nv_gem_object(gem);
@@ -160,6 +169,29 @@ void nv_drm_gem_prime_vunmap(struct drm_gem_object *gem, void *address)
         nv_gem->ops->prime_vunmap(nv_gem, address);
     }
 }
+#else
+// Updated vmap/vunmap operations to use struct dma_buf_map instead of raw pointers
+// See torvalds/linux commits ccc22d41bd9acec58cdc7c3b012e1887aba40af4, 6619ccf1bb1d0ebb071f758111efa83918b216fc
+int nv_drm_gem_prime_vmap(struct drm_gem_object *gem, struct dma_buf_map *map)
+{
+    struct nv_drm_gem_object *nv_gem = to_nv_gem_object(gem);
+
+    if (nv_gem->ops->prime_vmap != NULL) {
+        return nv_gem->ops->prime_vmap(nv_gem, map);
+    }
+
+    return -ENOTSUPP;
+}
+
+void nv_drm_gem_prime_vunmap(struct drm_gem_object *gem, struct dma_buf_map *map)
+{
+    struct nv_drm_gem_object *nv_gem = to_nv_gem_object(gem);
+
+    if (nv_gem->ops->prime_vunmap != NULL) {
+        nv_gem->ops->prime_vunmap(nv_gem, map);
+    }
+}
+#endif
 
 #if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ)
 nv_dma_resv_t* nv_drm_gem_prime_res_obj(struct drm_gem_object *obj)
diff --git a/kernel/nvidia-drm/nvidia-drm-gem.h b/kernel/nvidia-drm/nvidia-drm-gem.h
index 5c9f33d..24576e2 100644
--- a/kernel/nvidia-drm/nvidia-drm-gem.h
+++ b/kernel/nvidia-drm/nvidia-drm-gem.h
@@ -23,6 +23,7 @@
 #ifndef __NVIDIA_DRM_GEM_H__
 #define __NVIDIA_DRM_GEM_H__
 
+#include <linux/version.h>
 #include "nvidia-drm-conftest.h"
 
 #if defined(NV_DRM_AVAILABLE)
@@ -50,8 +51,15 @@ struct nv_drm_gem_object;
 struct nv_drm_gem_object_funcs {
     void (*free)(struct nv_drm_gem_object *nv_gem);
     struct sg_table *(*prime_get_sg_table)(struct nv_drm_gem_object *nv_gem);
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0))
     void *(*prime_vmap)(struct nv_drm_gem_object *nv_gem);
     void (*prime_vunmap)(struct nv_drm_gem_object *nv_gem, void *address);
+#else
+    // Updated vmap/vunmap operations to use struct dma_buf_map instead of raw pointers
+    // See torvalds/linux commits ccc22d41bd9acec58cdc7c3b012e1887aba40af4, 6619ccf1bb1d0ebb071f758111efa83918b216fc
+    int (*prime_vmap)(struct nv_drm_gem_object *nv_gem, struct dma_buf_map *map);
+    void (*prime_vunmap)(struct nv_drm_gem_object *nv_gem, struct dma_buf_map *map);
+#endif
     struct drm_gem_object *(*prime_dup)(struct drm_device *dev,
                                         const struct nv_drm_gem_object *nv_gem_src);
     int (*mmap)(struct nv_drm_gem_object *nv_gem, struct vm_area_struct *vma);
@@ -188,9 +196,17 @@ struct drm_gem_object *nv_drm_gem_prime_import(struct drm_device *dev,
 
 struct sg_table *nv_drm_gem_prime_get_sg_table(struct drm_gem_object *gem);
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0))
 void *nv_drm_gem_prime_vmap(struct drm_gem_object *gem);
 
 void nv_drm_gem_prime_vunmap(struct drm_gem_object *gem, void *address);
+#else
+// Updated vmap/vunmap operations to use struct dma_buf_map instead of raw pointers
+// See torvalds/linux commits ccc22d41bd9acec58cdc7c3b012e1887aba40af4, 6619ccf1bb1d0ebb071f758111efa83918b216fc
+int nv_drm_gem_prime_vmap(struct drm_gem_object *gem, struct dma_buf_map *map);
+
+void nv_drm_gem_prime_vunmap(struct drm_gem_object *gem, struct dma_buf_map *map);
+#endif
 
 #if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_RES_OBJ)
 nv_dma_resv_t* nv_drm_gem_prime_res_obj(struct drm_gem_object *obj);
diff --git a/kernel/nvidia-drm/nvidia-drm.Kbuild b/kernel/nvidia-drm/nvidia-drm.Kbuild
index 23ca4ed..8aefa11 100644
--- a/kernel/nvidia-drm/nvidia-drm.Kbuild
+++ b/kernel/nvidia-drm/nvidia-drm.Kbuild
@@ -106,3 +106,11 @@ NV_CONFTEST_TYPE_COMPILE_TESTS += drm_display_mode_has_vrefresh
 NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_master_set_has_int_return_type
 NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_free_object
 NV_CONFTEST_TYPE_COMPILE_TESTS += drm_prime_pages_to_sg_has_drm_device_arg
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_prime_get_sg_table
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_prime_export
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_prime_vmap
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_prime_vunmap
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_atomic_check_atomic_state
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_atomic_enable_atomic_state
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_device_list
+NV_CONFTEST_TYPE_COMPILE_TESTS += drm_driver_has_gem_vm_ops
diff --git a/kernel/nvidia/nv-caps.c b/kernel/nvidia/nv-caps.c
index 90e866f..5cde194 100644
--- a/kernel/nvidia/nv-caps.c
+++ b/kernel/nvidia/nv-caps.c
@@ -37,8 +37,12 @@ MODULE_PARM_DESC(nv_cap_enable_devfs, "Enable (1) or disable (0) nv-caps " \
 
 extern int NVreg_ModifyDeviceFiles;
 
+#if NV_IS_EXPORT_SYMBOL_PRESENT_close_fd
+#include <linux/fdtable.h>
+#else
 /* sys_close() or __close_fd() */
 #include <linux/syscalls.h>
+#endif
 
 #define NV_CAP_DRV_MINOR_COUNT 8192
 
@@ -586,7 +590,9 @@ void NV_API_CALL nv_cap_close_fd(int fd)
  * 2018-04-02 2ca2a09d6215 ("fs: add ksys_close() wrapper; remove in-kernel
  *  calls to sys_close()")
  */
-#if NV_IS_EXPORT_SYMBOL_PRESENT___close_fd
+#if NV_IS_EXPORT_SYMBOL_PRESENT_close_fd
+    close_fd(fd);
+#elif NV_IS_EXPORT_SYMBOL_PRESENT___close_fd
     __close_fd(current->files, fd);
 #else
     sys_close(fd);
diff --git a/kernel/nvidia/nvidia.Kbuild b/kernel/nvidia/nvidia.Kbuild
index 8fc929e..48a98d3 100644
--- a/kernel/nvidia/nvidia.Kbuild
+++ b/kernel/nvidia/nvidia.Kbuild
@@ -173,6 +173,7 @@ NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_tegra_dce_client_ip
 NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_dram_clk_to_mc_clk
 NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_get_dram_num_channels
 NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_tegra_dram_types
+NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_close_fd
 
 NV_CONFTEST_TYPE_COMPILE_TESTS += acpi_op_remove
 NV_CONFTEST_TYPE_COMPILE_TESTS += outer_flush_all

And what should I patch with this? The driver, the kernel or both? And what is the command for properly patching them?


A computer and Linux nerd, an avid 2D platformer and RPG gamer and a furry combined into one person.

I hope I can help you out with your Arch issues and get myself helped out, as well.

Offline

#37 2021-01-14 06:26:51

loqs
Member
Registered: 2014-03-06
Posts: 13,005

Re: [ERROR] [SOLVED] Custom Linux Kernel Compilation Part 2

TheFurryWeeb wrote:
loqs wrote:

Full patch for 460.32.03

And what should I patch with this? The driver, the kernel or both? And what is the command for properly patching them?

Why would you think it applies to anything other than the nvidia driver when I stated it was for 460.32.03?  You could also have compared the context with the kernel tree and nvidia driver to determine which it could apply to.

See https://github.com/archlinux/svntogit-p … 6057b32c32 as an example for nvidia-dkms.

Last edited by loqs (2021-01-14 06:27:15)

Offline

#38 2021-01-14 08:52:13

TheFurryWeeb
Member
Registered: 2020-08-06
Posts: 57

Re: [ERROR] [SOLVED] Custom Linux Kernel Compilation Part 2

loqs wrote:
TheFurryWeeb wrote:
loqs wrote:

Full patch for 460.32.03

And what should I patch with this? The driver, the kernel or both? And what is the command for properly patching them?

Why would you think it applies to anything other than the nvidia driver when I stated it was for 460.32.03?  You could also have compared the context with the kernel tree and nvidia driver to determine which it could apply to.

See https://github.com/archlinux/svntogit-p … 6057b32c32 as an example for nvidia-dkms.

Thank you, but what is the correct syntax for the patch command?

patch -p1 /path/to/patchfile

OR

patch -Np1 > /path/to/patchfile

A computer and Linux nerd, an avid 2D platformer and RPG gamer and a furry combined into one person.

I hope I can help you out with your Arch issues and get myself helped out, as well.

Offline

#39 2021-01-14 09:07:21

seth
Member
Registered: 2012-09-03
Posts: 18,979

Re: [ERROR] [SOLVED] Custom Linux Kernel Compilation Part 2

patch -Np1 > /path/to/patchfile

Where did you get that nonsense from?

loqs linked a pattern on how to add the patch to the PKGBUILD, just follow that.

Online

#40 2021-01-15 11:59:59

TheFurryWeeb
Member
Registered: 2020-08-06
Posts: 57

Re: [ERROR] [SOLVED] Custom Linux Kernel Compilation Part 2

seth wrote:

patch -Np1 > /path/to/patchfile

Where did you get that nonsense from?

loqs linked a pattern on how to add the patch to the PKGBUILD, just follow that.

From the Linux Kernel Documantation.

But now, I've extracted the driver sources and I've patched them, how can I install the patched driver? Or should I start from the beginning and you would show me how to fix the PKGBUILD issues (makepkg can't extract the .run file and it can't detect that I added the a copy-pasted patch command to the PKGBUILD file that points to the downloaded patch files)?

The worst thing is that I have to do this if I would like to use Syscall User Dispatch. Simply downloading the binaries with pacman gives me the same DKMS error message as before because currently, DKMS modules are incompatible with the 5.11 kernel.


A computer and Linux nerd, an avid 2D platformer and RPG gamer and a furry combined into one person.

I hope I can help you out with your Arch issues and get myself helped out, as well.

Offline

#41 2021-01-15 14:39:18

loqs
Member
Registered: 2014-03-06
Posts: 13,005

Re: [ERROR] [SOLVED] Custom Linux Kernel Compilation Part 2

TheFurryWeeb wrote:
seth wrote:

patch -Np1 > /path/to/patchfile

Where did you get that nonsense from?

loqs linked a pattern on how to add the patch to the PKGBUILD, just follow that.

From the Linux Kernel Documantation.

Please reread https://www.kernel.org/doc/html/latest/ … tches.html it does not include the command you posted or anything equivalent to it as you incorrectly copied the command.

TheFurryWeeb wrote:

But now, I've extracted the driver sources and I've patched them, how can I install the patched driver?

PKGBUILDs are just shell scripts you could follow the steps the PKGBUILD uses to install the nvidia driver.

TheFurryWeeb wrote:

Or should I start from the beginning and you would show me how to fix the PKGBUILD issues (makepkg can't extract the .run file and it can't detect that I added the a copy-pasted patch command to the PKGBUILD file that points to the downloaded patch files)?

Start a new thread on the segfault.

TheFurryWeeb wrote:

The worst thing is that I have to do this if I would like to use Syscall User Dispatch. Simply downloading the binaries with pacman gives me the same DKMS error message as before because currently, DKMS modules are incompatible with the 5.11 kernel.

The DKMS package will be updated when upstream updates it or Arch packages 5.11.

Offline

#42 2021-01-19 10:07:03

TheFurryWeeb
Member
Registered: 2020-08-06
Posts: 57

Re: [ERROR] [SOLVED] Custom Linux Kernel Compilation Part 2

Issue: SOLVED

Refer to this thread as the solution:

https://bbs.archlinux.org/viewtopic.php?id=262802


A computer and Linux nerd, an avid 2D platformer and RPG gamer and a furry combined into one person.

I hope I can help you out with your Arch issues and get myself helped out, as well.

Offline

#43 2021-01-29 20:25:05

paulywog
Member
Registered: 2021-01-29
Posts: 1

Re: [ERROR] [SOLVED] Custom Linux Kernel Compilation Part 2

loqs wrote:

Full patch for 460.32.03

Thanks for this, I needed one more patch to nvidia-drm-drv.c because of https://lists.freedesktop.org/archives/ … 52622.html currently on linux-next. Maybe it helps someone.

The previous part of the patch https://lists.freedesktop.org/archives/ … 52621.html leads me to believe that a NULL here is equivalent to drm_gem_dumb_destroy anyway.

Seems to work, YMMV.

@@ -815,7 +825,6 @@ static void nv_drm_update_drm_driver_features(void)
 
     nv_drm_driver.dumb_create      = nv_drm_dumb_create;
     nv_drm_driver.dumb_map_offset  = nv_drm_dumb_map_offset;
-    nv_drm_driver.dumb_destroy     = drm_gem_dumb_destroy;
 #endif /* NV_DRM_ATOMIC_MODESET_AVAILABLE */
 }
 

Offline

Board footer

Powered by FluxBB