git.iko.soy/typeable/nixpkgs
on master help sign in
amdgpu-pro: Init at 16.30.3-315407
commit3b4ce62451358882fb3f9bad5930fd13086223d1 authorDavid McFarland <corngood@gmail.com> dateWed 21 Sep 2016, 22:42 (10 years ago) parent44bc50c
14 files changed+779
nixos/modules/hardware/video/amdgpu-pro.nix+56 nixos/modules/module-list.nix+1 pkgs/os-specific/linux/amdgpu-pro/default.nix+155 pkgs/os-specific/linux/amdgpu-pro/patches/0001-add-OS-detection-for-arch.patch+26 pkgs/os-specific/linux/amdgpu-pro/patches/0002-update-kcl_ttm_bo_reserve-for-linux-4.7.patch+25 pkgs/os-specific/linux/amdgpu-pro/patches/0003-add-kcl_drm_gem_object_lookup.patch+204 pkgs/os-specific/linux/amdgpu-pro/patches/0004-paging-changes-for-linux-4.6.patch+42 pkgs/os-specific/linux/amdgpu-pro/patches/0005-LRU-stuff-isn-t-available-until-4.7.x.patch+48 pkgs/os-specific/linux/amdgpu-pro/patches/0006-Change-name-of-vblank_disable_allowed-to-vblank_disa.patch+29 pkgs/os-specific/linux/amdgpu-pro/patches/0007-Remove-connector-parameter-from-__drm_atomic_helper_.patch+29 pkgs/os-specific/linux/amdgpu-pro/patches/0008-fix-apparent-typo-in-bandwidth_calcs-causing-array-e.patch+25 pkgs/os-specific/linux/amdgpu-pro/patches/0009-disable-dal-by-default.patch+25 pkgs/os-specific/linux/amdgpu-pro/patches/0010-remove-dependency-on-System.map.patch+112 pkgs/top-level/all-packages.nix+2
nixos/modules/hardware/video/amdgpu-pro.nixnew file+56
@@ -0,0 +1,56 @@
1+# This module provides the proprietary AMDGPU-PRO drivers.
2+
3+{ config, lib, pkgs, pkgs_i686, ... }:
4+
5+with lib;
6+
7+let
8+
9+ drivers = config.services.xserver.videoDrivers;
10+
11+ enabled = elem "amdgpu-pro" drivers;
12+
13+ package = config.boot.kernelPackages.amdgpu-pro;
14+ package32 = pkgs_i686.linuxPackages.amdgpu-pro.override { libsOnly = true; kernel = null; };
15+
16+ opengl = config.hardware.opengl;
17+
18+in
19+
20+{
21+
22+ config = mkIf enabled {
23+
24+ services.xserver.drivers = singleton
25+ { name = "amdgpu"; modules = [ package ]; libPath = [ package ]; };
26+
27+ hardware.opengl.package = package;
28+ hardware.opengl.package32 = package32;
29+
30+ boot.extraModulePackages = [ package ];
31+
32+ boot.blacklistedKernelModules = [ "radeon" ];
33+
34+ hardware.firmware = [ package ];
35+
36+ system.activationScripts.setup-amdgpu-pro = ''
37+ mkdir -p /run/lib
38+ ln -sfn ${package}/lib ${package.libCompatDir}
39+ '' + optionalString opengl.driSupport32Bit ''
40+ ln -sfn ${package32}/lib ${package32.libCompatDir}
41+ '';
42+
43+ environment.etc = {
44+ "amd/amdrc".source = package + "/etc/amd/amdrc";
45+ "amd/amdapfxx.blb".source = package + "/etc/amd/amdapfxx.blb";
46+ "gbm/gbm.conf".source = package + "/etc/gbm/gbm.conf";
47+ "OpenCL/vendors/amdocl64.icd".source = package + "/etc/OpenCL/vendors/amdocl64.icd";
48+ "vulkan/icd.d/amd_icd64.json".source = package + "/etc/vulkan/icd.d/amd_icd64.json";
49+ } // optionalAttrs opengl.driSupport32Bit {
50+ "OpenCL/vendors/amdocl32.icd".source = package32 + "/etc/OpenCL/vendors/amdocl32.icd";
51+ "vulkan/icd.d/amd_icd32.json".source = package32 + "/etc/vulkan/icd.d/amd_icd32.json";
52+ };
53+
54+ };
55+
56+}
nixos/modules/module-list.nix+1
@@ -38,6 +38,7 @@
3838 ./hardware/opengl.nix
3939 ./hardware/pcmcia.nix
4040 ./hardware/video/amdgpu.nix
41+ ./hardware/video/amdgpu-pro.nix
4142 ./hardware/video/ati.nix
4243 ./hardware/video/bumblebee.nix
4344 ./hardware/video/displaylink.nix
pkgs/os-specific/linux/amdgpu-pro/default.nixnew file+155
@@ -0,0 +1,155 @@
1+{ stdenv, fetchurl, elfutils, mesa_noglu
2+, xorg, patchelf, openssl, libdrm, libudev
3+, libxcb, libxshmfence, epoxy, perl, zlib
4+, libsOnly ? false, kernel ? null
5+}:
6+
7+assert (!libsOnly) -> kernel != null;
8+
9+with stdenv.lib;
10+
11+let
12+
13+ kernelDir = if libsOnly then null else kernel.dev;
14+
15+ inherit (mesa_noglu) driverLink;
16+
17+ bitness = if stdenv.is64bit then "64" else "32";
18+
19+ libArch =
20+ if stdenv.system == "i686-linux" then
21+ "i386-linux-gnu"
22+ else if stdenv.system == "x86_64-linux" then
23+ "x86_64-linux-gnu"
24+ else throw "amdgpu-pro is Linux only. Sorry. The build was stopped.";
25+
26+ libReplaceDir = "/usr/lib/${libArch}";
27+
28+in stdenv.mkDerivation rec {
29+
30+ version = "16.30";
31+ pname = "amdgpu-pro";
32+ build = "16.30.3-315407";
33+
34+ libCompatDir = "/run/lib/${libArch}";
35+
36+ name = pname + "-" + version + (optionalString (!libsOnly) "-${kernelDir.version}");
37+
38+ src = fetchurl {
39+ url =
40+ "https://www2.ati.com/drivers/linux/amdgpu-pro_${build}.tar.xz";
41+ sha256 = "97d6fb64617cf2cefe780e5fb83b29d8ee4e3e7886b71fe3d92b0113847b2354";
42+ curlOpts = "--referer http://support.amd.com/en-us/kb-articles/Pages/AMDGPU-PRO-Beta-Driver-for-Vulkan-Release-Notes.aspx";
43+ };
44+
45+ hardeningDisable = [ "pic" "format" ];
46+
47+ inherit libsOnly;
48+
49+ postUnpack = ''
50+ cd $sourceRoot
51+ mkdir root
52+ cd root
53+ for deb in ../*.deb; do echo $deb; ar p $deb data.tar.xz | tar -xJ; done
54+ sourceRoot=.
55+ '';
56+
57+ modulePatches = [
58+ ./patches/0001-add-OS-detection-for-arch.patch
59+ ./patches/0002-update-kcl_ttm_bo_reserve-for-linux-4.7.patch
60+ ./patches/0003-add-kcl_drm_gem_object_lookup.patch
61+ ./patches/0004-paging-changes-for-linux-4.6.patch
62+ ./patches/0005-LRU-stuff-isn-t-available-until-4.7.x.patch
63+ ./patches/0006-Change-name-of-vblank_disable_allowed-to-vblank_disa.patch
64+ ./patches/0007-Remove-connector-parameter-from-__drm_atomic_helper_.patch
65+ ./patches/0008-fix-apparent-typo-in-bandwidth_calcs-causing-array-e.patch
66+ ./patches/0009-disable-dal-by-default.patch
67+ ./patches/0010-remove-dependency-on-System.map.patch
68+ ];
69+
70+ patchPhase = optionalString (!libsOnly) ''
71+ pushd usr/src/amdgpu-pro-${build}
72+ for patch in $modulePatches; do echo $patch; patch -p1 < $patch; done
73+ popd
74+ '';
75+
76+ preBuild = optionalString (!libsOnly) ''
77+ makeFlags="$makeFlags M=$(pwd)/usr/src/amdgpu-pro-${build}"
78+ '';
79+
80+ postBuild = optionalString (!libsOnly) ''
81+ xz usr/src/amdgpu-pro-${build}/amd/amdgpu/amdgpu.ko
82+ '';
83+
84+ makeFlags = optionalString (!libsOnly)
85+ "-C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build modules";
86+
87+ depLibPath = makeLibraryPath [
88+ stdenv.cc.cc.lib xorg.libXext xorg.libX11 xorg.libXdamage xorg.libXfixes zlib
89+ xorg.libXxf86vm libxcb libxshmfence epoxy openssl libdrm elfutils libudev
90+ ];
91+
92+ installPhase = ''
93+ mkdir -p $out
94+ cp -r usr/bin $out/bin
95+ cp -r etc $out/etc
96+ cp -r usr/include $out/include
97+ cp -r usr/lib/${libArch} $out/lib
98+ mv $out/lib/amdgpu-pro/* $out/lib/
99+ rmdir $out/lib/amdgpu-pro
100+ cp -r usr/share $out/share
101+ '' + optionalString (!libsOnly) ''
102+ if [ -d $out/lib/xorg ]; then
103+ rm $out/lib/xorg
104+ mv $out/lib/1.18 $out/lib/xorg
105+ rm -r $out/lib/1.*
106+ fi
107+ cp -r lib/firmware $out/lib/firmware
108+ mkdir -p $out/lib/modules/${kernel.modDirVersion}/kernel/drivers/gpu/drm/amd/amdgpu/amdgpu.ko.xz
109+ cp usr/src/amdgpu-pro-${build}/amd/amdgpu/amdgpu.ko.xz $out/lib/modules/${kernel.modDirVersion}/kernel/drivers/gpu/drm/amd/amdgpu/amdgpu.ko.xz
110+ '' + ''
111+ interpreter="$(cat $NIX_CC/nix-support/dynamic-linker)"
112+ libPath="$out/lib:$out/lib/gbm:$depLibPath"
113+ echo patching with $interpreter $libPath
114+ for prog in "$out"/bin/*; do
115+ echo patching program $prog
116+ patchelf --interpreter "$interpreter" --set-rpath "$libPath" "$prog"
117+ done
118+ for lib in `find "$out/lib/" -name '*.so*'`; do
119+ echo patching library $lib
120+ patchelf --set-rpath "$libPath" "$lib"
121+ done
122+ '';
123+
124+ postFixup = assert (stringLength libReplaceDir == stringLength libCompatDir); ''
125+ libPath="$out/lib:$out/lib/gbm:$depLibPath"
126+ for lib in libgbm.so.1.0.0 ${optionalString (!libsOnly) "xorg/modules/drivers/amdgpu_drv.so"} amdvlk${bitness}.so vdpau/libvdpau_amdgpu.so; do
127+ if [ -e "$out/lib/$lib" ]; then
128+ patchelf --set-rpath "$libPath" "$out/lib/$lib"
129+ fi
130+ done
131+ for lib in libEGL.so.1 libGL.so.1.2 ${optionalString (!libsOnly) "xorg/modules/extensions/libglx.so"} dri/amdgpu_dri.so; do
132+ if [ -e "$out/lib/$lib" ]; then
133+ perl -pi -e 's:${libReplaceDir}:${libCompatDir}:g' "$out/lib/$lib"
134+ fi
135+ done
136+ substituteInPlace "$out/etc/vulkan/icd.d/amd_icd${bitness}.json" --replace "/usr/lib/${libArch}" "$out/lib"
137+ '';
138+
139+ buildInputs = [
140+ patchelf
141+ perl
142+ ];
143+
144+ enableParallelBuilding = true;
145+
146+ meta = with stdenv.lib; {
147+ description = "AMDGPU-PRO drivers";
148+ homepage = http://support.amd.com/en-us/kb-articles/Pages/AMDGPU-PRO-Beta-Driver-for-Vulkan-Release-Notes.aspx ;
149+ license = licenses.unfree;
150+ platforms = platforms.linux;
151+ maintainers = with maintainers; [ corngood ];
152+ # Copied from the nvidia default.nix to prevent a store collision.
153+ priority = 4;
154+ };
155+}
pkgs/os-specific/linux/amdgpu-pro/patches/0001-add-OS-detection-for-arch.patchnew file+26
@@ -0,0 +1,26 @@
1+From e78ede724fff53fc0220999f6381242142ce8c33 Mon Sep 17 00:00:00 2001
2+From: David McFarland <corngood@gmail.com>
3+Date: Sun, 21 Aug 2016 16:30:25 -0300
4+Subject: [PATCH 1/8] add OS detection for arch
5+
6+---
7+ amd/backport/Makefile | 3 +++
8+ 1 file changed, 3 insertions(+)
9+
10+diff --git a/amd/backport/Makefile b/amd/backport/Makefile
11+index 0c285ef..6447a15 100644
12+--- a/amd/backport/Makefile
13++++ b/amd/backport/Makefile
14+@@ -17,6 +17,9 @@ else ifeq ("ubuntu",$(OS_NAME))
15+ ccflags-y += -DOS_NAME_UBUNTU
16+ else ifeq ("steamos",$(OS_NAME))
17+ ccflags-y += -DOS_NAME_STEAMOS
18++else ifeq ("arch",$(OS_NAME))
19++ccflags-y += -DOS_NAME_ARCH
20++OS_VERSION = "0.0"
21+ else
22+ ccflags-y += -DOS_NAME_UNKNOWN
23+ endif
24+--
25+2.9.3
26+
pkgs/os-specific/linux/amdgpu-pro/patches/0002-update-kcl_ttm_bo_reserve-for-linux-4.7.patchnew file+25
@@ -0,0 +1,25 @@
1+From d84bd62a10308efb6a414e8f6582a7b1e9860638 Mon Sep 17 00:00:00 2001
2+From: David McFarland <corngood@gmail.com>
3+Date: Sun, 21 Aug 2016 16:31:12 -0300
4+Subject: [PATCH 2/8] update kcl_ttm_bo_reserve for linux-4.7
5+
6+---
7+ amd/backport/include/kcl/kcl_ttm.h | 2 +-
8+ 1 file changed, 1 insertion(+), 1 deletion(-)
9+
10+diff --git a/amd/backport/include/kcl/kcl_ttm.h b/amd/backport/include/kcl/kcl_ttm.h
11+index 3575004..0d1560d 100644
12+--- a/amd/backport/include/kcl/kcl_ttm.h
13++++ b/amd/backport/include/kcl/kcl_ttm.h
14+@@ -84,7 +84,7 @@ static inline int kcl_ttm_bo_reserve(struct ttm_buffer_object *bo,
15+ bool interruptible, bool no_wait,
16+ struct ww_acquire_ctx *ticket)
17+ {
18+-#if defined(BUILD_AS_DKMS)
19++#if defined(BUILD_AS_DKMS) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0)
20+ return ttm_bo_reserve(bo, interruptible, no_wait, false, ticket);
21+ #else
22+ return ttm_bo_reserve(bo, interruptible, no_wait, ticket);
23+--
24+2.9.3
25+
pkgs/os-specific/linux/amdgpu-pro/patches/0003-add-kcl_drm_gem_object_lookup.patchnew file+204
@@ -0,0 +1,204 @@
1+From 2637dfe990e4c277bc724f6ba48e6661506805ec Mon Sep 17 00:00:00 2001
2+From: David McFarland <corngood@gmail.com>
3+Date: Sun, 21 Aug 2016 16:37:34 -0300
4+Subject: [PATCH 3/8] add kcl_drm_gem_object_lookup
5+
6+---
7+ amd/amdgpu/amdgpu_atpx_handler.c | 4 ++++
8+ amd/amdgpu/amdgpu_bo_list.c | 2 +-
9+ amd/amdgpu/amdgpu_cs.c | 2 +-
10+ amd/amdgpu/amdgpu_display.c | 2 +-
11+ amd/amdgpu/amdgpu_gem.c | 10 +++++-----
12+ amd/amdgpu/dce_v10_0.c | 2 +-
13+ amd/amdgpu/dce_v11_0.c | 2 +-
14+ amd/amdgpu/dce_v8_0.c | 2 +-
15+ amd/backport/include/kcl/kcl_drm.h | 11 +++++++++++
16+ amd/dal/amdgpu_dm/amdgpu_dm_types.c | 2 +-
17+ 10 files changed, 27 insertions(+), 12 deletions(-)
18+
19+diff --git a/amd/amdgpu/amdgpu_atpx_handler.c b/amd/amdgpu/amdgpu_atpx_handler.c
20+index cc9b998..7e47478 100644
21+--- a/amd/amdgpu/amdgpu_atpx_handler.c
22++++ b/amd/amdgpu/amdgpu_atpx_handler.c
23+@@ -565,7 +565,11 @@ void amdgpu_register_atpx_handler(void)
24+ if (!r)
25+ return;
26+
27++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
28++ vga_switcheroo_register_handler(&amdgpu_atpx_handler, 0);
29++#else
30+ vga_switcheroo_register_handler(&amdgpu_atpx_handler);
31++#endif
32+ }
33+
34+ /**
35+diff --git a/amd/amdgpu/amdgpu_bo_list.c b/amd/amdgpu/amdgpu_bo_list.c
36+index 35d0856..1d163ec 100644
37+--- a/amd/amdgpu/amdgpu_bo_list.c
38++++ b/amd/amdgpu/amdgpu_bo_list.c
39+@@ -106,7 +106,7 @@ static int amdgpu_bo_list_set(struct amdgpu_device *adev,
40+ struct amdgpu_bo *bo;
41+ struct mm_struct *usermm;
42+
43+- gobj = drm_gem_object_lookup(adev->ddev, filp, info[i].bo_handle);
44++ gobj = kcl_drm_gem_object_lookup(adev->ddev, filp, info[i].bo_handle);
45+ if (!gobj) {
46+ r = -ENOENT;
47+ goto error_free;
48+diff --git a/amd/amdgpu/amdgpu_cs.c b/amd/amdgpu/amdgpu_cs.c
49+index d16ed26..b0390b5 100644
50+--- a/amd/amdgpu/amdgpu_cs.c
51++++ b/amd/amdgpu/amdgpu_cs.c
52+@@ -92,7 +92,7 @@ static int amdgpu_cs_user_fence_chunk(struct amdgpu_cs_parser *p,
53+ {
54+ struct drm_gem_object *gobj;
55+
56+- gobj = drm_gem_object_lookup(p->adev->ddev, p->filp,
57++ gobj = kcl_drm_gem_object_lookup(p->adev->ddev, p->filp,
58+ data->handle);
59+ if (gobj == NULL)
60+ return -EINVAL;
61+diff --git a/amd/amdgpu/amdgpu_display.c b/amd/amdgpu/amdgpu_display.c
62+index 46326b3..9b5441f 100644
63+--- a/amd/amdgpu/amdgpu_display.c
64++++ b/amd/amdgpu/amdgpu_display.c
65+@@ -594,7 +594,7 @@ amdgpu_user_framebuffer_create(struct drm_device *dev,
66+ struct amdgpu_framebuffer *amdgpu_fb;
67+ int ret;
68+
69+- obj = drm_gem_object_lookup(dev, file_priv, mode_cmd->handles[0]);
70++ obj = kcl_drm_gem_object_lookup(dev, file_priv, mode_cmd->handles[0]);
71+ if (obj == NULL) {
72+ dev_err(&dev->pdev->dev, "No GEM object associated to handle 0x%08X, "
73+ "can't create framebuffer\n", mode_cmd->handles[0]);
74+diff --git a/amd/amdgpu/amdgpu_gem.c b/amd/amdgpu/amdgpu_gem.c
75+index 0069aec..d10c282 100644
76+--- a/amd/amdgpu/amdgpu_gem.c
77++++ b/amd/amdgpu/amdgpu_gem.c
78+@@ -397,7 +397,7 @@ int amdgpu_mode_dumb_mmap(struct drm_file *filp,
79+ struct drm_gem_object *gobj;
80+ struct amdgpu_bo *robj;
81+
82+- gobj = drm_gem_object_lookup(dev, filp, handle);
83++ gobj = kcl_drm_gem_object_lookup(dev, filp, handle);
84+ if (gobj == NULL) {
85+ return -ENOENT;
86+ }
87+@@ -461,7 +461,7 @@ int amdgpu_gem_wait_idle_ioctl(struct drm_device *dev, void *data,
88+ int r = 0;
89+ long ret;
90+
91+- gobj = drm_gem_object_lookup(dev, filp, handle);
92++ gobj = kcl_drm_gem_object_lookup(dev, filp, handle);
93+ if (gobj == NULL) {
94+ return -ENOENT;
95+ }
96+@@ -495,7 +495,7 @@ int amdgpu_gem_metadata_ioctl(struct drm_device *dev, void *data,
97+ int r = -1;
98+
99+ DRM_DEBUG("%d \n", args->handle);
100+- gobj = drm_gem_object_lookup(dev, filp, args->handle);
101++ gobj = kcl_drm_gem_object_lookup(dev, filp, args->handle);
102+ if (gobj == NULL)
103+ return -ENOENT;
104+ robj = gem_to_amdgpu_bo(gobj);
105+@@ -643,7 +643,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
106+ return -EINVAL;
107+ }
108+
109+- gobj = drm_gem_object_lookup(dev, filp, args->handle);
110++ gobj = kcl_drm_gem_object_lookup(dev, filp, args->handle);
111+ if (gobj == NULL)
112+ return -ENOENT;
113+ rbo = gem_to_amdgpu_bo(gobj);
114+@@ -705,7 +705,7 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data,
115+ struct amdgpu_bo *robj;
116+ int r;
117+
118+- gobj = drm_gem_object_lookup(dev, filp, args->handle);
119++ gobj = kcl_drm_gem_object_lookup(dev, filp, args->handle);
120+ if (gobj == NULL) {
121+ return -ENOENT;
122+ }
123+diff --git a/amd/amdgpu/dce_v10_0.c b/amd/amdgpu/dce_v10_0.c
124+index 7554dd7..6d38754 100644
125+--- a/amd/amdgpu/dce_v10_0.c
126++++ b/amd/amdgpu/dce_v10_0.c
127+@@ -2594,7 +2594,7 @@ static int dce_v10_0_crtc_cursor_set2(struct drm_crtc *crtc,
128+ return -EINVAL;
129+ }
130+
131+- obj = drm_gem_object_lookup(crtc->dev, file_priv, handle);
132++ obj = kcl_drm_gem_object_lookup(crtc->dev, file_priv, handle);
133+ if (!obj) {
134+ DRM_ERROR("Cannot find cursor object %x for crtc %d\n", handle, amdgpu_crtc->crtc_id);
135+ return -ENOENT;
136+diff --git a/amd/amdgpu/dce_v11_0.c b/amd/amdgpu/dce_v11_0.c
137+index d9c9b88..93dbc1a 100644
138+--- a/amd/amdgpu/dce_v11_0.c
139++++ b/amd/amdgpu/dce_v11_0.c
140+@@ -2604,7 +2604,7 @@ static int dce_v11_0_crtc_cursor_set2(struct drm_crtc *crtc,
141+ return -EINVAL;
142+ }
143+
144+- obj = drm_gem_object_lookup(crtc->dev, file_priv, handle);
145++ obj = kcl_drm_gem_object_lookup(crtc->dev, file_priv, handle);
146+ if (!obj) {
147+ DRM_ERROR("Cannot find cursor object %x for crtc %d\n", handle, amdgpu_crtc->crtc_id);
148+ return -ENOENT;
149+diff --git a/amd/amdgpu/dce_v8_0.c b/amd/amdgpu/dce_v8_0.c
150+index 7a027ce..c56a298 100644
151+--- a/amd/amdgpu/dce_v8_0.c
152++++ b/amd/amdgpu/dce_v8_0.c
153+@@ -2501,7 +2501,7 @@ static int dce_v8_0_crtc_cursor_set2(struct drm_crtc *crtc,
154+ return -EINVAL;
155+ }
156+
157+- obj = drm_gem_object_lookup(crtc->dev, file_priv, handle);
158++ obj = kcl_drm_gem_object_lookup(crtc->dev, file_priv, handle);
159+ if (!obj) {
160+ DRM_ERROR("Cannot find cursor object %x for crtc %d\n", handle, amdgpu_crtc->crtc_id);
161+ return -ENOENT;
162+diff --git a/amd/backport/include/kcl/kcl_drm.h b/amd/backport/include/kcl/kcl_drm.h
163+index a65ee25..5a8a7b3 100644
164+--- a/amd/backport/include/kcl/kcl_drm.h
165++++ b/amd/backport/include/kcl/kcl_drm.h
166+@@ -3,6 +3,7 @@
167+
168+ #include <linux/version.h>
169+ #include <drm/drmP.h>
170++#include <drm/drm_gem.h>
171+
172+ #if defined(BUILD_AS_DKMS)
173+ extern int drm_pcie_get_max_link_width(struct drm_device *dev, u32 *mlw);
174+@@ -123,4 +124,14 @@ static inline int kcl_drm_universal_plane_init(struct drm_device *dev, struct dr
175+ #endif
176+ }
177+
178++static inline struct drm_gem_object *kcl_drm_gem_object_lookup(struct drm_device *dev,
179++ struct drm_file *filp,
180++ u32 handle) {
181++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
182++ return drm_gem_object_lookup(filp, handle);
183++#else
184++ return drm_gem_object_lookup(dev, filp, handle);
185++#endif
186++}
187++
188+ #endif /* AMDGPU_BACKPORT_KCL_DRM_H */
189+diff --git a/amd/dal/amdgpu_dm/amdgpu_dm_types.c b/amd/dal/amdgpu_dm/amdgpu_dm_types.c
190+index 3f357a5..2e2d2e6 100644
191+--- a/amd/dal/amdgpu_dm/amdgpu_dm_types.c
192++++ b/amd/dal/amdgpu_dm/amdgpu_dm_types.c
193+@@ -152,7 +152,7 @@ static int dm_crtc_pin_cursor_bo_new(
194+
195+ amdgpu_crtc = to_amdgpu_crtc(crtc);
196+
197+- obj = drm_gem_object_lookup(crtc->dev, file_priv, handle);
198++ obj = kcl_drm_gem_object_lookup(crtc->dev, file_priv, handle);
199+
200+ if (!obj) {
201+ DRM_ERROR(
202+--
203+2.9.3
204+
pkgs/os-specific/linux/amdgpu-pro/patches/0004-paging-changes-for-linux-4.6.patchnew file+42
@@ -0,0 +1,42 @@
1+From 2bd83488ccea22bb9e399986c171cccc3b6beb93 Mon Sep 17 00:00:00 2001
2+From: David McFarland <corngood@gmail.com>
3+Date: Sun, 21 Aug 2016 16:40:32 -0300
4+Subject: [PATCH 4/8] paging changes for linux-4.6
5+
6+---
7+ amd/amdgpu/amdgpu_ttm.c | 10 +++++++++-
8+ 1 file changed, 9 insertions(+), 1 deletion(-)
9+
10+diff --git a/amd/amdgpu/amdgpu_ttm.c b/amd/amdgpu/amdgpu_ttm.c
11+index 7bdebde..8b676c2 100644
12+--- a/amd/amdgpu/amdgpu_ttm.c
13++++ b/amd/amdgpu/amdgpu_ttm.c
14+@@ -548,8 +548,12 @@ int amdgpu_ttm_tt_get_user_pages(struct ttm_tt *ttm, struct page **pages)
15+ list_add(&guptask.list, &gtt->guptasks);
16+ spin_unlock(&gtt->guptasklock);
17+
18++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
19++ r = get_user_pages(userptr, num_pages, write, 0, p, NULL);
20++#else
21+ r = get_user_pages(current, current->mm, userptr, num_pages,
22+- write, 0, p, NULL);
23++ write, 0, p, NULL);
24++#endif
25+
26+ spin_lock(&gtt->guptasklock);
27+ list_del(&guptask.list);
28+@@ -625,7 +629,11 @@ static void amdgpu_ttm_tt_unpin_userptr(struct ttm_tt *ttm)
29+ set_page_dirty(page);
30+
31+ mark_page_accessed(page);
32++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
33++ put_page(page);
34++#else
35+ page_cache_release(page);
36++#endif
37+ }
38+
39+ sg_free_table(ttm->sg);
40+--
41+2.9.3
42+
pkgs/os-specific/linux/amdgpu-pro/patches/0005-LRU-stuff-isn-t-available-until-4.7.x.patchnew file+48
@@ -0,0 +1,48 @@
1+From c41c15fa04e363c41272e7b5d767710170691347 Mon Sep 17 00:00:00 2001
2+From: "Luke A. Guest" <laguest@archeia.com>
3+Date: Mon, 4 Jul 2016 19:19:45 +0100
4+Subject: [PATCH 5/8] LRU stuff isn't available until >= 4.7.x
5+
6+---
7+ amd/amdgpu/amdgpu_ttm.c | 4 ++--
8+ amd/backport/kcl_ttm.c | 2 +-
9+ 2 files changed, 3 insertions(+), 3 deletions(-)
10+
11+diff --git a/amd/amdgpu/amdgpu_ttm.c b/amd/amdgpu/amdgpu_ttm.c
12+index 8b676c2..752d065 100644
13+--- a/amd/amdgpu/amdgpu_ttm.c
14++++ b/amd/amdgpu/amdgpu_ttm.c
15+@@ -907,7 +907,7 @@ uint32_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm,
16+ return flags;
17+ }
18+
19+-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
20++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
21+
22+ static void amdgpu_ttm_lru_removal(struct ttm_buffer_object *tbo)
23+ {
24+@@ -969,7 +969,7 @@ static struct ttm_bo_driver amdgpu_bo_driver = {
25+ .fault_reserve_notify = &amdgpu_bo_fault_reserve_notify,
26+ .io_mem_reserve = &amdgpu_ttm_io_mem_reserve,
27+ .io_mem_free = &amdgpu_ttm_io_mem_free,
28+-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
29++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
30+ .lru_removal = &amdgpu_ttm_lru_removal,
31+ .lru_tail = &amdgpu_ttm_lru_tail,
32+ .swap_lru_tail = &amdgpu_ttm_swap_lru_tail,
33+diff --git a/amd/backport/kcl_ttm.c b/amd/backport/kcl_ttm.c
34+index 24f7a83..1a2cb7b 100644
35+--- a/amd/backport/kcl_ttm.c
36++++ b/amd/backport/kcl_ttm.c
37+@@ -7,7 +7,7 @@ static int _kcl_ttm_bo_del_from_lru(struct ttm_buffer_object *bo)
38+ {
39+ int put_count = 0;
40+
41+-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
42++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
43+ struct ttm_bo_device *bdev = bo->bdev;
44+
45+ if (bdev->driver->lru_removal)
46+--
47+2.9.3
48+
pkgs/os-specific/linux/amdgpu-pro/patches/0006-Change-name-of-vblank_disable_allowed-to-vblank_disa.patchnew file+29
@@ -0,0 +1,29 @@
1+From 5b90b8d8ab44637c707623b25ee98aa4ebded308 Mon Sep 17 00:00:00 2001
2+From: "Luke A. Guest" <laguest@archeia.com>
3+Date: Mon, 4 Jul 2016 19:30:08 +0100
4+Subject: [PATCH 6/8] Change name of vblank_disable_allowed to
5+ vblank_disable_immediate under 4.7.x.
6+
7+---
8+ amd/amdgpu/amdgpu_irq.c | 4 ++++
9+ 1 file changed, 4 insertions(+)
10+
11+diff --git a/amd/amdgpu/amdgpu_irq.c b/amd/amdgpu/amdgpu_irq.c
12+index d13865a..5cfa69f 100644
13+--- a/amd/amdgpu/amdgpu_irq.c
14++++ b/amd/amdgpu/amdgpu_irq.c
15+@@ -240,7 +240,11 @@ int amdgpu_irq_init(struct amdgpu_device *adev)
16+ INIT_WORK(&adev->hotplug_work,
17+ amdgpu_hotplug_work_func);
18+ }
19++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
20++ adev->ddev->vblank_disable_immediate = true;
21++#else
22+ adev->ddev->vblank_disable_allowed = true;
23++#endif
24+
25+ INIT_WORK(&adev->reset_work, amdgpu_irq_reset_work_func);
26+
27+--
28+2.9.3
29+
pkgs/os-specific/linux/amdgpu-pro/patches/0007-Remove-connector-parameter-from-__drm_atomic_helper_.patchnew file+29
@@ -0,0 +1,29 @@
1+From 27ef2ce0d4d8eeb3bca32ddeae503f0a334832aa Mon Sep 17 00:00:00 2001
2+From: "Luke A. Guest" <laguest@archeia.com>
3+Date: Mon, 4 Jul 2016 19:41:08 +0100
4+Subject: [PATCH 7/8] Remove connector parameter from
5+ __drm_atomic_helper_connector_destroy_state for 4.7.x kernels.
6+
7+---
8+ amd/dal/amdgpu_dm/amdgpu_dm_types.c | 4 ++++
9+ 1 file changed, 4 insertions(+)
10+
11+diff --git a/amd/dal/amdgpu_dm/amdgpu_dm_types.c b/amd/dal/amdgpu_dm/amdgpu_dm_types.c
12+index 2e2d2e6..cd34607 100644
13+--- a/amd/dal/amdgpu_dm/amdgpu_dm_types.c
14++++ b/amd/dal/amdgpu_dm/amdgpu_dm_types.c
15+@@ -1205,7 +1205,11 @@ void amdgpu_dm_connector_atomic_destroy_state(
16+ struct dm_connector_state *dm_state =
17+ to_dm_connector_state(state);
18+
19++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
20++ __drm_atomic_helper_connector_destroy_state(state);
21++#else
22+ __drm_atomic_helper_connector_destroy_state(connector, state);
23++#endif
24+
25+ kfree(dm_state);
26+ }
27+--
28+2.9.3
29+
pkgs/os-specific/linux/amdgpu-pro/patches/0008-fix-apparent-typo-in-bandwidth_calcs-causing-array-e.patchnew file+25
@@ -0,0 +1,25 @@
1+From c9f2501131da0d9173e21f7e8ff5741a7fcfedb6 Mon Sep 17 00:00:00 2001
2+From: David McFarland <corngood@gmail.com>
3+Date: Sun, 21 Aug 2016 16:58:45 -0300
4+Subject: [PATCH 8/8] fix apparent typo in bandwidth_calcs causing array error
5+
6+---
7+ amd/dal/dc/calcs/bandwidth_calcs.c | 2 +-
8+ 1 file changed, 1 insertion(+), 1 deletion(-)
9+
10+diff --git a/amd/dal/dc/calcs/bandwidth_calcs.c b/amd/dal/dc/calcs/bandwidth_calcs.c
11+index 8a19139..c4ededd 100644
12+--- a/amd/dal/dc/calcs/bandwidth_calcs.c
13++++ b/amd/dal/dc/calcs/bandwidth_calcs.c
14+@@ -3181,7 +3181,7 @@ static void calculate_bandwidth(
15+ bw_int_to_fixed(
16+ 2),
17+ vbios->mcifwrmc_urgent_latency),
18+- results->dmif_burst_time[i][j]),
19++ results->dmif_burst_time[results->y_clk_level][results->sclk_level]),
20+ results->mcifwr_burst_time[results->y_clk_level][results->sclk_level])),
21+ results->dispclk),
22+ bw_int_to_fixed(
23+--
24+2.9.3
25+
pkgs/os-specific/linux/amdgpu-pro/patches/0009-disable-dal-by-default.patchnew file+25
@@ -0,0 +1,25 @@
1+From 49d45957ddaafe13a9cc7bacd1b9665fe9c517ac Mon Sep 17 00:00:00 2001
2+From: David McFarland <corngood@gmail.com>
3+Date: Thu, 25 Aug 2016 22:17:06 -0300
4+Subject: [PATCH] disable dal by default
5+
6+---
7+ amd/amdgpu/amdgpu_drv.c | 2 +-
8+ 1 file changed, 1 insertion(+), 1 deletion(-)
9+
10+diff --git a/amd/amdgpu/amdgpu_drv.c b/amd/amdgpu/amdgpu_drv.c
11+index 793528b..9a4dfcc 100644
12+--- a/amd/amdgpu/amdgpu_drv.c
13++++ b/amd/amdgpu/amdgpu_drv.c
14+@@ -79,7 +79,7 @@ int amdgpu_vm_block_size = -1;
15+ int amdgpu_vm_fault_stop = 0;
16+ int amdgpu_vm_debug = 0;
17+ int amdgpu_exp_hw_support = 0;
18+-int amdgpu_dal = -1;
19++int amdgpu_dal = 0;
20+ int amdgpu_sched_jobs = 32;
21+ int amdgpu_sched_hw_submission = 2;
22+ int amdgpu_powerplay = -1;
23+--
24+2.9.3
25+
pkgs/os-specific/linux/amdgpu-pro/patches/0010-remove-dependency-on-System.map.patchnew file+112
@@ -0,0 +1,112 @@
1+From fbc0d704f47526ca38f518b60237962cc6b08305 Mon Sep 17 00:00:00 2001
2+From: David McFarland <corngood@gmail.com>
3+Date: Thu, 25 Aug 2016 23:08:02 -0300
4+Subject: [PATCH] remove dependency on System.map
5+
6+---
7+ amd/backport/Makefile | 3 +--
8+ amd/backport/kcl_fence.c | 10 ++++++++--
9+ amd/backport/symbols | 3 ---
10+ dkms.conf | 1 -
11+ pre-build.sh | 32 --------------------------------
12+ 5 files changed, 9 insertions(+), 40 deletions(-)
13+ delete mode 100644 amd/backport/symbols
14+ delete mode 100755 pre-build.sh
15+
16+diff --git a/amd/backport/Makefile b/amd/backport/Makefile
17+index 6447a15..4682e0f 100644
18+--- a/amd/backport/Makefile
19++++ b/amd/backport/Makefile
20+@@ -53,10 +53,9 @@ ccflags-y += -DOS_NAME_RHEL_7
21+ endif
22+ endif
23+
24+-BACKPORT_OBJS = symbols.o
25+ endif
26+
27+-BACKPORT_OBJS += kcl_drm.o kcl_ttm.o kcl_amdgpu.o kcl_fence.o kcl_mn.o
28++BACKPORT_OBJS = kcl_drm.o kcl_ttm.o kcl_amdgpu.o kcl_fence.o kcl_mn.o
29+
30+ amdgpu-y += $(addprefix ../backport/,$(BACKPORT_OBJS))
31+
32+diff --git a/amd/backport/kcl_fence.c b/amd/backport/kcl_fence.c
33+index 2141eef..ceef1fe 100644
34+--- a/amd/backport/kcl_fence.c
35++++ b/amd/backport/kcl_fence.c
36+@@ -22,8 +22,14 @@ struct default_wait_cb {
37+ struct task_struct *task;
38+ };
39+
40+-extern void
41+-(*fence_default_wait_cb)(struct fence *fence, struct fence_cb *cb);
42++static void
43++fence_default_wait_cb(struct fence *fence, struct fence_cb *cb)
44++{
45++ struct default_wait_cb *wait =
46++ container_of(cb, struct default_wait_cb, base);
47++
48++ wake_up_process(wait->task);
49++}
50+
51+ signed long
52+ _kcl_fence_wait_any_timeout(struct fence **fences, uint32_t count,
53+diff --git a/amd/backport/symbols b/amd/backport/symbols
54+deleted file mode 100644
55+index 2d3f2ee..0000000
56+--- a/amd/backport/symbols
57++++ /dev/null
58+@@ -1,3 +0,0 @@
59+-SYMS=""
60+-
61+-SYMS+="fence_default_wait_cb"
62+diff --git a/dkms.conf b/dkms.conf
63+index 9ca148e..36be480 100644
64+--- a/dkms.conf
65++++ b/dkms.conf
66+@@ -4,4 +4,3 @@ BUILT_MODULE_NAME[0]="amdgpu"
67+ BUILT_MODULE_LOCATION[0]="amd/amdgpu"
68+ DEST_MODULE_LOCATION[0]="/extra"
69+ AUTOINSTALL="yes"
70+-PRE_BUILD="pre-build.sh $kernelver"
71+\ No newline at end of file
72+diff --git a/pre-build.sh b/pre-build.sh
73+deleted file mode 100755
74+index 88ec680..0000000
75+--- a/pre-build.sh
76++++ /dev/null
77+@@ -1,32 +0,0 @@
78+-#!/bin/bash
79+-
80+-KERNELVER=$1
81+-KERNELVER_BASE=${KERNELVER%%-*}
82+-
83+-version_lt () {
84+- newest=$((echo "$1"; echo "$2") | sort -V | tail -n1)
85+- [ "$1" != "$newest" ]
86+-}
87+-
88+-version_ge () {
89+- newest=$((echo "$1"; echo "$2") | sort -V | tail -n1)
90+- [ "$1" = "$newest" ]
91+-}
92+-
93+-version_gt () {
94+- oldest=$((echo "$1"; echo "$2") | sort -V | head -n1)
95+- [ "$1" != "$oldest" ]
96+-}
97+-
98+-version_le () {
99+- oldest=$((echo "$1"; echo "$2") | sort -V | head -n1)
100+- [ "$1" = "$oldest" ]
101+-}
102+-
103+-source amd/backport/symbols
104+-
105+-echo '// auto generated by DKMS pre-build.sh' > amd/backport/symbols.c
106+-for sym in $SYMS; do
107+- addr=$(grep $sym /boot/System.map-$KERNELVER | awk -F' ' '{print $1}')
108+- echo "void *$sym = (void *)0x$addr;" >> amd/backport/symbols.c
109+-done
110+--
111+2.9.3
112+
pkgs/top-level/all-packages.nix+2
@@ -11338,6 +11338,8 @@ in
1133811338
1133911339 acpi_call = callPackage ../os-specific/linux/acpi-call {};
1134011340
11341+ amdgpu-pro = callPackage ../os-specific/linux/amdgpu-pro { };
11342+
1134111343 batman_adv = callPackage ../os-specific/linux/batman-adv {};
1134211344
1134311345 bcc = callPackage ../os-specific/linux/bcc { };