1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-09-11 15:08:33 +01:00

ati-drivers: migrate some patches from gentoo ati-drivers

https://anaongit.gentoo.org/git/repo/gentoo.git @ 52dac7bdbb16f2353b15137165b69056034d7ad0
and parents for further source information.
This commit is contained in:
Edward Tjörnhammar 2016-05-20 13:05:41 +02:00
parent 2d6d731f24
commit f7aed7a00d
No known key found for this signature in database
GPG key ID: 7B82CE4A866B6845
9 changed files with 199 additions and 105 deletions

View file

@ -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}/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
)
{

View file

@ -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

View file

@ -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

View file

@ -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)) {

View file

@ -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

View file

@ -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 */

View file

@ -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;
}

View file

@ -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