i915_dma.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070
  1. /* i915_dma.c -- DMA support for the I915 -*- linux-c -*-
  2. */
  3. /*
  4. * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
  5. * All Rights Reserved.
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a
  8. * copy of this software and associated documentation files (the
  9. * "Software"), to deal in the Software without restriction, including
  10. * without limitation the rights to use, copy, modify, merge, publish,
  11. * distribute, sub license, and/or sell copies of the Software, and to
  12. * permit persons to whom the Software is furnished to do so, subject to
  13. * the following conditions:
  14. *
  15. * The above copyright notice and this permission notice (including the
  16. * next paragraph) shall be included in all copies or substantial portions
  17. * of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  20. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  21. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  22. * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
  23. * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  24. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  25. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26. *
  27. */
  28. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  29. #include <linux/async.h>
  30. #include <drm/drmP.h>
  31. #include <drm/drm_crtc_helper.h>
  32. #include <drm/drm_fb_helper.h>
  33. #include <drm/drm_legacy.h>
  34. #include "intel_drv.h"
  35. #include <drm/i915_drm.h>
  36. #include "i915_drv.h"
  37. #include "i915_trace.h"
  38. #include <linux/pci.h>
  39. #include <linux/console.h>
  40. #include <linux/vt.h>
  41. #include <linux/vgaarb.h>
  42. #include <linux/acpi.h>
  43. #include <linux/pnp.h>
  44. #include <linux/vga_switcheroo.h>
  45. #include <linux/slab.h>
  46. #include <acpi/video.h>
  47. #include <linux/pm.h>
  48. #include <linux/pm_runtime.h>
  49. #include <linux/oom.h>
  50. static int i915_getparam(struct drm_device *dev, void *data,
  51. struct drm_file *file_priv)
  52. {
  53. struct drm_i915_private *dev_priv = dev->dev_private;
  54. drm_i915_getparam_t *param = data;
  55. int value;
  56. switch (param->param) {
  57. case I915_PARAM_IRQ_ACTIVE:
  58. case I915_PARAM_ALLOW_BATCHBUFFER:
  59. case I915_PARAM_LAST_DISPATCH:
  60. /* Reject all old ums/dri params. */
  61. return -ENODEV;
  62. case I915_PARAM_CHIPSET_ID:
  63. value = dev->pdev->device;
  64. break;
  65. case I915_PARAM_HAS_GEM:
  66. value = 1;
  67. break;
  68. case I915_PARAM_NUM_FENCES_AVAIL:
  69. value = dev_priv->num_fence_regs - dev_priv->fence_reg_start;
  70. break;
  71. case I915_PARAM_HAS_OVERLAY:
  72. value = dev_priv->overlay ? 1 : 0;
  73. break;
  74. case I915_PARAM_HAS_PAGEFLIPPING:
  75. value = 1;
  76. break;
  77. case I915_PARAM_HAS_EXECBUF2:
  78. /* depends on GEM */
  79. value = 1;
  80. break;
  81. case I915_PARAM_HAS_BSD:
  82. value = intel_ring_initialized(&dev_priv->ring[VCS]);
  83. break;
  84. case I915_PARAM_HAS_BLT:
  85. value = intel_ring_initialized(&dev_priv->ring[BCS]);
  86. break;
  87. case I915_PARAM_HAS_VEBOX:
  88. value = intel_ring_initialized(&dev_priv->ring[VECS]);
  89. break;
  90. case I915_PARAM_HAS_RELAXED_FENCING:
  91. value = 1;
  92. break;
  93. case I915_PARAM_HAS_COHERENT_RINGS:
  94. value = 1;
  95. break;
  96. case I915_PARAM_HAS_EXEC_CONSTANTS:
  97. value = INTEL_INFO(dev)->gen >= 4;
  98. break;
  99. case I915_PARAM_HAS_RELAXED_DELTA:
  100. value = 1;
  101. break;
  102. case I915_PARAM_HAS_GEN7_SOL_RESET:
  103. value = 1;
  104. break;
  105. case I915_PARAM_HAS_LLC:
  106. value = HAS_LLC(dev);
  107. break;
  108. case I915_PARAM_HAS_WT:
  109. value = HAS_WT(dev);
  110. break;
  111. case I915_PARAM_HAS_ALIASING_PPGTT:
  112. value = USES_PPGTT(dev);
  113. break;
  114. case I915_PARAM_HAS_WAIT_TIMEOUT:
  115. value = 1;
  116. break;
  117. case I915_PARAM_HAS_SEMAPHORES:
  118. value = i915_semaphore_is_enabled(dev);
  119. break;
  120. case I915_PARAM_HAS_PRIME_VMAP_FLUSH:
  121. value = 1;
  122. break;
  123. case I915_PARAM_HAS_SECURE_BATCHES:
  124. value = capable(CAP_SYS_ADMIN);
  125. break;
  126. case I915_PARAM_HAS_PINNED_BATCHES:
  127. value = 1;
  128. break;
  129. case I915_PARAM_HAS_EXEC_NO_RELOC:
  130. value = 1;
  131. break;
  132. case I915_PARAM_HAS_EXEC_HANDLE_LUT:
  133. value = 1;
  134. break;
  135. case I915_PARAM_CMD_PARSER_VERSION:
  136. value = i915_cmd_parser_get_version();
  137. break;
  138. case I915_PARAM_HAS_COHERENT_PHYS_GTT:
  139. value = 1;
  140. break;
  141. default:
  142. DRM_DEBUG("Unknown parameter %d\n", param->param);
  143. return -EINVAL;
  144. }
  145. if (copy_to_user(param->value, &value, sizeof(int))) {
  146. DRM_ERROR("copy_to_user failed\n");
  147. return -EFAULT;
  148. }
  149. return 0;
  150. }
  151. static int i915_setparam(struct drm_device *dev, void *data,
  152. struct drm_file *file_priv)
  153. {
  154. struct drm_i915_private *dev_priv = dev->dev_private;
  155. drm_i915_setparam_t *param = data;
  156. switch (param->param) {
  157. case I915_SETPARAM_USE_MI_BATCHBUFFER_START:
  158. case I915_SETPARAM_TEX_LRU_LOG_GRANULARITY:
  159. case I915_SETPARAM_ALLOW_BATCHBUFFER:
  160. /* Reject all old ums/dri params. */
  161. return -ENODEV;
  162. case I915_SETPARAM_NUM_USED_FENCES:
  163. if (param->value > dev_priv->num_fence_regs ||
  164. param->value < 0)
  165. return -EINVAL;
  166. /* Userspace can use first N regs */
  167. dev_priv->fence_reg_start = param->value;
  168. break;
  169. default:
  170. DRM_DEBUG_DRIVER("unknown parameter %d\n",
  171. param->param);
  172. return -EINVAL;
  173. }
  174. return 0;
  175. }
  176. static int i915_get_bridge_dev(struct drm_device *dev)
  177. {
  178. struct drm_i915_private *dev_priv = dev->dev_private;
  179. dev_priv->bridge_dev = pci_get_bus_and_slot(0, PCI_DEVFN(0, 0));
  180. if (!dev_priv->bridge_dev) {
  181. DRM_ERROR("bridge device not found\n");
  182. return -1;
  183. }
  184. return 0;
  185. }
  186. #define MCHBAR_I915 0x44
  187. #define MCHBAR_I965 0x48
  188. #define MCHBAR_SIZE (4*4096)
  189. #define DEVEN_REG 0x54
  190. #define DEVEN_MCHBAR_EN (1 << 28)
  191. /* Allocate space for the MCH regs if needed, return nonzero on error */
  192. static int
  193. intel_alloc_mchbar_resource(struct drm_device *dev)
  194. {
  195. struct drm_i915_private *dev_priv = dev->dev_private;
  196. int reg = INTEL_INFO(dev)->gen >= 4 ? MCHBAR_I965 : MCHBAR_I915;
  197. u32 temp_lo, temp_hi = 0;
  198. u64 mchbar_addr;
  199. int ret;
  200. if (INTEL_INFO(dev)->gen >= 4)
  201. pci_read_config_dword(dev_priv->bridge_dev, reg + 4, &temp_hi);
  202. pci_read_config_dword(dev_priv->bridge_dev, reg, &temp_lo);
  203. mchbar_addr = ((u64)temp_hi << 32) | temp_lo;
  204. /* If ACPI doesn't have it, assume we need to allocate it ourselves */
  205. #ifdef CONFIG_PNP
  206. if (mchbar_addr &&
  207. pnp_range_reserved(mchbar_addr, mchbar_addr + MCHBAR_SIZE))
  208. return 0;
  209. #endif
  210. /* Get some space for it */
  211. dev_priv->mch_res.name = "i915 MCHBAR";
  212. dev_priv->mch_res.flags = IORESOURCE_MEM;
  213. ret = pci_bus_alloc_resource(dev_priv->bridge_dev->bus,
  214. &dev_priv->mch_res,
  215. MCHBAR_SIZE, MCHBAR_SIZE,
  216. PCIBIOS_MIN_MEM,
  217. 0, pcibios_align_resource,
  218. dev_priv->bridge_dev);
  219. if (ret) {
  220. DRM_DEBUG_DRIVER("failed bus alloc: %d\n", ret);
  221. dev_priv->mch_res.start = 0;
  222. return ret;
  223. }
  224. if (INTEL_INFO(dev)->gen >= 4)
  225. pci_write_config_dword(dev_priv->bridge_dev, reg + 4,
  226. upper_32_bits(dev_priv->mch_res.start));
  227. pci_write_config_dword(dev_priv->bridge_dev, reg,
  228. lower_32_bits(dev_priv->mch_res.start));
  229. return 0;
  230. }
  231. /* Setup MCHBAR if possible, return true if we should disable it again */
  232. static void
  233. intel_setup_mchbar(struct drm_device *dev)
  234. {
  235. struct drm_i915_private *dev_priv = dev->dev_private;
  236. int mchbar_reg = INTEL_INFO(dev)->gen >= 4 ? MCHBAR_I965 : MCHBAR_I915;
  237. u32 temp;
  238. bool enabled;
  239. if (IS_VALLEYVIEW(dev))
  240. return;
  241. dev_priv->mchbar_need_disable = false;
  242. if (IS_I915G(dev) || IS_I915GM(dev)) {
  243. pci_read_config_dword(dev_priv->bridge_dev, DEVEN_REG, &temp);
  244. enabled = !!(temp & DEVEN_MCHBAR_EN);
  245. } else {
  246. pci_read_config_dword(dev_priv->bridge_dev, mchbar_reg, &temp);
  247. enabled = temp & 1;
  248. }
  249. /* If it's already enabled, don't have to do anything */
  250. if (enabled)
  251. return;
  252. if (intel_alloc_mchbar_resource(dev))
  253. return;
  254. dev_priv->mchbar_need_disable = true;
  255. /* Space is allocated or reserved, so enable it. */
  256. if (IS_I915G(dev) || IS_I915GM(dev)) {
  257. pci_write_config_dword(dev_priv->bridge_dev, DEVEN_REG,
  258. temp | DEVEN_MCHBAR_EN);
  259. } else {
  260. pci_read_config_dword(dev_priv->bridge_dev, mchbar_reg, &temp);
  261. pci_write_config_dword(dev_priv->bridge_dev, mchbar_reg, temp | 1);
  262. }
  263. }
  264. static void
  265. intel_teardown_mchbar(struct drm_device *dev)
  266. {
  267. struct drm_i915_private *dev_priv = dev->dev_private;
  268. int mchbar_reg = INTEL_INFO(dev)->gen >= 4 ? MCHBAR_I965 : MCHBAR_I915;
  269. u32 temp;
  270. if (dev_priv->mchbar_need_disable) {
  271. if (IS_I915G(dev) || IS_I915GM(dev)) {
  272. pci_read_config_dword(dev_priv->bridge_dev, DEVEN_REG, &temp);
  273. temp &= ~DEVEN_MCHBAR_EN;
  274. pci_write_config_dword(dev_priv->bridge_dev, DEVEN_REG, temp);
  275. } else {
  276. pci_read_config_dword(dev_priv->bridge_dev, mchbar_reg, &temp);
  277. temp &= ~1;
  278. pci_write_config_dword(dev_priv->bridge_dev, mchbar_reg, temp);
  279. }
  280. }
  281. if (dev_priv->mch_res.start)
  282. release_resource(&dev_priv->mch_res);
  283. }
  284. /* true = enable decode, false = disable decoder */
  285. static unsigned int i915_vga_set_decode(void *cookie, bool state)
  286. {
  287. struct drm_device *dev = cookie;
  288. intel_modeset_vga_set_state(dev, state);
  289. if (state)
  290. return VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM |
  291. VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
  292. else
  293. return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
  294. }
  295. static void i915_switcheroo_set_state(struct pci_dev *pdev, enum vga_switcheroo_state state)
  296. {
  297. struct drm_device *dev = pci_get_drvdata(pdev);
  298. pm_message_t pmm = { .event = PM_EVENT_SUSPEND };
  299. if (state == VGA_SWITCHEROO_ON) {
  300. pr_info("switched on\n");
  301. dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
  302. /* i915 resume handler doesn't set to D0 */
  303. pci_set_power_state(dev->pdev, PCI_D0);
  304. i915_resume_legacy(dev);
  305. dev->switch_power_state = DRM_SWITCH_POWER_ON;
  306. } else {
  307. pr_err("switched off\n");
  308. dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
  309. i915_suspend_legacy(dev, pmm);
  310. dev->switch_power_state = DRM_SWITCH_POWER_OFF;
  311. }
  312. }
  313. static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
  314. {
  315. struct drm_device *dev = pci_get_drvdata(pdev);
  316. /*
  317. * FIXME: open_count is protected by drm_global_mutex but that would lead to
  318. * locking inversion with the driver load path. And the access here is
  319. * completely racy anyway. So don't bother with locking for now.
  320. */
  321. return dev->open_count == 0;
  322. }
  323. static const struct vga_switcheroo_client_ops i915_switcheroo_ops = {
  324. .set_gpu_state = i915_switcheroo_set_state,
  325. .reprobe = NULL,
  326. .can_switch = i915_switcheroo_can_switch,
  327. };
  328. static int i915_load_modeset_init(struct drm_device *dev)
  329. {
  330. struct drm_i915_private *dev_priv = dev->dev_private;
  331. int ret;
  332. ret = intel_parse_bios(dev);
  333. if (ret)
  334. DRM_INFO("failed to find VBIOS tables\n");
  335. /* If we have > 1 VGA cards, then we need to arbitrate access
  336. * to the common VGA resources.
  337. *
  338. * If we are a secondary display controller (!PCI_DISPLAY_CLASS_VGA),
  339. * then we do not take part in VGA arbitration and the
  340. * vga_client_register() fails with -ENODEV.
  341. */
  342. ret = vga_client_register(dev->pdev, dev, NULL, i915_vga_set_decode);
  343. if (ret && ret != -ENODEV)
  344. goto out;
  345. intel_register_dsm_handler();
  346. ret = vga_switcheroo_register_client(dev->pdev, &i915_switcheroo_ops, false);
  347. if (ret)
  348. goto cleanup_vga_client;
  349. /* Initialise stolen first so that we may reserve preallocated
  350. * objects for the BIOS to KMS transition.
  351. */
  352. ret = i915_gem_init_stolen(dev);
  353. if (ret)
  354. goto cleanup_vga_switcheroo;
  355. intel_power_domains_init_hw(dev_priv);
  356. ret = intel_irq_install(dev_priv);
  357. if (ret)
  358. goto cleanup_gem_stolen;
  359. /* Important: The output setup functions called by modeset_init need
  360. * working irqs for e.g. gmbus and dp aux transfers. */
  361. intel_modeset_init(dev);
  362. ret = i915_gem_init(dev);
  363. if (ret)
  364. goto cleanup_irq;
  365. intel_modeset_gem_init(dev);
  366. /* Always safe in the mode setting case. */
  367. /* FIXME: do pre/post-mode set stuff in core KMS code */
  368. dev->vblank_disable_allowed = true;
  369. if (INTEL_INFO(dev)->num_pipes == 0)
  370. return 0;
  371. ret = intel_fbdev_init(dev);
  372. if (ret)
  373. goto cleanup_gem;
  374. /* Only enable hotplug handling once the fbdev is fully set up. */
  375. intel_hpd_init(dev_priv);
  376. /*
  377. * Some ports require correctly set-up hpd registers for detection to
  378. * work properly (leading to ghost connected connector status), e.g. VGA
  379. * on gm45. Hence we can only set up the initial fbdev config after hpd
  380. * irqs are fully enabled. Now we should scan for the initial config
  381. * only once hotplug handling is enabled, but due to screwed-up locking
  382. * around kms/fbdev init we can't protect the fdbev initial config
  383. * scanning against hotplug events. Hence do this first and ignore the
  384. * tiny window where we will loose hotplug notifactions.
  385. */
  386. async_schedule(intel_fbdev_initial_config, dev_priv);
  387. drm_kms_helper_poll_init(dev);
  388. return 0;
  389. cleanup_gem:
  390. mutex_lock(&dev->struct_mutex);
  391. i915_gem_cleanup_ringbuffer(dev);
  392. i915_gem_context_fini(dev);
  393. mutex_unlock(&dev->struct_mutex);
  394. cleanup_irq:
  395. drm_irq_uninstall(dev);
  396. cleanup_gem_stolen:
  397. i915_gem_cleanup_stolen(dev);
  398. cleanup_vga_switcheroo:
  399. vga_switcheroo_unregister_client(dev->pdev);
  400. cleanup_vga_client:
  401. vga_client_register(dev->pdev, NULL, NULL, NULL);
  402. out:
  403. return ret;
  404. }
  405. #if IS_ENABLED(CONFIG_FB)
  406. static int i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)
  407. {
  408. struct apertures_struct *ap;
  409. struct pci_dev *pdev = dev_priv->dev->pdev;
  410. bool primary;
  411. int ret;
  412. ap = alloc_apertures(1);
  413. if (!ap)
  414. return -ENOMEM;
  415. ap->ranges[0].base = dev_priv->gtt.mappable_base;
  416. ap->ranges[0].size = dev_priv->gtt.mappable_end;
  417. primary =
  418. pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
  419. ret = remove_conflicting_framebuffers(ap, "inteldrmfb", primary);
  420. kfree(ap);
  421. return ret;
  422. }
  423. #else
  424. static int i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)
  425. {
  426. return 0;
  427. }
  428. #endif
  429. #if !defined(CONFIG_VGA_CONSOLE)
  430. static int i915_kick_out_vgacon(struct drm_i915_private *dev_priv)
  431. {
  432. return 0;
  433. }
  434. #elif !defined(CONFIG_DUMMY_CONSOLE)
  435. static int i915_kick_out_vgacon(struct drm_i915_private *dev_priv)
  436. {
  437. return -ENODEV;
  438. }
  439. #else
  440. static int i915_kick_out_vgacon(struct drm_i915_private *dev_priv)
  441. {
  442. int ret = 0;
  443. DRM_INFO("Replacing VGA console driver\n");
  444. console_lock();
  445. if (con_is_bound(&vga_con))
  446. ret = do_take_over_console(&dummy_con, 0, MAX_NR_CONSOLES - 1, 1);
  447. if (ret == 0) {
  448. ret = do_unregister_con_driver(&vga_con);
  449. /* Ignore "already unregistered". */
  450. if (ret == -ENODEV)
  451. ret = 0;
  452. }
  453. console_unlock();
  454. return ret;
  455. }
  456. #endif
  457. static void i915_dump_device_info(struct drm_i915_private *dev_priv)
  458. {
  459. const struct intel_device_info *info = &dev_priv->info;
  460. #define PRINT_S(name) "%s"
  461. #define SEP_EMPTY
  462. #define PRINT_FLAG(name) info->name ? #name "," : ""
  463. #define SEP_COMMA ,
  464. DRM_DEBUG_DRIVER("i915 device info: gen=%i, pciid=0x%04x rev=0x%02x flags="
  465. DEV_INFO_FOR_EACH_FLAG(PRINT_S, SEP_EMPTY),
  466. info->gen,
  467. dev_priv->dev->pdev->device,
  468. dev_priv->dev->pdev->revision,
  469. DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG, SEP_COMMA));
  470. #undef PRINT_S
  471. #undef SEP_EMPTY
  472. #undef PRINT_FLAG
  473. #undef SEP_COMMA
  474. }
  475. /*
  476. * Determine various intel_device_info fields at runtime.
  477. *
  478. * Use it when either:
  479. * - it's judged too laborious to fill n static structures with the limit
  480. * when a simple if statement does the job,
  481. * - run-time checks (eg read fuse/strap registers) are needed.
  482. *
  483. * This function needs to be called:
  484. * - after the MMIO has been setup as we are reading registers,
  485. * - after the PCH has been detected,
  486. * - before the first usage of the fields it can tweak.
  487. */
  488. static void intel_device_info_runtime_init(struct drm_device *dev)
  489. {
  490. struct drm_i915_private *dev_priv = dev->dev_private;
  491. struct intel_device_info *info;
  492. enum pipe pipe;
  493. info = (struct intel_device_info *)&dev_priv->info;
  494. if (IS_VALLEYVIEW(dev) || INTEL_INFO(dev)->gen == 9)
  495. for_each_pipe(dev_priv, pipe)
  496. info->num_sprites[pipe] = 2;
  497. else
  498. for_each_pipe(dev_priv, pipe)
  499. info->num_sprites[pipe] = 1;
  500. if (i915.disable_display) {
  501. DRM_INFO("Display disabled (module parameter)\n");
  502. info->num_pipes = 0;
  503. } else if (info->num_pipes > 0 &&
  504. (INTEL_INFO(dev)->gen == 7 || INTEL_INFO(dev)->gen == 8) &&
  505. !IS_VALLEYVIEW(dev)) {
  506. u32 fuse_strap = I915_READ(FUSE_STRAP);
  507. u32 sfuse_strap = I915_READ(SFUSE_STRAP);
  508. /*
  509. * SFUSE_STRAP is supposed to have a bit signalling the display
  510. * is fused off. Unfortunately it seems that, at least in
  511. * certain cases, fused off display means that PCH display
  512. * reads don't land anywhere. In that case, we read 0s.
  513. *
  514. * On CPT/PPT, we can detect this case as SFUSE_STRAP_FUSE_LOCK
  515. * should be set when taking over after the firmware.
  516. */
  517. if (fuse_strap & ILK_INTERNAL_DISPLAY_DISABLE ||
  518. sfuse_strap & SFUSE_STRAP_DISPLAY_DISABLED ||
  519. (dev_priv->pch_type == PCH_CPT &&
  520. !(sfuse_strap & SFUSE_STRAP_FUSE_LOCK))) {
  521. DRM_INFO("Display fused off, disabling\n");
  522. info->num_pipes = 0;
  523. }
  524. }
  525. }
  526. /**
  527. * i915_driver_load - setup chip and create an initial config
  528. * @dev: DRM device
  529. * @flags: startup flags
  530. *
  531. * The driver load routine has to do several things:
  532. * - drive output discovery via intel_modeset_init()
  533. * - initialize the memory manager
  534. * - allocate initial config memory
  535. * - setup the DRM framebuffer with the allocated memory
  536. */
  537. int i915_driver_load(struct drm_device *dev, unsigned long flags)
  538. {
  539. struct drm_i915_private *dev_priv;
  540. struct intel_device_info *info, *device_info;
  541. int ret = 0, mmio_bar, mmio_size;
  542. uint32_t aperture_size;
  543. info = (struct intel_device_info *) flags;
  544. /* Refuse to load on gen6+ without kms enabled. */
  545. if (info->gen >= 6 && !drm_core_check_feature(dev, DRIVER_MODESET)) {
  546. DRM_INFO("Your hardware requires kernel modesetting (KMS)\n");
  547. DRM_INFO("See CONFIG_DRM_I915_KMS, nomodeset, and i915.modeset parameters\n");
  548. return -ENODEV;
  549. }
  550. /* UMS needs agp support. */
  551. if (!drm_core_check_feature(dev, DRIVER_MODESET) && !dev->agp)
  552. return -EINVAL;
  553. dev_priv = kzalloc(sizeof(*dev_priv), GFP_KERNEL);
  554. if (dev_priv == NULL)
  555. return -ENOMEM;
  556. dev->dev_private = dev_priv;
  557. dev_priv->dev = dev;
  558. /* Setup the write-once "constant" device info */
  559. device_info = (struct intel_device_info *)&dev_priv->info;
  560. memcpy(device_info, info, sizeof(dev_priv->info));
  561. device_info->device_id = dev->pdev->device;
  562. spin_lock_init(&dev_priv->irq_lock);
  563. spin_lock_init(&dev_priv->gpu_error.lock);
  564. mutex_init(&dev_priv->backlight_lock);
  565. spin_lock_init(&dev_priv->uncore.lock);
  566. spin_lock_init(&dev_priv->mm.object_stat_lock);
  567. spin_lock_init(&dev_priv->mmio_flip_lock);
  568. mutex_init(&dev_priv->dpio_lock);
  569. mutex_init(&dev_priv->modeset_restore_lock);
  570. intel_pm_setup(dev);
  571. intel_display_crc_init(dev);
  572. i915_dump_device_info(dev_priv);
  573. /* Not all pre-production machines fall into this category, only the
  574. * very first ones. Almost everything should work, except for maybe
  575. * suspend/resume. And we don't implement workarounds that affect only
  576. * pre-production machines. */
  577. if (IS_HSW_EARLY_SDV(dev))
  578. DRM_INFO("This is an early pre-production Haswell machine. "
  579. "It may not be fully functional.\n");
  580. if (i915_get_bridge_dev(dev)) {
  581. ret = -EIO;
  582. goto free_priv;
  583. }
  584. mmio_bar = IS_GEN2(dev) ? 1 : 0;
  585. /* Before gen4, the registers and the GTT are behind different BARs.
  586. * However, from gen4 onwards, the registers and the GTT are shared
  587. * in the same BAR, so we want to restrict this ioremap from
  588. * clobbering the GTT which we want ioremap_wc instead. Fortunately,
  589. * the register BAR remains the same size for all the earlier
  590. * generations up to Ironlake.
  591. */
  592. if (info->gen < 5)
  593. mmio_size = 512*1024;
  594. else
  595. mmio_size = 2*1024*1024;
  596. dev_priv->regs = pci_iomap(dev->pdev, mmio_bar, mmio_size);
  597. if (!dev_priv->regs) {
  598. DRM_ERROR("failed to map registers\n");
  599. ret = -EIO;
  600. goto put_bridge;
  601. }
  602. /* This must be called before any calls to HAS_PCH_* */
  603. intel_detect_pch(dev);
  604. intel_uncore_init(dev);
  605. ret = i915_gem_gtt_init(dev);
  606. if (ret)
  607. goto out_regs;
  608. if (drm_core_check_feature(dev, DRIVER_MODESET)) {
  609. /* WARNING: Apparently we must kick fbdev drivers before vgacon,
  610. * otherwise the vga fbdev driver falls over. */
  611. ret = i915_kick_out_firmware_fb(dev_priv);
  612. if (ret) {
  613. DRM_ERROR("failed to remove conflicting framebuffer drivers\n");
  614. goto out_gtt;
  615. }
  616. ret = i915_kick_out_vgacon(dev_priv);
  617. if (ret) {
  618. DRM_ERROR("failed to remove conflicting VGA console\n");
  619. goto out_gtt;
  620. }
  621. }
  622. pci_set_master(dev->pdev);
  623. /* overlay on gen2 is broken and can't address above 1G */
  624. if (IS_GEN2(dev))
  625. dma_set_coherent_mask(&dev->pdev->dev, DMA_BIT_MASK(30));
  626. /* 965GM sometimes incorrectly writes to hardware status page (HWS)
  627. * using 32bit addressing, overwriting memory if HWS is located
  628. * above 4GB.
  629. *
  630. * The documentation also mentions an issue with undefined
  631. * behaviour if any general state is accessed within a page above 4GB,
  632. * which also needs to be handled carefully.
  633. */
  634. if (IS_BROADWATER(dev) || IS_CRESTLINE(dev))
  635. dma_set_coherent_mask(&dev->pdev->dev, DMA_BIT_MASK(32));
  636. aperture_size = dev_priv->gtt.mappable_end;
  637. dev_priv->gtt.mappable =
  638. io_mapping_create_wc(dev_priv->gtt.mappable_base,
  639. aperture_size);
  640. if (dev_priv->gtt.mappable == NULL) {
  641. ret = -EIO;
  642. goto out_gtt;
  643. }
  644. dev_priv->gtt.mtrr = arch_phys_wc_add(dev_priv->gtt.mappable_base,
  645. aperture_size);
  646. /* The i915 workqueue is primarily used for batched retirement of
  647. * requests (and thus managing bo) once the task has been completed
  648. * by the GPU. i915_gem_retire_requests() is called directly when we
  649. * need high-priority retirement, such as waiting for an explicit
  650. * bo.
  651. *
  652. * It is also used for periodic low-priority events, such as
  653. * idle-timers and recording error state.
  654. *
  655. * All tasks on the workqueue are expected to acquire the dev mutex
  656. * so there is no point in running more than one instance of the
  657. * workqueue at any time. Use an ordered one.
  658. */
  659. dev_priv->wq = alloc_ordered_workqueue("i915", 0);
  660. if (dev_priv->wq == NULL) {
  661. DRM_ERROR("Failed to create our workqueue.\n");
  662. ret = -ENOMEM;
  663. goto out_mtrrfree;
  664. }
  665. dev_priv->dp_wq = alloc_ordered_workqueue("i915-dp", 0);
  666. if (dev_priv->dp_wq == NULL) {
  667. DRM_ERROR("Failed to create our dp workqueue.\n");
  668. ret = -ENOMEM;
  669. goto out_freewq;
  670. }
  671. intel_irq_init(dev_priv);
  672. intel_uncore_sanitize(dev);
  673. /* Try to make sure MCHBAR is enabled before poking at it */
  674. intel_setup_mchbar(dev);
  675. intel_setup_gmbus(dev);
  676. intel_opregion_setup(dev);
  677. intel_setup_bios(dev);
  678. i915_gem_load(dev);
  679. /* On the 945G/GM, the chipset reports the MSI capability on the
  680. * integrated graphics even though the support isn't actually there
  681. * according to the published specs. It doesn't appear to function
  682. * correctly in testing on 945G.
  683. * This may be a side effect of MSI having been made available for PEG
  684. * and the registers being closely associated.
  685. *
  686. * According to chipset errata, on the 965GM, MSI interrupts may
  687. * be lost or delayed, but we use them anyways to avoid
  688. * stuck interrupts on some machines.
  689. */
  690. if (!IS_I945G(dev) && !IS_I945GM(dev))
  691. pci_enable_msi(dev->pdev);
  692. intel_device_info_runtime_init(dev);
  693. if (INTEL_INFO(dev)->num_pipes) {
  694. ret = drm_vblank_init(dev, INTEL_INFO(dev)->num_pipes);
  695. if (ret)
  696. goto out_gem_unload;
  697. }
  698. intel_power_domains_init(dev_priv);
  699. if (drm_core_check_feature(dev, DRIVER_MODESET)) {
  700. ret = i915_load_modeset_init(dev);
  701. if (ret < 0) {
  702. DRM_ERROR("failed to init modeset\n");
  703. goto out_power_well;
  704. }
  705. }
  706. i915_setup_sysfs(dev);
  707. if (INTEL_INFO(dev)->num_pipes) {
  708. /* Must be done after probing outputs */
  709. intel_opregion_init(dev);
  710. acpi_video_register();
  711. }
  712. if (IS_GEN5(dev))
  713. intel_gpu_ips_init(dev_priv);
  714. intel_runtime_pm_enable(dev_priv);
  715. return 0;
  716. out_power_well:
  717. intel_power_domains_fini(dev_priv);
  718. drm_vblank_cleanup(dev);
  719. out_gem_unload:
  720. WARN_ON(unregister_oom_notifier(&dev_priv->mm.oom_notifier));
  721. unregister_shrinker(&dev_priv->mm.shrinker);
  722. if (dev->pdev->msi_enabled)
  723. pci_disable_msi(dev->pdev);
  724. intel_teardown_gmbus(dev);
  725. intel_teardown_mchbar(dev);
  726. pm_qos_remove_request(&dev_priv->pm_qos);
  727. destroy_workqueue(dev_priv->dp_wq);
  728. out_freewq:
  729. destroy_workqueue(dev_priv->wq);
  730. out_mtrrfree:
  731. arch_phys_wc_del(dev_priv->gtt.mtrr);
  732. io_mapping_free(dev_priv->gtt.mappable);
  733. out_gtt:
  734. i915_global_gtt_cleanup(dev);
  735. out_regs:
  736. intel_uncore_fini(dev);
  737. pci_iounmap(dev->pdev, dev_priv->regs);
  738. put_bridge:
  739. pci_dev_put(dev_priv->bridge_dev);
  740. free_priv:
  741. if (dev_priv->slab)
  742. kmem_cache_destroy(dev_priv->slab);
  743. kfree(dev_priv);
  744. return ret;
  745. }
  746. int i915_driver_unload(struct drm_device *dev)
  747. {
  748. struct drm_i915_private *dev_priv = dev->dev_private;
  749. int ret;
  750. ret = i915_gem_suspend(dev);
  751. if (ret) {
  752. DRM_ERROR("failed to idle hardware: %d\n", ret);
  753. return ret;
  754. }
  755. intel_power_domains_fini(dev_priv);
  756. intel_gpu_ips_teardown();
  757. i915_teardown_sysfs(dev);
  758. WARN_ON(unregister_oom_notifier(&dev_priv->mm.oom_notifier));
  759. unregister_shrinker(&dev_priv->mm.shrinker);
  760. io_mapping_free(dev_priv->gtt.mappable);
  761. arch_phys_wc_del(dev_priv->gtt.mtrr);
  762. acpi_video_unregister();
  763. if (drm_core_check_feature(dev, DRIVER_MODESET))
  764. intel_fbdev_fini(dev);
  765. drm_vblank_cleanup(dev);
  766. if (drm_core_check_feature(dev, DRIVER_MODESET)) {
  767. intel_modeset_cleanup(dev);
  768. /*
  769. * free the memory space allocated for the child device
  770. * config parsed from VBT
  771. */
  772. if (dev_priv->vbt.child_dev && dev_priv->vbt.child_dev_num) {
  773. kfree(dev_priv->vbt.child_dev);
  774. dev_priv->vbt.child_dev = NULL;
  775. dev_priv->vbt.child_dev_num = 0;
  776. }
  777. vga_switcheroo_unregister_client(dev->pdev);
  778. vga_client_register(dev->pdev, NULL, NULL, NULL);
  779. }
  780. /* Free error state after interrupts are fully disabled. */
  781. del_timer_sync(&dev_priv->gpu_error.hangcheck_timer);
  782. cancel_work_sync(&dev_priv->gpu_error.work);
  783. i915_destroy_error_state(dev);
  784. if (dev->pdev->msi_enabled)
  785. pci_disable_msi(dev->pdev);
  786. intel_opregion_fini(dev);
  787. if (drm_core_check_feature(dev, DRIVER_MODESET)) {
  788. /* Flush any outstanding unpin_work. */
  789. flush_workqueue(dev_priv->wq);
  790. mutex_lock(&dev->struct_mutex);
  791. i915_gem_cleanup_ringbuffer(dev);
  792. i915_gem_context_fini(dev);
  793. mutex_unlock(&dev->struct_mutex);
  794. i915_gem_cleanup_stolen(dev);
  795. }
  796. intel_teardown_gmbus(dev);
  797. intel_teardown_mchbar(dev);
  798. destroy_workqueue(dev_priv->dp_wq);
  799. destroy_workqueue(dev_priv->wq);
  800. pm_qos_remove_request(&dev_priv->pm_qos);
  801. i915_global_gtt_cleanup(dev);
  802. intel_uncore_fini(dev);
  803. if (dev_priv->regs != NULL)
  804. pci_iounmap(dev->pdev, dev_priv->regs);
  805. if (dev_priv->slab)
  806. kmem_cache_destroy(dev_priv->slab);
  807. pci_dev_put(dev_priv->bridge_dev);
  808. kfree(dev_priv);
  809. return 0;
  810. }
  811. int i915_driver_open(struct drm_device *dev, struct drm_file *file)
  812. {
  813. int ret;
  814. ret = i915_gem_open(dev, file);
  815. if (ret)
  816. return ret;
  817. return 0;
  818. }
  819. /**
  820. * i915_driver_lastclose - clean up after all DRM clients have exited
  821. * @dev: DRM device
  822. *
  823. * Take care of cleaning up after all DRM clients have exited. In the
  824. * mode setting case, we want to restore the kernel's initial mode (just
  825. * in case the last client left us in a bad state).
  826. *
  827. * Additionally, in the non-mode setting case, we'll tear down the GTT
  828. * and DMA structures, since the kernel won't be using them, and clea
  829. * up any GEM state.
  830. */
  831. void i915_driver_lastclose(struct drm_device *dev)
  832. {
  833. intel_fbdev_restore_mode(dev);
  834. vga_switcheroo_process_delayed_switch();
  835. }
  836. void i915_driver_preclose(struct drm_device *dev, struct drm_file *file)
  837. {
  838. mutex_lock(&dev->struct_mutex);
  839. i915_gem_context_close(dev, file);
  840. i915_gem_release(dev, file);
  841. mutex_unlock(&dev->struct_mutex);
  842. if (drm_core_check_feature(dev, DRIVER_MODESET))
  843. intel_modeset_preclose(dev, file);
  844. }
  845. void i915_driver_postclose(struct drm_device *dev, struct drm_file *file)
  846. {
  847. struct drm_i915_file_private *file_priv = file->driver_priv;
  848. if (file_priv && file_priv->bsd_ring)
  849. file_priv->bsd_ring = NULL;
  850. kfree(file_priv);
  851. }
  852. const struct drm_ioctl_desc i915_ioctls[] = {
  853. DRM_IOCTL_DEF_DRV(I915_INIT, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
  854. DRM_IOCTL_DEF_DRV(I915_FLUSH, drm_noop, DRM_AUTH),
  855. DRM_IOCTL_DEF_DRV(I915_FLIP, drm_noop, DRM_AUTH),
  856. DRM_IOCTL_DEF_DRV(I915_BATCHBUFFER, drm_noop, DRM_AUTH),
  857. DRM_IOCTL_DEF_DRV(I915_IRQ_EMIT, drm_noop, DRM_AUTH),
  858. DRM_IOCTL_DEF_DRV(I915_IRQ_WAIT, drm_noop, DRM_AUTH),
  859. DRM_IOCTL_DEF_DRV(I915_GETPARAM, i915_getparam, DRM_AUTH|DRM_RENDER_ALLOW),
  860. DRM_IOCTL_DEF_DRV(I915_SETPARAM, i915_setparam, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
  861. DRM_IOCTL_DEF_DRV(I915_ALLOC, drm_noop, DRM_AUTH),
  862. DRM_IOCTL_DEF_DRV(I915_FREE, drm_noop, DRM_AUTH),
  863. DRM_IOCTL_DEF_DRV(I915_INIT_HEAP, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
  864. DRM_IOCTL_DEF_DRV(I915_CMDBUFFER, drm_noop, DRM_AUTH),
  865. DRM_IOCTL_DEF_DRV(I915_DESTROY_HEAP, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
  866. DRM_IOCTL_DEF_DRV(I915_SET_VBLANK_PIPE, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
  867. DRM_IOCTL_DEF_DRV(I915_GET_VBLANK_PIPE, drm_noop, DRM_AUTH),
  868. DRM_IOCTL_DEF_DRV(I915_VBLANK_SWAP, drm_noop, DRM_AUTH),
  869. DRM_IOCTL_DEF_DRV(I915_HWS_ADDR, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
  870. DRM_IOCTL_DEF_DRV(I915_GEM_INIT, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY|DRM_UNLOCKED),
  871. DRM_IOCTL_DEF_DRV(I915_GEM_EXECBUFFER, i915_gem_execbuffer, DRM_AUTH|DRM_UNLOCKED),
  872. DRM_IOCTL_DEF_DRV(I915_GEM_EXECBUFFER2, i915_gem_execbuffer2, DRM_AUTH|DRM_UNLOCKED|DRM_RENDER_ALLOW),
  873. DRM_IOCTL_DEF_DRV(I915_GEM_PIN, i915_gem_pin_ioctl, DRM_AUTH|DRM_ROOT_ONLY|DRM_UNLOCKED),
  874. DRM_IOCTL_DEF_DRV(I915_GEM_UNPIN, i915_gem_unpin_ioctl, DRM_AUTH|DRM_ROOT_ONLY|DRM_UNLOCKED),
  875. DRM_IOCTL_DEF_DRV(I915_GEM_BUSY, i915_gem_busy_ioctl, DRM_AUTH|DRM_UNLOCKED|DRM_RENDER_ALLOW),
  876. DRM_IOCTL_DEF_DRV(I915_GEM_SET_CACHING, i915_gem_set_caching_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW),
  877. DRM_IOCTL_DEF_DRV(I915_GEM_GET_CACHING, i915_gem_get_caching_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW),
  878. DRM_IOCTL_DEF_DRV(I915_GEM_THROTTLE, i915_gem_throttle_ioctl, DRM_AUTH|DRM_UNLOCKED|DRM_RENDER_ALLOW),
  879. DRM_IOCTL_DEF_DRV(I915_GEM_ENTERVT, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY|DRM_UNLOCKED),
  880. DRM_IOCTL_DEF_DRV(I915_GEM_LEAVEVT, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY|DRM_UNLOCKED),
  881. DRM_IOCTL_DEF_DRV(I915_GEM_CREATE, i915_gem_create_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW),
  882. DRM_IOCTL_DEF_DRV(I915_GEM_PREAD, i915_gem_pread_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW),
  883. DRM_IOCTL_DEF_DRV(I915_GEM_PWRITE, i915_gem_pwrite_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW),
  884. DRM_IOCTL_DEF_DRV(I915_GEM_MMAP, i915_gem_mmap_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW),
  885. DRM_IOCTL_DEF_DRV(I915_GEM_MMAP_GTT, i915_gem_mmap_gtt_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW),
  886. DRM_IOCTL_DEF_DRV(I915_GEM_SET_DOMAIN, i915_gem_set_domain_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW),
  887. DRM_IOCTL_DEF_DRV(I915_GEM_SW_FINISH, i915_gem_sw_finish_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW),
  888. DRM_IOCTL_DEF_DRV(I915_GEM_SET_TILING, i915_gem_set_tiling, DRM_UNLOCKED|DRM_RENDER_ALLOW),
  889. DRM_IOCTL_DEF_DRV(I915_GEM_GET_TILING, i915_gem_get_tiling, DRM_UNLOCKED|DRM_RENDER_ALLOW),
  890. DRM_IOCTL_DEF_DRV(I915_GEM_GET_APERTURE, i915_gem_get_aperture_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW),
  891. DRM_IOCTL_DEF_DRV(I915_GET_PIPE_FROM_CRTC_ID, intel_get_pipe_from_crtc_id, DRM_UNLOCKED),
  892. DRM_IOCTL_DEF_DRV(I915_GEM_MADVISE, i915_gem_madvise_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW),
  893. DRM_IOCTL_DEF_DRV(I915_OVERLAY_PUT_IMAGE, intel_overlay_put_image, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
  894. DRM_IOCTL_DEF_DRV(I915_OVERLAY_ATTRS, intel_overlay_attrs, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
  895. DRM_IOCTL_DEF_DRV(I915_SET_SPRITE_COLORKEY, intel_sprite_set_colorkey, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
  896. DRM_IOCTL_DEF_DRV(I915_GET_SPRITE_COLORKEY, intel_sprite_get_colorkey, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
  897. DRM_IOCTL_DEF_DRV(I915_GEM_WAIT, i915_gem_wait_ioctl, DRM_AUTH|DRM_UNLOCKED|DRM_RENDER_ALLOW),
  898. DRM_IOCTL_DEF_DRV(I915_GEM_CONTEXT_CREATE, i915_gem_context_create_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW),
  899. DRM_IOCTL_DEF_DRV(I915_GEM_CONTEXT_DESTROY, i915_gem_context_destroy_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW),
  900. DRM_IOCTL_DEF_DRV(I915_REG_READ, i915_reg_read_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW),
  901. DRM_IOCTL_DEF_DRV(I915_GET_RESET_STATS, i915_get_reset_stats_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW),
  902. DRM_IOCTL_DEF_DRV(I915_GEM_USERPTR, i915_gem_userptr_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW),
  903. };
  904. int i915_max_ioctl = ARRAY_SIZE(i915_ioctls);
  905. /*
  906. * This is really ugly: Because old userspace abused the linux agp interface to
  907. * manage the gtt, we need to claim that all intel devices are agp. For
  908. * otherwise the drm core refuses to initialize the agp support code.
  909. */
  910. int i915_driver_device_is_agp(struct drm_device *dev)
  911. {
  912. return 1;
  913. }