Wednesday, June 9, 2010

ATI Mobility Radeon HD 5xxx Series in Linux (kernel 2.6.34)

The aim of this writting is to show how I got to install the ATI driver in Linux, using kernel 2.6.34.

First of all, I tried to download the driver from http://ati.amd.com/support/driver.HTML. Although there is not any driver for 5xxx series, we can use the 4xxx series driver: http://support.amd.com/us/gpudownload/linux/Pages/radeon_linux.aspx?type=2.4.2&product=2.4.2.3.32&lang=English

After downloaded the driver I gave execution permissions to the driver and just in case, put out xserver:

$ chmod +x ati-driver-installer-10-5-x86.x86_64.run
$/etc/init.d/gdm stop




After executing the driver I got the first error. The logs are stored in /usr/share/ati/fglrx-install.log:

[Message] Kernel Module : Trying to install a precompiled kernel module.
[Message] Kernel Module : Precompiled kernel module version mismatched.
[Message] Kernel Module : Found kernel module build environment, generating kern
el module now.
AMD kernel module generator version 2.1
Error:
kernel includes at /lib/modules/2.6.34/build/include do not match current kernel
.
they are versioned as ""
instead of "2.6.34".
you might need to adjust your symlinks:
- /usr/include
- /usr/src/linux
[Error] Kernel Module : Failed to compile kernel module - please consult readme.


After looking a lot of web pages I decided to try something. So I extracted the driver content to a folder:

$ ./ati-driver-installer-10-5-x86.x86_64.run --extract ati


After that I wanted to search where the error was created. So I did a grep:

$ grep -r "do not match current kernel" *
common/lib/modules/fglrx/build_mod/make.sh:  echo "kernel includes at $linuxincludes do not match current kernel." | tee -a $logfile


So, in this moment, I knew where to look. I tried to execute this common/lib/modules/fglrx/build_mod/make.sh file and I got more errors:

AMD kernel module generator version 2.1
cat: /lib/modules/2.6.34/build/include/linux/utsrelease.h: No existe el fichero o el directorio
Error:
kernel includes at /lib/modules/2.6.34/build/include do not match current kernel.
they are versioned as ""
instead of "2.6.34".
you might need to adjust your symlinks:
- /usr/include
- /usr/src/linux


In this new error, I get the information that utsrelease.h didn't exist in the include /linux directory. So I find this file, and copied to this directory.

$ cd /usr/src/linux
$ find . -name utsrelease.h
./include/generated/utsrelease.h
$ cp include/generated/utsrelease.h include/linux/


After all, I executed again make.sh, and with the new error, I saw that I need autoconf.h file. So, I repeated the above same 2 commands.

$ find . -name autoconf.h
./include/generated/autoconf.h
$ cp include/generated/autoconf.h include/linux/


After that, the new error was the next:

$ ./make.sh 
AMD kernel module generator version 2.1
doing Makefile based build for kernel 2.6.x and higher
rm -rf *.c *.h *.o *.ko *.GCC* .??* *.symvers
make -C /lib/modules/2.6.34/build SUBDIRS=/home/pron/Downloads/ati/common/lib/modules/fglrx/build_mod/2.6.x modules
make[1]: se ingresa al directorio `/usr/src/linux-2.6.34'
  CC [M]  /home/pron/Downloads/ati/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.o
In file included from /home/pron/Downloads/ati/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.c:443:
/home/pron/Downloads/ati/common/lib/modules/fglrx/build_mod/2.6.x/drm_proc.h: In function ‘FGLDRM__vma_info’:
/home/pron/Downloads/ati/common/lib/modules/fglrx/build_mod/2.6.x/drm_proc.h:497: warning: format ‘%08lx’ expects type ‘long unsigned int’, but argument 5 has type ‘phys_addr_t’
/home/pron/Downloads/ati/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.c: In function ‘KCL_SetPageCache_Array’:
/home/pron/Downloads/ati/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.c:1316: warning: passing argument 1 of ‘KCL_ConvertPageToKernelAddress’ makes pointer from integer without a cast
/home/pron/Downloads/ati/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.c: In function ‘__ke__cmpxchg’:
/home/pron/Downloads/ati/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.c:1473: error: variable or field ‘__ret’ declared void
/home/pron/Downloads/ati/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.c:1473: error: variable or field ‘__old’ declared void
/home/pron/Downloads/ati/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.c:1473: error: variable or field ‘__new’ declared void
/home/pron/Downloads/ati/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.c: In function ‘KCL_MapPageToPfn’:
/home/pron/Downloads/ati/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.c:1615: warning: unused variable ‘bus_addr’
make[2]: *** [/home/pron/Downloads/ati/common/lib/modules/fglrx/build_mod/2.6.x/firegl_public.o] Error 1
make[1]: *** [_module_/home/pron/Downloads/ati/common/lib/modules/fglrx/build_mod/2.6.x] Error 2
make[1]: se sale del directorio `/usr/src/linux-2.6.34'
make: *** [kmod_build] Error 2
build failed with return value 2


After searching in Google, I found that a patch exist for the 10.1 ATI driver. After downloaded, I pathed the files like that:

$ cd unpacked_ati_directory
$ patch -p1 < ../fglrx.2.6.33.patch
patching file common/lib/modules/fglrx/build_mod/drmP.h
patching file common/lib/modules/fglrx/build_mod/firegl_public.c
Hunk #3 succeeded at 1470 (offset -2 lines).
patching file common/lib/modules/fglrx/build_mod/kcl_acpi.c
Hunk #1 succeeded at 15 with fuzz 2.
patching file common/lib/modules/fglrx/build_mod/kcl_agp.c
patching file common/lib/modules/fglrx/build_mod/kcl_io.c
patching file common/lib/modules/fglrx/build_mod/kcl_osconfig.h
patching file common/lib/modules/fglrx/build_mod/kcl_pci.c
patching file common/lib/modules/fglrx/build_mod/kcl_str.c
patching file common/lib/modules/fglrx/build_mod/kcl_wait.c
patching file common/lib/modules/fglrx/build_mod/make.sh


In this moment, it is supposed that all was going to work, but not. I executed again make.sh:

/home/pron/Downloads/ati/common/lib/modules/fglrx/build_mod/2.6.x/kcl_wait.c: In function ‘KCL_WAIT_Add’:
/home/pron/Downloads/ati/common/lib/modules/fglrx/build_mod/2.6.x/kcl_wait.c:52: error: implicit declaration of function ‘kmalloc’
/home/pron/Downloads/ati/common/lib/modules/fglrx/build_mod/2.6.x/kcl_wait.c:52: warning: initialization makes pointer from integer without a cast
/home/pron/Downloads/ati/common/lib/modules/fglrx/build_mod/2.6.x/kcl_wait.c: In function ‘KCL_WAIT_Add_Exclusive’:
/home/pron/Downloads/ati/common/lib/modules/fglrx/build_mod/2.6.x/kcl_wait.c:71: warning: initialization makes pointer from integer without a cast
/home/pron/Downloads/ati/common/lib/modules/fglrx/build_mod/2.6.x/kcl_wait.c: In function ‘KCL_WAIT_Remove’:
/home/pron/Downloads/ati/common/lib/modules/fglrx/build_mod/2.6.x/kcl_wait.c:95: error: implicit declaration of function ‘kfree’
/home/pron/Downloads/ati/common/lib/modules/fglrx/build_mod/2.6.x/kcl_wait.c: In function ‘KCL_WAIT_CreateObject’:
/home/pron/Downloads/ati/common/lib/modules/fglrx/build_mod/2.6.x/kcl_wait.c:112: warning: initialization makes pointer from integer without a cast
make[2]: *** [/home/pron/Downloads/ati/common/lib/modules/fglrx/build_mod/2.6.x/kcl_wait.o] Error 1
make[1]: *** [_module_/home/pron/Downloads/ati/common/lib/modules/fglrx/build_mod/2.6.x] Error 2
make[1]: se sale del directorio `/usr/src/linux-2.6.34'
make: *** [kmod_build] Error 2
build failed with return value 2


In the first error, it is seen that the kmalloc function didn't work. So after investigating in google, I realize that one header was necessary in kcl_wait.c file. So, using vim, I edited the file and added the next line:

#include <linux/slab.h>


After that, although and error was shown, I could execute the driver, like that:

./ati-installer.sh --install --install


In the code above, I put --install 2 times, because otherwise the scripts doesn't work.

References:
http://www.phoronix.com/forums/showthread.php?t=22261
http://www.linuxjournal.com/article/6930

3 comments:

rhalff said...

I've tried to compile the 10.6 version of the ATI driver using a kernel > .33 namely .35

The patch isn't necessary anymore with this newer ATI 10.6 driver, but I still got the error mentioned in your last step.

So adding slab.h solved my problem, thanks for writing this down :-)

rhalff said...
This comment has been removed by the author.
pron said...

I'm glad that it works.

However I don't understand how this problem hasn't been fixed with this new version. Maybe they test it with an old kernel.

Bye