summary refs log tree commit diff
path: root/pkgs/os-specific/linux/ati-drivers
diff options
context:
space:
mode:
authorVladimír Čunát <vcunat@gmail.com>2016-05-23 09:02:10 +0200
committerVladimír Čunát <vcunat@gmail.com>2016-05-23 09:02:10 +0200
commit0b192a09767c05b38f3e2838c07e9600318bbbb5 (patch)
tree4467053c39ef4bad71527cd5fda5cf92960575e8 /pkgs/os-specific/linux/ati-drivers
parentdc5bbc4700dd95420f87141efcc0e6cb48a710f9 (diff)
parent0e54c749114b79f6be78486086f5829b176fcba8 (diff)
downloadnixpkgs-0b192a09767c05b38f3e2838c07e9600318bbbb5.tar
nixpkgs-0b192a09767c05b38f3e2838c07e9600318bbbb5.tar.gz
nixpkgs-0b192a09767c05b38f3e2838c07e9600318bbbb5.tar.bz2
nixpkgs-0b192a09767c05b38f3e2838c07e9600318bbbb5.tar.lz
nixpkgs-0b192a09767c05b38f3e2838c07e9600318bbbb5.tar.xz
nixpkgs-0b192a09767c05b38f3e2838c07e9600318bbbb5.tar.zst
nixpkgs-0b192a09767c05b38f3e2838c07e9600318bbbb5.zip
Merge branch 'master' into staging
That's to get mesa rebuild from master, as it's nontrivial.
Diffstat (limited to 'pkgs/os-specific/linux/ati-drivers')
-rw-r--r--pkgs/os-specific/linux/ati-drivers/builder.sh13
-rw-r--r--pkgs/os-specific/linux/ati-drivers/default.nix11
-rw-r--r--pkgs/os-specific/linux/ati-drivers/kernel-api-fixes.patch99
-rw-r--r--pkgs/os-specific/linux/ati-drivers/patches/15.12-xstate-fp.patch26
-rw-r--r--pkgs/os-specific/linux/ati-drivers/patches/15.9-kcl_str.patch14
-rw-r--r--pkgs/os-specific/linux/ati-drivers/patches/15.9-mtrr.patch27
-rw-r--r--pkgs/os-specific/linux/ati-drivers/patches/15.9-preempt.patch103
-rw-r--r--pkgs/os-specific/linux/ati-drivers/patches/15.9-sep_printf.patch11
-rw-r--r--pkgs/os-specific/linux/ati-drivers/patches/patch-samples.patch (renamed from pkgs/os-specific/linux/ati-drivers/patch-samples.patch)0
9 files changed, 199 insertions, 105 deletions
diff --git a/pkgs/os-specific/linux/ati-drivers/builder.sh b/pkgs/os-specific/linux/ati-drivers/builder.sh
index b9f6ed22cba..2b907bde10a 100644
--- a/pkgs/os-specific/linux/ati-drivers/builder.sh
+++ b/pkgs/os-specific/linux/ati-drivers/builder.sh
@@ -9,6 +9,10 @@ unzip $src
 run_file=fglrx-$build/amd-driver-installer-$build-x86.x86_64.run
 sh $run_file --extract .
 
+for patch in $patches;do
+    patch -p1 < $patch
+done
+
 case "$system" in
   x86_64-linux)
     arch=x86_64
@@ -238,6 +242,7 @@ if test -z "$libsOnly"; then
   tar xfz ../common/usr/src/ati/fglrx_sample_source.tgz
   eval "$patchPhaseSamples"
 
+
   ( # build and install fgl_glxgears
     cd fgl_glxgears;
     gcc -DGL_ARB_texture_multisample=1 -g \
@@ -258,10 +263,10 @@ if test -z "$libsOnly"; then
 
     cd programs/fglrx_gamma
     gcc -fPIC -I${libXxf86vm.dev}/include \
-	    -I${xf86vidmodeproto}/include \
-	    -I$out/X11R6/include \
-	    -L$out/lib \
-	    -Wall -lm -lfglrx_gamma -lX11 -lXext -o $out/bin/fglrx_xgamma fglrx_xgamma.c
+      -I${xf86vidmodeproto}/include \
+      -I$out/X11R6/include \
+      -L$out/lib \
+      -Wall -lm -lfglrx_gamma -lX11 -lXext -o $out/bin/fglrx_xgamma fglrx_xgamma.c
   )
 
   {
diff --git a/pkgs/os-specific/linux/ati-drivers/default.nix b/pkgs/os-specific/linux/ati-drivers/default.nix
index a4f8b707c08..e5eb9b8c6c3 100644
--- a/pkgs/os-specific/linux/ati-drivers/default.nix
+++ b/pkgs/os-specific/linux/ati-drivers/default.nix
@@ -65,7 +65,14 @@ stdenv.mkDerivation rec {
     curlOpts = "--referer http://support.amd.com/en-us/download/desktop?os=Linux+x86_64";
   };
 
-  patchPhaseSamples = "patch -p2 < ${./patch-samples.patch}";
+  patchPhaseSamples = "patch -p2 < ${./patches/patch-samples.patch}";
+  patches = [
+    ./patches/15.12-xstate-fp.patch
+    ./patches/15.9-kcl_str.patch
+    ./patches/15.9-mtrr.patch
+    ./patches/15.9-preempt.patch
+    ./patches/15.9-sep_printf.patch
+  ];
 
   buildInputs =
     [ xorg.libXrender xorg.libXext xorg.libX11 xorg.libXinerama xorg.libSM
@@ -101,7 +108,7 @@ stdenv.mkDerivation rec {
   # appear in /run/opengl-driver/lib which get's added to LD_LIBRARY_PATH
 
   extraDRIlibs = [ xorg.libXrandr.out xorg.libXrender.out xorg.libXext.out
-                   xorg.libX11.out xorg.libXinerama.out xorg.libSM.out 
+                   xorg.libX11.out xorg.libXinerama.out xorg.libSM.out
                    xorg.libICE.out ];
 
   inherit mesa; # only required to build the examples
diff --git a/pkgs/os-specific/linux/ati-drivers/kernel-api-fixes.patch b/pkgs/os-specific/linux/ati-drivers/kernel-api-fixes.patch
deleted file mode 100644
index f763518b249..00000000000
--- a/pkgs/os-specific/linux/ati-drivers/kernel-api-fixes.patch
+++ /dev/null
@@ -1,99 +0,0 @@
-diff -Nru 15.7/common/lib/modules/fglrx/build_mod/firegl_public.c 15.7.new/common/lib/modules/fglrx/build_mod/firegl_public.c
---- 15.7/common/lib/modules/fglrx/build_mod/firegl_public.c	2015-07-04 10:31:23.000000000 -0400
-+++ 15.7.new/common/lib/modules/fglrx/build_mod/firegl_public.c	2015-08-03 21:21:13.893211082 -0400
-@@ -242,6 +242,14 @@
- #endif
- 
- // ============================================================
-+
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,18,0)
-+#define __read_cr4 read_cr4
-+#define __write_cr4 write_cr4
-+#endif
-+
-+// ============================================================
-+
- /* globals */
- 
- char* firegl = NULL;
-@@ -3495,10 +3503,12 @@
-         KCL_PUB_InterruptHandlerWrap,
- #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
-         ((useMSI) ? (SA_INTERRUPT) : (SA_SHIRQ)),
--#else
-+#elif LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
-         //when MSI enabled. keep irq disabled when calling the action handler,
-         //exclude this IRQ from irq balancing (only on one CPU) 
-         ((useMSI) ? (IRQF_DISABLED) : (IRQF_SHARED)),    
-+#else
-+        ((useMSI) ? 0 : IRQF_SHARED),
- #endif
-         dev_name,
-         context);
-@@ -4498,8 +4508,8 @@
- 
-     if (cpu_has_pge)
-     {
--        cr4 = read_cr4();
--        write_cr4(cr4 & ~X86_CR4_PGE);
-+        cr4 = __read_cr4();
-+        __write_cr4(cr4 & ~X86_CR4_PGE);
-     }
-      __flush_tlb();
- 
-@@ -4512,7 +4522,7 @@
-     write_cr0(cr0 & 0xbfffffff);
-     if (cpu_has_pge)
-     {
--        write_cr4(cr4);
-+        __write_cr4(cr4);
-     }
-     local_irq_restore(flags);
- 
-@@ -4539,8 +4549,8 @@
- 
-     if (cpu_has_pge)
-     {
--        cr4 = read_cr4();
--        write_cr4(cr4 & ~X86_CR4_PGE);
-+        cr4 = __read_cr4();
-+        __write_cr4(cr4 & ~X86_CR4_PGE);
-     }
-      __flush_tlb();
-   
-@@ -4552,7 +4562,7 @@
-     write_cr0(cr0 & 0xbfffffff);
-     if (cpu_has_pge)
-     {
--        write_cr4(cr4);
-+        __write_cr4(cr4);
-     }
-     local_irq_restore(flags);
- 
-diff -Nru 15.7/common/lib/modules/fglrx/build_mod/kcl_acpi.c 15.7.new/common/lib/modules/fglrx/build_mod/kcl_acpi.c
---- 15.7/common/lib/modules/fglrx/build_mod/kcl_acpi.c	2015-07-04 10:31:23.000000000 -0400
-+++ 15.7.new/common/lib/modules/fglrx/build_mod/kcl_acpi.c	2015-08-02 19:59:54.797911610 -0400
-@@ -861,7 +861,10 @@
- #elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
-     if(pdev)
-     {
--       pci_ignore_hotplug(pdev);
-+      struct pci_dev *bridge = pdev->bus->self;
-+
-+      pdev->ignore_hotplug = 1;
-+      if(bridge) bridge->ignore_hotplug = 1; 
-     }
- #endif
- }
-diff -Nru 15.7/common/lib/modules/fglrx/build_mod/kcl_str.c 15.7.new/common/lib/modules/fglrx/build_mod/kcl_str.c
---- 15.7/common/lib/modules/fglrx/build_mod/kcl_str.c	2015-07-04 10:31:23.000000000 -0400
-+++ 15.7.new/common/lib/modules/fglrx/build_mod/kcl_str.c	2015-08-03 00:35:25.938410435 -0400
-@@ -169,7 +169,7 @@
-                                   const char* s2,
-                                   KCL_TYPE_SizeSigned count)
- {
--    return strnicmp(s1, s2, count);
-+    return strncasecmp(s1, s2, count);
- }
- 
- /** \brief Locate character in string
diff --git a/pkgs/os-specific/linux/ati-drivers/patches/15.12-xstate-fp.patch b/pkgs/os-specific/linux/ati-drivers/patches/15.12-xstate-fp.patch
new file mode 100644
index 00000000000..22e43fc0c7b
--- /dev/null
+++ b/pkgs/os-specific/linux/ati-drivers/patches/15.12-xstate-fp.patch
@@ -0,0 +1,26 @@
+From: Krzysztof Kolasa <kkolasa@winsoft.pl>
+Date: Thu, 26 Nov 2015 14:28:46 +0100
+Subject: [PATCH] Patch for kernel 4.4.0-rc2
+
+constant change of name XSTATE_XP to name XFEATURE_MASK_FP
+---
+ firegl_public.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/common/lib/modules/fglrx/build_mod/firegl_public.c b/common/lib/modules/fglrx/build_mod/firegl_public.c
+index 3626c7b..f071d42 100644
+--- a/common/lib/modules/fglrx/build_mod/firegl_public.c
++++ b/common/lib/modules/fglrx/build_mod//firegl_public.c
+@@ -6463,7 +6463,11 @@ static int KCL_fpu_save_init(struct task_struct *tsk)
+       if (!(fpu->state->xsave.xsave_hdr.xstate_bv & XSTATE_FP))
+ #else
+ 	  copy_xregs_to_kernel(&fpu->state.xsave);
+-      if (!(fpu->state.xsave.header.xfeatures & XSTATE_FP))
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)
++      if (!(fpu->state.xsave.header.xfeatures & XFEATURE_MASK_FP))
++#else
++      if (!(fpu->state.xsave.header.xfeatures & XSTATE_FP))
++#endif
+ #endif
+          return 1;
+    } else if (static_cpu_has(X86_FEATURE_FXSR)) {
diff --git a/pkgs/os-specific/linux/ati-drivers/patches/15.9-kcl_str.patch b/pkgs/os-specific/linux/ati-drivers/patches/15.9-kcl_str.patch
new file mode 100644
index 00000000000..20c3bc8a169
--- /dev/null
+++ b/pkgs/os-specific/linux/ati-drivers/patches/15.9-kcl_str.patch
@@ -0,0 +1,14 @@
+--- a/common/lib/modules/fglrx/build_mod/kcl_str.c	2015-09-13 13:47:30.000000000 -0400
++++ b/common/lib/modules/fglrx/build_mod/kcl_str.c	2015-09-13 13:49:42.000000000 -0400
+@@ -169,7 +169,11 @@ int ATI_API_CALL KCL_STR_Strnicmp(const
+                                   const char* s2,
+                                   KCL_TYPE_SizeSigned count)
+ {
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,0,0)
+     return strnicmp(s1, s2, count);
++#else
++    return strncasecmp(s1, s2, count);
++#endif
+ }
+ 
+ /** \brief Locate character in string
diff --git a/pkgs/os-specific/linux/ati-drivers/patches/15.9-mtrr.patch b/pkgs/os-specific/linux/ati-drivers/patches/15.9-mtrr.patch
new file mode 100644
index 00000000000..bdf70b4ccdc
--- /dev/null
+++ b/pkgs/os-specific/linux/ati-drivers/patches/15.9-mtrr.patch
@@ -0,0 +1,27 @@
+--- a/common/lib/modules/fglrx/build_mod/firegl_public.c	2015-09-19 23:43:22.000000000 -0400
++++ b/common/lib/modules/fglrx/build_mod/firegl_public.c	2015-09-19 23:52:07.000000000 -0400
+@@ -3442,7 +3442,11 @@ int ATI_API_CALL KCL_MEM_MTRR_Support(vo
+ int ATI_API_CALL KCL_MEM_MTRR_AddRegionWc(unsigned long base, unsigned long size)
+ {
+ #ifdef CONFIG_MTRR
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)
++    return arch_phys_wc_add(base, size);
++#else
+     return mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
++#endif
+ #else /* !CONFIG_MTRR */
+     return -EPERM;
+ #endif /* !CONFIG_MTRR */
+@@ -3451,7 +3455,12 @@ int ATI_API_CALL KCL_MEM_MTRR_AddRegionW
+ int ATI_API_CALL KCL_MEM_MTRR_DeleteRegion(int reg, unsigned long base, unsigned long size)
+ {
+ #ifdef CONFIG_MTRR
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)
++    arch_phys_wc_del(reg);
++    return reg;
++#else
+     return mtrr_del(reg, base, size);
++#endif
+ #else /* !CONFIG_MTRR */
+     return -EPERM;
+ #endif /* !CONFIG_MTRR */
diff --git a/pkgs/os-specific/linux/ati-drivers/patches/15.9-preempt.patch b/pkgs/os-specific/linux/ati-drivers/patches/15.9-preempt.patch
new file mode 100644
index 00000000000..c6598835133
--- /dev/null
+++ b/pkgs/os-specific/linux/ati-drivers/patches/15.9-preempt.patch
@@ -0,0 +1,103 @@
+--- a/common/lib/modules/fglrx/build_mod/firegl_public.c	2015-08-30 17:36:02.000000000 -0400
++++ b/common/lib/modules/fglrx/build_mod/firegl_public.c	2015-08-30 17:39:36.000000000 -0400
+@@ -21,6 +21,8 @@
+ !!! since it requires changes to linux/init/main.c.
+ #endif /* !MODULE */
+ 
++#include <linux/preempt.h>
++
+ // ============================================================
+ #include <linux/version.h>
+ 
+@@ -4997,7 +4999,9 @@ static unsigned int kas_spin_unlock(kas_
+ unsigned long ATI_API_CALL KAS_GetExecutionLevel(void)
+ {
+     unsigned long ret;
++    preempt_disable();
+     ret = kas_GetExecutionLevel();
++    preempt_enable();
+     return ret;
+ }
+ 
+@@ -5022,8 +5026,10 @@ unsigned int ATI_API_CALL KAS_Ih_Execute
+     KCL_DEBUG5(FN_FIREGL_KAS,"0x%08X, 0x%08X\n", ih_routine, ih_context);
+ 
+     //Prevent simultaneous entry on some SMP systems.
++    preempt_disable();
+     if (test_and_set_bit(0, (void *)&(kasContext.in_interrupts[smp_processor_id()])))
+     {
++    	preempt_enable();
+         KCL_DEBUG1(FN_FIREGL_KAS, "The processor is handling the interrupt\n");
+         return IRQ_NONE;
+     }
+@@ -5036,9 +5042,9 @@ unsigned int ATI_API_CALL KAS_Ih_Execute
+ 
+     kasSetExecutionLevel(orig_level);
+     spin_unlock(&kasContext.lock_ih); 
+-
+     clear_bit(0, (void *)&(kasContext.in_interrupts[smp_processor_id()]));
+     KCL_DEBUG5(FN_FIREGL_KAS,"%d\n", ret);
++    preempt_enable();
+ 
+     return ret;
+ }
+@@ -5256,6 +5262,7 @@ unsigned int ATI_API_CALL KAS_Spinlock_A
+ 
+     KCL_DEBUG5(FN_FIREGL_KAS,"0x%08X\n", hSpinLock);
+ 
++    preempt_disable();
+     spin_lock_info.routine_type = spinlock_obj->routine_type;
+     spin_lock_info.plock = &(spinlock_obj->lock);
+ 
+@@ -5263,6 +5270,7 @@ unsigned int ATI_API_CALL KAS_Spinlock_A
+ 
+     spinlock_obj->acquire_type = spin_lock_info.acquire_type;
+     spinlock_obj->flags = spin_lock_info.flags;
++    preempt_enable();
+ 
+     KCL_DEBUG5(FN_FIREGL_KAS,"%d\n", ret);
+     return ret;
+@@ -6034,6 +6042,8 @@ unsigned int ATI_API_CALL KAS_Interlocke
+ 
+     KCL_DEBUG5(FN_FIREGL_KAS,"0x%08X, 0x%08X, 0x%08X\n", hListHead, hListEntry, phPrevEntry);
+ 
++    preempt_disable();
++
+     /* Protect the operation with spinlock */
+     spin_lock_info.routine_type = listhead_obj->routine_type;
+     spin_lock_info.plock = &(listhead_obj->lock);
+@@ -6041,6 +6051,7 @@ unsigned int ATI_API_CALL KAS_Interlocke
+     if (!kas_spin_lock(&spin_lock_info))
+     {
+         KCL_DEBUG_ERROR("Unable to grab list spinlock\n");
++	preempt_enable();
+         return 0; /* No spinlock - no operation */
+     }
+ 
+@@ -6065,6 +6076,7 @@ unsigned int ATI_API_CALL KAS_Interlocke
+     spin_unlock_info.flags = spin_lock_info.flags;
+ 
+     ret = kas_spin_unlock(&spin_unlock_info);
++    preempt_enable();
+     KCL_DEBUG5(FN_FIREGL_KAS,"%d", ret);
+     return ret;
+ }
+@@ -6153,8 +6165,10 @@ unsigned int ATI_API_CALL KAS_Interlocke
+     spin_lock_info.routine_type = listhead_obj->routine_type;
+     spin_lock_info.plock = &(listhead_obj->lock);
+ 
++    preempt_disable();
+     if (!kas_spin_lock(&spin_lock_info))
+     {
++        preempt_enable();
+         KCL_DEBUG_ERROR("Unable to grab list spinlock");
+         return 0; /* No spinlock - no operation */
+     }
+@@ -6178,6 +6192,7 @@ unsigned int ATI_API_CALL KAS_Interlocke
+     spin_unlock_info.flags = spin_lock_info.flags;
+ 
+     ret = kas_spin_unlock(&spin_unlock_info);
++    preempt_enable();
+     KCL_DEBUG5(FN_FIREGL_KAS,"%d", ret);
+     return ret;
+ }
diff --git a/pkgs/os-specific/linux/ati-drivers/patches/15.9-sep_printf.patch b/pkgs/os-specific/linux/ati-drivers/patches/15.9-sep_printf.patch
new file mode 100644
index 00000000000..3e4e8d6499a
--- /dev/null
+++ b/pkgs/os-specific/linux/ati-drivers/patches/15.9-sep_printf.patch
@@ -0,0 +1,11 @@
+--- a/common/lib/modules/fglrx/build_mod/firegl_public.c	2015-09-14 15:14:36.000000000 -0400
++++ b/common/lib/modules/fglrx/build_mod/firegl_public.c	2015-09-14 16:18:58.000000000 -0400
+@@ -649,6 +649,8 @@ static int firegl_major_proc_read(struct
+     *eof = 1;
+ 
+     len = snprintf(buf, request, "%d\n", major);
++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)
++    seq_printf(m, "%d\n", major);
+ #else
+     len = seq_printf(m, "%d\n", major);
+ #endif
diff --git a/pkgs/os-specific/linux/ati-drivers/patch-samples.patch b/pkgs/os-specific/linux/ati-drivers/patches/patch-samples.patch
index 8bd24b1d022..8bd24b1d022 100644
--- a/pkgs/os-specific/linux/ati-drivers/patch-samples.patch
+++ b/pkgs/os-specific/linux/ati-drivers/patches/patch-samples.patch