Thanks Jonas!

Best wishes,

   Julian

On Tue, May 12, 2026 at 02:16:04PM +0200, Jonas Andradas wrote:
> Hi Julian, 
> please find attached the patch that was created leveraging Gemini instead.  It
> addresses the same conflicts, but using slightly different approach.  Adding
> here just in case it's useful, not necesssarily as a production-ready patch.
> 
> Thanks,
> Jonas.
> On Mon, May 11, 2026 at 11:31 PM Julian Gilbey <[email protected]> wrote:
> 
>   Hi Jonás,
> 
>   Many thanks for this!
> 
>   Best wishes,
> 
>      Julian
> 
>   On Mon, May 11, 2026 at 07:38:00PM +0200, Jonas Andradas wrote:
>   > Hi Julian, 
>   > Please find attached the "consolidated" patch as "final-patch.patch) (I 
> had
>   3-4
>   > which I merged into one), in case it is useful. As I mentioned, I used
>   Claude
>   > Code to support this process, and iterated several times until a working
>   patch
>   > was produced.  (I also did the same using Gemini, but Gemini's patch 
> seems a
>   > little bit more messy, although it also "works" (e.g. the module 
> compiles). 
>   I
>   > can share the patch produced with Gemini as well for reference when I'm 
> back
>   > home, although the one with Claude seemed the cleanest.)
>   >
>   > Thanks,
>   > Jonas.
>   >
>   > Jonás Andradas
>   >
>   > GPG Fingerprint:  678F 7BD0 83C3 28CE 9E8F
>   >                            3F7F 4D87 9996 E0C6 9372
>   > On Sun, May 10, 2026 at 8:17 AM Julian Gilbey <[email protected]> wrote:
>   >
>   >   Dear Jonas,
>   >
>   >   Thanks for this tantalising message!
>   >
>   >   Until the maintainer is able to provide a "proper" patch, would you be
>   >   able to share your patch?  The maintainer might well then be able to
>   >   check it and either approve or improve on it.
>   >
>   >   Best wishes,
>   >
>   >      Julian
>   >
>   >   On Fri, May 08, 2026 at 08:50:33AM +0200, Jonas Andradas wrote:
>   >   > Package: nvidia-kernel-dkms
>   >   > Version: 550.163.01-5
>   >   > Followup-For: Bug #1135362
>   >   > X-Debbugs-Cc: [email protected], [email protected]
>   >   > User: [email protected]
>   >   > Usertags: amd64
>   >   > Control: tags -1 ftbfs
>   >   >
>   >   > Dear Maintainer,
>   >   >
>   >   > I am experiencing this as well in my Debian sid system. I had a 
> similar
>   >   issue a
>   >   > couple of weeks ago in a Proxmox host (running Debian trixie), as
>   Proxmox
>   >   > provides its own kernel and it was bumped to version 7.  Leveraging AI
>   >   (Gemini
>   >   > and Claude) I managed to obtain patches for the nvidia-kernel-dkms
>   package
>   >   in
>   >   > trixie, so that it would compile for Proxmox's kernel 7. These compile
>   and I
>   >   > get the functionality, so for me it was "good enough" for my homelab,
>   but I
>   >   > would not be so bold as to presume they are the best patch possible. 
> If
>   >   these
>   >   > patches can be useful to see the changes that were needed to make this
>   work,
>   >   > such as the ones below, I could upload the file under debian/patches
>   that
>   >   > applied to the trixie package allowed me to built it for Proxmox's
>   kernel 7:
>   >   >
>   >   >      - conftest.sh: detect NV_VM_AREA_STRUCT_HAS___VM_FLAGS, absence 
> of
>   >   > dma_map_ops.map_resource, void return of dma_fence_signal, and
>   >   > drm_mode_config_funcs.fb_create format_info argument
>   >   >      - nv-mm.h: handle vma->vm_flags cast for kernels without 
> __vm_flags
>   >   >      - nv-mmap.c: wrap VMA_LOCK_OFFSET and __is_vma_write_locked for
>   1-arg
>   >   form
>   >   >      - nv-time.h: compat shim for removed in_irq() macro
>   >   >      - nv-dma.c: guard dma_map_ops.map_resource access
>   >   >      - header-presence-tests.mk: add drm/drm_print.h detection
>   >   >      - nvidia-drm-priv.h: include drm_print.h for
>   >   DRM_ERROR/DRM_INFO/DRM_DEBUG
>   >   >      - nvidia-dma-fence-helper.h: handle void dma_fence_signal return
>   type
>   >   >      - nvidia-drm-helper.h: use for_each_new_*_in_state iterators
>   >   >      - nvidia-drm-drv.c, nvidia-drm-fb.c: handle fb_create format_info
>   arg
>   >   >
>   >   >
>   >   > Thanks,
>   >   > Jonas.
> 
> --
> Jonás Andradas
> 
> GPG Fingerprint:  678F 7BD0 83C3 28CE 9E8F
>                            3F7F 4D87 9996 E0C6 9372

> Index: kernel/common/inc/nv-timer.h
> ===================================================================
> --- kernel.orig/common/inc/nv-timer.h
> +++ kernel/common/inc/nv-timer.h
> @@ -24,6 +24,7 @@
>  
>  #include <linux/timer.h>
>  #include <linux/kernel.h> // For container_of
> +#include <linux/version.h>
>  
>  #include "conftest.h"
>  
> @@ -65,7 +66,7 @@ static inline void nv_timer_setup(struct
>  
>  static inline void nv_timer_delete_sync(struct timer_list *timer)
>  {
> -#if !defined(NV_BSD) && NV_IS_EXPORT_SYMBOL_PRESENT_timer_delete_sync
> +#if !defined(NV_BSD) && 
> (defined(NV_IS_EXPORT_SYMBOL_PRESENT_timer_delete_sync) || LINUX_VERSION_CODE 
> >= KERNEL_VERSION(6, 12, 0))
>      timer_delete_sync(timer);
>  #else
>      del_timer_sync(timer);
> Index: kernel/nvidia-drm/nvidia-dma-fence-helper.h
> ===================================================================
> --- kernel.orig/nvidia-drm/nvidia-dma-fence-helper.h
> +++ kernel/nvidia-drm/nvidia-dma-fence-helper.h
> @@ -97,7 +97,8 @@ static inline int nv_dma_fence_signal(nv
>  #if defined(NV_LINUX_FENCE_H_PRESENT)
>      return fence_signal(fence);
>  #else
> -    return dma_fence_signal(fence);
> +    dma_fence_signal(fence);
> +    return 0;
>  #endif
>  }
>  
> @@ -105,7 +106,8 @@ static inline int nv_dma_fence_signal_lo
>  #if defined(NV_LINUX_FENCE_H_PRESENT)
>      return fence_signal_locked(fence);
>  #else
> -    return dma_fence_signal_locked(fence);
> +    dma_fence_signal_locked(fence);
> +    return 0;
>  #endif
>  }
>  
> Index: kernel/nvidia-drm/nvidia-drm-priv.h
> ===================================================================
> --- kernel.orig/nvidia-drm/nvidia-drm-priv.h
> +++ kernel/nvidia-drm/nvidia-drm-priv.h
> @@ -47,6 +47,26 @@
>  
>  #include "nvkms-kapi.h"
>  
> +#if !defined(DRM_ERROR)
> +#define DRM_ERROR(fmt, ...) pr_err(fmt, ##__VA_ARGS__)
> +#endif
> +
> +#if !defined(DRM_INFO)
> +#define DRM_INFO(fmt, ...) pr_info(fmt, ##__VA_ARGS__)
> +#endif
> +
> +#if !defined(DRM_DEBUG)
> +#define DRM_DEBUG(fmt, ...) pr_debug(fmt, ##__VA_ARGS__)
> +#endif
> +
> +#if !defined(DRM_DEBUG_DRIVER)
> +#define DRM_DEBUG_DRIVER(fmt, ...) pr_debug(fmt, ##__VA_ARGS__)
> +#endif
> +
> +#if !defined(DRIVER_PRIME)
> +#define DRIVER_PRIME 0
> +#endif
> +
>  #define NV_DRM_LOG_ERR(__fmt, ...) \
>      DRM_ERROR("[nvidia-drm] " __fmt "\n", ##__VA_ARGS__)
>  
> Index: kernel/nvidia/nv-mmap.c
> ===================================================================
> --- kernel.orig/nvidia/nv-mmap.c
> +++ kernel/nvidia/nv-mmap.c
> @@ -839,6 +839,28 @@ void NV_API_CALL nv_set_safe_to_mmap_loc
>  }
>  
>  #if !NV_CAN_CALL_VMA_START_WRITE
> +
> +#ifndef VMA_LOCK_OFFSET
> +#define VMA_LOCK_OFFSET VM_REFCNT_EXCLUDE_READERS_FLAG
> +#endif
> +
> +#if !defined(NV_VM_AREA_STRUCT_HAS___VM_FLAGS)
> +/* v6.15+: one-argument form; retrieve seqnum via __vma_raw_mm_seqnum() */
> +static inline bool nv___is_vma_write_locked(struct vm_area_struct *vma,
> +                                             NvU32 *mm_lock_seq)
> +{
> +    *mm_lock_seq = __vma_raw_mm_seqnum(vma);
> +    return __is_vma_write_locked(vma);
> +}
> +#else
> +/* v6.3–v6.14: two-argument form stores the current mm_lock_seq */
> +static inline bool nv___is_vma_write_locked(struct vm_area_struct *vma,
> +                                             NvU32 *mm_lock_seq)
> +{
> +    return __is_vma_write_locked(vma, mm_lock_seq);
> +}
> +#endif
> +
>  static NvBool nv_vma_enter_locked(struct vm_area_struct *vma, NvBool 
> detaching)
>  {
>      NvU32 tgt_refcnt = VMA_LOCK_OFFSET;
> @@ -893,7 +915,7 @@ void nv_vma_start_write(struct vm_area_s
>  {
>      NvU32 mm_lock_seq;
>      NvBool locked;
> -    if (__is_vma_write_locked(vma, &mm_lock_seq))
> +    if (nv___is_vma_write_locked(vma, &mm_lock_seq))
>          return;
>  
>      locked = nv_vma_enter_locked(vma, NV_FALSE);
> Index: kernel/conftest.sh
> ===================================================================
> --- kernel.orig/conftest.sh
> +++ kernel/conftest.sh
> @@ -98,8 +98,16 @@ build_cflags() {
>      ISYSTEM=`$CC -print-file-name=include 2> /dev/null`
>      BASE_CFLAGS="-O2 -D__KERNEL__ \
>  -DKBUILD_BASENAME=\"#conftest$$\" -DKBUILD_MODNAME=\"#conftest$$\" \
> --nostdinc -isystem $ISYSTEM \
> +-nostdinc -isystem $ISYSTEM -std=gnu11 \
>  -Wno-implicit-function-declaration -Wno-strict-prototypes"
> +
> +    # Add UAPI headers and kconfig.h for Kernel 7.0 compatibility.
> +    BASE_CFLAGS="$BASE_CFLAGS -I$SOURCES/include/uapi"
> +    BASE_CFLAGS="$BASE_CFLAGS -I$OUTPUT/include/generated/uapi"
> +    BASE_CFLAGS="$BASE_CFLAGS -I$SOURCES/arch/$ARCH/include/uapi"
> +    BASE_CFLAGS="$BASE_CFLAGS -I$OUTPUT/arch/$ARCH/include/generated/uapi"
> +    BASE_CFLAGS="$BASE_CFLAGS -include $SOURCES/include/linux/kconfig.h"
>  
>      if [ "$OUTPUT" != "$SOURCES" ]; then
>          OUTPUT_CFLAGS="-I$OUTPUT/include2 -I$OUTPUT/include"
> @@ -148,6 +156,15 @@ build_cflags() {
>          fi
>      fi
>  
> +    # Ensure architecture-specific headers are also found in common headers 
> for split builds
> +    # and add all necessary paths to BASE_CFLAGS so they are used by all 
> conftests.
> +    BASE_CFLAGS="$BASE_CFLAGS -I$SOURCE_HEADERS"
> +    BASE_CFLAGS="$BASE_CFLAGS -I$SOURCE_HEADERS/uapi"
> +    BASE_CFLAGS="$BASE_CFLAGS -I$SOURCE_ARCH_HEADERS"
> +    BASE_CFLAGS="$BASE_CFLAGS -I$SOURCE_ARCH_HEADERS/uapi"
> +    BASE_CFLAGS="$BASE_CFLAGS -I$OUTPUT_ARCH_HEADERS/generated"
> +    BASE_CFLAGS="$BASE_CFLAGS -I$OUTPUT_ARCH_HEADERS/generated/uapi"
> +
>      SOURCE_HEADERS="$HEADERS"
>      SOURCE_ARCH_HEADERS="$SOURCES/arch/$KERNEL_ARCH/include"
>      OUTPUT_HEADERS="$OUTPUT/include"
> @@ -6537,7 +6554,7 @@ compile_test() {
>              CODE="
>              #include <linux/mm.h>
>              void conftest_vm_flags_set(void) {
> -                vm_flags_set();
> +                vm_flags_set(NULL, 0);
>              }"
>  
>              compile_check_conftest "$CODE" "NV_VM_FLAGS_SET_PRESENT" "" 
> "functions"
> @@ -6552,7 +6574,7 @@ compile_test() {
>              CODE="
>              #include <linux/mm.h>
>              void conftest_vma_flags_set_word(void) {
> -                vma_flags_set_word();
> +                vma_flags_set_word(NULL, 0);
>              }"
>  
>              compile_check_conftest "$CODE" "NV_VMA_FLAGS_SET_WORD_PRESENT" 
> "" "functions"
> Index: kernel/Makefile
> ===================================================================
> --- kernel.orig/Makefile
> +++ kernel/Makefile
> @@ -91,7 +91,7 @@ else
>    #     }
>    #     system(pahole_cmd)
>    # }
> -  PAHOLE_AWK_PROGRAM = BEGIN { pahole_cmd = \"pahole\"; for (i = 1; i < 
> ARGC; i++) { if (ARGV[i] ~ /--lang_exclude=/) { pahole_cmd = pahole_cmd 
> sprintf(\" %s,c++,c++11\", ARGV[i]); } else { pahole_cmd = pahole_cmd 
> sprintf(\" %s\", ARGV[i]); } } system(pahole_cmd); }
> +  PAHOLE_AWK_PROGRAM = BEGIN { pahole_cmd = "pahole"; for (i = 1; i < ARGC; 
> i++) { if (ARGV[i] ~ /--lang_exclude=/) { pahole_cmd = pahole_cmd sprintf(" 
> %s,c++,c++11", ARGV[i]); } else { pahole_cmd = pahole_cmd sprintf(" %s", 
> ARGV[i]); } } system(pahole_cmd); }
>    # If scripts/pahole-flags.sh is not present in the kernel tree, add PAHOLE 
> and
>    # PAHOLE_AWK_PROGRAM assignments to PAHOLE_VARIABLES; otherwise assign the
>    # empty string to PAHOLE_VARIABLES.

Reply via email to