buildroot/package/amd-catalyst/0003-Add-support-for-Linux-4.2.patch
Romain Perier 689ae6e404 package/amd-catalyst: Add AMD proprietary graphic stack support
This commits adds support for the AMD Catalyst Linux driver 15.9
(15.201.1151). It includes the fglrx kernel module with various fixes
to make it work with at least Linux kernel 4.4 LTS, the userspace OpenGL
stack and the xorg driver module.

Signed-off-by: Romain Perier <romain.perier@free-electrons.com>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
[Thomas:
 - fixup whitespace issues noticed by Yann.
 - register AMD_CATALYST_PREPARE_MODULE as a post-patch hook rather than
   calling it during the configure step, also suggested by Yann.]
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2016-08-23 18:00:40 +02:00

122 lines
3.6 KiB
Diff

From e2e6c2dac2a0311a022208dd289374b832538329 Mon Sep 17 00:00:00 2001
From: Alberto Milone <alberto.milone@canonical.com>
Date: Tue, 14 Jul 2015 12:56:37 +0200
Subject: [PATCH] Add support for Linux 4.2
Deal with the FPU code renaming
Signed-off-by: Romain Perier <romain.perier@free-electrons.com>
---
common/lib/modules/fglrx/build_mod/firegl_public.c | 38 ++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/common/lib/modules/fglrx/build_mod/firegl_public.c b/common/lib/modules/fglrx/build_mod/firegl_public.c
index 94778f1..749ea51 100755
--- a/common/lib/modules/fglrx/build_mod/firegl_public.c
+++ b/common/lib/modules/fglrx/build_mod/firegl_public.c
@@ -191,9 +191,17 @@
#include <linux/string.h>
#include <linux/gfp.h>
#include <linux/swap.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
#include "asm/i387.h"
+#else
+#include <asm/fpu/api.h>
+#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
#include <asm/fpu-internal.h>
+#else
+#include <asm/fpu/internal.h>
+#endif
#endif
#include "firegl_public.h"
@@ -1711,6 +1719,9 @@ void ATI_API_CALL KCL_SetCurrentProcessState(KCL_ENUM_ProcessState state)
#if defined(__i386__)
#ifndef __HAVE_ARCH_CMPXCHG
+#ifndef __xg
+#define __xg(x) ((volatile long *)(x))
+#endif
static inline
unsigned long __fgl_cmpxchg(volatile void *ptr, unsigned long old,
unsigned long new, int size)
@@ -1747,7 +1758,11 @@ unsigned long ATI_API_CALL kcl__cmpxchg(volatile void *ptr, unsigned long old,
unsigned long new, int size)
{
#ifndef __HAVE_ARCH_CMPXCHG
+#if defined(__i386__)
return __fgl_cmpxchg(ptr,old,new,size);
+#elif defined(__x86_64__)
+ return cmpxchg((unsigned long*)ptr,old,new);
+#endif
#else
/* On kernel version 2.6.34 passing a variable or unsupported size
* argument to the __cmpxchg macro causes the default-clause of a
@@ -6443,21 +6458,36 @@ static int KCL_fpu_save_init(struct task_struct *tsk)
struct fpu *fpu = &tsk->thread.fpu;
if(static_cpu_has(X86_FEATURE_XSAVE)) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
fpu_xsave(fpu);
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))
+#endif
return 1;
} else if (static_cpu_has(X86_FEATURE_FXSR)) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
fpu_fxsave(fpu);
+#else
+ copy_fxregs_to_kernel(fpu);
+#endif
} else {
asm volatile("fnsave %[fx]; fwait"
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
: [fx] "=m" (fpu->state->fsave));
+#else
+ : [fx] "=m" (fpu->state.fsave));
+#endif
return 0;
}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
if (unlikely(fpu->state->fxsave.swd & X87_FSW_ES)) {
asm volatile("fnclex");
return 0;
}
+#endif
return 1;
}
#endif
@@ -6469,8 +6499,12 @@ static int KCL_fpu_save_init(struct task_struct *tsk)
void ATI_API_CALL KCL_fpu_begin(void)
{
#ifdef CONFIG_X86_64
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
kernel_fpu_begin();
#else
+ __kernel_fpu_begin();
+#endif
+#else
#ifdef TS_USEDFPU
struct thread_info *cur_thread = current_thread_info();
struct task_struct *cur_task = get_current();
@@ -6515,7 +6549,11 @@ void ATI_API_CALL KCL_fpu_begin(void)
*/
void ATI_API_CALL KCL_fpu_end(void)
{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
kernel_fpu_end();
+#else
+ __kernel_fpu_end();
+#endif
}
/** Create new directory entry under "/proc/...."
--
2.8.1