/*
* AGPGART driver frontend
+ * Copyright (C) 2004 Silicon Graphics, Inc.
* Copyright (C) 2002-2003 Dave Jones
* Copyright (C) 1999 Jeff Hartmann
* Copyright (C) 1999 Precision Insight, Inc.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+ * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
/* Originally taken from linux/mm/mmap.c from the array
* protection_map.
- * The original really should be exported to modules, or
- * some routine which does the conversion for you
+ * The original really should be exported to modules, or
+ * some routine which does the conversion for you
*/
static const pgprot_t my_protect_map[16] =
/* File private list routines */
-struct agp_file_private *agp_find_private(pid_t pid)
+static struct agp_file_private *agp_find_private(pid_t pid)
{
struct agp_file_private *curr;
return NULL;
}
-void agp_insert_file_private(struct agp_file_private * priv)
+static void agp_insert_file_private(struct agp_file_private * priv)
{
struct agp_file_private *prev;
agp_fe.file_priv_list = priv;
}
-void agp_remove_file_private(struct agp_file_private * priv)
+static void agp_remove_file_private(struct agp_file_private * priv)
{
struct agp_file_private *next;
struct agp_file_private *prev;
/* End - File flag list routines */
-/*
- * Wrappers for agp_free_memory & agp_allocate_memory
+/*
+ * Wrappers for agp_free_memory & agp_allocate_memory
* These make sure that internal lists are kept updated.
*/
static void agp_free_memory_wrap(struct agp_memory *memory)
{
struct agp_memory *memory;
- memory = agp_allocate_memory(pg_count, type);
+ memory = agp_allocate_memory(agp_bridge, pg_count, type);
if (memory == NULL)
return NULL;
if (agp_fe.current_controller == controller) {
agp_fe.current_controller = NULL;
agp_fe.backend_acquired = FALSE;
- agp_backend_release();
+ agp_backend_release(agp_bridge);
}
kfree(controller);
return 0;
agp_fe.current_controller = NULL;
agp_fe.used_by_controller = FALSE;
- agp_backend_release();
+ agp_backend_release(agp_bridge);
}
-/*
+/*
* Routines for managing client lists -
* These routines are for managing the list of auth'ed clients.
*/
if (!(test_bit(AGP_FF_IS_VALID, &priv->access_flags)))
goto out_eperm;
- agp_copy_info(&kerninfo);
+ agp_copy_info(agp_bridge, &kerninfo);
size = vma->vm_end - vma->vm_start;
current_size = kerninfo.aper_size;
current_size = current_size * 0x100000;
DBG("client vm_ops=%p", kerninfo.vm_ops);
if (kerninfo.vm_ops) {
vma->vm_ops = kerninfo.vm_ops;
- } else if (remap_pfn_range(vma, vma->vm_start,
+ } else if (io_remap_pfn_range(vma, vma->vm_start,
(kerninfo.aper_base + offset) >> PAGE_SHIFT,
size, vma->vm_page_prot)) {
goto out_again;
DBG("controller vm_ops=%p", kerninfo.vm_ops);
if (kerninfo.vm_ops) {
vma->vm_ops = kerninfo.vm_ops;
- } else if (remap_pfn_range(vma, vma->vm_start,
+ } else if (io_remap_pfn_range(vma, vma->vm_start,
kerninfo.aper_base >> PAGE_SHIFT,
size, vma->vm_page_prot)) {
goto out_again;
struct agp_info userinfo;
struct agp_kern_info kerninfo;
- agp_copy_info(&kerninfo);
+ agp_copy_info(agp_bridge, &kerninfo);
userinfo.version.major = kerninfo.version.major;
userinfo.version.minor = kerninfo.version.minor;
static int agpioc_acquire_wrap(struct agp_file_private *priv)
{
- int ret;
struct agp_controller *controller;
DBG("");
if (agp_fe.current_controller != NULL)
return -EBUSY;
- ret = agp_backend_acquire();
- if (ret == 0)
- agp_fe.backend_acquired = TRUE;
- else
- return ret;
+ if(!agp_bridge)
+ return -ENODEV;
+
+ if (atomic_read(&agp_bridge->agp_in_use))
+ return -EBUSY;
+
+ atomic_inc(&agp_bridge->agp_in_use);
+
+ agp_fe.backend_acquired = TRUE;
controller = agp_find_controller_by_pid(priv->my_pid);
if (controller == NULL) {
agp_fe.backend_acquired = FALSE;
- agp_backend_release();
+ agp_backend_release(agp_bridge);
return -ENOMEM;
}
agp_insert_controller(controller);
if (copy_from_user(&mode, arg, sizeof(struct agp_setup)))
return -EFAULT;
- agp_enable(mode.agp_mode);
+ agp_enable(agp_bridge, mode.agp_mode);
return 0;
}
if ((agp_fe.current_controller == NULL) &&
(cmd != AGPIOC_ACQUIRE)) {
ret_val = -EINVAL;
- goto ioctl_out;
+ goto ioctl_out;
}
if ((agp_fe.backend_acquired != TRUE) &&
(cmd != AGPIOC_ACQUIRE)) {
ret_val = -EBUSY;
- goto ioctl_out;
+ goto ioctl_out;
}
if (cmd != AGPIOC_ACQUIRE) {
if (!(test_bit(AGP_FF_IS_CONTROLLER, &curr_priv->access_flags))) {
ret_val = -EPERM;
- goto ioctl_out;
+ goto ioctl_out;
}
/* Use the original pid of the controller,
* in case it's threaded */
if (agp_fe.current_controller->pid != curr_priv->my_pid) {
ret_val = -EBUSY;
- goto ioctl_out;
+ goto ioctl_out;
}
}
case AGPIOC_ACQUIRE:
ret_val = agpioc_acquire_wrap(curr_priv);
break;
-
+
case AGPIOC_RELEASE:
ret_val = agpioc_release_wrap(curr_priv);
break;
-
+
case AGPIOC_SETUP:
ret_val = agpioc_setup_wrap(curr_priv, (void __user *) arg);
break;
-
+
case AGPIOC_RESERVE:
ret_val = agpioc_reserve_wrap(curr_priv, (void __user *) arg);
break;
-
+
case AGPIOC_PROTECT:
ret_val = agpioc_protect_wrap(curr_priv);
break;
-
+
case AGPIOC_ALLOCATE:
ret_val = agpioc_allocate_wrap(curr_priv, (void __user *) arg);
break;
-
+
case AGPIOC_DEALLOCATE:
ret_val = agpioc_deallocate_wrap(curr_priv, (int) arg);
break;
-
+
case AGPIOC_BIND:
ret_val = agpioc_bind_wrap(curr_priv, (void __user *) arg);
break;
-
+
case AGPIOC_UNBIND:
ret_val = agpioc_unbind_wrap(curr_priv, (void __user *) arg);
break;