summaryrefslogtreecommitdiff
path: root/x11-drivers/ati-drivers/files
diff options
context:
space:
mode:
Diffstat (limited to 'x11-drivers/ati-drivers/files')
-rw-r--r--x11-drivers/ati-drivers/files/ati-drivers-13.12-acpi.patch16
-rw-r--r--x11-drivers/ati-drivers/files/ati-drivers-13.6-linux-3.10-proc.diff356
-rw-r--r--x11-drivers/ati-drivers/files/ati-drivers-13.8-beta-include-seq_file.patch13
-rw-r--r--x11-drivers/ati-drivers/files/buildfix_kernel_3.13.patch30
-rw-r--r--x11-drivers/ati-drivers/files/check-for-iommu-only-if-iommu-is-supported.patch31
-rw-r--r--x11-drivers/ati-drivers/files/linux-3.10-proc.diff293
-rw-r--r--x11-drivers/ati-drivers/files/typesafe-kuid.diff34
7 files changed, 773 insertions, 0 deletions
diff --git a/x11-drivers/ati-drivers/files/ati-drivers-13.12-acpi.patch b/x11-drivers/ati-drivers/files/ati-drivers-13.12-acpi.patch
new file mode 100644
index 00000000..3c568742
--- /dev/null
+++ b/x11-drivers/ati-drivers/files/ati-drivers-13.12-acpi.patch
@@ -0,0 +1,16 @@
+diff -urN common.old/lib/modules/fglrx/build_mod/kcl_acpi.c common/lib/modules/fglrx/build_mod/kcl_acpi.c
+--- common.old/lib/modules/fglrx/build_mod/kcl_acpi.c 2013-12-27 13:32:34.734832283 +0100
++++ common/lib/modules/fglrx/build_mod/kcl_acpi.c 2013-12-27 13:33:31.849831765 +0100
+@@ -1002,7 +1002,11 @@
+ #endif
+ {
+ return KCL_ACPI_ERROR;
+- }
++ }
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)
++ ((acpi_tbl_table_handler)handler)(hdr);
++#else
+ ((acpi_table_handler)handler)(hdr);
++#endif
+ return KCL_ACPI_OK;
+ }
diff --git a/x11-drivers/ati-drivers/files/ati-drivers-13.6-linux-3.10-proc.diff b/x11-drivers/ati-drivers/files/ati-drivers-13.6-linux-3.10-proc.diff
new file mode 100644
index 00000000..bdb22eae
--- /dev/null
+++ b/x11-drivers/ati-drivers/files/ati-drivers-13.6-linux-3.10-proc.diff
@@ -0,0 +1,356 @@
+diff --git a/common/lib/modules/fglrx/build_mod/drmP.h b/common/lib/modules/fglrx/build_mod/drmP.h
+index 81546b2..4e74526 100755
+--- a/common/lib/modules/fglrx/build_mod/drmP.h
++++ b/common/lib/modules/fglrx/build_mod/drmP.h
+@@ -901,10 +901,6 @@ int DRM(stub_register)(const char *name,
+ int DRM(stub_unregister)(int minor);
+
+ /* Proc support (drm_proc.h) */
+-extern struct proc_dir_entry *DRM(proc_init)(drm_device_t *dev,
+- int minor,
+- struct proc_dir_entry *root,
+- struct proc_dir_entry **dev_root);
+ extern int DRM(proc_cleanup)(int minor,
+ struct proc_dir_entry *root,
+ struct proc_dir_entry *dev_root);
+diff --git a/common/lib/modules/fglrx/build_mod/drm_proc.h b/common/lib/modules/fglrx/build_mod/drm_proc.h
+index 1e3ab4a..c52ad7e 100755
+--- a/common/lib/modules/fglrx/build_mod/drm_proc.h
++++ b/common/lib/modules/fglrx/build_mod/drm_proc.h
+@@ -75,61 +75,6 @@ struct drm_proc_list {
+ #define DRM_PROC_ENTRIES (sizeof(DRM(proc_list))/sizeof(DRM(proc_list)[0]))
+
+ /**
+- * Initialize the DRI proc filesystem for a device.
+- *
+- * \param dev DRM device.
+- * \param minor device minor number.
+- * \param root DRI proc dir entry.
+- * \param dev_root resulting DRI device proc dir entry.
+- * \return root entry pointer on success, or NULL on failure.
+- *
+- * Create the DRI proc root entry "/proc/ati", the device proc root entry
+- * "/proc/ati/%minor%/", and each entry in proc_list as
+- * "/proc/ati/%minor%/%name%".
+- */
+-struct proc_dir_entry *DRM(proc_init)(drm_device_t *dev, int minor,
+- struct proc_dir_entry *root,
+- struct proc_dir_entry **dev_root)
+-{
+- struct proc_dir_entry *ent;
+- int i, j;
+- char name[64];
+-
+- if (!minor) root = create_proc_entry("dri", S_IFDIR, NULL);
+- if (!root) {
+- DRM_ERROR("Cannot create /proc/ati\n");
+- return NULL;
+- }
+-
+- sprintf(name, "%d", minor);
+- *dev_root = create_proc_entry(name, S_IFDIR, root);
+- if (!*dev_root) {
+- DRM_ERROR("Cannot create /proc/ati/%s\n", name);
+- return NULL;
+- }
+-
+- for (i = 0; i < DRM_PROC_ENTRIES; i++) {
+- ent = create_proc_entry(DRM(proc_list)[i].name,
+- S_IFREG|S_IRUGO, *dev_root);
+- if (!ent) {
+- DRM_ERROR("Cannot create /proc/ati/%s/%s\n",
+- name, DRM(proc_list)[i].name);
+- for (j = 0; j < i; j++)
+- remove_proc_entry(DRM(proc_list)[i].name,
+- *dev_root);
+- remove_proc_entry(name, root);
+- if (!minor) remove_proc_entry("dri", NULL);
+- return NULL;
+- }
+- ent->read_proc = DRM(proc_list)[i].f;
+- ent->data = dev;
+- }
+-
+- return root;
+-}
+-
+-
+-/**
+ * Cleanup the proc filesystem resources.
+ *
+ * \param minor device minor number.
+diff --git a/common/lib/modules/fglrx/build_mod/firegl_public.c b/common/lib/modules/fglrx/build_mod/firegl_public.c
+index d3ad3ce..890a0aa 100755
+--- a/common/lib/modules/fglrx/build_mod/firegl_public.c
++++ b/common/lib/modules/fglrx/build_mod/firegl_public.c
+@@ -583,6 +583,202 @@ kcl_proc_list_t KCL_PROC_FileList[] =
+ { "NULL", NULL, NULL} // Terminate List!!!
+ };
+
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
++typedef int (read_proc_t)(char *page, char **start, off_t off, int count, int *eof, void *data);
++typedef int (write_proc_t)(struct file *file, const char __user *buffer, unsigned long count, void *data);
++#else
++#define PDE_DATA(inode) (PDE((inode))->data)
++#endif
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
++typedef struct {
++ read_proc_t *read_func;
++ write_proc_t *write_func;
++ void *data;
++} gentoo_proc_wrapper_t;
++
++#define GENTOO_PROC_WRAPPER_OVERFLOW_MAGIC 939750305
++
++static ssize_t gentoo_proc_wrapper_read (struct file *myfile, char __user *buffer, size_t count, loff_t *offset) {
++ int is_eof=0, retval;
++ char *start, *usebuffer=NULL;
++ gentoo_proc_wrapper_t* wrapper_data=(gentoo_proc_wrapper_t*)(myfile->private_data);
++ if (PAGE_SIZE<*offset) {
++ printk(KERN_ERR "Trying to read beyond 4k on proc\n");
++ return -EIO;
++ }
++ //printk(KERN_NOTICE " call with: dev %p, func %p\n", wrapper_data->data, wrapper_data->read_func);
++
++ usebuffer=kmalloc(2*PAGE_SIZE, GFP_KERNEL);
++ if (!usebuffer)
++ return -ENOMEM;
++ ((u32*)usebuffer)[1024]=GENTOO_PROC_WRAPPER_OVERFLOW_MAGIC;
++
++ retval=wrapper_data->read_func(usebuffer, &start, *offset, count, &is_eof, wrapper_data->data);
++
++ BUG_ON(GENTOO_PROC_WRAPPER_OVERFLOW_MAGIC != ((u32*)usebuffer)[1024]);
++
++ if (0 > retval)
++ {
++ printk(KERN_ERR "Proc read failed with %d", retval);
++ goto out;
++ }
++
++ if (copy_to_user(buffer, start, retval)) {
++ printk(KERN_NOTICE "copy to user failed in amd drivers proc code\n");
++ retval=-EFAULT;
++ goto out;
++ }
++ *offset+=retval;
++
++out:
++ if (usebuffer)
++ kfree(usebuffer);
++ return retval;
++}
++static ssize_t gentoo_proc_wrapper_write (struct file *myfile, const char __user *buffer, size_t count, loff_t *offset) {
++ gentoo_proc_wrapper_t* wrapper_data=(gentoo_proc_wrapper_t*)(myfile->private_data);
++ int retval=0;
++ void *usebuffer=NULL;
++
++ BUG_ON(*offset);
++ if (!wrapper_data->write_func)
++ return -EPERM;
++
++ usebuffer=kmalloc(count, GFP_KERNEL);
++ if (!usebuffer)
++ return -ENOMEM;
++ if (copy_from_user(usebuffer, buffer, count)) {
++ printk(KERN_NOTICE "copy from user failed in amd drivers proc code\n");
++ retval=-EFAULT;
++ goto out;
++ }
++
++ retval=wrapper_data->write_func(myfile, buffer, count, wrapper_data->data);
++ *offset+=retval;
++out:
++ if (usebuffer)
++ kfree(usebuffer);
++ return retval;
++}
++static int gentoo_proc_wrapper_open(struct inode *myinode, struct file *myfile) {
++ myfile->private_data=PDE_DATA(myinode);
++ return generic_file_open(myinode, myfile);
++}
++struct file_operations gentoo_proc_fops = {
++ .read=gentoo_proc_wrapper_read,
++ .write=gentoo_proc_wrapper_write,
++ .open=gentoo_proc_wrapper_open,
++};
++
++static void *gentoo_proc_wrapper_data(read_proc_t *reader, write_proc_t *writer, void *mydata) {
++ gentoo_proc_wrapper_t *retval=kmalloc(sizeof(gentoo_proc_wrapper_t), GFP_KERNEL);
++ if (!retval)
++ return retval;
++ retval->read_func=reader;
++ retval->write_func=writer;
++ retval->data=mydata;
++ return retval;
++}
++
++static struct proc_dir_entry *firegl_proc_init( device_t *dev,
++ int minor,
++ struct proc_dir_entry *root,
++ struct proc_dir_entry **dev_root,
++ kcl_proc_list_t *proc_list ) // proc_list must be terminated!
++{
++ struct proc_dir_entry *ent;
++ char name[64];
++ kcl_proc_list_t *list = proc_list;
++ void *tempdata;
++ KCL_DEBUG1(FN_FIREGL_PROC, "minor %d, proc_list 0x%08lx\n", minor, (unsigned long)proc_list);
++ if (!minor)
++ {
++ root = proc_mkdir("ati", NULL);
++ }
++
++ if (!root)
++ {
++ KCL_DEBUG_ERROR("Cannot create /proc/ati\n");
++ return NULL;
++ }
++
++ if (minor == 0)
++ {
++ // Global major debice number entry
++ tempdata=gentoo_proc_wrapper_data((read_proc_t*)firegl_major_proc_read, NULL, NULL);
++ if (!tempdata)
++ return NULL;
++ ent = proc_create_data("major", S_IFREG|S_IRUGO, root, &gentoo_proc_fops, tempdata);
++ if (!ent)
++ {
++ remove_proc_entry("ati", NULL);
++ KCL_DEBUG_ERROR("Cannot create /proc/ati/major\n");
++ return NULL;
++ }
++ }
++
++ sprintf(name, "%d", minor);
++ *dev_root = proc_mkdir(name, root);
++ if (!*dev_root) {
++ remove_proc_entry("major", root);
++ remove_proc_entry("ati", NULL);
++ KCL_DEBUG_ERROR("Cannot create /proc/ati/%s\n", name);
++ return NULL;
++ }
++
++ while (list->f || list->fops)
++ {
++ struct file_operations *my_fops = &gentoo_proc_fops;
++ if (list->fops)
++ {
++ my_fops = (struct file_operations*)list->fops;
++ tempdata=(dev->pubdev.signature == FGL_DEVICE_SIGNATURE)? firegl_find_device(minor) : (dev);
++ }
++ else {
++ BUG_ON(!list->f);
++ tempdata=gentoo_proc_wrapper_data((read_proc_t*)list->f, NULL, (dev->pubdev.signature == FGL_DEVICE_SIGNATURE)? firegl_find_device(minor) : (dev) );
++ if (!tempdata)
++ return NULL;
++ }
++ //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);
++ ent = proc_create_data(list->name, S_IFREG|S_IRUGO, *dev_root, my_fops, tempdata);
++
++ if (!ent)
++ {
++ KCL_DEBUG_ERROR("Cannot create /proc/ati/%s/%s\n", name, list->name);
++ while (proc_list != list)
++ {
++ remove_proc_entry(proc_list->name, *dev_root);
++ proc_list++;
++ }
++ remove_proc_entry(name, root);
++ if (!minor)
++ {
++ remove_proc_entry("major", root);
++ remove_proc_entry("ati", NULL);
++ }
++ return NULL;
++ }
++
++ list++;
++ }
++
++ if (minor == 0)
++ {
++ // Global debug entry, only create it once
++ tempdata=gentoo_proc_wrapper_data((read_proc_t*)firegl_debug_proc_read_wrap, (write_proc_t*)firegl_debug_proc_write_wrap, dev);
++ if (!tempdata)
++ return NULL;
++ ent=proc_create_data("debug", S_IFREG|S_IRUGO, root, &gentoo_proc_fops, tempdata);
++ if (!ent)
++ return NULL;
++ }
++
++ return root;
++}
++#else
+ static struct proc_dir_entry *firegl_proc_init( device_t *dev,
+ int minor,
+ struct proc_dir_entry *root,
+@@ -677,6 +873,7 @@ static struct proc_dir_entry *firegl_proc_init( device_t *dev,
+
+ return root;
+ }
++#endif
+
+ static int firegl_proc_cleanup( int minor,
+ struct proc_dir_entry *root,
+@@ -6135,59 +6332,4 @@ void ATI_API_CALL KCL_fpu_end(void)
+ kernel_fpu_end();
+ }
+
+-/** Create new directory entry under "/proc/ati/...."
+- * Where
+- * root_dir - Root directory. If NULL then we should use "/proc/ati" root.
+- * name - Pointer to the name of directory
+- * access - Access attribute. We could use it to disable access to the directory for everybody accept owner.
+- * By default owner is root.
+- * Return NULL if failure. Pointer to proc_dir_entry otherwise
+- */
+-void * KCL_create_proc_dir(void *root_dir, const char *name, unsigned int access)
+-{
+- struct proc_dir_entry *dir = NULL;
+-
+- if (root_dir == NULL)
+- dir = create_proc_entry(name, S_IFDIR | access, firegl_stub_root);
+- else
+- dir = create_proc_entry(name, S_IFDIR | access, (struct proc_dir_entry *)root_dir);
+-
+- return dir;
+-}
+-
+-/* Remove proc directory entry
+- * root - Pointer to directory proc entry or NULL if for "/proc/ati"
+- * name - Name to delete
+- */
+-void KCL_remove_proc_dir_entry(void *root, const char *name)
+-{
+- if (root == NULL)
+- remove_proc_entry(name, firegl_stub_root);
+- else
+- remove_proc_entry(name, (struct proc_dir_entry *)root);
+-}
+-
+-
+-/* Create proc_entry under "root_dir"
+- * read_fn - Function which will be called on read request
+- * write_fn - Function which will be called on write request
+- * private_data - Pointer to private data which will be passed
+- */
+-void KCL_create_proc_entry(void *root_dir, const char *name, unsigned int access_mode, void *read_fn, void *write_fn, void *private_data)
+-{
+- struct proc_dir_entry *ent = NULL;
+-
+- if (root_dir == NULL || name == NULL)
+- return;
+-
+- ent = create_proc_entry(name, access_mode, (struct proc_dir_entry *)root_dir);
+-
+- if (ent)
+- {
+- ent->read_proc = (read_proc_t *)read_fn;
+- ent->write_proc = (write_proc_t *)write_fn;
+- ent->data = private_data;
+- }
+-}
+-
+ #endif /* __KERNEL__ */
diff --git a/x11-drivers/ati-drivers/files/ati-drivers-13.8-beta-include-seq_file.patch b/x11-drivers/ati-drivers/files/ati-drivers-13.8-beta-include-seq_file.patch
new file mode 100644
index 00000000..fb1ba17e
--- /dev/null
+++ b/x11-drivers/ati-drivers/files/ati-drivers-13.8-beta-include-seq_file.patch
@@ -0,0 +1,13 @@
+diff --git a/common/lib/modules/fglrx/build_mod/firegl_public.c b/common/lib/modules/fglrx/build_mod/firegl_public.c
+index 22561c5..fdfe65e 100755
+--- a/common/lib/modules/fglrx/build_mod/firegl_public.c
++++ b/common/lib/modules/fglrx/build_mod/firegl_public.c
+@@ -520,6 +520,8 @@ static int func##_wrap(char *buf, char **start, kcl_off_t offset, \
+ }
+
+ #else
++#include <linux/seq_file.h>
++
+ #define READ_PROC_WRAP(func) \
+ static int func##_wrap(struct seq_file *m, void* data) \
+ { \
diff --git a/x11-drivers/ati-drivers/files/buildfix_kernel_3.13.patch b/x11-drivers/ati-drivers/files/buildfix_kernel_3.13.patch
new file mode 100644
index 00000000..432e6666
--- /dev/null
+++ b/x11-drivers/ati-drivers/files/buildfix_kernel_3.13.patch
@@ -0,0 +1,30 @@
+From 6ea087272c0774fc86693a6fc379a2226e10b323 Mon Sep 17 00:00:00 2001
+From: Alberto Milone <alberto.milone@canonical.com>
+Date: Wed, 8 Jan 2014 16:09:58 +0100
+Subject: [PATCH 1/1] Add support for Linux 3.13
+
+Do not use the ACPI handle which was removed from struct acpi_dev_node
+in Linux 3.13. Use the ACPI companion device instead.
+---
+ kcl_acpi.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/kcl_acpi.c b/kcl_acpi.c
+index 5eb9fb1..96b6113 100755
+--- a/common/lib/modules/fglrx/build_mod/kcl_acpi.c
++++ b/common/lib/modules/fglrx/build_mod/kcl_acpi.c
+@@ -793,7 +793,11 @@ unsigned int ATI_API_CALL KCL_ACPI_GetHandles(kcl_match_info_t *pInfo)
+ {
+ #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12)
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
++ #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)
++ pInfo->video_handle = pInfo->pcidev->dev.acpi_node.companion;
++ #else
+ pInfo->video_handle = pInfo->pcidev->dev.acpi_node.handle;
++ #endif
+ #elif LINUX_VERSION_CODE > KERNEL_VERSION(2,6,19)
+ pInfo->video_handle = pInfo->pcidev->dev.archdata.acpi_handle;
+ #else
+--
+1.7.9.5
+
diff --git a/x11-drivers/ati-drivers/files/check-for-iommu-only-if-iommu-is-supported.patch b/x11-drivers/ati-drivers/files/check-for-iommu-only-if-iommu-is-supported.patch
new file mode 100644
index 00000000..79324873
--- /dev/null
+++ b/x11-drivers/ati-drivers/files/check-for-iommu-only-if-iommu-is-supported.patch
@@ -0,0 +1,31 @@
+From 1633d55aa0fb9c2ceb0ae1eab15bdec5066d35ae Mon Sep 17 00:00:00 2001
+From: Emil Karlson <jekarlson@gmail.com>
+Date: Fri, 2 Aug 2013 01:18:41 +0300
+Subject: [PATCH 1/3] Check for iommu only, if iommu is supported.
+
+---
+ common/lib/modules/fglrx/build_mod/kcl_iommu.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/common/lib/modules/fglrx/build_mod/kcl_iommu.c b/common/lib/modules/fglrx/build_mod/kcl_iommu.c
+index c6602dd..803455c 100755
+--- a/common/lib/modules/fglrx/build_mod/kcl_iommu.c
++++ b/common/lib/modules/fglrx/build_mod/kcl_iommu.c
+@@ -183,11 +183,13 @@ void ATI_API_CALL KCL_IOMMU_UnbindPasid( KCL_PCI_DevHandle pcidev,int pasid)
+ */
+ int ATI_API_CALL KCL_IOMMU_CheckInfo( KCL_PCI_DevHandle pcidev)
+ {
++#if defined(CONFIG_INTEL_IOMMU) || defined(CONFIG_AMD_IOMMU)
+ struct pci_dev* pdev = (struct pci_dev*)pcidev;
+- if ( pdev->dev.archdata.iommu )
++ if ( pdev->dev.archdata.iommu )
+ {
+ return 1;
+ }
++#endif
+ return 0;
+ }
+
+--
+1.8.1.5
+
diff --git a/x11-drivers/ati-drivers/files/linux-3.10-proc.diff b/x11-drivers/ati-drivers/files/linux-3.10-proc.diff
new file mode 100644
index 00000000..ce4871c0
--- /dev/null
+++ b/x11-drivers/ati-drivers/files/linux-3.10-proc.diff
@@ -0,0 +1,293 @@
+diff -Nur common/lib/modules/fglrx/build_mod/drmP.h common-r1/lib/modules/fglrx/build_mod/drmP.h
+--- common/lib/modules/fglrx/build_mod/drmP.h 2013-05-15 09:26:23.555752577 +0300
++++ common-r1/lib/modules/fglrx/build_mod/drmP.h 2013-05-16 10:39:17.496212055 +0300
+@@ -901,10 +901,6 @@
+ int DRM(stub_unregister)(int minor);
+
+ /* Proc support (drm_proc.h) */
+-extern struct proc_dir_entry *DRM(proc_init)(drm_device_t *dev,
+- int minor,
+- struct proc_dir_entry *root,
+- struct proc_dir_entry **dev_root);
+ extern int DRM(proc_cleanup)(int minor,
+ struct proc_dir_entry *root,
+ struct proc_dir_entry *dev_root);
+diff -Nur common/lib/modules/fglrx/build_mod/drm_proc.h common-r1/lib/modules/fglrx/build_mod/drm_proc.h
+--- common/lib/modules/fglrx/build_mod/drm_proc.h 2013-05-15 09:26:23.555752577 +0300
++++ common-r1/lib/modules/fglrx/build_mod/drm_proc.h 2013-05-19 02:16:16.584406160 +0300
+@@ -75,61 +75,6 @@
+ #define DRM_PROC_ENTRIES (sizeof(DRM(proc_list))/sizeof(DRM(proc_list)[0]))
+
+ /**
+- * Initialize the DRI proc filesystem for a device.
+- *
+- * \param dev DRM device.
+- * \param minor device minor number.
+- * \param root DRI proc dir entry.
+- * \param dev_root resulting DRI device proc dir entry.
+- * \return root entry pointer on success, or NULL on failure.
+- *
+- * Create the DRI proc root entry "/proc/ati", the device proc root entry
+- * "/proc/ati/%minor%/", and each entry in proc_list as
+- * "/proc/ati/%minor%/%name%".
+- */
+-struct proc_dir_entry *DRM(proc_init)(drm_device_t *dev, int minor,
+- struct proc_dir_entry *root,
+- struct proc_dir_entry **dev_root)
+-{
+- struct proc_dir_entry *ent;
+- int i, j;
+- char name[64];
+-
+- if (!minor) root = create_proc_entry("dri", S_IFDIR, NULL);
+- if (!root) {
+- DRM_ERROR("Cannot create /proc/ati\n");
+- return NULL;
+- }
+-
+- sprintf(name, "%d", minor);
+- *dev_root = create_proc_entry(name, S_IFDIR, root);
+- if (!*dev_root) {
+- DRM_ERROR("Cannot create /proc/ati/%s\n", name);
+- return NULL;
+- }
+-
+- for (i = 0; i < DRM_PROC_ENTRIES; i++) {
+- ent = create_proc_entry(DRM(proc_list)[i].name,
+- S_IFREG|S_IRUGO, *dev_root);
+- if (!ent) {
+- DRM_ERROR("Cannot create /proc/ati/%s/%s\n",
+- name, DRM(proc_list)[i].name);
+- for (j = 0; j < i; j++)
+- remove_proc_entry(DRM(proc_list)[i].name,
+- *dev_root);
+- remove_proc_entry(name, root);
+- if (!minor) remove_proc_entry("dri", NULL);
+- return NULL;
+- }
+- ent->read_proc = DRM(proc_list)[i].f;
+- ent->data = dev;
+- }
+-
+- return root;
+-}
+-
+-
+-/**
+ * Cleanup the proc filesystem resources.
+ *
+ * \param minor device minor number.
+diff -Nur common/lib/modules/fglrx/build_mod/firegl_public.c common-r1/lib/modules/fglrx/build_mod/firegl_public.c
+--- common/lib/modules/fglrx/build_mod/firegl_public.c 2013-05-15 09:26:23.545752925 +0300
++++ common-r1/lib/modules/fglrx/build_mod/firegl_public.c 2013-05-19 03:07:10.236552522 +0300
+@@ -583,6 +583,202 @@
+ { "NULL", NULL, NULL} // Terminate List!!!
+ };
+
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
++typedef int (read_proc_t)(char *page, char **start, off_t off, int count, int *eof, void *data);
++typedef int (write_proc_t)(struct file *file, const char __user *buffer, unsigned long count, void *data);
++#else
++#define PDE_DATA(inode) (PDE((inode))->data)
++#endif
++
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
++typedef struct {
++ read_proc_t *read_func;
++ write_proc_t *write_func;
++ void *data;
++} gentoo_proc_wrapper_t;
++
++#define GENTOO_PROC_WRAPPER_OVERFLOW_MAGIC 939750305
++
++static ssize_t gentoo_proc_wrapper_read (struct file *myfile, char __user *buffer, size_t count, loff_t *offset) {
++ int is_eof=0, retval;
++ char *start, *usebuffer=NULL;
++ gentoo_proc_wrapper_t* wrapper_data=(gentoo_proc_wrapper_t*)(myfile->private_data);
++ if (PAGE_SIZE<*offset) {
++ printk(KERN_ERR "Trying to read beyond 4k on proc\n");
++ return -EIO;
++ }
++ //printk(KERN_NOTICE " call with: dev %p, func %p\n", wrapper_data->data, wrapper_data->read_func);
++
++ usebuffer=kmalloc(2*PAGE_SIZE, GFP_KERNEL);
++ if (!usebuffer)
++ return -ENOMEM;
++ ((u32*)usebuffer)[1024]=GENTOO_PROC_WRAPPER_OVERFLOW_MAGIC;
++
++ retval=wrapper_data->read_func(usebuffer, &start, *offset, count, &is_eof, wrapper_data->data);
++
++ BUG_ON(GENTOO_PROC_WRAPPER_OVERFLOW_MAGIC != ((u32*)usebuffer)[1024]);
++
++ if (0 > retval)
++ {
++ printk(KERN_ERR "Proc read failed with %d", retval);
++ goto out;
++ }
++
++ if (copy_to_user(buffer, start, retval)) {
++ printk(KERN_NOTICE "copy to user failed in amd drivers proc code\n");
++ retval=-EFAULT;
++ goto out;
++ }
++ *offset+=retval;
++
++out:
++ if (usebuffer)
++ kfree(usebuffer);
++ return retval;
++}
++static ssize_t gentoo_proc_wrapper_write (struct file *myfile, const char __user *buffer, size_t count, loff_t *offset) {
++ gentoo_proc_wrapper_t* wrapper_data=(gentoo_proc_wrapper_t*)(myfile->private_data);
++ int retval=0;
++ void *usebuffer=NULL;
++
++ BUG_ON(*offset);
++ if (!wrapper_data->write_func)
++ return -EPERM;
++
++ usebuffer=kmalloc(count, GFP_KERNEL);
++ if (!usebuffer)
++ return -ENOMEM;
++ if (copy_from_user(usebuffer, buffer, count)) {
++ printk(KERN_NOTICE "copy from user failed in amd drivers proc code\n");
++ retval=-EFAULT;
++ goto out;
++ }
++
++ retval=wrapper_data->write_func(myfile, buffer, count, wrapper_data->data);
++ *offset+=retval;
++out:
++ if (usebuffer)
++ kfree(usebuffer);
++ return retval;
++}
++static int gentoo_proc_wrapper_open(struct inode *myinode, struct file *myfile) {
++ myfile->private_data=PDE_DATA(myinode);
++ return generic_file_open(myinode, myfile);
++}
++struct file_operations gentoo_proc_fops = {
++ .read=gentoo_proc_wrapper_read,
++ .write=gentoo_proc_wrapper_write,
++ .open=gentoo_proc_wrapper_open,
++};
++
++static void *gentoo_proc_wrapper_data(read_proc_t *reader, write_proc_t *writer, void *mydata) {
++ gentoo_proc_wrapper_t *retval=kmalloc(sizeof(gentoo_proc_wrapper_t), GFP_KERNEL);
++ if (!retval)
++ return retval;
++ retval->read_func=reader;
++ retval->write_func=writer;
++ retval->data=mydata;
++ return retval;
++}
++
++static struct proc_dir_entry *firegl_proc_init( device_t *dev,
++ int minor,
++ struct proc_dir_entry *root,
++ struct proc_dir_entry **dev_root,
++ kcl_proc_list_t *proc_list ) // proc_list must be terminated!
++{
++ struct proc_dir_entry *ent;
++ char name[64];
++ kcl_proc_list_t *list = proc_list;
++ void *tempdata;
++ KCL_DEBUG1(FN_FIREGL_PROC, "minor %d, proc_list 0x%08lx\n", minor, (unsigned long)proc_list);
++ if (!minor)
++ {
++ root = proc_mkdir("ati", NULL);
++ }
++
++ if (!root)
++ {
++ KCL_DEBUG_ERROR("Cannot create /proc/ati\n");
++ return NULL;
++ }
++
++ if (minor == 0)
++ {
++ // Global major debice number entry
++ tempdata=gentoo_proc_wrapper_data((read_proc_t*)firegl_major_proc_read, NULL, NULL);
++ if (!tempdata)
++ return NULL;
++ ent = proc_create_data("major", S_IFREG|S_IRUGO, root, &gentoo_proc_fops, tempdata);
++ if (!ent)
++ {
++ remove_proc_entry("ati", NULL);
++ KCL_DEBUG_ERROR("Cannot create /proc/ati/major\n");
++ return NULL;
++ }
++ }
++
++ sprintf(name, "%d", minor);
++ *dev_root = proc_mkdir(name, root);
++ if (!*dev_root) {
++ remove_proc_entry("major", root);
++ remove_proc_entry("ati", NULL);
++ KCL_DEBUG_ERROR("Cannot create /proc/ati/%s\n", name);
++ return NULL;
++ }
++
++ while (list->f || list->fops)
++ {
++ struct file_operations *my_fops = &gentoo_proc_fops;
++ if (list->fops)
++ {
++ my_fops = (struct file_operations*)list->fops;
++ tempdata=(dev->pubdev.signature == FGL_DEVICE_SIGNATURE)? firegl_find_device(minor) : (dev);
++ }
++ else {
++ BUG_ON(!list->f);
++ tempdata=gentoo_proc_wrapper_data((read_proc_t*)list->f, NULL, (dev->pubdev.signature == FGL_DEVICE_SIGNATURE)? firegl_find_device(minor) : (dev) );
++ if (!tempdata)
++ return NULL;
++ }
++ //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);
++ ent = proc_create_data(list->name, S_IFREG|S_IRUGO, *dev_root, my_fops, tempdata);
++
++ if (!ent)
++ {
++ KCL_DEBUG_ERROR("Cannot create /proc/ati/%s/%s\n", name, list->name);
++ while (proc_list != list)
++ {
++ remove_proc_entry(proc_list->name, *dev_root);
++ proc_list++;
++ }
++ remove_proc_entry(name, root);
++ if (!minor)
++ {
++ remove_proc_entry("major", root);
++ remove_proc_entry("ati", NULL);
++ }
++ return NULL;
++ }
++
++ list++;
++ }
++
++ if (minor == 0)
++ {
++ // Global debug entry, only create it once
++ tempdata=gentoo_proc_wrapper_data((read_proc_t*)firegl_debug_proc_read_wrap, (write_proc_t*)firegl_debug_proc_write_wrap, dev);
++ if (!tempdata)
++ return NULL;
++ ent=proc_create_data("debug", S_IFREG|S_IRUGO, root, &gentoo_proc_fops, tempdata);
++ if (!ent)
++ return NULL;
++ }
++
++ return root;
++}
++#else
+ static struct proc_dir_entry *firegl_proc_init( device_t *dev,
+ int minor,
+ struct proc_dir_entry *root,
+@@ -677,6 +873,7 @@
+
+ return root;
+ }
++#endif
+
+ static int firegl_proc_cleanup( int minor,
+ struct proc_dir_entry *root,
diff --git a/x11-drivers/ati-drivers/files/typesafe-kuid.diff b/x11-drivers/ati-drivers/files/typesafe-kuid.diff
new file mode 100644
index 00000000..c226ea3d
--- /dev/null
+++ b/x11-drivers/ati-drivers/files/typesafe-kuid.diff
@@ -0,0 +1,34 @@
+diff --git a/common/lib/modules/fglrx/build_mod/firegl_public.c b/common/lib/modules/fglrx/build_mod/firegl_public.c
+index d3ad3ce..9362b58 100755
+--- a/common/lib/modules/fglrx/build_mod/firegl_public.c
++++ b/common/lib/modules/fglrx/build_mod/firegl_public.c
+@@ -34,6 +34,11 @@
+ #include <linux/autoconf.h>
+ #endif
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
++#include <linux/uidgid.h>
++#endif
++
++
+ #if !defined(CONFIG_X86)
+ #if !defined(CONFIG_X86_PC)
+ #if !defined(CONFIG_X86_XEN)
+@@ -1543,9 +1548,17 @@ KCL_TYPE_Pid ATI_API_CALL KCL_GetTgid(void)
+ KCL_TYPE_Uid ATI_API_CALL KCL_GetEffectiveUid(void)
+ {
+ #ifdef current_euid
++# if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
++ return __kuid_val(current_euid());
++# else
+ return current_euid();
++# endif
+ #else
++# if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
++ return __kuid_val(current->euid);
++# else
+ return current->euid;
++# endif
+ #endif
+ }
+