Skip to content

Add Linux Kernel 7.2 support - #1227

Closed
ThePedroo wants to merge 3 commits into
NVIDIA:mainfrom
ThePedroo:main
Closed

Add Linux Kernel 7.2 support#1227
ThePedroo wants to merge 3 commits into
NVIDIA:mainfrom
ThePedroo:main

Conversation

@ThePedroo

Copy link
Copy Markdown

This PR replaces strncpy with strscpy (removed in 7.2 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1a3746ccbb0a97bed3c06ccde6b880013b1dddc1) and adds a conftest to handle a 7.2 commit (https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5164f7e7ff8e) also renaming drm_atomic_state to drm_atomic_commit.

One of strncpy was replaced with memcpy as it is more appropriate than strscpy.

ThePedroo added 2 commits July 1, 2026 01:01
This commit replaces all usages of "strncpy" to use "strscpy". Since Linux 7.2-rc.1, "strncpy" has been fully removed from the source, and cannot be used by drivers anymore (see https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1a3746ccbb0a97bed3c06ccde6b880013b1dddc1). We also replace one of the "strncpy" for "memcpy", since "strscpy" is not suitable either here, due to always NUL terminate.
This commit addresses the rename (see https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5164f7e7ff8e) by adding a new conftest to see if it was renamed, and if so, use it.
@CLAassistant

CLAassistant commented Jul 2, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

…_version`

This commit fixes a bug introduced by the previous strncpy→strscpy conversion in nvswitch.c. The `strscpy` call was incorrectly passed `VERSION_LENGTH` (which is `strlen(NV_VERSION_STRING)` without the NUL terminator) as the destination buffer size. `strscpy` expects the full buffer size including space for the NUL terminator, so the version string was silently truncated by one character, causing the version compatibility check to always fail.

Fix it by passing `length` (the caller-provided buffer size) instead.
@lucasdemarchi

Copy link
Copy Markdown

610.57.04 has the fixes for both missing strscpy and drm_atomic_state

@ThePedroo

Copy link
Copy Markdown
Author

Yeah, they kinda just forget PRs and let them rot. Very embarrassing.

@ThePedroo ThePedroo closed this Aug 5, 2026
plopresti added a commit to plopresti/open-gpu-kernel-modules that referenced this pull request Aug 5, 2026
nv_alloc_system_pages() sets pages to UC only after the whole array is
allocated. On an out-of-memory partial allocation it jumps to failed: ->
nv_free_system_pages() before that, which then calls
nv_set_memory_type(at, NV_MEMORY_WRITEBACK) based on the requested
at->cache_type.

nv_set_memory_type() iterates over all at->num_pages with no
unallocated-slot guard, unlike the two loops in nv_free_system_pages()
that break at page_ptr->virt_addr == 0. For a large descriptor that
failed early, most slots are unallocated (phys_addr == 0), so
NV_GET_PAGE_STRUCT(0) yields PFN 0 and set_memory_wb()/
set_memory_array_wb() is invoked on [0x0-0xfff] once per slot. This
floods the kernel log with "x86/PAT: freeing invalid memtype
[mem 0x0-0xfff]" and spins in an O(num_pages) TLB-flushing loop while
holding the RM API write lock (rmapiLockAcquire in serverAllocResource),
deadlocking all other threads until reboot.

Bound the cache-type reset to actually-allocated pages by breaking at the
first virt_addr == 0, mirroring the existing guards in
nv_free_system_pages(). Fully-allocated frees are unaffected; an OOM now
returns NV_ERR_NO_MEMORY cleanly instead of wedging the system.

Fixes NVIDIA#1227

Signed-off-by: Patrick LoPresti <lopresti@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants