From 1475c2c6cb9b7a6d639c445633126280844443b6 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Sat, 6 Jan 2024 07:47:24 +0100 Subject: [PATCH] update to 390.157 added patches up to kernel 6.4 patch to ignore cc mismatch [release 390.157-1mamba;Thu Jul 27 2023] --- nvidia_390-390.157-ignore-cc-mismatch.patch | 11 ++ ...0.157-kenrel-4.16+-memory-encryption.patch | 33 ++++ nvidia_390-390.157-kernel-6.2.patch | 145 ++++++++++++++++++ nvidia_390-390.157-kernel-6.3.patch | 89 +++++++++++ nvidia_390-390.157-kernel-6.4.patch | 16 ++ nvidia_390.spec | 39 +++-- 6 files changed, 324 insertions(+), 9 deletions(-) create mode 100644 nvidia_390-390.157-ignore-cc-mismatch.patch create mode 100644 nvidia_390-390.157-kenrel-4.16+-memory-encryption.patch create mode 100644 nvidia_390-390.157-kernel-6.2.patch create mode 100644 nvidia_390-390.157-kernel-6.3.patch create mode 100644 nvidia_390-390.157-kernel-6.4.patch diff --git a/nvidia_390-390.157-ignore-cc-mismatch.patch b/nvidia_390-390.157-ignore-cc-mismatch.patch new file mode 100644 index 0000000..ebf4357 --- /dev/null +++ b/nvidia_390-390.157-ignore-cc-mismatch.patch @@ -0,0 +1,11 @@ +--- NVIDIA-Linux-x86_64-390.157/kernel/conftest.sh.orig 2022-10-11 18:00:50.000000000 +0200 ++++ NVIDIA-Linux-x86_64-390.157/kernel/conftest.sh 2023-07-27 17:40:56.108522499 +0200 +@@ -4772,7 +4772,7 @@ + echo "The kernel was built with ${kernel_cc_string}, but the" \ + "current compiler version is `$CC --version | head -n 1`."; + fi +- exit 1; ++ exit 0; + fi + ;; + diff --git a/nvidia_390-390.157-kenrel-4.16+-memory-encryption.patch b/nvidia_390-390.157-kenrel-4.16+-memory-encryption.patch new file mode 100644 index 0000000..737295c --- /dev/null +++ b/nvidia_390-390.157-kenrel-4.16+-memory-encryption.patch @@ -0,0 +1,33 @@ +diff --git a/kernel/common/inc/nv-linux.h b/kernel/common/inc/nv-linux.h +index 10fc418..22ef968 100644 +--- a/kernel/common/inc/nv-linux.h ++++ b/kernel/common/inc/nv-linux.h +@@ -174,7 +174,11 @@ static inline uid_t __kuid_val(kuid_t uid) + + #if defined(NV_VM_INSERT_PAGE_PRESENT) + #include ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0) + #include ++#else ++#include ++#endif + + #if defined(NV_LINUX_DMA_MAP_OPS_H_PRESENT) + #include +diff --git a/kernel/conftest.sh b/kernel/conftest.sh +index b23dbb4..42dc576 100755 +--- a/kernel/conftest.sh ++++ b/kernel/conftest.sh +@@ -2056,7 +2056,12 @@ compile_test() { + # Determine if the phys_to_dma function is present. + # + CODE=" ++ #include ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0) + #include ++#else ++ #include ++#endif + void conftest_phys_to_dma(void) { + phys_to_dma(); + }" diff --git a/nvidia_390-390.157-kernel-6.2.patch b/nvidia_390-390.157-kernel-6.2.patch new file mode 100644 index 0000000..bb85492 --- /dev/null +++ b/nvidia_390-390.157-kernel-6.2.patch @@ -0,0 +1,145 @@ +From 5db7eb5a62003bbe04f3f07d089fcf5445b34a29 Mon Sep 17 00:00:00 2001 +From: Joan Bruguera +Date: Sun, 25 Dec 2022 22:05:14 +0000 +Subject: [PATCH] Tentative fix for NVIDIA 470.161.03 driver for Linux 6.2-rc1 + +--- + kernel/nvidia-drm/nvidia-drm-connector.c | 22 ++++++++++++++++++++++ + kernel/nvidia-drm/nvidia-drm-drv.c | 4 ++++ + kernel/nvidia/nv-acpi.c | 19 ++++++++++++++++--- + 3 files changed, 42 insertions(+), 3 deletions(-) + +diff --git a/kernel/nvidia-drm/nvidia-drm-connector.c b/kernel/nvidia-drm/nvidia-drm-connector.c +index 6fbcd63..a5ab9e9 100644 +--- a/kernel/nvidia-drm/nvidia-drm-connector.c ++++ b/kernel/nvidia-drm/nvidia-drm-connector.c +@@ -20,6 +20,8 @@ + * DEALINGS IN THE SOFTWARE. + */ + ++#include ++#include + #include "nvidia-drm-conftest.h" /* NV_DRM_ATOMIC_MODESET_AVAILABLE */ + + #if defined(NV_DRM_ATOMIC_MODESET_AVAILABLE) +@@ -98,6 +100,7 @@ __nv_drm_detect_encoder(struct NvKmsKapiDynamicDisplayParams *pDetectParams, + break; + } + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0) + if (connector->override_edid) { + const struct drm_property_blob *edid = connector->edid_blob_ptr; + +@@ -110,6 +113,25 @@ __nv_drm_detect_encoder(struct NvKmsKapiDynamicDisplayParams *pDetectParams, + sizeof(pDetectParams->edid.buffer)); + } + } ++#else ++ // Rel. commit "drm/edid: detach debugfs EDID override from EDID property update" (Jani Nikula, 24 Oct 2022) ++ // NOTE: HUGE HACK! ++ mutex_lock(&connector->edid_override_mutex); ++ if (connector->edid_override) { ++ const struct edid *edid = drm_edid_raw(connector->edid_override); ++ size_t edid_length = EDID_LENGTH * (edid->extensions + 1); ++ if (edid_length <= sizeof(pDetectParams->edid.buffer)) { ++ memcpy(pDetectParams->edid.buffer, edid, edid_length); ++ pDetectParams->edid.bufferSize = edid_length; ++ pDetectParams->overrideEdid = NV_TRUE; ++ } else { ++ WARN_ON(edid_length > ++ sizeof(pDetectParams->edid.buffer)); ++ } ++ } ++ mutex_unlock(&connector->edid_override_mutex); ++ ++#endif + + if (!nvKms->getDynamicDisplayInfo(nv_dev->pDevice, pDetectParams)) { + NV_DRM_DEV_LOG_ERR( +diff --git a/kernel/nvidia-drm/nvidia-drm-drv.c b/kernel/nvidia-drm/nvidia-drm-drv.c +index 6d007b1..d08ab4c 100644 +--- a/kernel/nvidia-drm/nvidia-drm-drv.c ++++ b/kernel/nvidia-drm/nvidia-drm-drv.c +@@ -20,6 +20,7 @@ + * DEALINGS IN THE SOFTWARE. + */ + ++#include + #include "nvidia-drm-conftest.h" /* NV_DRM_AVAILABLE and NV_DRM_DRM_GEM_H_PRESENT */ + + #include "nvidia-drm-priv.h" +@@ -240,9 +241,12 @@ nv_drm_init_mode_config(struct nv_drm_device *nv_dev, + dev->mode_config.preferred_depth = 24; + dev->mode_config.prefer_shadow = 1; + ++// Rel. commit "drm: Remove drm_mode_config::fb_base" (Zack Rusin, 18 Oct 2022) ++#if defined(CONFIG_FB) && LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0) + /* Currently unused. Update when needed. */ + + dev->mode_config.fb_base = 0; ++#endif + + #if defined(NV_DRM_CRTC_STATE_HAS_ASYNC_FLIP) || \ + defined(NV_DRM_CRTC_STATE_HAS_PAGEFLIP_FLAGS) +diff --git a/kernel/nvidia/nv-acpi.c b/kernel/nvidia/nv-acpi.c +index 07501eb..1fdf71c 100644 +--- a/kernel/nvidia/nv-acpi.c ++++ b/kernel/nvidia/nv-acpi.c +@@ -8,6 +8,7 @@ + * _NVRM_COPYRIGHT_END_ + */ + ++#include + #define __NO_VERSION__ + + #include "os-interface.h" +@@ -24,7 +25,10 @@ static NV_STATUS nv_acpi_extract_object (const union acpi_object *, void *, N + + static int nv_acpi_add (struct acpi_device *); + +-#if !defined(NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT) || (NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT == 2) ++// Rel. commit "ACPI: make remove callback of ACPI driver void" (Dawei Li, 14 Nov 2022) ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 2, 0)) ++static void nv_acpi_remove_one_arg_void(struct acpi_device *device); ++#elif !defined(NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT) || (NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT == 2) + static int nv_acpi_remove_two_args(struct acpi_device *device, int type); + #else + static int nv_acpi_remove_one_arg(struct acpi_device *device); +@@ -80,7 +84,10 @@ static const struct acpi_driver nv_acpi_driver_template = { + .ids = nv_video_device_ids, + .ops = { + .add = nv_acpi_add, +-#if !defined(NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT) || (NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT == 2) ++// Rel. commit "ACPI: make remove callback of ACPI driver void" (Dawei Li, 14 Nov 2022) ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 2, 0)) ++ .remove = nv_acpi_remove_one_arg_void, ++#elif !defined(NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT) || (NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT == 2) + .remove = nv_acpi_remove_two_args, + #else + .remove = nv_acpi_remove_one_arg, +@@ -342,7 +349,10 @@ static int nv_acpi_add(struct acpi_device *device) + return 0; + } + +-#if !defined(NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT) || (NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT == 2) ++// Rel. commit "ACPI: make remove callback of ACPI driver void" (Dawei Li, 14 Nov 2022) ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 2, 0)) ++static void nv_acpi_remove_one_arg_void(struct acpi_device *device) ++#elif !defined(NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT) || (NV_ACPI_DEVICE_OPS_REMOVE_ARGUMENT_COUNT == 2) + static int nv_acpi_remove_two_args(struct acpi_device *device, int type) + #else + static int nv_acpi_remove_one_arg(struct acpi_device *device) +@@ -396,7 +406,10 @@ static int nv_acpi_remove_one_arg(struct acpi_device *device) + device->driver_data = NULL; + } + ++// Rel. commit "ACPI: make remove callback of ACPI driver void" (Dawei Li, 14 Nov 2022) ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0)) + return status; ++#endif + } + + /* +-- +2.39.0 + diff --git a/nvidia_390-390.157-kernel-6.3.patch b/nvidia_390-390.157-kernel-6.3.patch new file mode 100644 index 0000000..3927195 --- /dev/null +++ b/nvidia_390-390.157-kernel-6.3.patch @@ -0,0 +1,89 @@ +diff --git a/kernel/common/inc/nv-linux.h b/kernel/common/inc/nv-linux.h +index 2c4cb7b..f68fcf2 100644 +--- a/kernel/common/inc/nv-linux.h ++++ b/kernel/common/inc/nv-linux.h +@@ -1996,4 +1996,17 @@ static inline NvU64 nv_expand_nvlink_addr(NvU64 addr47) + #include + #endif + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0) ++// Rel. commit "mm: introduce vma->vm_flags wrapper functions" (Suren Baghdasaryan, 26 Jan 2023) ++static inline void vm_flags_set(struct vm_area_struct *vma, vm_flags_t flags) ++{ ++ vma->vm_flags |= flags; ++} ++ ++static inline void vm_flags_clear(struct vm_area_struct *vma, vm_flags_t flags) ++{ ++ vma->vm_flags &= ~flags; ++} ++#endif ++ + #endif /* _NV_LINUX_H_ */ +diff --git a/kernel/nvidia-drm/nvidia-drm-fb.c b/kernel/nvidia-drm/nvidia-drm-fb.c +index 725164a..c35e0ee 100644 +--- a/kernel/nvidia-drm/nvidia-drm-fb.c ++++ b/kernel/nvidia-drm/nvidia-drm-fb.c +@@ -29,6 +29,7 @@ + #include "nvidia-drm-fb.h" + #include "nvidia-drm-utils.h" + #include "nvidia-drm-gem.h" ++#include "nvidia-drm-helper.h" + + #include + +diff --git a/kernel/nvidia-uvm/uvm8.c b/kernel/nvidia-uvm/uvm8.c +index 11cb373..49e1047 100644 +--- a/kernel/nvidia-uvm/uvm8.c ++++ b/kernel/nvidia-uvm/uvm8.c +@@ -658,7 +658,7 @@ static int uvm_mmap(struct file *filp, struct vm_area_struct *vma) + // Using VM_DONTCOPY would be nice, but madvise(MADV_DOFORK) can reset that + // so we have to handle vm_open on fork anyway. We could disable MADV_DOFORK + // with VM_IO, but that causes other mapping issues. +- vma->vm_flags |= VM_MIXEDMAP | VM_DONTEXPAND; ++ vm_flags_set(vma, VM_MIXEDMAP | VM_DONTEXPAND); + + vma->vm_ops = &uvm_vm_ops_managed; + +diff --git a/kernel/nvidia/nv-mmap.c b/kernel/nvidia/nv-mmap.c +index 0b0a6f2..da891ff 100644 +--- a/kernel/nvidia/nv-mmap.c ++++ b/kernel/nvidia/nv-mmap.c +@@ -447,7 +447,7 @@ int nvidia_mmap_helper( + addr = mmap_start; + + // Needed for the linux kernel for mapping compound pages +- vma->vm_flags |= VM_MIXEDMAP; ++ vm_flags_set(vma, VM_MIXEDMAP); + + for (j = 0; j < pages; j++) + { +@@ -471,7 +471,7 @@ int nvidia_mmap_helper( + } + } + +- vma->vm_flags |= VM_IO; ++ vm_flags_set(vma, VM_IO); + } + else + { +@@ -533,15 +533,15 @@ int nvidia_mmap_helper( + + NV_PRINT_AT(NV_DBG_MEMINFO, at); + +- vma->vm_flags |= (VM_IO | VM_LOCKED | VM_RESERVED); +- vma->vm_flags |= (VM_DONTEXPAND | VM_DONTDUMP); ++ vm_flags_set(vma, VM_IO | VM_LOCKED | VM_RESERVED); ++ vm_flags_set(vma, VM_DONTEXPAND | VM_DONTDUMP); + } + + if ((prot & NV_PROTECT_WRITEABLE) == 0) + { + vma->vm_page_prot = NV_PGPROT_READ_ONLY(vma->vm_page_prot); +- vma->vm_flags &= ~VM_WRITE; +- vma->vm_flags &= ~VM_MAYWRITE; ++ vm_flags_clear(vma, VM_WRITE); ++ vm_flags_clear(vma, VM_MAYWRITE); + } + + vma->vm_ops = &nv_vm_ops; diff --git a/nvidia_390-390.157-kernel-6.4.patch b/nvidia_390-390.157-kernel-6.4.patch new file mode 100644 index 0000000..dfa433c --- /dev/null +++ b/nvidia_390-390.157-kernel-6.4.patch @@ -0,0 +1,16 @@ +diff --git a/kernel/nvidia-drm/nvidia-drm-drv.c b/kernel/nvidia-drm/nvidia-drm-drv.c +index e5dee49..caa9e8c 100644 +--- a/kernel/nvidia-drm/nvidia-drm-drv.c ++++ b/kernel/nvidia-drm/nvidia-drm-drv.c +@@ -766,7 +766,11 @@ static void nv_drm_update_drm_driver_features(void) + + nv_drm_driver.dumb_create = nv_drm_dumb_create; + nv_drm_driver.dumb_map_offset = nv_drm_dumb_map_offset; ++// Rel. commit "drm: remove dumb_destroy callback" (Christian König, 26 Jan 2023) ++// NB: No resources are leaked, the kernel releases the same resources by default ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0) + nv_drm_driver.dumb_destroy = nv_drm_dumb_destroy; ++#endif + + #if defined(NV_DRM_DRIVER_HAS_GEM_PRIME_CALLBACKS) + nv_drm_driver.gem_vm_ops = &nv_drm_gem_vma_ops; diff --git a/nvidia_390.spec b/nvidia_390.spec index f9ff02b..d07c35c 100644 --- a/nvidia_390.spec +++ b/nvidia_390.spec @@ -1,7 +1,7 @@ %define nvidia_current_ver %version %define nvidia_current_libver %version Name: nvidia_390 -Version: 390.143 +Version: 390.157 Epoch: 1 Release: 1mamba Summary: NVIDIA proprietary accelerated drivers for the Linux Kernel @@ -9,7 +9,7 @@ Group: System/Kernel and Hardware Vendor: openmamba Distribution: openmamba Packager: Silvan Calarco -URL: http://www.nvidia.com/object/unix.html +URL: https://www.nvidia.com/en-us/drivers/unix/ Source0: http://us.download.nvidia.com/XFree86/Linux-x86/%{version}/NVIDIA-Linux-x86-%{version}.run Source1: http://us.download.nvidia.com/XFree86/Linux-x86_64/%{version}/NVIDIA-Linux-x86_64-%{version}.run Source2: nvidia_390.sysusers @@ -17,6 +17,11 @@ Source3: nvidia_390-drm-outputclass.conf Patch0: nvidia-331.20-x86-conftest.patch Patch1: nvidia-367.35-kernel-4.6.patch Patch2: nvidia_390-390.143-kernel-5.12.patch +Patch3: nvidia_390-390.157-kernel-6.2.patch +Patch4: nvidia_390-390.157-kernel-6.3.patch +Patch5: nvidia_390-390.157-kernel-6.4.patch +Patch6: nvidia_390-390.157-ignore-cc-mismatch.patch +Patch7: nvidia_390-390.157-kenrel-4.16+-memory-encryption.patch License: no OSI Approved ## AUTOBUILDREQ-BEGIN BuildRequires: glibc-devel @@ -82,7 +87,7 @@ This package contains the HTML documentation. %prep %setup -q -c -n %{name}-%{version} -T - +%define _default_patch_fuzz 2 %global __provides_exclude ^(libGL\\.so.*|libEGL\\.so.*|libGLESv1_CM\\.so.*|libGLESv2\\.so.*|libOpenCL\\.so.*)$ # @@ -102,7 +107,13 @@ sed -i "s|__UTILS_PATH__|%{_bindir}|;s|__PIXMAP_PATH__|%{_datadir}/pixmaps|" \ cd current #%patch0 -p1 #%patch1 -p1 -%patch2 -p1 +#%patch 2 -p1 +%patch 7 -p1 -b .kenrel-4.16+-memory-encryption +%patch 3 -p1 -b .kernel-6.2 +%patch 4 -p1 -b .kernel-6.3 +%patch 5 -p1 -b .kernel-6.4 +%patch 6 -p1 + tar xf nvidia-persistenced-init.tar.bz2 cd .. @@ -218,6 +229,11 @@ sed -i "s|lib64|lib|g" %{buildroot}%{_datadir}/X11/xorg.conf.d/10-nvidia-drm-out install -Dm644 %{SOURCE2} %{buildroot}%{_sysusersdir}/nvidia.conf +# blacklist nouveau +install -d -m0755 %{buildroot}%{_modprobedir} +echo "blacklist nouveau +" > %{buildroot}%{_modprobedir}/%{name}.conf + ## Clutter workaround (http://blog.sukimashita.com/2015/04/13/gnome-3-16-and-nvidia-binary-driver-crash-with-totem-gnome-maps-cheese-and-others/) #mkdir -p %{buildroot}%{_sysconfdir}/profile.d/ #cat > %{buildroot}%{_sysconfdir}/profile.d/nvidia-clutter.sh << _EOF @@ -248,7 +264,6 @@ BUILT_MODULE_NAME[3]=nvidia-uvm BUILT_MODULE_LOCATION[3]=./ DEST_MODULE_LOCATION[3]=/kernel/drivers/video %endif -REMAKE_INITRD=no AUTOINSTALL=yes _EOF @@ -274,17 +289,17 @@ nvidia-uvm \ %clean [ "%{buildroot}" != / ] && rm -rf "%{buildroot}" -%post -n xorg-drv-video-%{name} +%posttrans -n xorg-drv-video-%{name} /sbin/ldconfig -# new install if [ $1 -ge 1 ]; then # clean any legacy alternatives symlink find /lib/modules/*/kernel/drivers/video/ -name nvidia.ko -type l -exec rm -f {} \; dkms add -q -m %{name} -v %{version} dkms install -q -m %{name} -v %{version} + /sbin/depmod -a -F /boot/System.map-%{kernel_ver}%{?KERNEL_TARGET} \ + %{kernel_ver}%{?KERNEL_TARGET} &>/dev/null + /usr/sbin/mkinitrd -f fi -/sbin/depmod -a -F /boot/System.map-%{kernel_ver}%{?KERNEL_TARGET} \ - %{kernel_ver}%{?KERNEL_TARGET} &>/dev/null : %preun -n xorg-drv-video-%{name} @@ -305,6 +320,7 @@ fi %{_prefix}/src/%{name}-%{version}/* %{_bindir}/nvidia-* %{_unitdir}/nvidia-persistenced.service +%{_modprobedir}/%{name}.conf %{_sysusersdir}/nvidia.conf %{_libdir}/libEGL_nvidia.so.* %{_libdir}/libGLESv1_CM_nvidia.so.* @@ -335,6 +351,11 @@ fi %doc current/{NVIDIA_Changelog,README.txt} current/html %changelog +* Thu Jul 27 2023 Silvan Calarco 390.157-1mamba +- update to 390.157 +- added patches up to kernel 6.4 +- patch to ignore cc mismatch + * Fri Apr 23 2021 Silvan Calarco 390.143-1mamba - update to 390.143 - repackaged with libglvnd and libmesa layout