Merge pull request #33685 from corngood/amdgpu-pro-upgrade

amdgpu-pro: 17.10 -> 17.40
This commit is contained in:
Matthew Justin Bauer 2018-03-19 12:40:03 -05:00 committed by GitHub
commit ce01740dae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 174 additions and 166 deletions

View file

@ -15,13 +15,19 @@ let
opengl = config.hardware.opengl;
kernel = pkgs.linux_4_9.override {
extraConfig = ''
KALLSYMS_ALL y
'';
};
in
{
config = mkIf enabled {
nixpkgs.config.xorg.abiCompat = "1.18";
nixpkgs.config.xorg.abiCompat = "1.19";
services.xserver.drivers = singleton
{ name = "amdgpu"; modules = [ package ]; libPath = [ package ]; };
@ -31,6 +37,9 @@ in
boot.extraModulePackages = [ package ];
boot.kernelPackages =
pkgs.recurseIntoAttrs (pkgs.linuxPackagesFor kernel);
boot.blacklistedKernelModules = [ "radeon" ];
hardware.firmware = [ package ];
@ -38,10 +47,15 @@ in
system.activationScripts.setup-amdgpu-pro = ''
mkdir -p /run/lib
ln -sfn ${package}/lib ${package.libCompatDir}
ln -sfn ${package} /run/amdgpu-pro
'' + optionalString opengl.driSupport32Bit ''
ln -sfn ${package32}/lib ${package32.libCompatDir}
'';
system.requiredKernelConfig = with config.lib.kernelConfig; [
(isYes "KALLSYMS_ALL")
];
environment.etc = {
"amd/amdrc".source = package + "/etc/amd/amdrc";
"amd/amdapfxx.blb".source = package + "/etc/amd/amdapfxx.blb";

View file

@ -30,9 +30,9 @@ let
in stdenv.mkDerivation rec {
version = "17.10";
version = "17.40";
pname = "amdgpu-pro";
build = "${version}-401251";
build = "${version}-492261";
libCompatDir = "/run/lib/${libArch}";
@ -41,7 +41,7 @@ in stdenv.mkDerivation rec {
src = fetchurl {
url =
"https://www2.ati.com/drivers/linux/ubuntu/amdgpu-pro-${build}.tar.xz";
sha256 = "004n0df8acjpjz72z3bjxb2a0b7qwln13jlknfn7xxqvhhwwy40a";
sha256 = "1c073lp9cq1rc2mddky2r0j2dv9dd167qj02visz37vwaxbm2r5h";
curlOpts = "--referer http://support.amd.com/en-us/kb-articles/Pages/AMD-Radeon-GPU-PRO-Linux-Beta-Driver%e2%80%93Release-Notes.aspx";
};
@ -57,15 +57,14 @@ in stdenv.mkDerivation rec {
sourceRoot=.
'';
modulePatches = [
./patches/0001-disable-firmware-copy.patch
./patches/0002-linux-4.9-fixes.patch
./patches/0003-Change-seq_printf-format-for-64-bit-context.patch
./patches/0004-fix-warnings-for-Werror.patch
];
modulePatches = optionals (!libsOnly) ([
./patches/0001-fix-warnings-for-Werror.patch
./patches/0002-fix-sketchy-int-ptr-warning.patch
./patches/0003-disable-firmware-copy.patch
]);
patchPhase = optionalString (!libsOnly) ''
pushd usr/src/amdgpu-pro-${build}
pushd usr/src/amdgpu-${build}
for patch in $modulePatches
do
echo $patch
@ -74,12 +73,18 @@ in stdenv.mkDerivation rec {
popd
'';
xreallocarray = ./xreallocarray.c;
preBuild = optionalString (!libsOnly) ''
pushd usr/src/amdgpu-pro-${build}
pushd usr/src/amdgpu-${build}
makeFlags="$makeFlags M=$(pwd)"
patchShebangs pre-build.sh
./pre-build.sh ${kernel.version}
popd
pushd lib
$CC -fPIC -shared -o libhack-xreallocarray.so $xreallocarray
strip libhack-xreallocarray.so
popd
'';
modules = [
@ -89,7 +94,7 @@ in stdenv.mkDerivation rec {
];
postBuild = optionalString (!libsOnly)
(concatMapStrings (m: "xz usr/src/amdgpu-pro-${build}/${m}\n") modules);
(concatMapStrings (m: "xz usr/src/amdgpu-${build}/${m}\n") modules);
NIX_CFLAGS_COMPILE = "-Werror";
@ -110,16 +115,17 @@ in stdenv.mkDerivation rec {
pushd usr
cp -r lib/${libArch}/* $out/lib
'' + optionalString (!libsOnly) ''
cp -r src/amdgpu-pro-${build}/firmware $out/lib/firmware
cp -r src/amdgpu-${build}/firmware $out/lib/firmware
'' + ''
cp -r share $out/share
popd
pushd opt/amdgpu-pro
'' + optionalString (!stdenv.is64bit) ''
'' + optionalString (!libsOnly && stdenv.is64bit) ''
cp -r bin $out/bin
'' + ''
cp -r include $out/include
cp -r share/* $out/share
cp -r lib/${libArch}/* $out/lib
'' + optionalString (!libsOnly) ''
mv lib/xorg $out/lib/xorg
@ -128,12 +134,12 @@ in stdenv.mkDerivation rec {
'' + optionalString (!libsOnly)
(concatMapStrings (m:
"install -Dm444 usr/src/amdgpu-pro-${build}/${m}.xz $out/lib/modules/${kernel.modDirVersion}/kernel/drivers/gpu/drm/${m}.xz\n") modules)
"install -Dm444 usr/src/amdgpu-${build}/${m}.xz $out/lib/modules/${kernel.modDirVersion}/kernel/drivers/gpu/drm/${m}.xz\n") modules)
+ ''
mv $out/etc/vulkan $out/share
interpreter="$(cat $NIX_CC/nix-support/dynamic-linker)"
libPath="$out/lib:$out/lib/gbm:$depLibPath"
'' + optionalString (!stdenv.is64bit) ''
'' + optionalString (!libsOnly && stdenv.is64bit) ''
for prog in clinfo modetest vbltest kms-universal-planes kms-steal-crtc modeprint amdgpu_test kmstest proptest; do
patchelf --interpreter "$interpreter" --set-rpath "$libPath" "$out/bin/$prog"
done
@ -147,10 +153,17 @@ in stdenv.mkDerivation rec {
for lib in `find "$out/lib/" -name '*.so*' -type f`; do
patchelf --set-rpath "$libPath" "$lib"
done
for lib in libEGL.so.1 libGL.so.1.2 ${optionalString (!libsOnly) "xorg/modules/extensions/libglx.so"} dri/amdgpu_dri.so; do
for lib in libEGL.so.1 libGL.so.1.2 ${optionalString (!libsOnly) "xorg/modules/extensions/libglx.so"} dri/amdgpu_dri.so libamdocl${bitness}.so; do
perl -pi -e 's:${libReplaceDir}:${libCompatDir}:g' "$out/lib/$lib"
done
for lib in dri/amdgpu_dri.so libdrm_amdgpu.so.1.0.0 libgbm_amdgpu.so.1.0.0 libkms_amdgpu.so.1.0.0 libamdocl${bitness}.so; do
perl -pi -e 's:/opt/amdgpu-pro/:/run/amdgpu-pro/:g' "$out/lib/$lib"
done
substituteInPlace "$out/share/vulkan/icd.d/amd_icd${bitness}.json" --replace "/opt/amdgpu-pro/lib/${libArch}" "$out/lib"
'' + optionalString (!libsOnly) ''
for lib in drivers/modesetting_drv.so libglamoregl.so; do
patchelf --add-needed $out/lib/libhack-xreallocarray.so $out/lib/xorg/modules/$lib
done
'';
buildInputs = [

View file

@ -1,25 +0,0 @@
From 704cef8638ffbdd8de9e57f28b43ea42c685ea87 Mon Sep 17 00:00:00 2001
From: David McFarland <corngood@gmail.com>
Date: Sat, 28 Jan 2017 16:57:26 -0400
Subject: [PATCH 1/4] disable firmware copy
---
pre-build.sh | 5 -----
1 file changed, 5 deletions(-)
diff --git a/pre-build.sh b/pre-build.sh
index 622ff13..e3cd009 100755
--- a/pre-build.sh
+++ b/pre-build.sh
@@ -35,8 +35,3 @@ find ttm -name '*.c' -exec grep EXPORT_SYMBOL {} + \
| sort -u \
| awk -F'[()]' '{print "#define "$2" amd"$2" //"$0}'\
> include/rename_symbol.h
-
-FW_DIR="/lib/firmware/$KERNELVER"
-mkdir -p $FW_DIR
-cp -ar /usr/src/amdgpu-pro-17.10-401251/firmware/radeon $FW_DIR
-cp -ar /usr/src/amdgpu-pro-17.10-401251/firmware/amdgpu $FW_DIR
--
2.12.2

View file

@ -0,0 +1,71 @@
From 9167d76c435a7c1df7954f0fbe5cc6d083f8ed2f Mon Sep 17 00:00:00 2001
From: David McFarland <corngood@gmail.com>
Date: Mon, 6 Feb 2017 22:13:49 -0400
Subject: [PATCH 1/3] fix warnings for Werror
---
amd/amdgpu/amdgpu_device.c | 4 ++--
amd/amdgpu/amdgpu_sa.c | 2 +-
amd/display/dc/bios/bios_parser2.c | 8 ++++----
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/amd/amdgpu/amdgpu_device.c b/amd/amdgpu/amdgpu_device.c
index fc1c543..186e06d 100644
--- a/amd/amdgpu/amdgpu_device.c
+++ b/amd/amdgpu/amdgpu_device.c
@@ -3164,7 +3164,7 @@ void amdgpu_debugfs_cleanup(struct drm_minor *minor)
struct drm_info_node *node, *tmp;
if (!&minor->debugfs_root)
- return 0;
+ return;
mutex_lock(&minor->debugfs_lock);
list_for_each_entry_safe(node, tmp,
@@ -3175,7 +3175,7 @@ void amdgpu_debugfs_cleanup(struct drm_minor *minor)
}
mutex_unlock(&minor->debugfs_lock);
- return 0;
+ return;
}
#endif
diff --git a/amd/amdgpu/amdgpu_sa.c b/amd/amdgpu/amdgpu_sa.c
index 7206b34..8b7123c 100644
--- a/amd/amdgpu/amdgpu_sa.c
+++ b/amd/amdgpu/amdgpu_sa.c
@@ -430,7 +430,7 @@ void amdgpu_sa_bo_dump_debug_info(struct amdgpu_sa_manager *sa_manager,
if (i->fence)
#if defined(BUILD_AS_DKMS)
seq_printf(m, " protected by 0x%08x on context %d",
- i->fence->seqno, i->fence->context);
+ i->fence->seqno, (int)i->fence->context);
#else
seq_printf(m, " protected by 0x%08x on context %llu",
i->fence->seqno, i->fence->context);
diff --git a/amd/display/dc/bios/bios_parser2.c b/amd/display/dc/bios/bios_parser2.c
index 86fce5a..99681c5 100644
--- a/amd/display/dc/bios/bios_parser2.c
+++ b/amd/display/dc/bios/bios_parser2.c
@@ -1326,13 +1326,13 @@ static enum bp_result get_embedded_panel_info_v2_1(
info->lcd_timing.misc_info.VERTICAL_CUT_OFF = 0;
info->lcd_timing.misc_info.H_REPLICATION_BY2 =
- lvds->lcd_timing.miscinfo & ATOM_H_REPLICATIONBY2;
+ (lvds->lcd_timing.miscinfo & ATOM_H_REPLICATIONBY2) != 0;
info->lcd_timing.misc_info.V_REPLICATION_BY2 =
- lvds->lcd_timing.miscinfo & ATOM_V_REPLICATIONBY2;
+ (lvds->lcd_timing.miscinfo & ATOM_V_REPLICATIONBY2) != 0;
info->lcd_timing.misc_info.COMPOSITE_SYNC =
- lvds->lcd_timing.miscinfo & ATOM_COMPOSITESYNC;
+ (lvds->lcd_timing.miscinfo & ATOM_COMPOSITESYNC) != 0;
info->lcd_timing.misc_info.INTERLACE =
- lvds->lcd_timing.miscinfo & ATOM_INTERLACE;
+ (lvds->lcd_timing.miscinfo & ATOM_INTERLACE) != 0;
/* not provided by VBIOS*/
info->lcd_timing.misc_info.DOUBLE_CLOCK = 0;
--
2.15.1

View file

@ -0,0 +1,25 @@
From a07ee5dec35ca24a013a6638543ef5030b2bab40 Mon Sep 17 00:00:00 2001
From: David McFarland <corngood@gmail.com>
Date: Tue, 9 Jan 2018 21:45:33 -0400
Subject: [PATCH 2/3] fix sketchy int->ptr warning
---
amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
index d0f091b..707815a 100644
--- a/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
+++ b/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
@@ -236,7 +236,7 @@ bool dm_helpers_dp_mst_write_payload_allocation_table(
pbn = drm_dp_calc_pbn_mode(clock, bpp);
slots = drm_dp_find_vcpi_slots(mst_mgr, pbn);
- ret = drm_dp_mst_allocate_vcpi(mst_mgr, mst_port, pbn, slots);
+ ret = drm_dp_mst_allocate_vcpi(mst_mgr, mst_port, pbn, &slots);
if (!ret)
return false;
--
2.15.1

View file

@ -1,50 +0,0 @@
From 0ead7017e1db18be971c24c891d4bdcc507deea7 Mon Sep 17 00:00:00 2001
From: David McFarland <corngood@gmail.com>
Date: Sun, 29 Jan 2017 18:23:47 -0400
Subject: [PATCH 2/4] linux-4.9 fixes
---
amd/amdkcl/kcl_io.c | 2 ++
amd/display/amdgpu_dm/amdgpu_dm_types.c | 8 ++++++++
2 files changed, 10 insertions(+)
diff --git a/amd/amdkcl/kcl_io.c b/amd/amdkcl/kcl_io.c
index d8f843f..9a1bd9b 100644
--- a/amd/amdkcl/kcl_io.c
+++ b/amd/amdkcl/kcl_io.c
@@ -31,4 +31,6 @@ void amdkcl_io_init(void)
_kcl_io_free_memtype = amdkcl_fp_setup("io_free_memtype", NULL);
}
#endif
+#else
+void amdkcl_io_init(void) {}
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0) */
diff --git a/amd/display/amdgpu_dm/amdgpu_dm_types.c b/amd/display/amdgpu_dm/amdgpu_dm_types.c
index 34313a9..44a4a71 100644
--- a/amd/display/amdgpu_dm/amdgpu_dm_types.c
+++ b/amd/display/amdgpu_dm/amdgpu_dm_types.c
@@ -1720,6 +1720,10 @@ static int dm_plane_helper_prepare_fb(
static int dm_plane_helper_prepare_fb(
struct drm_plane *plane,
const struct drm_plane_state *new_state)
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)
+static int dm_plane_helper_prepare_fb(
+ struct drm_plane *plane,
+ struct drm_plane_state *new_state)
#else
static int dm_plane_helper_prepare_fb(
struct drm_plane *plane,
@@ -1766,6 +1770,10 @@ static void dm_plane_helper_cleanup_fb(
static void dm_plane_helper_cleanup_fb(
struct drm_plane *plane,
const struct drm_plane_state *old_state)
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)
+static void dm_plane_helper_cleanup_fb(
+ struct drm_plane *plane,
+ struct drm_plane_state *old_state)
#else
static void dm_plane_helper_cleanup_fb(
struct drm_plane *plane,
--
2.12.2

View file

@ -1,25 +0,0 @@
From b6dd36dd90c5d88ae10b9dbc763d3bacb95ccddb Mon Sep 17 00:00:00 2001
From: "Luke A. Guest" <laguest@archeia.com>
Date: Sun, 25 Sep 2016 16:46:39 +0100
Subject: [PATCH 3/4] Change seq_printf format for 64 bit context
---
amd/amdgpu/amdgpu_sa.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/amd/amdgpu/amdgpu_sa.c b/amd/amdgpu/amdgpu_sa.c
index 74932bf..db4119a 100644
--- a/amd/amdgpu/amdgpu_sa.c
+++ b/amd/amdgpu/amdgpu_sa.c
@@ -428,7 +428,7 @@ void amdgpu_sa_bo_dump_debug_info(struct amdgpu_sa_manager *sa_manager,
soffset, eoffset, eoffset - soffset);
if (i->fence)
-#if defined(BUILD_AS_DKMS)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
seq_printf(m, " protected by 0x%08x on context %d",
i->fence->seqno, i->fence->context);
#else
--
2.12.2

View file

@ -0,0 +1,25 @@
From 7a3062acbbabdb29239bbc8c984e62589a88576e Mon Sep 17 00:00:00 2001
From: David McFarland <corngood@gmail.com>
Date: Tue, 9 Jan 2018 21:49:55 -0400
Subject: [PATCH 3/3] disable firmware copy
---
pre-build.sh | 5 -----
1 file changed, 5 deletions(-)
diff --git a/pre-build.sh b/pre-build.sh
index e7b8a32..bad8f25 100755
--- a/pre-build.sh
+++ b/pre-build.sh
@@ -38,8 +38,3 @@ find ttm -name '*.c' -exec grep EXPORT_SYMBOL {} + \
| sort -u \
| awk -F'[()]' '{print "#define "$2" amd"$2" //"$0}'\
>> include/rename_symbol.h
-
-FW_DIR="/lib/firmware/$KERNELVER"
-mkdir -p $FW_DIR
-cp -ar /usr/src/amdgpu-17.40-492261/firmware/radeon $FW_DIR
-cp -ar /usr/src/amdgpu-17.40-492261/firmware/amdgpu $FW_DIR
--
2.15.1

View file

@ -1,46 +0,0 @@
From dbf01d3934c52acaaa37f008859f69c5edf19ad5 Mon Sep 17 00:00:00 2001
From: David McFarland <corngood@gmail.com>
Date: Mon, 6 Feb 2017 22:13:49 -0400
Subject: [PATCH 4/4] fix warnings for Werror
---
amd/amdgpu/amdgpu_ttm.c | 2 ++
amd/display/amdgpu_dm/amdgpu_dm_types.c | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/amd/amdgpu/amdgpu_ttm.c b/amd/amdgpu/amdgpu_ttm.c
index 0e30389..890aafa 100644
--- a/amd/amdgpu/amdgpu_ttm.c
+++ b/amd/amdgpu/amdgpu_ttm.c
@@ -1083,6 +1083,7 @@ uint32_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm,
return flags;
}
+#if 0
static void amdgpu_ttm_lru_removal(struct ttm_buffer_object *tbo)
{
struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev);
@@ -1132,6 +1133,7 @@ static struct list_head *amdgpu_ttm_swap_lru_tail(struct ttm_buffer_object *tbo)
return res;
}
+#endif
static bool amdgpu_ttm_bo_eviction_valuable(struct ttm_buffer_object *bo,
const struct ttm_place *place)
diff --git a/amd/display/amdgpu_dm/amdgpu_dm_types.c b/amd/display/amdgpu_dm/amdgpu_dm_types.c
index 44a4a71..ae7e707 100644
--- a/amd/display/amdgpu_dm/amdgpu_dm_types.c
+++ b/amd/display/amdgpu_dm/amdgpu_dm_types.c
@@ -932,7 +932,7 @@ static void decide_crtc_timing_for_drm_display_mode(
}
static struct dc_target *create_target_for_sink(
- const struct amdgpu_connector *aconnector,
+ struct amdgpu_connector *aconnector,
const struct drm_display_mode *drm_mode,
const struct dm_connector_state *dm_state)
{
--
2.12.2

View file

@ -0,0 +1,5 @@
#include <malloc.h>
void *xreallocarray(void *ptr, size_t nmemb, size_t size) {
return reallocarray(ptr, nmemb, size);
}

View file

@ -429,8 +429,9 @@ in
xorgserver = with xorg; attrs_passed:
# exchange attrs if abiCompat is set
let
version = (builtins.parseDrvName attrs_passed.name).version;
attrs = with args;
if (args.abiCompat == null) then attrs_passed
if (args.abiCompat == null || lib.hasPrefix args.abiCompat version) then attrs_passed
else if (args.abiCompat == "1.17") then {
name = "xorg-server-1.17.4";
builder = ./builder.sh;
@ -452,7 +453,7 @@ in
buildInputs = [ dri2proto dri3proto renderproto libdrm openssl libX11 libXau libXaw libxcb xcbutil xcbutilwm xcbutilimage xcbutilkeysyms xcbutilrenderutil libXdmcp libXfixes libxkbfile libXmu libXpm libXrender libXres libXt ];
postPatch = "sed '1i#include <malloc.h>' -i include/os.h";
meta.platforms = stdenv.lib.platforms.unix;
} else throw "unsupported xorg abiCompat: ${args.abiCompat}";
} else throw "unsupported xorg abiCompat ${args.abiCompat} for ${attrs_passed.name}";
in attrs //
(let