summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: f31623c0fe25f1ec1be1e682ece48819fc5fca1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Maintainer: Vasiliy Stelmachenok <cabopust@yandex.ru>
# Contributor: Pavel Priluckiy <gerallitluis2@gmail.com>

# Includes application of the Powermizer-max-performance.patch
# USE AT YOUR OWN RISK!
_pref_maximum_performance=

pkgname=nvidia-dkms-performance
pkgver=460.39
pkgrel=4
pkgdesc='NVIDIA driver sources for linux with some optimizations'
arch=('x86_64')
url='https://www.nvidia.com/'
license=('custom')
provides=("nvidia=${pkgver}" "nvidia-dkms=${pkgver}" 
          "nvidia-dkms-performance=${pkgver}" 'NVIDIA-MODULE')
conflicts=('nvidia' 'nvidia-dkms')
_pkg="NVIDIA-Linux-${CARCH}-${pkgver}-no-compat32"
source=("https://us.download.nvidia.com/XFree86/Linux-${CARCH}/${pkgver}/${_pkg}.run"
        'nvidia.hook'
        '0001-nvidia-dkms-conf.patch'
        '0002-linux-rt.patch'
        '0003-nvidia-drm-modeset.patch'
        '0004-NVreg.patch'
        '0005-Powermizer-max-performance.patch')
sha256sums=('07042bd0c2f5c37b455a973f15561450f789590b8650a6ea573c819591d572a9'
            '717920f48b4d7ec50b83d2d096bab36449b30f1b5d144f0fe586627025367293'
            '1bd56d082093db9819b07f42c5414dffd1bcf92946d5f5dab706ed785933e169'
            'cf4ee7cbc4200126ff25d649d11257eb1c7ade4aa0b313f31b56207f9fa73d4b'
            'a9465149c336c8f0bded15a4d473f16156d6da3a9fe4965ebe8a9afba5519c9f'
            'd24e341f9a0e38f03f4e425e5f59e407604463fc3daee36009ecbd0fefa8b801'
            '9140aa5ea1b7c0704a2606b27a61af42b0309eceebac496704a9e8db18815aa4')

prepare() {
    [ -d "$_pkg" ] && rm -rf "$_pkg"
    
    sh "${_pkg}.run" --extract-only
    cd "${_pkg}"
    
    patch -Np1 -i "${srcdir}/0001-nvidia-dkms-conf.patch"
    # Fixing compatibility with the RT (Real-Time) kernel
    patch -Np1 -i "${srcdir}/0002-linux-rt.patch"
    # Enable nvidia-drm.modeset=1 (DRM KMS) by default.
    # This is necessary for NVIDIA PRIME to work correctly.
    # Note: May cause problems with scaling in console mode.
    patch -Np1 -i "${srcdir}/0003-nvidia-drm-modeset.patch"
    # This patch edits the default values of the NVIDIA kernel module
    # parameters, and makes the following changes:
    #
    # NVreg_UsePageAttributeTable=1 (Default 0) - Activating the better
    # memory management method (PAT). The PAT method creates a partition type table
    # at a specific address mapped inside the register and utilizes the memory architecture
    # and instruction set more efficiently and faster.
    # If your system can support this feature, it should improve CPU performance.
    #
    # NVreg_EnablePCIeGen3=1 (Default 0) - Enable PCIe Gen 3.x support.
    # If the system supports this 8GT high speed bus then enable it with this module option flag.
    # By default the Nvidia driver is set to use PCIe Gen 2.x for compatibility reasons.
    #
    # NVreg_InitializeSystemMemoryAllocations=0 (Default 1) - Disables
    # clearing system memory allocation before using it for the GPU.
    # Potentially improves performance, but at the cost of increased security risks.
    # Write "options nvidia NVreg_InitializeSystemMemoryAllocations=1" in /etc/modprobe.d/nvidia.conf,
    # if you want to return the default value.
    #
    # NVreg_EnableStreamMemOPs=1 (Default 0) - Activates the support for
    # CUDA Stream Memory Operations in user-mode applications.
    # 
    # If you want to learn more about the NVIDIA driver module parameters,
    # you can go to the Gentoo Wiki or view the source code of the nv-reg.h file.
    patch -Np1 -i "${srcdir}/0004-NVreg.patch"
    # Sets the default power plan in preference to maximum
    # performance. This is similar to the power plan settings in nvidia-
    # settings. The advantage of this method is that it controls the power
    # plan for each power source, i.e. the driver will be set for maximum
    # performance when running from the mains and for the battery it
    # will be set for optimal power savings. It also does not require nvidia-
    # settings as a dependency and does not use it in any way.
    if [ -n "$_pref_maximum_performance" ]; then
        patch -Np1 -i "${srcdir}/0005-Powermizer-max-performance.patch"
    fi
}

package() {
    depends=('dkms' "nvidia-utils>=${pkgver}" 'libglvnd')

    # Nvidia hook for update initramfs after an NVIDIA driver upgrade
    install -D -m644 "${srcdir}/nvidia.hook" -t "${pkgdir}/usr/share/libalpm/hooks"

    mkdir -p "${pkgdir}/usr/src"
    cp -dr --no-preserve='ownership' "${_pkg}/kernel" "${pkgdir}/usr/src/nvidia-${pkgver}"

    # Block Nouveau
    install -D -m644 <(printf '%s\n%s\n' 'blacklist nouveau' 'options nouveau modeset=0') \
        "${pkgdir}/usr/lib/modprobe.d/nvidia.conf"

    # license
    install -D -m644 "${_pkg}/LICENSE" -t "${pkgdir}/usr/share/licenses/${pkgname}"
}