drm_ioc32.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146
  1. /**
  2. * \file drm_ioc32.c
  3. *
  4. * 32-bit ioctl compatibility routines for the DRM.
  5. *
  6. * \author Paul Mackerras <paulus@samba.org>
  7. *
  8. * Copyright (C) Paul Mackerras 2005.
  9. * All Rights Reserved.
  10. *
  11. * Permission is hereby granted, free of charge, to any person obtaining a
  12. * copy of this software and associated documentation files (the "Software"),
  13. * to deal in the Software without restriction, including without limitation
  14. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  15. * and/or sell copies of the Software, and to permit persons to whom the
  16. * Software is furnished to do so, subject to the following conditions:
  17. *
  18. * The above copyright notice and this permission notice (including the next
  19. * paragraph) shall be included in all copies or substantial portions of the
  20. * Software.
  21. *
  22. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  23. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  25. * THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  26. * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  27. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  28. * IN THE SOFTWARE.
  29. */
  30. #include <linux/compat.h>
  31. #include <linux/ratelimit.h>
  32. #include <linux/export.h>
  33. #include <drm/drmP.h>
  34. #include <drm/drm_core.h>
  35. #define DRM_IOCTL_VERSION32 DRM_IOWR(0x00, drm_version32_t)
  36. #define DRM_IOCTL_GET_UNIQUE32 DRM_IOWR(0x01, drm_unique32_t)
  37. #define DRM_IOCTL_GET_MAP32 DRM_IOWR(0x04, drm_map32_t)
  38. #define DRM_IOCTL_GET_CLIENT32 DRM_IOWR(0x05, drm_client32_t)
  39. #define DRM_IOCTL_GET_STATS32 DRM_IOR( 0x06, drm_stats32_t)
  40. #define DRM_IOCTL_SET_UNIQUE32 DRM_IOW( 0x10, drm_unique32_t)
  41. #define DRM_IOCTL_ADD_MAP32 DRM_IOWR(0x15, drm_map32_t)
  42. #define DRM_IOCTL_ADD_BUFS32 DRM_IOWR(0x16, drm_buf_desc32_t)
  43. #define DRM_IOCTL_MARK_BUFS32 DRM_IOW( 0x17, drm_buf_desc32_t)
  44. #define DRM_IOCTL_INFO_BUFS32 DRM_IOWR(0x18, drm_buf_info32_t)
  45. #define DRM_IOCTL_MAP_BUFS32 DRM_IOWR(0x19, drm_buf_map32_t)
  46. #define DRM_IOCTL_FREE_BUFS32 DRM_IOW( 0x1a, drm_buf_free32_t)
  47. #define DRM_IOCTL_RM_MAP32 DRM_IOW( 0x1b, drm_map32_t)
  48. #define DRM_IOCTL_SET_SAREA_CTX32 DRM_IOW( 0x1c, drm_ctx_priv_map32_t)
  49. #define DRM_IOCTL_GET_SAREA_CTX32 DRM_IOWR(0x1d, drm_ctx_priv_map32_t)
  50. #define DRM_IOCTL_RES_CTX32 DRM_IOWR(0x26, drm_ctx_res32_t)
  51. #define DRM_IOCTL_DMA32 DRM_IOWR(0x29, drm_dma32_t)
  52. #define DRM_IOCTL_AGP_ENABLE32 DRM_IOW( 0x32, drm_agp_mode32_t)
  53. #define DRM_IOCTL_AGP_INFO32 DRM_IOR( 0x33, drm_agp_info32_t)
  54. #define DRM_IOCTL_AGP_ALLOC32 DRM_IOWR(0x34, drm_agp_buffer32_t)
  55. #define DRM_IOCTL_AGP_FREE32 DRM_IOW( 0x35, drm_agp_buffer32_t)
  56. #define DRM_IOCTL_AGP_BIND32 DRM_IOW( 0x36, drm_agp_binding32_t)
  57. #define DRM_IOCTL_AGP_UNBIND32 DRM_IOW( 0x37, drm_agp_binding32_t)
  58. #define DRM_IOCTL_SG_ALLOC32 DRM_IOW( 0x38, drm_scatter_gather32_t)
  59. #define DRM_IOCTL_SG_FREE32 DRM_IOW( 0x39, drm_scatter_gather32_t)
  60. #define DRM_IOCTL_UPDATE_DRAW32 DRM_IOW( 0x3f, drm_update_draw32_t)
  61. #define DRM_IOCTL_WAIT_VBLANK32 DRM_IOWR(0x3a, drm_wait_vblank32_t)
  62. #define DRM_IOCTL_MODE_ADDFB232 DRM_IOWR(0xb8, drm_mode_fb_cmd232_t)
  63. typedef struct drm_version_32 {
  64. int version_major; /**< Major version */
  65. int version_minor; /**< Minor version */
  66. int version_patchlevel; /**< Patch level */
  67. u32 name_len; /**< Length of name buffer */
  68. u32 name; /**< Name of driver */
  69. u32 date_len; /**< Length of date buffer */
  70. u32 date; /**< User-space buffer to hold date */
  71. u32 desc_len; /**< Length of desc buffer */
  72. u32 desc; /**< User-space buffer to hold desc */
  73. } drm_version32_t;
  74. static int compat_drm_version(struct file *file, unsigned int cmd,
  75. unsigned long arg)
  76. {
  77. drm_version32_t v32;
  78. struct drm_version __user *version;
  79. int err;
  80. if (copy_from_user(&v32, (void __user *)arg, sizeof(v32)))
  81. return -EFAULT;
  82. version = compat_alloc_user_space(sizeof(*version));
  83. if (!version)
  84. return -EFAULT;
  85. if (__put_user(v32.name_len, &version->name_len)
  86. || __put_user((void __user *)(unsigned long)v32.name,
  87. &version->name)
  88. || __put_user(v32.date_len, &version->date_len)
  89. || __put_user((void __user *)(unsigned long)v32.date,
  90. &version->date)
  91. || __put_user(v32.desc_len, &version->desc_len)
  92. || __put_user((void __user *)(unsigned long)v32.desc,
  93. &version->desc))
  94. return -EFAULT;
  95. err = drm_ioctl(file,
  96. DRM_IOCTL_VERSION, (unsigned long)version);
  97. if (err)
  98. return err;
  99. if (__get_user(v32.version_major, &version->version_major)
  100. || __get_user(v32.version_minor, &version->version_minor)
  101. || __get_user(v32.version_patchlevel, &version->version_patchlevel)
  102. || __get_user(v32.name_len, &version->name_len)
  103. || __get_user(v32.date_len, &version->date_len)
  104. || __get_user(v32.desc_len, &version->desc_len))
  105. return -EFAULT;
  106. if (copy_to_user((void __user *)arg, &v32, sizeof(v32)))
  107. return -EFAULT;
  108. return 0;
  109. }
  110. typedef struct drm_unique32 {
  111. u32 unique_len; /**< Length of unique */
  112. u32 unique; /**< Unique name for driver instantiation */
  113. } drm_unique32_t;
  114. static int compat_drm_getunique(struct file *file, unsigned int cmd,
  115. unsigned long arg)
  116. {
  117. drm_unique32_t uq32;
  118. struct drm_unique __user *u;
  119. int err;
  120. if (copy_from_user(&uq32, (void __user *)arg, sizeof(uq32)))
  121. return -EFAULT;
  122. u = compat_alloc_user_space(sizeof(*u));
  123. if (!u)
  124. return -EFAULT;
  125. if (__put_user(uq32.unique_len, &u->unique_len)
  126. || __put_user((void __user *)(unsigned long)uq32.unique,
  127. &u->unique))
  128. return -EFAULT;
  129. err = drm_ioctl(file, DRM_IOCTL_GET_UNIQUE, (unsigned long)u);
  130. if (err)
  131. return err;
  132. if (__get_user(uq32.unique_len, &u->unique_len))
  133. return -EFAULT;
  134. if (copy_to_user((void __user *)arg, &uq32, sizeof(uq32)))
  135. return -EFAULT;
  136. return 0;
  137. }
  138. static int compat_drm_setunique(struct file *file, unsigned int cmd,
  139. unsigned long arg)
  140. {
  141. drm_unique32_t uq32;
  142. struct drm_unique __user *u;
  143. if (copy_from_user(&uq32, (void __user *)arg, sizeof(uq32)))
  144. return -EFAULT;
  145. u = compat_alloc_user_space(sizeof(*u));
  146. if (!u)
  147. return -EFAULT;
  148. if (__put_user(uq32.unique_len, &u->unique_len)
  149. || __put_user((void __user *)(unsigned long)uq32.unique,
  150. &u->unique))
  151. return -EFAULT;
  152. return drm_ioctl(file, DRM_IOCTL_SET_UNIQUE, (unsigned long)u);
  153. }
  154. typedef struct drm_map32 {
  155. u32 offset; /**< Requested physical address (0 for SAREA)*/
  156. u32 size; /**< Requested physical size (bytes) */
  157. enum drm_map_type type; /**< Type of memory to map */
  158. enum drm_map_flags flags; /**< Flags */
  159. u32 handle; /**< User-space: "Handle" to pass to mmap() */
  160. int mtrr; /**< MTRR slot used */
  161. } drm_map32_t;
  162. static int compat_drm_getmap(struct file *file, unsigned int cmd,
  163. unsigned long arg)
  164. {
  165. drm_map32_t __user *argp = (void __user *)arg;
  166. drm_map32_t m32;
  167. struct drm_map __user *map;
  168. int idx, err;
  169. void *handle;
  170. if (get_user(idx, &argp->offset))
  171. return -EFAULT;
  172. map = compat_alloc_user_space(sizeof(*map));
  173. if (!map)
  174. return -EFAULT;
  175. if (__put_user(idx, &map->offset))
  176. return -EFAULT;
  177. err = drm_ioctl(file, DRM_IOCTL_GET_MAP, (unsigned long)map);
  178. if (err)
  179. return err;
  180. if (__get_user(m32.offset, &map->offset)
  181. || __get_user(m32.size, &map->size)
  182. || __get_user(m32.type, &map->type)
  183. || __get_user(m32.flags, &map->flags)
  184. || __get_user(handle, &map->handle)
  185. || __get_user(m32.mtrr, &map->mtrr))
  186. return -EFAULT;
  187. m32.handle = (unsigned long)handle;
  188. if (copy_to_user(argp, &m32, sizeof(m32)))
  189. return -EFAULT;
  190. return 0;
  191. }
  192. static int compat_drm_addmap(struct file *file, unsigned int cmd,
  193. unsigned long arg)
  194. {
  195. drm_map32_t __user *argp = (void __user *)arg;
  196. drm_map32_t m32;
  197. struct drm_map __user *map;
  198. int err;
  199. void *handle;
  200. if (copy_from_user(&m32, argp, sizeof(m32)))
  201. return -EFAULT;
  202. map = compat_alloc_user_space(sizeof(*map));
  203. if (!map)
  204. return -EFAULT;
  205. if (__put_user(m32.offset, &map->offset)
  206. || __put_user(m32.size, &map->size)
  207. || __put_user(m32.type, &map->type)
  208. || __put_user(m32.flags, &map->flags))
  209. return -EFAULT;
  210. err = drm_ioctl(file, DRM_IOCTL_ADD_MAP, (unsigned long)map);
  211. if (err)
  212. return err;
  213. if (__get_user(m32.offset, &map->offset)
  214. || __get_user(m32.mtrr, &map->mtrr)
  215. || __get_user(handle, &map->handle))
  216. return -EFAULT;
  217. m32.handle = (unsigned long)handle;
  218. if (m32.handle != (unsigned long)handle)
  219. printk_ratelimited(KERN_ERR "compat_drm_addmap truncated handle"
  220. " %p for type %d offset %x\n",
  221. handle, m32.type, m32.offset);
  222. if (copy_to_user(argp, &m32, sizeof(m32)))
  223. return -EFAULT;
  224. return 0;
  225. }
  226. static int compat_drm_rmmap(struct file *file, unsigned int cmd,
  227. unsigned long arg)
  228. {
  229. drm_map32_t __user *argp = (void __user *)arg;
  230. struct drm_map __user *map;
  231. u32 handle;
  232. if (get_user(handle, &argp->handle))
  233. return -EFAULT;
  234. map = compat_alloc_user_space(sizeof(*map));
  235. if (!map)
  236. return -EFAULT;
  237. if (__put_user((void *)(unsigned long)handle, &map->handle))
  238. return -EFAULT;
  239. return drm_ioctl(file, DRM_IOCTL_RM_MAP, (unsigned long)map);
  240. }
  241. typedef struct drm_client32 {
  242. int idx; /**< Which client desired? */
  243. int auth; /**< Is client authenticated? */
  244. u32 pid; /**< Process ID */
  245. u32 uid; /**< User ID */
  246. u32 magic; /**< Magic */
  247. u32 iocs; /**< Ioctl count */
  248. } drm_client32_t;
  249. static int compat_drm_getclient(struct file *file, unsigned int cmd,
  250. unsigned long arg)
  251. {
  252. drm_client32_t c32;
  253. drm_client32_t __user *argp = (void __user *)arg;
  254. struct drm_client __user *client;
  255. int idx, err;
  256. if (get_user(idx, &argp->idx))
  257. return -EFAULT;
  258. client = compat_alloc_user_space(sizeof(*client));
  259. if (!client)
  260. return -EFAULT;
  261. if (__put_user(idx, &client->idx))
  262. return -EFAULT;
  263. err = drm_ioctl(file, DRM_IOCTL_GET_CLIENT, (unsigned long)client);
  264. if (err)
  265. return err;
  266. if (__get_user(c32.idx, &client->idx)
  267. || __get_user(c32.auth, &client->auth)
  268. || __get_user(c32.pid, &client->pid)
  269. || __get_user(c32.uid, &client->uid)
  270. || __get_user(c32.magic, &client->magic)
  271. || __get_user(c32.iocs, &client->iocs))
  272. return -EFAULT;
  273. if (copy_to_user(argp, &c32, sizeof(c32)))
  274. return -EFAULT;
  275. return 0;
  276. }
  277. typedef struct drm_stats32 {
  278. u32 count;
  279. struct {
  280. u32 value;
  281. enum drm_stat_type type;
  282. } data[15];
  283. } drm_stats32_t;
  284. static int compat_drm_getstats(struct file *file, unsigned int cmd,
  285. unsigned long arg)
  286. {
  287. drm_stats32_t s32;
  288. drm_stats32_t __user *argp = (void __user *)arg;
  289. struct drm_stats __user *stats;
  290. int i, err;
  291. stats = compat_alloc_user_space(sizeof(*stats));
  292. if (!stats)
  293. return -EFAULT;
  294. err = drm_ioctl(file, DRM_IOCTL_GET_STATS, (unsigned long)stats);
  295. if (err)
  296. return err;
  297. if (__get_user(s32.count, &stats->count))
  298. return -EFAULT;
  299. for (i = 0; i < 15; ++i)
  300. if (__get_user(s32.data[i].value, &stats->data[i].value)
  301. || __get_user(s32.data[i].type, &stats->data[i].type))
  302. return -EFAULT;
  303. if (copy_to_user(argp, &s32, sizeof(s32)))
  304. return -EFAULT;
  305. return 0;
  306. }
  307. typedef struct drm_buf_desc32 {
  308. int count; /**< Number of buffers of this size */
  309. int size; /**< Size in bytes */
  310. int low_mark; /**< Low water mark */
  311. int high_mark; /**< High water mark */
  312. int flags;
  313. u32 agp_start; /**< Start address in the AGP aperture */
  314. } drm_buf_desc32_t;
  315. static int compat_drm_addbufs(struct file *file, unsigned int cmd,
  316. unsigned long arg)
  317. {
  318. drm_buf_desc32_t __user *argp = (void __user *)arg;
  319. struct drm_buf_desc __user *buf;
  320. int err;
  321. unsigned long agp_start;
  322. buf = compat_alloc_user_space(sizeof(*buf));
  323. if (!buf || !access_ok(VERIFY_WRITE, argp, sizeof(*argp)))
  324. return -EFAULT;
  325. if (__copy_in_user(buf, argp, offsetof(drm_buf_desc32_t, agp_start))
  326. || __get_user(agp_start, &argp->agp_start)
  327. || __put_user(agp_start, &buf->agp_start))
  328. return -EFAULT;
  329. err = drm_ioctl(file, DRM_IOCTL_ADD_BUFS, (unsigned long)buf);
  330. if (err)
  331. return err;
  332. if (__copy_in_user(argp, buf, offsetof(drm_buf_desc32_t, agp_start))
  333. || __get_user(agp_start, &buf->agp_start)
  334. || __put_user(agp_start, &argp->agp_start))
  335. return -EFAULT;
  336. return 0;
  337. }
  338. static int compat_drm_markbufs(struct file *file, unsigned int cmd,
  339. unsigned long arg)
  340. {
  341. drm_buf_desc32_t b32;
  342. drm_buf_desc32_t __user *argp = (void __user *)arg;
  343. struct drm_buf_desc __user *buf;
  344. if (copy_from_user(&b32, argp, sizeof(b32)))
  345. return -EFAULT;
  346. buf = compat_alloc_user_space(sizeof(*buf));
  347. if (!buf)
  348. return -EFAULT;
  349. if (__put_user(b32.size, &buf->size)
  350. || __put_user(b32.low_mark, &buf->low_mark)
  351. || __put_user(b32.high_mark, &buf->high_mark))
  352. return -EFAULT;
  353. return drm_ioctl(file, DRM_IOCTL_MARK_BUFS, (unsigned long)buf);
  354. }
  355. typedef struct drm_buf_info32 {
  356. int count; /**< Entries in list */
  357. u32 list;
  358. } drm_buf_info32_t;
  359. static int compat_drm_infobufs(struct file *file, unsigned int cmd,
  360. unsigned long arg)
  361. {
  362. drm_buf_info32_t req32;
  363. drm_buf_info32_t __user *argp = (void __user *)arg;
  364. drm_buf_desc32_t __user *to;
  365. struct drm_buf_info __user *request;
  366. struct drm_buf_desc __user *list;
  367. size_t nbytes;
  368. int i, err;
  369. int count, actual;
  370. if (copy_from_user(&req32, argp, sizeof(req32)))
  371. return -EFAULT;
  372. count = req32.count;
  373. to = (drm_buf_desc32_t __user *) (unsigned long)req32.list;
  374. if (count < 0)
  375. count = 0;
  376. if (count > 0
  377. && !access_ok(VERIFY_WRITE, to, count * sizeof(drm_buf_desc32_t)))
  378. return -EFAULT;
  379. nbytes = sizeof(*request) + count * sizeof(struct drm_buf_desc);
  380. request = compat_alloc_user_space(nbytes);
  381. if (!request)
  382. return -EFAULT;
  383. list = (struct drm_buf_desc *) (request + 1);
  384. if (__put_user(count, &request->count)
  385. || __put_user(list, &request->list))
  386. return -EFAULT;
  387. err = drm_ioctl(file, DRM_IOCTL_INFO_BUFS, (unsigned long)request);
  388. if (err)
  389. return err;
  390. if (__get_user(actual, &request->count))
  391. return -EFAULT;
  392. if (count >= actual)
  393. for (i = 0; i < actual; ++i)
  394. if (__copy_in_user(&to[i], &list[i],
  395. offsetof(struct drm_buf_desc, flags)))
  396. return -EFAULT;
  397. if (__put_user(actual, &argp->count))
  398. return -EFAULT;
  399. return 0;
  400. }
  401. typedef struct drm_buf_pub32 {
  402. int idx; /**< Index into the master buffer list */
  403. int total; /**< Buffer size */
  404. int used; /**< Amount of buffer in use (for DMA) */
  405. u32 address; /**< Address of buffer */
  406. } drm_buf_pub32_t;
  407. typedef struct drm_buf_map32 {
  408. int count; /**< Length of the buffer list */
  409. u32 virtual; /**< Mmap'd area in user-virtual */
  410. u32 list; /**< Buffer information */
  411. } drm_buf_map32_t;
  412. static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
  413. unsigned long arg)
  414. {
  415. drm_buf_map32_t __user *argp = (void __user *)arg;
  416. drm_buf_map32_t req32;
  417. drm_buf_pub32_t __user *list32;
  418. struct drm_buf_map __user *request;
  419. struct drm_buf_pub __user *list;
  420. int i, err;
  421. int count, actual;
  422. size_t nbytes;
  423. void __user *addr;
  424. if (copy_from_user(&req32, argp, sizeof(req32)))
  425. return -EFAULT;
  426. count = req32.count;
  427. list32 = (void __user *)(unsigned long)req32.list;
  428. if (count < 0)
  429. return -EINVAL;
  430. nbytes = sizeof(*request) + count * sizeof(struct drm_buf_pub);
  431. request = compat_alloc_user_space(nbytes);
  432. if (!request)
  433. return -EFAULT;
  434. list = (struct drm_buf_pub *) (request + 1);
  435. if (__put_user(count, &request->count)
  436. || __put_user(list, &request->list))
  437. return -EFAULT;
  438. err = drm_ioctl(file, DRM_IOCTL_MAP_BUFS, (unsigned long)request);
  439. if (err)
  440. return err;
  441. if (__get_user(actual, &request->count))
  442. return -EFAULT;
  443. if (count >= actual)
  444. for (i = 0; i < actual; ++i)
  445. if (__copy_in_user(&list32[i], &list[i],
  446. offsetof(struct drm_buf_pub, address))
  447. || __get_user(addr, &list[i].address)
  448. || __put_user((unsigned long)addr,
  449. &list32[i].address))
  450. return -EFAULT;
  451. if (__put_user(actual, &argp->count)
  452. || __get_user(addr, &request->virtual)
  453. || __put_user((unsigned long)addr, &argp->virtual))
  454. return -EFAULT;
  455. return 0;
  456. }
  457. typedef struct drm_buf_free32 {
  458. int count;
  459. u32 list;
  460. } drm_buf_free32_t;
  461. static int compat_drm_freebufs(struct file *file, unsigned int cmd,
  462. unsigned long arg)
  463. {
  464. drm_buf_free32_t req32;
  465. struct drm_buf_free __user *request;
  466. drm_buf_free32_t __user *argp = (void __user *)arg;
  467. if (copy_from_user(&req32, argp, sizeof(req32)))
  468. return -EFAULT;
  469. request = compat_alloc_user_space(sizeof(*request));
  470. if (!request)
  471. return -EFAULT;
  472. if (__put_user(req32.count, &request->count)
  473. || __put_user((int __user *)(unsigned long)req32.list,
  474. &request->list))
  475. return -EFAULT;
  476. return drm_ioctl(file, DRM_IOCTL_FREE_BUFS, (unsigned long)request);
  477. }
  478. typedef struct drm_ctx_priv_map32 {
  479. unsigned int ctx_id; /**< Context requesting private mapping */
  480. u32 handle; /**< Handle of map */
  481. } drm_ctx_priv_map32_t;
  482. static int compat_drm_setsareactx(struct file *file, unsigned int cmd,
  483. unsigned long arg)
  484. {
  485. drm_ctx_priv_map32_t req32;
  486. struct drm_ctx_priv_map __user *request;
  487. drm_ctx_priv_map32_t __user *argp = (void __user *)arg;
  488. if (copy_from_user(&req32, argp, sizeof(req32)))
  489. return -EFAULT;
  490. request = compat_alloc_user_space(sizeof(*request));
  491. if (!request)
  492. return -EFAULT;
  493. if (__put_user(req32.ctx_id, &request->ctx_id)
  494. || __put_user((void *)(unsigned long)req32.handle,
  495. &request->handle))
  496. return -EFAULT;
  497. return drm_ioctl(file, DRM_IOCTL_SET_SAREA_CTX, (unsigned long)request);
  498. }
  499. static int compat_drm_getsareactx(struct file *file, unsigned int cmd,
  500. unsigned long arg)
  501. {
  502. struct drm_ctx_priv_map __user *request;
  503. drm_ctx_priv_map32_t __user *argp = (void __user *)arg;
  504. int err;
  505. unsigned int ctx_id;
  506. void *handle;
  507. if (!access_ok(VERIFY_WRITE, argp, sizeof(*argp))
  508. || __get_user(ctx_id, &argp->ctx_id))
  509. return -EFAULT;
  510. request = compat_alloc_user_space(sizeof(*request));
  511. if (!request)
  512. return -EFAULT;
  513. if (__put_user(ctx_id, &request->ctx_id))
  514. return -EFAULT;
  515. err = drm_ioctl(file, DRM_IOCTL_GET_SAREA_CTX, (unsigned long)request);
  516. if (err)
  517. return err;
  518. if (__get_user(handle, &request->handle)
  519. || __put_user((unsigned long)handle, &argp->handle))
  520. return -EFAULT;
  521. return 0;
  522. }
  523. typedef struct drm_ctx_res32 {
  524. int count;
  525. u32 contexts;
  526. } drm_ctx_res32_t;
  527. static int compat_drm_resctx(struct file *file, unsigned int cmd,
  528. unsigned long arg)
  529. {
  530. drm_ctx_res32_t __user *argp = (void __user *)arg;
  531. drm_ctx_res32_t res32;
  532. struct drm_ctx_res __user *res;
  533. int err;
  534. if (copy_from_user(&res32, argp, sizeof(res32)))
  535. return -EFAULT;
  536. res = compat_alloc_user_space(sizeof(*res));
  537. if (!res)
  538. return -EFAULT;
  539. if (__put_user(res32.count, &res->count)
  540. || __put_user((struct drm_ctx __user *) (unsigned long)res32.contexts,
  541. &res->contexts))
  542. return -EFAULT;
  543. err = drm_ioctl(file, DRM_IOCTL_RES_CTX, (unsigned long)res);
  544. if (err)
  545. return err;
  546. if (__get_user(res32.count, &res->count)
  547. || __put_user(res32.count, &argp->count))
  548. return -EFAULT;
  549. return 0;
  550. }
  551. typedef struct drm_dma32 {
  552. int context; /**< Context handle */
  553. int send_count; /**< Number of buffers to send */
  554. u32 send_indices; /**< List of handles to buffers */
  555. u32 send_sizes; /**< Lengths of data to send */
  556. enum drm_dma_flags flags; /**< Flags */
  557. int request_count; /**< Number of buffers requested */
  558. int request_size; /**< Desired size for buffers */
  559. u32 request_indices; /**< Buffer information */
  560. u32 request_sizes;
  561. int granted_count; /**< Number of buffers granted */
  562. } drm_dma32_t;
  563. static int compat_drm_dma(struct file *file, unsigned int cmd,
  564. unsigned long arg)
  565. {
  566. drm_dma32_t d32;
  567. drm_dma32_t __user *argp = (void __user *)arg;
  568. struct drm_dma __user *d;
  569. int err;
  570. if (copy_from_user(&d32, argp, sizeof(d32)))
  571. return -EFAULT;
  572. d = compat_alloc_user_space(sizeof(*d));
  573. if (!d)
  574. return -EFAULT;
  575. if (__put_user(d32.context, &d->context)
  576. || __put_user(d32.send_count, &d->send_count)
  577. || __put_user((int __user *)(unsigned long)d32.send_indices,
  578. &d->send_indices)
  579. || __put_user((int __user *)(unsigned long)d32.send_sizes,
  580. &d->send_sizes)
  581. || __put_user(d32.flags, &d->flags)
  582. || __put_user(d32.request_count, &d->request_count)
  583. || __put_user((int __user *)(unsigned long)d32.request_indices,
  584. &d->request_indices)
  585. || __put_user((int __user *)(unsigned long)d32.request_sizes,
  586. &d->request_sizes))
  587. return -EFAULT;
  588. err = drm_ioctl(file, DRM_IOCTL_DMA, (unsigned long)d);
  589. if (err)
  590. return err;
  591. if (__get_user(d32.request_size, &d->request_size)
  592. || __get_user(d32.granted_count, &d->granted_count)
  593. || __put_user(d32.request_size, &argp->request_size)
  594. || __put_user(d32.granted_count, &argp->granted_count))
  595. return -EFAULT;
  596. return 0;
  597. }
  598. #if IS_ENABLED(CONFIG_AGP)
  599. typedef struct drm_agp_mode32 {
  600. u32 mode; /**< AGP mode */
  601. } drm_agp_mode32_t;
  602. static int compat_drm_agp_enable(struct file *file, unsigned int cmd,
  603. unsigned long arg)
  604. {
  605. drm_agp_mode32_t __user *argp = (void __user *)arg;
  606. drm_agp_mode32_t m32;
  607. struct drm_agp_mode __user *mode;
  608. if (get_user(m32.mode, &argp->mode))
  609. return -EFAULT;
  610. mode = compat_alloc_user_space(sizeof(*mode));
  611. if (put_user(m32.mode, &mode->mode))
  612. return -EFAULT;
  613. return drm_ioctl(file, DRM_IOCTL_AGP_ENABLE, (unsigned long)mode);
  614. }
  615. typedef struct drm_agp_info32 {
  616. int agp_version_major;
  617. int agp_version_minor;
  618. u32 mode;
  619. u32 aperture_base; /* physical address */
  620. u32 aperture_size; /* bytes */
  621. u32 memory_allowed; /* bytes */
  622. u32 memory_used;
  623. /* PCI information */
  624. unsigned short id_vendor;
  625. unsigned short id_device;
  626. } drm_agp_info32_t;
  627. static int compat_drm_agp_info(struct file *file, unsigned int cmd,
  628. unsigned long arg)
  629. {
  630. drm_agp_info32_t __user *argp = (void __user *)arg;
  631. drm_agp_info32_t i32;
  632. struct drm_agp_info __user *info;
  633. int err;
  634. info = compat_alloc_user_space(sizeof(*info));
  635. if (!info)
  636. return -EFAULT;
  637. err = drm_ioctl(file, DRM_IOCTL_AGP_INFO, (unsigned long)info);
  638. if (err)
  639. return err;
  640. if (__get_user(i32.agp_version_major, &info->agp_version_major)
  641. || __get_user(i32.agp_version_minor, &info->agp_version_minor)
  642. || __get_user(i32.mode, &info->mode)
  643. || __get_user(i32.aperture_base, &info->aperture_base)
  644. || __get_user(i32.aperture_size, &info->aperture_size)
  645. || __get_user(i32.memory_allowed, &info->memory_allowed)
  646. || __get_user(i32.memory_used, &info->memory_used)
  647. || __get_user(i32.id_vendor, &info->id_vendor)
  648. || __get_user(i32.id_device, &info->id_device))
  649. return -EFAULT;
  650. if (copy_to_user(argp, &i32, sizeof(i32)))
  651. return -EFAULT;
  652. return 0;
  653. }
  654. typedef struct drm_agp_buffer32 {
  655. u32 size; /**< In bytes -- will round to page boundary */
  656. u32 handle; /**< Used for binding / unbinding */
  657. u32 type; /**< Type of memory to allocate */
  658. u32 physical; /**< Physical used by i810 */
  659. } drm_agp_buffer32_t;
  660. static int compat_drm_agp_alloc(struct file *file, unsigned int cmd,
  661. unsigned long arg)
  662. {
  663. drm_agp_buffer32_t __user *argp = (void __user *)arg;
  664. drm_agp_buffer32_t req32;
  665. struct drm_agp_buffer __user *request;
  666. int err;
  667. if (copy_from_user(&req32, argp, sizeof(req32)))
  668. return -EFAULT;
  669. request = compat_alloc_user_space(sizeof(*request));
  670. if (!request
  671. || __put_user(req32.size, &request->size)
  672. || __put_user(req32.type, &request->type))
  673. return -EFAULT;
  674. err = drm_ioctl(file, DRM_IOCTL_AGP_ALLOC, (unsigned long)request);
  675. if (err)
  676. return err;
  677. if (__get_user(req32.handle, &request->handle)
  678. || __get_user(req32.physical, &request->physical)
  679. || copy_to_user(argp, &req32, sizeof(req32))) {
  680. drm_ioctl(file, DRM_IOCTL_AGP_FREE, (unsigned long)request);
  681. return -EFAULT;
  682. }
  683. return 0;
  684. }
  685. static int compat_drm_agp_free(struct file *file, unsigned int cmd,
  686. unsigned long arg)
  687. {
  688. drm_agp_buffer32_t __user *argp = (void __user *)arg;
  689. struct drm_agp_buffer __user *request;
  690. u32 handle;
  691. request = compat_alloc_user_space(sizeof(*request));
  692. if (!request
  693. || get_user(handle, &argp->handle)
  694. || __put_user(handle, &request->handle))
  695. return -EFAULT;
  696. return drm_ioctl(file, DRM_IOCTL_AGP_FREE, (unsigned long)request);
  697. }
  698. typedef struct drm_agp_binding32 {
  699. u32 handle; /**< From drm_agp_buffer */
  700. u32 offset; /**< In bytes -- will round to page boundary */
  701. } drm_agp_binding32_t;
  702. static int compat_drm_agp_bind(struct file *file, unsigned int cmd,
  703. unsigned long arg)
  704. {
  705. drm_agp_binding32_t __user *argp = (void __user *)arg;
  706. drm_agp_binding32_t req32;
  707. struct drm_agp_binding __user *request;
  708. if (copy_from_user(&req32, argp, sizeof(req32)))
  709. return -EFAULT;
  710. request = compat_alloc_user_space(sizeof(*request));
  711. if (!request
  712. || __put_user(req32.handle, &request->handle)
  713. || __put_user(req32.offset, &request->offset))
  714. return -EFAULT;
  715. return drm_ioctl(file, DRM_IOCTL_AGP_BIND, (unsigned long)request);
  716. }
  717. static int compat_drm_agp_unbind(struct file *file, unsigned int cmd,
  718. unsigned long arg)
  719. {
  720. drm_agp_binding32_t __user *argp = (void __user *)arg;
  721. struct drm_agp_binding __user *request;
  722. u32 handle;
  723. request = compat_alloc_user_space(sizeof(*request));
  724. if (!request
  725. || get_user(handle, &argp->handle)
  726. || __put_user(handle, &request->handle))
  727. return -EFAULT;
  728. return drm_ioctl(file, DRM_IOCTL_AGP_UNBIND, (unsigned long)request);
  729. }
  730. #endif /* CONFIG_AGP */
  731. typedef struct drm_scatter_gather32 {
  732. u32 size; /**< In bytes -- will round to page boundary */
  733. u32 handle; /**< Used for mapping / unmapping */
  734. } drm_scatter_gather32_t;
  735. static int compat_drm_sg_alloc(struct file *file, unsigned int cmd,
  736. unsigned long arg)
  737. {
  738. drm_scatter_gather32_t __user *argp = (void __user *)arg;
  739. struct drm_scatter_gather __user *request;
  740. int err;
  741. unsigned long x;
  742. request = compat_alloc_user_space(sizeof(*request));
  743. if (!request || !access_ok(VERIFY_WRITE, argp, sizeof(*argp))
  744. || __get_user(x, &argp->size)
  745. || __put_user(x, &request->size))
  746. return -EFAULT;
  747. err = drm_ioctl(file, DRM_IOCTL_SG_ALLOC, (unsigned long)request);
  748. if (err)
  749. return err;
  750. /* XXX not sure about the handle conversion here... */
  751. if (__get_user(x, &request->handle)
  752. || __put_user(x >> PAGE_SHIFT, &argp->handle))
  753. return -EFAULT;
  754. return 0;
  755. }
  756. static int compat_drm_sg_free(struct file *file, unsigned int cmd,
  757. unsigned long arg)
  758. {
  759. drm_scatter_gather32_t __user *argp = (void __user *)arg;
  760. struct drm_scatter_gather __user *request;
  761. unsigned long x;
  762. request = compat_alloc_user_space(sizeof(*request));
  763. if (!request || !access_ok(VERIFY_WRITE, argp, sizeof(*argp))
  764. || __get_user(x, &argp->handle)
  765. || __put_user(x << PAGE_SHIFT, &request->handle))
  766. return -EFAULT;
  767. return drm_ioctl(file, DRM_IOCTL_SG_FREE, (unsigned long)request);
  768. }
  769. #if defined(CONFIG_X86) || defined(CONFIG_IA64)
  770. typedef struct drm_update_draw32 {
  771. drm_drawable_t handle;
  772. unsigned int type;
  773. unsigned int num;
  774. /* 64-bit version has a 32-bit pad here */
  775. u64 data; /**< Pointer */
  776. } __attribute__((packed)) drm_update_draw32_t;
  777. static int compat_drm_update_draw(struct file *file, unsigned int cmd,
  778. unsigned long arg)
  779. {
  780. drm_update_draw32_t update32;
  781. struct drm_update_draw __user *request;
  782. int err;
  783. if (copy_from_user(&update32, (void __user *)arg, sizeof(update32)))
  784. return -EFAULT;
  785. request = compat_alloc_user_space(sizeof(*request));
  786. if (!request ||
  787. __put_user(update32.handle, &request->handle) ||
  788. __put_user(update32.type, &request->type) ||
  789. __put_user(update32.num, &request->num) ||
  790. __put_user(update32.data, &request->data))
  791. return -EFAULT;
  792. err = drm_ioctl(file, DRM_IOCTL_UPDATE_DRAW, (unsigned long)request);
  793. return err;
  794. }
  795. #endif
  796. struct drm_wait_vblank_request32 {
  797. enum drm_vblank_seq_type type;
  798. unsigned int sequence;
  799. u32 signal;
  800. };
  801. struct drm_wait_vblank_reply32 {
  802. enum drm_vblank_seq_type type;
  803. unsigned int sequence;
  804. s32 tval_sec;
  805. s32 tval_usec;
  806. };
  807. typedef union drm_wait_vblank32 {
  808. struct drm_wait_vblank_request32 request;
  809. struct drm_wait_vblank_reply32 reply;
  810. } drm_wait_vblank32_t;
  811. static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
  812. unsigned long arg)
  813. {
  814. drm_wait_vblank32_t __user *argp = (void __user *)arg;
  815. drm_wait_vblank32_t req32;
  816. union drm_wait_vblank __user *request;
  817. int err;
  818. if (copy_from_user(&req32, argp, sizeof(req32)))
  819. return -EFAULT;
  820. request = compat_alloc_user_space(sizeof(*request));
  821. if (!request
  822. || __put_user(req32.request.type, &request->request.type)
  823. || __put_user(req32.request.sequence, &request->request.sequence)
  824. || __put_user(req32.request.signal, &request->request.signal))
  825. return -EFAULT;
  826. err = drm_ioctl(file, DRM_IOCTL_WAIT_VBLANK, (unsigned long)request);
  827. if (err)
  828. return err;
  829. if (__get_user(req32.reply.type, &request->reply.type)
  830. || __get_user(req32.reply.sequence, &request->reply.sequence)
  831. || __get_user(req32.reply.tval_sec, &request->reply.tval_sec)
  832. || __get_user(req32.reply.tval_usec, &request->reply.tval_usec))
  833. return -EFAULT;
  834. if (copy_to_user(argp, &req32, sizeof(req32)))
  835. return -EFAULT;
  836. return 0;
  837. }
  838. #if defined(CONFIG_X86) || defined(CONFIG_IA64)
  839. typedef struct drm_mode_fb_cmd232 {
  840. u32 fb_id;
  841. u32 width;
  842. u32 height;
  843. u32 pixel_format;
  844. u32 flags;
  845. u32 handles[4];
  846. u32 pitches[4];
  847. u32 offsets[4];
  848. u64 modifier[4];
  849. } __attribute__((packed)) drm_mode_fb_cmd232_t;
  850. static int compat_drm_mode_addfb2(struct file *file, unsigned int cmd,
  851. unsigned long arg)
  852. {
  853. struct drm_mode_fb_cmd232 __user *argp = (void __user *)arg;
  854. struct drm_mode_fb_cmd232 req32;
  855. struct drm_mode_fb_cmd2 __user *req64;
  856. int i;
  857. int err;
  858. if (copy_from_user(&req32, argp, sizeof(req32)))
  859. return -EFAULT;
  860. req64 = compat_alloc_user_space(sizeof(*req64));
  861. if (!access_ok(VERIFY_WRITE, req64, sizeof(*req64))
  862. || __put_user(req32.width, &req64->width)
  863. || __put_user(req32.height, &req64->height)
  864. || __put_user(req32.pixel_format, &req64->pixel_format)
  865. || __put_user(req32.flags, &req64->flags))
  866. return -EFAULT;
  867. for (i = 0; i < 4; i++) {
  868. if (__put_user(req32.handles[i], &req64->handles[i]))
  869. return -EFAULT;
  870. if (__put_user(req32.pitches[i], &req64->pitches[i]))
  871. return -EFAULT;
  872. if (__put_user(req32.offsets[i], &req64->offsets[i]))
  873. return -EFAULT;
  874. if (__put_user(req32.modifier[i], &req64->modifier[i]))
  875. return -EFAULT;
  876. }
  877. err = drm_ioctl(file, DRM_IOCTL_MODE_ADDFB2, (unsigned long)req64);
  878. if (err)
  879. return err;
  880. if (__get_user(req32.fb_id, &req64->fb_id))
  881. return -EFAULT;
  882. if (copy_to_user(argp, &req32, sizeof(req32)))
  883. return -EFAULT;
  884. return 0;
  885. }
  886. #endif
  887. static drm_ioctl_compat_t *drm_compat_ioctls[] = {
  888. [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
  889. [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
  890. [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
  891. [DRM_IOCTL_NR(DRM_IOCTL_GET_CLIENT32)] = compat_drm_getclient,
  892. [DRM_IOCTL_NR(DRM_IOCTL_GET_STATS32)] = compat_drm_getstats,
  893. [DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE32)] = compat_drm_setunique,
  894. [DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP32)] = compat_drm_addmap,
  895. [DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS32)] = compat_drm_addbufs,
  896. [DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS32)] = compat_drm_markbufs,
  897. [DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS32)] = compat_drm_infobufs,
  898. [DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS32)] = compat_drm_mapbufs,
  899. [DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS32)] = compat_drm_freebufs,
  900. [DRM_IOCTL_NR(DRM_IOCTL_RM_MAP32)] = compat_drm_rmmap,
  901. [DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX32)] = compat_drm_setsareactx,
  902. [DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX32)] = compat_drm_getsareactx,
  903. [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX32)] = compat_drm_resctx,
  904. [DRM_IOCTL_NR(DRM_IOCTL_DMA32)] = compat_drm_dma,
  905. #if IS_ENABLED(CONFIG_AGP)
  906. [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE32)] = compat_drm_agp_enable,
  907. [DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO32)] = compat_drm_agp_info,
  908. [DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC32)] = compat_drm_agp_alloc,
  909. [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE32)] = compat_drm_agp_free,
  910. [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND32)] = compat_drm_agp_bind,
  911. [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND32)] = compat_drm_agp_unbind,
  912. #endif
  913. [DRM_IOCTL_NR(DRM_IOCTL_SG_ALLOC32)] = compat_drm_sg_alloc,
  914. [DRM_IOCTL_NR(DRM_IOCTL_SG_FREE32)] = compat_drm_sg_free,
  915. #if defined(CONFIG_X86) || defined(CONFIG_IA64)
  916. [DRM_IOCTL_NR(DRM_IOCTL_UPDATE_DRAW32)] = compat_drm_update_draw,
  917. #endif
  918. [DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK32)] = compat_drm_wait_vblank,
  919. #if defined(CONFIG_X86) || defined(CONFIG_IA64)
  920. [DRM_IOCTL_NR(DRM_IOCTL_MODE_ADDFB232)] = compat_drm_mode_addfb2,
  921. #endif
  922. };
  923. /**
  924. * Called whenever a 32-bit process running under a 64-bit kernel
  925. * performs an ioctl on /dev/drm.
  926. *
  927. * \param file_priv DRM file private.
  928. * \param cmd command.
  929. * \param arg user argument.
  930. * \return zero on success or negative number on failure.
  931. */
  932. long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
  933. {
  934. unsigned int nr = DRM_IOCTL_NR(cmd);
  935. drm_ioctl_compat_t *fn;
  936. int ret;
  937. /* Assume that ioctls without an explicit compat routine will just
  938. * work. This may not always be a good assumption, but it's better
  939. * than always failing.
  940. */
  941. if (nr >= ARRAY_SIZE(drm_compat_ioctls))
  942. return drm_ioctl(filp, cmd, arg);
  943. fn = drm_compat_ioctls[nr];
  944. if (fn != NULL)
  945. ret = (*fn) (filp, cmd, arg);
  946. else
  947. ret = drm_ioctl(filp, cmd, arg);
  948. return ret;
  949. }
  950. EXPORT_SYMBOL(drm_compat_ioctl);