| 1 | /* $NetBSD: drm_drv.c,v 1.17 2015/11/09 22:04:53 jmcneill Exp $ */ |
| 2 | |
| 3 | /*- |
| 4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * This code is derived from software contributed to The NetBSD Foundation |
| 8 | * by Taylor R. Campbell. |
| 9 | * |
| 10 | * Redistribution and use in source and binary forms, with or without |
| 11 | * modification, are permitted provided that the following conditions |
| 12 | * are met: |
| 13 | * 1. Redistributions of source code must retain the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer. |
| 15 | * 2. Redistributions in binary form must reproduce the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer in the |
| 17 | * documentation and/or other materials provided with the distribution. |
| 18 | * |
| 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
| 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
| 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
| 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 29 | * POSSIBILITY OF SUCH DAMAGE. |
| 30 | */ |
| 31 | |
| 32 | #include <sys/cdefs.h> |
| 33 | __KERNEL_RCSID(0, "$NetBSD: drm_drv.c,v 1.17 2015/11/09 22:04:53 jmcneill Exp $" ); |
| 34 | |
| 35 | #include <sys/param.h> |
| 36 | #include <sys/types.h> |
| 37 | #include <sys/conf.h> |
| 38 | #include <sys/device.h> |
| 39 | #include <sys/file.h> |
| 40 | #include <sys/filedesc.h> |
| 41 | #include <sys/ioccom.h> |
| 42 | #include <sys/kauth.h> |
| 43 | #ifndef _MODULE |
| 44 | /* XXX Mega-kludge because modules are broken. */ |
| 45 | #include <sys/once.h> |
| 46 | #endif |
| 47 | #include <sys/pmf.h> |
| 48 | #include <sys/poll.h> |
| 49 | #ifndef _MODULE |
| 50 | #include <sys/reboot.h> /* XXX drm_init kludge */ |
| 51 | #endif |
| 52 | #include <sys/select.h> |
| 53 | |
| 54 | #include <uvm/uvm_extern.h> |
| 55 | |
| 56 | #include <linux/err.h> |
| 57 | |
| 58 | #include <linux/pm.h> |
| 59 | |
| 60 | #include <drm/drmP.h> |
| 61 | |
| 62 | static dev_type_open(drm_open); |
| 63 | |
| 64 | static int drm_firstopen(struct drm_device *); |
| 65 | |
| 66 | static int drm_close(struct file *); |
| 67 | static int drm_read(struct file *, off_t *, struct uio *, kauth_cred_t, |
| 68 | int); |
| 69 | static int drm_dequeue_event(struct drm_file *, size_t, |
| 70 | struct drm_pending_event **, int); |
| 71 | static int drm_poll(struct file *, int); |
| 72 | static int drm_kqfilter(struct file *, struct knote *); |
| 73 | static int drm_stat(struct file *, struct stat *); |
| 74 | static int drm_ioctl(struct file *, unsigned long, void *); |
| 75 | static int drm_fop_mmap(struct file *, off_t *, size_t, int, int *, int *, |
| 76 | struct uvm_object **, int *); |
| 77 | static int drm_version_string(char *, size_t *, const char *); |
| 78 | static paddr_t drm_mmap(dev_t, off_t, int); |
| 79 | |
| 80 | static drm_ioctl_t drm_version; |
| 81 | |
| 82 | #define DRM_IOCTL_DEF(IOCTL, FUNC, FLAGS) \ |
| 83 | [DRM_IOCTL_NR(IOCTL)] = { \ |
| 84 | .cmd = (IOCTL), \ |
| 85 | .flags = (FLAGS), \ |
| 86 | .func = (FUNC), \ |
| 87 | .cmd_drv = 0, \ |
| 88 | } |
| 89 | |
| 90 | #if __OS_HAS_AGP |
| 91 | /* XXX Kludge for AGP. */ |
| 92 | static drm_ioctl_t drm_agp_acquire_hook_ioctl; |
| 93 | static drm_ioctl_t drm_agp_release_hook_ioctl; |
| 94 | static drm_ioctl_t drm_agp_enable_hook_ioctl; |
| 95 | static drm_ioctl_t drm_agp_info_hook_ioctl; |
| 96 | static drm_ioctl_t drm_agp_alloc_hook_ioctl; |
| 97 | static drm_ioctl_t drm_agp_free_hook_ioctl; |
| 98 | static drm_ioctl_t drm_agp_bind_hook_ioctl; |
| 99 | static drm_ioctl_t drm_agp_unbind_hook_ioctl; |
| 100 | |
| 101 | #define drm_agp_acquire_ioctl drm_agp_acquire_hook_ioctl |
| 102 | #define drm_agp_release_ioctl drm_agp_release_hook_ioctl |
| 103 | #define drm_agp_enable_ioctl drm_agp_enable_hook_ioctl |
| 104 | #define drm_agp_info_ioctl drm_agp_info_hook_ioctl |
| 105 | #define drm_agp_alloc_ioctl drm_agp_alloc_hook_ioctl |
| 106 | #define drm_agp_free_ioctl drm_agp_free_hook_ioctl |
| 107 | #define drm_agp_bind_ioctl drm_agp_bind_hook_ioctl |
| 108 | #define drm_agp_unbind_ioctl drm_agp_unbind_hook_ioctl |
| 109 | #endif |
| 110 | |
| 111 | /* Table copied verbatim from dist/drm/drm_drv.c. */ |
| 112 | static const struct drm_ioctl_desc drm_ioctls[] = { |
| 113 | DRM_IOCTL_DEF(DRM_IOCTL_VERSION, drm_version, DRM_UNLOCKED|DRM_RENDER_ALLOW), |
| 114 | DRM_IOCTL_DEF(DRM_IOCTL_GET_UNIQUE, drm_getunique, 0), |
| 115 | DRM_IOCTL_DEF(DRM_IOCTL_GET_MAGIC, drm_getmagic, 0), |
| 116 | DRM_IOCTL_DEF(DRM_IOCTL_IRQ_BUSID, drm_irq_by_busid, DRM_MASTER|DRM_ROOT_ONLY), |
| 117 | DRM_IOCTL_DEF(DRM_IOCTL_GET_MAP, drm_getmap, DRM_UNLOCKED), |
| 118 | DRM_IOCTL_DEF(DRM_IOCTL_GET_CLIENT, drm_getclient, DRM_UNLOCKED), |
| 119 | DRM_IOCTL_DEF(DRM_IOCTL_GET_STATS, drm_getstats, DRM_UNLOCKED), |
| 120 | DRM_IOCTL_DEF(DRM_IOCTL_GET_CAP, drm_getcap, DRM_UNLOCKED|DRM_RENDER_ALLOW), |
| 121 | DRM_IOCTL_DEF(DRM_IOCTL_SET_CLIENT_CAP, drm_setclientcap, 0), |
| 122 | DRM_IOCTL_DEF(DRM_IOCTL_SET_VERSION, drm_setversion, DRM_MASTER), |
| 123 | |
| 124 | DRM_IOCTL_DEF(DRM_IOCTL_SET_UNIQUE, drm_setunique, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 125 | DRM_IOCTL_DEF(DRM_IOCTL_BLOCK, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 126 | DRM_IOCTL_DEF(DRM_IOCTL_UNBLOCK, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 127 | DRM_IOCTL_DEF(DRM_IOCTL_AUTH_MAGIC, drm_authmagic, DRM_AUTH|DRM_MASTER), |
| 128 | |
| 129 | DRM_IOCTL_DEF(DRM_IOCTL_ADD_MAP, drm_addmap_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 130 | DRM_IOCTL_DEF(DRM_IOCTL_RM_MAP, drm_rmmap_ioctl, DRM_AUTH), |
| 131 | |
| 132 | DRM_IOCTL_DEF(DRM_IOCTL_SET_SAREA_CTX, drm_setsareactx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 133 | DRM_IOCTL_DEF(DRM_IOCTL_GET_SAREA_CTX, drm_getsareactx, DRM_AUTH), |
| 134 | |
| 135 | DRM_IOCTL_DEF(DRM_IOCTL_SET_MASTER, drm_setmaster_ioctl, DRM_ROOT_ONLY), |
| 136 | DRM_IOCTL_DEF(DRM_IOCTL_DROP_MASTER, drm_dropmaster_ioctl, DRM_ROOT_ONLY), |
| 137 | |
| 138 | DRM_IOCTL_DEF(DRM_IOCTL_ADD_CTX, drm_addctx, DRM_AUTH|DRM_ROOT_ONLY), |
| 139 | DRM_IOCTL_DEF(DRM_IOCTL_RM_CTX, drm_rmctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 140 | DRM_IOCTL_DEF(DRM_IOCTL_MOD_CTX, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 141 | DRM_IOCTL_DEF(DRM_IOCTL_GET_CTX, drm_getctx, DRM_AUTH), |
| 142 | DRM_IOCTL_DEF(DRM_IOCTL_SWITCH_CTX, drm_switchctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 143 | DRM_IOCTL_DEF(DRM_IOCTL_NEW_CTX, drm_newctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 144 | DRM_IOCTL_DEF(DRM_IOCTL_RES_CTX, drm_resctx, DRM_AUTH), |
| 145 | |
| 146 | DRM_IOCTL_DEF(DRM_IOCTL_ADD_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 147 | DRM_IOCTL_DEF(DRM_IOCTL_RM_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 148 | |
| 149 | DRM_IOCTL_DEF(DRM_IOCTL_LOCK, drm_lock, DRM_AUTH), |
| 150 | DRM_IOCTL_DEF(DRM_IOCTL_UNLOCK, drm_unlock, DRM_AUTH), |
| 151 | |
| 152 | DRM_IOCTL_DEF(DRM_IOCTL_FINISH, drm_noop, DRM_AUTH), |
| 153 | |
| 154 | DRM_IOCTL_DEF(DRM_IOCTL_ADD_BUFS, drm_addbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 155 | DRM_IOCTL_DEF(DRM_IOCTL_MARK_BUFS, drm_markbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 156 | DRM_IOCTL_DEF(DRM_IOCTL_INFO_BUFS, drm_infobufs, DRM_AUTH), |
| 157 | DRM_IOCTL_DEF(DRM_IOCTL_MAP_BUFS, drm_mapbufs, DRM_AUTH), |
| 158 | DRM_IOCTL_DEF(DRM_IOCTL_FREE_BUFS, drm_freebufs, DRM_AUTH), |
| 159 | DRM_IOCTL_DEF(DRM_IOCTL_DMA, drm_dma_ioctl, DRM_AUTH), |
| 160 | |
| 161 | DRM_IOCTL_DEF(DRM_IOCTL_CONTROL, drm_control, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 162 | |
| 163 | #if __OS_HAS_AGP |
| 164 | DRM_IOCTL_DEF(DRM_IOCTL_AGP_ACQUIRE, drm_agp_acquire_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 165 | DRM_IOCTL_DEF(DRM_IOCTL_AGP_RELEASE, drm_agp_release_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 166 | DRM_IOCTL_DEF(DRM_IOCTL_AGP_ENABLE, drm_agp_enable_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 167 | DRM_IOCTL_DEF(DRM_IOCTL_AGP_INFO, drm_agp_info_ioctl, DRM_AUTH), |
| 168 | DRM_IOCTL_DEF(DRM_IOCTL_AGP_ALLOC, drm_agp_alloc_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 169 | DRM_IOCTL_DEF(DRM_IOCTL_AGP_FREE, drm_agp_free_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 170 | DRM_IOCTL_DEF(DRM_IOCTL_AGP_BIND, drm_agp_bind_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 171 | DRM_IOCTL_DEF(DRM_IOCTL_AGP_UNBIND, drm_agp_unbind_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 172 | #endif |
| 173 | |
| 174 | DRM_IOCTL_DEF(DRM_IOCTL_SG_ALLOC, drm_sg_alloc, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 175 | DRM_IOCTL_DEF(DRM_IOCTL_SG_FREE, drm_sg_free, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 176 | |
| 177 | DRM_IOCTL_DEF(DRM_IOCTL_WAIT_VBLANK, drm_wait_vblank, DRM_UNLOCKED), |
| 178 | |
| 179 | DRM_IOCTL_DEF(DRM_IOCTL_MODESET_CTL, drm_modeset_ctl, 0), |
| 180 | |
| 181 | DRM_IOCTL_DEF(DRM_IOCTL_UPDATE_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 182 | |
| 183 | DRM_IOCTL_DEF(DRM_IOCTL_GEM_CLOSE, drm_gem_close_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW), |
| 184 | DRM_IOCTL_DEF(DRM_IOCTL_GEM_FLINK, drm_gem_flink_ioctl, DRM_AUTH|DRM_UNLOCKED), |
| 185 | DRM_IOCTL_DEF(DRM_IOCTL_GEM_OPEN, drm_gem_open_ioctl, DRM_AUTH|DRM_UNLOCKED), |
| 186 | |
| 187 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETRESOURCES, drm_mode_getresources, DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
| 188 | |
| 189 | #ifndef __NetBSD__ /* XXX drm prime */ |
| 190 | DRM_IOCTL_DEF(DRM_IOCTL_PRIME_HANDLE_TO_FD, drm_prime_handle_to_fd_ioctl, DRM_AUTH|DRM_UNLOCKED|DRM_RENDER_ALLOW), |
| 191 | DRM_IOCTL_DEF(DRM_IOCTL_PRIME_FD_TO_HANDLE, drm_prime_fd_to_handle_ioctl, DRM_AUTH|DRM_UNLOCKED|DRM_RENDER_ALLOW), |
| 192 | #endif |
| 193 | |
| 194 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPLANERESOURCES, drm_mode_getplane_res, DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
| 195 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETCRTC, drm_mode_getcrtc, DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
| 196 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETCRTC, drm_mode_setcrtc, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
| 197 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPLANE, drm_mode_getplane, DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
| 198 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETPLANE, drm_mode_setplane, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
| 199 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_CURSOR, drm_mode_cursor_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
| 200 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETGAMMA, drm_mode_gamma_get_ioctl, DRM_UNLOCKED), |
| 201 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETGAMMA, drm_mode_gamma_set_ioctl, DRM_MASTER|DRM_UNLOCKED), |
| 202 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETENCODER, drm_mode_getencoder, DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
| 203 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETCONNECTOR, drm_mode_getconnector, DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
| 204 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_ATTACHMODE, drm_noop, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
| 205 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_DETACHMODE, drm_noop, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
| 206 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPROPERTY, drm_mode_getproperty_ioctl, DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
| 207 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETPROPERTY, drm_mode_connector_property_set_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
| 208 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPROPBLOB, drm_mode_getblob_ioctl, DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
| 209 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETFB, drm_mode_getfb, DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
| 210 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_ADDFB, drm_mode_addfb, DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
| 211 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_ADDFB2, drm_mode_addfb2, DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
| 212 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_RMFB, drm_mode_rmfb, DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
| 213 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_PAGE_FLIP, drm_mode_page_flip_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
| 214 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_DIRTYFB, drm_mode_dirtyfb_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
| 215 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_CREATE_DUMB, drm_mode_create_dumb_ioctl, DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
| 216 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_MAP_DUMB, drm_mode_mmap_dumb_ioctl, DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
| 217 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_DESTROY_DUMB, drm_mode_destroy_dumb_ioctl, DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
| 218 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_OBJ_GETPROPERTIES, drm_mode_obj_get_properties_ioctl, DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
| 219 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_OBJ_SETPROPERTY, drm_mode_obj_set_property_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
| 220 | DRM_IOCTL_DEF(DRM_IOCTL_MODE_CURSOR2, drm_mode_cursor2_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED), |
| 221 | }; |
| 222 | |
| 223 | const struct cdevsw drm_cdevsw = { |
| 224 | .d_open = drm_open, |
| 225 | .d_close = noclose, |
| 226 | .d_read = noread, |
| 227 | .d_write = nowrite, |
| 228 | .d_ioctl = noioctl, |
| 229 | .d_stop = nostop, |
| 230 | .d_tty = notty, |
| 231 | .d_poll = nopoll, |
| 232 | .d_mmap = drm_mmap, |
| 233 | .d_kqfilter = nokqfilter, |
| 234 | .d_discard = nodiscard, |
| 235 | /* XXX was D_TTY | D_NEGOFFSAFE */ |
| 236 | /* XXX Add D_MPSAFE some day... */ |
| 237 | .d_flag = D_NEGOFFSAFE, |
| 238 | }; |
| 239 | |
| 240 | static const struct fileops drm_fileops = { |
| 241 | .fo_read = drm_read, |
| 242 | .fo_write = fbadop_write, |
| 243 | .fo_ioctl = drm_ioctl, |
| 244 | .fo_fcntl = fnullop_fcntl, |
| 245 | .fo_poll = drm_poll, |
| 246 | .fo_stat = drm_stat, |
| 247 | .fo_close = drm_close, |
| 248 | .fo_kqfilter = drm_kqfilter, |
| 249 | .fo_restart = fnullop_restart, |
| 250 | .fo_mmap = drm_fop_mmap, |
| 251 | }; |
| 252 | |
| 253 | static int |
| 254 | drm_open(dev_t d, int flags, int fmt, struct lwp *l) |
| 255 | { |
| 256 | struct drm_minor *dminor; |
| 257 | struct drm_device *dev; |
| 258 | bool firstopen, lastclose; |
| 259 | int fd; |
| 260 | struct file *fp; |
| 261 | int error; |
| 262 | extern int drm_guarantee_initialized(void); |
| 263 | |
| 264 | error = drm_guarantee_initialized(); |
| 265 | if (error) |
| 266 | goto fail0; |
| 267 | |
| 268 | if (flags & O_EXCL) { |
| 269 | error = EBUSY; |
| 270 | goto fail0; |
| 271 | } |
| 272 | |
| 273 | dminor = drm_minor_acquire(minor(d)); |
| 274 | if (IS_ERR(dminor)) { |
| 275 | /* XXX errno Linux->NetBSD */ |
| 276 | error = -PTR_ERR(dminor); |
| 277 | goto fail0; |
| 278 | } |
| 279 | dev = dminor->dev; |
| 280 | if (dev->switch_power_state != DRM_SWITCH_POWER_ON) { |
| 281 | error = EINVAL; |
| 282 | goto fail1; |
| 283 | } |
| 284 | |
| 285 | spin_lock(&dev->count_lock); |
| 286 | if (dev->open_count == INT_MAX) { |
| 287 | spin_unlock(&dev->count_lock); |
| 288 | error = EBUSY; |
| 289 | goto fail1; |
| 290 | } |
| 291 | firstopen = (dev->open_count == 0); |
| 292 | dev->open_count++; |
| 293 | spin_unlock(&dev->count_lock); |
| 294 | |
| 295 | if (firstopen) { |
| 296 | /* XXX errno Linux->NetBSD */ |
| 297 | error = drm_firstopen(dev); |
| 298 | if (error) |
| 299 | goto fail2; |
| 300 | } |
| 301 | |
| 302 | error = fd_allocfile(&fp, &fd); |
| 303 | if (error) |
| 304 | goto fail2; |
| 305 | |
| 306 | struct drm_file *const file = kmem_zalloc(sizeof(*file), KM_SLEEP); |
| 307 | /* XXX errno Linux->NetBSD */ |
| 308 | error = -drm_open_file(file, fp, dminor); |
| 309 | if (error) |
| 310 | goto fail3; |
| 311 | |
| 312 | error = fd_clone(fp, fd, flags, &drm_fileops, file); |
| 313 | KASSERT(error == EMOVEFD); /* XXX */ |
| 314 | |
| 315 | /* Success! (But error has to be EMOVEFD, not 0.) */ |
| 316 | return error; |
| 317 | |
| 318 | fail3: kmem_free(file, sizeof(*file)); |
| 319 | fd_abort(curproc, fp, fd); |
| 320 | fail2: spin_lock(&dev->count_lock); |
| 321 | KASSERT(0 < dev->open_count); |
| 322 | --dev->open_count; |
| 323 | lastclose = (dev->open_count == 0); |
| 324 | spin_unlock(&dev->count_lock); |
| 325 | if (lastclose) |
| 326 | (void)drm_lastclose(dev); |
| 327 | fail1: drm_minor_release(dminor); |
| 328 | fail0: KASSERT(error); |
| 329 | return error; |
| 330 | } |
| 331 | |
| 332 | static int |
| 333 | drm_close(struct file *fp) |
| 334 | { |
| 335 | struct drm_file *const file = fp->f_data; |
| 336 | struct drm_minor *const dminor = file->minor; |
| 337 | struct drm_device *const dev = dminor->dev; |
| 338 | bool lastclose; |
| 339 | |
| 340 | drm_close_file(file); |
| 341 | kmem_free(file, sizeof(*file)); |
| 342 | |
| 343 | spin_lock(&dev->count_lock); |
| 344 | KASSERT(0 < dev->open_count); |
| 345 | --dev->open_count; |
| 346 | lastclose = (dev->open_count == 0); |
| 347 | spin_unlock(&dev->count_lock); |
| 348 | |
| 349 | if (lastclose) |
| 350 | (void)drm_lastclose(dev); |
| 351 | |
| 352 | drm_minor_release(dminor); |
| 353 | |
| 354 | return 0; |
| 355 | } |
| 356 | |
| 357 | static int |
| 358 | drm_firstopen(struct drm_device *dev) |
| 359 | { |
| 360 | int ret; |
| 361 | |
| 362 | if (drm_core_check_feature(dev, DRIVER_MODESET)) |
| 363 | return 0; |
| 364 | |
| 365 | if (dev->driver->firstopen) { |
| 366 | ret = (*dev->driver->firstopen)(dev); |
| 367 | if (ret) |
| 368 | goto fail0; |
| 369 | } |
| 370 | |
| 371 | ret = drm_legacy_dma_setup(dev); |
| 372 | if (ret) |
| 373 | goto fail1; |
| 374 | |
| 375 | return 0; |
| 376 | |
| 377 | fail2: __unused |
| 378 | drm_legacy_dma_takedown(dev); |
| 379 | fail1: if (dev->driver->lastclose) |
| 380 | (*dev->driver->lastclose)(dev); |
| 381 | fail0: KASSERT(ret); |
| 382 | return ret; |
| 383 | } |
| 384 | |
| 385 | int |
| 386 | drm_lastclose(struct drm_device *dev) |
| 387 | { |
| 388 | struct drm_vma_entry *vma, *vma_temp; |
| 389 | |
| 390 | /* XXX Order is sketchy here... */ |
| 391 | if (dev->driver->lastclose) |
| 392 | (*dev->driver->lastclose)(dev); |
| 393 | if (dev->irq_enabled && !drm_core_check_feature(dev, DRIVER_MODESET)) |
| 394 | drm_irq_uninstall(dev); |
| 395 | |
| 396 | mutex_lock(&dev->struct_mutex); |
| 397 | if (dev->agp) |
| 398 | drm_agp_clear_hook(dev); |
| 399 | drm_legacy_sg_cleanup(dev); |
| 400 | list_for_each_entry_safe(vma, vma_temp, &dev->vmalist, head) { |
| 401 | list_del(&vma->head); |
| 402 | kfree(vma); |
| 403 | } |
| 404 | drm_legacy_dma_takedown(dev); |
| 405 | mutex_unlock(&dev->struct_mutex); |
| 406 | |
| 407 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) { |
| 408 | dev->sigdata.lock = NULL; |
| 409 | dev->context_flag = 0; |
| 410 | dev->last_context = 0; |
| 411 | dev->if_version = 0; |
| 412 | } |
| 413 | |
| 414 | return 0; |
| 415 | } |
| 416 | |
| 417 | static int |
| 418 | drm_read(struct file *fp, off_t *off, struct uio *uio, kauth_cred_t cred, |
| 419 | int flags) |
| 420 | { |
| 421 | struct drm_file *const file = fp->f_data; |
| 422 | struct drm_pending_event *event; |
| 423 | bool first; |
| 424 | int error = 0; |
| 425 | |
| 426 | for (first = true; ; first = false) { |
| 427 | int f = 0; |
| 428 | |
| 429 | if (!first || ISSET(fp->f_flag, FNONBLOCK)) |
| 430 | f |= FNONBLOCK; |
| 431 | |
| 432 | /* XXX errno Linux->NetBSD */ |
| 433 | error = -drm_dequeue_event(file, uio->uio_resid, &event, f); |
| 434 | if (error) { |
| 435 | if ((error == EWOULDBLOCK) && !first) |
| 436 | error = 0; |
| 437 | break; |
| 438 | } |
| 439 | if (event == NULL) |
| 440 | break; |
| 441 | error = uiomove(event->event, event->event->length, uio); |
| 442 | if (error) /* XXX Requeue the event? */ |
| 443 | break; |
| 444 | (*event->destroy)(event); |
| 445 | } |
| 446 | |
| 447 | /* Success! */ |
| 448 | return error; |
| 449 | } |
| 450 | |
| 451 | static int |
| 452 | drm_dequeue_event(struct drm_file *file, size_t max_length, |
| 453 | struct drm_pending_event **eventp, int flags) |
| 454 | { |
| 455 | struct drm_device *const dev = file->minor->dev; |
| 456 | struct drm_pending_event *event = NULL; |
| 457 | unsigned long irqflags; |
| 458 | int ret = 0; |
| 459 | |
| 460 | spin_lock_irqsave(&dev->event_lock, irqflags); |
| 461 | |
| 462 | if (ISSET(flags, FNONBLOCK)) { |
| 463 | if (list_empty(&file->event_list)) |
| 464 | ret = -EWOULDBLOCK; |
| 465 | } else { |
| 466 | DRM_SPIN_WAIT_UNTIL(ret, &file->event_wait, &dev->event_lock, |
| 467 | !list_empty(&file->event_list)); |
| 468 | } |
| 469 | if (ret) |
| 470 | goto out; |
| 471 | |
| 472 | event = list_first_entry(&file->event_list, struct drm_pending_event, |
| 473 | link); |
| 474 | if (event->event->length > max_length) { |
| 475 | /* Event is too large, can't return it. */ |
| 476 | event = NULL; |
| 477 | ret = 0; |
| 478 | goto out; |
| 479 | } |
| 480 | |
| 481 | file->event_space += event->event->length; |
| 482 | list_del(&event->link); |
| 483 | |
| 484 | out: spin_unlock_irqrestore(&dev->event_lock, irqflags); |
| 485 | *eventp = event; |
| 486 | return ret; |
| 487 | } |
| 488 | |
| 489 | static int |
| 490 | drm_poll(struct file *fp __unused, int events __unused) |
| 491 | { |
| 492 | struct drm_file *const file = fp->f_data; |
| 493 | struct drm_device *const dev = file->minor->dev; |
| 494 | int revents = 0; |
| 495 | unsigned long irqflags; |
| 496 | |
| 497 | if (!ISSET(events, (POLLIN | POLLRDNORM))) |
| 498 | return 0; |
| 499 | |
| 500 | spin_lock_irqsave(&dev->event_lock, irqflags); |
| 501 | if (list_empty(&file->event_list)) |
| 502 | selrecord(curlwp, &file->event_selq); |
| 503 | else |
| 504 | revents |= (events & (POLLIN | POLLRDNORM)); |
| 505 | spin_unlock_irqrestore(&dev->event_lock, irqflags); |
| 506 | |
| 507 | return revents; |
| 508 | } |
| 509 | |
| 510 | static void filt_drm_detach(struct knote *); |
| 511 | static int filt_drm_event(struct knote *, long); |
| 512 | |
| 513 | static const struct filterops drm_filtops = |
| 514 | { 1, NULL, filt_drm_detach, filt_drm_event }; |
| 515 | |
| 516 | static int |
| 517 | drm_kqfilter(struct file *fp, struct knote *kn) |
| 518 | { |
| 519 | struct drm_file *const file = fp->f_data; |
| 520 | struct drm_device *const dev = file->minor->dev; |
| 521 | unsigned long irqflags; |
| 522 | |
| 523 | switch (kn->kn_filter) { |
| 524 | case EVFILT_READ: |
| 525 | kn->kn_fop = &drm_filtops; |
| 526 | kn->kn_hook = file; |
| 527 | spin_lock_irqsave(&dev->event_lock, irqflags); |
| 528 | SLIST_INSERT_HEAD(&file->event_selq.sel_klist, kn, kn_selnext); |
| 529 | spin_unlock_irqrestore(&dev->event_lock, irqflags); |
| 530 | return 0; |
| 531 | case EVFILT_WRITE: |
| 532 | default: |
| 533 | return EINVAL; |
| 534 | } |
| 535 | } |
| 536 | |
| 537 | static void |
| 538 | filt_drm_detach(struct knote *kn) |
| 539 | { |
| 540 | struct drm_file *const file = kn->kn_hook; |
| 541 | struct drm_device *const dev = file->minor->dev; |
| 542 | unsigned long irqflags; |
| 543 | |
| 544 | spin_lock_irqsave(&dev->event_lock, irqflags); |
| 545 | SLIST_REMOVE(&file->event_selq.sel_klist, kn, knote, kn_selnext); |
| 546 | spin_unlock_irqrestore(&dev->event_lock, irqflags); |
| 547 | } |
| 548 | |
| 549 | static int |
| 550 | filt_drm_event(struct knote *kn, long hint) |
| 551 | { |
| 552 | struct drm_file *const file = kn->kn_hook; |
| 553 | struct drm_device *const dev = file->minor->dev; |
| 554 | unsigned long irqflags; |
| 555 | int ret; |
| 556 | |
| 557 | if (hint == NOTE_SUBMIT) |
| 558 | KASSERT(spin_is_locked(&dev->event_lock)); |
| 559 | else |
| 560 | spin_lock_irqsave(&dev->event_lock, irqflags); |
| 561 | if (list_empty(&file->event_list)) { |
| 562 | ret = 0; |
| 563 | } else { |
| 564 | struct drm_pending_event *const event = |
| 565 | list_first_entry(&file->event_list, |
| 566 | struct drm_pending_event, link); |
| 567 | kn->kn_data = event->event->length; |
| 568 | ret = 1; |
| 569 | } |
| 570 | if (hint == NOTE_SUBMIT) |
| 571 | KASSERT(spin_is_locked(&dev->event_lock)); |
| 572 | else |
| 573 | spin_unlock_irqrestore(&dev->event_lock, irqflags); |
| 574 | |
| 575 | return ret; |
| 576 | } |
| 577 | |
| 578 | static int |
| 579 | drm_stat(struct file *fp, struct stat *st) |
| 580 | { |
| 581 | struct drm_file *const file = fp->f_data; |
| 582 | struct drm_minor *const dminor = file->minor; |
| 583 | const dev_t devno = makedev(cdevsw_lookup_major(&drm_cdevsw), |
| 584 | 64*dminor->index + dminor->type); |
| 585 | |
| 586 | (void)memset(st, 0, sizeof(*st)); |
| 587 | |
| 588 | st->st_dev = devno; |
| 589 | st->st_ino = 0; /* XXX (dev,ino) uniqueness bleh */ |
| 590 | st->st_uid = kauth_cred_geteuid(fp->f_cred); |
| 591 | st->st_gid = kauth_cred_getegid(fp->f_cred); |
| 592 | st->st_mode = S_IFCHR; /* XXX what? */ |
| 593 | st->st_rdev = devno; |
| 594 | /* XXX what else? */ |
| 595 | |
| 596 | return 0; |
| 597 | } |
| 598 | |
| 599 | static int |
| 600 | drm_ioctl(struct file *fp, unsigned long cmd, void *data) |
| 601 | { |
| 602 | struct drm_file *const file = fp->f_data; |
| 603 | const unsigned int nr = DRM_IOCTL_NR(cmd); |
| 604 | int error; |
| 605 | |
| 606 | switch (cmd) { |
| 607 | case FIONBIO: |
| 608 | case FIOASYNC: |
| 609 | return 0; |
| 610 | |
| 611 | #if 0 /* XXX why? */ |
| 612 | case SIOCSPGRP: |
| 613 | case TIOCSPGRP: |
| 614 | case FIOSETOWN: |
| 615 | return fsetown(&dev->buf_pgid, cmd, data); |
| 616 | |
| 617 | case SIOCGPGRP: |
| 618 | case TIOCGPGRP: |
| 619 | case FIOGETOWN: |
| 620 | return fgetown(&dev->buf_pgid, cmd, data); |
| 621 | #endif |
| 622 | |
| 623 | default: |
| 624 | break; |
| 625 | } |
| 626 | |
| 627 | if (IOCGROUP(cmd) != DRM_IOCTL_BASE) |
| 628 | return EINVAL; |
| 629 | |
| 630 | KASSERT(file != NULL); |
| 631 | KASSERT(file->minor != NULL); |
| 632 | KASSERT(file->minor->dev != NULL); |
| 633 | struct drm_device *const dev = file->minor->dev; |
| 634 | const struct drm_ioctl_desc *ioctl; |
| 635 | |
| 636 | if ((DRM_COMMAND_BASE <= nr) && (nr < DRM_COMMAND_END)) { |
| 637 | const unsigned int driver_nr = nr - DRM_COMMAND_BASE; |
| 638 | if (driver_nr >= dev->driver->num_ioctls) |
| 639 | return EINVAL; |
| 640 | ioctl = &dev->driver->ioctls[driver_nr]; |
| 641 | } else if (nr < __arraycount(drm_ioctls)) { |
| 642 | ioctl = &drm_ioctls[nr]; |
| 643 | } else { |
| 644 | ioctl = NULL; |
| 645 | } |
| 646 | |
| 647 | if ((ioctl == NULL) || (ioctl->func == NULL)) |
| 648 | return EINVAL; |
| 649 | |
| 650 | /* XXX Synchronize with drm_ioctl_permit in upstream drm_drv.c. */ |
| 651 | if (ISSET(ioctl->flags, DRM_ROOT_ONLY) && !DRM_SUSER()) |
| 652 | return EACCES; |
| 653 | |
| 654 | if (ISSET(ioctl->flags, DRM_AUTH) && |
| 655 | (file->minor->type != DRM_MINOR_RENDER) && |
| 656 | !file->authenticated) |
| 657 | return EACCES; |
| 658 | |
| 659 | if (ISSET(ioctl->flags, DRM_MASTER) && |
| 660 | (file->master == NULL) && |
| 661 | (file->minor->type != DRM_MINOR_CONTROL)) |
| 662 | return EACCES; |
| 663 | |
| 664 | if (!ISSET(ioctl->flags, DRM_CONTROL_ALLOW) && |
| 665 | (file->minor->type == DRM_MINOR_CONTROL)) |
| 666 | return EACCES; |
| 667 | |
| 668 | if (!ISSET(ioctl->flags, DRM_RENDER_ALLOW) && |
| 669 | (file->minor->type == DRM_MINOR_RENDER)) |
| 670 | return EACCES; |
| 671 | |
| 672 | if (!ISSET(ioctl->flags, DRM_UNLOCKED)) |
| 673 | mutex_lock(&drm_global_mutex); |
| 674 | |
| 675 | /* XXX errno Linux->NetBSD */ |
| 676 | error = -(*ioctl->func)(dev, data, file); |
| 677 | |
| 678 | if (!ISSET(ioctl->flags, DRM_UNLOCKED)) |
| 679 | mutex_unlock(&drm_global_mutex); |
| 680 | |
| 681 | return error; |
| 682 | } |
| 683 | |
| 684 | static int |
| 685 | drm_fop_mmap(struct file *fp, off_t *offp, size_t len, int prot, int *flagsp, |
| 686 | int *advicep, struct uvm_object **uobjp, int *maxprotp) |
| 687 | { |
| 688 | struct drm_file *const file = fp->f_data; |
| 689 | struct drm_device *const dev = file->minor->dev; |
| 690 | int error; |
| 691 | |
| 692 | KASSERT(fp == file->filp); |
| 693 | error = (*dev->driver->mmap_object)(dev, *offp, len, prot, uobjp, |
| 694 | offp, file->filp); |
| 695 | *maxprotp = prot; |
| 696 | *advicep = UVM_ADV_RANDOM; |
| 697 | return -error; |
| 698 | } |
| 699 | |
| 700 | static int |
| 701 | drm_version_string(char *target, size_t *lenp, const char *source) |
| 702 | { |
| 703 | const size_t len = strlen(source); |
| 704 | const size_t trunc_len = MIN(len, *lenp); |
| 705 | |
| 706 | *lenp = len; |
| 707 | if ((trunc_len > 0) && (target != NULL)) |
| 708 | /* copyoutstr takes a buffer size, not a string length. */ |
| 709 | /* XXX errno NetBSD->Linux */ |
| 710 | return -copyoutstr(source, target, trunc_len+1, NULL); |
| 711 | |
| 712 | return 0; |
| 713 | } |
| 714 | |
| 715 | static int |
| 716 | drm_version(struct drm_device *dev, void *data, struct drm_file *file) |
| 717 | { |
| 718 | struct drm_version *v = data; |
| 719 | int error; |
| 720 | |
| 721 | v->version_major = dev->driver->major; |
| 722 | v->version_minor = dev->driver->minor; |
| 723 | v->version_patchlevel = dev->driver->patchlevel; |
| 724 | |
| 725 | error = drm_version_string(v->name, &v->name_len, dev->driver->name); |
| 726 | if (error) |
| 727 | goto out; |
| 728 | error = drm_version_string(v->date, &v->date_len, dev->driver->date); |
| 729 | if (error) |
| 730 | goto out; |
| 731 | error = drm_version_string(v->desc, &v->desc_len, dev->driver->desc); |
| 732 | if (error) |
| 733 | goto out; |
| 734 | |
| 735 | out: return error; |
| 736 | } |
| 737 | |
| 738 | static paddr_t |
| 739 | drm_mmap(dev_t d, off_t offset, int prot) |
| 740 | { |
| 741 | struct drm_minor *dminor; |
| 742 | paddr_t paddr; |
| 743 | |
| 744 | dminor = drm_minor_acquire(minor(d)); |
| 745 | if (IS_ERR(dminor)) |
| 746 | return (paddr_t)-1; |
| 747 | |
| 748 | paddr = drm_mmap_paddr(dminor->dev, offset, prot); |
| 749 | |
| 750 | drm_minor_release(dminor); |
| 751 | return paddr; |
| 752 | } |
| 753 | |
| 754 | static const struct drm_agp_hooks *volatile drm_current_agp_hooks; |
| 755 | |
| 756 | int |
| 757 | drm_agp_register(const struct drm_agp_hooks *hooks) |
| 758 | { |
| 759 | |
| 760 | membar_producer(); |
| 761 | if (atomic_cas_ptr(&drm_current_agp_hooks, NULL, __UNCONST(hooks)) |
| 762 | != NULL) |
| 763 | return EBUSY; |
| 764 | |
| 765 | return 0; |
| 766 | } |
| 767 | |
| 768 | void |
| 769 | drm_agp_deregister(const struct drm_agp_hooks *hooks) |
| 770 | { |
| 771 | |
| 772 | if (atomic_cas_ptr(&drm_current_agp_hooks, __UNCONST(hooks), NULL) |
| 773 | != hooks) |
| 774 | panic("%s: wrong hooks: %p != %p" , __func__, |
| 775 | hooks, drm_current_agp_hooks); |
| 776 | } |
| 777 | |
| 778 | static void __dead |
| 779 | drm_noagp_panic(struct drm_device *dev) |
| 780 | { |
| 781 | if ((dev != NULL) && |
| 782 | (dev->control != NULL) && |
| 783 | (dev->control->kdev != NULL)) |
| 784 | panic("%s: no agp loaded" , device_xname(dev->control->kdev)); |
| 785 | else |
| 786 | panic("drm_device %p: no agp loaded" , dev); |
| 787 | } |
| 788 | |
| 789 | int |
| 790 | drm_agp_release_hook(struct drm_device *dev) |
| 791 | { |
| 792 | const struct drm_agp_hooks *const hooks = drm_current_agp_hooks; |
| 793 | |
| 794 | if (hooks == NULL) |
| 795 | drm_noagp_panic(dev); |
| 796 | membar_consumer(); |
| 797 | return (*hooks->agph_release)(dev); |
| 798 | } |
| 799 | |
| 800 | void |
| 801 | drm_agp_clear_hook(struct drm_device *dev) |
| 802 | { |
| 803 | const struct drm_agp_hooks *const hooks = drm_current_agp_hooks; |
| 804 | |
| 805 | if (hooks == NULL) |
| 806 | drm_noagp_panic(dev); |
| 807 | membar_consumer(); |
| 808 | (*hooks->agph_clear)(dev); |
| 809 | } |
| 810 | |
| 811 | #if __OS_HAS_AGP |
| 812 | |
| 813 | #define DEFINE_AGP_HOOK_IOCTL(NAME, HOOK) \ |
| 814 | static int \ |
| 815 | NAME(struct drm_device *dev, void *data, struct drm_file *file) \ |
| 816 | { \ |
| 817 | const struct drm_agp_hooks *const hooks = drm_current_agp_hooks; \ |
| 818 | \ |
| 819 | if (hooks == NULL) \ |
| 820 | return -ENODEV; \ |
| 821 | membar_consumer(); \ |
| 822 | return (*hooks->HOOK)(dev, data, file); \ |
| 823 | } |
| 824 | |
| 825 | DEFINE_AGP_HOOK_IOCTL(drm_agp_acquire_hook_ioctl, agph_acquire_ioctl) |
| 826 | DEFINE_AGP_HOOK_IOCTL(drm_agp_release_hook_ioctl, agph_release_ioctl) |
| 827 | DEFINE_AGP_HOOK_IOCTL(drm_agp_enable_hook_ioctl, agph_enable_ioctl) |
| 828 | DEFINE_AGP_HOOK_IOCTL(drm_agp_info_hook_ioctl, agph_info_ioctl) |
| 829 | DEFINE_AGP_HOOK_IOCTL(drm_agp_alloc_hook_ioctl, agph_alloc_ioctl) |
| 830 | DEFINE_AGP_HOOK_IOCTL(drm_agp_free_hook_ioctl, agph_free_ioctl) |
| 831 | DEFINE_AGP_HOOK_IOCTL(drm_agp_bind_hook_ioctl, agph_bind_ioctl) |
| 832 | DEFINE_AGP_HOOK_IOCTL(drm_agp_unbind_hook_ioctl, agph_unbind_ioctl) |
| 833 | |
| 834 | #endif |
| 835 | |