^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * AGPGART driver frontend compatibility ioctls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2004 Silicon Graphics, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (C) 2002-2003 Dave Jones
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 1999 Jeff Hartmann
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 1999 Precision Insight, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright (C) 1999 Xi Graphics, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Permission is hereby granted, free of charge, to any person obtaining a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * copy of this software and associated documentation files (the "Software"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * to deal in the Software without restriction, including without limitation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * the rights to use, copy, modify, merge, publish, distribute, sublicense,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * and/or sell copies of the Software, and to permit persons to whom the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * Software is furnished to do so, subject to the following conditions:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * The above copyright notice and this permission notice shall be included
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * in all copies or substantial portions of the Software.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <linux/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include <linux/agpgart.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #include "agp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #include "compat_ioctl.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) static int compat_agpioc_info_wrap(struct agp_file_private *priv, void __user *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) struct agp_info32 userinfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) struct agp_kern_info kerninfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) agp_copy_info(agp_bridge, &kerninfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) userinfo.version.major = kerninfo.version.major;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) userinfo.version.minor = kerninfo.version.minor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) userinfo.bridge_id = kerninfo.device->vendor |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) (kerninfo.device->device << 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) userinfo.agp_mode = kerninfo.mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) userinfo.aper_base = (compat_long_t)kerninfo.aper_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) userinfo.aper_size = kerninfo.aper_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) userinfo.pg_total = userinfo.pg_system = kerninfo.max_memory;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) userinfo.pg_used = kerninfo.current_memory;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) if (copy_to_user(arg, &userinfo, sizeof(userinfo)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) struct agp_region32 ureserve;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) struct agp_region kreserve;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) struct agp_client *client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) struct agp_file_private *client_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) DBG("");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) if (copy_from_user(&ureserve, arg, sizeof(ureserve)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) if ((unsigned) ureserve.seg_count >= ~0U/sizeof(struct agp_segment32))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) kreserve.pid = ureserve.pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) kreserve.seg_count = ureserve.seg_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) client = agp_find_client_by_pid(kreserve.pid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) if (kreserve.seg_count == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) /* remove a client */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) client_priv = agp_find_private(kreserve.pid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) if (client_priv != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) set_bit(AGP_FF_IS_CLIENT, &client_priv->access_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) set_bit(AGP_FF_IS_VALID, &client_priv->access_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) if (client == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) /* client is already removed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) return agp_remove_client(kreserve.pid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) struct agp_segment32 *usegment;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) struct agp_segment *ksegment;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) int seg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) if (ureserve.seg_count >= 16384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) usegment = kmalloc_array(ureserve.seg_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) sizeof(*usegment),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) if (!usegment)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) ksegment = kmalloc_array(kreserve.seg_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) sizeof(*ksegment),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) if (!ksegment) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) kfree(usegment);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) sizeof(*usegment) * ureserve.seg_count)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) kfree(usegment);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) kfree(ksegment);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) for (seg = 0; seg < ureserve.seg_count; seg++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) ksegment[seg].pg_start = usegment[seg].pg_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) ksegment[seg].pg_count = usegment[seg].pg_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) ksegment[seg].prot = usegment[seg].prot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) kfree(usegment);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) kreserve.seg_list = ksegment;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) if (client == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) /* Create the client and add the segment */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) client = agp_create_client(kreserve.pid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) if (client == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) kfree(ksegment);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) client_priv = agp_find_private(kreserve.pid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) if (client_priv != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) set_bit(AGP_FF_IS_CLIENT, &client_priv->access_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) set_bit(AGP_FF_IS_VALID, &client_priv->access_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) return agp_create_segment(client, &kreserve);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) /* Will never really happen */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) static int compat_agpioc_allocate_wrap(struct agp_file_private *priv, void __user *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) struct agp_memory *memory;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) struct agp_allocate32 alloc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) DBG("");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) if (copy_from_user(&alloc, arg, sizeof(alloc)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) memory = agp_allocate_memory_wrap(alloc.pg_count, alloc.type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) if (memory == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) alloc.key = memory->key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) alloc.physical = memory->physical;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) if (copy_to_user(arg, &alloc, sizeof(alloc))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) agp_free_memory_wrap(memory);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) static int compat_agpioc_bind_wrap(struct agp_file_private *priv, void __user *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) struct agp_bind32 bind_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) struct agp_memory *memory;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) DBG("");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) if (copy_from_user(&bind_info, arg, sizeof(bind_info)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) memory = agp_find_mem_by_key(bind_info.key);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) if (memory == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) return agp_bind_memory(memory, bind_info.pg_start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) static int compat_agpioc_unbind_wrap(struct agp_file_private *priv, void __user *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) struct agp_memory *memory;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) struct agp_unbind32 unbind;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) DBG("");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) if (copy_from_user(&unbind, arg, sizeof(unbind)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) memory = agp_find_mem_by_key(unbind.key);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) if (memory == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) return agp_unbind_memory(memory);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) long compat_agp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) struct agp_file_private *curr_priv = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) int ret_val = -ENOTTY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) mutex_lock(&(agp_fe.agp_mutex));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) if ((agp_fe.current_controller == NULL) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) (cmd != AGPIOC_ACQUIRE32)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) ret_val = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) goto ioctl_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) if ((agp_fe.backend_acquired != true) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) (cmd != AGPIOC_ACQUIRE32)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) ret_val = -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) goto ioctl_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) if (cmd != AGPIOC_ACQUIRE32) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) if (!(test_bit(AGP_FF_IS_CONTROLLER, &curr_priv->access_flags))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) ret_val = -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) goto ioctl_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) /* Use the original pid of the controller,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) * in case it's threaded */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) if (agp_fe.current_controller->pid != curr_priv->my_pid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) ret_val = -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) goto ioctl_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) switch (cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) case AGPIOC_INFO32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) ret_val = compat_agpioc_info_wrap(curr_priv, (void __user *) arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) case AGPIOC_ACQUIRE32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) ret_val = agpioc_acquire_wrap(curr_priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) case AGPIOC_RELEASE32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) ret_val = agpioc_release_wrap(curr_priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) case AGPIOC_SETUP32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) ret_val = agpioc_setup_wrap(curr_priv, (void __user *) arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) case AGPIOC_RESERVE32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) ret_val = compat_agpioc_reserve_wrap(curr_priv, (void __user *) arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) case AGPIOC_PROTECT32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) ret_val = agpioc_protect_wrap(curr_priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) case AGPIOC_ALLOCATE32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) ret_val = compat_agpioc_allocate_wrap(curr_priv, (void __user *) arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) case AGPIOC_DEALLOCATE32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) ret_val = agpioc_deallocate_wrap(curr_priv, (int) arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) case AGPIOC_BIND32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) ret_val = compat_agpioc_bind_wrap(curr_priv, (void __user *) arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) case AGPIOC_UNBIND32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) ret_val = compat_agpioc_unbind_wrap(curr_priv, (void __user *) arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) case AGPIOC_CHIPSET_FLUSH32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) ioctl_out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) DBG("ioctl returns %d\n", ret_val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) mutex_unlock(&(agp_fe.agp_mutex));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) return ret_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)