From 7365aad6161ed2da1f31d6e30603346e8302d381 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Fri, 18 Oct 2024 10:28:03 +0100 Subject: x11-drivers/nvidia-drivers: add fbdev_ttm detection for kernel 6.11 (https://gitweb.gentoo.org/repo/gentoo.git/commit/x11-drivers/nvidia-drivers?id=86de42c9fddf3c7a693b77d3662a2677d2b402f3) --- ...idia-drivers-550.107.02-kernel-6.11-fbdev.patch | 186 ++++++++++ .../nvidia-drivers-550.107.02-r3.ebuild | 405 -------------------- .../nvidia-drivers-550.107.02-r4.ebuild | 406 +++++++++++++++++++++ 3 files changed, 592 insertions(+), 405 deletions(-) create mode 100644 x11-drivers/nvidia-drivers/files/nvidia-drivers-550.107.02-kernel-6.11-fbdev.patch delete mode 100644 x11-drivers/nvidia-drivers/nvidia-drivers-550.107.02-r3.ebuild create mode 100644 x11-drivers/nvidia-drivers/nvidia-drivers-550.107.02-r4.ebuild (limited to 'x11-drivers/nvidia-drivers') diff --git a/x11-drivers/nvidia-drivers/files/nvidia-drivers-550.107.02-kernel-6.11-fbdev.patch b/x11-drivers/nvidia-drivers/files/nvidia-drivers-550.107.02-kernel-6.11-fbdev.patch new file mode 100644 index 00000000..047078dd --- /dev/null +++ b/x11-drivers/nvidia-drivers/files/nvidia-drivers-550.107.02-kernel-6.11-fbdev.patch @@ -0,0 +1,186 @@ +diff '--color=auto' -Nur a/kernel/conftest.sh b/kernel/conftest.sh +--- a/kernel/conftest.sh 2024-07-24 23:57:19.000000000 +0100 ++++ b/kernel/conftest.sh 2024-10-18 10:22:27.367073132 +0100 +@@ -6593,6 +6593,25 @@ + compile_check_conftest "$CODE" "NV_DRM_FBDEV_GENERIC_SETUP_PRESENT" "" "functions" + ;; + ++ drm_fbdev_ttm_setup) ++ # ++ # Determine whether drm_fbdev_ttm_setup is present. ++ # ++ # Added by commit 9060d7f49376 ("drm/fb-helper: Finish the ++ # generic fbdev emulation") in v4.19. ++ # ++ CODE=" ++ #include ++ #if defined(NV_DRM_DRM_FBDEV_TTM_H_PRESENT) ++ #include ++ #endif ++ void conftest_drm_fbdev_ttm_setup(void) { ++ drm_fbdev_ttm_setup(); ++ }" ++ ++ compile_check_conftest "$CODE" "NV_DRM_FBDEV_TTM_SETUP_PRESENT" "" "functions" ++ ;; ++ + drm_aperture_remove_conflicting_pci_framebuffers) + # + # Determine whether drm_aperture_remove_conflicting_pci_framebuffers is present. +diff '--color=auto' -Nur a/kernel/header-presence-tests.mk b/kernel/header-presence-tests.mk +--- a/kernel/header-presence-tests.mk 2024-07-24 23:57:19.000000000 +0100 ++++ b/kernel/header-presence-tests.mk 2024-10-18 10:22:27.368073132 +0100 +@@ -15,6 +15,7 @@ + drm/drm_atomic_uapi.h \ + drm/drm_drv.h \ + drm/drm_fbdev_generic.h \ ++ drm/drm_fbdev_ttm.h \ + drm/drm_framebuffer.h \ + drm/drm_connector.h \ + drm/drm_probe_helper.h \ +diff '--color=auto' -Nur a/kernel/nvidia-drm/nvidia-drm-drv.c b/kernel/nvidia-drm/nvidia-drm-drv.c +--- a/kernel/nvidia-drm/nvidia-drm-drv.c 2024-07-25 00:22:50.000000000 +0100 ++++ b/kernel/nvidia-drm/nvidia-drm-drv.c 2024-10-18 10:22:27.368073132 +0100 +@@ -73,6 +73,10 @@ + #include + #endif + ++#if defined(NV_DRM_DRM_FBDEV_TTM_H_PRESENT) ++#include ++#endif ++ + #include + #include + +@@ -1823,7 +1827,11 @@ + drm_aperture_remove_conflicting_pci_framebuffers(pdev, nv_drm_driver.name); + #endif + } ++#if defined(NV_DRM_FBDEV_TTM_AVAILABLE) ++ drm_fbdev_ttm_setup(dev, 32); ++#else + drm_fbdev_generic_setup(dev, 32); ++#endif + } + #endif /* defined(NV_DRM_FBDEV_GENERIC_AVAILABLE) */ + +diff '--color=auto' -Nur a/kernel/nvidia-drm/nvidia-drm-os-interface.h b/kernel/nvidia-drm/nvidia-drm-os-interface.h +--- a/kernel/nvidia-drm/nvidia-drm-os-interface.h 2024-07-25 00:22:50.000000000 +0100 ++++ b/kernel/nvidia-drm/nvidia-drm-os-interface.h 2024-10-18 10:22:27.368073132 +0100 +@@ -58,8 +58,11 @@ + #error "Need to define kernel timer callback primitives for this OS" + #endif + +-#if defined(NV_DRM_FBDEV_GENERIC_SETUP_PRESENT) && defined(NV_DRM_APERTURE_REMOVE_CONFLICTING_PCI_FRAMEBUFFERS_PRESENT) ++#if (defined(NV_DRM_FBDEV_GENERIC_SETUP_PRESENT) || defined(NV_DRM_FBDEV_TTM_SETUP_PRESENT)) && defined(NV_DRM_APERTURE_REMOVE_CONFLICTING_PCI_FRAMEBUFFERS_PRESENT) + #define NV_DRM_FBDEV_GENERIC_AVAILABLE ++#if defined(NV_DRM_FBDEV_TTM_SETUP_PRESENT) ++#define NV_DRM_FBDEV_TTM_AVAILABLE ++#endif + #endif + + struct page; +diff '--color=auto' -Nur a/kernel/nvidia-drm/nvidia-drm-sources.mk b/kernel/nvidia-drm/nvidia-drm-sources.mk +--- a/kernel/nvidia-drm/nvidia-drm-sources.mk 2024-07-24 23:59:33.000000000 +0100 ++++ b/kernel/nvidia-drm/nvidia-drm-sources.mk 2024-10-18 10:22:27.368073132 +0100 +@@ -67,6 +67,7 @@ + NV_CONFTEST_FUNCTION_COMPILE_TESTS += sync_file_get_fence + NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_aperture_remove_conflicting_pci_framebuffers + NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_fbdev_generic_setup ++NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_fbdev_ttm_setup + NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_connector_attach_hdr_output_metadata_property + NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_helper_crtc_enable_color_mgmt + NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_crtc_enable_color_mgmt +diff '--color=auto' -Nur a/kernel-open/conftest.sh b/kernel-open/conftest.sh +--- a/kernel-open/conftest.sh 2024-07-24 23:57:19.000000000 +0100 ++++ b/kernel-open/conftest.sh 2024-10-18 10:22:27.369073132 +0100 +@@ -6593,6 +6593,25 @@ + compile_check_conftest "$CODE" "NV_DRM_FBDEV_GENERIC_SETUP_PRESENT" "" "functions" + ;; + ++ drm_fbdev_ttm_setup) ++ # ++ # Determine whether drm_fbdev_ttm_setup is present. ++ # ++ # Added by commit 9060d7f49376 ("drm/fb-helper: Finish the ++ # generic fbdev emulation") in v4.19. ++ # ++ CODE=" ++ #include ++ #if defined(NV_DRM_DRM_FBDEV_TTM_H_PRESENT) ++ #include ++ #endif ++ void conftest_drm_fbdev_ttm_setup(void) { ++ drm_fbdev_ttm_setup(); ++ }" ++ ++ compile_check_conftest "$CODE" "NV_DRM_FBDEV_TTM_SETUP_PRESENT" "" "functions" ++ ;; ++ + drm_aperture_remove_conflicting_pci_framebuffers) + # + # Determine whether drm_aperture_remove_conflicting_pci_framebuffers is present. +diff '--color=auto' -Nur a/kernel-open/header-presence-tests.mk b/kernel-open/header-presence-tests.mk +--- a/kernel-open/header-presence-tests.mk 2024-07-24 23:57:19.000000000 +0100 ++++ b/kernel-open/header-presence-tests.mk 2024-10-18 10:22:27.369073132 +0100 +@@ -15,6 +15,7 @@ + drm/drm_atomic_uapi.h \ + drm/drm_drv.h \ + drm/drm_fbdev_generic.h \ ++ drm/drm_fbdev_ttm.h \ + drm/drm_framebuffer.h \ + drm/drm_connector.h \ + drm/drm_probe_helper.h \ +diff '--color=auto' -Nur a/kernel-open/nvidia-drm/nvidia-drm-drv.c b/kernel-open/nvidia-drm/nvidia-drm-drv.c +--- a/kernel-open/nvidia-drm/nvidia-drm-drv.c 2024-07-25 00:22:48.000000000 +0100 ++++ b/kernel-open/nvidia-drm/nvidia-drm-drv.c 2024-10-18 10:22:27.370073132 +0100 +@@ -73,6 +73,10 @@ + #include + #endif + ++#if defined(NV_DRM_DRM_FBDEV_TTM_H_PRESENT) ++#include ++#endif ++ + #include + #include + +@@ -1823,7 +1827,11 @@ + drm_aperture_remove_conflicting_pci_framebuffers(pdev, nv_drm_driver.name); + #endif + } ++#if defined(NV_DRM_FBDEV_TTM_AVAILABLE) ++ drm_fbdev_ttm_setup(dev, 32); ++#else + drm_fbdev_generic_setup(dev, 32); ++#endif + } + #endif /* defined(NV_DRM_FBDEV_GENERIC_AVAILABLE) */ + +diff '--color=auto' -Nur a/kernel-open/nvidia-drm/nvidia-drm-os-interface.h b/kernel-open/nvidia-drm/nvidia-drm-os-interface.h +--- a/kernel-open/nvidia-drm/nvidia-drm-os-interface.h 2024-07-25 00:22:48.000000000 +0100 ++++ b/kernel-open/nvidia-drm/nvidia-drm-os-interface.h 2024-10-18 10:22:27.370073132 +0100 +@@ -58,8 +58,11 @@ + #error "Need to define kernel timer callback primitives for this OS" + #endif + +-#if defined(NV_DRM_FBDEV_GENERIC_SETUP_PRESENT) && defined(NV_DRM_APERTURE_REMOVE_CONFLICTING_PCI_FRAMEBUFFERS_PRESENT) ++#if (defined(NV_DRM_FBDEV_GENERIC_SETUP_PRESENT) || defined(NV_DRM_FBDEV_TTM_SETUP_PRESENT)) && defined(NV_DRM_APERTURE_REMOVE_CONFLICTING_PCI_FRAMEBUFFERS_PRESENT) + #define NV_DRM_FBDEV_GENERIC_AVAILABLE ++#if defined(NV_DRM_FBDEV_TTM_SETUP_PRESENT) ++#define NV_DRM_FBDEV_TTM_AVAILABLE ++#endif + #endif + + struct page; +diff '--color=auto' -Nur a/kernel-open/nvidia-drm/nvidia-drm-sources.mk b/kernel-open/nvidia-drm/nvidia-drm-sources.mk +--- a/kernel-open/nvidia-drm/nvidia-drm-sources.mk 2024-07-24 23:59:33.000000000 +0100 ++++ b/kernel-open/nvidia-drm/nvidia-drm-sources.mk 2024-10-18 10:22:27.370073132 +0100 +@@ -67,6 +67,7 @@ + NV_CONFTEST_FUNCTION_COMPILE_TESTS += sync_file_get_fence + NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_aperture_remove_conflicting_pci_framebuffers + NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_fbdev_generic_setup ++NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_fbdev_ttm_setup + NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_connector_attach_hdr_output_metadata_property + NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_helper_crtc_enable_color_mgmt + NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_crtc_enable_color_mgmt diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-550.107.02-r3.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-550.107.02-r3.ebuild deleted file mode 100644 index 001889c6..00000000 --- a/x11-drivers/nvidia-drivers/nvidia-drivers-550.107.02-r3.ebuild +++ /dev/null @@ -1,405 +0,0 @@ -# Copyright 1999-2024 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 - -inherit desktop flag-o-matic readme.gentoo-r1 -inherit systemd toolchain-funcs unpacker user-info - -NV_URI="https://download.nvidia.com/XFree86/" - -DESCRIPTION="NVIDIA Accelerated Graphics Driver" -HOMEPAGE="https://www.nvidia.com/download/index.aspx" -SRC_URI=" - ${NV_URI}Linux-x86_64/${PV}/NVIDIA-Linux-x86_64-${PV}.run - $(printf "${NV_URI}%s/%s-${PV}.tar.bz2 " \ - nvidia-{installer,modprobe,persistenced,xconfig}{,}) -" -# nvidia-installer is unused but here for GPL-2's "distribute sources" -S=${WORKDIR} - -LICENSE="NVIDIA-r2 Apache-2.0 BSD BSD-2 GPL-2 MIT ZLIB curl openssl" -SLOT="5" -KEYWORDS="-* amd64" -IUSE="abi_x86_32 abi_x86_64 +acpi +dkms +persistenced +powerd +tools +wayland +X" -RESTRICT="strip" - -COMMON_DEPEND=" - acct-group/video - X? ( x11-libs/libpciaccess ) - persistenced? ( - acct-user/nvpd - net-libs/libtirpc:= - ) -" -RDEPEND=" - ${COMMON_DEPEND} - dev-libs/openssl:0/3 - sys-libs/glibc - !!x11-drivers/nvidia-drivers:3 - !!x11-drivers/nvidia-drivers:4 - acpi? ( sys-power/acpid ) - dkms? ( ~sys-kernel/${PN}-dkms-${PV}:${SLOT} ) - X? ( - media-libs/libglvnd[X,abi_x86_32(-)?] - x11-libs/libX11[abi_x86_32(-)?] - x11-libs/libXext[abi_x86_32(-)?] - ) - powerd? ( sys-apps/dbus[abi_x86_32(-)?] ) - wayland? ( - gui-libs/egl-gbm - >=gui-libs/egl-wayland-1.1.10 - ) -" -DEPEND=" - ${COMMON_DEPEND} - x11-base/xorg-proto - x11-libs/libX11 - x11-libs/libXext -" -BDEPEND=" - sys-devel/m4 - virtual/pkgconfig -" -PDEPEND=" - tools? ( x11-misc/nvidia-settings:${SLOT} ) -" - -QA_PREBUILT="lib/firmware/* opt/bin/* usr/lib*" - -PATCHES=( - "${FILESDIR}"/nvidia-modprobe-390.141-uvm-perms.patch -) - -pkg_setup() { - local CONFIG_CHECK=" - PROC_FS - ~DRM_KMS_HELPER - ~SYSVIPC - ~!LOCKDEP - ~!SLUB_DEBUG_ON - !DEBUG_MUTEXES - $(usev powerd '~CPU_FREQ') - " - - local ERROR_DRM_KMS_HELPER="CONFIG_DRM_KMS_HELPER: is not set but required - for drivers (no custom config), and for wayland / nvidia-drm.modeset=1. - Cannot be directly selected in the kernel's menuconfig, and may need - selection of a DRM device even if unused, e.g. CONFIG_DRM_AMDGPU=m or - DRM_I915=y, DRM_NOUVEAU=m also acceptable if a module and not built-in." - - CONFIG_CHECK+=" X86_PAT" #817764 - - CONFIG_CHECK+=" MMU_NOTIFIER" #843827 - local ERROR_MMU_NOTIFIER="CONFIG_MMU_NOTIFIER: is not set but required. - Cannot be directly selected in the kernel's menuconfig, and may need - selection of another option that requires it such as CONFIG_KVM." -} - -src_prepare() { - # make patches usable across versions - rm nvidia-modprobe && mv nvidia-modprobe{-${PV},} || die - rm nvidia-persistenced && mv nvidia-persistenced{-${PV},} || die - rm nvidia-xconfig && mv nvidia-xconfig{-${PV},} || die - - default - - # prevent detection of incomplete kernel DRM support (bug #603818) - sed 's/defined(CONFIG_DRM/defined(CONFIG_DRM_KMS_HELPER/g' \ - -i kernel/conftest.sh || die - - # adjust service files - sed 's/__USER__/nvpd/' \ - nvidia-persistenced/init/systemd/nvidia-persistenced.service.template \ - > "${T}"/nvidia-persistenced.service || die - sed -i "s|/usr|${EPREFIX}/opt|" systemd/system/nvidia-powerd.service || die - - # use alternative vulkan icd option if USE=-X (bug #909181) - use X || sed -i 's/"libGLX/"libEGL/' nvidia_{layers,icd}.json || die - - # enable nvidia-drm.modeset=1 by default with USE=wayland - cp "${FILESDIR}"/nvidia-545.conf "${T}"/nvidia.conf || die - use !wayland || sed -i '/^#.*modeset=1$/s/^#//' "${T}"/nvidia.conf || die -} - -src_compile() { - tc-export AR CC CXX LD OBJCOPY OBJDUMP PKG_CONFIG - - local xnvflags=-fPIC #840389 - # lto static libraries tend to cause problems without fat objects - tc-is-lto && xnvflags+=" $(test-flags-CC -ffat-lto-objects)" - - NV_ARGS=( - PREFIX="${EPREFIX}"/usr - HOST_CC="$(tc-getBUILD_CC)" - HOST_LD="$(tc-getBUILD_LD)" - BUILD_GTK2LIB= - NV_USE_BUNDLED_LIBJANSSON=0 - NV_VERBOSE=1 DO_STRIP= MANPAGE_GZIP= OUTPUTDIR=out - WAYLAND_AVAILABLE=$(usex wayland 1 0) - XNVCTRL_CFLAGS="${xnvflags}" - ) - - use persistenced && emake "${NV_ARGS[@]}" -C nvidia-persistenced - - emake "${NV_ARGS[@]}" -C nvidia-modprobe - use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig -} - -src_install() { - local libdir=$(get_libdir) libdir32=$(ABI=x86 get_libdir) - - NV_ARGS+=( DESTDIR="${D}" LIBDIR="${ED}"/usr/${libdir} ) - - local -A paths=( - [APPLICATION_PROFILE]=/usr/share/nvidia - [CUDA_ICD]=/etc/OpenCL/vendors - [EGL_EXTERNAL_PLATFORM_JSON]=/usr/share/egl/egl_external_platform.d - [FIRMWARE]=/lib/firmware/nvidia/${PV} - [GBM_BACKEND_LIB_SYMLINK]=/usr/${libdir}/gbm - [GLVND_EGL_ICD_JSON]=/usr/share/glvnd/egl_vendor.d - [OPENGL_DATA]=/usr/share/nvidia - [VULKAN_ICD_JSON]=/usr/share/vulkan - [WINE_LIB]=/usr/${libdir}/nvidia/wine - [XORG_OUTPUTCLASS_CONFIG]=/usr/share/X11/xorg.conf.d - - [GLX_MODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules/extensions - [GLX_MODULE_SYMLINK]=/usr/${libdir}/xorg/modules - [XMODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules - ) - - local skip_files=( - $(usev !X "libGLX_nvidia libglxserver_nvidia") - libGLX_indirect # non-glvnd unused fallback - libnvidia-{gtk,wayland-client} nvidia-{settings,xconfig} # from source - libnvidia-egl-gbm 15_nvidia_gbm # gui-libs/egl-gbm - libnvidia-egl-wayland 10_nvidia_wayland # gui-libs/egl-wayland - libnvidia-pkcs11.so # using the openssl3 version instead - ) - local skip_modules=( - $(usev !X "nvfbc vdpau xdriver") - $(usev !dkms gsp) - $(usev !powerd powerd) - installer nvpd # handled separately / built from source - ) - local skip_types=( - GLVND_LIB GLVND_SYMLINK EGL_CLIENT.\* GLX_CLIENT.\* # media-libs/libglvnd - OPENCL_WRAPPER.\* # virtual/opencl - DOCUMENTATION DOT_DESKTOP .\*_SRC DKMS_CONF SYSTEMD_UNIT # handled separately / unused - ) - - local DOCS=( - README.txt NVIDIA_Changelog supported-gpus/supported-gpus.json - ) - local HTML_DOCS=( html/. ) - einstalldocs - - local DISABLE_AUTOFORMATTING=yes - local DOC_CONTENTS="\ -Trusted users should be in the 'video' group to use NVIDIA devices. -You can add yourself by using: gpasswd -a my-user video\ - -See '${EPREFIX}/etc/modprobe.d/nvidia.conf' for modules options.\ - -Note that without USE=abi_x86_32 on ${PN}, 32bit applications -(typically using wine / steam) will not be able to use GPU acceleration.\ - -For additional information or for troubleshooting issues, please see -https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers and NVIDIA's own -documentation that is installed alongside this README." - readme.gentoo_create_doc - - insinto /etc/modprobe.d - doins "${T}"/nvidia.conf - - emake "${NV_ARGS[@]}" -C nvidia-modprobe install - fowners :video /usr/bin/nvidia-modprobe #505092 - fperms 4710 /usr/bin/nvidia-modprobe - - if use persistenced; then - emake "${NV_ARGS[@]}" -C nvidia-persistenced install - newconfd "${FILESDIR}"/nvidia-persistenced.confd nvidia-persistenced - newinitd "${FILESDIR}"/nvidia-persistenced.initd nvidia-persistenced - systemd_dounit "${T}"/nvidia-persistenced.service - fi - - use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig install - - # mimic nvidia-installer by reading .manifest to install files - # 0:file 1:perms 2:type 3+:subtype/arguments -:module - local m into - while IFS=' ' read -ra m; do - ! [[ ${#m[@]} -ge 2 && ${m[-1]} =~ MODULE: ]] || - [[ " ${m[0]##*/}" =~ ^(\ ${skip_files[*]/%/.*|\\} )$ ]] || - [[ " ${m[2]}" =~ ^(\ ${skip_types[*]/%/|\\} )$ ]] || - has ${m[-1]#MODULE:} "${skip_modules[@]}" && continue - - case ${m[2]} in - MANPAGE) - gzip -dc ${m[0]} | newman - ${m[0]%.gz}; assert - continue - ;; - GBM_BACKEND_LIB_SYMLINK) m[4]=../${m[4]};; # missing ../ - VDPAU_SYMLINK) m[4]=vdpau/; m[5]=${m[5]#vdpau/};; # .so to vdpau/ - esac - - if [[ -v 'paths[${m[2]}]' ]]; then - into=${paths[${m[2]}]} - elif [[ ${m[2]} == EXPLICIT_PATH ]]; then - into=${m[3]} - elif [[ ${m[2]} == *_BINARY ]]; then - into=/opt/bin - elif [[ ${m[3]} == COMPAT32 ]]; then - use abi_x86_32 || continue - into=/usr/${libdir32} - elif [[ ${m[2]} == *_@(LIB|SYMLINK) ]]; then - into=/usr/${libdir} - else - die "No known installation path for ${m[0]}" - fi - [[ ${m[3]: -2} == ?/ ]] && into+=/${m[3]%/} - [[ ${m[4]: -2} == ?/ ]] && into+=/${m[4]%/} - - if [[ ${m[2]} =~ _SYMLINK$ ]]; then - [[ ${m[4]: -1} == / ]] && m[4]=${m[5]} - dosym ${m[4]} ${into}/${m[0]} - continue - fi - [[ ${m[0]} =~ ^libnvidia-ngx.so|^libnvidia-egl-gbm.so ]] && - dosym ${m[0]} ${into}/${m[0]%.so*}.so.1 # soname not in .manifest - - printf -v m[1] %o $((m[1] | 0200)) # 444->644 - insopts -m${m[1]} - insinto ${into} - doins ${m[0]} - done < .manifest || die - insopts -m0644 # reset - - # MODULE:installer non-skipped extras - : "$(systemd_get_sleepdir)" - exeinto "${_#"${EPREFIX}"}" - doexe systemd/system-sleep/nvidia - dobin systemd/nvidia-sleep.sh - systemd_dounit systemd/system/nvidia-{hibernate,resume,suspend}.service - - dobin nvidia-bug-report.sh - - # MODULE:powerd extras - if use powerd; then - newinitd "${FILESDIR}"/nvidia-powerd.initd nvidia-powerd #923117 - systemd_dounit systemd/system/nvidia-powerd.service - - insinto /usr/share/dbus-1/system.d - doins nvidia-dbus.conf - fi - - # enabling is needed for sleep to work properly and little reason not to do - # it unconditionally for a better user experience - : "$(systemd_get_systemunitdir)" - local unitdir=${_#"${EPREFIX}"} - # not using relative symlinks to match systemd's own links - dosym {"${unitdir}",/etc/systemd/system/systemd-hibernate.service.wants}/nvidia-hibernate.service - dosym {"${unitdir}",/etc/systemd/system/systemd-hibernate.service.wants}/nvidia-resume.service - dosym {"${unitdir}",/etc/systemd/system/systemd-suspend.service.wants}/nvidia-suspend.service - dosym {"${unitdir}",/etc/systemd/system/systemd-suspend.service.wants}/nvidia-resume.service - # also add a custom elogind hook to do the equivalent of the above - exeinto /usr/lib/elogind/system-sleep - newexe "${FILESDIR}"/system-sleep.elogind nvidia - # > \ - "${ED}/usr/lib/dracut/dracut.conf.d/10-${PN}.conf" || die -} - -_dracut_initramfs_regen() { - if [ -x $(which dracut) ]; then - dracut -N -f --no-hostonly-cmdline - fi -} - -pkg_preinst() { - # set video group id based on live system (bug #491414) - local g=$(egetent group video | cut -d: -f3) - [[ ${g} =~ ^[0-9]+$ ]] || die "Failed to determine video group id (got '${g}')" - sed -i "s/@VIDEOGID@/${g}/" "${ED}"/etc/modprobe.d/nvidia.conf || die -} - -pkg_postinst() { - if [ $(stat -c %d:%i /) == $(stat -c %d:%i /proc/1/root/.) ]; then - _dracut_initramfs_regen - fi - - readme.gentoo_print_elog - - if [[ $(/dev/null | wc -l) -gt 2 ]] - then - ewarn - ewarn "!!! WARNING !!!" - ewarn "Detected a custom script at ${EROOT}{/etc,{/usr,}/lib*}/elogind/system-sleep" - ewarn "referencing NVIDIA. This version of ${PN} has installed its own" - ewarn "hook at ${EROOT}/usr/lib/elogind/system-sleep/nvidia and it is recommended" - ewarn "to remove the custom one to avoid potential issues." - ewarn - ewarn "Feel free to ignore this warning if you know the other NVIDIA-related" - ewarn "scripts can be used together. The warning will be removed in the future." - fi - if [[ ${REPLACING_VERSIONS##* } ]] && - ver_test ${REPLACING_VERSIONS##* } -lt 470.256.02-r1 # may get repeated - then - elog - elog "For suspend/sleep, 'NVreg_PreserveVideoMemoryAllocations=1' is now default" - elog "with this version of ${PN}. This is recommended (or required) by" - elog "major DEs especially with wayland but, *if* experience regressions with" - elog "suspend, try reverting to =0 in '${EROOT}/etc/modprobe.d/nvidia.conf'." - elog - elog "May notably be an issue when using neither systemd nor elogind to suspend." - elog - elog "Also, the systemd suspend/hibernate/resume services are now enabled by" - elog "default, and for openrc+elogind a similar hook has been installed." - fi -} - -pkg_postrm() { - if [ $(stat -c %d:%i /) == $(stat -c %d:%i /proc/1/root/.) ]; then - _dracut_initramfs_regen - fi -} diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-550.107.02-r4.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-550.107.02-r4.ebuild new file mode 100644 index 00000000..cb0a33e8 --- /dev/null +++ b/x11-drivers/nvidia-drivers/nvidia-drivers-550.107.02-r4.ebuild @@ -0,0 +1,406 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit desktop flag-o-matic readme.gentoo-r1 +inherit systemd toolchain-funcs unpacker user-info + +NV_URI="https://download.nvidia.com/XFree86/" + +DESCRIPTION="NVIDIA Accelerated Graphics Driver" +HOMEPAGE="https://www.nvidia.com/download/index.aspx" +SRC_URI=" + ${NV_URI}Linux-x86_64/${PV}/NVIDIA-Linux-x86_64-${PV}.run + $(printf "${NV_URI}%s/%s-${PV}.tar.bz2 " \ + nvidia-{installer,modprobe,persistenced,xconfig}{,}) +" +# nvidia-installer is unused but here for GPL-2's "distribute sources" +S=${WORKDIR} + +LICENSE="NVIDIA-r2 Apache-2.0 BSD BSD-2 GPL-2 MIT ZLIB curl openssl" +SLOT="5" +KEYWORDS="-* amd64" +IUSE="abi_x86_32 abi_x86_64 +acpi +dkms +persistenced +powerd +tools +wayland +X" +RESTRICT="strip" + +COMMON_DEPEND=" + acct-group/video + X? ( x11-libs/libpciaccess ) + persistenced? ( + acct-user/nvpd + net-libs/libtirpc:= + ) +" +RDEPEND=" + ${COMMON_DEPEND} + dev-libs/openssl:0/3 + sys-libs/glibc + !!x11-drivers/nvidia-drivers:3 + !!x11-drivers/nvidia-drivers:4 + acpi? ( sys-power/acpid ) + dkms? ( ~sys-kernel/${PN}-dkms-${PV}:${SLOT} ) + X? ( + media-libs/libglvnd[X,abi_x86_32(-)?] + x11-libs/libX11[abi_x86_32(-)?] + x11-libs/libXext[abi_x86_32(-)?] + ) + powerd? ( sys-apps/dbus[abi_x86_32(-)?] ) + wayland? ( + gui-libs/egl-gbm + >=gui-libs/egl-wayland-1.1.10 + ) +" +DEPEND=" + ${COMMON_DEPEND} + x11-base/xorg-proto + x11-libs/libX11 + x11-libs/libXext +" +BDEPEND=" + sys-devel/m4 + virtual/pkgconfig +" +PDEPEND=" + tools? ( x11-misc/nvidia-settings:${SLOT} ) +" + +QA_PREBUILT="lib/firmware/* opt/bin/* usr/lib*" + +PATCHES=( + "${FILESDIR}"/nvidia-modprobe-390.141-uvm-perms.patch + "${FILESDIR}"/nvidia-drivers-550.107.02-kernel-6.11-fbdev.patch +) + +pkg_setup() { + local CONFIG_CHECK=" + PROC_FS + ~DRM_KMS_HELPER + ~SYSVIPC + ~!LOCKDEP + ~!SLUB_DEBUG_ON + !DEBUG_MUTEXES + $(usev powerd '~CPU_FREQ') + " + + local ERROR_DRM_KMS_HELPER="CONFIG_DRM_KMS_HELPER: is not set but required + for drivers (no custom config), and for wayland / nvidia-drm.modeset=1. + Cannot be directly selected in the kernel's menuconfig, and may need + selection of a DRM device even if unused, e.g. CONFIG_DRM_AMDGPU=m or + DRM_I915=y, DRM_NOUVEAU=m also acceptable if a module and not built-in." + + CONFIG_CHECK+=" X86_PAT" #817764 + + CONFIG_CHECK+=" MMU_NOTIFIER" #843827 + local ERROR_MMU_NOTIFIER="CONFIG_MMU_NOTIFIER: is not set but required. + Cannot be directly selected in the kernel's menuconfig, and may need + selection of another option that requires it such as CONFIG_KVM." +} + +src_prepare() { + # make patches usable across versions + rm nvidia-modprobe && mv nvidia-modprobe{-${PV},} || die + rm nvidia-persistenced && mv nvidia-persistenced{-${PV},} || die + rm nvidia-xconfig && mv nvidia-xconfig{-${PV},} || die + + default + + # prevent detection of incomplete kernel DRM support (bug #603818) + sed 's/defined(CONFIG_DRM/defined(CONFIG_DRM_KMS_HELPER/g' \ + -i kernel/conftest.sh || die + + # adjust service files + sed 's/__USER__/nvpd/' \ + nvidia-persistenced/init/systemd/nvidia-persistenced.service.template \ + > "${T}"/nvidia-persistenced.service || die + sed -i "s|/usr|${EPREFIX}/opt|" systemd/system/nvidia-powerd.service || die + + # use alternative vulkan icd option if USE=-X (bug #909181) + use X || sed -i 's/"libGLX/"libEGL/' nvidia_{layers,icd}.json || die + + # enable nvidia-drm.modeset=1 by default with USE=wayland + cp "${FILESDIR}"/nvidia-545.conf "${T}"/nvidia.conf || die + use !wayland || sed -i '/^#.*modeset=1$/s/^#//' "${T}"/nvidia.conf || die +} + +src_compile() { + tc-export AR CC CXX LD OBJCOPY OBJDUMP PKG_CONFIG + + local xnvflags=-fPIC #840389 + # lto static libraries tend to cause problems without fat objects + tc-is-lto && xnvflags+=" $(test-flags-CC -ffat-lto-objects)" + + NV_ARGS=( + PREFIX="${EPREFIX}"/usr + HOST_CC="$(tc-getBUILD_CC)" + HOST_LD="$(tc-getBUILD_LD)" + BUILD_GTK2LIB= + NV_USE_BUNDLED_LIBJANSSON=0 + NV_VERBOSE=1 DO_STRIP= MANPAGE_GZIP= OUTPUTDIR=out + WAYLAND_AVAILABLE=$(usex wayland 1 0) + XNVCTRL_CFLAGS="${xnvflags}" + ) + + use persistenced && emake "${NV_ARGS[@]}" -C nvidia-persistenced + + emake "${NV_ARGS[@]}" -C nvidia-modprobe + use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig +} + +src_install() { + local libdir=$(get_libdir) libdir32=$(ABI=x86 get_libdir) + + NV_ARGS+=( DESTDIR="${D}" LIBDIR="${ED}"/usr/${libdir} ) + + local -A paths=( + [APPLICATION_PROFILE]=/usr/share/nvidia + [CUDA_ICD]=/etc/OpenCL/vendors + [EGL_EXTERNAL_PLATFORM_JSON]=/usr/share/egl/egl_external_platform.d + [FIRMWARE]=/lib/firmware/nvidia/${PV} + [GBM_BACKEND_LIB_SYMLINK]=/usr/${libdir}/gbm + [GLVND_EGL_ICD_JSON]=/usr/share/glvnd/egl_vendor.d + [OPENGL_DATA]=/usr/share/nvidia + [VULKAN_ICD_JSON]=/usr/share/vulkan + [WINE_LIB]=/usr/${libdir}/nvidia/wine + [XORG_OUTPUTCLASS_CONFIG]=/usr/share/X11/xorg.conf.d + + [GLX_MODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules/extensions + [GLX_MODULE_SYMLINK]=/usr/${libdir}/xorg/modules + [XMODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules + ) + + local skip_files=( + $(usev !X "libGLX_nvidia libglxserver_nvidia") + libGLX_indirect # non-glvnd unused fallback + libnvidia-{gtk,wayland-client} nvidia-{settings,xconfig} # from source + libnvidia-egl-gbm 15_nvidia_gbm # gui-libs/egl-gbm + libnvidia-egl-wayland 10_nvidia_wayland # gui-libs/egl-wayland + libnvidia-pkcs11.so # using the openssl3 version instead + ) + local skip_modules=( + $(usev !X "nvfbc vdpau xdriver") + $(usev !dkms gsp) + $(usev !powerd powerd) + installer nvpd # handled separately / built from source + ) + local skip_types=( + GLVND_LIB GLVND_SYMLINK EGL_CLIENT.\* GLX_CLIENT.\* # media-libs/libglvnd + OPENCL_WRAPPER.\* # virtual/opencl + DOCUMENTATION DOT_DESKTOP .\*_SRC DKMS_CONF SYSTEMD_UNIT # handled separately / unused + ) + + local DOCS=( + README.txt NVIDIA_Changelog supported-gpus/supported-gpus.json + ) + local HTML_DOCS=( html/. ) + einstalldocs + + local DISABLE_AUTOFORMATTING=yes + local DOC_CONTENTS="\ +Trusted users should be in the 'video' group to use NVIDIA devices. +You can add yourself by using: gpasswd -a my-user video\ + +See '${EPREFIX}/etc/modprobe.d/nvidia.conf' for modules options.\ + +Note that without USE=abi_x86_32 on ${PN}, 32bit applications +(typically using wine / steam) will not be able to use GPU acceleration.\ + +For additional information or for troubleshooting issues, please see +https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers and NVIDIA's own +documentation that is installed alongside this README." + readme.gentoo_create_doc + + insinto /etc/modprobe.d + doins "${T}"/nvidia.conf + + emake "${NV_ARGS[@]}" -C nvidia-modprobe install + fowners :video /usr/bin/nvidia-modprobe #505092 + fperms 4710 /usr/bin/nvidia-modprobe + + if use persistenced; then + emake "${NV_ARGS[@]}" -C nvidia-persistenced install + newconfd "${FILESDIR}"/nvidia-persistenced.confd nvidia-persistenced + newinitd "${FILESDIR}"/nvidia-persistenced.initd nvidia-persistenced + systemd_dounit "${T}"/nvidia-persistenced.service + fi + + use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig install + + # mimic nvidia-installer by reading .manifest to install files + # 0:file 1:perms 2:type 3+:subtype/arguments -:module + local m into + while IFS=' ' read -ra m; do + ! [[ ${#m[@]} -ge 2 && ${m[-1]} =~ MODULE: ]] || + [[ " ${m[0]##*/}" =~ ^(\ ${skip_files[*]/%/.*|\\} )$ ]] || + [[ " ${m[2]}" =~ ^(\ ${skip_types[*]/%/|\\} )$ ]] || + has ${m[-1]#MODULE:} "${skip_modules[@]}" && continue + + case ${m[2]} in + MANPAGE) + gzip -dc ${m[0]} | newman - ${m[0]%.gz}; assert + continue + ;; + GBM_BACKEND_LIB_SYMLINK) m[4]=../${m[4]};; # missing ../ + VDPAU_SYMLINK) m[4]=vdpau/; m[5]=${m[5]#vdpau/};; # .so to vdpau/ + esac + + if [[ -v 'paths[${m[2]}]' ]]; then + into=${paths[${m[2]}]} + elif [[ ${m[2]} == EXPLICIT_PATH ]]; then + into=${m[3]} + elif [[ ${m[2]} == *_BINARY ]]; then + into=/opt/bin + elif [[ ${m[3]} == COMPAT32 ]]; then + use abi_x86_32 || continue + into=/usr/${libdir32} + elif [[ ${m[2]} == *_@(LIB|SYMLINK) ]]; then + into=/usr/${libdir} + else + die "No known installation path for ${m[0]}" + fi + [[ ${m[3]: -2} == ?/ ]] && into+=/${m[3]%/} + [[ ${m[4]: -2} == ?/ ]] && into+=/${m[4]%/} + + if [[ ${m[2]} =~ _SYMLINK$ ]]; then + [[ ${m[4]: -1} == / ]] && m[4]=${m[5]} + dosym ${m[4]} ${into}/${m[0]} + continue + fi + [[ ${m[0]} =~ ^libnvidia-ngx.so|^libnvidia-egl-gbm.so ]] && + dosym ${m[0]} ${into}/${m[0]%.so*}.so.1 # soname not in .manifest + + printf -v m[1] %o $((m[1] | 0200)) # 444->644 + insopts -m${m[1]} + insinto ${into} + doins ${m[0]} + done < .manifest || die + insopts -m0644 # reset + + # MODULE:installer non-skipped extras + : "$(systemd_get_sleepdir)" + exeinto "${_#"${EPREFIX}"}" + doexe systemd/system-sleep/nvidia + dobin systemd/nvidia-sleep.sh + systemd_dounit systemd/system/nvidia-{hibernate,resume,suspend}.service + + dobin nvidia-bug-report.sh + + # MODULE:powerd extras + if use powerd; then + newinitd "${FILESDIR}"/nvidia-powerd.initd nvidia-powerd #923117 + systemd_dounit systemd/system/nvidia-powerd.service + + insinto /usr/share/dbus-1/system.d + doins nvidia-dbus.conf + fi + + # enabling is needed for sleep to work properly and little reason not to do + # it unconditionally for a better user experience + : "$(systemd_get_systemunitdir)" + local unitdir=${_#"${EPREFIX}"} + # not using relative symlinks to match systemd's own links + dosym {"${unitdir}",/etc/systemd/system/systemd-hibernate.service.wants}/nvidia-hibernate.service + dosym {"${unitdir}",/etc/systemd/system/systemd-hibernate.service.wants}/nvidia-resume.service + dosym {"${unitdir}",/etc/systemd/system/systemd-suspend.service.wants}/nvidia-suspend.service + dosym {"${unitdir}",/etc/systemd/system/systemd-suspend.service.wants}/nvidia-resume.service + # also add a custom elogind hook to do the equivalent of the above + exeinto /usr/lib/elogind/system-sleep + newexe "${FILESDIR}"/system-sleep.elogind nvidia + # > \ + "${ED}/usr/lib/dracut/dracut.conf.d/10-${PN}.conf" || die +} + +_dracut_initramfs_regen() { + if [ -x $(which dracut) ]; then + dracut -N -f --no-hostonly-cmdline + fi +} + +pkg_preinst() { + # set video group id based on live system (bug #491414) + local g=$(egetent group video | cut -d: -f3) + [[ ${g} =~ ^[0-9]+$ ]] || die "Failed to determine video group id (got '${g}')" + sed -i "s/@VIDEOGID@/${g}/" "${ED}"/etc/modprobe.d/nvidia.conf || die +} + +pkg_postinst() { + if [ $(stat -c %d:%i /) == $(stat -c %d:%i /proc/1/root/.) ]; then + _dracut_initramfs_regen + fi + + readme.gentoo_print_elog + + if [[ $(/dev/null | wc -l) -gt 2 ]] + then + ewarn + ewarn "!!! WARNING !!!" + ewarn "Detected a custom script at ${EROOT}{/etc,{/usr,}/lib*}/elogind/system-sleep" + ewarn "referencing NVIDIA. This version of ${PN} has installed its own" + ewarn "hook at ${EROOT}/usr/lib/elogind/system-sleep/nvidia and it is recommended" + ewarn "to remove the custom one to avoid potential issues." + ewarn + ewarn "Feel free to ignore this warning if you know the other NVIDIA-related" + ewarn "scripts can be used together. The warning will be removed in the future." + fi + if [[ ${REPLACING_VERSIONS##* } ]] && + ver_test ${REPLACING_VERSIONS##* } -lt 470.256.02-r1 # may get repeated + then + elog + elog "For suspend/sleep, 'NVreg_PreserveVideoMemoryAllocations=1' is now default" + elog "with this version of ${PN}. This is recommended (or required) by" + elog "major DEs especially with wayland but, *if* experience regressions with" + elog "suspend, try reverting to =0 in '${EROOT}/etc/modprobe.d/nvidia.conf'." + elog + elog "May notably be an issue when using neither systemd nor elogind to suspend." + elog + elog "Also, the systemd suspend/hibernate/resume services are now enabled by" + elog "default, and for openrc+elogind a similar hook has been installed." + fi +} + +pkg_postrm() { + if [ $(stat -c %d:%i /) == $(stat -c %d:%i /proc/1/root/.) ]; then + _dracut_initramfs_regen + fi +} -- cgit v1.2.3