Announcement

Collapse
No announcement yet.

Patch to compile fgrlx module on Linux 3.3.rc4 with x86 32 bit arch

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Patch to compile fgrlx module on Linux 3.3.rc4 with x86 32 bit arch

    Hi all,
    due to this commit:

    https://github.com/torvalds/linux/co...949a703977a7f3

    the fgrlx module fails to compile on kernel 3.3-rc4 with the 32-bit x86 architecture, with this error:

    Code:
    DKMS make.log for fglrx-8.930 for kernel 3.3.0-rc4-extra-drivers (i686)
    mar 21 feb 2012, 14.36.00, CET
    AMD kernel module generator version 2.1
    [: 393: 1: unexpected operator
    [: 399: 1: unexpected operator
    doing Makefile based build for kernel 2.6.x and higher
    rm -rf *.c *.h *.o *.ko *.a .??* *.symvers
    make -C /lib/modules/3.3.0-rc4-extra-drivers/build SUBDIRS=/var/lib/dkms/fglrx/8.930/build/2.6.x modules
    make[1]: ingresso nella directory "/home/jena/experimental-kernel/linux-3.3-rc4"
      CC [M]  /var/lib/dkms/fglrx/8.930/build/2.6.x/firegl_public.o
    In file included from /var/lib/dkms/fglrx/8.930/build/2.6.x/firegl_public.c:192:0:
    /var/lib/dkms/fglrx/8.930/build/2.6.x/kcl_debug.h:202:5: warning: "_DEBUG" is not defined [-Wundef]
    /var/lib/dkms/fglrx/8.930/build/2.6.x/firegl_public.c: In function ‘KCL_fpu_begin’:
    /var/lib/dkms/fglrx/8.930/build/2.6.x/firegl_public.c:5802:28: error: ‘TS_USEDFPU’ undeclared (first use in this function)
    /var/lib/dkms/fglrx/8.930/build/2.6.x/firegl_public.c:5802:28: note: each undeclared identifier is reported only once for each function it appears in
    /var/lib/dkms/fglrx/8.930/build/2.6.x/firegl_public.c: At top level:
    /var/lib/dkms/fglrx/8.930/build/2.6.x/kcl_debug.h:162:16: warning: ‘module_log_map’ defined but not used [-Wunused-variable]
    /var/lib/dkms/fglrx/8.930/build/2.6.x/kcl_debug.h:175:19: warning: ‘module_type_map’ defined but not used [-Wunused-variable]
    make[2]: *** [/var/lib/dkms/fglrx/8.930/build/2.6.x/firegl_public.o] Errore 1
    make[1]: *** [_module_/var/lib/dkms/fglrx/8.930/build/2.6.x] Errore 2
    make[1]: uscita dalla directory "/home/jena/experimental-kernel/linux-3.3-rc4"
    make: *** [kmod_build] Errore 2
    build failed with return value 2
    This patch fixes the problem:

    Code:
    fixed fgrlx compilation error on 32-bit x86 arch with kernel 3.3-rc4 due to commit:
    https://github.com/torvalds/linux/commit/f94edacf998516ac9d849f7bc6949a703977a7f3
    
    Signed-off-by: Gianluca Gennari <gennarone@gmail.com>
    ---
     firegl_public.c |    9 +++++++++
     1 files changed, 9 insertions(+), 0 deletions(-)
    
    diff --git a/firegl_public.c b/firegl_public.c
    index 6e0aa82..5010b91 100644
    --- a/firegl_public.c
    +++ b/firegl_public.c
    @@ -5797,6 +5797,14 @@ void ATI_API_CALL KCL_fpu_begin(void)
     #ifdef CONFIG_X86_64
         kernel_fpu_begin();
     #else
    +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
    +    struct task_struct *tsk = current;
    +    preempt_disable();
    +    if (tsk->thread.has_fpu)
    +        __save_init_fpu(tsk);
    +    else
    +        clts();
    +#else
         struct thread_info *cur_task = current_thread_info();
         preempt_disable();
         if (cur_task->status & TS_USEDFPU)
    @@ -5804,6 +5812,7 @@ void ATI_API_CALL KCL_fpu_begin(void)
         else
             clts();
     #endif
    +#endif
     }
     
     /** \brief End of using FPU
    -- 
    1.7.5.4
    Regards,
    Gennar1

  • #2
    Eh, sorry. I missed that. A geometric mean makes more sense, since we want to favour lower scores (lower scores tend to indicate some bottleneck, and us users notice the bottlenecks)

    Comment


    • #3
      There is a further change in kernel 3.3-rc5. Also, the changes have been backported to kernel 3.2.8:

      https://lwn.net/Articles/484042/

      So this new version of the patch applies to all kernels >= 3.2.8:

      Code:
      fixed fgrlx compilation error on 32-bit x86 arch with kernel 3.3-rc4 due to commit:
      https://github.com/torvalds/linux/commit/f94edacf998516ac9d849f7bc6949a703977a7f3
      later modified (in 3.3-rc5) by commit:
      https://github.com/torvalds/linux/commit/7e16838d94b566a17b65231073d179bc04d590c8#diff-1
      and finally backported to kernel 3.2.8.
      
      Signed-off-by: Gianluca Gennari <gennarone@gmail.com>
      ---
       firegl_public.c |    6 ++++++
       1 files changed, 6 insertions(+), 0 deletions(-)
      
      diff --git a/firegl_public.c b/firegl_public.c
      index 6e0aa82..cb9e217 100644
      --- a/firegl_public.c
      +++ b/firegl_public.c
      @@ -5797,10 +5797,16 @@ void ATI_API_CALL KCL_fpu_begin(void)
       #ifdef CONFIG_X86_64
           kernel_fpu_begin();
       #else
      +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,8)
      +    preempt_disable();
      +    if (__thread_has_fpu(current))
      +        __save_init_fpu(current);
      +#else
           struct thread_info *cur_task = current_thread_info();
           preempt_disable();
           if (cur_task->status & TS_USEDFPU)
               __save_init_fpu(cur_task->task);
      +#endif
           else
               clts();
       #endif
      -- 
      1.7.5.4

      Comment


      • #4
        Interesting patch, but how do you hande distro kernels which still report 3.2.0?

        Comment


        • #5
          Nice question.

          Maybe a smarter solution would be to check if TS_USEDFPU is defined or not, instead of looking at the kernel version.

          I mean something like this (beware that this patch is not tested!):

          Code:
          fixed fgrlx compilation error on 32-bit x86 arch with kernel 3.3-rc4 due to commit:
          https://github.com/torvalds/linux/commit/f94edacf998516ac9d849f7bc6949a703977a7f3
          later modified (in 3.3-rc5) by commit:
          https://github.com/torvalds/linux/commit/7e16838d94b566a17b65231073d179bc04d590c8#diff-1
          and finally backported to kernel 3.2.8.
          
          Signed-off-by: Gianluca Gennari <gennarone@gmail.com>
          ---
           firegl_public.c |    6 ++++++
           1 files changed, 6 insertions(+), 0 deletions(-)
          
          diff --git a/firegl_public.c b/firegl_public.c
          index 6e0aa82..cb9e217 100644
          --- a/firegl_public.c
          +++ b/firegl_public.c
          @@ -5797,10 +5797,16 @@ void ATI_API_CALL KCL_fpu_begin(void)
           #ifdef CONFIG_X86_64
               kernel_fpu_begin();
           #else
          +#ifndef TS_USEDFPU
          +    preempt_disable();
          +    if (__thread_has_fpu(current))
          +        __save_init_fpu(current);
          +#else
               struct thread_info *cur_task = current_thread_info();
               preempt_disable();
               if (cur_task->status & TS_USEDFPU)
                   __save_init_fpu(cur_task->task);
          +#endif
               else
                   clts();
           #endif
          -- 
          1.7.5.4

          Comment


          • #6
            Sorry but how exactly do I use this patch?

            Comment


            • #7
              The patch must be applied to the file firegl_public.c .
              On my Ubuntu 11.10 system, it is installed in /usr/src/fglrx-8.950 (the patch was originally developed on fglrx-8.930 but is still required on the new fglrx-8.950).

              Select all the patch text and copy/paste it into a new text file (you can use the third version of the patch, it works well on all kernel versions). Save it on your home directory and name it, for example, fglrx.patch .
              Then you have to run something like this:

              Code:
              cd /usr/src/fglrx-8.950
              sudo patch -p1 < ~/fglrx.patch
              Now you can install the new kernel. On Ubuntu, you can use .deb packages to install new kernels, and the fglrx module is built automatically by the install script.

              The patch is required to build the fgrlx module against all 3.2 kernels >= 3.2.8 and all 3.3 kernels >= 3.3-rc4 with the x86 32 bit architecture. The 64 bit kernels are not affected by the problem.
              Last edited by Gennar1; 03-10-2012, 08:43 PM.

              Comment


              • #8
                Thanks, that worked.

                Comment


                • #9
                  Hello, I have a x64 and can't compile

                  uname -r: 3.2.10-1.fc16.x86_64 (I try with others kernels and the same result):


                  Code:
                  Detected configuration:
                  Architecture: x86_64 (64-bit)
                  X Server: X.Org 6.9 or later 64-bit
                  loki_setup: directory: (null)
                  DKMS part of installation failed.  Please refer to /usr/share/ati/fglrx-install.log for details
                  Removing temporary directory: fglrx-install.S5pNDk
                  [drekion@drekion-laptop Descargas]$ cat /usr/share/ati/fglrx-install.log Detected a previous installation, /usr/share/ati/amd-uninstall.sh
                  Dryrun uninstall succeeded continuing with installation.
                  Uninstalling any previously installed drivers.
                  Forcing uninstall of AMD Catalyst(TM) Proprietary Driver.
                  No integrity verification is done.
                  restore of system environment completed
                  Errors during DKMS module removal
                  Uninstall fglrx driver complete.
                  For detailed log of uninstall, please see /etc/ati/fglrx-uninstall.log
                  System must be rebooted to avoid system instability and potential data loss.
                  /usr/share/ati/amd-uninstall.sh completed with 0
                  
                  Creating symlink /var/lib/dkms/fglrx/8.95/source ->
                                   /usr/src/fglrx-8.95
                  
                  DKMS: add completed.
                  
                  Kernel preparation unnecessary for this kernel.  Skipping...
                  
                  Building module:
                  cleaning build area....
                  cd /var/lib/dkms/fglrx/8.95/build; sh make.sh --nohints --uname_r=3.2.10-1.fc16.x86_64 --norootcheck....(bad exit status: 1)
                  [Error] Kernel Module : Failed to build fglrx-8.95 with DKMS
                  [Error] Kernel Module : Removing fglrx-8.95 from DKMS
                  
                  ------------------------------
                  Deleting module version: 8.95
                  completely from the DKMS tree.
                  ------------------------------
                  Done.
                  [Reboot] Kernel Module : dracut
                  can help me?

                  Comment


                  • #10
                    Originally posted by dreKion View Post
                    Hello, I have a x64 and can't compile
                    uname -r: 3.2.10-1.fc16.x86_64 (I try with others kernels and the same result):
                    can help me?
                    Sorry, I can't. For sure it's not related to the problem discussed in this topic, as 64 bit systems are not affected. Also, I compiled the latest fglrx against 3.2.10 without problems. Probably you have a new version of Xorg that is not supported yet by the fgrlx module. Look into /usr/share/ati/fglrx-install.log for details about your problem.

                    Comment


                    • #11
                      Another update of the patch for the newly released kernel 3.4-rc1. In the new kernel several header files have been cleaned-up and splitted into smaller files, so now we have to include a new header file. Again, this is only required for 32 bit kernels.

                      The patch has been tested with fglrx 8.951 (Catalyst 12.3) and the 3.4-rc1 vanilla kernel (32 bit).

                      Code:
                      fixed fgrlx compilation error on 32-bit x86 arch with kernel 3.3-rc4 due to commit:
                      https://github.com/torvalds/linux/commit/f94edacf998516ac9d849f7bc6949a703977a7f3
                      later modified (in 3.3-rc5) by commit:
                      https://github.com/torvalds/linux/commit/7e16838d94b566a17b65231073d179bc04d590c8#diff-1
                      and finally backported to kernel 3.2.8.
                      
                      This new version adds support for the 3.4 kernels, where some ASM header
                      file was splitted into several smaller files, so we have to explicitally
                      include the new file <asm/fpu-internal.h>.
                      
                      Signed-off-by: Gianluca Gennari <gennarone@gmail.com>
                      ---
                       firegl_public.c |    9 +++++++++
                       1 files changed, 9 insertions(+), 0 deletions(-)
                      
                      diff --git a/firegl_public.c b/firegl_public.c
                      index a56fff1..2858170 100644
                      --- a/firegl_public.c
                      +++ b/firegl_public.c
                      @@ -187,6 +187,9 @@
                       #include <linux/gfp.h>
                       #include <linux/swap.h>
                       #include "asm/i387.h"
                      +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)
                      +#include <asm/fpu-internal.h>
                      +#endif
                       
                       #include "firegl_public.h"
                       #include "kcl_osconfig.h"
                      @@ -5799,10 +5802,16 @@ void ATI_API_CALL KCL_fpu_begin(void)
                       #ifdef CONFIG_X86_64
                           kernel_fpu_begin();
                       #else
                      +#ifndef TS_USEDFPU
                      +    preempt_disable();
                      +    if (__thread_has_fpu(current))
                      +        __save_init_fpu(current);
                      +#else
                           struct thread_info *cur_task = current_thread_info();
                           preempt_disable();
                           if (cur_task->status & TS_USEDFPU)
                               __save_init_fpu(cur_task->task);
                      +#endif
                           else
                               clts();
                       #endif
                      -- 
                      1.7.5.4

                      Comment


                      • #12
                        Unfortunately I get a

                        Code:
                        patching file firegl_public.c
                        Hunk #2 FAILED at 5802.
                        1 out of 2 hunks FAILED -- saving rejects to file firegl_public.c.rej
                        this time.


                        firegl_public.c.rej:
                        Code:
                        --- firegl_public.c
                        +++ firegl_public.c
                        @@ -5802,10 +5805,16 @@
                         #ifdef CONFIG_X86_64
                             kernel_fpu_begin();
                         #else
                        +#ifndef TS_USEDFPU
                        +    preempt_disable();
                        +    if (__thread_has_fpu(current))
                        +        __save_init_fpu(current);
                        +#else
                             struct thread_info *cur_task = current_thread_info();
                             preempt_disable();
                             if (cur_task->status & TS_USEDFPU)
                                 __save_init_fpu(cur_task->task);
                        +#endif
                             else
                                 clts();
                         #endif

                        Comment


                        • #13
                          Strange. Maybe a copy&paste problem?

                          Anyway, here is another version of the patch, required to build the fglrx module against kernel 3.4-rc2.
                          This time, cpu_possible_map has been dropped in favor of cpu_possible_mask.
                          Probably, this trivial change is necessary also for 64 bit kernels, but I have not tested it.

                          Anyway, this is the new patch:

                          Code:
                          fixed fgrlx compilation error on 32-bit x86 arch with kernel 3.3-rc4 due to commit:
                          https://github.com/torvalds/linux/commit/f94edacf998516ac9d849f7bc6949a703977a7f3
                          later modified (in 3.3-rc5) by commit:
                          https://github.com/torvalds/linux/commit/7e16838d94b566a17b65231073d179bc04d590c8#diff-1
                          and finally backported to kernel 3.2.8.
                          
                          This new version adds support for the 3.4 kernels, where some ASM header
                          file was splitted into several smaller files, so we have to explicitally
                          include the new file <asm/fpu-internal.h>.
                          
                          Since 3.4-rc2, cpu_possible_map has been definitely removed. Let's use
                          cpu_possible_mask instead. This is probably required also for 64 bit kernels.
                          
                          Signed-off-by: Gianluca Gennari <gennarone@gmail.com>
                          ---
                           firegl_public.c |   13 +++++++++++++
                           1 files changed, 13 insertions(+), 0 deletions(-)
                          
                          diff --git a/firegl_public.c b/firegl_public.c
                          index a56fff1..b4bdfb7 100644
                          --- a/firegl_public.c
                          +++ b/firegl_public.c
                          @@ -187,6 +187,9 @@
                           #include <linux/gfp.h>
                           #include <linux/swap.h>
                           #include "asm/i387.h"
                          +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)
                          +#include <asm/fpu-internal.h>
                          +#endif
                           
                           #include "firegl_public.h"
                           #include "kcl_osconfig.h"
                          @@ -4181,7 +4184,11 @@ static int kasInitExecutionLevels(unsigned long level_init)
                           {
                               unsigned int p;
                               KCL_DEBUG5(FN_FIREGL_KAS, "%d\n", level_init);
                          +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)
                          +    for_each_cpu_mask(p, cpu_possible_mask)
                          +#else
                               for_each_cpu_mask(p, cpu_possible_map)
                          +#endif
                               {
                                   KCL_DEBUG1(FN_FIREGL_KAS,"Setting initial execution level for CPU # %d\n", p);
                                   preempt_disable();
                          @@ -5799,10 +5806,16 @@ void ATI_API_CALL KCL_fpu_begin(void)
                           #ifdef CONFIG_X86_64
                               kernel_fpu_begin();
                           #else
                          +#ifndef TS_USEDFPU
                          +    preempt_disable();
                          +    if (__thread_has_fpu(current))
                          +        __save_init_fpu(current);
                          +#else
                               struct thread_info *cur_task = current_thread_info();
                               preempt_disable();
                               if (cur_task->status & TS_USEDFPU)
                                   __save_init_fpu(cur_task->task);
                          +#endif
                               else
                                   clts();
                           #endif
                          -- 
                          1.7.5.4

                          Comment


                          • #14
                            I have apply this patch.. and after i have try to reinstall the .deb of catalyst 12.3.... i obtain this:
                            Code:
                            diabolik@Diabolik-ubuntu:~/catalyst12.3$ sudo dpkg -i fgl*.deb
                            (Lettura del database... 323026 file e directory attualmente installati.)
                            Preparativi per sostituire fglrx v.2:8.951-0ubuntu1 (utilizzando fglrx_8.951-0ubuntu1_i386.deb)...
                            Removing all DKMS Modules
                            Done.
                            Estrazione del sostituto di fglrx...
                            Preparativi per sostituire fglrx-amdcccle v.2:8.951-0ubuntu1 (utilizzando fglrx-amdcccle_8.951-0ubuntu1_i386.deb)...
                            Estrazione del sostituto di fglrx-amdcccle...
                            Preparativi per sostituire fglrx-dev v.2:8.951-0ubuntu1 (utilizzando fglrx-dev_8.951-0ubuntu1_i386.deb)...
                            Estrazione del sostituto di fglrx-dev...
                            Configurazione di fglrx (2:8.951-0ubuntu1)...
                            update-alternatives: attenzione: viene forzata l'installazione dell'alternativa /usr/lib/fglrx/ld.so.conf poiché il gruppo i386-linux-gnu_gl_conf è danneggiato.
                            update-alternatives: attenzione: saltata la creazione di /etc/OpenCL/vendors/amdocl64.icd poiché il file /usr/lib/fglrx/etc/OpenCL/vendors/amdocl64.icd associato (del gruppo i386-linux-gnu_gl_conf) non esiste.
                            update-alternatives: attenzione: saltata la creazione di /usr/lib32/libaticalcl.so poiché il file /usr/lib32/fglrx/libaticalcl.so associato (del gruppo i386-linux-gnu_gl_conf) non esiste.
                            update-alternatives: attenzione: saltata la creazione di /usr/lib32/libaticalrt.so poiché il file /usr/lib32/fglrx/libaticalrt.so associato (del gruppo i386-linux-gnu_gl_conf) non esiste.
                            update-alternatives: attenzione: viene forzata l'installazione dell'alternativa /usr/lib/fglrx/ld.so.conf poiché il gruppo i386-linux-gnu_gl_conf è danneggiato.
                            update-alternatives: attenzione: saltata la creazione di /etc/OpenCL/vendors/amdocl64.icd poiché il file /usr/lib/fglrx/etc/OpenCL/vendors/amdocl64.icd associato (del gruppo i386-linux-gnu_gl_conf) non esiste.
                            update-alternatives: attenzione: saltata la creazione di /usr/lib32/libaticalcl.so poiché il file /usr/lib32/fglrx/libaticalcl.so associato (del gruppo i386-linux-gnu_gl_conf) non esiste.
                            update-alternatives: attenzione: saltata la creazione di /usr/lib32/libaticalrt.so poiché il file /usr/lib32/fglrx/libaticalrt.so associato (del gruppo i386-linux-gnu_gl_conf) non esiste.
                            update-initramfs: deferring update (trigger activated)
                            update-initramfs: Generating /boot/initrd.img-3.3.1-030301-generic-pae
                            Loading new fglrx-8.951 DKMS files...
                            Building only for 3.3.1-030301-generic-pae
                            Building for architecture i686
                            Building initial module for 3.3.1-030301-generic-pae
                            Error! Bad return status for module build on kernel: 3.3.1-030301-generic-pae (i686)
                            Consult /var/lib/dkms/fglrx/8.951/build/make.log for more information.
                            update-initramfs: deferring update (trigger activated)
                            Elaborazione dei trigger per ureadahead...
                            Elaborazione dei trigger per gnome-menus...
                            Elaborazione dei trigger per bamfdaemon...
                            Rebuilding /usr/share/applications/bamf.index...
                            Configurazione di fglrx-amdcccle (2:8.951-0ubuntu1)...
                            Configurazione di fglrx-dev (2:8.951-0ubuntu1)...
                            Elaborazione dei trigger per initramfs-tools...
                            update-initramfs: Generating /boot/initrd.img-3.3.1-030301-generic-pae
                            Elaborazione dei trigger per libc-bin...
                            ldconfig deferred processing now taking place
                            diabolik@Diabolik-ubuntu:~/catalyst12.3$
                            What's the all error of file not found ?
                            You thinks now the driver it's correctly installed ?? i thinks no

                            Comment


                            • #15
                              Your installation is apparently messed-up. You should remove any catalyst/fglrx package, and start from scratch.

                              I've never used the distribution packages. I usually download the AMD installer and create the deb packages for my Ubuntu 11.10 oneiric:

                              Code:
                              sudo sh amd-driver-installer-12-3-x86.x86_64.run --buildpkg Ubuntu/oneiric
                              Install the .deb packaegs (it will fail to build the modules), then apply the patch and reinstall the kernel module with:

                              Code:
                              sudo dkms install -m fglrx -v 8.951
                              If you have multiple kernels installed, you can specify the "-k kernel-version" option to build the module for a specific kernel version ("kernel-version" is what you get from "uname -r" when you run that kernel).

                              Comment

                              Working...
                              X