ati-drivers: update to 13.12 (close #1569)

This update is mostly effort from @MarcWeber and @vcunat, now tested on real
hardware making sure it works with multiple GPUs and opencl.

authored by Jaka Hudoklin and committed by Vladimír Čunát e0000f8a f5461b02

+99 -303
+10 -5
pkgs/development/misc/amdadl-sdk/default.nix
··· 1 - { fetchurl, stdenv, unzip }: 1 + { requireFile, stdenv, unzip }: 2 2 3 3 stdenv.mkDerivation rec { 4 - version = "4.0"; 4 + version = "6.0"; 5 5 name = "amdadl-sdk-${version}"; 6 6 7 - src = fetchurl { 8 - url = "http://download2-developer.amd.com/amd/GPU/zip/ADL_SDK_${version}.zip"; 9 - sha256 = "4265ee2f265b69cc39b61e10f79741c1d799f4edb71dce14a7d88509fbec0efa"; 7 + src = requireFile { 8 + name = "ADL_SDK_6.0.zip"; 9 + url = http://developer.amd.com/tools-and-sdks/graphics-development/display-library-adl-sdk/; 10 + sha256 = "429f4fd1edebb030d6366f4e0a877cf105e4383f7dd2ccf54e5aef8f2e4242c9"; 10 11 }; 11 12 12 13 buildInputs = [ unzip ]; ··· 15 16 16 17 unpackPhase = '' 17 18 unzip $src 19 + ''; 20 + 21 + patchPhase = '' 22 + sed -i -e '/include/a \#include <wchar.h>' include/adl_structures.h || die 18 23 ''; 19 24 20 25 buildPhase = ''
+4 -1
pkgs/os-specific/linux/ati-drivers/builder.sh
··· 8 8 9 9 # custom unpack: 10 10 unzip $src 11 - run_file=$(echo amd-driver-installer-*) 11 + run_file=$(echo amd-catalyst-*) 12 12 sh $run_file --extract . 13 13 14 14 eval "$patchPhase" ··· 181 181 # make xorg use the ati version 182 182 ln -s $out/lib/xorg/modules/extensions/{fglrx/fglrx-libglx.so,libglx.so} 183 183 184 + # libstdc++ and gcc are needed by some libs 185 + patchelf --set-rpath $gcc/$lib_arch $out/lib/libatiadlxx.so 184 186 } 185 187 186 188 { # build samples ··· 190 192 cd samples 191 193 tar xfz ../common/usr/src/ati/fglrx_sample_source.tgz 192 194 195 + eval "$patchPhaseSamples" 193 196 194 197 ( # build and install fgl_glxgears 195 198 cd fgl_glxgears;
+15 -11
pkgs/os-specific/linux/ati-drivers/default.nix
··· 13 13 # See http://thread.gmane.org/gmane.linux.distributions.nixos/4145 for a 14 14 # workaround (TODO) 15 15 16 - # The gentoo ebuild contains much more magic.. 16 + # The gentoo ebuild contains much more magic and is usually a great resource to 17 + # find patches :) 17 18 18 19 # http://wiki.cchtml.com/index.php/Main_Page 19 20 20 21 # There is one issue left: 21 22 # /usr/lib/dri/fglrx_dri.so must point to /run/opengl-driver/lib/fglrx_dri.so 22 23 23 - assert stdenv.system == "x86_64-linux"; 24 + # You eventually have to blacklist radeon module (?) 24 25 26 + assert stdenv.system == "x86_64-linux"; 25 27 26 28 stdenv.mkDerivation { 27 - name = "ati-drivers-13.4-${kernel.version}"; 29 + name = "ati-drivers-13.12-${kernel.version}"; 28 30 29 31 builder = ./builder.sh; 30 32 31 33 inherit libXxf86vm xf86vidmodeproto; 34 + gcc = stdenv.gcc.gcc; 32 35 33 36 src = fetchurl { 34 - url = http://www2.ati.com/drivers/linux/amd-driver-installer-catalyst-13-4-linux-x86.x86_64.zip; 35 - sha256 = "1914ikdich0kg047bqh89ai5z4dyryj5mlw5i46n90fsfiaxa532"; 37 + url = http://www2.ati.com/drivers/linux/amd-catalyst-13.12-linux-x86.x86_64.zip; 38 + sha256 = "1jm0c4rqyjjhyj8a7axf4hz16bcvy8yhnkn45wc2l73xhks36h02"; 36 39 curlOpts = "--referer http://support.amd.com/en-us/download/desktop?os=Linux%20x86_64"; 37 40 }; 38 41 39 - patchPhase = "patch -p0 < ${./gentoo-patches.patch}"; 42 + # most patches are taken from gentoo 43 + patchPhase = "patch -p1 < ${./gentoo-patches.patch}"; 44 + patchPhaseSamples = "patch -p2 < ${./patch-samples.patch}"; 40 45 41 46 buildInputs = 42 47 [ xlibs.libXext xlibs.libX11 xlibs.libXinerama ··· 61 66 # without this some applications like blender don't start, but they start 62 67 # with nvidia. This causes them to be symlinked to $out/lib so that they 63 68 # appear in /run/opengl-driver/lib which get's added to LD_LIBRARY_PATH 64 - extraDRIlibs = [ xorg.libXext ]; 69 + extraDRIlibs = [ xorg.libXext ]; 65 70 66 71 inherit mesa; # only required to build examples 67 72 68 - meta = { 73 + meta = with stdenv.lib; { 69 74 description = "ATI drivers"; 70 75 homepage = http://support.amd.com/us/gpudownload/Pages/index.aspx; 71 - license = "unfree"; 72 - maintainers = [stdenv.lib.maintainers.marcweber]; 76 + license = licenses.unfree; 77 + maintainers = with maintainers; [marcweber offline]; 73 78 platforms = [ "x86_64-linux" ]; 74 79 hydraPlatforms = []; 75 - broken = true; 76 80 }; 77 81 78 82 # moved assertions here because the name is evaluated when the NixOS manual is generated
+44 -286
pkgs/os-specific/linux/ati-drivers/gentoo-patches.patch
··· 1 - diff -Nur common/lib/modules/fglrx/build_mod/drmP.h common-r1/lib/modules/fglrx/build_mod/drmP.h 2 - --- common/lib/modules/fglrx/build_mod/drmP.h 2013-05-15 09:26:23.555752577 +0300 3 - +++ common-r1/lib/modules/fglrx/build_mod/drmP.h 2013-05-16 10:39:17.496212055 +0300 4 - @@ -901,10 +901,6 @@ 5 - int DRM(stub_unregister)(int minor); 6 - 7 - /* Proc support (drm_proc.h) */ 8 - -extern struct proc_dir_entry *DRM(proc_init)(drm_device_t *dev, 9 - - int minor, 10 - - struct proc_dir_entry *root, 11 - - struct proc_dir_entry **dev_root); 12 - extern int DRM(proc_cleanup)(int minor, 13 - struct proc_dir_entry *root, 14 - struct proc_dir_entry *dev_root); 15 - diff -Nur common/lib/modules/fglrx/build_mod/drm_proc.h common-r1/lib/modules/fglrx/build_mod/drm_proc.h 16 - --- common/lib/modules/fglrx/build_mod/drm_proc.h 2013-05-15 09:26:23.555752577 +0300 17 - +++ common-r1/lib/modules/fglrx/build_mod/drm_proc.h 2013-05-19 02:16:16.584406160 +0300 18 - @@ -75,61 +75,6 @@ 19 - #define DRM_PROC_ENTRIES (sizeof(DRM(proc_list))/sizeof(DRM(proc_list)[0])) 1 + diff --git a/common/lib/modules/fglrx/build_mod/firegl_public.c b/common/lib/modules/fglrx/build_mod/firegl_public.c 2 + index d3ad3ce..9362b58 100755 3 + --- a/common/lib/modules/fglrx/build_mod/firegl_public.c 4 + +++ b/common/lib/modules/fglrx/build_mod/firegl_public.c 5 + @@ -34,6 +34,11 @@ 6 + #include <linux/autoconf.h> 7 + #endif 20 8 21 - /** 22 - - * Initialize the DRI proc filesystem for a device. 23 - - * 24 - - * \param dev DRM device. 25 - - * \param minor device minor number. 26 - - * \param root DRI proc dir entry. 27 - - * \param dev_root resulting DRI device proc dir entry. 28 - - * \return root entry pointer on success, or NULL on failure. 29 - - * 30 - - * Create the DRI proc root entry "/proc/ati", the device proc root entry 31 - - * "/proc/ati/%minor%/", and each entry in proc_list as 32 - - * "/proc/ati/%minor%/%name%". 33 - - */ 34 - -struct proc_dir_entry *DRM(proc_init)(drm_device_t *dev, int minor, 35 - - struct proc_dir_entry *root, 36 - - struct proc_dir_entry **dev_root) 37 - -{ 38 - - struct proc_dir_entry *ent; 39 - - int i, j; 40 - - char name[64]; 41 - - 42 - - if (!minor) root = create_proc_entry("dri", S_IFDIR, NULL); 43 - - if (!root) { 44 - - DRM_ERROR("Cannot create /proc/ati\n"); 45 - - return NULL; 46 - - } 47 - - 48 - - sprintf(name, "%d", minor); 49 - - *dev_root = create_proc_entry(name, S_IFDIR, root); 50 - - if (!*dev_root) { 51 - - DRM_ERROR("Cannot create /proc/ati/%s\n", name); 52 - - return NULL; 53 - - } 54 - - 55 - - for (i = 0; i < DRM_PROC_ENTRIES; i++) { 56 - - ent = create_proc_entry(DRM(proc_list)[i].name, 57 - - S_IFREG|S_IRUGO, *dev_root); 58 - - if (!ent) { 59 - - DRM_ERROR("Cannot create /proc/ati/%s/%s\n", 60 - - name, DRM(proc_list)[i].name); 61 - - for (j = 0; j < i; j++) 62 - - remove_proc_entry(DRM(proc_list)[i].name, 63 - - *dev_root); 64 - - remove_proc_entry(name, root); 65 - - if (!minor) remove_proc_entry("dri", NULL); 66 - - return NULL; 67 - - } 68 - - ent->read_proc = DRM(proc_list)[i].f; 69 - - ent->data = dev; 70 - - } 71 - - 72 - - return root; 73 - -} 74 - - 75 - - 76 - -/** 77 - * Cleanup the proc filesystem resources. 78 - * 79 - * \param minor device minor number. 80 - diff -Nur common/lib/modules/fglrx/build_mod/firegl_public.c common-r1/lib/modules/fglrx/build_mod/firegl_public.c 81 - --- common/lib/modules/fglrx/build_mod/firegl_public.c 2013-05-15 09:26:23.545752925 +0300 82 - +++ common-r1/lib/modules/fglrx/build_mod/firegl_public.c 2013-05-19 03:07:10.236552522 +0300 83 - @@ -583,6 +583,202 @@ 84 - { "NULL", NULL, NULL} // Terminate List!!! 85 - }; 86 - 87 - + 88 - +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) 89 - +typedef int (read_proc_t)(char *page, char **start, off_t off, int count, int *eof, void *data); 90 - +typedef int (write_proc_t)(struct file *file, const char __user *buffer, unsigned long count, void *data); 91 - +#else 92 - +#define PDE_DATA(inode) (PDE((inode))->data) 9 + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0) 10 + +#include <linux/uidgid.h> 93 11 +#endif 94 12 + 95 - +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) 96 - +typedef struct { 97 - + read_proc_t *read_func; 98 - + write_proc_t *write_func; 99 - + void *data; 100 - +} gentoo_proc_wrapper_t; 101 13 + 102 - +#define GENTOO_PROC_WRAPPER_OVERFLOW_MAGIC 939750305 103 - + 104 - +static ssize_t gentoo_proc_wrapper_read (struct file *myfile, char __user *buffer, size_t count, loff_t *offset) { 105 - + int is_eof=0, retval; 106 - + char *start, *usebuffer=NULL; 107 - + gentoo_proc_wrapper_t* wrapper_data=(gentoo_proc_wrapper_t*)(myfile->private_data); 108 - + if (PAGE_SIZE<*offset) { 109 - + printk(KERN_ERR "Trying to read beyond 4k on proc\n"); 110 - + return -EIO; 111 - + } 112 - + //printk(KERN_NOTICE " call with: dev %p, func %p\n", wrapper_data->data, wrapper_data->read_func); 113 - + 114 - + usebuffer=kmalloc(2*PAGE_SIZE, GFP_KERNEL); 115 - + if (!usebuffer) 116 - + return -ENOMEM; 117 - + ((u32*)usebuffer)[1024]=GENTOO_PROC_WRAPPER_OVERFLOW_MAGIC; 118 - + 119 - + retval=wrapper_data->read_func(usebuffer, &start, *offset, count, &is_eof, wrapper_data->data); 120 - + 121 - + BUG_ON(GENTOO_PROC_WRAPPER_OVERFLOW_MAGIC != ((u32*)usebuffer)[1024]); 122 - + 123 - + if (0 > retval) 124 - + { 125 - + printk(KERN_ERR "Proc read failed with %d", retval); 126 - + goto out; 127 - + } 128 - + 129 - + if (copy_to_user(buffer, start, retval)) { 130 - + printk(KERN_NOTICE "copy to user failed in amd drivers proc code\n"); 131 - + retval=-EFAULT; 132 - + goto out; 133 - + } 134 - + *offset+=retval; 135 - + 136 - +out: 137 - + if (usebuffer) 138 - + kfree(usebuffer); 139 - + return retval; 140 - +} 141 - +static ssize_t gentoo_proc_wrapper_write (struct file *myfile, const char __user *buffer, size_t count, loff_t *offset) { 142 - + gentoo_proc_wrapper_t* wrapper_data=(gentoo_proc_wrapper_t*)(myfile->private_data); 143 - + int retval=0; 144 - + void *usebuffer=NULL; 145 - + 146 - + BUG_ON(*offset); 147 - + if (!wrapper_data->write_func) 148 - + return -EPERM; 149 - + 150 - + usebuffer=kmalloc(count, GFP_KERNEL); 151 - + if (!usebuffer) 152 - + return -ENOMEM; 153 - + if (copy_from_user(usebuffer, buffer, count)) { 154 - + printk(KERN_NOTICE "copy from user failed in amd drivers proc code\n"); 155 - + retval=-EFAULT; 156 - + goto out; 157 - + } 158 - + 159 - + retval=wrapper_data->write_func(myfile, buffer, count, wrapper_data->data); 160 - + *offset+=retval; 161 - +out: 162 - + if (usebuffer) 163 - + kfree(usebuffer); 164 - + return retval; 165 - +} 166 - +static int gentoo_proc_wrapper_open(struct inode *myinode, struct file *myfile) { 167 - + myfile->private_data=PDE_DATA(myinode); 168 - + return generic_file_open(myinode, myfile); 169 - +} 170 - +struct file_operations gentoo_proc_fops = { 171 - + .read=gentoo_proc_wrapper_read, 172 - + .write=gentoo_proc_wrapper_write, 173 - + .open=gentoo_proc_wrapper_open, 174 - +}; 175 - + 176 - +static void *gentoo_proc_wrapper_data(read_proc_t *reader, write_proc_t *writer, void *mydata) { 177 - + gentoo_proc_wrapper_t *retval=kmalloc(sizeof(gentoo_proc_wrapper_t), GFP_KERNEL); 178 - + if (!retval) 179 - + return retval; 180 - + retval->read_func=reader; 181 - + retval->write_func=writer; 182 - + retval->data=mydata; 183 - + return retval; 184 - +} 185 - + 186 - +static struct proc_dir_entry *firegl_proc_init( device_t *dev, 187 - + int minor, 188 - + struct proc_dir_entry *root, 189 - + struct proc_dir_entry **dev_root, 190 - + kcl_proc_list_t *proc_list ) // proc_list must be terminated! 191 - +{ 192 - + struct proc_dir_entry *ent; 193 - + char name[64]; 194 - + kcl_proc_list_t *list = proc_list; 195 - + void *tempdata; 196 - + KCL_DEBUG1(FN_FIREGL_PROC, "minor %d, proc_list 0x%08lx\n", minor, (unsigned long)proc_list); 197 - + if (!minor) 198 - + { 199 - + root = proc_mkdir("ati", NULL); 14 + #if !defined(CONFIG_X86) 15 + #if !defined(CONFIG_X86_PC) 16 + #if !defined(CONFIG_X86_XEN) 17 + @@ -1543,9 +1548,17 @@ KCL_TYPE_Pid ATI_API_CALL KCL_GetTgid(void) 18 + KCL_TYPE_Uid ATI_API_CALL KCL_GetEffectiveUid(void) 19 + { 20 + #ifdef current_euid 21 + +# if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0) 22 + + return __kuid_val(current_euid()); 23 + +# else 24 + return current_euid(); 25 + +# endif 26 + #else 27 + +# if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0) 28 + + return __kuid_val(current->euid); 29 + +# else 30 + return current->euid; 31 + +# endif 32 + #endif 33 + } 34 + 35 + 36 + diff -urN a/common/lib/modules/fglrx/build_mod/kcl_acpi.c common/lib/modules/fglrx/build_mod/kcl_acpi.c 37 + --- a/common/lib/modules/fglrx/build_mod/kcl_acpi.c 2013-12-27 13:32:34.734832283 +0100 38 + +++ b/common/lib/modules/fglrx/build_mod/kcl_acpi.c 2013-12-27 13:33:31.849831765 +0100 39 + @@ -1002,7 +1002,11 @@ 40 + #endif 41 + { 42 + return KCL_ACPI_ERROR; 43 + - } 200 44 + } 201 - + 202 - + if (!root) 203 - + { 204 - + KCL_DEBUG_ERROR("Cannot create /proc/ati\n"); 205 - + return NULL; 206 - + } 207 - + 208 - + if (minor == 0) 209 - + { 210 - + // Global major debice number entry 211 - + tempdata=gentoo_proc_wrapper_data((read_proc_t*)firegl_major_proc_read, NULL, NULL); 212 - + if (!tempdata) 213 - + return NULL; 214 - + ent = proc_create_data("major", S_IFREG|S_IRUGO, root, &gentoo_proc_fops, tempdata); 215 - + if (!ent) 216 - + { 217 - + remove_proc_entry("ati", NULL); 218 - + KCL_DEBUG_ERROR("Cannot create /proc/ati/major\n"); 219 - + return NULL; 220 - + } 221 - + } 222 - + 223 - + sprintf(name, "%d", minor); 224 - + *dev_root = proc_mkdir(name, root); 225 - + if (!*dev_root) { 226 - + remove_proc_entry("major", root); 227 - + remove_proc_entry("ati", NULL); 228 - + KCL_DEBUG_ERROR("Cannot create /proc/ati/%s\n", name); 229 - + return NULL; 230 - + } 231 - + 232 - + while (list->f || list->fops) 233 - + { 234 - + struct file_operations *my_fops = &gentoo_proc_fops; 235 - + if (list->fops) 236 - + { 237 - + my_fops = (struct file_operations*)list->fops; 238 - + tempdata=(dev->pubdev.signature == FGL_DEVICE_SIGNATURE)? firegl_find_device(minor) : (dev); 239 - + } 240 - + else { 241 - + BUG_ON(!list->f); 242 - + tempdata=gentoo_proc_wrapper_data((read_proc_t*)list->f, NULL, (dev->pubdev.signature == FGL_DEVICE_SIGNATURE)? firegl_find_device(minor) : (dev) ); 243 - + if (!tempdata) 244 - + return NULL; 245 - + } 246 - + //printk(KERN_NOTICE "name %s, dev %p, func %p, data %p\n", list->name, (dev->pubdev.signature == FGL_DEVICE_SIGNATURE)? firegl_find_device(minor) : (dev), list->f, tempdata); 247 - + ent = proc_create_data(list->name, S_IFREG|S_IRUGO, *dev_root, my_fops, tempdata); 248 - + 249 - + if (!ent) 250 - + { 251 - + KCL_DEBUG_ERROR("Cannot create /proc/ati/%s/%s\n", name, list->name); 252 - + while (proc_list != list) 253 - + { 254 - + remove_proc_entry(proc_list->name, *dev_root); 255 - + proc_list++; 256 - + } 257 - + remove_proc_entry(name, root); 258 - + if (!minor) 259 - + { 260 - + remove_proc_entry("major", root); 261 - + remove_proc_entry("ati", NULL); 262 - + } 263 - + return NULL; 264 - + } 265 - + 266 - + list++; 267 - + } 268 - + 269 - + if (minor == 0) 270 - + { 271 - + // Global debug entry, only create it once 272 - + tempdata=gentoo_proc_wrapper_data((read_proc_t*)firegl_debug_proc_read_wrap, (write_proc_t*)firegl_debug_proc_write_wrap, dev); 273 - + if (!tempdata) 274 - + return NULL; 275 - + ent=proc_create_data("debug", S_IFREG|S_IRUGO, root, &gentoo_proc_fops, tempdata); 276 - + if (!ent) 277 - + return NULL; 278 - + } 279 - + 280 - + return root; 281 - +} 45 + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,1) 46 + + ((acpi_tbl_table_handler)handler)(hdr); 282 47 +#else 283 - static struct proc_dir_entry *firegl_proc_init( device_t *dev, 284 - int minor, 285 - struct proc_dir_entry *root, 286 - @@ -677,6 +873,7 @@ 287 - 288 - return root; 289 - } 48 + ((acpi_table_handler)handler)(hdr); 290 49 +#endif 291 - 292 - static int firegl_proc_cleanup( int minor, 293 - struct proc_dir_entry *root, 50 + return KCL_ACPI_OK; 51 + }
+26
pkgs/os-specific/linux/ati-drivers/patch-samples.patch
··· 1 + diff --git a/samples/fgl_glxgears/fgl_glxgears.c b/samples/fgl_glxgears/fgl_glxgears.c 2 + index 6c8e313..2b8d035 100644 3 + --- a/samples/fgl_glxgears/fgl_glxgears.c 4 + +++ b/samples/fgl_glxgears/fgl_glxgears.c 5 + @@ -1096,8 +1096,6 @@ static void event_loop(void) 6 + view_rotx -= 5.0; 7 + } 8 + else { 9 + - r = XLookupString(&event.xkey, buffer, sizeof(buffer), 10 + - NULL, NULL); 11 + if (buffer[0] == 27) { 12 + /* escape */ 13 + return; 14 + 15 + 16 + diff -Nur a/samples/fgl_glxgears/fgl_glxgears.c b/samples/fgl_glxgears/fgl_glxgears.c 17 + --- a/samples/fgl_glxgears/fgl_glxgears.c 2012-08-29 09:59:03.000000000 +0300 18 + +++ b/samples/fgl_glxgears/fgl_glxgears.c 2013-09-07 09:26:11.034723135 +0300 19 + @@ -78,7 +78,6 @@ 20 + #endif // _WIN32 21 + 22 + #define INT_PTR ptrdiff_t 23 + -#include <GL/glATI.h> 24 + 25 + #ifdef _WIN32 26 + #include <GL/wglATI.h>