Gentoo Archives: gentoo-commits

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