mirror of
https://github.com/ublue-os/akmods.git
synced 2026-11-03 23:09:54 -09:00
feat: Patch nvidia-open for gamemode during build (#579)
This commit is contained in:
parent
4403fec091
commit
4ccd2e3618
2 changed files with 100 additions and 0 deletions
|
|
@ -22,6 +22,57 @@ if [[ "${KMOD_REPO}" =~ "lts" ]]; then
|
|||
fi
|
||||
DEPRECATED_RELEASE="${DIST}.${ARCH}"
|
||||
|
||||
# Applies patches for the current kernel flavor.
|
||||
# Patches can be optionally placed in build_files/nvidia/patches/{flavor}/
|
||||
# and will be applied alphanumerically if present.
|
||||
patch_nvidia_kmod_source() {
|
||||
local patch_dir="/tmp/patches/${KERNEL_FLAVOR}"
|
||||
local topdir="/tmp/nvidia-kmod-patched"
|
||||
local patches=() tarball srcdir patched_srpm patch
|
||||
|
||||
[[ -d "${patch_dir}" ]] || return 0
|
||||
mapfile -t patches < <(find "${patch_dir}" -maxdepth 1 -name '*.patch' | sort)
|
||||
(( ${#patches[@]} )) || return 0
|
||||
|
||||
echo "Applying ${#patches[@]} ${KERNEL_FLAVOR} patch(es) to nvidia-kmod source"
|
||||
|
||||
rm -rf "${topdir}"
|
||||
rpm -i --define "_topdir ${topdir}" /usr/src/akmods/nvidia-kmod.latest
|
||||
|
||||
tarball="$(find "${topdir}/SOURCES" -maxdepth 1 -name 'open-gpu-kernel-modules-*.tar.gz' -print -quit)"
|
||||
if [[ -z "${tarball}" ]]; then
|
||||
echo "ERROR: no open-gpu-kernel-modules tarball in ${topdir}/SOURCES" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
srcdir="$(basename "${tarball}" .tar.gz)"
|
||||
|
||||
pushd "${topdir}/SOURCES" > /dev/null
|
||||
tar xzf "${tarball}"
|
||||
if [[ ! -d "${srcdir}" ]]; then
|
||||
echo "ERROR: ${tarball##*/} did not unpack into ${srcdir}/" >&2
|
||||
exit 1
|
||||
fi
|
||||
for patch in "${patches[@]}"; do
|
||||
echo " ${patch##*/}"
|
||||
patch -p1 -F0 -d "${srcdir}" < "${patch}"
|
||||
done
|
||||
tar czf "${tarball}.new" "${srcdir}"
|
||||
mv "${tarball}.new" "${tarball}"
|
||||
rm -rf "${srcdir}"
|
||||
popd > /dev/null
|
||||
|
||||
rpmbuild -bs --define "_topdir ${topdir}" "${topdir}/SPECS/nvidia-kmod.spec"
|
||||
|
||||
patched_srpm="$(find "${topdir}/SRPMS" -maxdepth 1 -name 'nvidia-kmod-*.src.rpm' -print -quit)"
|
||||
if [[ -z "${patched_srpm}" ]]; then
|
||||
echo "ERROR: rpmbuild produced no patched SRPM in ${topdir}/SRPMS" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ln -sfn "${patched_srpm}" /usr/src/akmods/nvidia-kmod.latest
|
||||
}
|
||||
|
||||
cd /tmp
|
||||
|
||||
### BUILD nvidia
|
||||
|
|
@ -39,6 +90,8 @@ rpm -qa |grep nvidia
|
|||
KERNEL_VERSION="$(rpm -q "${KERNEL_NAME}" --queryformat '%{VERSION}-%{RELEASE}.%{ARCH}')"
|
||||
NVIDIA_AKMOD_VERSION="$(basename "$(rpm -q "akmod-nvidia" --queryformat '%{VERSION}-%{RELEASE}')" ".${DIST}")"
|
||||
|
||||
patch_nvidia_kmod_source
|
||||
|
||||
akmods --force --kernels "${KERNEL_VERSION}" --kmod "nvidia"
|
||||
|
||||
modinfo /usr/lib/modules/"${KERNEL_VERSION}"/extra/nvidia/nvidia{,-drm,-modeset,-peermem,-uvm}.ko.xz > /dev/null || \
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
From 6c4728b1f422d2cc6cfe4656defde2b8beb4ed1f Mon Sep 17 00:00:00 2001
|
||||
From: Matthew Schwartz <matthew.schwartz@linux.dev>
|
||||
Date: Tue, 18 Aug 2026 15:56:23 -0700
|
||||
Subject: [PATCH] Honor RMDisableNoncontigAlloc in the PMA vidmem path
|
||||
|
||||
The RMDisableNoncontigAlloc registry key clears
|
||||
bAllowNoncontiguousAllocation, but the flag is only consulted by
|
||||
vidmemAllocResources() and heapAlloc() on the legacy heap path.
|
||||
_vidmemPmaAllocate() decides contiguity from the client's PHYSICALITY
|
||||
attribute alone and silently retries a failed contiguous allocation as
|
||||
noncontiguous, so the key has no effect on PMA-managed framebuffer
|
||||
heaps, which covers every modern GPU.
|
||||
|
||||
Consult the flag in the PMA path as well. When noncontiguous
|
||||
allocation is disabled, allocate contiguously regardless of the
|
||||
requested physicality and skip the noncontiguous retry, so the
|
||||
allocation fails cleanly instead of silently degrading.
|
||||
---
|
||||
src/nvidia/src/kernel/mem_mgr/video_mem.c | 8 +++++++-
|
||||
1 file changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/nvidia/src/kernel/mem_mgr/video_mem.c b/src/nvidia/src/kernel/mem_mgr/video_mem.c
|
||||
index b8098d3df0..1c1e0decc5 100644
|
||||
--- a/src/nvidia/src/kernel/mem_mgr/video_mem.c
|
||||
+++ b/src/nvidia/src/kernel/mem_mgr/video_mem.c
|
||||
@@ -161,6 +161,12 @@ _vidmemPmaAllocate
|
||||
pAllocData->attr);
|
||||
}
|
||||
|
||||
+ // RMDisableNoncontigAlloc applies to PMA-managed heaps too, not just heapAlloc().
|
||||
+ if (!pMemoryManager->bAllowNoncontiguousAllocation)
|
||||
+ {
|
||||
+ bContig = NV_TRUE;
|
||||
+ }
|
||||
+
|
||||
NV_PRINTF(LEVEL_INFO, "PMA input\n");
|
||||
NV_PRINTF(LEVEL_INFO, " Owner: 0x%x\n", pAllocData->owner);
|
||||
NV_PRINTF(LEVEL_INFO, " hMemory: 0x%x\n", pAllocRequest->hMemory);
|
||||
@@ -324,7 +330,7 @@ _vidmemPmaAllocate
|
||||
portMemFree(pAllocRequest->pPmaAllocInfo[subdevInst]);
|
||||
pAllocRequest->pPmaAllocInfo[subdevInst] = NULL;
|
||||
|
||||
- if (bContig)
|
||||
+ if (bContig && pMemoryManager->bAllowNoncontiguousAllocation)
|
||||
{
|
||||
if (FLD_TEST_DRF(OS32, _ATTR, _PHYSICALITY, _ALLOW_NONCONTIGUOUS, pAllocData->attr) ||
|
||||
(FLD_TEST_DRF(OS32, _ATTR, _PHYSICALITY, _DEFAULT, pAllocData->attr) &&
|
||||
Loading…
Reference in a new issue