diff --git a/kernel/conftest.sh b/kernel/conftest.sh index 3d11fc4..48b48d0 100755 --- a/kernel/conftest.sh +++ b/kernel/conftest.sh @@ -3360,9 +3360,9 @@ compile_test() { compile_check_conftest "$CODE" "NV_DRM_ATOMIC_MODESET_NONBLOCKING_COMMIT_AVAILABLE" "" "generic" ;; - drm_atomic_state_ref_counting) + drm_atomic_commit_ref_counting) # - # Determine if functions drm_atomic_state_get/put() are + # Determine if functions drm_atomic_commit_get/put() are # present. # # Added by commit 0853695c3ba4 ("drm: Add reference counting to @@ -3372,11 +3372,18 @@ compile_test() { #if defined(NV_DRM_DRM_ATOMIC_H_PRESENT) #include #endif - void conftest_drm_atomic_state_get(void) { - drm_atomic_state_get(); + #include + + // Rel. commit \"drm: Rename struct drm_atomic_state to drm_atomic_commit\" (Maxime Ripard, 27 Apr 2026) + #if LINUX_VERSION_CODE < KERNEL_VERSION(7, 2, 0) + #define drm_atomic_commit_get drm_atomic_state_get + #endif + + void conftest_drm_atomic_commit_get(void) { + drm_atomic_commit_get(); }" - compile_check_conftest "$CODE" "NV_DRM_ATOMIC_STATE_REF_COUNTING_PRESENT" "" "functions" + compile_check_conftest "$CODE" "NV_DRM_ATOMIC_COMMIT_REF_COUNTING_PRESENT" "" "functions" ;; vm_ops_fault_removed_vma_arg) @@ -3940,8 +3947,15 @@ compile_test() { # CODE=" #include + #include + + // Rel. commit \"drm: Rename struct drm_atomic_state to drm_atomic_commit\" (Maxime Ripard, 27 Apr 2026) + #if LINUX_VERSION_CODE < KERNEL_VERSION(7, 2, 0) + #define drm_atomic_commit drm_atomic_state + #endif + void conftest_drm_atomic_helper_swap_state_has_stall_arg( - struct drm_atomic_state *state, + struct drm_atomic_commit *state, bool stall) { (void)drm_atomic_helper_swap_state(state, stall); }" @@ -3959,8 +3973,15 @@ compile_test() { # CODE=" #include + #include + + // Rel. commit \"drm: Rename struct drm_atomic_state to drm_atomic_commit\" (Maxime Ripard, 27 Apr 2026) + #if LINUX_VERSION_CODE < KERNEL_VERSION(7, 2, 0) + #define drm_atomic_commit drm_atomic_state + #endif + int conftest_drm_atomic_helper_swap_state_return_int( - struct drm_atomic_state *state, + struct drm_atomic_commit *state, bool stall) { return drm_atomic_helper_swap_state(state, stall); }" @@ -4413,10 +4434,10 @@ compile_test() { compile_check_conftest "$CODE" "NV_DRM_DRIVER_HAS_GEM_PRIME_CALLBACKS" "" "types" ;; - drm_crtc_atomic_check_has_atomic_state_arg) + drm_crtc_atomic_check_has_atomic_commit_arg) # # Determine if drm_crtc_helper_funcs::atomic_check takes 'state' - # argument of 'struct drm_atomic_state' type. + # argument of 'struct drm_atomic_commit' type. # # The commit 29b77ad7b9ca ("drm/atomic: Pass the full state to CRTC # atomic_check") passed the full atomic state to @@ -4430,12 +4451,18 @@ compile_test() { # echo "$CONFTEST_PREAMBLE #include + #include + + // Rel. commit \"drm: Rename struct drm_atomic_state to drm_atomic_commit\" (Maxime Ripard, 27 Apr 2026) + #if LINUX_VERSION_CODE < KERNEL_VERSION(7, 2, 0) + #define drm_atomic_commit drm_atomic_state + #endif static const struct drm_crtc_helper_funcs *funcs; - typeof(*funcs->atomic_check) conftest_drm_crtc_atomic_check_has_atomic_state_arg; + typeof(*funcs->atomic_check) conftest_drm_crtc_atomic_check_has_atomic_commit_arg; - int conftest_drm_crtc_atomic_check_has_atomic_state_arg( - struct drm_crtc *crtc, struct drm_atomic_state *state) { + int conftest_drm_crtc_atomic_check_has_atomic_commit_arg( + struct drm_crtc *crtc, struct drm_atomic_commit *state) { return 0; }" > conftest$$.c @@ -4444,9 +4471,9 @@ compile_test() { if [ -f conftest$$.o ]; then rm -f conftest$$.o - echo "#define NV_DRM_CRTC_ATOMIC_CHECK_HAS_ATOMIC_STATE_ARG" | append_conftest "types" + echo "#define NV_DRM_CRTC_ATOMIC_CHECK_HAS_ATOMIC_COMMIT_ARG" | append_conftest "types" else - echo "#undef NV_DRM_CRTC_ATOMIC_CHECK_HAS_ATOMIC_STATE_ARG" | append_conftest "types" + echo "#undef NV_DRM_CRTC_ATOMIC_CHECK_HAS_ATOMIC_COMMIT_ARG" | append_conftest "types" fi ;; @@ -4487,10 +4514,10 @@ compile_test() { compile_check_conftest "$CODE" "NV_FOLLOW_PFN_PRESENT" "" "functions" ;; - drm_plane_atomic_check_has_atomic_state_arg) + drm_plane_atomic_check_has_atomic_commit_arg) # # Determine if drm_plane_helper_funcs::atomic_check takes 'state' - # argument of 'struct drm_atomic_state' type. + # argument of 'struct drm_atomic_commit' type. # # The commit 7c11b99a8e58 ("drm/atomic: Pass the full state to # planes atomic_check") passed the full atomic state to @@ -4504,12 +4531,18 @@ compile_test() { # echo "$CONFTEST_PREAMBLE #include + #include + + // Rel. commit \"drm: Rename struct drm_atomic_state to drm_atomic_commit\" (Maxime Ripard, 27 Apr 2026) + #if LINUX_VERSION_CODE < KERNEL_VERSION(7, 2, 0) + #define drm_atomic_commit drm_atomic_state + #endif static const struct drm_plane_helper_funcs *funcs; - typeof(*funcs->atomic_check) conftest_drm_plane_atomic_check_has_atomic_state_arg; + typeof(*funcs->atomic_check) conftest_drm_plane_atomic_check_has_atomic_commit_arg; - int conftest_drm_plane_atomic_check_has_atomic_state_arg( - struct drm_plane *plane, struct drm_atomic_state *state) { + int conftest_drm_plane_atomic_check_has_atomic_commit_arg( + struct drm_plane *plane, struct drm_atomic_commit *state) { return 0; }" > conftest$$.c @@ -4518,9 +4551,9 @@ compile_test() { if [ -f conftest$$.o ]; then rm -f conftest$$.o - echo "#define NV_DRM_PLANE_ATOMIC_CHECK_HAS_ATOMIC_STATE_ARG" | append_conftest "types" + echo "#define NV_DRM_PLANE_ATOMIC_CHECK_HAS_ATOMIC_COMMIT_ARG" | append_conftest "types" else - echo "#undef NV_DRM_PLANE_ATOMIC_CHECK_HAS_ATOMIC_STATE_ARG" | append_conftest "types" + echo "#undef NV_DRM_PLANE_ATOMIC_CHECK_HAS_ATOMIC_COMMIT_ARG" | append_conftest "types" fi ;; diff --git a/kernel/nvidia-drm/nvidia-drm-crtc.c b/kernel/nvidia-drm/nvidia-drm-crtc.c index 9253bd5..0d94703 100644 --- a/kernel/nvidia-drm/nvidia-drm-crtc.c +++ b/kernel/nvidia-drm/nvidia-drm-crtc.c @@ -130,15 +130,15 @@ plane_req_config_update(struct drm_plane_state *plane_state, old_config.dstHeight != req_config->config.dstHeight; } -#if defined(NV_DRM_PLANE_ATOMIC_CHECK_HAS_ATOMIC_STATE_ARG) +#if defined(NV_DRM_PLANE_ATOMIC_CHECK_HAS_ATOMIC_COMMIT_ARG) static int nv_drm_plane_atomic_check(struct drm_plane *plane, - struct drm_atomic_state *state) + struct drm_atomic_commit *state) #else static int nv_drm_plane_atomic_check(struct drm_plane *plane, struct drm_plane_state *plane_state) #endif { -#if defined(NV_DRM_PLANE_ATOMIC_CHECK_HAS_ATOMIC_STATE_ARG) +#if defined(NV_DRM_PLANE_ATOMIC_CHECK_HAS_ATOMIC_COMMIT_ARG) struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane); #endif @@ -333,15 +333,15 @@ static int head_modeset_config_attach_connector( * the 'nv_drm_crtc_state::req_config', that is fine becase 'nv_drm_crtc_state' * will be discarded if ->atomic_check() fails. */ -#if defined(NV_DRM_CRTC_ATOMIC_CHECK_HAS_ATOMIC_STATE_ARG) +#if defined(NV_DRM_CRTC_ATOMIC_CHECK_HAS_ATOMIC_COMMIT_ARG) static int nv_drm_crtc_atomic_check(struct drm_crtc *crtc, - struct drm_atomic_state *state) + struct drm_atomic_commit *state) #else static int nv_drm_crtc_atomic_check(struct drm_crtc *crtc, struct drm_crtc_state *crtc_state) #endif { -#if defined(NV_DRM_CRTC_ATOMIC_CHECK_HAS_ATOMIC_STATE_ARG) +#if defined(NV_DRM_CRTC_ATOMIC_CHECK_HAS_ATOMIC_COMMIT_ARG) struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, crtc); #endif diff --git a/kernel/nvidia-drm/nvidia-drm-modeset.c b/kernel/nvidia-drm/nvidia-drm-modeset.c index 5bbcd4a..f58a38c 100644 --- a/kernel/nvidia-drm/nvidia-drm-modeset.c +++ b/kernel/nvidia-drm/nvidia-drm-modeset.c @@ -42,23 +42,23 @@ #include #include -struct nv_drm_atomic_state { +struct nv_drm_atomic_commit { struct NvKmsKapiRequestedModeSetConfig config; - struct drm_atomic_state base; + struct drm_atomic_commit base; }; -static inline struct nv_drm_atomic_state *to_nv_atomic_state( - struct drm_atomic_state *state) +static inline struct nv_drm_atomic_commit *to_nv_atomic_commit( + struct drm_atomic_commit *state) { - return container_of(state, struct nv_drm_atomic_state, base); + return container_of(state, struct nv_drm_atomic_commit, base); } -struct drm_atomic_state *nv_drm_atomic_state_alloc(struct drm_device *dev) +struct drm_atomic_commit *nv_drm_atomic_state_alloc(struct drm_device *dev) { - struct nv_drm_atomic_state *nv_state = + struct nv_drm_atomic_commit *nv_state = nv_drm_calloc(1, sizeof(*nv_state)); - if (nv_state == NULL || drm_atomic_state_init(dev, &nv_state->base) < 0) { + if (nv_state == NULL || drm_atomic_commit_init(dev, &nv_state->base) < 0) { nv_drm_free(nv_state); return NULL; } @@ -66,16 +66,16 @@ struct drm_atomic_state *nv_drm_atomic_state_alloc(struct drm_device *dev) return &nv_state->base; } -void nv_drm_atomic_state_clear(struct drm_atomic_state *state) +void nv_drm_atomic_state_clear(struct drm_atomic_commit *state) { - drm_atomic_state_default_clear(state); + drm_atomic_commit_default_clear(state); } -void nv_drm_atomic_state_free(struct drm_atomic_state *state) +void nv_drm_atomic_state_free(struct drm_atomic_commit *state) { - struct nv_drm_atomic_state *nv_state = - to_nv_atomic_state(state); - drm_atomic_state_default_release(state); + struct nv_drm_atomic_commit *nv_state = + to_nv_atomic_commit(state); + drm_atomic_commit_default_release(state); nv_drm_free(nv_state); } @@ -105,12 +105,12 @@ void nv_drm_atomic_state_free(struct drm_atomic_state *state) */ static int nv_drm_atomic_apply_modeset_config(struct drm_device *dev, - struct drm_atomic_state *state, + struct drm_atomic_commit *state, bool commit) { struct nv_drm_device *nv_dev = to_nv_device(dev); struct NvKmsKapiRequestedModeSetConfig *requested_config = - &(to_nv_atomic_state(state)->config); + &(to_nv_atomic_commit(state)->config); struct drm_crtc *crtc; struct drm_crtc_state *old_crtc_state, *new_crtc_state; int i; @@ -161,7 +161,7 @@ nv_drm_atomic_apply_modeset_config(struct drm_device *dev, } int nv_drm_atomic_check(struct drm_device *dev, - struct drm_atomic_state *state) + struct drm_atomic_commit *state) { int ret = 0; @@ -205,7 +205,7 @@ static void __nv_drm_handle_flip_event(struct nv_drm_crtc *nv_crtc) } int nv_drm_atomic_commit(struct drm_device *dev, - struct drm_atomic_state *state, + struct drm_atomic_commit *state, bool nonblock) { int ret = -EBUSY; @@ -333,7 +333,7 @@ int nv_drm_atomic_commit(struct drm_device *dev, } } -#if defined(NV_DRM_ATOMIC_STATE_REF_COUNTING_PRESENT) +#if defined(NV_DRM_ATOMIC_COMMIT_REF_COUNTING_PRESENT) /* * If ref counting is present, state will be freed when the caller * drops its reference after we return. diff --git a/kernel/nvidia-drm/nvidia-drm-modeset.h b/kernel/nvidia-drm/nvidia-drm-modeset.h index effb990..418891e 100644 --- a/kernel/nvidia-drm/nvidia-drm-modeset.h +++ b/kernel/nvidia-drm/nvidia-drm-modeset.h @@ -30,17 +30,17 @@ #include "nvkms-kapi.h" struct drm_device; -struct drm_atomic_state; +struct drm_atomic_commit; -struct drm_atomic_state *nv_drm_atomic_state_alloc(struct drm_device *dev); -void nv_drm_atomic_state_clear(struct drm_atomic_state *state); -void nv_drm_atomic_state_free(struct drm_atomic_state *state); +struct drm_atomic_commit *nv_drm_atomic_state_alloc(struct drm_device *dev); +void nv_drm_atomic_state_clear(struct drm_atomic_commit *state); +void nv_drm_atomic_state_free(struct drm_atomic_commit *state); int nv_drm_atomic_check(struct drm_device *dev, - struct drm_atomic_state *state); + struct drm_atomic_commit *state); int nv_drm_atomic_commit(struct drm_device *dev, - struct drm_atomic_state *state, bool nonblock); + struct drm_atomic_commit *state, bool nonblock); void nv_drm_handle_flip_occurred(struct nv_drm_device *nv_dev, diff --git a/kernel/nvidia-drm/nvidia-drm-priv.h b/kernel/nvidia-drm/nvidia-drm-priv.h index 953c2eb..df7db28 100644 --- a/kernel/nvidia-drm/nvidia-drm-priv.h +++ b/kernel/nvidia-drm/nvidia-drm-priv.h @@ -25,6 +25,17 @@ #include "nvidia-drm-conftest.h" /* NV_DRM_AVAILABLE */ +#include + +// Rel. commit "drm: Rename struct drm_atomic_state to drm_atomic_commit" (Maxime Ripard, 27 Apr 2026) +#if LINUX_VERSION_CODE < KERNEL_VERSION(7, 2, 0) +#define drm_atomic_commit drm_atomic_state +#define drm_atomic_commit_init drm_atomic_state_init +#define drm_atomic_commit_free drm_atomic_state_free +#define drm_atomic_commit_default_clear drm_atomic_state_default_clear +#define drm_atomic_commit_default_release drm_atomic_state_default_release +#endif + #if defined(NV_DRM_AVAILABLE) #if defined(NV_DRM_DRMP_H_PRESENT) diff --git a/kernel/nvidia-drm/nvidia-drm.Kbuild b/kernel/nvidia-drm/nvidia-drm.Kbuild index e283874..04e163e 100644 --- a/kernel/nvidia-drm/nvidia-drm.Kbuild +++ b/kernel/nvidia-drm/nvidia-drm.Kbuild @@ -57,7 +57,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_reinit_primary_mode_group NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_user_pages_remote NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_user_pages NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_gem_object_lookup -NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_atomic_state_ref_counting +NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_atomic_commit_ref_counting NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_driver_has_gem_prime_res_obj NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_atomic_helper_connector_dpms NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_connector_funcs_have_mode_in_name @@ -99,9 +99,9 @@ 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_callbacks -NV_CONFTEST_TYPE_COMPILE_TESTS += drm_crtc_atomic_check_has_atomic_state_arg +NV_CONFTEST_TYPE_COMPILE_TESTS += drm_crtc_atomic_check_has_atomic_commit_arg NV_CONFTEST_TYPE_COMPILE_TESTS += drm_gem_object_vmap_has_map_arg -NV_CONFTEST_TYPE_COMPILE_TESTS += drm_plane_atomic_check_has_atomic_state_arg +NV_CONFTEST_TYPE_COMPILE_TESTS += drm_plane_atomic_check_has_atomic_commit_arg NV_CONFTEST_TYPE_COMPILE_TESTS += drm_device_has_pdev NV_CONFTEST_TYPE_COMPILE_TESTS += dma_resv_add_fence NV_CONFTEST_TYPE_COMPILE_TESTS += dma_resv_reserve_fences diff --git a/kernel/nvidia-modeset/nvidia-modeset-linux.c b/kernel/nvidia-modeset/nvidia-modeset-linux.c index 4042687..aee5923 100644 --- a/kernel/nvidia-modeset/nvidia-modeset-linux.c +++ b/kernel/nvidia-modeset/nvidia-modeset-linux.c @@ -181,7 +181,18 @@ int NVKMS_API_CALL nvkms_strcmp(const char *s1, const char *s2) char* NVKMS_API_CALL nvkms_strncpy(char *dest, const char *src, size_t n) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 2, 0) + // Rel. commit "string: Remove strncpy() from the kernel" (Kees Cook, 18 Jun 2026) + // Open-coded strncpy(). + size_t i; + for (i = 0; i < n && src[i] != '\0'; i++) + dest[i] = src[i]; + for (; i < n; i++) + dest[i] = '\0'; + return dest; +#else return strncpy(dest, src, n); +#endif } void NVKMS_API_CALL nvkms_usleep(NvU64 usec) diff --git a/kernel/nvidia/nv-gpu-numa.c b/kernel/nvidia/nv-gpu-numa.c index 7916d35..b1aef08 100644 --- a/kernel/nvidia/nv-gpu-numa.c +++ b/kernel/nvidia/nv-gpu-numa.c @@ -158,8 +158,13 @@ static int filldir_get_memblock_id(struct dir_context *ctx, if (name_len + 1 > BUF_SIZE) return -ERANGE; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 2, 0) + // Rel. commit "string: Remove strncpy() from the kernel" (Kees Cook, 18 Jun 2026) + strscpy(name_copy, name, name_len + 1); +#else strncpy(name_copy, name, name_len); *(name_copy + name_len) = '\0'; +#endif // Convert the memory block ID into an integer if (kstrtoull(name_copy + strlen(MEMBLOCK_PREFIX), 0, &memblock_id) != 0) diff --git a/kernel/nvidia/os-interface.c b/kernel/nvidia/os-interface.c index 87780ad..432186d 100644 --- a/kernel/nvidia/os-interface.c +++ b/kernel/nvidia/os-interface.c @@ -642,8 +642,13 @@ NvU32 NV_API_CALL os_get_current_process(void) void NV_API_CALL os_get_current_process_name(char *buf, NvU32 len) { task_lock(current); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(7, 2, 0) + // Rel. commit "string: Remove strncpy() from the kernel" (Kees Cook, 18 Jun 2026) + strscpy(buf, current->comm, len); +#else strncpy(buf, current->comm, len - 1); buf[len - 1] = '\0'; +#endif task_unlock(current); }