0003-Add-support-for-Linux-4.2.patch 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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
  5. Deal with the FPU code renaming
  6. Signed-off-by: Romain Perier <romain.perier@free-electrons.com>
  7. ---
  8. common/lib/modules/fglrx/build_mod/firegl_public.c | 38 ++++++++++++++++++++++
  9. 1 file changed, 38 insertions(+)
  10. diff --git a/common/lib/modules/fglrx/build_mod/firegl_public.c b/common/lib/modules/fglrx/build_mod/firegl_public.c
  11. index 94778f1..749ea51 100755
  12. --- a/common/lib/modules/fglrx/build_mod/firegl_public.c
  13. +++ b/common/lib/modules/fglrx/build_mod/firegl_public.c
  14. @@ -191,9 +191,17 @@
  15. #include <linux/string.h>
  16. #include <linux/gfp.h>
  17. #include <linux/swap.h>
  18. +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
  19. #include "asm/i387.h"
  20. +#else
  21. +#include <asm/fpu/api.h>
  22. +#endif
  23. #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)
  24. +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
  25. #include <asm/fpu-internal.h>
  26. +#else
  27. +#include <asm/fpu/internal.h>
  28. +#endif
  29. #endif
  30. #include "firegl_public.h"
  31. @@ -1711,6 +1719,9 @@ void ATI_API_CALL KCL_SetCurrentProcessState(KCL_ENUM_ProcessState state)
  32. #if defined(__i386__)
  33. #ifndef __HAVE_ARCH_CMPXCHG
  34. +#ifndef __xg
  35. +#define __xg(x) ((volatile long *)(x))
  36. +#endif
  37. static inline
  38. unsigned long __fgl_cmpxchg(volatile void *ptr, unsigned long old,
  39. unsigned long new, int size)
  40. @@ -1747,7 +1758,11 @@ unsigned long ATI_API_CALL kcl__cmpxchg(volatile void *ptr, unsigned long old,
  41. unsigned long new, int size)
  42. {
  43. #ifndef __HAVE_ARCH_CMPXCHG
  44. +#if defined(__i386__)
  45. return __fgl_cmpxchg(ptr,old,new,size);
  46. +#elif defined(__x86_64__)
  47. + return cmpxchg((unsigned long*)ptr,old,new);
  48. +#endif
  49. #else
  50. /* On kernel version 2.6.34 passing a variable or unsupported size
  51. * argument to the __cmpxchg macro causes the default-clause of a
  52. @@ -6443,21 +6458,36 @@ static int KCL_fpu_save_init(struct task_struct *tsk)
  53. struct fpu *fpu = &tsk->thread.fpu;
  54. if(static_cpu_has(X86_FEATURE_XSAVE)) {
  55. +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
  56. fpu_xsave(fpu);
  57. if (!(fpu->state->xsave.xsave_hdr.xstate_bv & XSTATE_FP))
  58. +#else
  59. + copy_xregs_to_kernel(&fpu->state.xsave);
  60. + if (!(fpu->state.xsave.header.xfeatures & XSTATE_FP))
  61. +#endif
  62. return 1;
  63. } else if (static_cpu_has(X86_FEATURE_FXSR)) {
  64. +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
  65. fpu_fxsave(fpu);
  66. +#else
  67. + copy_fxregs_to_kernel(fpu);
  68. +#endif
  69. } else {
  70. asm volatile("fnsave %[fx]; fwait"
  71. +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
  72. : [fx] "=m" (fpu->state->fsave));
  73. +#else
  74. + : [fx] "=m" (fpu->state.fsave));
  75. +#endif
  76. return 0;
  77. }
  78. +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
  79. if (unlikely(fpu->state->fxsave.swd & X87_FSW_ES)) {
  80. asm volatile("fnclex");
  81. return 0;
  82. }
  83. +#endif
  84. return 1;
  85. }
  86. #endif
  87. @@ -6469,8 +6499,12 @@ static int KCL_fpu_save_init(struct task_struct *tsk)
  88. void ATI_API_CALL KCL_fpu_begin(void)
  89. {
  90. #ifdef CONFIG_X86_64
  91. +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
  92. kernel_fpu_begin();
  93. #else
  94. + __kernel_fpu_begin();
  95. +#endif
  96. +#else
  97. #ifdef TS_USEDFPU
  98. struct thread_info *cur_thread = current_thread_info();
  99. struct task_struct *cur_task = get_current();
  100. @@ -6515,7 +6549,11 @@ void ATI_API_CALL KCL_fpu_begin(void)
  101. */
  102. void ATI_API_CALL KCL_fpu_end(void)
  103. {
  104. +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
  105. kernel_fpu_end();
  106. +#else
  107. + __kernel_fpu_end();
  108. +#endif
  109. }
  110. /** Create new directory entry under "/proc/...."
  111. --
  112. 2.8.1