1 From e2e6c2dac2a0311a022208dd289374b832538329 Mon Sep 17 00:00:00 2001
2 From: Alberto Milone <alberto.milone@canonical.com>
3 Date: Tue, 14 Jul 2015 12:56:37 +0200
4 Subject: [PATCH] Add support for Linux 4.2
6 Deal with the FPU code renaming
8 Signed-off-by: Romain Perier <romain.perier@free-electrons.com>
10 common/lib/modules/fglrx/build_mod/firegl_public.c | 38 ++++++++++++++++++++++
11 1 file changed, 38 insertions(+)
13 diff --git a/common/lib/modules/fglrx/build_mod/firegl_public.c b/common/lib/modules/fglrx/build_mod/firegl_public.c
14 index 94778f1..749ea51 100755
15 --- a/common/lib/modules/fglrx/build_mod/firegl_public.c
16 +++ b/common/lib/modules/fglrx/build_mod/firegl_public.c
18 #include <linux/string.h>
19 #include <linux/gfp.h>
20 #include <linux/swap.h>
21 +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
24 +#include <asm/fpu/api.h>
26 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)
27 +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
28 #include <asm/fpu-internal.h>
30 +#include <asm/fpu/internal.h>
34 #include "firegl_public.h"
35 @@ -1711,6 +1719,9 @@ void ATI_API_CALL KCL_SetCurrentProcessState(KCL_ENUM_ProcessState state)
38 #ifndef __HAVE_ARCH_CMPXCHG
40 +#define __xg(x) ((volatile long *)(x))
43 unsigned long __fgl_cmpxchg(volatile void *ptr, unsigned long old,
44 unsigned long new, int size)
45 @@ -1747,7 +1758,11 @@ unsigned long ATI_API_CALL kcl__cmpxchg(volatile void *ptr, unsigned long old,
46 unsigned long new, int size)
48 #ifndef __HAVE_ARCH_CMPXCHG
49 +#if defined(__i386__)
50 return __fgl_cmpxchg(ptr,old,new,size);
51 +#elif defined(__x86_64__)
52 + return cmpxchg((unsigned long*)ptr,old,new);
55 /* On kernel version 2.6.34 passing a variable or unsupported size
56 * argument to the __cmpxchg macro causes the default-clause of a
57 @@ -6443,21 +6458,36 @@ static int KCL_fpu_save_init(struct task_struct *tsk)
58 struct fpu *fpu = &tsk->thread.fpu;
60 if(static_cpu_has(X86_FEATURE_XSAVE)) {
61 +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
63 if (!(fpu->state->xsave.xsave_hdr.xstate_bv & XSTATE_FP))
65 + copy_xregs_to_kernel(&fpu->state.xsave);
66 + if (!(fpu->state.xsave.header.xfeatures & XSTATE_FP))
69 } else if (static_cpu_has(X86_FEATURE_FXSR)) {
70 +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
73 + copy_fxregs_to_kernel(fpu);
76 asm volatile("fnsave %[fx]; fwait"
77 +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
78 : [fx] "=m" (fpu->state->fsave));
80 + : [fx] "=m" (fpu->state.fsave));
85 +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
86 if (unlikely(fpu->state->fxsave.swd & X87_FSW_ES)) {
87 asm volatile("fnclex");
94 @@ -6469,8 +6499,12 @@ static int KCL_fpu_save_init(struct task_struct *tsk)
95 void ATI_API_CALL KCL_fpu_begin(void)
98 +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
101 + __kernel_fpu_begin();
105 struct thread_info *cur_thread = current_thread_info();
106 struct task_struct *cur_task = get_current();
107 @@ -6515,7 +6549,11 @@ void ATI_API_CALL KCL_fpu_begin(void)
109 void ATI_API_CALL KCL_fpu_end(void)
111 +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
114 + __kernel_fpu_end();
118 /** Create new directory entry under "/proc/...."