Wednesday, September 07, 2005

hacking ATI FireGL drivers

Maybe the title of this write-up is little overblown, because the whole `hacking' came down to simple substitution... but here's the whole story: I've compiled new version of kernel (2.6.13) on my development machine and as ATI drivers for FireGL cards come as kernel module, I had to recompile them too. First of all, my old version (8.14.3) did not compile with new kernel - I got those error messages:

dh_testdir
KERNEL_PATH= uname_r= ./make.sh --nohints
ATI module generator V 2.0
==========================
initializing...
cleaning...
patching 'highmem.h'...
assuming new VMA API since we do have kernel 2.6.x...
doing Makefile based build for kernel 2.6.x and higher
make[1]: Entering directory `/usr/src/modules/fglrx'
make -C /usr/src/linux-2.6.13 SUBDIRS=/usr/src/modules/fglrx modules
make[2]: Entering directory `/usr/src/linux-2.6.13'
CC [M] /usr/src/modules/fglrx/agp3.o
CC [M] /usr/src/modules/fglrx/nvidia-agp.o
CC [M] /usr/src/modules/fglrx/agpgart_be.o
/usr/src/modules/fglrx/agpgart_be.c: In function `agp_find_supported_device':
/usr/src/modules/fglrx/agpgart_be.c:7136: error: structure has no member named `slot_na
me'
/usr/src/modules/fglrx/agpgart_be.c:7156: error: structure has no member named `slot_na
me'
/usr/src/modules/fglrx/agpgart_be.c:7161: error: structure has no member named `slot_na
me'
/usr/src/modules/fglrx/agpgart_be.c:7187: error: structure has no member named `slot_na
me'
/usr/src/modules/fglrx/agpgart_be.c:7207: error: structure has no member named `slot_na
me'
/usr/src/modules/fglrx/agpgart_be.c:7227: error: structure has no member named `slot_na
me'
/usr/src/modules/fglrx/agpgart_be.c:7232: error: structure has no member named `slot_na
me'
/usr/src/modules/fglrx/agpgart_be.c: In function `__fgl_agp_init':
/usr/src/modules/fglrx/agpgart_be.c:7613: warning: `pm_register' is deprecated (declare
d at include/linux/pm.h:107)
/usr/src/modules/fglrx/agpgart_be.c: In function `__fgl_agp_cleanup':
/usr/src/modules/fglrx/agpgart_be.c:7623: warning: `pm_unregister_all' is deprecated (d
eclared at include/linux/pm.h:117)
make[3]: *** [/usr/src/modules/fglrx/agpgart_be.o] Error 1
make[2]: *** [_module_/usr/src/modules/fglrx] Error 2
make[2]: Leaving directory `/usr/src/linux-2.6.13'
make[1]: *** [kmod_build] Error 2
make[1]: Leaving directory `/usr/src/modules/fglrx'
build failed with return value 2
I suspected that something changed in new version of kernel, so I downloaded new version (8.20.16) and tried again. This time the error message was different, certain symbol ('verify_area') was not defined. Looking into the kernel sources I've found out that this system call was dropped and 'access_ok()' now replaces it. What I did was this simple hack:

--- firegl_public.c 2005-09-07 14:41:04.401948000 +0200
+++ firegl_public.c.orig 2005-09-07 14:37:22.548083000 +0200
@@ -1425,9 +1425,7 @@

int ATI_API_CALL __ke_verify_area(int type, const void * addr, unsigned long size)
{
- /* return verify_area(type, addr, size);
- */
- return verify_area(type, addr, size);
+ return access_ok(type,addr,size);
}

int ATI_API_CALL __ke_get_pci_device_info(__ke_pci_dev_t* dev, __ke_pci_device_info_t
*pinfo)
...or simple substitution of one function call to another (parameters looked the same). This works right now, and I'm getting usual number FPSs as before.

That's it! anyone interesting can try it out and if you know exactly what I did, please let me know :-).

0 Comments:

Post a Comment

<< Home