Lines Matching +full:memory +full:- +full:controllers
4 * Copyright (C) 2002-2003 Dave Jones
55 curr = agp_fe.current_controller->pool; in agp_find_mem_by_key()
58 if (curr->key == key) in agp_find_mem_by_key()
60 curr = curr->next; in agp_find_mem_by_key()
63 DBG("key=%d -> mem=%p", key, curr); in agp_find_mem_by_key()
72 /* Check to see if this is even in the memory pool */ in agp_remove_from_pool()
75 if (agp_find_mem_by_key(temp->key) != NULL) { in agp_remove_from_pool()
76 next = temp->next; in agp_remove_from_pool()
77 prev = temp->prev; in agp_remove_from_pool()
80 prev->next = next; in agp_remove_from_pool()
82 next->prev = prev; in agp_remove_from_pool()
87 next->prev = NULL; in agp_remove_from_pool()
89 agp_fe.current_controller->pool = next; in agp_remove_from_pool()
95 * Routines for managing each client's segment list -
112 seg = *(client->segments); in agp_find_seg_in_client()
114 for (i = 0; i < client->num_segments; i++) { in agp_find_seg_in_client()
129 if (client->segments != NULL) { in agp_remove_seg_from_client()
130 if (*(client->segments) != NULL) { in agp_remove_seg_from_client()
131 DBG("Freeing %p from client %p", *(client->segments), client); in agp_remove_seg_from_client()
132 kfree(*(client->segments)); in agp_remove_seg_from_client()
134 DBG("Freeing %p from client %p", client->segments, client); in agp_remove_seg_from_client()
135 kfree(client->segments); in agp_remove_seg_from_client()
136 client->segments = NULL; in agp_remove_seg_from_client()
145 prev_seg = client->segments; in agp_add_seg_to_client()
151 client->num_segments = num_segments; in agp_add_seg_to_client()
152 client->segments = seg; in agp_add_seg_to_client()
170 seg = kzalloc((sizeof(struct agp_segment_priv) * region->seg_count), GFP_KERNEL); in agp_create_segment()
172 kfree(region->seg_list); in agp_create_segment()
173 region->seg_list = NULL; in agp_create_segment()
174 return -ENOMEM; in agp_create_segment()
176 user_seg = region->seg_list; in agp_create_segment()
178 for (i = 0; i < region->seg_count; i++) { in agp_create_segment()
183 kfree(region->seg_list); in agp_create_segment()
184 region->seg_list = NULL; in agp_create_segment()
189 return -ENOMEM; in agp_create_segment()
192 agp_add_seg_to_client(client, ret_seg, region->seg_count); in agp_create_segment()
196 /* End - Routines for managing each client's segment list */
203 prev = agp_fe.current_controller->pool; in agp_insert_into_pool()
206 prev->prev = temp; in agp_insert_into_pool()
207 temp->next = prev; in agp_insert_into_pool()
209 agp_fe.current_controller->pool = temp; in agp_insert_into_pool()
222 if (curr->my_pid == pid) in agp_find_private()
224 curr = curr->next; in agp_find_private()
237 prev->prev = priv; in agp_insert_file_private()
238 priv->next = prev; in agp_insert_file_private()
247 next = priv->next; in agp_remove_file_private()
248 prev = priv->prev; in agp_remove_file_private()
251 prev->next = next; in agp_remove_file_private()
254 next->prev = prev; in agp_remove_file_private()
258 next->prev = NULL; in agp_remove_file_private()
264 /* End - File flag list routines */
270 void agp_free_memory_wrap(struct agp_memory *memory) in agp_free_memory_wrap() argument
272 agp_remove_from_pool(memory); in agp_free_memory_wrap()
273 agp_free_memory(memory); in agp_free_memory_wrap()
278 struct agp_memory *memory; in agp_allocate_memory_wrap() local
280 memory = agp_allocate_memory(agp_bridge, pg_count, type); in agp_allocate_memory_wrap()
281 if (memory == NULL) in agp_allocate_memory_wrap()
284 agp_insert_into_pool(memory); in agp_allocate_memory_wrap()
285 return memory; in agp_allocate_memory_wrap()
288 /* Routines for managing the list of controllers -
290 * controllers
297 controller = agp_fe.controllers; in agp_find_controller_by_pid()
300 if (controller->pid == id) in agp_find_controller_by_pid()
302 controller = controller->next; in agp_find_controller_by_pid()
316 controller->pid = id; in agp_create_controller()
324 prev_controller = agp_fe.controllers; in agp_insert_controller()
325 controller->next = prev_controller; in agp_insert_controller()
328 prev_controller->prev = controller; in agp_insert_controller()
330 agp_fe.controllers = controller; in agp_insert_controller()
340 client = controller->clients; in agp_remove_all_clients()
347 priv = agp_find_private(temp->pid); in agp_remove_all_clients()
350 clear_bit(AGP_FF_IS_VALID, &priv->access_flags); in agp_remove_all_clients()
351 clear_bit(AGP_FF_IS_CLIENT, &priv->access_flags); in agp_remove_all_clients()
353 client = client->next; in agp_remove_all_clients()
360 struct agp_memory *memory; in agp_remove_all_memory() local
363 memory = controller->pool; in agp_remove_all_memory()
365 while (memory) { in agp_remove_all_memory()
366 temp = memory; in agp_remove_all_memory()
367 memory = memory->next; in agp_remove_all_memory()
377 prev_controller = controller->prev; in agp_remove_controller()
378 next_controller = controller->next; in agp_remove_controller()
381 prev_controller->next = next_controller; in agp_remove_controller()
383 next_controller->prev = prev_controller; in agp_remove_controller()
387 next_controller->prev = NULL; in agp_remove_controller()
389 agp_fe.controllers = next_controller; in agp_remove_controller()
408 clients = controller->clients; in agp_controller_make_current()
413 priv = agp_find_private(clients->pid); in agp_controller_make_current()
416 set_bit(AGP_FF_IS_VALID, &priv->access_flags); in agp_controller_make_current()
417 set_bit(AGP_FF_IS_CLIENT, &priv->access_flags); in agp_controller_make_current()
419 clients = clients->next; in agp_controller_make_current()
430 clear_bit(AGP_FF_IS_VALID, &controller_priv->access_flags); in agp_controller_release_current()
431 clients = controller->clients; in agp_controller_release_current()
436 priv = agp_find_private(clients->pid); in agp_controller_release_current()
439 clear_bit(AGP_FF_IS_VALID, &priv->access_flags); in agp_controller_release_current()
441 clients = clients->next; in agp_controller_release_current()
450 * Routines for managing client lists -
462 client = controller->clients; in agp_find_client_in_controller()
465 if (client->pid == id) in agp_find_client_in_controller()
467 client = client->next; in agp_find_client_in_controller()
477 controller = agp_fe.controllers; in agp_find_controller_for_client()
482 controller = controller->next; in agp_find_controller_for_client()
503 prev_client = agp_fe.current_controller->clients; in agp_insert_client()
504 client->next = prev_client; in agp_insert_client()
507 prev_client->prev = client; in agp_insert_client()
509 agp_fe.current_controller->clients = client; in agp_insert_client()
510 agp_fe.current_controller->num_clients++; in agp_insert_client()
521 new_client->pid = id; in agp_create_client()
535 return -EINVAL; in agp_remove_client()
539 return -EINVAL; in agp_remove_client()
541 prev_client = client->prev; in agp_remove_client()
542 next_client = client->next; in agp_remove_client()
545 prev_client->next = next_client; in agp_remove_client()
547 next_client->prev = prev_client; in agp_remove_client()
551 next_client->prev = NULL; in agp_remove_client()
552 controller->clients = next_client; in agp_remove_client()
555 controller->num_clients--; in agp_remove_client()
561 /* End - Routines for managing client lists */
570 struct agp_file_private *priv = file->private_data; in agp_mmap()
578 if (!(test_bit(AGP_FF_IS_VALID, &priv->access_flags))) in agp_mmap()
582 size = vma->vm_end - vma->vm_start; in agp_mmap()
585 offset = vma->vm_pgoff << PAGE_SHIFT; in agp_mmap()
588 if (test_bit(AGP_FF_IS_CLIENT, &priv->access_flags)) { in agp_mmap()
592 client = agp_find_client_by_pid(current->pid); in agp_mmap()
597 if (!agp_find_seg_in_client(client, offset, size, vma->vm_page_prot)) in agp_mmap()
602 vma->vm_ops = kerninfo.vm_ops; in agp_mmap()
603 } else if (io_remap_pfn_range(vma, vma->vm_start, in agp_mmap()
606 pgprot_writecombine(vma->vm_page_prot))) { in agp_mmap()
613 if (test_bit(AGP_FF_IS_CONTROLLER, &priv->access_flags)) { in agp_mmap()
619 vma->vm_ops = kerninfo.vm_ops; in agp_mmap()
620 } else if (io_remap_pfn_range(vma, vma->vm_start, in agp_mmap()
623 pgprot_writecombine(vma->vm_page_prot))) { in agp_mmap()
632 return -EPERM; in agp_mmap()
636 return -EINVAL; in agp_mmap()
640 return -EAGAIN; in agp_mmap()
645 struct agp_file_private *priv = file->private_data; in agp_release()
651 if (test_bit(AGP_FF_IS_CONTROLLER, &priv->access_flags)) { in agp_release()
654 controller = agp_find_controller_by_pid(priv->my_pid); in agp_release()
664 if (test_bit(AGP_FF_IS_CLIENT, &priv->access_flags)) in agp_release()
665 agp_remove_client(priv->my_pid); in agp_release()
669 file->private_data = NULL; in agp_release()
681 return -ENXIO; in agp_open()
688 return -ENOMEM; in agp_open()
691 set_bit(AGP_FF_ALLOW_CLIENT, &priv->access_flags); in agp_open()
692 priv->my_pid = current->pid; in agp_open()
696 set_bit(AGP_FF_ALLOW_CONTROLLER, &priv->access_flags); in agp_open()
698 client = agp_find_client_by_pid(current->pid); in agp_open()
701 set_bit(AGP_FF_IS_CLIENT, &priv->access_flags); in agp_open()
702 set_bit(AGP_FF_IS_VALID, &priv->access_flags); in agp_open()
704 file->private_data = (void *) priv; in agp_open()
723 userinfo.bridge_id = kerninfo.device->vendor | in agpioc_info_wrap()
724 (kerninfo.device->device << 16); in agpioc_info_wrap()
732 return -EFAULT; in agpioc_info_wrap()
743 if (!(test_bit(AGP_FF_ALLOW_CONTROLLER, &priv->access_flags))) in agpioc_acquire_wrap()
744 return -EPERM; in agpioc_acquire_wrap()
747 return -EBUSY; in agpioc_acquire_wrap()
750 return -ENODEV; in agpioc_acquire_wrap()
752 if (atomic_read(&agp_bridge->agp_in_use)) in agpioc_acquire_wrap()
753 return -EBUSY; in agpioc_acquire_wrap()
755 atomic_inc(&agp_bridge->agp_in_use); in agpioc_acquire_wrap()
759 controller = agp_find_controller_by_pid(priv->my_pid); in agpioc_acquire_wrap()
764 controller = agp_create_controller(priv->my_pid); in agpioc_acquire_wrap()
769 return -ENOMEM; in agpioc_acquire_wrap()
775 set_bit(AGP_FF_IS_CONTROLLER, &priv->access_flags); in agpioc_acquire_wrap()
776 set_bit(AGP_FF_IS_VALID, &priv->access_flags); in agpioc_acquire_wrap()
793 return -EFAULT; in agpioc_setup_wrap()
807 return -EFAULT; in agpioc_reserve_wrap()
810 return -EFAULT; in agpioc_reserve_wrap()
819 set_bit(AGP_FF_IS_CLIENT, &client_priv->access_flags); in agpioc_reserve_wrap()
820 set_bit(AGP_FF_IS_VALID, &client_priv->access_flags); in agpioc_reserve_wrap()
831 return -EINVAL; in agpioc_reserve_wrap()
837 return -ENOMEM; in agpioc_reserve_wrap()
842 return -EFAULT; in agpioc_reserve_wrap()
852 return -ENOMEM; in agpioc_reserve_wrap()
857 set_bit(AGP_FF_IS_CLIENT, &client_priv->access_flags); in agpioc_reserve_wrap()
858 set_bit(AGP_FF_IS_VALID, &client_priv->access_flags); in agpioc_reserve_wrap()
864 return -EINVAL; in agpioc_reserve_wrap()
871 return -EINVAL; in agpioc_protect_wrap()
876 struct agp_memory *memory; in agpioc_allocate_wrap() local
881 return -EFAULT; in agpioc_allocate_wrap()
884 return -EINVAL; in agpioc_allocate_wrap()
886 memory = agp_allocate_memory_wrap(alloc.pg_count, alloc.type); in agpioc_allocate_wrap()
888 if (memory == NULL) in agpioc_allocate_wrap()
889 return -ENOMEM; in agpioc_allocate_wrap()
891 alloc.key = memory->key; in agpioc_allocate_wrap()
892 alloc.physical = memory->physical; in agpioc_allocate_wrap()
895 agp_free_memory_wrap(memory); in agpioc_allocate_wrap()
896 return -EFAULT; in agpioc_allocate_wrap()
903 struct agp_memory *memory; in agpioc_deallocate_wrap() local
906 memory = agp_find_mem_by_key(arg); in agpioc_deallocate_wrap()
908 if (memory == NULL) in agpioc_deallocate_wrap()
909 return -EINVAL; in agpioc_deallocate_wrap()
911 agp_free_memory_wrap(memory); in agpioc_deallocate_wrap()
918 struct agp_memory *memory; in agpioc_bind_wrap() local
922 return -EFAULT; in agpioc_bind_wrap()
924 memory = agp_find_mem_by_key(bind_info.key); in agpioc_bind_wrap()
926 if (memory == NULL) in agpioc_bind_wrap()
927 return -EINVAL; in agpioc_bind_wrap()
929 return agp_bind_memory(memory, bind_info.pg_start); in agpioc_bind_wrap()
934 struct agp_memory *memory; in agpioc_unbind_wrap() local
939 return -EFAULT; in agpioc_unbind_wrap()
941 memory = agp_find_mem_by_key(unbind.key); in agpioc_unbind_wrap()
943 if (memory == NULL) in agpioc_unbind_wrap()
944 return -EINVAL; in agpioc_unbind_wrap()
946 return agp_unbind_memory(memory); in agpioc_unbind_wrap()
952 struct agp_file_private *curr_priv = file->private_data; in agp_ioctl()
953 int ret_val = -ENOTTY; in agp_ioctl()
960 ret_val = -EINVAL; in agp_ioctl()
965 ret_val = -EBUSY; in agp_ioctl()
969 if (!(test_bit(AGP_FF_IS_CONTROLLER, &curr_priv->access_flags))) { in agp_ioctl()
970 ret_val = -EPERM; in agp_ioctl()
976 if (agp_fe.current_controller->pid != curr_priv->my_pid) { in agp_ioctl()
977 ret_val = -EBUSY; in agp_ioctl()
1060 return -EIO; in agp_frontend_initialize()