i915_dma.c 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653
  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 <drm/drmP.h>
  30. #include <drm/drm_crtc_helper.h>
  31. #include <drm/drm_fb_helper.h>
  32. #include <drm/drm_legacy.h>
  33. #include "intel_drv.h"
  34. #include <drm/i915_drm.h>
  35. #include "i915_drv.h"
  36. #include "i915_vgpu.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 unsigned int i915_load_fail_count;
  51. bool __i915_inject_load_failure(const char *func, int line)
  52. {
  53. if (i915_load_fail_count >= i915.inject_load_failure)
  54. return false;
  55. if (++i915_load_fail_count == i915.inject_load_failure) {
  56. DRM_INFO("Injecting failure at checkpoint %u [%s:%d]\n",
  57. i915.inject_load_failure, func, line);
  58. return true;
  59. }
  60. return false;
  61. }
  62. #define FDO_BUG_URL "https://bugs.freedesktop.org/enter_bug.cgi?product=DRI"
  63. #define FDO_BUG_MSG "Please file a bug at " FDO_BUG_URL " against DRM/Intel " \
  64. "providing the dmesg log by booting with drm.debug=0xf"
  65. void
  66. __i915_printk(struct drm_i915_private *dev_priv, const char *level,
  67. const char *fmt, ...)
  68. {
  69. static bool shown_bug_once;
  70. struct device *dev = dev_priv->dev->dev;
  71. bool is_error = level[1] <= KERN_ERR[1];
  72. bool is_debug = level[1] == KERN_DEBUG[1];
  73. struct va_format vaf;
  74. va_list args;
  75. if (is_debug && !(drm_debug & DRM_UT_DRIVER))
  76. return;
  77. va_start(args, fmt);
  78. vaf.fmt = fmt;
  79. vaf.va = &args;
  80. dev_printk(level, dev, "[" DRM_NAME ":%ps] %pV",
  81. __builtin_return_address(0), &vaf);
  82. if (is_error && !shown_bug_once) {
  83. dev_notice(dev, "%s", FDO_BUG_MSG);
  84. shown_bug_once = true;
  85. }
  86. va_end(args);
  87. }
  88. static bool i915_error_injected(struct drm_i915_private *dev_priv)
  89. {
  90. return i915.inject_load_failure &&
  91. i915_load_fail_count == i915.inject_load_failure;
  92. }
  93. #define i915_load_error(dev_priv, fmt, ...) \
  94. __i915_printk(dev_priv, \
  95. i915_error_injected(dev_priv) ? KERN_DEBUG : KERN_ERR, \
  96. fmt, ##__VA_ARGS__)
  97. static int i915_getparam(struct drm_device *dev, void *data,
  98. struct drm_file *file_priv)
  99. {
  100. struct drm_i915_private *dev_priv = dev->dev_private;
  101. drm_i915_getparam_t *param = data;
  102. int value;
  103. switch (param->param) {
  104. case I915_PARAM_IRQ_ACTIVE:
  105. case I915_PARAM_ALLOW_BATCHBUFFER:
  106. case I915_PARAM_LAST_DISPATCH:
  107. /* Reject all old ums/dri params. */
  108. return -ENODEV;
  109. case I915_PARAM_CHIPSET_ID:
  110. value = dev->pdev->device;
  111. break;
  112. case I915_PARAM_REVISION:
  113. value = dev->pdev->revision;
  114. break;
  115. case I915_PARAM_HAS_GEM:
  116. value = 1;
  117. break;
  118. case I915_PARAM_NUM_FENCES_AVAIL:
  119. value = dev_priv->num_fence_regs;
  120. break;
  121. case I915_PARAM_HAS_OVERLAY:
  122. value = dev_priv->overlay ? 1 : 0;
  123. break;
  124. case I915_PARAM_HAS_PAGEFLIPPING:
  125. value = 1;
  126. break;
  127. case I915_PARAM_HAS_EXECBUF2:
  128. /* depends on GEM */
  129. value = 1;
  130. break;
  131. case I915_PARAM_HAS_BSD:
  132. value = intel_engine_initialized(&dev_priv->engine[VCS]);
  133. break;
  134. case I915_PARAM_HAS_BLT:
  135. value = intel_engine_initialized(&dev_priv->engine[BCS]);
  136. break;
  137. case I915_PARAM_HAS_VEBOX:
  138. value = intel_engine_initialized(&dev_priv->engine[VECS]);
  139. break;
  140. case I915_PARAM_HAS_BSD2:
  141. value = intel_engine_initialized(&dev_priv->engine[VCS2]);
  142. break;
  143. case I915_PARAM_HAS_RELAXED_FENCING:
  144. value = 1;
  145. break;
  146. case I915_PARAM_HAS_COHERENT_RINGS:
  147. value = 1;
  148. break;
  149. case I915_PARAM_HAS_EXEC_CONSTANTS:
  150. value = INTEL_INFO(dev)->gen >= 4;
  151. break;
  152. case I915_PARAM_HAS_RELAXED_DELTA:
  153. value = 1;
  154. break;
  155. case I915_PARAM_HAS_GEN7_SOL_RESET:
  156. value = 1;
  157. break;
  158. case I915_PARAM_HAS_LLC:
  159. value = HAS_LLC(dev);
  160. break;
  161. case I915_PARAM_HAS_WT:
  162. value = HAS_WT(dev);
  163. break;
  164. case I915_PARAM_HAS_ALIASING_PPGTT:
  165. value = USES_PPGTT(dev);
  166. break;
  167. case I915_PARAM_HAS_WAIT_TIMEOUT:
  168. value = 1;
  169. break;
  170. case I915_PARAM_HAS_SEMAPHORES:
  171. value = i915_semaphore_is_enabled(dev_priv);
  172. break;
  173. case I915_PARAM_HAS_PRIME_VMAP_FLUSH:
  174. value = 1;
  175. break;
  176. case I915_PARAM_HAS_SECURE_BATCHES:
  177. value = capable(CAP_SYS_ADMIN);
  178. break;
  179. case I915_PARAM_HAS_PINNED_BATCHES:
  180. value = 1;
  181. break;
  182. case I915_PARAM_HAS_EXEC_NO_RELOC:
  183. value = 1;
  184. break;
  185. case I915_PARAM_HAS_EXEC_HANDLE_LUT:
  186. value = 1;
  187. break;
  188. case I915_PARAM_CMD_PARSER_VERSION:
  189. value = i915_cmd_parser_get_version(dev_priv);
  190. break;
  191. case I915_PARAM_HAS_COHERENT_PHYS_GTT:
  192. value = 1;
  193. break;
  194. case I915_PARAM_MMAP_VERSION:
  195. value = 1;
  196. break;
  197. case I915_PARAM_SUBSLICE_TOTAL:
  198. value = INTEL_INFO(dev)->subslice_total;
  199. if (!value)
  200. return -ENODEV;
  201. break;
  202. case I915_PARAM_EU_TOTAL:
  203. value = INTEL_INFO(dev)->eu_total;
  204. if (!value)
  205. return -ENODEV;
  206. break;
  207. case I915_PARAM_HAS_GPU_RESET:
  208. value = i915.enable_hangcheck && intel_has_gpu_reset(dev_priv);
  209. break;
  210. case I915_PARAM_HAS_RESOURCE_STREAMER:
  211. value = HAS_RESOURCE_STREAMER(dev);
  212. break;
  213. case I915_PARAM_HAS_EXEC_SOFTPIN:
  214. value = 1;
  215. break;
  216. default:
  217. DRM_DEBUG("Unknown parameter %d\n", param->param);
  218. return -EINVAL;
  219. }
  220. if (copy_to_user(param->value, &value, sizeof(int))) {
  221. DRM_ERROR("copy_to_user failed\n");
  222. return -EFAULT;
  223. }
  224. return 0;
  225. }
  226. static int i915_get_bridge_dev(struct drm_device *dev)
  227. {
  228. struct drm_i915_private *dev_priv = dev->dev_private;
  229. dev_priv->bridge_dev = pci_get_bus_and_slot(0, PCI_DEVFN(0, 0));
  230. if (!dev_priv->bridge_dev) {
  231. DRM_ERROR("bridge device not found\n");
  232. return -1;
  233. }
  234. return 0;
  235. }
  236. /* Allocate space for the MCH regs if needed, return nonzero on error */
  237. static int
  238. intel_alloc_mchbar_resource(struct drm_device *dev)
  239. {
  240. struct drm_i915_private *dev_priv = dev->dev_private;
  241. int reg = INTEL_INFO(dev)->gen >= 4 ? MCHBAR_I965 : MCHBAR_I915;
  242. u32 temp_lo, temp_hi = 0;
  243. u64 mchbar_addr;
  244. int ret;
  245. if (INTEL_INFO(dev)->gen >= 4)
  246. pci_read_config_dword(dev_priv->bridge_dev, reg + 4, &temp_hi);
  247. pci_read_config_dword(dev_priv->bridge_dev, reg, &temp_lo);
  248. mchbar_addr = ((u64)temp_hi << 32) | temp_lo;
  249. /* If ACPI doesn't have it, assume we need to allocate it ourselves */
  250. #ifdef CONFIG_PNP
  251. if (mchbar_addr &&
  252. pnp_range_reserved(mchbar_addr, mchbar_addr + MCHBAR_SIZE))
  253. return 0;
  254. #endif
  255. /* Get some space for it */
  256. dev_priv->mch_res.name = "i915 MCHBAR";
  257. dev_priv->mch_res.flags = IORESOURCE_MEM;
  258. ret = pci_bus_alloc_resource(dev_priv->bridge_dev->bus,
  259. &dev_priv->mch_res,
  260. MCHBAR_SIZE, MCHBAR_SIZE,
  261. PCIBIOS_MIN_MEM,
  262. 0, pcibios_align_resource,
  263. dev_priv->bridge_dev);
  264. if (ret) {
  265. DRM_DEBUG_DRIVER("failed bus alloc: %d\n", ret);
  266. dev_priv->mch_res.start = 0;
  267. return ret;
  268. }
  269. if (INTEL_INFO(dev)->gen >= 4)
  270. pci_write_config_dword(dev_priv->bridge_dev, reg + 4,
  271. upper_32_bits(dev_priv->mch_res.start));
  272. pci_write_config_dword(dev_priv->bridge_dev, reg,
  273. lower_32_bits(dev_priv->mch_res.start));
  274. return 0;
  275. }
  276. /* Setup MCHBAR if possible, return true if we should disable it again */
  277. static void
  278. intel_setup_mchbar(struct drm_device *dev)
  279. {
  280. struct drm_i915_private *dev_priv = dev->dev_private;
  281. int mchbar_reg = INTEL_INFO(dev)->gen >= 4 ? MCHBAR_I965 : MCHBAR_I915;
  282. u32 temp;
  283. bool enabled;
  284. if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev))
  285. return;
  286. dev_priv->mchbar_need_disable = false;
  287. if (IS_I915G(dev) || IS_I915GM(dev)) {
  288. pci_read_config_dword(dev_priv->bridge_dev, DEVEN, &temp);
  289. enabled = !!(temp & DEVEN_MCHBAR_EN);
  290. } else {
  291. pci_read_config_dword(dev_priv->bridge_dev, mchbar_reg, &temp);
  292. enabled = temp & 1;
  293. }
  294. /* If it's already enabled, don't have to do anything */
  295. if (enabled)
  296. return;
  297. if (intel_alloc_mchbar_resource(dev))
  298. return;
  299. dev_priv->mchbar_need_disable = true;
  300. /* Space is allocated or reserved, so enable it. */
  301. if (IS_I915G(dev) || IS_I915GM(dev)) {
  302. pci_write_config_dword(dev_priv->bridge_dev, DEVEN,
  303. temp | DEVEN_MCHBAR_EN);
  304. } else {
  305. pci_read_config_dword(dev_priv->bridge_dev, mchbar_reg, &temp);
  306. pci_write_config_dword(dev_priv->bridge_dev, mchbar_reg, temp | 1);
  307. }
  308. }
  309. static void
  310. intel_teardown_mchbar(struct drm_device *dev)
  311. {
  312. struct drm_i915_private *dev_priv = dev->dev_private;
  313. int mchbar_reg = INTEL_INFO(dev)->gen >= 4 ? MCHBAR_I965 : MCHBAR_I915;
  314. if (dev_priv->mchbar_need_disable) {
  315. if (IS_I915G(dev) || IS_I915GM(dev)) {
  316. u32 deven_val;
  317. pci_read_config_dword(dev_priv->bridge_dev, DEVEN,
  318. &deven_val);
  319. deven_val &= ~DEVEN_MCHBAR_EN;
  320. pci_write_config_dword(dev_priv->bridge_dev, DEVEN,
  321. deven_val);
  322. } else {
  323. u32 mchbar_val;
  324. pci_read_config_dword(dev_priv->bridge_dev, mchbar_reg,
  325. &mchbar_val);
  326. mchbar_val &= ~1;
  327. pci_write_config_dword(dev_priv->bridge_dev, mchbar_reg,
  328. mchbar_val);
  329. }
  330. }
  331. if (dev_priv->mch_res.start)
  332. release_resource(&dev_priv->mch_res);
  333. }
  334. /* true = enable decode, false = disable decoder */
  335. static unsigned int i915_vga_set_decode(void *cookie, bool state)
  336. {
  337. struct drm_device *dev = cookie;
  338. intel_modeset_vga_set_state(dev, state);
  339. if (state)
  340. return VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM |
  341. VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
  342. else
  343. return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
  344. }
  345. static void i915_switcheroo_set_state(struct pci_dev *pdev, enum vga_switcheroo_state state)
  346. {
  347. struct drm_device *dev = pci_get_drvdata(pdev);
  348. pm_message_t pmm = { .event = PM_EVENT_SUSPEND };
  349. if (state == VGA_SWITCHEROO_ON) {
  350. pr_info("switched on\n");
  351. dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
  352. /* i915 resume handler doesn't set to D0 */
  353. pci_set_power_state(dev->pdev, PCI_D0);
  354. i915_resume_switcheroo(dev);
  355. dev->switch_power_state = DRM_SWITCH_POWER_ON;
  356. } else {
  357. pr_info("switched off\n");
  358. dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
  359. i915_suspend_switcheroo(dev, pmm);
  360. dev->switch_power_state = DRM_SWITCH_POWER_OFF;
  361. }
  362. }
  363. static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
  364. {
  365. struct drm_device *dev = pci_get_drvdata(pdev);
  366. /*
  367. * FIXME: open_count is protected by drm_global_mutex but that would lead to
  368. * locking inversion with the driver load path. And the access here is
  369. * completely racy anyway. So don't bother with locking for now.
  370. */
  371. return dev->open_count == 0;
  372. }
  373. static const struct vga_switcheroo_client_ops i915_switcheroo_ops = {
  374. .set_gpu_state = i915_switcheroo_set_state,
  375. .reprobe = NULL,
  376. .can_switch = i915_switcheroo_can_switch,
  377. };
  378. static void i915_gem_fini(struct drm_device *dev)
  379. {
  380. struct drm_i915_private *dev_priv = to_i915(dev);
  381. /*
  382. * Neither the BIOS, ourselves or any other kernel
  383. * expects the system to be in execlists mode on startup,
  384. * so we need to reset the GPU back to legacy mode. And the only
  385. * known way to disable logical contexts is through a GPU reset.
  386. *
  387. * So in order to leave the system in a known default configuration,
  388. * always reset the GPU upon unload. Afterwards we then clean up the
  389. * GEM state tracking, flushing off the requests and leaving the
  390. * system in a known idle state.
  391. *
  392. * Note that is of the upmost importance that the GPU is idle and
  393. * all stray writes are flushed *before* we dismantle the backing
  394. * storage for the pinned objects.
  395. *
  396. * However, since we are uncertain that reseting the GPU on older
  397. * machines is a good idea, we don't - just in case it leaves the
  398. * machine in an unusable condition.
  399. */
  400. if (HAS_HW_CONTEXTS(dev)) {
  401. int reset = intel_gpu_reset(dev_priv, ALL_ENGINES);
  402. WARN_ON(reset && reset != -ENODEV);
  403. }
  404. mutex_lock(&dev->struct_mutex);
  405. i915_gem_reset(dev);
  406. i915_gem_cleanup_engines(dev);
  407. i915_gem_context_fini(dev);
  408. mutex_unlock(&dev->struct_mutex);
  409. WARN_ON(!list_empty(&to_i915(dev)->context_list));
  410. }
  411. static int i915_load_modeset_init(struct drm_device *dev)
  412. {
  413. struct drm_i915_private *dev_priv = dev->dev_private;
  414. int ret;
  415. if (i915_inject_load_failure())
  416. return -ENODEV;
  417. ret = intel_bios_init(dev_priv);
  418. if (ret)
  419. DRM_INFO("failed to find VBIOS tables\n");
  420. /* If we have > 1 VGA cards, then we need to arbitrate access
  421. * to the common VGA resources.
  422. *
  423. * If we are a secondary display controller (!PCI_DISPLAY_CLASS_VGA),
  424. * then we do not take part in VGA arbitration and the
  425. * vga_client_register() fails with -ENODEV.
  426. */
  427. ret = vga_client_register(dev->pdev, dev, NULL, i915_vga_set_decode);
  428. if (ret && ret != -ENODEV)
  429. goto out;
  430. intel_register_dsm_handler();
  431. ret = vga_switcheroo_register_client(dev->pdev, &i915_switcheroo_ops, false);
  432. if (ret)
  433. goto cleanup_vga_client;
  434. /* must happen before intel_power_domains_init_hw() on VLV/CHV */
  435. intel_update_rawclk(dev_priv);
  436. intel_power_domains_init_hw(dev_priv, false);
  437. intel_csr_ucode_init(dev_priv);
  438. ret = intel_irq_install(dev_priv);
  439. if (ret)
  440. goto cleanup_csr;
  441. intel_setup_gmbus(dev);
  442. /* Important: The output setup functions called by modeset_init need
  443. * working irqs for e.g. gmbus and dp aux transfers. */
  444. intel_modeset_init(dev);
  445. intel_guc_init(dev);
  446. ret = i915_gem_init(dev);
  447. if (ret)
  448. goto cleanup_irq;
  449. intel_modeset_gem_init(dev);
  450. if (INTEL_INFO(dev)->num_pipes == 0)
  451. return 0;
  452. ret = intel_fbdev_init(dev);
  453. if (ret)
  454. goto cleanup_gem;
  455. /* Only enable hotplug handling once the fbdev is fully set up. */
  456. intel_hpd_init(dev_priv);
  457. /*
  458. * Some ports require correctly set-up hpd registers for detection to
  459. * work properly (leading to ghost connected connector status), e.g. VGA
  460. * on gm45. Hence we can only set up the initial fbdev config after hpd
  461. * irqs are fully enabled. Now we should scan for the initial config
  462. * only once hotplug handling is enabled, but due to screwed-up locking
  463. * around kms/fbdev init we can't protect the fdbev initial config
  464. * scanning against hotplug events. Hence do this first and ignore the
  465. * tiny window where we will loose hotplug notifactions.
  466. */
  467. intel_fbdev_initial_config_async(dev);
  468. drm_kms_helper_poll_init(dev);
  469. return 0;
  470. cleanup_gem:
  471. i915_gem_fini(dev);
  472. cleanup_irq:
  473. intel_guc_fini(dev);
  474. drm_irq_uninstall(dev);
  475. intel_teardown_gmbus(dev);
  476. cleanup_csr:
  477. intel_csr_ucode_fini(dev_priv);
  478. intel_power_domains_fini(dev_priv);
  479. vga_switcheroo_unregister_client(dev->pdev);
  480. cleanup_vga_client:
  481. vga_client_register(dev->pdev, NULL, NULL, NULL);
  482. out:
  483. return ret;
  484. }
  485. #if IS_ENABLED(CONFIG_FB)
  486. static int i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)
  487. {
  488. struct apertures_struct *ap;
  489. struct pci_dev *pdev = dev_priv->dev->pdev;
  490. struct i915_ggtt *ggtt = &dev_priv->ggtt;
  491. bool primary;
  492. int ret;
  493. ap = alloc_apertures(1);
  494. if (!ap)
  495. return -ENOMEM;
  496. ap->ranges[0].base = ggtt->mappable_base;
  497. ap->ranges[0].size = ggtt->mappable_end;
  498. primary =
  499. pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
  500. ret = remove_conflicting_framebuffers(ap, "inteldrmfb", primary);
  501. kfree(ap);
  502. return ret;
  503. }
  504. #else
  505. static int i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)
  506. {
  507. return 0;
  508. }
  509. #endif
  510. #if !defined(CONFIG_VGA_CONSOLE)
  511. static int i915_kick_out_vgacon(struct drm_i915_private *dev_priv)
  512. {
  513. return 0;
  514. }
  515. #elif !defined(CONFIG_DUMMY_CONSOLE)
  516. static int i915_kick_out_vgacon(struct drm_i915_private *dev_priv)
  517. {
  518. return -ENODEV;
  519. }
  520. #else
  521. static int i915_kick_out_vgacon(struct drm_i915_private *dev_priv)
  522. {
  523. int ret = 0;
  524. DRM_INFO("Replacing VGA console driver\n");
  525. console_lock();
  526. if (con_is_bound(&vga_con))
  527. ret = do_take_over_console(&dummy_con, 0, MAX_NR_CONSOLES - 1, 1);
  528. if (ret == 0) {
  529. ret = do_unregister_con_driver(&vga_con);
  530. /* Ignore "already unregistered". */
  531. if (ret == -ENODEV)
  532. ret = 0;
  533. }
  534. console_unlock();
  535. return ret;
  536. }
  537. #endif
  538. static void i915_dump_device_info(struct drm_i915_private *dev_priv)
  539. {
  540. const struct intel_device_info *info = &dev_priv->info;
  541. #define PRINT_S(name) "%s"
  542. #define SEP_EMPTY
  543. #define PRINT_FLAG(name) info->name ? #name "," : ""
  544. #define SEP_COMMA ,
  545. DRM_DEBUG_DRIVER("i915 device info: gen=%i, pciid=0x%04x rev=0x%02x flags="
  546. DEV_INFO_FOR_EACH_FLAG(PRINT_S, SEP_EMPTY),
  547. info->gen,
  548. dev_priv->dev->pdev->device,
  549. dev_priv->dev->pdev->revision,
  550. DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG, SEP_COMMA));
  551. #undef PRINT_S
  552. #undef SEP_EMPTY
  553. #undef PRINT_FLAG
  554. #undef SEP_COMMA
  555. }
  556. static void cherryview_sseu_info_init(struct drm_device *dev)
  557. {
  558. struct drm_i915_private *dev_priv = dev->dev_private;
  559. struct intel_device_info *info;
  560. u32 fuse, eu_dis;
  561. info = (struct intel_device_info *)&dev_priv->info;
  562. fuse = I915_READ(CHV_FUSE_GT);
  563. info->slice_total = 1;
  564. if (!(fuse & CHV_FGT_DISABLE_SS0)) {
  565. info->subslice_per_slice++;
  566. eu_dis = fuse & (CHV_FGT_EU_DIS_SS0_R0_MASK |
  567. CHV_FGT_EU_DIS_SS0_R1_MASK);
  568. info->eu_total += 8 - hweight32(eu_dis);
  569. }
  570. if (!(fuse & CHV_FGT_DISABLE_SS1)) {
  571. info->subslice_per_slice++;
  572. eu_dis = fuse & (CHV_FGT_EU_DIS_SS1_R0_MASK |
  573. CHV_FGT_EU_DIS_SS1_R1_MASK);
  574. info->eu_total += 8 - hweight32(eu_dis);
  575. }
  576. info->subslice_total = info->subslice_per_slice;
  577. /*
  578. * CHV expected to always have a uniform distribution of EU
  579. * across subslices.
  580. */
  581. info->eu_per_subslice = info->subslice_total ?
  582. info->eu_total / info->subslice_total :
  583. 0;
  584. /*
  585. * CHV supports subslice power gating on devices with more than
  586. * one subslice, and supports EU power gating on devices with
  587. * more than one EU pair per subslice.
  588. */
  589. info->has_slice_pg = 0;
  590. info->has_subslice_pg = (info->subslice_total > 1);
  591. info->has_eu_pg = (info->eu_per_subslice > 2);
  592. }
  593. static void gen9_sseu_info_init(struct drm_device *dev)
  594. {
  595. struct drm_i915_private *dev_priv = dev->dev_private;
  596. struct intel_device_info *info;
  597. int s_max = 3, ss_max = 4, eu_max = 8;
  598. int s, ss;
  599. u32 fuse2, s_enable, ss_disable, eu_disable;
  600. u8 eu_mask = 0xff;
  601. info = (struct intel_device_info *)&dev_priv->info;
  602. fuse2 = I915_READ(GEN8_FUSE2);
  603. s_enable = (fuse2 & GEN8_F2_S_ENA_MASK) >>
  604. GEN8_F2_S_ENA_SHIFT;
  605. ss_disable = (fuse2 & GEN9_F2_SS_DIS_MASK) >>
  606. GEN9_F2_SS_DIS_SHIFT;
  607. info->slice_total = hweight32(s_enable);
  608. /*
  609. * The subslice disable field is global, i.e. it applies
  610. * to each of the enabled slices.
  611. */
  612. info->subslice_per_slice = ss_max - hweight32(ss_disable);
  613. info->subslice_total = info->slice_total *
  614. info->subslice_per_slice;
  615. /*
  616. * Iterate through enabled slices and subslices to
  617. * count the total enabled EU.
  618. */
  619. for (s = 0; s < s_max; s++) {
  620. if (!(s_enable & (0x1 << s)))
  621. /* skip disabled slice */
  622. continue;
  623. eu_disable = I915_READ(GEN9_EU_DISABLE(s));
  624. for (ss = 0; ss < ss_max; ss++) {
  625. int eu_per_ss;
  626. if (ss_disable & (0x1 << ss))
  627. /* skip disabled subslice */
  628. continue;
  629. eu_per_ss = eu_max - hweight8((eu_disable >> (ss*8)) &
  630. eu_mask);
  631. /*
  632. * Record which subslice(s) has(have) 7 EUs. we
  633. * can tune the hash used to spread work among
  634. * subslices if they are unbalanced.
  635. */
  636. if (eu_per_ss == 7)
  637. info->subslice_7eu[s] |= 1 << ss;
  638. info->eu_total += eu_per_ss;
  639. }
  640. }
  641. /*
  642. * SKL is expected to always have a uniform distribution
  643. * of EU across subslices with the exception that any one
  644. * EU in any one subslice may be fused off for die
  645. * recovery. BXT is expected to be perfectly uniform in EU
  646. * distribution.
  647. */
  648. info->eu_per_subslice = info->subslice_total ?
  649. DIV_ROUND_UP(info->eu_total,
  650. info->subslice_total) : 0;
  651. /*
  652. * SKL supports slice power gating on devices with more than
  653. * one slice, and supports EU power gating on devices with
  654. * more than one EU pair per subslice. BXT supports subslice
  655. * power gating on devices with more than one subslice, and
  656. * supports EU power gating on devices with more than one EU
  657. * pair per subslice.
  658. */
  659. info->has_slice_pg = ((IS_SKYLAKE(dev) || IS_KABYLAKE(dev)) &&
  660. (info->slice_total > 1));
  661. info->has_subslice_pg = (IS_BROXTON(dev) && (info->subslice_total > 1));
  662. info->has_eu_pg = (info->eu_per_subslice > 2);
  663. }
  664. static void broadwell_sseu_info_init(struct drm_device *dev)
  665. {
  666. struct drm_i915_private *dev_priv = dev->dev_private;
  667. struct intel_device_info *info;
  668. const int s_max = 3, ss_max = 3, eu_max = 8;
  669. int s, ss;
  670. u32 fuse2, eu_disable[s_max], s_enable, ss_disable;
  671. fuse2 = I915_READ(GEN8_FUSE2);
  672. s_enable = (fuse2 & GEN8_F2_S_ENA_MASK) >> GEN8_F2_S_ENA_SHIFT;
  673. ss_disable = (fuse2 & GEN8_F2_SS_DIS_MASK) >> GEN8_F2_SS_DIS_SHIFT;
  674. eu_disable[0] = I915_READ(GEN8_EU_DISABLE0) & GEN8_EU_DIS0_S0_MASK;
  675. eu_disable[1] = (I915_READ(GEN8_EU_DISABLE0) >> GEN8_EU_DIS0_S1_SHIFT) |
  676. ((I915_READ(GEN8_EU_DISABLE1) & GEN8_EU_DIS1_S1_MASK) <<
  677. (32 - GEN8_EU_DIS0_S1_SHIFT));
  678. eu_disable[2] = (I915_READ(GEN8_EU_DISABLE1) >> GEN8_EU_DIS1_S2_SHIFT) |
  679. ((I915_READ(GEN8_EU_DISABLE2) & GEN8_EU_DIS2_S2_MASK) <<
  680. (32 - GEN8_EU_DIS1_S2_SHIFT));
  681. info = (struct intel_device_info *)&dev_priv->info;
  682. info->slice_total = hweight32(s_enable);
  683. /*
  684. * The subslice disable field is global, i.e. it applies
  685. * to each of the enabled slices.
  686. */
  687. info->subslice_per_slice = ss_max - hweight32(ss_disable);
  688. info->subslice_total = info->slice_total * info->subslice_per_slice;
  689. /*
  690. * Iterate through enabled slices and subslices to
  691. * count the total enabled EU.
  692. */
  693. for (s = 0; s < s_max; s++) {
  694. if (!(s_enable & (0x1 << s)))
  695. /* skip disabled slice */
  696. continue;
  697. for (ss = 0; ss < ss_max; ss++) {
  698. u32 n_disabled;
  699. if (ss_disable & (0x1 << ss))
  700. /* skip disabled subslice */
  701. continue;
  702. n_disabled = hweight8(eu_disable[s] >> (ss * eu_max));
  703. /*
  704. * Record which subslices have 7 EUs.
  705. */
  706. if (eu_max - n_disabled == 7)
  707. info->subslice_7eu[s] |= 1 << ss;
  708. info->eu_total += eu_max - n_disabled;
  709. }
  710. }
  711. /*
  712. * BDW is expected to always have a uniform distribution of EU across
  713. * subslices with the exception that any one EU in any one subslice may
  714. * be fused off for die recovery.
  715. */
  716. info->eu_per_subslice = info->subslice_total ?
  717. DIV_ROUND_UP(info->eu_total, info->subslice_total) : 0;
  718. /*
  719. * BDW supports slice power gating on devices with more than
  720. * one slice.
  721. */
  722. info->has_slice_pg = (info->slice_total > 1);
  723. info->has_subslice_pg = 0;
  724. info->has_eu_pg = 0;
  725. }
  726. /*
  727. * Determine various intel_device_info fields at runtime.
  728. *
  729. * Use it when either:
  730. * - it's judged too laborious to fill n static structures with the limit
  731. * when a simple if statement does the job,
  732. * - run-time checks (eg read fuse/strap registers) are needed.
  733. *
  734. * This function needs to be called:
  735. * - after the MMIO has been setup as we are reading registers,
  736. * - after the PCH has been detected,
  737. * - before the first usage of the fields it can tweak.
  738. */
  739. static void intel_device_info_runtime_init(struct drm_device *dev)
  740. {
  741. struct drm_i915_private *dev_priv = dev->dev_private;
  742. struct intel_device_info *info;
  743. enum pipe pipe;
  744. info = (struct intel_device_info *)&dev_priv->info;
  745. /*
  746. * Skylake and Broxton currently don't expose the topmost plane as its
  747. * use is exclusive with the legacy cursor and we only want to expose
  748. * one of those, not both. Until we can safely expose the topmost plane
  749. * as a DRM_PLANE_TYPE_CURSOR with all the features exposed/supported,
  750. * we don't expose the topmost plane at all to prevent ABI breakage
  751. * down the line.
  752. */
  753. if (IS_BROXTON(dev)) {
  754. info->num_sprites[PIPE_A] = 2;
  755. info->num_sprites[PIPE_B] = 2;
  756. info->num_sprites[PIPE_C] = 1;
  757. } else if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev))
  758. for_each_pipe(dev_priv, pipe)
  759. info->num_sprites[pipe] = 2;
  760. else
  761. for_each_pipe(dev_priv, pipe)
  762. info->num_sprites[pipe] = 1;
  763. if (i915.disable_display) {
  764. DRM_INFO("Display disabled (module parameter)\n");
  765. info->num_pipes = 0;
  766. } else if (info->num_pipes > 0 &&
  767. (IS_GEN7(dev_priv) || IS_GEN8(dev_priv)) &&
  768. HAS_PCH_SPLIT(dev)) {
  769. u32 fuse_strap = I915_READ(FUSE_STRAP);
  770. u32 sfuse_strap = I915_READ(SFUSE_STRAP);
  771. /*
  772. * SFUSE_STRAP is supposed to have a bit signalling the display
  773. * is fused off. Unfortunately it seems that, at least in
  774. * certain cases, fused off display means that PCH display
  775. * reads don't land anywhere. In that case, we read 0s.
  776. *
  777. * On CPT/PPT, we can detect this case as SFUSE_STRAP_FUSE_LOCK
  778. * should be set when taking over after the firmware.
  779. */
  780. if (fuse_strap & ILK_INTERNAL_DISPLAY_DISABLE ||
  781. sfuse_strap & SFUSE_STRAP_DISPLAY_DISABLED ||
  782. (dev_priv->pch_type == PCH_CPT &&
  783. !(sfuse_strap & SFUSE_STRAP_FUSE_LOCK))) {
  784. DRM_INFO("Display fused off, disabling\n");
  785. info->num_pipes = 0;
  786. } else if (fuse_strap & IVB_PIPE_C_DISABLE) {
  787. DRM_INFO("PipeC fused off\n");
  788. info->num_pipes -= 1;
  789. }
  790. } else if (info->num_pipes > 0 && IS_GEN9(dev_priv)) {
  791. u32 dfsm = I915_READ(SKL_DFSM);
  792. u8 disabled_mask = 0;
  793. bool invalid;
  794. int num_bits;
  795. if (dfsm & SKL_DFSM_PIPE_A_DISABLE)
  796. disabled_mask |= BIT(PIPE_A);
  797. if (dfsm & SKL_DFSM_PIPE_B_DISABLE)
  798. disabled_mask |= BIT(PIPE_B);
  799. if (dfsm & SKL_DFSM_PIPE_C_DISABLE)
  800. disabled_mask |= BIT(PIPE_C);
  801. num_bits = hweight8(disabled_mask);
  802. switch (disabled_mask) {
  803. case BIT(PIPE_A):
  804. case BIT(PIPE_B):
  805. case BIT(PIPE_A) | BIT(PIPE_B):
  806. case BIT(PIPE_A) | BIT(PIPE_C):
  807. invalid = true;
  808. break;
  809. default:
  810. invalid = false;
  811. }
  812. if (num_bits > info->num_pipes || invalid)
  813. DRM_ERROR("invalid pipe fuse configuration: 0x%x\n",
  814. disabled_mask);
  815. else
  816. info->num_pipes -= num_bits;
  817. }
  818. /* Initialize slice/subslice/EU info */
  819. if (IS_CHERRYVIEW(dev))
  820. cherryview_sseu_info_init(dev);
  821. else if (IS_BROADWELL(dev))
  822. broadwell_sseu_info_init(dev);
  823. else if (INTEL_INFO(dev)->gen >= 9)
  824. gen9_sseu_info_init(dev);
  825. info->has_snoop = !info->has_llc;
  826. /* Snooping is broken on BXT A stepping. */
  827. if (IS_BXT_REVID(dev, 0, BXT_REVID_A1))
  828. info->has_snoop = false;
  829. DRM_DEBUG_DRIVER("slice total: %u\n", info->slice_total);
  830. DRM_DEBUG_DRIVER("subslice total: %u\n", info->subslice_total);
  831. DRM_DEBUG_DRIVER("subslice per slice: %u\n", info->subslice_per_slice);
  832. DRM_DEBUG_DRIVER("EU total: %u\n", info->eu_total);
  833. DRM_DEBUG_DRIVER("EU per subslice: %u\n", info->eu_per_subslice);
  834. DRM_DEBUG_DRIVER("has slice power gating: %s\n",
  835. info->has_slice_pg ? "y" : "n");
  836. DRM_DEBUG_DRIVER("has subslice power gating: %s\n",
  837. info->has_subslice_pg ? "y" : "n");
  838. DRM_DEBUG_DRIVER("has EU power gating: %s\n",
  839. info->has_eu_pg ? "y" : "n");
  840. i915.enable_execlists =
  841. intel_sanitize_enable_execlists(dev_priv,
  842. i915.enable_execlists);
  843. /*
  844. * i915.enable_ppgtt is read-only, so do an early pass to validate the
  845. * user's requested state against the hardware/driver capabilities. We
  846. * do this now so that we can print out any log messages once rather
  847. * than every time we check intel_enable_ppgtt().
  848. */
  849. i915.enable_ppgtt =
  850. intel_sanitize_enable_ppgtt(dev_priv, i915.enable_ppgtt);
  851. DRM_DEBUG_DRIVER("ppgtt mode: %i\n", i915.enable_ppgtt);
  852. }
  853. static void intel_init_dpio(struct drm_i915_private *dev_priv)
  854. {
  855. /*
  856. * IOSF_PORT_DPIO is used for VLV x2 PHY (DP/HDMI B and C),
  857. * CHV x1 PHY (DP/HDMI D)
  858. * IOSF_PORT_DPIO_2 is used for CHV x2 PHY (DP/HDMI B and C)
  859. */
  860. if (IS_CHERRYVIEW(dev_priv)) {
  861. DPIO_PHY_IOSF_PORT(DPIO_PHY0) = IOSF_PORT_DPIO_2;
  862. DPIO_PHY_IOSF_PORT(DPIO_PHY1) = IOSF_PORT_DPIO;
  863. } else if (IS_VALLEYVIEW(dev_priv)) {
  864. DPIO_PHY_IOSF_PORT(DPIO_PHY0) = IOSF_PORT_DPIO;
  865. }
  866. }
  867. static int i915_workqueues_init(struct drm_i915_private *dev_priv)
  868. {
  869. /*
  870. * The i915 workqueue is primarily used for batched retirement of
  871. * requests (and thus managing bo) once the task has been completed
  872. * by the GPU. i915_gem_retire_requests() is called directly when we
  873. * need high-priority retirement, such as waiting for an explicit
  874. * bo.
  875. *
  876. * It is also used for periodic low-priority events, such as
  877. * idle-timers and recording error state.
  878. *
  879. * All tasks on the workqueue are expected to acquire the dev mutex
  880. * so there is no point in running more than one instance of the
  881. * workqueue at any time. Use an ordered one.
  882. */
  883. dev_priv->wq = alloc_ordered_workqueue("i915", 0);
  884. if (dev_priv->wq == NULL)
  885. goto out_err;
  886. dev_priv->hotplug.dp_wq = alloc_ordered_workqueue("i915-dp", 0);
  887. if (dev_priv->hotplug.dp_wq == NULL)
  888. goto out_free_wq;
  889. dev_priv->gpu_error.hangcheck_wq =
  890. alloc_ordered_workqueue("i915-hangcheck", 0);
  891. if (dev_priv->gpu_error.hangcheck_wq == NULL)
  892. goto out_free_dp_wq;
  893. return 0;
  894. out_free_dp_wq:
  895. destroy_workqueue(dev_priv->hotplug.dp_wq);
  896. out_free_wq:
  897. destroy_workqueue(dev_priv->wq);
  898. out_err:
  899. DRM_ERROR("Failed to allocate workqueues.\n");
  900. return -ENOMEM;
  901. }
  902. static void i915_workqueues_cleanup(struct drm_i915_private *dev_priv)
  903. {
  904. destroy_workqueue(dev_priv->gpu_error.hangcheck_wq);
  905. destroy_workqueue(dev_priv->hotplug.dp_wq);
  906. destroy_workqueue(dev_priv->wq);
  907. }
  908. /**
  909. * i915_driver_init_early - setup state not requiring device access
  910. * @dev_priv: device private
  911. *
  912. * Initialize everything that is a "SW-only" state, that is state not
  913. * requiring accessing the device or exposing the driver via kernel internal
  914. * or userspace interfaces. Example steps belonging here: lock initialization,
  915. * system memory allocation, setting up device specific attributes and
  916. * function hooks not requiring accessing the device.
  917. */
  918. static int i915_driver_init_early(struct drm_i915_private *dev_priv,
  919. struct drm_device *dev,
  920. struct intel_device_info *info)
  921. {
  922. struct intel_device_info *device_info;
  923. int ret = 0;
  924. if (i915_inject_load_failure())
  925. return -ENODEV;
  926. /* Setup the write-once "constant" device info */
  927. device_info = (struct intel_device_info *)&dev_priv->info;
  928. memcpy(device_info, info, sizeof(dev_priv->info));
  929. device_info->device_id = dev->pdev->device;
  930. BUG_ON(device_info->gen > sizeof(device_info->gen_mask) * BITS_PER_BYTE);
  931. device_info->gen_mask = BIT(device_info->gen - 1);
  932. spin_lock_init(&dev_priv->irq_lock);
  933. spin_lock_init(&dev_priv->gpu_error.lock);
  934. mutex_init(&dev_priv->backlight_lock);
  935. spin_lock_init(&dev_priv->uncore.lock);
  936. spin_lock_init(&dev_priv->mm.object_stat_lock);
  937. spin_lock_init(&dev_priv->mmio_flip_lock);
  938. mutex_init(&dev_priv->sb_lock);
  939. mutex_init(&dev_priv->modeset_restore_lock);
  940. mutex_init(&dev_priv->av_mutex);
  941. mutex_init(&dev_priv->wm.wm_mutex);
  942. mutex_init(&dev_priv->pps_mutex);
  943. ret = i915_workqueues_init(dev_priv);
  944. if (ret < 0)
  945. return ret;
  946. /* This must be called before any calls to HAS_PCH_* */
  947. intel_detect_pch(dev);
  948. intel_pm_setup(dev);
  949. intel_init_dpio(dev_priv);
  950. intel_power_domains_init(dev_priv);
  951. intel_irq_init(dev_priv);
  952. intel_init_display_hooks(dev_priv);
  953. intel_init_clock_gating_hooks(dev_priv);
  954. intel_init_audio_hooks(dev_priv);
  955. i915_gem_load_init(dev);
  956. intel_display_crc_init(dev);
  957. i915_dump_device_info(dev_priv);
  958. /* Not all pre-production machines fall into this category, only the
  959. * very first ones. Almost everything should work, except for maybe
  960. * suspend/resume. And we don't implement workarounds that affect only
  961. * pre-production machines. */
  962. if (IS_HSW_EARLY_SDV(dev))
  963. DRM_INFO("This is an early pre-production Haswell machine. "
  964. "It may not be fully functional.\n");
  965. return 0;
  966. }
  967. /**
  968. * i915_driver_cleanup_early - cleanup the setup done in i915_driver_init_early()
  969. * @dev_priv: device private
  970. */
  971. static void i915_driver_cleanup_early(struct drm_i915_private *dev_priv)
  972. {
  973. i915_gem_load_cleanup(dev_priv->dev);
  974. i915_workqueues_cleanup(dev_priv);
  975. }
  976. static int i915_mmio_setup(struct drm_device *dev)
  977. {
  978. struct drm_i915_private *dev_priv = to_i915(dev);
  979. int mmio_bar;
  980. int mmio_size;
  981. mmio_bar = IS_GEN2(dev) ? 1 : 0;
  982. /*
  983. * Before gen4, the registers and the GTT are behind different BARs.
  984. * However, from gen4 onwards, the registers and the GTT are shared
  985. * in the same BAR, so we want to restrict this ioremap from
  986. * clobbering the GTT which we want ioremap_wc instead. Fortunately,
  987. * the register BAR remains the same size for all the earlier
  988. * generations up to Ironlake.
  989. */
  990. if (INTEL_INFO(dev)->gen < 5)
  991. mmio_size = 512 * 1024;
  992. else
  993. mmio_size = 2 * 1024 * 1024;
  994. dev_priv->regs = pci_iomap(dev->pdev, mmio_bar, mmio_size);
  995. if (dev_priv->regs == NULL) {
  996. DRM_ERROR("failed to map registers\n");
  997. return -EIO;
  998. }
  999. /* Try to make sure MCHBAR is enabled before poking at it */
  1000. intel_setup_mchbar(dev);
  1001. return 0;
  1002. }
  1003. static void i915_mmio_cleanup(struct drm_device *dev)
  1004. {
  1005. struct drm_i915_private *dev_priv = to_i915(dev);
  1006. intel_teardown_mchbar(dev);
  1007. pci_iounmap(dev->pdev, dev_priv->regs);
  1008. }
  1009. /**
  1010. * i915_driver_init_mmio - setup device MMIO
  1011. * @dev_priv: device private
  1012. *
  1013. * Setup minimal device state necessary for MMIO accesses later in the
  1014. * initialization sequence. The setup here should avoid any other device-wide
  1015. * side effects or exposing the driver via kernel internal or user space
  1016. * interfaces.
  1017. */
  1018. static int i915_driver_init_mmio(struct drm_i915_private *dev_priv)
  1019. {
  1020. struct drm_device *dev = dev_priv->dev;
  1021. int ret;
  1022. if (i915_inject_load_failure())
  1023. return -ENODEV;
  1024. if (i915_get_bridge_dev(dev))
  1025. return -EIO;
  1026. ret = i915_mmio_setup(dev);
  1027. if (ret < 0)
  1028. goto put_bridge;
  1029. intel_uncore_init(dev_priv);
  1030. return 0;
  1031. put_bridge:
  1032. pci_dev_put(dev_priv->bridge_dev);
  1033. return ret;
  1034. }
  1035. /**
  1036. * i915_driver_cleanup_mmio - cleanup the setup done in i915_driver_init_mmio()
  1037. * @dev_priv: device private
  1038. */
  1039. static void i915_driver_cleanup_mmio(struct drm_i915_private *dev_priv)
  1040. {
  1041. struct drm_device *dev = dev_priv->dev;
  1042. intel_uncore_fini(dev_priv);
  1043. i915_mmio_cleanup(dev);
  1044. pci_dev_put(dev_priv->bridge_dev);
  1045. }
  1046. /**
  1047. * i915_driver_init_hw - setup state requiring device access
  1048. * @dev_priv: device private
  1049. *
  1050. * Setup state that requires accessing the device, but doesn't require
  1051. * exposing the driver via kernel internal or userspace interfaces.
  1052. */
  1053. static int i915_driver_init_hw(struct drm_i915_private *dev_priv)
  1054. {
  1055. struct drm_device *dev = dev_priv->dev;
  1056. struct i915_ggtt *ggtt = &dev_priv->ggtt;
  1057. uint32_t aperture_size;
  1058. int ret;
  1059. if (i915_inject_load_failure())
  1060. return -ENODEV;
  1061. intel_device_info_runtime_init(dev);
  1062. ret = i915_ggtt_init_hw(dev);
  1063. if (ret)
  1064. return ret;
  1065. ret = i915_ggtt_enable_hw(dev);
  1066. if (ret) {
  1067. DRM_ERROR("failed to enable GGTT\n");
  1068. goto out_ggtt;
  1069. }
  1070. /* WARNING: Apparently we must kick fbdev drivers before vgacon,
  1071. * otherwise the vga fbdev driver falls over. */
  1072. ret = i915_kick_out_firmware_fb(dev_priv);
  1073. if (ret) {
  1074. DRM_ERROR("failed to remove conflicting framebuffer drivers\n");
  1075. goto out_ggtt;
  1076. }
  1077. ret = i915_kick_out_vgacon(dev_priv);
  1078. if (ret) {
  1079. DRM_ERROR("failed to remove conflicting VGA console\n");
  1080. goto out_ggtt;
  1081. }
  1082. pci_set_master(dev->pdev);
  1083. /* overlay on gen2 is broken and can't address above 1G */
  1084. if (IS_GEN2(dev)) {
  1085. ret = dma_set_coherent_mask(&dev->pdev->dev, DMA_BIT_MASK(30));
  1086. if (ret) {
  1087. DRM_ERROR("failed to set DMA mask\n");
  1088. goto out_ggtt;
  1089. }
  1090. }
  1091. /* 965GM sometimes incorrectly writes to hardware status page (HWS)
  1092. * using 32bit addressing, overwriting memory if HWS is located
  1093. * above 4GB.
  1094. *
  1095. * The documentation also mentions an issue with undefined
  1096. * behaviour if any general state is accessed within a page above 4GB,
  1097. * which also needs to be handled carefully.
  1098. */
  1099. if (IS_BROADWATER(dev) || IS_CRESTLINE(dev)) {
  1100. ret = dma_set_coherent_mask(&dev->pdev->dev, DMA_BIT_MASK(32));
  1101. if (ret) {
  1102. DRM_ERROR("failed to set DMA mask\n");
  1103. goto out_ggtt;
  1104. }
  1105. }
  1106. aperture_size = ggtt->mappable_end;
  1107. ggtt->mappable =
  1108. io_mapping_create_wc(ggtt->mappable_base,
  1109. aperture_size);
  1110. if (!ggtt->mappable) {
  1111. ret = -EIO;
  1112. goto out_ggtt;
  1113. }
  1114. ggtt->mtrr = arch_phys_wc_add(ggtt->mappable_base,
  1115. aperture_size);
  1116. pm_qos_add_request(&dev_priv->pm_qos, PM_QOS_CPU_DMA_LATENCY,
  1117. PM_QOS_DEFAULT_VALUE);
  1118. intel_uncore_sanitize(dev_priv);
  1119. intel_opregion_setup(dev_priv);
  1120. i915_gem_load_init_fences(dev_priv);
  1121. /* On the 945G/GM, the chipset reports the MSI capability on the
  1122. * integrated graphics even though the support isn't actually there
  1123. * according to the published specs. It doesn't appear to function
  1124. * correctly in testing on 945G.
  1125. * This may be a side effect of MSI having been made available for PEG
  1126. * and the registers being closely associated.
  1127. *
  1128. * According to chipset errata, on the 965GM, MSI interrupts may
  1129. * be lost or delayed, but we use them anyways to avoid
  1130. * stuck interrupts on some machines.
  1131. */
  1132. if (!IS_I945G(dev) && !IS_I945GM(dev)) {
  1133. if (pci_enable_msi(dev->pdev) < 0)
  1134. DRM_DEBUG_DRIVER("can't enable MSI");
  1135. }
  1136. return 0;
  1137. out_ggtt:
  1138. i915_ggtt_cleanup_hw(dev);
  1139. return ret;
  1140. }
  1141. /**
  1142. * i915_driver_cleanup_hw - cleanup the setup done in i915_driver_init_hw()
  1143. * @dev_priv: device private
  1144. */
  1145. static void i915_driver_cleanup_hw(struct drm_i915_private *dev_priv)
  1146. {
  1147. struct drm_device *dev = dev_priv->dev;
  1148. struct i915_ggtt *ggtt = &dev_priv->ggtt;
  1149. if (dev->pdev->msi_enabled)
  1150. pci_disable_msi(dev->pdev);
  1151. pm_qos_remove_request(&dev_priv->pm_qos);
  1152. arch_phys_wc_del(ggtt->mtrr);
  1153. io_mapping_free(ggtt->mappable);
  1154. i915_ggtt_cleanup_hw(dev);
  1155. }
  1156. /**
  1157. * i915_driver_register - register the driver with the rest of the system
  1158. * @dev_priv: device private
  1159. *
  1160. * Perform any steps necessary to make the driver available via kernel
  1161. * internal or userspace interfaces.
  1162. */
  1163. static void i915_driver_register(struct drm_i915_private *dev_priv)
  1164. {
  1165. struct drm_device *dev = dev_priv->dev;
  1166. i915_gem_shrinker_init(dev_priv);
  1167. /*
  1168. * Notify a valid surface after modesetting,
  1169. * when running inside a VM.
  1170. */
  1171. if (intel_vgpu_active(dev_priv))
  1172. I915_WRITE(vgtif_reg(display_ready), VGT_DRV_DISPLAY_READY);
  1173. i915_setup_sysfs(dev);
  1174. if (INTEL_INFO(dev_priv)->num_pipes) {
  1175. /* Must be done after probing outputs */
  1176. intel_opregion_register(dev_priv);
  1177. acpi_video_register();
  1178. }
  1179. if (IS_GEN5(dev_priv))
  1180. intel_gpu_ips_init(dev_priv);
  1181. i915_audio_component_init(dev_priv);
  1182. }
  1183. /**
  1184. * i915_driver_unregister - cleanup the registration done in i915_driver_regiser()
  1185. * @dev_priv: device private
  1186. */
  1187. static void i915_driver_unregister(struct drm_i915_private *dev_priv)
  1188. {
  1189. i915_audio_component_cleanup(dev_priv);
  1190. intel_gpu_ips_teardown();
  1191. acpi_video_unregister();
  1192. intel_opregion_unregister(dev_priv);
  1193. i915_teardown_sysfs(dev_priv->dev);
  1194. i915_gem_shrinker_cleanup(dev_priv);
  1195. }
  1196. /**
  1197. * i915_driver_load - setup chip and create an initial config
  1198. * @dev: DRM device
  1199. * @flags: startup flags
  1200. *
  1201. * The driver load routine has to do several things:
  1202. * - drive output discovery via intel_modeset_init()
  1203. * - initialize the memory manager
  1204. * - allocate initial config memory
  1205. * - setup the DRM framebuffer with the allocated memory
  1206. */
  1207. int i915_driver_load(struct drm_device *dev, unsigned long flags)
  1208. {
  1209. struct drm_i915_private *dev_priv;
  1210. int ret = 0;
  1211. dev_priv = kzalloc(sizeof(*dev_priv), GFP_KERNEL);
  1212. if (dev_priv == NULL)
  1213. return -ENOMEM;
  1214. dev->dev_private = dev_priv;
  1215. /* Must be set before calling __i915_printk */
  1216. dev_priv->dev = dev;
  1217. ret = i915_driver_init_early(dev_priv, dev,
  1218. (struct intel_device_info *)flags);
  1219. if (ret < 0)
  1220. goto out_free_priv;
  1221. intel_runtime_pm_get(dev_priv);
  1222. ret = i915_driver_init_mmio(dev_priv);
  1223. if (ret < 0)
  1224. goto out_runtime_pm_put;
  1225. ret = i915_driver_init_hw(dev_priv);
  1226. if (ret < 0)
  1227. goto out_cleanup_mmio;
  1228. /*
  1229. * TODO: move the vblank init and parts of modeset init steps into one
  1230. * of the i915_driver_init_/i915_driver_register functions according
  1231. * to the role/effect of the given init step.
  1232. */
  1233. if (INTEL_INFO(dev)->num_pipes) {
  1234. ret = drm_vblank_init(dev, INTEL_INFO(dev)->num_pipes);
  1235. if (ret)
  1236. goto out_cleanup_hw;
  1237. }
  1238. ret = i915_load_modeset_init(dev);
  1239. if (ret < 0)
  1240. goto out_cleanup_vblank;
  1241. i915_driver_register(dev_priv);
  1242. intel_runtime_pm_enable(dev_priv);
  1243. intel_runtime_pm_put(dev_priv);
  1244. return 0;
  1245. out_cleanup_vblank:
  1246. drm_vblank_cleanup(dev);
  1247. out_cleanup_hw:
  1248. i915_driver_cleanup_hw(dev_priv);
  1249. out_cleanup_mmio:
  1250. i915_driver_cleanup_mmio(dev_priv);
  1251. out_runtime_pm_put:
  1252. intel_runtime_pm_put(dev_priv);
  1253. i915_driver_cleanup_early(dev_priv);
  1254. out_free_priv:
  1255. i915_load_error(dev_priv, "Device initialization failed (%d)\n", ret);
  1256. kfree(dev_priv);
  1257. return ret;
  1258. }
  1259. int i915_driver_unload(struct drm_device *dev)
  1260. {
  1261. struct drm_i915_private *dev_priv = dev->dev_private;
  1262. int ret;
  1263. intel_fbdev_fini(dev);
  1264. ret = i915_gem_suspend(dev);
  1265. if (ret) {
  1266. DRM_ERROR("failed to idle hardware: %d\n", ret);
  1267. return ret;
  1268. }
  1269. intel_display_power_get(dev_priv, POWER_DOMAIN_INIT);
  1270. i915_driver_unregister(dev_priv);
  1271. drm_vblank_cleanup(dev);
  1272. intel_modeset_cleanup(dev);
  1273. /*
  1274. * free the memory space allocated for the child device
  1275. * config parsed from VBT
  1276. */
  1277. if (dev_priv->vbt.child_dev && dev_priv->vbt.child_dev_num) {
  1278. kfree(dev_priv->vbt.child_dev);
  1279. dev_priv->vbt.child_dev = NULL;
  1280. dev_priv->vbt.child_dev_num = 0;
  1281. }
  1282. kfree(dev_priv->vbt.sdvo_lvds_vbt_mode);
  1283. dev_priv->vbt.sdvo_lvds_vbt_mode = NULL;
  1284. kfree(dev_priv->vbt.lfp_lvds_vbt_mode);
  1285. dev_priv->vbt.lfp_lvds_vbt_mode = NULL;
  1286. vga_switcheroo_unregister_client(dev->pdev);
  1287. vga_client_register(dev->pdev, NULL, NULL, NULL);
  1288. intel_csr_ucode_fini(dev_priv);
  1289. /* Free error state after interrupts are fully disabled. */
  1290. cancel_delayed_work_sync(&dev_priv->gpu_error.hangcheck_work);
  1291. i915_destroy_error_state(dev);
  1292. /* Flush any outstanding unpin_work. */
  1293. flush_workqueue(dev_priv->wq);
  1294. intel_guc_fini(dev);
  1295. i915_gem_fini(dev);
  1296. intel_fbc_cleanup_cfb(dev_priv);
  1297. intel_power_domains_fini(dev_priv);
  1298. i915_driver_cleanup_hw(dev_priv);
  1299. i915_driver_cleanup_mmio(dev_priv);
  1300. intel_display_power_put(dev_priv, POWER_DOMAIN_INIT);
  1301. i915_driver_cleanup_early(dev_priv);
  1302. kfree(dev_priv);
  1303. return 0;
  1304. }
  1305. int i915_driver_open(struct drm_device *dev, struct drm_file *file)
  1306. {
  1307. int ret;
  1308. ret = i915_gem_open(dev, file);
  1309. if (ret)
  1310. return ret;
  1311. return 0;
  1312. }
  1313. /**
  1314. * i915_driver_lastclose - clean up after all DRM clients have exited
  1315. * @dev: DRM device
  1316. *
  1317. * Take care of cleaning up after all DRM clients have exited. In the
  1318. * mode setting case, we want to restore the kernel's initial mode (just
  1319. * in case the last client left us in a bad state).
  1320. *
  1321. * Additionally, in the non-mode setting case, we'll tear down the GTT
  1322. * and DMA structures, since the kernel won't be using them, and clea
  1323. * up any GEM state.
  1324. */
  1325. void i915_driver_lastclose(struct drm_device *dev)
  1326. {
  1327. intel_fbdev_restore_mode(dev);
  1328. vga_switcheroo_process_delayed_switch();
  1329. }
  1330. void i915_driver_preclose(struct drm_device *dev, struct drm_file *file)
  1331. {
  1332. mutex_lock(&dev->struct_mutex);
  1333. i915_gem_context_close(dev, file);
  1334. i915_gem_release(dev, file);
  1335. mutex_unlock(&dev->struct_mutex);
  1336. }
  1337. void i915_driver_postclose(struct drm_device *dev, struct drm_file *file)
  1338. {
  1339. struct drm_i915_file_private *file_priv = file->driver_priv;
  1340. kfree(file_priv);
  1341. }
  1342. static int
  1343. i915_gem_reject_pin_ioctl(struct drm_device *dev, void *data,
  1344. struct drm_file *file)
  1345. {
  1346. return -ENODEV;
  1347. }
  1348. const struct drm_ioctl_desc i915_ioctls[] = {
  1349. DRM_IOCTL_DEF_DRV(I915_INIT, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
  1350. DRM_IOCTL_DEF_DRV(I915_FLUSH, drm_noop, DRM_AUTH),
  1351. DRM_IOCTL_DEF_DRV(I915_FLIP, drm_noop, DRM_AUTH),
  1352. DRM_IOCTL_DEF_DRV(I915_BATCHBUFFER, drm_noop, DRM_AUTH),
  1353. DRM_IOCTL_DEF_DRV(I915_IRQ_EMIT, drm_noop, DRM_AUTH),
  1354. DRM_IOCTL_DEF_DRV(I915_IRQ_WAIT, drm_noop, DRM_AUTH),
  1355. DRM_IOCTL_DEF_DRV(I915_GETPARAM, i915_getparam, DRM_AUTH|DRM_RENDER_ALLOW),
  1356. DRM_IOCTL_DEF_DRV(I915_SETPARAM, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
  1357. DRM_IOCTL_DEF_DRV(I915_ALLOC, drm_noop, DRM_AUTH),
  1358. DRM_IOCTL_DEF_DRV(I915_FREE, drm_noop, DRM_AUTH),
  1359. DRM_IOCTL_DEF_DRV(I915_INIT_HEAP, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
  1360. DRM_IOCTL_DEF_DRV(I915_CMDBUFFER, drm_noop, DRM_AUTH),
  1361. DRM_IOCTL_DEF_DRV(I915_DESTROY_HEAP, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
  1362. DRM_IOCTL_DEF_DRV(I915_SET_VBLANK_PIPE, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
  1363. DRM_IOCTL_DEF_DRV(I915_GET_VBLANK_PIPE, drm_noop, DRM_AUTH),
  1364. DRM_IOCTL_DEF_DRV(I915_VBLANK_SWAP, drm_noop, DRM_AUTH),
  1365. DRM_IOCTL_DEF_DRV(I915_HWS_ADDR, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
  1366. DRM_IOCTL_DEF_DRV(I915_GEM_INIT, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
  1367. DRM_IOCTL_DEF_DRV(I915_GEM_EXECBUFFER, i915_gem_execbuffer, DRM_AUTH),
  1368. DRM_IOCTL_DEF_DRV(I915_GEM_EXECBUFFER2, i915_gem_execbuffer2, DRM_AUTH|DRM_RENDER_ALLOW),
  1369. DRM_IOCTL_DEF_DRV(I915_GEM_PIN, i915_gem_reject_pin_ioctl, DRM_AUTH|DRM_ROOT_ONLY),
  1370. DRM_IOCTL_DEF_DRV(I915_GEM_UNPIN, i915_gem_reject_pin_ioctl, DRM_AUTH|DRM_ROOT_ONLY),
  1371. DRM_IOCTL_DEF_DRV(I915_GEM_BUSY, i915_gem_busy_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
  1372. DRM_IOCTL_DEF_DRV(I915_GEM_SET_CACHING, i915_gem_set_caching_ioctl, DRM_RENDER_ALLOW),
  1373. DRM_IOCTL_DEF_DRV(I915_GEM_GET_CACHING, i915_gem_get_caching_ioctl, DRM_RENDER_ALLOW),
  1374. DRM_IOCTL_DEF_DRV(I915_GEM_THROTTLE, i915_gem_throttle_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
  1375. DRM_IOCTL_DEF_DRV(I915_GEM_ENTERVT, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
  1376. DRM_IOCTL_DEF_DRV(I915_GEM_LEAVEVT, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
  1377. DRM_IOCTL_DEF_DRV(I915_GEM_CREATE, i915_gem_create_ioctl, DRM_RENDER_ALLOW),
  1378. DRM_IOCTL_DEF_DRV(I915_GEM_PREAD, i915_gem_pread_ioctl, DRM_RENDER_ALLOW),
  1379. DRM_IOCTL_DEF_DRV(I915_GEM_PWRITE, i915_gem_pwrite_ioctl, DRM_RENDER_ALLOW),
  1380. DRM_IOCTL_DEF_DRV(I915_GEM_MMAP, i915_gem_mmap_ioctl, DRM_RENDER_ALLOW),
  1381. DRM_IOCTL_DEF_DRV(I915_GEM_MMAP_GTT, i915_gem_mmap_gtt_ioctl, DRM_RENDER_ALLOW),
  1382. DRM_IOCTL_DEF_DRV(I915_GEM_SET_DOMAIN, i915_gem_set_domain_ioctl, DRM_RENDER_ALLOW),
  1383. DRM_IOCTL_DEF_DRV(I915_GEM_SW_FINISH, i915_gem_sw_finish_ioctl, DRM_RENDER_ALLOW),
  1384. DRM_IOCTL_DEF_DRV(I915_GEM_SET_TILING, i915_gem_set_tiling, DRM_RENDER_ALLOW),
  1385. DRM_IOCTL_DEF_DRV(I915_GEM_GET_TILING, i915_gem_get_tiling, DRM_RENDER_ALLOW),
  1386. DRM_IOCTL_DEF_DRV(I915_GEM_GET_APERTURE, i915_gem_get_aperture_ioctl, DRM_RENDER_ALLOW),
  1387. DRM_IOCTL_DEF_DRV(I915_GET_PIPE_FROM_CRTC_ID, intel_get_pipe_from_crtc_id, 0),
  1388. DRM_IOCTL_DEF_DRV(I915_GEM_MADVISE, i915_gem_madvise_ioctl, DRM_RENDER_ALLOW),
  1389. DRM_IOCTL_DEF_DRV(I915_OVERLAY_PUT_IMAGE, intel_overlay_put_image_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW),
  1390. DRM_IOCTL_DEF_DRV(I915_OVERLAY_ATTRS, intel_overlay_attrs_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW),
  1391. DRM_IOCTL_DEF_DRV(I915_SET_SPRITE_COLORKEY, intel_sprite_set_colorkey, DRM_MASTER|DRM_CONTROL_ALLOW),
  1392. DRM_IOCTL_DEF_DRV(I915_GET_SPRITE_COLORKEY, drm_noop, DRM_MASTER|DRM_CONTROL_ALLOW),
  1393. DRM_IOCTL_DEF_DRV(I915_GEM_WAIT, i915_gem_wait_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
  1394. DRM_IOCTL_DEF_DRV(I915_GEM_CONTEXT_CREATE, i915_gem_context_create_ioctl, DRM_RENDER_ALLOW),
  1395. DRM_IOCTL_DEF_DRV(I915_GEM_CONTEXT_DESTROY, i915_gem_context_destroy_ioctl, DRM_RENDER_ALLOW),
  1396. DRM_IOCTL_DEF_DRV(I915_REG_READ, i915_reg_read_ioctl, DRM_RENDER_ALLOW),
  1397. DRM_IOCTL_DEF_DRV(I915_GET_RESET_STATS, i915_gem_context_reset_stats_ioctl, DRM_RENDER_ALLOW),
  1398. DRM_IOCTL_DEF_DRV(I915_GEM_USERPTR, i915_gem_userptr_ioctl, DRM_RENDER_ALLOW),
  1399. DRM_IOCTL_DEF_DRV(I915_GEM_CONTEXT_GETPARAM, i915_gem_context_getparam_ioctl, DRM_RENDER_ALLOW),
  1400. DRM_IOCTL_DEF_DRV(I915_GEM_CONTEXT_SETPARAM, i915_gem_context_setparam_ioctl, DRM_RENDER_ALLOW),
  1401. };
  1402. int i915_max_ioctl = ARRAY_SIZE(i915_ioctls);