summarylogtreecommitdiffstats
path: root/0006-kernel-nvidia-use-new-helper-macros-and-post-removal-in_irq-for-6.19.patch
blob: 7971a130dc85db13bf11ec0e2bce03d8a563eb2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
diff --git a/kernel/common/inc/nv-memdbg.h b/kernel/common/inc/nv-memdbg.h
index a749571..66e539f 100644
--- a/kernel/common/inc/nv-memdbg.h
+++ b/kernel/common/inc/nv-memdbg.h
@@ -41,8 +41,9 @@ void nv_memdbg_exit(void);
 
 #else
 
-#define NV_MEMDBG_ADD(ptr, size)
-#define NV_MEMDBG_REMOVE(ptr, size)
+// NB: Using while(0) to avoid -Wempty-body warnings
+#define NV_MEMDBG_ADD(ptr, size) while(0)
+#define NV_MEMDBG_REMOVE(ptr, size) while(0)
 
 #endif /* NV_MEM_LOGGER */
 
diff --git a/kernel/common/inc/nv-time.h b/kernel/common/inc/nv-time.h
index 7c3f512..ee8c687 100644
--- a/kernel/common/inc/nv-time.h
+++ b/kernel/common/inc/nv-time.h
@@ -29,9 +29,15 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/ktime.h>
+#include <linux/version.h>
 
 #include <nvstatus.h>
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0)
+// Rel. commit "treewide: Remove in_irq()" (Matthew Wilcox, 24 Oct 2025)
+#define in_hardirq in_irq
+#endif
+
 #define NV_MAX_ISR_DELAY_US           20000
 #define NV_MAX_ISR_DELAY_MS           (NV_MAX_ISR_DELAY_US / 1000)
 #define NV_NSECS_TO_JIFFIES(nsec)     ((nsec) * HZ / 1000000000)
@@ -142,7 +148,7 @@ static inline NV_STATUS nv_sleep_us(unsigned int us)
     ktime_get_raw_ts64(&tm1);
 #endif
 
-    if (in_irq() && (us > NV_MAX_ISR_DELAY_US))
+    if (in_hardirq() && (us > NV_MAX_ISR_DELAY_US))
         return NV_ERR_GENERIC;
 
     mdelay_safe_msec = us / 1000;
@@ -187,7 +193,7 @@ static inline NV_STATUS nv_sleep_ms(unsigned int ms)
     tm_start = tm_aux;
 #endif
 
-    if (in_irq() && (ms > NV_MAX_ISR_DELAY_MS))
+    if (in_hardirq() && (ms > NV_MAX_ISR_DELAY_MS))
     {
         return NV_ERR_GENERIC;
     }
diff --git a/kernel/conftest.sh b/kernel/conftest.sh
index 56ffd18..93c6136 100755
--- a/kernel/conftest.sh
+++ b/kernel/conftest.sh
@@ -93,7 +93,11 @@ test_header_presence() {
 
 build_cflags() {
     ISYSTEM=`$CC -print-file-name=include 2> /dev/null`
-    BASE_CFLAGS="-std=gnu17 -O2 -D__KERNEL__ \
+
+    # Rel. commit "Kbuild: enable -fms-extensions" (Rasmus Villemoes, 20 Oct 2025)
+    # Enable the flags since the Linux headers use those extensions in some structs
+    # See https://www.phoronix.com/news/Linux-6.19-Patch-Would-MS-Ext
+    BASE_CFLAGS="-std=gnu17 -fms-extensions -O2 -D__KERNEL__ \
 -DKBUILD_BASENAME=\"#conftest$$\" -DKBUILD_MODNAME=\"#conftest$$\" \
 -nostdinc -isystem $ISYSTEM \
 -Wno-implicit-function-declaration -Wno-strict-prototypes"
@@ -6519,7 +6523,11 @@ compile_test() {
             CODE="
             #include <linux/mm_types.h>
             int conftest_vm_area_struct_has_const_vm_flags(void) {
-                return offsetof(struct vm_area_struct, __vm_flags);
+                // Rel. commit 'mm: introduce VMA flags bitmap type' (Lorenzo Stoakes, 14 Nov 2025)
+                // Check for the const-ness of vm_flags directly: If vm_flags
+                // is not const, _Generic doesn't match and the build fails)
+                struct vm_area_struct vma;
+                return _Generic(&vma.vm_flags, const typeof(vma.vm_flags) *: 1);
             }"
 
             compile_check_conftest "$CODE" "NV_VM_AREA_STRUCT_HAS_CONST_VM_FLAGS" "" "types"
diff --git a/kernel/nvidia-drm/nvidia-drm-crtc.c b/kernel/nvidia-drm/nvidia-drm-crtc.c
index ee9573b..19311c3 100644
--- a/kernel/nvidia-drm/nvidia-drm-crtc.c
+++ b/kernel/nvidia-drm/nvidia-drm-crtc.c
@@ -563,7 +563,7 @@ static int __nv_drm_cursor_atomic_check(struct drm_plane *plane,
 
     WARN_ON(nv_plane->layer_idx != NVKMS_KAPI_LAYER_INVALID_IDX);
 
-    nv_drm_for_each_crtc_in_state(plane_state->state, crtc, crtc_state, i) {
+    for_each_new_crtc_in_state(plane_state->state, crtc, crtc_state, i) {
         struct nv_drm_crtc_state *nv_crtc_state = to_nv_crtc_state(crtc_state);
         struct NvKmsKapiHeadRequestedConfig *head_req_config =
             &nv_crtc_state->req_config;
@@ -609,7 +609,7 @@ static int nv_drm_plane_atomic_check(struct drm_plane *plane,
 
     WARN_ON(nv_plane->layer_idx == NVKMS_KAPI_LAYER_INVALID_IDX);
 
-    nv_drm_for_each_crtc_in_state(plane_state->state, crtc, crtc_state, i) {
+    for_each_new_crtc_in_state(plane_state->state, crtc, crtc_state, i) {
         struct nv_drm_crtc_state *nv_crtc_state = to_nv_crtc_state(crtc_state);
         struct NvKmsKapiHeadRequestedConfig *head_req_config =
             &nv_crtc_state->req_config;
@@ -1208,8 +1208,8 @@ static int nv_drm_crtc_atomic_check(struct drm_crtc *crtc,
 
         req_config->flags.displaysChanged = NV_TRUE;
 
-        nv_drm_for_each_connector_in_state(crtc_state->state,
-                                           connector, connector_state, j) {
+        for_each_new_connector_in_state(crtc_state->state,
+                                        connector, connector_state, j) {
             if (connector_state->crtc != crtc) {
                 continue;
             }
diff --git a/kernel/nvidia-drm/nvidia-drm-drv.c b/kernel/nvidia-drm/nvidia-drm-drv.c
index e7d880f..228e9b0 100644
--- a/kernel/nvidia-drm/nvidia-drm-drv.c
+++ b/kernel/nvidia-drm/nvidia-drm-drv.c
@@ -750,13 +750,13 @@ void nv_drm_master_drop(struct drm_device *dev, struct drm_file *file_priv)
 
     drm_modeset_lock_all(dev);
 
-    if ((err = nv_drm_atomic_helper_disable_all(
+    if ((err = drm_atomic_helper_disable_all(
             dev,
             dev->mode_config.acquire_ctx)) != 0) {
 
         NV_DRM_DEV_LOG_ERR(
             nv_dev,
-            "nv_drm_atomic_helper_disable_all failed with error code %d !",
+            "drm_atomic_helper_disable_all failed with error code %d !",
             err);
     }
 
@@ -1117,11 +1117,11 @@ static int nv_drm_grant_sub_ownership(struct drm_device *dev,
      * When creating an ownership grant, shut down all heads and disable flip
      * notifications.
      */
-    ret = nv_drm_atomic_helper_disable_all(dev, pctx);
+    ret = drm_atomic_helper_disable_all(dev, pctx);
     if (ret != 0) {
         NV_DRM_DEV_LOG_ERR(
             nv_dev,
-            "nv_drm_atomic_helper_disable_all failed with error code %d!",
+            "drm_atomic_helper_disable_all failed with error code %d!",
             ret);
     }
 
diff --git a/kernel/nvidia-drm/nvidia-drm-helper.c b/kernel/nvidia-drm/nvidia-drm-helper.c
index dd6f89a..f2f8429 100644
--- a/kernel/nvidia-drm/nvidia-drm-helper.c
+++ b/kernel/nvidia-drm/nvidia-drm-helper.c
@@ -66,153 +66,4 @@ static void __nv_drm_framebuffer_put(struct drm_framebuffer *fb)
 
 }
 
-/*
- * drm_atomic_helper_disable_all() has been added by commit
- * 1494276000db789c6d2acd85747be4707051c801, which is Signed-off-by:
- *     Thierry Reding <treding@nvidia.com>
- *     Daniel Vetter <daniel.vetter@ffwll.ch>
- *
- * drm_atomic_helper_disable_all() is copied from
- * linux/drivers/gpu/drm/drm_atomic_helper.c and modified to use
- * nv_drm_for_each_crtc instead of drm_for_each_crtc to loop over all crtcs,
- * use nv_drm_for_each_*_in_state instead of for_each_connector_in_state to loop
- * over all modeset object states, and use drm_atomic_state_free() if
- * drm_atomic_state_put() is not available.
- *
- * drm_atomic_helper_disable_all() is copied from
- *     linux/drivers/gpu/drm/drm_atomic_helper.c @
- *     49d70aeaeca8f62b72b7712ecd1e29619a445866, which has the following
- * copyright and license information:
- *
- * Copyright (C) 2014 Red Hat
- * Copyright (C) 2014 Intel Corp.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Rob Clark <robdclark@gmail.com>
- * Daniel Vetter <daniel.vetter@ffwll.ch>
- */
-int nv_drm_atomic_helper_disable_all(struct drm_device *dev,
-                                     struct drm_modeset_acquire_ctx *ctx)
-{
-    struct drm_atomic_state *state;
-    struct drm_connector_state *conn_state;
-    struct drm_connector *conn;
-    struct drm_plane_state *plane_state;
-    struct drm_plane *plane;
-    struct drm_crtc_state *crtc_state;
-    struct drm_crtc *crtc;
-    unsigned plane_mask = 0;
-    int ret, i;
-
-    state = drm_atomic_state_alloc(dev);
-    if (!state)
-        return -ENOMEM;
-
-    state->acquire_ctx = ctx;
-
-    nv_drm_for_each_crtc(crtc, dev) {
-        crtc_state = drm_atomic_get_crtc_state(state, crtc);
-        if (IS_ERR(crtc_state)) {
-            ret = PTR_ERR(crtc_state);
-            goto free;
-        }
-
-        crtc_state->active = false;
-
-        ret = drm_atomic_set_mode_prop_for_crtc(crtc_state, NULL);
-        if (ret < 0)
-            goto free;
-
-        ret = drm_atomic_add_affected_planes(state, crtc);
-        if (ret < 0)
-            goto free;
-
-        ret = drm_atomic_add_affected_connectors(state, crtc);
-        if (ret < 0)
-            goto free;
-    }
-
-#if defined(NV_DRM_ROTATION_AVAILABLE)
-    nv_drm_for_each_plane(plane, dev) {
-        plane_state = drm_atomic_get_plane_state(state, plane);
-        if (IS_ERR(plane_state)) {
-            ret = PTR_ERR(plane_state);
-            goto free;
-        }
-
-        plane_state->rotation = DRM_MODE_ROTATE_0;
-    }
-#endif
-
-    nv_drm_for_each_connector_in_state(state, conn, conn_state, i) {
-        ret = drm_atomic_set_crtc_for_connector(conn_state, NULL);
-        if (ret < 0)
-            goto free;
-    }
-
-    nv_drm_for_each_plane_in_state(state, plane, plane_state, i) {
-        ret = drm_atomic_set_crtc_for_plane(plane_state, NULL);
-        if (ret < 0)
-            goto free;
-
-        drm_atomic_set_fb_for_plane(plane_state, NULL);
-        plane_mask |= NVBIT(drm_plane_index(plane));
-        plane->old_fb = plane->fb;
-    }
-
-    ret = drm_atomic_commit(state);
-free:
-    if (plane_mask) {
-        drm_for_each_plane_mask(plane, dev, plane_mask) {
-            if (ret == 0) {
-                plane->fb = NULL;
-                plane->crtc = NULL;
-
-                WARN_ON(plane->state->fb);
-                WARN_ON(plane->state->crtc);
-
-                if (plane->old_fb)
-                    __nv_drm_framebuffer_put(plane->old_fb);
-           }
-           plane->old_fb = NULL;
-       }
-    }
-
-#if defined(NV_DRM_ATOMIC_STATE_REF_COUNTING_PRESENT)
-    drm_atomic_state_put(state);
-#else
-    if (ret != 0) {
-        drm_atomic_state_free(state);
-    } else {
-        /*
-         * In case of success, drm_atomic_commit() takes care to cleanup and
-         * free @state.
-         *
-         * Comment placed above drm_atomic_commit() says: The caller must not
-         * free or in any other way access @state. If the function fails then
-         * the caller must clean up @state itself.
-         */
-    }
-#endif
-    return ret;
-}
-
 #endif /* NV_DRM_ATOMIC_MODESET_AVAILABLE */
diff --git a/kernel/nvidia-drm/nvidia-drm-helper.h b/kernel/nvidia-drm/nvidia-drm-helper.h
index 94d48db..1934b95 100644
--- a/kernel/nvidia-drm/nvidia-drm-helper.h
+++ b/kernel/nvidia-drm/nvidia-drm-helper.h
@@ -185,157 +185,6 @@ nv_drm_prime_pages_to_sg(struct drm_device *dev,
 #include <drm/drm_atomic.h>
 #include <drm/drm_atomic_helper.h>
 
-int nv_drm_atomic_helper_disable_all(struct drm_device *dev,
-                                     struct drm_modeset_acquire_ctx *ctx);
-
-/*
- * for_each_connector_in_state(), for_each_crtc_in_state() and
- * for_each_plane_in_state() were added by kernel commit
- * df63b9994eaf942afcdb946d27a28661d7dfbf2a which was Signed-off-by:
- *      Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
- *      Daniel Vetter <daniel.vetter@ffwll.ch>
- *
- * for_each_connector_in_state(), for_each_crtc_in_state() and
- * for_each_plane_in_state() were copied from
- *      include/drm/drm_atomic.h @
- *      21a01abbe32a3cbeb903378a24e504bfd9fe0648
- * which has the following copyright and license information:
- *
- * Copyright (C) 2014 Red Hat
- * Copyright (C) 2014 Intel Corp.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Rob Clark <robdclark@gmail.com>
- * Daniel Vetter <daniel.vetter@ffwll.ch>
- */
-
-/**
- * nv_drm_for_each_connector_in_state - iterate over all connectors in an
- * atomic update
- * @__state: &struct drm_atomic_state pointer
- * @connector: &struct drm_connector iteration cursor
- * @connector_state: &struct drm_connector_state iteration cursor
- * @__i: int iteration cursor, for macro-internal use
- *
- * This iterates over all connectors in an atomic update. Note that before the
- * software state is committed (by calling drm_atomic_helper_swap_state(), this
- * points to the new state, while afterwards it points to the old state. Due to
- * this tricky confusion this macro is deprecated.
- */
-#if !defined(for_each_connector_in_state)
-#define nv_drm_for_each_connector_in_state(__state,                         \
-                                           connector, connector_state, __i) \
-       for ((__i) = 0;                                                      \
-            (__i) < (__state)->num_connector &&                             \
-            ((connector) = (__state)->connectors[__i].ptr,                  \
-            (connector_state) = (__state)->connectors[__i].state, 1);       \
-            (__i)++)                                                        \
-               for_each_if (connector)
-#else
-#define nv_drm_for_each_connector_in_state(__state,                         \
-                                           connector, connector_state, __i) \
-    for_each_connector_in_state(__state, connector, connector_state, __i)
-#endif
-
-
-/**
- * nv_drm_for_each_crtc_in_state - iterate over all CRTCs in an atomic update
- * @__state: &struct drm_atomic_state pointer
- * @crtc: &struct drm_crtc iteration cursor
- * @crtc_state: &struct drm_crtc_state iteration cursor
- * @__i: int iteration cursor, for macro-internal use
- *
- * This iterates over all CRTCs in an atomic update. Note that before the
- * software state is committed (by calling drm_atomic_helper_swap_state(), this
- * points to the new state, while afterwards it points to the old state. Due to
- * this tricky confusion this macro is deprecated.
- */
-#if !defined(for_each_crtc_in_state)
-#define nv_drm_for_each_crtc_in_state(__state, crtc, crtc_state, __i) \
-       for ((__i) = 0;                                                \
-            (__i) < (__state)->dev->mode_config.num_crtc &&           \
-            ((crtc) = (__state)->crtcs[__i].ptr,                      \
-            (crtc_state) = (__state)->crtcs[__i].state, 1);           \
-            (__i)++)                                                  \
-               for_each_if (crtc_state)
-#else
-#define nv_drm_for_each_crtc_in_state(__state, crtc, crtc_state, __i) \
-    for_each_crtc_in_state(__state, crtc, crtc_state, __i)
-#endif
-
-/**
- * nv_drm_for_each_plane_in_state - iterate over all planes in an atomic update
- * @__state: &struct drm_atomic_state pointer
- * @plane: &struct drm_plane iteration cursor
- * @plane_state: &struct drm_plane_state iteration cursor
- * @__i: int iteration cursor, for macro-internal use
- *
- * This iterates over all planes in an atomic update. Note that before the
- * software state is committed (by calling drm_atomic_helper_swap_state(), this
- * points to the new state, while afterwards it points to the old state. Due to
- * this tricky confusion this macro is deprecated.
- */
-#if !defined(for_each_plane_in_state)
-#define nv_drm_for_each_plane_in_state(__state, plane, plane_state, __i) \
-       for ((__i) = 0;                                                   \
-            (__i) < (__state)->dev->mode_config.num_total_plane &&       \
-            ((plane) = (__state)->planes[__i].ptr,                       \
-            (plane_state) = (__state)->planes[__i].state, 1);            \
-            (__i)++)                                                     \
-               for_each_if (plane_state)
-#else
-#define nv_drm_for_each_plane_in_state(__state, plane, plane_state, __i) \
-    for_each_plane_in_state(__state, plane, plane_state, __i)
-#endif
-
-/*
- * for_each_new_plane_in_state() was added by kernel commit
- * 581e49fe6b411f407102a7f2377648849e0fa37f which was Signed-off-by:
- *      Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
- *      Daniel Vetter <daniel.vetter@ffwll.ch>
- *
- * This commit also added the old_state and new_state pointers to
- * __drm_planes_state. Because of this, the best that can be done on kernel
- * versions without this macro is for_each_plane_in_state.
- */
-
-/**
- * nv_drm_for_each_new_plane_in_state - iterate over all planes in an atomic update
- * @__state: &struct drm_atomic_state pointer
- * @plane: &struct drm_plane iteration cursor
- * @new_plane_state: &struct drm_plane_state iteration cursor for the new state
- * @__i: int iteration cursor, for macro-internal use
- *
- * This iterates over all planes in an atomic update, tracking only the new
- * state. This is useful in enable functions, where we need the new state the
- * hardware should be in when the atomic commit operation has completed.
- */
-#if !defined(for_each_new_plane_in_state)
-#define nv_drm_for_each_new_plane_in_state(__state, plane, new_plane_state, __i) \
-    nv_drm_for_each_plane_in_state(__state, plane, new_plane_state, __i)
-#else
-#define nv_drm_for_each_new_plane_in_state(__state, plane, new_plane_state, __i) \
-    for_each_new_plane_in_state(__state, plane, new_plane_state, __i)
-#endif
-
 static inline struct drm_connector *
 nv_drm_connector_lookup(struct drm_device *dev, struct drm_file *filep,
                         uint32_t id)
diff --git a/kernel/nvidia-drm/nvidia-drm-modeset.c b/kernel/nvidia-drm/nvidia-drm-modeset.c
index a811282..256f541 100644
--- a/kernel/nvidia-drm/nvidia-drm-modeset.c
+++ b/kernel/nvidia-drm/nvidia-drm-modeset.c
@@ -86,9 +86,9 @@ void nv_drm_atomic_state_free(struct drm_atomic_state *state)
  * is swapped into current state.
  */
 static bool __will_generate_flip_event(struct drm_crtc *crtc,
-                                       struct drm_crtc_state *old_crtc_state)
+                                       struct drm_crtc_state *old_crtc_state,
+                                       struct drm_crtc_state *new_crtc_state)
 {
-    struct drm_crtc_state *new_crtc_state = crtc->state;
     struct nv_drm_crtc_state *nv_new_crtc_state =
         to_nv_crtc_state(new_crtc_state);
     struct drm_plane_state *old_plane_state = NULL;
@@ -104,7 +104,7 @@ static bool __will_generate_flip_event(struct drm_crtc *crtc,
     }
 
     /* Find out whether primary & overlay flip done events will be generated. */
-    nv_drm_for_each_plane_in_state(old_crtc_state->state,
+    for_each_old_plane_in_state(old_crtc_state->state,
         plane, old_plane_state, i) {
         if (old_plane_state->crtc != crtc) {
            continue;
@@ -150,13 +150,13 @@ static int __nv_drm_get_syncpt_data(
     struct nv_drm_device *nv_dev,
     struct drm_crtc *crtc,
     struct drm_crtc_state *old_crtc_state,
+    struct drm_crtc_state *new_crtc_state,
     struct NvKmsKapiRequestedModeSetConfig *requested_config,
     struct NvKmsKapiModeSetReplyConfig *reply_config)
 {
     struct nv_drm_crtc *nv_crtc = to_nv_crtc(crtc);
     struct NvKmsKapiHeadReplyConfig *head_reply_config;
     struct nv_drm_plane_state *plane_state;
-    struct drm_crtc_state *new_crtc_state = crtc->state;
     struct drm_plane_state *old_plane_state = NULL;
     struct drm_plane_state *new_plane_state = NULL;
     struct drm_plane *plane = NULL;
@@ -172,15 +172,13 @@ static int __nv_drm_get_syncpt_data(
 
     head_reply_config = &reply_config->headReplyConfig[nv_crtc->head];
 
-    nv_drm_for_each_plane_in_state(old_crtc_state->state, plane, old_plane_state, i) {
+    for_each_oldnew_plane_in_state(old_crtc_state->state, plane, old_plane_state, new_plane_state, i) {
         struct nv_drm_plane *nv_plane = to_nv_plane(plane);
 
         if (plane->type == DRM_PLANE_TYPE_CURSOR || old_plane_state->crtc != crtc) {
             continue;
         }
 
-        new_plane_state = plane->state;
-
         if (new_plane_state->crtc != crtc) {
             continue;
         }
@@ -233,7 +231,7 @@ nv_drm_atomic_apply_modeset_config(struct drm_device *dev,
         &(to_nv_atomic_state(state)->config);
     struct NvKmsKapiModeSetReplyConfig reply_config = { };
     struct drm_crtc *crtc;
-    struct drm_crtc_state *crtc_state;
+    struct drm_crtc_state *old_crtc_state, *new_crtc_state;
     int i;
     int ret;
 
@@ -248,14 +246,7 @@ nv_drm_atomic_apply_modeset_config(struct drm_device *dev,
     memset(requested_config, 0, sizeof(*requested_config));
 
     /* Loop over affected crtcs and construct NvKmsKapiRequestedModeSetConfig */
-    nv_drm_for_each_crtc_in_state(state, crtc, crtc_state, i) {
-        /*
-         * When committing a state, the new state is already stored in
-         * crtc->state. When checking a proposed state, the proposed state is
-         * stored in crtc_state.
-         */
-        struct drm_crtc_state *new_crtc_state =
-                               commit ? crtc->state : crtc_state;
+    for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
         struct nv_drm_crtc *nv_crtc = to_nv_crtc(crtc);
 
         requested_config->headRequestedConfig[nv_crtc->head] =
@@ -264,7 +255,6 @@ nv_drm_atomic_apply_modeset_config(struct drm_device *dev,
         requested_config->headsMask |= 1 << nv_crtc->head;
 
         if (commit) {
-            struct drm_crtc_state *old_crtc_state = crtc_state;
             struct nv_drm_crtc_state *nv_new_crtc_state =
                 to_nv_crtc_state(new_crtc_state);
 
@@ -276,7 +266,7 @@ nv_drm_atomic_apply_modeset_config(struct drm_device *dev,
              * If flip event will be generated by hardware
              * then defer flip object processing to flip event from hardware.
              */
-            if (__will_generate_flip_event(crtc, old_crtc_state)) {
+            if (__will_generate_flip_event(crtc, old_crtc_state, new_crtc_state)) {
                 nv_drm_crtc_enqueue_flip(nv_crtc,
                                          nv_new_crtc_state->nv_flip);
 
@@ -303,10 +293,12 @@ nv_drm_atomic_apply_modeset_config(struct drm_device *dev,
     }
 
     if (commit && nv_dev->supportsSyncpts) {
-        nv_drm_for_each_crtc_in_state(state, crtc, crtc_state, i) {
+        for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state,
+                                      new_crtc_state, i) {
             /*! loop over affected crtcs and get NvKmsKapiModeSetReplyConfig */
-            ret = __nv_drm_get_syncpt_data(
-                      nv_dev, crtc, crtc_state, requested_config, &reply_config);
+            ret = __nv_drm_get_syncpt_data(nv_dev, crtc,
+                                           old_crtc_state, new_crtc_state,
+                                           requested_config, &reply_config);
             if (ret != 0) {
                 return ret;
             }
@@ -326,7 +318,7 @@ int nv_drm_atomic_check(struct drm_device *dev,
     struct drm_crtc_state *crtc_state;
     int i;
 
-    nv_drm_for_each_crtc_in_state(state, crtc, crtc_state, i) {
+    for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
         /*
          * if the color management changed on the crtc, we need to update the
          * crtc's plane's CSC matrices, so add the crtc's planes to the commit
@@ -409,7 +401,7 @@ int nv_drm_atomic_commit(struct drm_device *dev,
 
     int i;
     struct drm_crtc *crtc = NULL;
-    struct drm_crtc_state *crtc_state = NULL;
+    struct drm_crtc_state *new_crtc_state = NULL;
     struct nv_drm_device *nv_dev = to_nv_device(dev);
 
     /*
@@ -423,7 +415,7 @@ int nv_drm_atomic_commit(struct drm_device *dev,
      * Our system already implements such a queue, but due to
      * bug 4054608, it is currently not used.
      */
-    nv_drm_for_each_crtc_in_state(state, crtc, crtc_state, i) {
+    for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
         struct nv_drm_crtc *nv_crtc = to_nv_crtc(crtc);
 
         /*
@@ -508,10 +500,10 @@ int nv_drm_atomic_commit(struct drm_device *dev,
     }
     nv_dev->drmMasterChangedSinceLastAtomicCommit = NV_FALSE;
 
-    nv_drm_for_each_crtc_in_state(state, crtc, crtc_state, i) {
+    for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
         struct nv_drm_crtc *nv_crtc = to_nv_crtc(crtc);
         struct nv_drm_crtc_state *nv_new_crtc_state =
-            to_nv_crtc_state(crtc->state);
+            to_nv_crtc_state(new_crtc_state);
 
         /*
          * If nv_drm_atomic_apply_modeset_config() hasn't consumed the flip
diff --git a/kernel/nvidia-drm/nvidia-drm-priv.h b/kernel/nvidia-drm/nvidia-drm-priv.h
index c9ce727..f13ac7d 100644
--- a/kernel/nvidia-drm/nvidia-drm-priv.h
+++ b/kernel/nvidia-drm/nvidia-drm-priv.h
@@ -39,6 +39,9 @@
 #include <drm/drm_gem.h>
 #endif
 
+// Rel. commit "drm/mm: replace drm_print.h include with a forward declaration" (Jani Nikula, 29 Oct 2025)
+#include <drm/drm_print.h>
+
 #include "nvidia-drm-os-interface.h"
 
 #include "nvkms-kapi.h"
diff --git a/kernel/nvidia/kernel/nvidia/nv-dma.c
index f7861b2..3a204a6 100644
--- a/kernel/nvidia/nv-dma.c
+++ b/kernel/nvidia/nv-dma.c
@@ -27,6 +27,8 @@
 #include "nv-linux.h"
 #include "nv-reg.h"
 
+#include <linux/version.h>
+
 #define NV_DMA_DEV_PRINTF(debuglevel, dma_dev, format, ... )                \
     nv_printf(debuglevel, "NVRM: %s: " format,                              \
               (((dma_dev) && ((dma_dev)->dev)) ? dev_name((dma_dev)->dev) : \
@@ -796,7 +798,13 @@ static NvBool nv_dma_use_map_resource
 #endif
     }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 19, 0)
+    // Rel. commit "dma-mapping: remove unused mapping resource callbacks" (Leon Romanovsky, 15 Oct 2025)
+    // https://lore.kernel.org/all/20251015-remove-map-page-v5-0-3bbfe3a25cdf@kernel.org/
+    return (ops->map_phys != NULL);
+#else
     return (ops->map_resource != NULL);
+#endif
 #else
     return NV_FALSE;
 #endif
diff --git a/kernel/nvidia/kernel/nvidia/os-interface.c
index 310aff3..b3da778 100644
--- a/kernel/nvidia/os-interface.c
+++ b/kernel/nvidia/os-interface.c
@@ -334,7 +334,7 @@ NvBool NV_API_CALL os_semaphore_may_sleep(void)
 
 NvBool NV_API_CALL os_is_isr(void)
 {
-    return (in_irq());
+    return (in_hardirq());
 }
 
 // return TRUE if the caller is the super-user