Gentoo Archives: gentoo-commits

From: "Chi-Thanh Christopher Nguyen (chithanh)" <chithanh@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in x11-drivers/ati-drivers/files: linux-3.9-kuid.diff linux-3.10-proc.diff
Date: Mon, 20 May 2013 17:41:07
Message-Id: 20130520174102.7F1F52171D@flycatcher.gentoo.org
1 chithanh 13/05/20 17:41:02
2
3 Added: linux-3.9-kuid.diff linux-3.10-proc.diff
4 Log:
5 Import latest ebuild from the x11 overlay, by Emil Karlson.
6
7 (Portage version: 2.1.11.62/cvs/Linux x86_64, unsigned Manifest commit)
8
9 Revision Changes Path
10 1.1 x11-drivers/ati-drivers/files/linux-3.9-kuid.diff
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/x11-drivers/ati-drivers/files/linux-3.9-kuid.diff?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/x11-drivers/ati-drivers/files/linux-3.9-kuid.diff?rev=1.1&content-type=text/plain
14
15 Index: linux-3.9-kuid.diff
16 ===================================================================
17 diff -Nur common/lib/modules/fglrx/build_mod/firegl_public.c common-r1/lib/modules/fglrx/build_mod/firegl_public.c
18 --- common/lib/modules/fglrx/build_mod/firegl_public.c 2013-04-17 00:29:55.000000000 +0300
19 +++ common-r1/lib/modules/fglrx/build_mod/firegl_public.c 2013-05-11 00:37:44.653966585 +0300
20 @@ -34,6 +34,11 @@
21 #include <linux/autoconf.h>
22 #endif
23
24 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)
25 +#include <linux/uidgid.h>
26 +#endif
27 +
28 +
29 #if !defined(CONFIG_X86)
30 #if !defined(CONFIG_X86_PC)
31 #if !defined(CONFIG_X86_XEN)
32 @@ -1543,9 +1548,17 @@
33 KCL_TYPE_Uid ATI_API_CALL KCL_GetEffectiveUid(void)
34 {
35 #ifdef current_euid
36 +# if LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)
37 + return __kuid_val(current_euid());
38 +# else
39 return current_euid();
40 +# endif
41 #else
42 +# if LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)
43 + return __kuid_val(current->euid);
44 +# else
45 return current->euid;
46 +# endif
47 #endif
48 }
49
50
51
52
53 1.1 x11-drivers/ati-drivers/files/linux-3.10-proc.diff
54
55 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/x11-drivers/ati-drivers/files/linux-3.10-proc.diff?rev=1.1&view=markup
56 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/x11-drivers/ati-drivers/files/linux-3.10-proc.diff?rev=1.1&content-type=text/plain
57
58 Index: linux-3.10-proc.diff
59 ===================================================================
60 diff -Nur common/lib/modules/fglrx/build_mod/drmP.h common-r1/lib/modules/fglrx/build_mod/drmP.h
61 --- common/lib/modules/fglrx/build_mod/drmP.h 2013-05-15 09:26:23.555752577 +0300
62 +++ common-r1/lib/modules/fglrx/build_mod/drmP.h 2013-05-16 10:39:17.496212055 +0300
63 @@ -901,10 +901,6 @@
64 int DRM(stub_unregister)(int minor);
65
66 /* Proc support (drm_proc.h) */
67 -extern struct proc_dir_entry *DRM(proc_init)(drm_device_t *dev,
68 - int minor,
69 - struct proc_dir_entry *root,
70 - struct proc_dir_entry **dev_root);
71 extern int DRM(proc_cleanup)(int minor,
72 struct proc_dir_entry *root,
73 struct proc_dir_entry *dev_root);
74 diff -Nur common/lib/modules/fglrx/build_mod/drm_proc.h common-r1/lib/modules/fglrx/build_mod/drm_proc.h
75 --- common/lib/modules/fglrx/build_mod/drm_proc.h 2013-05-15 09:26:23.555752577 +0300
76 +++ common-r1/lib/modules/fglrx/build_mod/drm_proc.h 2013-05-19 02:16:16.584406160 +0300
77 @@ -75,61 +75,6 @@
78 #define DRM_PROC_ENTRIES (sizeof(DRM(proc_list))/sizeof(DRM(proc_list)[0]))
79
80 /**
81 - * Initialize the DRI proc filesystem for a device.
82 - *
83 - * \param dev DRM device.
84 - * \param minor device minor number.
85 - * \param root DRI proc dir entry.
86 - * \param dev_root resulting DRI device proc dir entry.
87 - * \return root entry pointer on success, or NULL on failure.
88 - *
89 - * Create the DRI proc root entry "/proc/ati", the device proc root entry
90 - * "/proc/ati/%minor%/", and each entry in proc_list as
91 - * "/proc/ati/%minor%/%name%".
92 - */
93 -struct proc_dir_entry *DRM(proc_init)(drm_device_t *dev, int minor,
94 - struct proc_dir_entry *root,
95 - struct proc_dir_entry **dev_root)
96 -{
97 - struct proc_dir_entry *ent;
98 - int i, j;
99 - char name[64];
100 -
101 - if (!minor) root = create_proc_entry("dri", S_IFDIR, NULL);
102 - if (!root) {
103 - DRM_ERROR("Cannot create /proc/ati\n");
104 - return NULL;
105 - }
106 -
107 - sprintf(name, "%d", minor);
108 - *dev_root = create_proc_entry(name, S_IFDIR, root);
109 - if (!*dev_root) {
110 - DRM_ERROR("Cannot create /proc/ati/%s\n", name);
111 - return NULL;
112 - }
113 -
114 - for (i = 0; i < DRM_PROC_ENTRIES; i++) {
115 - ent = create_proc_entry(DRM(proc_list)[i].name,
116 - S_IFREG|S_IRUGO, *dev_root);
117 - if (!ent) {
118 - DRM_ERROR("Cannot create /proc/ati/%s/%s\n",
119 - name, DRM(proc_list)[i].name);
120 - for (j = 0; j < i; j++)
121 - remove_proc_entry(DRM(proc_list)[i].name,
122 - *dev_root);
123 - remove_proc_entry(name, root);
124 - if (!minor) remove_proc_entry("dri", NULL);
125 - return NULL;
126 - }
127 - ent->read_proc = DRM(proc_list)[i].f;
128 - ent->data = dev;
129 - }
130 -
131 - return root;
132 -}
133 -
134 -
135 -/**
136 * Cleanup the proc filesystem resources.
137 *
138 * \param minor device minor number.
139 diff -Nur common/lib/modules/fglrx/build_mod/firegl_public.c common-r1/lib/modules/fglrx/build_mod/firegl_public.c
140 --- common/lib/modules/fglrx/build_mod/firegl_public.c 2013-05-15 09:26:23.545752925 +0300
141 +++ common-r1/lib/modules/fglrx/build_mod/firegl_public.c 2013-05-19 03:07:10.236552522 +0300
142 @@ -583,6 +583,202 @@
143 { "NULL", NULL, NULL} // Terminate List!!!
144 };
145
146 +
147 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
148 +typedef int (read_proc_t)(char *page, char **start, off_t off, int count, int *eof, void *data);
149 +typedef int (write_proc_t)(struct file *file, const char __user *buffer, unsigned long count, void *data);
150 +#else
151 +#define PDE_DATA(inode) (PDE((inode))->data)
152 +#endif
153 +
154 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
155 +typedef struct {
156 + read_proc_t *read_func;
157 + write_proc_t *write_func;
158 + void *data;
159 +} gentoo_proc_wrapper_t;
160 +
161 +#define GENTOO_PROC_WRAPPER_OVERFLOW_MAGIC 939750305
162 +
163 +static ssize_t gentoo_proc_wrapper_read (struct file *myfile, char __user *buffer, size_t count, loff_t *offset) {
164 + int is_eof=0, retval;
165 + char *start, *usebuffer=NULL;
166 + gentoo_proc_wrapper_t* wrapper_data=(gentoo_proc_wrapper_t*)(myfile->private_data);
167 + if (PAGE_SIZE<*offset) {
168 + printk(KERN_ERR "Trying to read beyond 4k on proc\n");
169 + return -EIO;
170 + }
171 + //printk(KERN_NOTICE " call with: dev %p, func %p\n", wrapper_data->data, wrapper_data->read_func);
172 +
173 + usebuffer=kmalloc(2*PAGE_SIZE, GFP_KERNEL);
174 + if (!usebuffer)
175 + return -ENOMEM;
176 + ((u32*)usebuffer)[1024]=GENTOO_PROC_WRAPPER_OVERFLOW_MAGIC;
177 +
178 + retval=wrapper_data->read_func(usebuffer, &start, *offset, count, &is_eof, wrapper_data->data);
179 +
180 + BUG_ON(GENTOO_PROC_WRAPPER_OVERFLOW_MAGIC != ((u32*)usebuffer)[1024]);
181 +
182 + if (0 > retval)
183 + {
184 + printk(KERN_ERR "Proc read failed with %d", retval);
185 + goto out;
186 + }
187 +
188 + if (copy_to_user(buffer, start, retval)) {
189 + printk(KERN_NOTICE "copy to user failed in amd drivers proc code\n");
190 + retval=-EFAULT;
191 + goto out;
192 + }
193 + *offset+=retval;
194 +
195 +out:
196 + if (usebuffer)
197 + kfree(usebuffer);
198 + return retval;
199 +}
200 +static ssize_t gentoo_proc_wrapper_write (struct file *myfile, const char __user *buffer, size_t count, loff_t *offset) {
201 + gentoo_proc_wrapper_t* wrapper_data=(gentoo_proc_wrapper_t*)(myfile->private_data);
202 + int retval=0;
203 + void *usebuffer=NULL;
204 +
205 + BUG_ON(*offset);
206 + if (!wrapper_data->write_func)
207 + return -EPERM;
208 +
209 + usebuffer=kmalloc(count, GFP_KERNEL);
210 + if (!usebuffer)
211 + return -ENOMEM;
212 + if (copy_from_user(usebuffer, buffer, count)) {
213 + printk(KERN_NOTICE "copy from user failed in amd drivers proc code\n");
214 + retval=-EFAULT;
215 + goto out;
216 + }
217 +
218 + retval=wrapper_data->write_func(myfile, buffer, count, wrapper_data->data);
219 + *offset+=retval;
220 +out:
221 + if (usebuffer)
222 + kfree(usebuffer);
223 + return retval;
224 +}
225 +static int gentoo_proc_wrapper_open(struct inode *myinode, struct file *myfile) {
226 + myfile->private_data=PDE_DATA(myinode);
227 + return generic_file_open(myinode, myfile);
228 +}
229 +struct file_operations gentoo_proc_fops = {
230 + .read=gentoo_proc_wrapper_read,
231 + .write=gentoo_proc_wrapper_write,
232 + .open=gentoo_proc_wrapper_open,
233 +};
234 +
235 +static void *gentoo_proc_wrapper_data(read_proc_t *reader, write_proc_t *writer, void *mydata) {
236 + gentoo_proc_wrapper_t *retval=kmalloc(sizeof(gentoo_proc_wrapper_t), GFP_KERNEL);
237 + if (!retval)
238 + return retval;
239 + retval->read_func=reader;
240 + retval->write_func=writer;
241 + retval->data=mydata;
242 + return retval;
243 +}
244 +
245 +static struct proc_dir_entry *firegl_proc_init( device_t *dev,
246 + int minor,
247 + struct proc_dir_entry *root,
248 + struct proc_dir_entry **dev_root,
249 + kcl_proc_list_t *proc_list ) // proc_list must be terminated!
250 +{
251 + struct proc_dir_entry *ent;
252 + char name[64];
253 + kcl_proc_list_t *list = proc_list;
254 + void *tempdata;
255 + KCL_DEBUG1(FN_FIREGL_PROC, "minor %d, proc_list 0x%08lx\n", minor, (unsigned long)proc_list);
256 + if (!minor)
257 + {
258 + root = proc_mkdir("ati", NULL);
259 + }
260 +
261 + if (!root)
262 + {
263 + KCL_DEBUG_ERROR("Cannot create /proc/ati\n");
264 + return NULL;
265 + }
266 +
267 + if (minor == 0)
268 + {
269 + // Global major debice number entry
270 + tempdata=gentoo_proc_wrapper_data((read_proc_t*)firegl_major_proc_read, NULL, NULL);
271 + if (!tempdata)
272 + return NULL;
273 + ent = proc_create_data("major", S_IFREG|S_IRUGO, root, &gentoo_proc_fops, tempdata);
274 + if (!ent)
275 + {
276 + remove_proc_entry("ati", NULL);
277 + KCL_DEBUG_ERROR("Cannot create /proc/ati/major\n");
278 + return NULL;
279 + }
280 + }
281 +
282 + sprintf(name, "%d", minor);
283 + *dev_root = proc_mkdir(name, root);
284 + if (!*dev_root) {
285 + remove_proc_entry("major", root);
286 + remove_proc_entry("ati", NULL);
287 + KCL_DEBUG_ERROR("Cannot create /proc/ati/%s\n", name);
288 + return NULL;
289 + }
290 +
291 + while (list->f || list->fops)
292 + {
293 + struct file_operations *my_fops = &gentoo_proc_fops;
294 + if (list->fops)
295 + {
296 + my_fops = (struct file_operations*)list->fops;
297 + tempdata=(dev->pubdev.signature == FGL_DEVICE_SIGNATURE)? firegl_find_device(minor) : (dev);
298 + }
299 + else {
300 + BUG_ON(!list->f);
301 + tempdata=gentoo_proc_wrapper_data((read_proc_t*)list->f, NULL, (dev->pubdev.signature == FGL_DEVICE_SIGNATURE)? firegl_find_device(minor) : (dev) );
302 + if (!tempdata)
303 + return NULL;
304 + }
305 + //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);
306 + ent = proc_create_data(list->name, S_IFREG|S_IRUGO, *dev_root, my_fops, tempdata);
307 +
308 + if (!ent)
309 + {
310 + KCL_DEBUG_ERROR("Cannot create /proc/ati/%s/%s\n", name, list->name);
311 + while (proc_list != list)
312 + {
313 + remove_proc_entry(proc_list->name, *dev_root);
314 + proc_list++;
315 + }
316 + remove_proc_entry(name, root);
317 + if (!minor)
318 + {
319 + remove_proc_entry("major", root);
320 + remove_proc_entry("ati", NULL);
321 + }
322 + return NULL;
323 + }
324 +
325 + list++;
326 + }
327 +
328 + if (minor == 0)
329 + {
330 + // Global debug entry, only create it once
331 + tempdata=gentoo_proc_wrapper_data((read_proc_t*)firegl_debug_proc_read_wrap, (write_proc_t*)firegl_debug_proc_write_wrap, dev);
332 + if (!tempdata)
333 + return NULL;
334 + ent=proc_create_data("debug", S_IFREG|S_IRUGO, root, &gentoo_proc_fops, tempdata);
335 + if (!ent)
336 + return NULL;
337 + }
338 +
339 + return root;
340 +}
341 +#else
342 static struct proc_dir_entry *firegl_proc_init( device_t *dev,
343 int minor,
344 struct proc_dir_entry *root,
345 @@ -677,6 +873,7 @@
346
347 return root;
348 }
349 +#endif
350
351 static int firegl_proc_cleanup( int minor,
352 struct proc_dir_entry *root,