Debian nvidia-kernel-dkms_550.163.01-3 patch to support kernel 6.17

Started by Teriarch, 2025/10/03, 16:44:04

Previous topic - Next topic

Teriarch

The following patch customizes the current Debian Nvidia modules to support kernel 6.17, just in
case someone is working on it (maybe towo):


diff -ur a/usr/src/nvidia-current-550.163.01/nvidia-drm/nvidia-drm-drv.c b/usr/src/nvidia-current-550.163.01/nvidia-drm/nvidia-drm-drv.c
--- a/usr/src/nvidia-current-550.163.01/nvidia-drm/nvidia-drm-drv.c     2025-08-28 09:13:46.000000000 +0200
+++ b/usr/src/nvidia-current-550.163.01/nvidia-drm/nvidia-drm-drv.c     2025-10-03 12:33:43.000000000 +0200
@@ -189,24 +189,38 @@
     struct drm_device *dev,
     struct drm_file *file,
     #if defined(NV_DRM_HELPER_MODE_FILL_FB_STRUCT_HAS_CONST_MODE_CMD_ARG)
+    #if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 17, 0)
+    const struct drm_format_info *info,
+    #endif
     const struct drm_mode_fb_cmd2 *cmd
     #else
+    #if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 17, 0)
+    struct drm_format_info *info,
+    #endif
     struct drm_mode_fb_cmd2 *cmd
     #endif
)
{
     struct drm_mode_fb_cmd2 local_cmd;
+    #if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 17, 0)
+    struct drm_format_info local_info;
+    #endif
     struct drm_framebuffer *fb;
-
+    #if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 17, 0)
+    local_info = *info;
+    #endif
     local_cmd = *cmd;
-
     fb = nv_drm_internal_framebuffer_create(
             dev,
             file,
+            #if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 17, 0)
+           &local_info,
+            #endif
             &local_cmd);

     #if !defined(NV_DRM_HELPER_MODE_FILL_FB_STRUCT_HAS_CONST_MODE_CMD_ARG)
     *cmd = local_cmd;
+    *info = local_info;
     #endif

     return fb;
diff -ur a/usr/src/nvidia-current-550.163.01/nvidia-drm/nvidia-drm-fb.c b/usr/src/nvidia-current-550.163.01/nvidia-drm/nvidia-drm-fb.c
--- a/usr/src/nvidia-current-550.163.01/nvidia-drm/nvidia-drm-fb.c      2025-04-08 14:08:08.000000000 +0200
+++ b/usr/src/nvidia-current-550.163.01/nvidia-drm/nvidia-drm-fb.c      2025-10-03 12:34:20.000000000 +0200
@@ -24,6 +24,8 @@

#if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE)

+#include <linux/version.h>
+
#include "nvidia-drm-priv.h"
#include "nvidia-drm-ioctl.h"
#include "nvidia-drm-fb.h"
@@ -33,6 +35,9 @@
#include "nvidia-drm-format.h"

#include <drm/drm_crtc_helper.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 17, 0)
+#include <drm/drm_fourcc.h>
+#endif

static void __nv_drm_framebuffer_free(struct nv_drm_framebuffer *nv_fb)
{
@@ -84,7 +89,11 @@
static struct nv_drm_framebuffer *nv_drm_framebuffer_alloc(
     struct drm_device *dev,
     struct drm_file *file,
+    #if defined(NV_DRM_HELPER_MODE_FILL_FB_STRUCT_HAS_CONST_MODE_CMD_ARG)
+    const struct drm_mode_fb_cmd2 *cmd)
+    #else
     struct drm_mode_fb_cmd2 *cmd)
+    #endif
{
     struct nv_drm_device *nv_dev = to_nv_device(dev);
     struct nv_drm_framebuffer *nv_fb;
@@ -203,10 +212,27 @@
     return -EINVAL;
}

+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 17, 0)
struct drm_framebuffer *nv_drm_internal_framebuffer_create(
     struct drm_device *dev,
     struct drm_file *file,
+    #if defined(NV_DRM_HELPER_MODE_FILL_FB_STRUCT_HAS_CONST_MODE_CMD_ARG)
+    const struct drm_mode_fb_cmd2 *cmd)
+    #else
     struct drm_mode_fb_cmd2 *cmd)
+    #endif
+#else
+struct drm_framebuffer *nv_drm_internal_framebuffer_create(
+    struct drm_device *dev,
+    struct drm_file *file,
+    #if defined(NV_DRM_HELPER_MODE_FILL_FB_STRUCT_HAS_CONST_MODE_CMD_ARG)
+    const struct drm_format_info *info,
+    const struct drm_mode_fb_cmd2 *cmd)
+    #else
+    struct drm_format_info *info,
+    struct drm_mode_fb_cmd2 *cmd)
+    #endif
+#endif
{
     struct nv_drm_device *nv_dev = to_nv_device(dev);
     struct nv_drm_framebuffer *nv_fb;
@@ -254,12 +280,25 @@

     /* Fill out framebuffer metadata from the userspace fb creation request */

+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 17, 0)
+    drm_helper_mode_fill_fb_struct(
+        dev,
+        &nv_fb->base,
+        cmd);
+#else
+    if (!info) {
+        u64 modifier = (cmd->flags & DRM_MODE_FB_MODIFIERS) ?
+                       cmd->modifier[0] : DRM_FORMAT_MOD_INVALID;
+        info = drm_get_format_info(dev, cmd->pixel_format, modifier);
+    }
     drm_helper_mode_fill_fb_struct(
         #if defined(NV_DRM_HELPER_MODE_FILL_FB_STRUCT_HAS_DEV_ARG)
         dev,
         #endif
         &nv_fb->base,
+       info,
         cmd);
+#endif

     /*
      * Finish up FB initialization by creating the backing NVKMS surface and
diff -ur a/usr/src/nvidia-current-550.163.01/nvidia-drm/nvidia-drm-fb.h b/usr/src/nvidia-current-550.163.01/nvidia-drm/nvidia-drm-fb.h
--- a/usr/src/nvidia-current-550.163.01/nvidia-drm/nvidia-drm-fb.h      2025-04-08 14:08:06.000000000 +0200
+++ b/usr/src/nvidia-current-550.163.01/nvidia-drm/nvidia-drm-fb.h      2025-10-03 12:34:47.000000000 +0200
@@ -23,6 +23,7 @@
#ifndef __NVIDIA_DRM_FB_H__
#define __NVIDIA_DRM_FB_H__

+#include <linux/version.h>
#include "nvidia-drm-conftest.h"

#if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE)
@@ -56,10 +57,27 @@
     return container_of(fb, struct nv_drm_framebuffer, base);
}

+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 17, 0)
struct drm_framebuffer *nv_drm_internal_framebuffer_create(
     struct drm_device *dev,
     struct drm_file *file,
+    #if defined(NV_DRM_HELPER_MODE_FILL_FB_STRUCT_HAS_CONST_MODE_CMD_ARG)
+    const struct drm_mode_fb_cmd2 *cmd);
+    #else
     struct drm_mode_fb_cmd2 *cmd);
+    #endif
+#else
+struct drm_framebuffer *nv_drm_internal_framebuffer_create(
+    struct drm_device *dev,
+    struct drm_file *file,
+    #if defined(NV_DRM_HELPER_MODE_FILL_FB_STRUCT_HAS_CONST_MODE_CMD_ARG)
+    const struct drm_format_info *info,
+    const struct drm_mode_fb_cmd2 *cmd);
+    #else
+    struct drm_format_info *info,
+    struct drm_mode_fb_cmd2 *cmd);
+    #endif
+#endif

#endif /* NV_DRM_ATOMIC_MODESET_AVAILABLE */


michaa7

In case such a patch is also available for nvidia-470 I really would like the siduction kernel would still support the nvidia-470 driver as the nouveau driver here is as POS (causes long temporary freezes and corrupted rendering again and again) !

I really, really would appreciate it very much.
Ok, you can't code, but you still might be able to write a bug report for Debian's sake

Teriarch

May I ask, which kernel the nvidia-kernel-dkms package is running on? I suppose you
mean the Debian nvidia-kernel-dkms (470.256.02-2) bullseye version. But without modification
that version cannot run on a recent 6.16 kernel, let alone a 6.17 one. Can you clarify?

michaa7

Quote from: Teriarch on 2025/10/05, 22:25:11
May I ask, which kernel the nvidia-kernel-dkms package is running on?
Currently none as I have to use nouveau with currrent kernels.

From what I remember last working kernel waqs 6.14.xxx. The module build failed on 6.15 with nvidia-tesla-470-kernel-dkms_470.256.02-7.siduction.4 . But to me it seemed that  nvidia-tesla-470-kernel-dkms_470.256.02-7.siduction.4.1 was working on 6.15, but I could not go back. I may be wrong.

Anyway, it would be great to get official siduction packages working with nvidia-tesla-470 *if technically still possible*. If not, I have to throw out my nvidia card and find an other solution als there are way to many rendering issues with the nouveau driver.

Ok, you can't code, but you still might be able to write a bug report for Debian's sake

Teriarch

Now I remember, they gave it another go in June. Since then the changes required to support the
new kernel, though doable, are massive. In the meantime kernel apis changed their number of
arguments and types. Unless someone already considered the changes worth the effort you are
out of luck. And newer nvidia driver versions do not support your card, I suppose? 

towo

I have uploaded nvidia-470 to our fixes repo.

It builds (on my system) against 6.16 and 6.17 and should build against 6.15, since that suppurt was added by debian.
Besides the build i can't test anything other.

Ich gehe nicht zum Karneval, ich verleihe nur manchmal mein Gesicht.

michaa7

Thanks towo!!!

Besides installing nvidia-tesla-470-driver, do I need to do something else to get rid of the nouveau driver, blacklist or whatever? I will, as usual, report on success or not.
Ok, you can't code, but you still might be able to write a bug report for Debian's sake

towo

Ich gehe nicht zum Karneval, ich verleihe nur manchmal mein Gesicht.

towo

Nvidia-550 is now in fixes repo too, added the patch for kernel 6.17.
Ich gehe nicht zum Karneval, ich verleihe nur manchmal mein Gesicht.

michaa7

Quote from: towo on 2025/10/06, 21:06:23
...
Besides the build i can't test anything other.

The nvidia-tesla-470-modul builds just fine and boots to X in both pure Debian 6.16.9-xx and Siduction 6.16.11-1.siduction kernel.

Thank you again, towo, good work. It's very appreciated!

Danke, towo!
Ok, you can't code, but you still might be able to write a bug report for Debian's sake

Geier0815

Maybe it's only me, but the 470 builds not against 6.15

Quotegcc-14 (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44

does not match the compiler used here:

gcc (Debian 15.2.0-4) 15.2.0

grep -i gcc config-6.16.11-1-siduction-amd64
shows that the 6.16 is build with gcc-15 so if I remove the older kernel it should build.
Wenn Windows die Lösung ist...
kann ich dann bitte das Problem zurück haben?

Geier0815

Ok, it wasn't that simple. I had to remove the nvidia kernel-dkms first and then purge the 6.15 kernel. Otherwise the kernel purge failled because kernel-dkms does not work...
Sledgehammer approach, but after re-install the kernel-dkms my system is up and running again.
Wenn Windows die Lösung ist...
kann ich dann bitte das Problem zurück haben?

michaa7

Ok, you can't code, but you still might be able to write a bug report for Debian's sake

michaa7

And only to let know other nvidia-470 users, the modul builts fine with kernel 6.17.2-1-siduction-amd64, too!

Thanks towo.
Ok, you can't code, but you still might be able to write a bug report for Debian's sake