2 * AGPGART driver frontend
3 * Copyright (C) 2002-2003 Dave Jones
4 * Copyright (C) 1999 Jeff Hartmann
5 * Copyright (C) 1999 Precision Insight, Inc.
6 * Copyright (C) 1999 Xi Graphics, Inc.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
22 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
24 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 #include <linux/types.h>
29 #include <linux/kernel.h>
30 #include <linux/module.h>
31 #include <linux/mman.h>
32 #include <linux/pci.h>
33 #include <linux/init.h>
34 #include <linux/miscdevice.h>
35 #include <linux/agp_backend.h>
36 #include <linux/agpgart.h>
37 #include <linux/slab.h>
39 #include <asm/uaccess.h>
40 #include <asm/pgtable.h>
43 static struct agp_front_data agp_fe;
45 static struct agp_memory *agp_find_mem_by_key(int key)
47 struct agp_memory *curr;
49 if (agp_fe.current_controller == NULL)
52 curr = agp_fe.current_controller->pool;
54 while (curr != NULL) {
60 DBG("key=%d -> mem=%p", key, curr);
64 static void agp_remove_from_pool(struct agp_memory *temp)
66 struct agp_memory *prev;
67 struct agp_memory *next;
69 /* Check to see if this is even in the memory pool */
72 if (agp_find_mem_by_key(temp->key) != NULL) {
82 /* This is the first item on the list */
86 agp_fe.current_controller->pool = next;
92 * Routines for managing each client's segment list -
93 * These routines handle adding and removing segments
94 * to each auth'ed client.
98 agp_segment_priv *agp_find_seg_in_client(const struct agp_client *client,
100 int size, pgprot_t page_prot)
102 struct agp_segment_priv *seg;
107 pg_start = offset / 4096;
108 pg_count = size / 4096;
109 seg = *(client->segments);
110 num_segments = client->num_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 /* Originally taken from linux/mm/mmap.c from the array
155 * The original really should be exported to modules, or
156 * some routine which does the conversion for you
159 static const pgprot_t my_protect_map[16] =
161 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
162 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
165 static pgprot_t agp_convert_mmap_flags(int prot)
167 #define _trans(x,bit1,bit2) \
168 ((bit1==bit2)?(x&bit1):(x&bit1)?bit2:0)
170 unsigned long prot_bits;
173 prot_bits = _trans(prot, PROT_READ, VM_READ) |
174 _trans(prot, PROT_WRITE, VM_WRITE) |
175 _trans(prot, PROT_EXEC, VM_EXEC);
177 prot_bits |= VM_SHARED;
179 temp = my_protect_map[prot_bits & 0x0000000f];
184 static int agp_create_segment(struct agp_client *client, struct agp_region *region)
186 struct agp_segment_priv **ret_seg;
187 struct agp_segment_priv *seg;
188 struct agp_segment *user_seg;
191 seg = kmalloc((sizeof(struct agp_segment_priv) * region->seg_count), GFP_KERNEL);
193 kfree(region->seg_list);
194 region->seg_list = NULL;
197 memset(seg, 0, (sizeof(struct agp_segment_priv) * region->seg_count));
198 user_seg = region->seg_list;
200 for (i = 0; i < region->seg_count; i++) {
201 seg[i].pg_start = user_seg[i].pg_start;
202 seg[i].pg_count = user_seg[i].pg_count;
203 seg[i].prot = agp_convert_mmap_flags(user_seg[i].prot);
205 kfree(region->seg_list);
206 region->seg_list = NULL;
208 ret_seg = kmalloc(sizeof(void *), GFP_KERNEL);
209 if (ret_seg == NULL) {
214 agp_add_seg_to_client(client, ret_seg, region->seg_count);
218 /* End - Routines for managing each client's segment list */
220 /* This function must only be called when current_controller != NULL */
221 static void agp_insert_into_pool(struct agp_memory * temp)
223 struct agp_memory *prev;
225 prev = agp_fe.current_controller->pool;
231 agp_fe.current_controller->pool = temp;
235 /* File private list routines */
237 struct agp_file_private *agp_find_private(pid_t pid)
239 struct agp_file_private *curr;
241 curr = agp_fe.file_priv_list;
243 while (curr != NULL) {
244 if (curr->my_pid == pid)
252 void agp_insert_file_private(struct agp_file_private * priv)
254 struct agp_file_private *prev;
256 prev = agp_fe.file_priv_list;
261 agp_fe.file_priv_list = priv;
264 void agp_remove_file_private(struct agp_file_private * priv)
266 struct agp_file_private *next;
267 struct agp_file_private *prev;
282 agp_fe.file_priv_list = next;
286 /* End - File flag list routines */
289 * Wrappers for agp_free_memory & agp_allocate_memory
290 * These make sure that internal lists are kept updated.
292 static void agp_free_memory_wrap(struct agp_memory *memory)
294 agp_remove_from_pool(memory);
295 agp_free_memory(memory);
298 static struct agp_memory *agp_allocate_memory_wrap(size_t pg_count, u32 type)
300 struct agp_memory *memory;
302 memory = agp_allocate_memory(pg_count, type);
306 agp_insert_into_pool(memory);
310 /* Routines for managing the list of controllers -
311 * These routines manage the current controller, and the list of
315 static struct agp_controller *agp_find_controller_by_pid(pid_t id)
317 struct agp_controller *controller;
319 controller = agp_fe.controllers;
321 while (controller != NULL) {
322 if (controller->pid == id)
324 controller = controller->next;
330 static struct agp_controller *agp_create_controller(pid_t id)
332 struct agp_controller *controller;
334 controller = kmalloc(sizeof(struct agp_controller), GFP_KERNEL);
336 if (controller == NULL)
339 memset(controller, 0, sizeof(struct agp_controller));
340 controller->pid = id;
345 static int agp_insert_controller(struct agp_controller *controller)
347 struct agp_controller *prev_controller;
349 prev_controller = agp_fe.controllers;
350 controller->next = prev_controller;
352 if (prev_controller != NULL)
353 prev_controller->prev = controller;
355 agp_fe.controllers = controller;
360 static void agp_remove_all_clients(struct agp_controller *controller)
362 struct agp_client *client;
363 struct agp_client *temp;
365 client = controller->clients;
368 struct agp_file_private *priv;
371 agp_remove_seg_from_client(temp);
372 priv = agp_find_private(temp->pid);
375 clear_bit(AGP_FF_IS_VALID, &priv->access_flags);
376 clear_bit(AGP_FF_IS_CLIENT, &priv->access_flags);
378 client = client->next;
383 static void agp_remove_all_memory(struct agp_controller *controller)
385 struct agp_memory *memory;
386 struct agp_memory *temp;
388 memory = controller->pool;
392 memory = memory->next;
393 agp_free_memory_wrap(temp);
397 static int agp_remove_controller(struct agp_controller *controller)
399 struct agp_controller *prev_controller;
400 struct agp_controller *next_controller;
402 prev_controller = controller->prev;
403 next_controller = controller->next;
405 if (prev_controller != NULL) {
406 prev_controller->next = next_controller;
407 if (next_controller != NULL)
408 next_controller->prev = prev_controller;
411 if (next_controller != NULL)
412 next_controller->prev = NULL;
414 agp_fe.controllers = next_controller;
417 agp_remove_all_memory(controller);
418 agp_remove_all_clients(controller);
420 if (agp_fe.current_controller == controller) {
421 agp_fe.current_controller = NULL;
422 agp_fe.backend_acquired = FALSE;
423 agp_backend_release();
429 static void agp_controller_make_current(struct agp_controller *controller)
431 struct agp_client *clients;
433 clients = controller->clients;
435 while (clients != NULL) {
436 struct agp_file_private *priv;
438 priv = agp_find_private(clients->pid);
441 set_bit(AGP_FF_IS_VALID, &priv->access_flags);
442 set_bit(AGP_FF_IS_CLIENT, &priv->access_flags);
444 clients = clients->next;
447 agp_fe.current_controller = controller;
450 static void agp_controller_release_current(struct agp_controller *controller,
451 struct agp_file_private *controller_priv)
453 struct agp_client *clients;
455 clear_bit(AGP_FF_IS_VALID, &controller_priv->access_flags);
456 clients = controller->clients;
458 while (clients != NULL) {
459 struct agp_file_private *priv;
461 priv = agp_find_private(clients->pid);
464 clear_bit(AGP_FF_IS_VALID, &priv->access_flags);
466 clients = clients->next;
469 agp_fe.current_controller = NULL;
470 agp_fe.used_by_controller = FALSE;
471 agp_backend_release();
475 * Routines for managing client lists -
476 * These routines are for managing the list of auth'ed clients.
479 static struct agp_client
480 *agp_find_client_in_controller(struct agp_controller *controller, pid_t id)
482 struct agp_client *client;
484 if (controller == NULL)
487 client = controller->clients;
489 while (client != NULL) {
490 if (client->pid == id)
492 client = client->next;
498 static struct agp_controller *agp_find_controller_for_client(pid_t id)
500 struct agp_controller *controller;
502 controller = agp_fe.controllers;
504 while (controller != NULL) {
505 if ((agp_find_client_in_controller(controller, id)) != NULL)
507 controller = controller->next;
513 static struct agp_client *agp_find_client_by_pid(pid_t id)
515 struct agp_client *temp;
517 if (agp_fe.current_controller == NULL)
520 temp = agp_find_client_in_controller(agp_fe.current_controller, id);
524 static void agp_insert_client(struct agp_client *client)
526 struct agp_client *prev_client;
528 prev_client = agp_fe.current_controller->clients;
529 client->next = prev_client;
531 if (prev_client != NULL)
532 prev_client->prev = client;
534 agp_fe.current_controller->clients = client;
535 agp_fe.current_controller->num_clients++;
538 static struct agp_client *agp_create_client(pid_t id)
540 struct agp_client *new_client;
542 new_client = kmalloc(sizeof(struct agp_client), GFP_KERNEL);
544 if (new_client == NULL)
547 memset(new_client, 0, sizeof(struct agp_client));
548 new_client->pid = id;
549 agp_insert_client(new_client);
553 static int agp_remove_client(pid_t id)
555 struct agp_client *client;
556 struct agp_client *prev_client;
557 struct agp_client *next_client;
558 struct agp_controller *controller;
560 controller = agp_find_controller_for_client(id);
561 if (controller == NULL)
564 client = agp_find_client_in_controller(controller, id);
568 prev_client = client->prev;
569 next_client = client->next;
571 if (prev_client != NULL) {
572 prev_client->next = next_client;
573 if (next_client != NULL)
574 next_client->prev = prev_client;
577 if (next_client != NULL)
578 next_client->prev = NULL;
579 controller->clients = next_client;
582 controller->num_clients--;
583 agp_remove_seg_from_client(client);
588 /* End - Routines for managing client lists */
590 /* File Operations */
592 static int agp_mmap(struct file *file, struct vm_area_struct *vma)
594 unsigned int size, current_size;
595 unsigned long offset;
596 struct agp_client *client;
597 struct agp_file_private *priv = file->private_data;
598 struct agp_kern_info kerninfo;
600 down(&(agp_fe.agp_mutex));
602 if (agp_fe.backend_acquired != TRUE)
605 if (!(test_bit(AGP_FF_IS_VALID, &priv->access_flags)))
608 agp_copy_info(&kerninfo);
609 size = vma->vm_end - vma->vm_start;
610 current_size = kerninfo.aper_size;
611 current_size = current_size * 0x100000;
612 offset = vma->vm_pgoff << PAGE_SHIFT;
613 DBG("%lx:%lx", offset, offset+size);
615 if (test_bit(AGP_FF_IS_CLIENT, &priv->access_flags)) {
616 if ((size + offset) > current_size)
619 client = agp_find_client_by_pid(current->pid);
624 if (!agp_find_seg_in_client(client, offset, size, vma->vm_page_prot))
627 DBG("client vm_ops=%p", kerninfo.vm_ops);
628 if (kerninfo.vm_ops) {
629 vma->vm_ops = kerninfo.vm_ops;
630 } else if (remap_pfn_range(vma, vma->vm_start,
631 (kerninfo.aper_base + offset) >> PAGE_SHIFT,
632 size, vma->vm_page_prot)) {
635 up(&(agp_fe.agp_mutex));
639 if (test_bit(AGP_FF_IS_CONTROLLER, &priv->access_flags)) {
640 if (size != current_size)
643 DBG("controller vm_ops=%p", kerninfo.vm_ops);
644 if (kerninfo.vm_ops) {
645 vma->vm_ops = kerninfo.vm_ops;
646 } else if (remap_pfn_range(vma, vma->vm_start,
647 kerninfo.aper_base >> PAGE_SHIFT,
648 size, vma->vm_page_prot)) {
651 up(&(agp_fe.agp_mutex));
656 up(&(agp_fe.agp_mutex));
660 up(&(agp_fe.agp_mutex));
664 up(&(agp_fe.agp_mutex));
668 static int agp_release(struct inode *inode, struct file *file)
670 struct agp_file_private *priv = file->private_data;
672 down(&(agp_fe.agp_mutex));
674 DBG("priv=%p", priv);
676 if (test_bit(AGP_FF_IS_CONTROLLER, &priv->access_flags)) {
677 struct agp_controller *controller;
679 controller = agp_find_controller_by_pid(priv->my_pid);
681 if (controller != NULL) {
682 if (controller == agp_fe.current_controller)
683 agp_controller_release_current(controller, priv);
684 agp_remove_controller(controller);
689 if (test_bit(AGP_FF_IS_CLIENT, &priv->access_flags))
690 agp_remove_client(priv->my_pid);
692 agp_remove_file_private(priv);
694 file->private_data = NULL;
695 up(&(agp_fe.agp_mutex));
699 static int agp_open(struct inode *inode, struct file *file)
701 int minor = iminor(inode);
702 struct agp_file_private *priv;
703 struct agp_client *client;
706 down(&(agp_fe.agp_mutex));
708 if (minor != AGPGART_MINOR)
711 priv = kmalloc(sizeof(struct agp_file_private), GFP_KERNEL);
715 memset(priv, 0, sizeof(struct agp_file_private));
716 set_bit(AGP_FF_ALLOW_CLIENT, &priv->access_flags);
717 priv->my_pid = current->pid;
719 if ((current->uid == 0) || (current->suid == 0)) {
720 /* Root priv, can be controller */
721 set_bit(AGP_FF_ALLOW_CONTROLLER, &priv->access_flags);
723 client = agp_find_client_by_pid(current->pid);
725 if (client != NULL) {
726 set_bit(AGP_FF_IS_CLIENT, &priv->access_flags);
727 set_bit(AGP_FF_IS_VALID, &priv->access_flags);
729 file->private_data = (void *) priv;
730 agp_insert_file_private(priv);
731 DBG("private=%p, client=%p", priv, client);
732 up(&(agp_fe.agp_mutex));
738 up(&(agp_fe.agp_mutex));
743 static ssize_t agp_read(struct file *file, char __user *buf,
744 size_t count, loff_t * ppos)
749 static ssize_t agp_write(struct file *file, const char __user *buf,
750 size_t count, loff_t * ppos)
755 static int agpioc_info_wrap(struct agp_file_private *priv, void __user *arg)
757 struct agp_info userinfo;
758 struct agp_kern_info kerninfo;
760 agp_copy_info(&kerninfo);
762 userinfo.version.major = kerninfo.version.major;
763 userinfo.version.minor = kerninfo.version.minor;
764 userinfo.bridge_id = kerninfo.device->vendor |
765 (kerninfo.device->device << 16);
766 userinfo.agp_mode = kerninfo.mode;
767 userinfo.aper_base = kerninfo.aper_base;
768 userinfo.aper_size = kerninfo.aper_size;
769 userinfo.pg_total = userinfo.pg_system = kerninfo.max_memory;
770 userinfo.pg_used = kerninfo.current_memory;
772 if (copy_to_user(arg, &userinfo, sizeof(struct agp_info)))
778 static int agpioc_acquire_wrap(struct agp_file_private *priv)
781 struct agp_controller *controller;
785 if (!(test_bit(AGP_FF_ALLOW_CONTROLLER, &priv->access_flags)))
788 if (agp_fe.current_controller != NULL)
791 ret = agp_backend_acquire();
793 agp_fe.backend_acquired = TRUE;
797 controller = agp_find_controller_by_pid(priv->my_pid);
799 if (controller != NULL) {
800 agp_controller_make_current(controller);
802 controller = agp_create_controller(priv->my_pid);
804 if (controller == NULL) {
805 agp_fe.backend_acquired = FALSE;
806 agp_backend_release();
809 agp_insert_controller(controller);
810 agp_controller_make_current(controller);
813 set_bit(AGP_FF_IS_CONTROLLER, &priv->access_flags);
814 set_bit(AGP_FF_IS_VALID, &priv->access_flags);
818 static int agpioc_release_wrap(struct agp_file_private *priv)
821 agp_controller_release_current(agp_fe.current_controller, priv);
825 static int agpioc_setup_wrap(struct agp_file_private *priv, void __user *arg)
827 struct agp_setup mode;
830 if (copy_from_user(&mode, arg, sizeof(struct agp_setup)))
833 agp_enable(mode.agp_mode);
837 static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
839 struct agp_region reserve;
840 struct agp_client *client;
841 struct agp_file_private *client_priv;
844 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
847 if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
850 client = agp_find_client_by_pid(reserve.pid);
852 if (reserve.seg_count == 0) {
853 /* remove a client */
854 client_priv = agp_find_private(reserve.pid);
856 if (client_priv != NULL) {
857 set_bit(AGP_FF_IS_CLIENT, &client_priv->access_flags);
858 set_bit(AGP_FF_IS_VALID, &client_priv->access_flags);
860 if (client == NULL) {
861 /* client is already removed */
864 return agp_remove_client(reserve.pid);
866 struct agp_segment *segment;
868 if (reserve.seg_count >= 16384)
871 segment = kmalloc((sizeof(struct agp_segment) * reserve.seg_count),
877 if (copy_from_user(segment, (void __user *) reserve.seg_list,
878 sizeof(struct agp_segment) * reserve.seg_count)) {
882 reserve.seg_list = segment;
884 if (client == NULL) {
885 /* Create the client and add the segment */
886 client = agp_create_client(reserve.pid);
888 if (client == NULL) {
892 client_priv = agp_find_private(reserve.pid);
894 if (client_priv != NULL) {
895 set_bit(AGP_FF_IS_CLIENT, &client_priv->access_flags);
896 set_bit(AGP_FF_IS_VALID, &client_priv->access_flags);
899 return agp_create_segment(client, &reserve);
901 /* Will never really happen */
905 static int agpioc_protect_wrap(struct agp_file_private *priv)
908 /* This function is not currently implemented */
912 static int agpioc_allocate_wrap(struct agp_file_private *priv, void __user *arg)
914 struct agp_memory *memory;
915 struct agp_allocate alloc;
918 if (copy_from_user(&alloc, arg, sizeof(struct agp_allocate)))
921 memory = agp_allocate_memory_wrap(alloc.pg_count, alloc.type);
926 alloc.key = memory->key;
927 alloc.physical = memory->physical;
929 if (copy_to_user(arg, &alloc, sizeof(struct agp_allocate))) {
930 agp_free_memory_wrap(memory);
936 static int agpioc_deallocate_wrap(struct agp_file_private *priv, int arg)
938 struct agp_memory *memory;
941 memory = agp_find_mem_by_key(arg);
946 agp_free_memory_wrap(memory);
950 static int agpioc_bind_wrap(struct agp_file_private *priv, void __user *arg)
952 struct agp_bind bind_info;
953 struct agp_memory *memory;
956 if (copy_from_user(&bind_info, arg, sizeof(struct agp_bind)))
959 memory = agp_find_mem_by_key(bind_info.key);
964 return agp_bind_memory(memory, bind_info.pg_start);
967 static int agpioc_unbind_wrap(struct agp_file_private *priv, void __user *arg)
969 struct agp_memory *memory;
970 struct agp_unbind unbind;
973 if (copy_from_user(&unbind, arg, sizeof(struct agp_unbind)))
976 memory = agp_find_mem_by_key(unbind.key);
981 return agp_unbind_memory(memory);
984 static int agp_ioctl(struct inode *inode, struct file *file,
985 unsigned int cmd, unsigned long arg)
987 struct agp_file_private *curr_priv = file->private_data;
988 int ret_val = -ENOTTY;
990 DBG("priv=%p, cmd=%x", curr_priv, cmd);
991 down(&(agp_fe.agp_mutex));
993 if ((agp_fe.current_controller == NULL) &&
994 (cmd != AGPIOC_ACQUIRE)) {
998 if ((agp_fe.backend_acquired != TRUE) &&
999 (cmd != AGPIOC_ACQUIRE)) {
1003 if (cmd != AGPIOC_ACQUIRE) {
1004 if (!(test_bit(AGP_FF_IS_CONTROLLER, &curr_priv->access_flags))) {
1008 /* Use the original pid of the controller,
1009 * in case it's threaded */
1011 if (agp_fe.current_controller->pid != curr_priv->my_pid) {
1019 ret_val = agpioc_info_wrap(curr_priv, (void __user *) arg);
1022 case AGPIOC_ACQUIRE:
1023 ret_val = agpioc_acquire_wrap(curr_priv);
1026 case AGPIOC_RELEASE:
1027 ret_val = agpioc_release_wrap(curr_priv);
1031 ret_val = agpioc_setup_wrap(curr_priv, (void __user *) arg);
1034 case AGPIOC_RESERVE:
1035 ret_val = agpioc_reserve_wrap(curr_priv, (void __user *) arg);
1038 case AGPIOC_PROTECT:
1039 ret_val = agpioc_protect_wrap(curr_priv);
1042 case AGPIOC_ALLOCATE:
1043 ret_val = agpioc_allocate_wrap(curr_priv, (void __user *) arg);
1046 case AGPIOC_DEALLOCATE:
1047 ret_val = agpioc_deallocate_wrap(curr_priv, (int) arg);
1051 ret_val = agpioc_bind_wrap(curr_priv, (void __user *) arg);
1055 ret_val = agpioc_unbind_wrap(curr_priv, (void __user *) arg);
1060 DBG("ioctl returns %d\n", ret_val);
1061 up(&(agp_fe.agp_mutex));
1065 static struct file_operations agp_fops =
1067 .owner = THIS_MODULE,
1068 .llseek = no_llseek,
1074 .release = agp_release,
1077 static struct miscdevice agp_miscdev =
1079 .minor = AGPGART_MINOR,
1084 int agp_frontend_initialize(void)
1086 memset(&agp_fe, 0, sizeof(struct agp_front_data));
1087 sema_init(&(agp_fe.agp_mutex), 1);
1089 if (misc_register(&agp_miscdev)) {
1090 printk(KERN_ERR PFX "unable to get minor: %d\n", AGPGART_MINOR);
1096 void agp_frontend_cleanup(void)
1098 misc_deregister(&agp_miscdev);