2 * AGPGART driver frontend
3 * Copyright (C) 2004 Silicon Graphics, Inc.
4 * Copyright (C) 2002-2003 Dave Jones
5 * Copyright (C) 1999 Jeff Hartmann
6 * Copyright (C) 1999 Precision Insight, Inc.
7 * Copyright (C) 1999 Xi Graphics, Inc.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
23 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
25 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 #include <linux/types.h>
30 #include <linux/kernel.h>
31 #include <linux/module.h>
32 #include <linux/mman.h>
33 #include <linux/pci.h>
34 #include <linux/miscdevice.h>
35 #include <linux/agp_backend.h>
36 #include <linux/agpgart.h>
37 #include <linux/slab.h>
40 #include <linux/sched.h>
41 #include <linux/uaccess.h>
44 struct agp_front_data agp_fe;
46 struct agp_memory *agp_find_mem_by_key(int key)
48 struct agp_memory *curr;
50 if (agp_fe.current_controller == NULL)
53 curr = agp_fe.current_controller->pool;
55 while (curr != NULL) {
61 DBG("key=%d -> mem=%p", key, curr);
65 static void agp_remove_from_pool(struct agp_memory *temp)
67 struct agp_memory *prev;
68 struct agp_memory *next;
70 /* Check to see if this is even in the memory pool */
73 if (agp_find_mem_by_key(temp->key) != NULL) {
83 /* This is the first item on the list */
87 agp_fe.current_controller->pool = next;
93 * Routines for managing each client's segment list -
94 * These routines handle adding and removing segments
95 * to each auth'ed client.
99 agp_segment_priv *agp_find_seg_in_client(const struct agp_client *client,
100 unsigned long offset,
101 int size, pgprot_t page_prot)
103 struct agp_segment_priv *seg;
108 pg_start = offset / 4096;
109 pg_count = size / 4096;
110 seg = *(client->segments);
112 for (i = 0; i < client->num_segments; i++) {
113 if ((seg[i].pg_start == pg_start) &&
114 (seg[i].pg_count == pg_count) &&
115 (pgprot_val(seg[i].prot) == pgprot_val(page_prot))) {
123 static void agp_remove_seg_from_client(struct agp_client *client)
125 DBG("client=%p", client);
127 if (client->segments != NULL) {
128 if (*(client->segments) != NULL) {
129 DBG("Freeing %p from client %p", *(client->segments), client);
130 kfree(*(client->segments));
132 DBG("Freeing %p from client %p", client->segments, client);
133 kfree(client->segments);
134 client->segments = NULL;
138 static void agp_add_seg_to_client(struct agp_client *client,
139 struct agp_segment_priv ** seg, int num_segments)
141 struct agp_segment_priv **prev_seg;
143 prev_seg = client->segments;
145 if (prev_seg != NULL)
146 agp_remove_seg_from_client(client);
148 DBG("Adding seg %p (%d segments) to client %p", seg, num_segments, client);
149 client->num_segments = num_segments;
150 client->segments = seg;
153 static pgprot_t agp_convert_mmap_flags(int prot)
155 unsigned long prot_bits;
157 prot_bits = calc_vm_prot_bits(prot, 0) | VM_SHARED;
158 return vm_get_page_prot(prot_bits);
161 int agp_create_segment(struct agp_client *client, struct agp_region *region)
163 struct agp_segment_priv **ret_seg;
164 struct agp_segment_priv *seg;
165 struct agp_segment *user_seg;
168 seg = kzalloc((sizeof(struct agp_segment_priv) * region->seg_count), GFP_KERNEL);
170 kfree(region->seg_list);
171 region->seg_list = NULL;
174 user_seg = region->seg_list;
176 for (i = 0; i < region->seg_count; i++) {
177 seg[i].pg_start = user_seg[i].pg_start;
178 seg[i].pg_count = user_seg[i].pg_count;
179 seg[i].prot = agp_convert_mmap_flags(user_seg[i].prot);
181 kfree(region->seg_list);
182 region->seg_list = NULL;
184 ret_seg = kmalloc(sizeof(void *), GFP_KERNEL);
185 if (ret_seg == NULL) {
190 agp_add_seg_to_client(client, ret_seg, region->seg_count);
194 /* End - Routines for managing each client's segment list */
196 /* This function must only be called when current_controller != NULL */
197 static void agp_insert_into_pool(struct agp_memory * temp)
199 struct agp_memory *prev;
201 prev = agp_fe.current_controller->pool;
207 agp_fe.current_controller->pool = temp;
211 /* File private list routines */
213 struct agp_file_private *agp_find_private(pid_t pid)
215 struct agp_file_private *curr;
217 curr = agp_fe.file_priv_list;
219 while (curr != NULL) {
220 if (curr->my_pid == pid)
228 static void agp_insert_file_private(struct agp_file_private * priv)
230 struct agp_file_private *prev;
232 prev = agp_fe.file_priv_list;
237 agp_fe.file_priv_list = priv;
240 static void agp_remove_file_private(struct agp_file_private * priv)
242 struct agp_file_private *next;
243 struct agp_file_private *prev;
258 agp_fe.file_priv_list = next;
262 /* End - File flag list routines */
265 * Wrappers for agp_free_memory & agp_allocate_memory
266 * These make sure that internal lists are kept updated.
268 void agp_free_memory_wrap(struct agp_memory *memory)
270 agp_remove_from_pool(memory);
271 agp_free_memory(memory);
274 struct agp_memory *agp_allocate_memory_wrap(size_t pg_count, u32 type)
276 struct agp_memory *memory;
278 memory = agp_allocate_memory(agp_bridge, pg_count, type);
282 agp_insert_into_pool(memory);
286 /* Routines for managing the list of controllers -
287 * These routines manage the current controller, and the list of
291 static struct agp_controller *agp_find_controller_by_pid(pid_t id)
293 struct agp_controller *controller;
295 controller = agp_fe.controllers;
297 while (controller != NULL) {
298 if (controller->pid == id)
300 controller = controller->next;
306 static struct agp_controller *agp_create_controller(pid_t id)
308 struct agp_controller *controller;
310 controller = kzalloc(sizeof(struct agp_controller), GFP_KERNEL);
311 if (controller == NULL)
314 controller->pid = id;
318 static int agp_insert_controller(struct agp_controller *controller)
320 struct agp_controller *prev_controller;
322 prev_controller = agp_fe.controllers;
323 controller->next = prev_controller;
325 if (prev_controller != NULL)
326 prev_controller->prev = controller;
328 agp_fe.controllers = controller;
333 static void agp_remove_all_clients(struct agp_controller *controller)
335 struct agp_client *client;
336 struct agp_client *temp;
338 client = controller->clients;
341 struct agp_file_private *priv;
344 agp_remove_seg_from_client(temp);
345 priv = agp_find_private(temp->pid);
348 clear_bit(AGP_FF_IS_VALID, &priv->access_flags);
349 clear_bit(AGP_FF_IS_CLIENT, &priv->access_flags);
351 client = client->next;
356 static void agp_remove_all_memory(struct agp_controller *controller)
358 struct agp_memory *memory;
359 struct agp_memory *temp;
361 memory = controller->pool;
365 memory = memory->next;
366 agp_free_memory_wrap(temp);
370 static int agp_remove_controller(struct agp_controller *controller)
372 struct agp_controller *prev_controller;
373 struct agp_controller *next_controller;
375 prev_controller = controller->prev;
376 next_controller = controller->next;
378 if (prev_controller != NULL) {
379 prev_controller->next = next_controller;
380 if (next_controller != NULL)
381 next_controller->prev = prev_controller;
384 if (next_controller != NULL)
385 next_controller->prev = NULL;
387 agp_fe.controllers = next_controller;
390 agp_remove_all_memory(controller);
391 agp_remove_all_clients(controller);
393 if (agp_fe.current_controller == controller) {
394 agp_fe.current_controller = NULL;
395 agp_fe.backend_acquired = false;
396 agp_backend_release(agp_bridge);
402 static void agp_controller_make_current(struct agp_controller *controller)
404 struct agp_client *clients;
406 clients = controller->clients;
408 while (clients != NULL) {
409 struct agp_file_private *priv;
411 priv = agp_find_private(clients->pid);
414 set_bit(AGP_FF_IS_VALID, &priv->access_flags);
415 set_bit(AGP_FF_IS_CLIENT, &priv->access_flags);
417 clients = clients->next;
420 agp_fe.current_controller = controller;
423 static void agp_controller_release_current(struct agp_controller *controller,
424 struct agp_file_private *controller_priv)
426 struct agp_client *clients;
428 clear_bit(AGP_FF_IS_VALID, &controller_priv->access_flags);
429 clients = controller->clients;
431 while (clients != NULL) {
432 struct agp_file_private *priv;
434 priv = agp_find_private(clients->pid);
437 clear_bit(AGP_FF_IS_VALID, &priv->access_flags);
439 clients = clients->next;
442 agp_fe.current_controller = NULL;
443 agp_fe.used_by_controller = false;
444 agp_backend_release(agp_bridge);
448 * Routines for managing client lists -
449 * These routines are for managing the list of auth'ed clients.
452 static struct agp_client
453 *agp_find_client_in_controller(struct agp_controller *controller, pid_t id)
455 struct agp_client *client;
457 if (controller == NULL)
460 client = controller->clients;
462 while (client != NULL) {
463 if (client->pid == id)
465 client = client->next;
471 static struct agp_controller *agp_find_controller_for_client(pid_t id)
473 struct agp_controller *controller;
475 controller = agp_fe.controllers;
477 while (controller != NULL) {
478 if ((agp_find_client_in_controller(controller, id)) != NULL)
480 controller = controller->next;
486 struct agp_client *agp_find_client_by_pid(pid_t id)
488 struct agp_client *temp;
490 if (agp_fe.current_controller == NULL)
493 temp = agp_find_client_in_controller(agp_fe.current_controller, id);
497 static void agp_insert_client(struct agp_client *client)
499 struct agp_client *prev_client;
501 prev_client = agp_fe.current_controller->clients;
502 client->next = prev_client;
504 if (prev_client != NULL)
505 prev_client->prev = client;
507 agp_fe.current_controller->clients = client;
508 agp_fe.current_controller->num_clients++;
511 struct agp_client *agp_create_client(pid_t id)
513 struct agp_client *new_client;
515 new_client = kzalloc(sizeof(struct agp_client), GFP_KERNEL);
516 if (new_client == NULL)
519 new_client->pid = id;
520 agp_insert_client(new_client);
524 int agp_remove_client(pid_t id)
526 struct agp_client *client;
527 struct agp_client *prev_client;
528 struct agp_client *next_client;
529 struct agp_controller *controller;
531 controller = agp_find_controller_for_client(id);
532 if (controller == NULL)
535 client = agp_find_client_in_controller(controller, id);
539 prev_client = client->prev;
540 next_client = client->next;
542 if (prev_client != NULL) {
543 prev_client->next = next_client;
544 if (next_client != NULL)
545 next_client->prev = prev_client;
548 if (next_client != NULL)
549 next_client->prev = NULL;
550 controller->clients = next_client;
553 controller->num_clients--;
554 agp_remove_seg_from_client(client);
559 /* End - Routines for managing client lists */
561 /* File Operations */
563 static int agp_mmap(struct file *file, struct vm_area_struct *vma)
565 unsigned int size, current_size;
566 unsigned long offset;
567 struct agp_client *client;
568 struct agp_file_private *priv = file->private_data;
569 struct agp_kern_info kerninfo;
571 mutex_lock(&(agp_fe.agp_mutex));
573 if (agp_fe.backend_acquired != true)
576 if (!(test_bit(AGP_FF_IS_VALID, &priv->access_flags)))
579 agp_copy_info(agp_bridge, &kerninfo);
580 size = vma->vm_end - vma->vm_start;
581 current_size = kerninfo.aper_size;
582 current_size = current_size * 0x100000;
583 offset = vma->vm_pgoff << PAGE_SHIFT;
584 DBG("%lx:%lx", offset, offset+size);
586 if (test_bit(AGP_FF_IS_CLIENT, &priv->access_flags)) {
587 if ((size + offset) > current_size)
590 client = agp_find_client_by_pid(current->pid);
595 if (!agp_find_seg_in_client(client, offset, size, vma->vm_page_prot))
598 DBG("client vm_ops=%p", kerninfo.vm_ops);
599 if (kerninfo.vm_ops) {
600 vma->vm_ops = kerninfo.vm_ops;
601 } else if (io_remap_pfn_range(vma, vma->vm_start,
602 (kerninfo.aper_base + offset) >> PAGE_SHIFT,
604 pgprot_writecombine(vma->vm_page_prot))) {
607 mutex_unlock(&(agp_fe.agp_mutex));
611 if (test_bit(AGP_FF_IS_CONTROLLER, &priv->access_flags)) {
612 if (size != current_size)
615 DBG("controller vm_ops=%p", kerninfo.vm_ops);
616 if (kerninfo.vm_ops) {
617 vma->vm_ops = kerninfo.vm_ops;
618 } else if (io_remap_pfn_range(vma, vma->vm_start,
619 kerninfo.aper_base >> PAGE_SHIFT,
621 pgprot_writecombine(vma->vm_page_prot))) {
624 mutex_unlock(&(agp_fe.agp_mutex));
629 mutex_unlock(&(agp_fe.agp_mutex));
633 mutex_unlock(&(agp_fe.agp_mutex));
637 mutex_unlock(&(agp_fe.agp_mutex));
641 static int agp_release(struct inode *inode, struct file *file)
643 struct agp_file_private *priv = file->private_data;
645 mutex_lock(&(agp_fe.agp_mutex));
647 DBG("priv=%p", priv);
649 if (test_bit(AGP_FF_IS_CONTROLLER, &priv->access_flags)) {
650 struct agp_controller *controller;
652 controller = agp_find_controller_by_pid(priv->my_pid);
654 if (controller != NULL) {
655 if (controller == agp_fe.current_controller)
656 agp_controller_release_current(controller, priv);
657 agp_remove_controller(controller);
662 if (test_bit(AGP_FF_IS_CLIENT, &priv->access_flags))
663 agp_remove_client(priv->my_pid);
665 agp_remove_file_private(priv);
667 file->private_data = NULL;
668 mutex_unlock(&(agp_fe.agp_mutex));
672 static int agp_open(struct inode *inode, struct file *file)
674 int minor = iminor(inode);
675 struct agp_file_private *priv;
676 struct agp_client *client;
678 if (minor != AGPGART_MINOR)
681 mutex_lock(&(agp_fe.agp_mutex));
683 priv = kzalloc(sizeof(struct agp_file_private), GFP_KERNEL);
685 mutex_unlock(&(agp_fe.agp_mutex));
689 set_bit(AGP_FF_ALLOW_CLIENT, &priv->access_flags);
690 priv->my_pid = current->pid;
692 if (capable(CAP_SYS_RAWIO))
693 /* Root priv, can be controller */
694 set_bit(AGP_FF_ALLOW_CONTROLLER, &priv->access_flags);
696 client = agp_find_client_by_pid(current->pid);
698 if (client != NULL) {
699 set_bit(AGP_FF_IS_CLIENT, &priv->access_flags);
700 set_bit(AGP_FF_IS_VALID, &priv->access_flags);
702 file->private_data = (void *) priv;
703 agp_insert_file_private(priv);
704 DBG("private=%p, client=%p", priv, client);
706 mutex_unlock(&(agp_fe.agp_mutex));
711 static int agpioc_info_wrap(struct agp_file_private *priv, void __user *arg)
713 struct agp_info userinfo;
714 struct agp_kern_info kerninfo;
716 agp_copy_info(agp_bridge, &kerninfo);
718 memset(&userinfo, 0, sizeof(userinfo));
719 userinfo.version.major = kerninfo.version.major;
720 userinfo.version.minor = kerninfo.version.minor;
721 userinfo.bridge_id = kerninfo.device->vendor |
722 (kerninfo.device->device << 16);
723 userinfo.agp_mode = kerninfo.mode;
724 userinfo.aper_base = kerninfo.aper_base;
725 userinfo.aper_size = kerninfo.aper_size;
726 userinfo.pg_total = userinfo.pg_system = kerninfo.max_memory;
727 userinfo.pg_used = kerninfo.current_memory;
729 if (copy_to_user(arg, &userinfo, sizeof(struct agp_info)))
735 int agpioc_acquire_wrap(struct agp_file_private *priv)
737 struct agp_controller *controller;
741 if (!(test_bit(AGP_FF_ALLOW_CONTROLLER, &priv->access_flags)))
744 if (agp_fe.current_controller != NULL)
750 if (atomic_read(&agp_bridge->agp_in_use))
753 atomic_inc(&agp_bridge->agp_in_use);
755 agp_fe.backend_acquired = true;
757 controller = agp_find_controller_by_pid(priv->my_pid);
759 if (controller != NULL) {
760 agp_controller_make_current(controller);
762 controller = agp_create_controller(priv->my_pid);
764 if (controller == NULL) {
765 agp_fe.backend_acquired = false;
766 agp_backend_release(agp_bridge);
769 agp_insert_controller(controller);
770 agp_controller_make_current(controller);
773 set_bit(AGP_FF_IS_CONTROLLER, &priv->access_flags);
774 set_bit(AGP_FF_IS_VALID, &priv->access_flags);
778 int agpioc_release_wrap(struct agp_file_private *priv)
781 agp_controller_release_current(agp_fe.current_controller, priv);
785 int agpioc_setup_wrap(struct agp_file_private *priv, void __user *arg)
787 struct agp_setup mode;
790 if (copy_from_user(&mode, arg, sizeof(struct agp_setup)))
793 agp_enable(agp_bridge, mode.agp_mode);
797 static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
799 struct agp_region reserve;
800 struct agp_client *client;
801 struct agp_file_private *client_priv;
804 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
807 if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
810 client = agp_find_client_by_pid(reserve.pid);
812 if (reserve.seg_count == 0) {
813 /* remove a client */
814 client_priv = agp_find_private(reserve.pid);
816 if (client_priv != NULL) {
817 set_bit(AGP_FF_IS_CLIENT, &client_priv->access_flags);
818 set_bit(AGP_FF_IS_VALID, &client_priv->access_flags);
820 if (client == NULL) {
821 /* client is already removed */
824 return agp_remove_client(reserve.pid);
826 struct agp_segment *segment;
828 if (reserve.seg_count >= 16384)
831 segment = kmalloc((sizeof(struct agp_segment) * reserve.seg_count),
837 if (copy_from_user(segment, (void __user *) reserve.seg_list,
838 sizeof(struct agp_segment) * reserve.seg_count)) {
842 reserve.seg_list = segment;
844 if (client == NULL) {
845 /* Create the client and add the segment */
846 client = agp_create_client(reserve.pid);
848 if (client == NULL) {
852 client_priv = agp_find_private(reserve.pid);
854 if (client_priv != NULL) {
855 set_bit(AGP_FF_IS_CLIENT, &client_priv->access_flags);
856 set_bit(AGP_FF_IS_VALID, &client_priv->access_flags);
859 return agp_create_segment(client, &reserve);
861 /* Will never really happen */
865 int agpioc_protect_wrap(struct agp_file_private *priv)
868 /* This function is not currently implemented */
872 static int agpioc_allocate_wrap(struct agp_file_private *priv, void __user *arg)
874 struct agp_memory *memory;
875 struct agp_allocate alloc;
878 if (copy_from_user(&alloc, arg, sizeof(struct agp_allocate)))
881 if (alloc.type >= AGP_USER_TYPES)
884 memory = agp_allocate_memory_wrap(alloc.pg_count, alloc.type);
889 alloc.key = memory->key;
890 alloc.physical = memory->physical;
892 if (copy_to_user(arg, &alloc, sizeof(struct agp_allocate))) {
893 agp_free_memory_wrap(memory);
899 int agpioc_deallocate_wrap(struct agp_file_private *priv, int arg)
901 struct agp_memory *memory;
904 memory = agp_find_mem_by_key(arg);
909 agp_free_memory_wrap(memory);
913 static int agpioc_bind_wrap(struct agp_file_private *priv, void __user *arg)
915 struct agp_bind bind_info;
916 struct agp_memory *memory;
919 if (copy_from_user(&bind_info, arg, sizeof(struct agp_bind)))
922 memory = agp_find_mem_by_key(bind_info.key);
927 return agp_bind_memory(memory, bind_info.pg_start);
930 static int agpioc_unbind_wrap(struct agp_file_private *priv, void __user *arg)
932 struct agp_memory *memory;
933 struct agp_unbind unbind;
936 if (copy_from_user(&unbind, arg, sizeof(struct agp_unbind)))
939 memory = agp_find_mem_by_key(unbind.key);
944 return agp_unbind_memory(memory);
947 static long agp_ioctl(struct file *file,
948 unsigned int cmd, unsigned long arg)
950 struct agp_file_private *curr_priv = file->private_data;
951 int ret_val = -ENOTTY;
953 DBG("priv=%p, cmd=%x", curr_priv, cmd);
954 mutex_lock(&(agp_fe.agp_mutex));
956 if ((agp_fe.current_controller == NULL) &&
957 (cmd != AGPIOC_ACQUIRE)) {
961 if ((agp_fe.backend_acquired != true) &&
962 (cmd != AGPIOC_ACQUIRE)) {
966 if (cmd != AGPIOC_ACQUIRE) {
967 if (!(test_bit(AGP_FF_IS_CONTROLLER, &curr_priv->access_flags))) {
971 /* Use the original pid of the controller,
972 * in case it's threaded */
974 if (agp_fe.current_controller->pid != curr_priv->my_pid) {
982 ret_val = agpioc_info_wrap(curr_priv, (void __user *) arg);
986 ret_val = agpioc_acquire_wrap(curr_priv);
990 ret_val = agpioc_release_wrap(curr_priv);
994 ret_val = agpioc_setup_wrap(curr_priv, (void __user *) arg);
998 ret_val = agpioc_reserve_wrap(curr_priv, (void __user *) arg);
1001 case AGPIOC_PROTECT:
1002 ret_val = agpioc_protect_wrap(curr_priv);
1005 case AGPIOC_ALLOCATE:
1006 ret_val = agpioc_allocate_wrap(curr_priv, (void __user *) arg);
1009 case AGPIOC_DEALLOCATE:
1010 ret_val = agpioc_deallocate_wrap(curr_priv, (int) arg);
1014 ret_val = agpioc_bind_wrap(curr_priv, (void __user *) arg);
1018 ret_val = agpioc_unbind_wrap(curr_priv, (void __user *) arg);
1021 case AGPIOC_CHIPSET_FLUSH:
1026 DBG("ioctl returns %d\n", ret_val);
1027 mutex_unlock(&(agp_fe.agp_mutex));
1031 static const struct file_operations agp_fops =
1033 .owner = THIS_MODULE,
1034 .llseek = no_llseek,
1035 .unlocked_ioctl = agp_ioctl,
1036 #ifdef CONFIG_COMPAT
1037 .compat_ioctl = compat_agp_ioctl,
1041 .release = agp_release,
1044 static struct miscdevice agp_miscdev =
1046 .minor = AGPGART_MINOR,
1051 int agp_frontend_initialize(void)
1053 memset(&agp_fe, 0, sizeof(struct agp_front_data));
1054 mutex_init(&(agp_fe.agp_mutex));
1056 if (misc_register(&agp_miscdev)) {
1057 printk(KERN_ERR PFX "unable to get minor: %d\n", AGPGART_MINOR);
1063 void agp_frontend_cleanup(void)
1065 misc_deregister(&agp_miscdev);